1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-28 16:01:18 +01:00

shell: adapt 6ctx command for NIB

This somehow was left by the wayside when we moved from the old ND to
the NIB. Also piggybacks some fixes.
This commit is contained in:
Martine Lenders 2018-02-16 12:22:15 +01:00
parent 95254990d0
commit ed0fbbb2a3
3 changed files with 12 additions and 12 deletions

View File

@ -44,7 +44,7 @@ ifneq (,$(filter gnrc_rpl,$(USEMODULE)))
SRC += sc_gnrc_rpl.c
endif
ifneq (,$(filter gnrc_sixlowpan_ctx,$(USEMODULE)))
ifneq (,$(filter gnrc_sixlowpan_nd_border_router,$(USEMODULE)))
ifneq (,$(filter gnrc_ipv6_nib_6lbr,$(USEMODULE)))
SRC += sc_gnrc_6ctx.c
endif
endif

View File

@ -21,7 +21,7 @@
#include "net/ipv6/addr.h"
#include "net/gnrc/sixlowpan/ctx.h"
#include "net/gnrc/sixlowpan/nd.h"
#include "net/sixlowpan/nd.h"
#include "timex.h"
#include "xtimer.h"
@ -45,13 +45,14 @@ int _gnrc_6ctx_list(void)
{
puts("cid|prefix |C|ltime");
puts("-----------------------------------------------------------");
for (uint8_t i = 0; i < GNRC_SIXLOWPAN_CTX_SIZE; i++) {
gnrc_sixlowpan_ctx_t *ctx = gnrc_sixlowpan_ctx_lookup_id(i);
for (uint8_t cid = 0; cid < GNRC_SIXLOWPAN_CTX_SIZE; cid++) {
gnrc_sixlowpan_ctx_t *ctx = gnrc_sixlowpan_ctx_lookup_id(cid);
if (ctx != NULL) {
char addr_str[IPV6_ADDR_MAX_STR_LEN];
printf(" %2" PRIu8 "|%39s/%-3" PRIu8 "|%" PRIx8 "|%5" PRIu16 " min\n", i,
ipv6_addr_to_str(addr_str, &ctx->prefix, sizeof(addr_str)), ctx->prefix_len,
(uint8_t) ((ctx->flags_id & 0xf0) >> 4), ctx->ltime);
printf(" %2u|%39s/%-3u|%x|%5umin\n", cid,
ipv6_addr_to_str(addr_str, &ctx->prefix, sizeof(addr_str)),
ctx->prefix_len, (uint8_t) ((ctx->flags_id & 0xf0) >> 4),
ctx->ltime);
}
}
return 0;
@ -112,15 +113,14 @@ int _gnrc_6ctx_del(char *cmd_str, char *ctx_str)
ctx->ltime = 0;
del_timer[cid].callback = _del_cb;
del_timer[cid].arg = ctx;
xtimer_set(&del_timer[cid], GNRC_SIXLOWPAN_ND_RTR_MIN_CTX_DELAY * US_PER_SEC);
xtimer_set(&del_timer[cid],
SIXLOWPAN_ND_MIN_CTX_CHANGE_SEC_DELAY * US_PER_SEC);
}
}
else {
printf("Context %u already marked for removal\n", cid);
return 1;
}
/* advertise updated context */
_adv_ctx();
return 0;
}

View File

@ -113,7 +113,7 @@ extern int _gnrc_rpl(int argc, char **argv);
#endif
#ifdef MODULE_GNRC_SIXLOWPAN_CTX
#ifdef MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER
#ifdef MODULE_GNRC_IPV6_NIB_6LBR
extern int _gnrc_6ctx(int argc, char **argv);
#endif
#endif
@ -203,7 +203,7 @@ const shell_command_t _shell_command_list[] = {
{"rpl", "rpl configuration tool ('rpl help' for more information)", _gnrc_rpl },
#endif
#ifdef MODULE_GNRC_SIXLOWPAN_CTX
#ifdef MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER
#ifdef MODULE_GNRC_IPV6_NIB_6LBR
{"6ctx", "6LoWPAN context configuration tool", _gnrc_6ctx },
#endif
#endif