From c8c8a183d9273c711ab1cbef3b20e3feddf85d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= Date: Mon, 24 Aug 2015 10:27:04 +0200 Subject: [PATCH] rpl: p2p-rpl shell extension --- sys/shell/commands/sc_gnrc_rpl.c | 43 ++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/sys/shell/commands/sc_gnrc_rpl.c b/sys/shell/commands/sc_gnrc_rpl.c index c3fce2c68f..eb3e339a2f 100644 --- a/sys/shell/commands/sc_gnrc_rpl.c +++ b/sys/shell/commands/sc_gnrc_rpl.c @@ -23,6 +23,11 @@ #include "net/gnrc/rpl/dodag.h" #include "utlist.h" #include "trickle.h" +#ifdef MODULE_GNRC_RPL_P2P +#include "net/gnrc/rpl/p2p.h" +#include "net/gnrc/rpl/p2p_dodag.h" +#include "net/gnrc/rpl/p2p_structs.h" +#endif int _gnrc_rpl_init(char *arg) { @@ -80,8 +85,7 @@ int _gnrc_rpl_find(char *arg1, char *arg2) return 1; } - gnrc_rpl_instance_t *instance = NULL; - if ((instance = gnrc_rpl_p2p_root_init(0, &dodag_id, &target, true)) == NULL) { + if (gnrc_rpl_p2p_root_init(0, &dodag_id, &target, true) == NULL) { char addr_str[IPV6_ADDR_MAX_STR_LEN]; printf("error: could not add DODAG (%s) to instance (%d)\n", ipv6_addr_to_str(addr_str, &dodag_id, sizeof(addr_str)), instance_id); @@ -203,7 +207,22 @@ int _gnrc_rpl_dodag_show(void) } putchar('\t'); } + putchar('\n'); + +#ifdef MODULE_GNRC_RPL_P2P + printf("p2p-rpl table:\t"); + for (int8_t i = 0; i < GNRC_RPL_P2P_EXTS_NUMOF; ++i) { + if (gnrc_rpl_p2p_exts[i].state == 0) { + printf("[ ]"); + } + else { + printf("[X]"); + } + putchar('\t'); + } +#endif + putchar('\n'); gnrc_rpl_dodag_t *dodag = NULL; @@ -241,6 +260,16 @@ int _gnrc_rpl_dodag_show(void) (int) cleanup, (1 << dodag->dio_min), dodag->dio_interval_doubl, dodag->trickle.k, dodag->trickle.c, (uint32_t) (tc & 0xFFFFFFFF), (uint32_t) (ti & 0xFFFFFFFF)); +#ifdef MODULE_GNRC_RPL_P2P + if (dodag->instance->mop == GNRC_RPL_P2P_MOP) { + gnrc_rpl_p2p_ext_t *p2p_ext = gnrc_rpl_p2p_ext_get(dodag); + printf("\tP2P-Ext [%s | HBH: %s | R: %s | L: %us]\n", + ipv6_addr_to_str(addr_str, &p2p_ext->target, sizeof(addr_str)), + p2p_ext->hop_by_hop ? "True" : "False", + p2p_ext->reply ? "True" : "False", p2p_ext->lifetime_sec); + } +#endif + gnrc_rpl_parent_t *parent; LL_FOREACH(gnrc_rpl_instances[i].dodag.parents, parent) { printf("\t\tparent [addr: %s | rank: %d | lifetime: %" PRIu32 "s]\n", @@ -347,7 +376,17 @@ int _gnrc_rpl(int argc, char **argv) #endif } } +#ifdef MODULE_GNRC_RPL_P2P + else if (strcmp(argv[1], "find") == 0) { + if (argc == 4) { + return _gnrc_rpl_find(argv[2], argv[3]); + } + } +#endif +#ifdef MODULE_GNRC_RPL_P2P + puts("* find \t\t\t- initiate a P2P-RPL route discovery"); +#endif puts("* help\t\t\t\t\t- show usage"); puts("* init \t\t\t\t- initialize RPL on the given interface"); puts("* leaf \t\t\t- operate as leaf in the instance");