Merge pull request #1757 from simonduq/pr/br-http-nonstoring

RPL border HTTP server: support for non-storing
contiki
Nicolas Tsiftes 2016-07-01 15:39:17 +02:00 committed by GitHub
commit c9deeb443a
1 changed files with 67 additions and 2 deletions

View File

@ -41,7 +41,10 @@
#include "net/ip/uip.h"
#include "net/ipv6/uip-ds6.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 "dev/button-sensor.h"
#include "dev/slip.h"
@ -144,6 +147,9 @@ static
PT_THREAD(generate_routes(struct httpd_state *s))
{
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;
#if BUF_USES_STACK
char buf[256];
@ -210,7 +216,7 @@ PT_THREAD(generate_routes(struct httpd_state *s))
}
#endif
}
ADD("</pre>Routes<pre>");
ADD("</pre>Routes<pre>\n");
SEND_STRING(&s->sout, buf);
#if BUF_USES_STACK
bufptr = buf; bufend = bufptr + sizeof(buf);
@ -259,6 +265,65 @@ PT_THREAD(generate_routes(struct httpd_state *s))
}
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
static uint16_t numtimes;
ADD("<br><i>This page sent %u times</i>",++numtimes);