From 59e8d059c265c5487f23a2520a6d6ed44c6cd5fd Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 18 May 2018 05:52:33 -0700 Subject: [PATCH] RPL: print links at root periodically --- os/net/routing/rpl-lite/rpl-dag-root.c | 23 +++++++++++++++++++++++ os/net/routing/rpl-lite/rpl-dag-root.h | 6 ++++++ os/net/routing/rpl-lite/rpl-timers.c | 1 + 3 files changed, 30 insertions(+) diff --git a/os/net/routing/rpl-lite/rpl-dag-root.c b/os/net/routing/rpl-lite/rpl-dag-root.c index 0d5cebe92..c96fd6656 100644 --- a/os/net/routing/rpl-lite/rpl-dag-root.c +++ b/os/net/routing/rpl-lite/rpl-dag-root.c @@ -42,12 +42,35 @@ #include "net/routing/rpl-lite/rpl.h" #include "net/ipv6/uip-ds6-route.h" +#include "net/ipv6/uip-sr.h" /* Log configuration */ #include "sys/log.h" #define LOG_MODULE "RPL" #define LOG_LEVEL LOG_LEVEL_RPL +/*---------------------------------------------------------------------------*/ +void +rpl_dag_root_print_links(const char *str) +{ + if(rpl_dag_root_is_root()) { + if(uip_sr_num_nodes() > 0) { + uip_sr_node_t *link; + /* Our routing links */ + LOG_INFO("links: %u routing links in total (%s)\n", uip_sr_num_nodes(), str); + link = uip_sr_node_head(); + while(link != NULL) { + char buf[100]; + uip_sr_link_snprint(buf, sizeof(buf), link); + LOG_INFO("links: %s\n", buf); + link = uip_sr_node_next(link); + } + LOG_INFO("links: end of list\n"); + } else { + LOG_INFO("No routing links\n"); + } + } +} /*---------------------------------------------------------------------------*/ static void set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid) diff --git a/os/net/routing/rpl-lite/rpl-dag-root.h b/os/net/routing/rpl-lite/rpl-dag-root.h index af0048c4d..71b999765 100644 --- a/os/net/routing/rpl-lite/rpl-dag-root.h +++ b/os/net/routing/rpl-lite/rpl-dag-root.h @@ -63,6 +63,12 @@ int rpl_dag_root_start(void); * \return 1 if we are dag root, 0 otherwise */ int rpl_dag_root_is_root(void); +/** + * Prints a summary of all routing links + * + * \param str A descriptive text on the caller +*/ +void rpl_dag_root_print_links(const char *str); /** @} */ diff --git a/os/net/routing/rpl-lite/rpl-timers.c b/os/net/routing/rpl-lite/rpl-timers.c index 6fb00ca17..c41b92948 100644 --- a/os/net/routing/rpl-lite/rpl-timers.c +++ b/os/net/routing/rpl-lite/rpl-timers.c @@ -521,6 +521,7 @@ handle_periodic_timer(void *ptr) if(LOG_INFO_ENABLED) { rpl_neighbor_print_list("Periodic"); + rpl_dag_root_print_links("Periodic"); } ctimer_reset(&periodic_timer);