diff --git a/apps/webserver/httpd-cgi.c b/apps/webserver/httpd-cgi.c index f1cf87bbf..85ce3a521 100644 --- a/apps/webserver/httpd-cgi.c +++ b/apps/webserver/httpd-cgi.c @@ -307,23 +307,25 @@ PT_THREAD(neighbors(struct httpd_state *s, char *ptr)) static unsigned short make_routes(void *p) { -static const char httpd_cgi_rtes1[] HTTPD_STRING_ATTR = "(%u (via "; -static const char httpd_cgi_rtes2[] HTTPD_STRING_ATTR = ") %us
"; -static const char httpd_cgi_rtes3[] HTTPD_STRING_ATTR = ")
"; -uint8_t i,j=0; -uint16_t numprinted; + static const char httpd_cgi_rtes1[] HTTPD_STRING_ATTR = "(%u (via "; + static const char httpd_cgi_rtes2[] HTTPD_STRING_ATTR = ") %lus
"; + static const char httpd_cgi_rtes3[] HTTPD_STRING_ATTR = ")
"; + uint8_t i,j=0; + uint16_t numprinted; + uip_ds6_route_t *r; + numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh); - for (i=0; iipaddr, uip_appdata + numprinted); + numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, r->length); + numprinted += httpd_cgi_sprint_ip6(r->nexthop, uip_appdata + numprinted); + if(r->state.lifetime < 3600) { + numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, r->state.lifetime); + } else { + numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes3); } } if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn); diff --git a/examples/ipv6/native-border-router/border-router.c b/examples/ipv6/native-border-router/border-router.c index e3f5af2ac..b8d01f2bb 100644 --- a/examples/ipv6/native-border-router/border-router.c +++ b/examples/ipv6/native-border-router/border-router.c @@ -149,6 +149,7 @@ static PT_THREAD(generate_routes(struct httpd_state *s)) { static int i; + static uip_ds6_route_t *r; PSOCK_BEGIN(&s->sout); SEND_STRING(&s->sout, TOP); @@ -169,19 +170,19 @@ PT_THREAD(generate_routes(struct httpd_state *s)) ADD("Routes
");
   SEND_STRING(&s->sout, buf);
   blen = 0;
