Border router: include RPL links in HTTP reply when non-storing mode is enabled

This commit is contained in:
Simon Duquennoy 2016-06-29 16:51:38 +02:00
parent 5eb022fdd8
commit 3e987ec138

View file

@ -41,7 +41,10 @@
#include "net/ip/uip.h" #include "net/ip/uip.h"
#include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-ds6.h"
#include "net/rpl/rpl.h" #include "net/rpl/rpl.h"
#include "net/rpl/rpl-private.h"
#if RPL_WITH_NON_STORING
#include "net/rpl/rpl-ns.h"
#endif /* RPL_WITH_NON_STORING */
#include "net/netstack.h" #include "net/netstack.h"
#include "dev/button-sensor.h" #include "dev/button-sensor.h"
#include "dev/slip.h" #include "dev/slip.h"
@ -144,6 +147,9 @@ static
PT_THREAD(generate_routes(struct httpd_state *s)) PT_THREAD(generate_routes(struct httpd_state *s))
{ {
static uip_ds6_route_t *r; static uip_ds6_route_t *r;
#if RPL_WITH_NON_STORING
static rpl_ns_node_t *link;
#endif /* RPL_WITH_NON_STORING */
static uip_ds6_nbr_t *nbr; static uip_ds6_nbr_t *nbr;
#if BUF_USES_STACK #if BUF_USES_STACK
char buf[256]; char buf[256];
@ -210,7 +216,7 @@ PT_THREAD(generate_routes(struct httpd_state *s))
} }
#endif #endif
} }
ADD("</pre>Routes<pre>"); ADD("</pre>Routes<pre>\n");
SEND_STRING(&s->sout, buf); SEND_STRING(&s->sout, buf);
#if BUF_USES_STACK #if BUF_USES_STACK
bufptr = buf; bufend = bufptr + sizeof(buf); bufptr = buf; bufend = bufptr + sizeof(buf);
@ -259,6 +265,65 @@ PT_THREAD(generate_routes(struct httpd_state *s))
} }
ADD("</pre>"); ADD("</pre>");
#if RPL_WITH_NON_STORING
ADD("Links<pre>\n");
SEND_STRING(&s->sout, buf);
#if BUF_USES_STACK
bufptr = buf; bufend = bufptr + sizeof(buf);
#else
blen = 0;
#endif
for(link = rpl_ns_node_head(); link != NULL; link = rpl_ns_node_next(link)) {
if(link->parent != NULL) {
uip_ipaddr_t child_ipaddr;
uip_ipaddr_t parent_ipaddr;
rpl_ns_get_node_global_addr(&child_ipaddr, link);
rpl_ns_get_node_global_addr(&parent_ipaddr, link->parent);
#if BUF_USES_STACK
#if WEBSERVER_CONF_ROUTE_LINKS
ADD("<a href=http://[");
ipaddr_add(&child_ipaddr);
ADD("]/status.shtml>");
ipaddr_add(&child_ipaddr);
ADD("</a>");
#else
ipaddr_add(&child_ipaddr);
#endif
#else
#if WEBSERVER_CONF_ROUTE_LINKS
ADD("<a href=http://[");
ipaddr_add(&child_ipaddr);
ADD("]/status.shtml>");
SEND_STRING(&s->sout, buf); //TODO: why tunslip6 needs an output here, wpcapslip does not
blen = 0;
ipaddr_add(&child_ipaddr);
ADD("</a>");
#else
ipaddr_add(&child_ipaddr);
#endif
#endif
ADD(" (parent: ");
ipaddr_add(&parent_ipaddr);
if(1 || (link->lifetime < 600)) {
ADD(") %us\n", (unsigned int)link->lifetime); // iotlab printf does not have %lu
//ADD(") %lus\n", (unsigned long)r->state.lifetime);
} else {
ADD(")\n");
}
SEND_STRING(&s->sout, buf);
#if BUF_USES_STACK
bufptr = buf; bufend = bufptr + sizeof(buf);
#else
blen = 0;
#endif
}
}
ADD("</pre>");
#endif /* RPL_WITH_NON_STORING */
#if WEBSERVER_CONF_FILESTATS #if WEBSERVER_CONF_FILESTATS
static uint16_t numtimes; static uint16_t numtimes;
ADD("<br><i>This page sent %u times</i>",++numtimes); ADD("<br><i>This page sent %u times</i>",++numtimes);