Search code examples
contikitexas-instrumentscontiki-ngrpl6lowpan

How to get routes of the DODAG at the root?


I'm using contiki-ng with the TI Simplelink CC1310 and with RPL in non-storing mode and my objective is to get the routes of the DODAG at the root of the network in order to know which nodes are accessible by the root directly or indirectly (via another hops).

enter image description here

I see that in the contiki-ng wiki, in the rpl tutorial, there is some track about how to do this, but using the shell. My plan is to do it using code.

Thank you in advance!


Solution

  • It depends if you're using storing mode RPL or non-storing mode RPL.

    In the former case you iterate over the uIPv6 route list (defined in file os/net/ipv6/uip-ds6-route.c):

    uip_ds6_route_t *route = uip_ds6_route_head();
    while(route != NULL) {
      /* ... do something with the route ... */
      route = uip_ds6_route_next(route);
    }
    

    For the non-storing mode RPL, you need to iterate over the source routing table instead (from os/net/ipv6/uip-sr.c):

    uip_sr_node_t* route = uip_sr_node_head();
    while(route != NULL) {
      /* ... do something with the route ... */
      route = uip_sr_node_next(route);
    }