-  for(i = 0; i < UIP_DS6_ROUTE_NB; i++) {
-    if(uip_ds6_routing_table[i].isused) {
-      ipaddr_add(&uip_ds6_routing_table[i].ipaddr);
-      ADD("/%u (via ", uip_ds6_routing_table[i].length);
-      ipaddr_add(&uip_ds6_routing_table[i].nexthop);
-      if(uip_ds6_routing_table[i].state.lifetime < 600) {
-        ADD(") %lus\n", (unsigned long)uip_ds6_routing_table[i].state.lifetime);
-      } else {
-        ADD(")\n");
-      }
-      SEND_STRING(&s->sout, buf);
-      blen = 0;
+  for(r = uip_ds6_route_list_head();
+      r != NULL;
+      r = list_item_next(r)) {
+    ipaddr_add(&r->ipaddr);
+    ADD("/%u (via ", r->length);
+    ipaddr_add(&r->nexthop);
+    if(r->state.lifetime < 600) {
+      ADD(") %lus\n", (unsigned long)r->state.lifetime);
+    } else {
+      ADD(")\n");
     }
+    SEND_STRING(&s->sout, buf);
+    blen = 0;
   }
   ADD("
"); //if(blen > 0) { diff --git a/examples/ipv6/rpl-collect/udp-sender.c b/examples/ipv6/rpl-collect/udp-sender.c index fa5c80790..113afdc4a 100644 --- a/examples/ipv6/rpl-collect/udp-sender.c +++ b/examples/ipv6/rpl-collect/udp-sender.c @@ -70,7 +70,8 @@ void collect_common_net_print(void) { rpl_dag_t *dag; - int i; + uip_ds6_route_t *r; + /* Let's suppose we have only one instance */ dag = rpl_get_any_dag(); if(dag->preferred_parent != NULL) { @@ -78,12 +79,10 @@ collect_common_net_print(void) PRINT6ADDR(&dag->preferred_parent->addr); PRINTF("\n"); } - PRINTF("Route entries:\n"); - for(i = 0; i < UIP_DS6_ROUTE_NB; i++) { - if(uip_ds6_routing_table[i].isused) { - PRINT6ADDR(&uip_ds6_routing_table[i].ipaddr); - PRINTF("\n"); - } + for(r = uip_ds6_route_list_head(); + r != NULL; + r = list_item_next(r)) { + PRINT6ADDR(&r->ipaddr); } PRINTF("---\n"); } diff --git a/platform/avr-atmega128rfa1/contiki-main.c b/platform/avr-atmega128rfa1/contiki-main.c index 995960151..05a9ee392 100644 --- a/platform/avr-atmega128rfa1/contiki-main.c +++ b/platform/avr-atmega128rfa1/contiki-main.c @@ -536,17 +536,22 @@ extern uip_ds6_netif_t uip_ds6_if; } if (j) PRINTF(" "); PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); - for(i = 0,j=1; i < UIP_DS6_ROUTE_NB; i++) { - if(uip_ds6_routing_table[i].isused) { - ipaddr_add(&uip_ds6_routing_table[i].ipaddr); - PRINTF("/%u (via ", uip_ds6_routing_table[i].length); - ipaddr_add(&uip_ds6_routing_table[i].nexthop); + { + uip_ds6_route_t *r; + PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); + j = 1; + for(r = uip_ds6_route_list_head(); + r != NULL; + r = list_item_next(r)) { + ipaddr_add(&r->ipaddr); + PRINTF("/%u (via ", r->length); + ipaddr_add(&r->nexthop); // if(uip_ds6_routing_table[i].state.lifetime < 600) { - PRINTF(") %lus\n", uip_ds6_routing_table[i].state.lifetime); - // } else { - // PRINTF(")\n"); - // } - j=0; + PRINTF(") %lus\n", r->state.lifetime); + // } else { + // PRINTF(")\n"); + // } + j = 0; } } if (j) PRINTF(" "); diff --git a/platform/avr-raven/apps/raven-webserver/httpd-cgi.c b/platform/avr-raven/apps/raven-webserver/httpd-cgi.c index 793aefbe3..a9ed784f8 100644 --- a/platform/avr-raven/apps/raven-webserver/httpd-cgi.c +++ b/platform/avr-raven/apps/raven-webserver/httpd-cgi.c @@ -354,23 +354,25 @@ PT_THREAD(neighbors(struct httpd_state *s, char *ptr)) static unsigned short make_routes(void *p) { -static const char httpd_cgi_rtes1[] HTTPD_STRING_ATTR = "(%u (via "; -static const char httpd_cgi_rtes2[] HTTPD_STRING_ATTR = ") %lus
"; -static const char httpd_cgi_rtes3[] HTTPD_STRING_ATTR = ")
"; -uint8_t i,j=0; -uint16_t numprinted; + static const char httpd_cgi_rtes1[] HTTPD_STRING_ATTR = "(%u (via "; + static const char httpd_cgi_rtes2[] HTTPD_STRING_ATTR = ") %lus
"; + static const char httpd_cgi_rtes3[] HTTPD_STRING_ATTR = ")
"; + uint8_t i,j=0; + uint16_t numprinted; + uip_ds6_route_t *r; + numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh); - for (i=0; iipaddr, uip_appdata + numprinted); + numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, r->length); + numprinted += httpd_cgi_sprint_ip6(r->nexthop, uip_appdata + numprinted); + if(r->state.lifetime < 3600) { + numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, r->state.lifetime); + } else { + numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes3); } } if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn); diff --git a/platform/avr-raven/contiki-raven-main.c b/platform/avr-raven/contiki-raven-main.c index 1d939ebc9..c9521c124 100644 --- a/platform/avr-raven/contiki-raven-main.c +++ b/platform/avr-raven/contiki-raven-main.c @@ -531,18 +531,22 @@ extern uip_ds6_netif_t uip_ds6_if; } } if (j) PRINTF(" "); - PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); - for(i = 0,j=1; i < UIP_DS6_ROUTE_NB; i++) { - if(uip_ds6_routing_table[i].isused) { - ipaddr_add(&uip_ds6_routing_table[i].ipaddr); - PRINTF("/%u (via ", uip_ds6_routing_table[i].length); - ipaddr_add(&uip_ds6_routing_table[i].nexthop); + { + uip_ds6_route_t *r; + PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); + j = 1; + for(r = uip_ds6_route_list_head(); + r != NULL; + r = list_item_next(r)) { + ipaddr_add(&r->ipaddr); + PRINTF("/%u (via ", r->length); + ipaddr_add(&r->nexthop); // if(uip_ds6_routing_table[i].state.lifetime < 600) { - PRINTF(") %lus\n", uip_ds6_routing_table[i].state.lifetime); - // } else { - // PRINTF(")\n"); - // } - j=0; + PRINTF(") %lus\n", r->state.lifetime); + // } else { + // PRINTF(")\n"); + // } + j = 0; } } if (j) PRINTF(" "); diff --git a/platform/redbee-econotag/contiki-mc1322x-main.c b/platform/redbee-econotag/contiki-mc1322x-main.c index f3bc8f5a3..d43d34661 100644 --- a/platform/redbee-econotag/contiki-mc1322x-main.c +++ b/platform/redbee-econotag/contiki-mc1322x-main.c @@ -614,18 +614,23 @@ extern uip_ds6_netif_t uip_ds6_if; } } if (j) printf(" "); - printf("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); - for(i = 0,j=1; i < UIP_DS6_ROUTE_NB; i++) { - if(uip_ds6_routing_table[i].isused) { - uip_debug_ipaddr_print(&uip_ds6_routing_table[i].ipaddr); - printf("/%u (via ", uip_ds6_routing_table[i].length); - uip_debug_ipaddr_print(&uip_ds6_routing_table[i].nexthop); + PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); + { + uip_ds6_route_t *r; + PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); + j = 1; + for(r = uip_ds6_route_list_head(); + r != NULL; + r = list_item_next(r)) { + ipaddr_add(&r->ipaddr); + PRINTF("/%u (via ", r->length); + ipaddr_add(&r->nexthop); // if(uip_ds6_routing_table[i].state.lifetime < 600) { - printf(") %lus\n", uip_ds6_routing_table[i].state.lifetime); - // } else { - // printf(")\n"); - // } - j=0; + PRINTF(") %lus\n", r->state.lifetime); + // } else { + // PRINTF(")\n"); + // } + j = 0; } } if (j) printf(" ");