Port apps, examples, platforms and tools so they use the new neighbor and route API.

This commit is contained in:
Simon Duquennoy 2013-07-03 20:26:54 +02:00
parent ff093a2b50
commit 5dc05e7913
21 changed files with 262 additions and 257 deletions

View file

@ -51,7 +51,7 @@ do{\
uip_ipaddr_t ipaddr_local, ipaddr_global;\ uip_ipaddr_t ipaddr_local, ipaddr_global;\
NODE_IP(node_global, GLOBAL, &ipaddr_global);\ NODE_IP(node_global, GLOBAL, &ipaddr_global);\
NODE_IP(node_local, LOCAL, &ipaddr_local);\ NODE_IP(node_local, LOCAL, &ipaddr_local);\
uip_ds6_route_add(&ipaddr_global, 128, &ipaddr_local, 0);\ uip_ds6_route_add(&ipaddr_global, 128, &ipaddr_local);\
}while(0) }while(0)
void set_global_address(void); void set_global_address(void);

View file

@ -50,6 +50,7 @@
#include "httpd-fs.h" #include "httpd-fs.h"
#include "httpd-fsdata.h" #include "httpd-fsdata.h"
#include "lib/petsciiconv.h" #include "lib/petsciiconv.h"
#include "net/neighbor-table.h"
#include "sensors.h" #include "sensors.h"
@ -479,7 +480,6 @@ PT_THREAD(addresses(struct httpd_state *s, char *ptr))
#endif /* WEBSERVER_CONF_ADDRESSES */ #endif /* WEBSERVER_CONF_ADDRESSES */
#if WEBSERVER_CONF_NEIGHBORS #if WEBSERVER_CONF_NEIGHBORS
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static unsigned short static unsigned short
make_neighbors(void *p) make_neighbors(void *p)
@ -487,11 +487,13 @@ make_neighbors(void *p)
uint8_t i,j; uint8_t i,j;
uint16_t numprinted=0; uint16_t numprinted=0;
struct httpd_state *s=p; struct httpd_state *s=p;
static uip_ds6_nbr_t *nbr;
/* Span generator calls over tcp segments */ /* Span generator calls over tcp segments */
/* Note retransmissions will execute thise code multiple times for a segment */ /* Note retransmissions will execute thise code multiple times for a segment */
i=s->starti;j=s->startj; i=s->starti;j=s->startj;
for (;i<UIP_DS6_NBR_NB;i++) { for(nbr = nbr_table_head(ds6_neighbors);
if (uip_ds6_nbr_cache[i].isused) { nbr != NULL;
nbr = nbr_table_next(ds6_neighbors, nbr), i++) {
j++; j++;
#if WEBSERVER_CONF_NEIGHBOR_STATUS #if WEBSERVER_CONF_NEIGHBOR_STATUS
@ -501,32 +503,31 @@ static const char httpd_cgi_nbrs3[] HTTPD_STRING_ATTR = " STALE";
static const char httpd_cgi_nbrs4[] HTTPD_STRING_ATTR = " DELAY"; static const char httpd_cgi_nbrs4[] HTTPD_STRING_ATTR = " DELAY";
static const char httpd_cgi_nbrs5[] HTTPD_STRING_ATTR = " NBR_PROBE"; static const char httpd_cgi_nbrs5[] HTTPD_STRING_ATTR = " NBR_PROBE";
{uint16_t k=numprinted+25; {uint16_t k=numprinted+25;
numprinted += httpd_cgi_sprint_ip6(uip_ds6_nbr_cache[i].ipaddr, uip_appdata + numprinted); numprinted += httpd_cgi_sprint_ip6(nbr->ipaddr, uip_appdata + numprinted);
while (numprinted < k) {*((char *)uip_appdata+numprinted++) = ' ';} while (numprinted < k) {*((char *)uip_appdata+numprinted++) = ' ';}
switch (uip_ds6_nbr_cache[i].state) { switch (nbr->state) {
case NBR_INCOMPLETE: numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_nbrs1);break; case NBR_INCOMPLETE: numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_nbrs1);break;
case NBR_REACHABLE: numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_nbrs2);break; case NBR_REACHABLE: numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_nbrs2);break;
case NBR_STALE: numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_nbrs3);break; case NBR_STALE: numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_nbrs3);break;
case NBR_DELAY: numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_nbrs4);break; case NBR_DELAY: numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_nbrs4);break;
case NBR_PROBE: numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_nbrs5);break; case NBR_PROBE: numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_nbrs5);break;
} }
} }
#else #else
numprinted += httpd_cgi_sprint_ip6(uip_ds6_nbr_cache[i].ipaddr, uip_appdata + numprinted); numprinted += httpd_cgi_sprint_ip6(nbr->ipaddr, uip_appdata + numprinted);
#endif #endif
*((char *)uip_appdata+numprinted++) = '\n'; *((char *)uip_appdata+numprinted++) = '\n';
/* If buffer near full, send it and wait for the next call. Could be a retransmission, or the next segment */ /* If buffer near full, send it and wait for the next call. Could be a retransmission, or the next segment */
if(numprinted > (uip_mss() - 50)) { if(numprinted > (uip_mss() - 50)) {
s->savei=i;s->savej=j; s->savei=i;s->savej=j;
return numprinted; return numprinted;
} }
}
} }
#if WEBSERVER_CONF_SHOW_ROOM #if WEBSERVER_CONF_SHOW_ROOM
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf,UIP_DS6_NBR_NB-j); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf,NEIGHBOR_TABLE_MAX_NEIGHBORS-j);
#else #else
if(UIP_DS6_NBR_NB == j) { if(NEIGHBOR_TABLE_MAX_NEIGHBORS == j) {
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf);
} }
#endif #endif
@ -554,7 +555,6 @@ PT_THREAD(neighbors(struct httpd_state *s, char *ptr))
#endif #endif
#if WEBSERVER_CONF_ROUTES #if WEBSERVER_CONF_ROUTES
extern uip_ds6_route_t uip_ds6_routing_table[];
#if WEBSERVER_CONF_ROUTE_LINKS #if WEBSERVER_CONF_ROUTE_LINKS
static const char httpd_cgi_rtesl1[] HTTPD_STRING_ATTR = "<a href=http://["; static const char httpd_cgi_rtesl1[] HTTPD_STRING_ATTR = "<a href=http://[";
static const char httpd_cgi_rtesl2[] HTTPD_STRING_ATTR = "]/status.shtml>"; static const char httpd_cgi_rtesl2[] HTTPD_STRING_ATTR = "]/status.shtml>";
@ -570,27 +570,29 @@ static const char httpd_cgi_rtes3[] HTTPD_STRING_ATTR = ")\n";
uint8_t i,j; uint8_t i,j;
uint16_t numprinted=0; uint16_t numprinted=0;
struct httpd_state *s=p; struct httpd_state *s=p;
uip_ds6_route_t *r;
/* Span generator calls over tcp segments */ /* Span generator calls over tcp segments */
/* Note retransmissions will execute thise code multiple times for a segment */ /* Note retransmissions will execute thise code multiple times for a segment */
i=s->starti;j=s->startj; i=s->starti;j=s->startj;
for (;i<UIP_DS6_ROUTE_NB;i++) { for(r = uip_ds6_route_head();
if (uip_ds6_routing_table[i].isused) { r != NULL;
r = uip_ds6_route_next(r)) {
j++; j++;
#if WEBSERVER_CONF_ROUTE_LINKS #if WEBSERVER_CONF_ROUTE_LINKS
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtesl1); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtesl1);
numprinted += httpd_cgi_sprint_ip6(uip_ds6_routing_table[i].ipaddr, uip_appdata + numprinted); numprinted += httpd_cgi_sprint_ip6(r->ipaddr, uip_appdata + numprinted);
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtesl2); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtesl2);
numprinted += httpd_cgi_sprint_ip6(uip_ds6_routing_table[i].ipaddr, uip_appdata + numprinted); numprinted += httpd_cgi_sprint_ip6(r->ipaddr, uip_appdata + numprinted);
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtesl3); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtesl3);
#else #else
numprinted += httpd_cgi_sprint_ip6(uip_ds6_routing_table[i].ipaddr, uip_appdata + numprinted); numprinted += httpd_cgi_sprint_ip6(r->ipaddr, uip_appdata + numprinted);
#endif #endif
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, uip_ds6_routing_table[i].length); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, r->length);
numprinted += httpd_cgi_sprint_ip6(uip_ds6_routing_table[i].nexthop, uip_appdata + numprinted); numprinted += httpd_cgi_sprint_ip6(uip_ds6_route_nexthop(r), uip_appdata + numprinted);
if(1 || uip_ds6_routing_table[i].state.lifetime < 3600) { if(1 || r->state.lifetime < 3600) {
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, (long unsigned int)uip_ds6_routing_table[i].state.lifetime); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, (long unsigned int)r->state.lifetime);
} else { } else {
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes3); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes3);
} }

View file

@ -244,8 +244,6 @@ static const char httpd_cgi_addrh[] HTTPD_STRING_ATTR = "<code>";
static const char httpd_cgi_addrf[] HTTPD_STRING_ATTR = "</code>[Room for %u more]"; static const char httpd_cgi_addrf[] HTTPD_STRING_ATTR = "</code>[Room for %u more]";
static const char httpd_cgi_addrb[] HTTPD_STRING_ATTR = "<br>"; static const char httpd_cgi_addrb[] HTTPD_STRING_ATTR = "<br>";
static const char httpd_cgi_addrn[] HTTPD_STRING_ATTR = "(none)<br>"; static const char httpd_cgi_addrn[] HTTPD_STRING_ATTR = "(none)<br>";
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
extern uip_ds6_route_t uip_ds6_routing_table[];
extern uip_ds6_netif_t uip_ds6_if; extern uip_ds6_netif_t uip_ds6_if;
static unsigned short static unsigned short
@ -282,15 +280,16 @@ make_neighbors(void *p)
uint8_t i,j=0; uint8_t i,j=0;
uint16_t numprinted; uint16_t numprinted;
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh); numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
for (i=0; i<UIP_DS6_NBR_NB;i++) { uip_ds6_nbr_t *nbr;
if (uip_ds6_nbr_cache[i].isused) { for(nbr = nbr_table_head(ds6_neighbors);
j++; nbr != NULL;
numprinted += httpd_cgi_sprint_ip6(uip_ds6_nbr_cache[i].ipaddr, uip_appdata + numprinted); nbr = nbr_table_next(ds6_neighbors, nbr)) {
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrb); j++;
} numprinted += httpd_cgi_sprint_ip6(nbr->ipaddr, uip_appdata + numprinted);
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrb);
} }
//if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn); //if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn);
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf,UIP_DS6_NBR_NB-j); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf,NEIGHBOR_TABLE_MAX_NEIGHBORS-j);
return numprinted; return numprinted;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -315,13 +314,13 @@ make_routes(void *p)
uip_ds6_route_t *r; uip_ds6_route_t *r;
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh); numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
for(r = uip_ds6_route_list_head(); for(r = uip_ds6_route_head();
r != NULL; r != NULL;
r = list_item_next(r)) { r = uip_ds6_route_next(r)) {
j++; j++;
numprinted += httpd_cgi_sprint_ip6(r->ipaddr, uip_appdata + numprinted); numprinted += httpd_cgi_sprint_ip6(r->ipaddr, uip_appdata + numprinted);
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, r->length); 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); numprinted += httpd_cgi_sprint_ip6(uip_ds6_route_nexthop(r), uip_appdata + numprinted);
if(r->state.lifetime < 3600) { if(r->state.lifetime < 3600) {
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, r->state.lifetime); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, r->state.lifetime);
} else { } else {

View file

@ -63,9 +63,6 @@
uint16_t dag_id[] = {0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011}; uint16_t dag_id[] = {0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011};
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
extern uip_ds6_route_t uip_ds6_routing_table[];
extern long slip_sent; extern long slip_sent;
extern long slip_received; extern long slip_received;
@ -150,32 +147,34 @@ PT_THREAD(generate_routes(struct httpd_state *s))
{ {
static int i; static int i;
static uip_ds6_route_t *r; static uip_ds6_route_t *r;
static uip_ds6_nbr_t *nbr;
PSOCK_BEGIN(&s->sout); PSOCK_BEGIN(&s->sout);
SEND_STRING(&s->sout, TOP); SEND_STRING(&s->sout, TOP);
blen = 0; blen = 0;
ADD("Neighbors<pre>"); ADD("Neighbors<pre>");
for(i = 0; i < UIP_DS6_NBR_NB; i++) { for(nbr = nbr_table_head(ds6_neighbors);
if(uip_ds6_nbr_cache[i].isused) { nbr != NULL;
ipaddr_add(&uip_ds6_nbr_cache[i].ipaddr); nbr = nbr_table_next(ds6_neighbors, nbr)) {
ADD("\n"); ipaddr_add(&nbr->ipaddr;);
if(blen > sizeof(buf) - 45) { ADD("\n");
SEND_STRING(&s->sout, buf); if(blen > sizeof(buf) - 45) {
blen = 0; SEND_STRING(&s->sout, buf);
} blen = 0;
} }
} }
ADD("</pre>Routes<pre>"); ADD("</pre>Routes<pre>");
SEND_STRING(&s->sout, buf); SEND_STRING(&s->sout, buf);
blen = 0; blen = 0;
for(r = uip_ds6_route_list_head(); for(r = uip_ds6_route_head();
r != NULL; r != NULL;
r = list_item_next(r)) { r = uip_ds6_route_next(r)) {
ipaddr_add(&r->ipaddr); ipaddr_add(&r->ipaddr);
ADD("/%u (via ", r->length); ADD("/%u (via ", r->length);
ipaddr_add(&r->nexthop); ipaddr_add(uip_ds6_route_nexthop(r));
if(r->state.lifetime < 600) { if(r->state.lifetime < 600) {
ADD(") %lus\n", (unsigned long)r->state.lifetime); ADD(") %lus\n", (unsigned long)r->state.lifetime);
} else { } else {

View file

@ -56,8 +56,6 @@
uint16_t dag_id[] = {0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011}; uint16_t dag_id[] = {0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011};
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
static uip_ipaddr_t prefix; static uip_ipaddr_t prefix;
static uint8_t prefix_set; static uint8_t prefix_set;
@ -149,6 +147,7 @@ PT_THREAD(generate_routes(struct httpd_state *s))
{ {
static int i; static int i;
static uip_ds6_route_t *r; static uip_ds6_route_t *r;
static uip_ds6_nbr_t *nbr;
#if BUF_USES_STACK #if BUF_USES_STACK
char buf[256]; char buf[256];
#endif #endif
@ -166,15 +165,17 @@ PT_THREAD(generate_routes(struct httpd_state *s))
blen = 0; blen = 0;
#endif #endif
ADD("Neighbors<pre>"); ADD("Neighbors<pre>");
for(i = 0; i < UIP_DS6_NBR_NB; i++) {
if(uip_ds6_nbr_cache[i].isused) { for(nbr = nbr_table_head(ds6_neighbors);
nbr != NULL;
nbr = nbr_table_next(ds6_neighbors, nbr)) {
#if WEBSERVER_CONF_NEIGHBOR_STATUS #if WEBSERVER_CONF_NEIGHBOR_STATUS
#if BUF_USES_STACK #if BUF_USES_STACK
{char* j=bufptr+25; {char* j=bufptr+25;
ipaddr_add(&uip_ds6_nbr_cache[i].ipaddr); ipaddr_add(&nbr->ipaddr);
while (bufptr < j) ADD(" "); while (bufptr < j) ADD(" ");
switch (uip_ds6_nbr_cache[i].state) { switch (nbr->state) {
case NBR_INCOMPLETE: ADD(" INCOMPLETE");break; case NBR_INCOMPLETE: ADD(" INCOMPLETE");break;
case NBR_REACHABLE: ADD(" REACHABLE");break; case NBR_REACHABLE: ADD(" REACHABLE");break;
case NBR_STALE: ADD(" STALE");break; case NBR_STALE: ADD(" STALE");break;
@ -184,9 +185,9 @@ PT_THREAD(generate_routes(struct httpd_state *s))
} }
#else #else
{uint8_t j=blen+25; {uint8_t j=blen+25;
ipaddr_add(&uip_ds6_nbr_cache[i].ipaddr); ipaddr_add(&nbr->ipaddr);
while (blen < j) ADD(" "); while (blen < j) ADD(" ");
switch (uip_ds6_nbr_cache[i].state) { switch (nbr->state) {
case NBR_INCOMPLETE: ADD(" INCOMPLETE");break; case NBR_INCOMPLETE: ADD(" INCOMPLETE");break;
case NBR_REACHABLE: ADD(" REACHABLE");break; case NBR_REACHABLE: ADD(" REACHABLE");break;
case NBR_STALE: ADD(" STALE");break; case NBR_STALE: ADD(" STALE");break;
@ -196,7 +197,7 @@ PT_THREAD(generate_routes(struct httpd_state *s))
} }
#endif #endif
#else #else
ipaddr_add(&uip_ds6_nbr_cache[i].ipaddr); ipaddr_add(&nbr->ipaddr);
#endif #endif
ADD("\n"); ADD("\n");
@ -211,7 +212,6 @@ PT_THREAD(generate_routes(struct httpd_state *s))
blen = 0; blen = 0;
} }
#endif #endif
}
} }
ADD("</pre>Routes<pre>"); ADD("</pre>Routes<pre>");
SEND_STRING(&s->sout, buf); SEND_STRING(&s->sout, buf);
@ -221,7 +221,7 @@ PT_THREAD(generate_routes(struct httpd_state *s))
blen = 0; blen = 0;
#endif #endif
for(r = uip_ds6_route_list_head(); r != NULL; r = list_item_next(r)) { for(r = uip_ds6_route_head(); r != NULL; r = uip_ds6_route_next(r)) {
#if BUF_USES_STACK #if BUF_USES_STACK
#if WEBSERVER_CONF_ROUTE_LINKS #if WEBSERVER_CONF_ROUTE_LINKS
@ -247,7 +247,7 @@ PT_THREAD(generate_routes(struct httpd_state *s))
#endif #endif
#endif #endif
ADD("/%u (via ", r->length); ADD("/%u (via ", r->length);
ipaddr_add(&r->nexthop); ipaddr_add(uip_ds6_route_nexthop(r));
if(1 || (r->state.lifetime < 600)) { if(1 || (r->state.lifetime < 600)) {
ADD(") %lus\n", r->state.lifetime); ADD(") %lus\n", r->state.lifetime);
} else { } else {

View file

@ -31,7 +31,6 @@
#include "net/uip.h" #include "net/uip.h"
#include "net/uip-ds6.h" #include "net/uip-ds6.h"
#include "net/uip-udp-packet.h" #include "net/uip-udp-packet.h"
#include "net/neighbor-info.h"
#include "net/rpl/rpl.h" #include "net/rpl/rpl.h"
#include "dev/serial-line.h" #include "dev/serial-line.h"
#if CONTIKI_TARGET_Z1 #if CONTIKI_TARGET_Z1
@ -64,7 +63,6 @@ collect_common_set_sink(void)
/* A udp client can never become sink */ /* A udp client can never become sink */
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
extern uip_ds6_route_t uip_ds6_routing_table[UIP_DS6_ROUTE_NB];
void void
collect_common_net_print(void) collect_common_net_print(void)
@ -76,12 +74,12 @@ collect_common_net_print(void)
dag = rpl_get_any_dag(); dag = rpl_get_any_dag();
if(dag->preferred_parent != NULL) { if(dag->preferred_parent != NULL) {
PRINTF("Preferred parent: "); PRINTF("Preferred parent: ");
PRINT6ADDR(&dag->preferred_parent->addr); PRINT6ADDR(rpl_get_parent_ipaddr(dag->preferred_parent));
PRINTF("\n"); PRINTF("\n");
} }
for(r = uip_ds6_route_list_head(); for(r = uip_ds6_route_head();
r != NULL; r != NULL;
r = list_item_next(r)) { r = uip_ds6_route_next(r)) {
PRINT6ADDR(&r->ipaddr); PRINT6ADDR(&r->ipaddr);
} }
PRINTF("---\n"); PRINTF("---\n");
@ -134,12 +132,12 @@ collect_common_send(void)
preferred_parent = dag->preferred_parent; preferred_parent = dag->preferred_parent;
if(preferred_parent != NULL) { if(preferred_parent != NULL) {
uip_ds6_nbr_t *nbr; uip_ds6_nbr_t *nbr;
nbr = uip_ds6_nbr_lookup(&preferred_parent->addr); nbr = uip_ds6_nbr_lookup(rpl_get_parent_ipaddr(preferred_parent));
if(nbr != NULL) { if(nbr != NULL) {
/* Use parts of the IPv6 address as the parent address, in reversed byte order. */ /* Use parts of the IPv6 address as the parent address, in reversed byte order. */
parent.u8[RIMEADDR_SIZE - 1] = nbr->ipaddr.u8[sizeof(uip_ipaddr_t) - 2]; parent.u8[RIMEADDR_SIZE - 1] = nbr->ipaddr.u8[sizeof(uip_ipaddr_t) - 2];
parent.u8[RIMEADDR_SIZE - 2] = nbr->ipaddr.u8[sizeof(uip_ipaddr_t) - 1]; parent.u8[RIMEADDR_SIZE - 2] = nbr->ipaddr.u8[sizeof(uip_ipaddr_t) - 1];
parent_etx = neighbor_info_get_metric((rimeaddr_t *) &nbr->lladdr) / 2; parent_etx = rpl_get_parent_rank((rimeaddr_t *) uip_ds6_nbr_get_ll(nbr)) / 2;
} }
} }
rtmetric = dag->rank; rtmetric = dag->rank;

View file

@ -131,3 +131,9 @@ uip_icmp6chksum(void)
{ {
return upper_layer_chksum(UIP_PROTO_ICMP6); return upper_layer_chksum(UIP_PROTO_ICMP6);
} }
/*---------------------------------------------------------------------------*/
void
uip_ds6_link_neighbor_callback(int status, int numtx)
{
}

View file

@ -290,8 +290,6 @@ static const char httpd_cgi_addrh[] HTTPD_STRING_ATTR = "<code>";
static const char httpd_cgi_addrf[] HTTPD_STRING_ATTR = "</code>[Room for %u more]"; static const char httpd_cgi_addrf[] HTTPD_STRING_ATTR = "</code>[Room for %u more]";
static const char httpd_cgi_addrb[] HTTPD_STRING_ATTR = "<br>"; static const char httpd_cgi_addrb[] HTTPD_STRING_ATTR = "<br>";
static const char httpd_cgi_addrn[] HTTPD_STRING_ATTR = "(none)<br>"; static const char httpd_cgi_addrn[] HTTPD_STRING_ATTR = "(none)<br>";
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
extern uip_ds6_route_t uip_ds6_routing_table[];
extern uip_ds6_netif_t uip_ds6_if; extern uip_ds6_netif_t uip_ds6_if;
static unsigned short static unsigned short
@ -328,15 +326,16 @@ make_neighbors(void *p)
uint8_t i,j=0; uint8_t i,j=0;
uint16_t numprinted; uint16_t numprinted;
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh); numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
for (i=0; i<UIP_DS6_NBR_NB;i++) { uip_ds6_nbr_t *nbr;
if (uip_ds6_nbr_cache[i].isused) { for(nbr = nbr_table_head(ds6_neighbors);
j++; nbr != NULL;
numprinted += httpd_cgi_sprint_ip6(uip_ds6_nbr_cache[i].ipaddr, uip_appdata + numprinted); nbr = nbr_table_next(ds6_neighbors, nbr)) {
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrb); j++;
} numprinted += httpd_cgi_sprint_ip6(nbr->ipaddr, uip_appdata + numprinted);
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrb);
} }
//if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn); //if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn);
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf,UIP_DS6_NBR_NB-j); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf,NEIGHBOR_TABLE_MAX_NEIGHBORS-j);
return numprinted; return numprinted;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -358,15 +357,17 @@ static const char httpd_cgi_rtes2[] HTTPD_STRING_ATTR = ") %lus<br>";
static const char httpd_cgi_rtes3[] HTTPD_STRING_ATTR = ")<br>"; static const char httpd_cgi_rtes3[] HTTPD_STRING_ATTR = ")<br>";
uint8_t i,j=0; uint8_t i,j=0;
uint16_t numprinted; uint16_t numprinted;
uip_ds6_route_t *r;
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh); numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
for (i=0; i<UIP_DS6_ROUTE_NB;i++) { for(r = uip_ds6_route_head();
if (uip_ds6_routing_table[i].isused) { r != NULL;
r = uip_ds6_route_next(r)) {
j++; j++;
numprinted += httpd_cgi_sprint_ip6(uip_ds6_routing_table[i].ipaddr, uip_appdata + numprinted); numprinted += httpd_cgi_sprint_ip6(r->ipaddr, uip_appdata + numprinted);
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, uip_ds6_routing_table[i].length); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, r->length);
numprinted += httpd_cgi_sprint_ip6(uip_ds6_routing_table[i].nexthop, uip_appdata + numprinted); numprinted += httpd_cgi_sprint_ip6(uip_ds6_route_nexthop(r), uip_appdata + numprinted);
if(uip_ds6_routing_table[i].state.lifetime < 3600) { if(r->state.lifetime < 3600) {
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, uip_ds6_routing_table[i].state.lifetime); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, r->state.lifetime);
} else { } else {
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes3); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes3);
} }

View file

@ -419,6 +419,9 @@ ipaddr_add(const uip_ipaddr_t *addr)
int int
main(void) main(void)
{ {
#if UIP_CONF_IPV6
uip_ds6_nbr_t *nbr;
#endif /* UIP_CONF_IPV6 */
initialize(); initialize();
while(1) { while(1) {
@ -514,8 +517,6 @@ if ((clocktime%PINGS)==1) {
#if ROUTES && UIP_CONF_IPV6 #if ROUTES && UIP_CONF_IPV6
if ((clocktime%ROUTES)==2) { if ((clocktime%ROUTES)==2) {
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
extern uip_ds6_route_t uip_ds6_routing_table[];
extern uip_ds6_netif_t uip_ds6_if; extern uip_ds6_netif_t uip_ds6_if;
uint8_t i,j; uint8_t i,j;
@ -526,13 +527,14 @@ extern uip_ds6_netif_t uip_ds6_if;
PRINTF("\n"); PRINTF("\n");
} }
} }
PRINTF("\nNeighbors [%u max]\n",UIP_DS6_NBR_NB); PRINTF("\nNeighbors [%u max]\n",NEIGHBOR_TABLE_MAX_NEIGHBORS);
for(i = 0,j=1; i < UIP_DS6_NBR_NB; i++) {
if(uip_ds6_nbr_cache[i].isused) { for(nbr = nbr_table_head(ds6_neighbors);
ipaddr_add(&uip_ds6_nbr_cache[i].ipaddr); nbr != NULL;
PRINTF("\n"); nbr = nbr_table_next(ds6_neighbors, nbr)) {
j=0; ipaddr_add(&nbr->ipaddr);
} PRINTF("\n");
j=0;
} }
if (j) PRINTF(" <none>"); if (j) PRINTF(" <none>");
PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB);
@ -540,17 +542,13 @@ extern uip_ds6_netif_t uip_ds6_if;
uip_ds6_route_t *r; uip_ds6_route_t *r;
PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB);
j = 1; j = 1;
for(r = uip_ds6_route_list_head(); for(r = uip_ds6_route_head();
r != NULL; r != NULL;
r = list_item_next(r)) { r = uip_ds6_route_next(r)) {
ipaddr_add(&r->ipaddr); ipaddr_add(&r->ipaddr);
PRINTF("/%u (via ", r->length); PRINTF("/%u (via ", r->length);
ipaddr_add(&r->nexthop); ipaddr_add(uip_ds6_route_nexthop(r));
// if(uip_ds6_routing_table[i].state.lifetime < 600) {
PRINTF(") %lus\n", r->state.lifetime); PRINTF(") %lus\n", r->state.lifetime);
// } else {
// PRINTF(")\n");
// }
j = 0; j = 0;
} }
} }

View file

@ -291,8 +291,6 @@ static const char httpd_cgi_addrh[] HTTPD_STRING_ATTR = "<code>";
static const char httpd_cgi_addrf[] HTTPD_STRING_ATTR = "</code>[Room for %u more]"; static const char httpd_cgi_addrf[] HTTPD_STRING_ATTR = "</code>[Room for %u more]";
static const char httpd_cgi_addrb[] HTTPD_STRING_ATTR = "<br>"; static const char httpd_cgi_addrb[] HTTPD_STRING_ATTR = "<br>";
static const char httpd_cgi_addrn[] HTTPD_STRING_ATTR = "(none)<br>"; static const char httpd_cgi_addrn[] HTTPD_STRING_ATTR = "(none)<br>";
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
extern uip_ds6_route_t uip_ds6_routing_table[];
extern uip_ds6_netif_t uip_ds6_if; extern uip_ds6_netif_t uip_ds6_if;
static unsigned short static unsigned short
@ -328,16 +326,18 @@ make_neighbors(void *p)
{ {
uint8_t i,j=0; uint8_t i,j=0;
uint16_t numprinted; uint16_t numprinted;
uip_ds6_nbr_t *nbr;
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh); numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
for (i=0; i<UIP_DS6_NBR_NB;i++) { for(nbr = nbr_table_head(ds6_neighbors);
if (uip_ds6_nbr_cache[i].isused) { nbr != NULL;
j++; nbr = nbr_table_next(ds6_neighbors, nbr)) {
numprinted += httpd_cgi_sprint_ip6(uip_ds6_nbr_cache[i].ipaddr, uip_appdata + numprinted); j++;
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrb); numprinted += httpd_cgi_sprint_ip6(nbr->ipaddr, uip_appdata + numprinted);
} numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrb);
} }
//if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn); //if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn);
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf,UIP_DS6_NBR_NB-j); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf,NEIGHBOR_TABLE_MAX_NEIGHBORS-j);
return numprinted; return numprinted;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -362,13 +362,13 @@ make_routes(void *p)
uip_ds6_route_t *r; uip_ds6_route_t *r;
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh); numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
for(r = uip_ds6_route_list_head(); for(r = uip_ds6_route_head();
r != NULL; r != NULL;
r = list_item_next(r)) { r = uip_ds6_route_next(r)) {
j++; j++;
numprinted += httpd_cgi_sprint_ip6(r->ipaddr, uip_appdata + numprinted); numprinted += httpd_cgi_sprint_ip6(r->ipaddr, uip_appdata + numprinted);
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, r->length); 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); numprinted += httpd_cgi_sprint_ip6(uip_ds6_route_nexthop(r), uip_appdata + numprinted);
if(r->state.lifetime < 3600) { if(r->state.lifetime < 3600) {
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, r->state.lifetime); numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, r->state.lifetime);
} else { } else {

View file

@ -429,6 +429,9 @@ ipaddr_add(const uip_ipaddr_t *addr)
int int
main(void) main(void)
{ {
#if UIP_CONF_IPV6
uip_ds6_nbr_t *nbr;
#endif /* UIP_CONF_IPV6 */
initialize(); initialize();
while(1) { while(1) {
@ -510,8 +513,6 @@ if ((clocktime%PINGS)==1) {
#if ROUTES && UIP_CONF_IPV6 #if ROUTES && UIP_CONF_IPV6
if ((clocktime%ROUTES)==2) { if ((clocktime%ROUTES)==2) {
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
extern uip_ds6_route_t uip_ds6_routing_table[];
extern uip_ds6_netif_t uip_ds6_if; extern uip_ds6_netif_t uip_ds6_if;
uint8_t i,j; uint8_t i,j;
@ -522,30 +523,26 @@ extern uip_ds6_netif_t uip_ds6_if;
PRINTF("\n"); PRINTF("\n");
} }
} }
PRINTF("\nNeighbors [%u max]\n",UIP_DS6_NBR_NB); PRINTF("\nNeighbors [%u max]\n",NEIGHBOR_TABLE_MAX_NEIGHBORS);
for(i = 0,j=1; i < UIP_DS6_NBR_NB; i++) { for(nbr = nbr_table_head(ds6_neighbors);
if(uip_ds6_nbr_cache[i].isused) { nbr != NULL;
ipaddr_add(&uip_ds6_nbr_cache[i].ipaddr); nbr = nbr_table_next(ds6_neighbors, nbr)) {
PRINTF("\n"); ipaddr_add(&nbr->ipaddr);
j=0; PRINTF("\n");
} j=0;
} }
if (j) PRINTF(" <none>"); if (j) PRINTF(" <none>");
{ {
uip_ds6_route_t *r; uip_ds6_route_t *r;
PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB);
j = 1; j = 1;
for(r = uip_ds6_route_list_head(); for(r = uip_ds6_route_head();
r != NULL; r != NULL;
r = list_item_next(r)) { r = uip_ds6_route_next(r)) {
ipaddr_add(&r->ipaddr); ipaddr_add(&r->ipaddr);
PRINTF("/%u (via ", r->length); PRINTF("/%u (via ", r->length);
ipaddr_add(&r->nexthop); ipaddr_add(uip_ds6_route_nexthop(r));
// if(uip_ds6_routing_table[i].state.lifetime < 600) { PRINTF(") %lus\n", r->state.lifetime);
PRINTF(") %lus\n", r->state.lifetime);
// } else {
// PRINTF(")\n");
// }
j = 0; j = 0;
} }
} }

View file

@ -579,11 +579,10 @@ void menu_process(char c)
#if UIP_CONF_IPV6_RPL #if UIP_CONF_IPV6_RPL
#include "rpl.h" #include "rpl.h"
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
extern uip_ds6_route_t uip_ds6_routing_table[];
extern uip_ds6_netif_t uip_ds6_if; extern uip_ds6_netif_t uip_ds6_if;
case 'N': case 'N':
{ uint8_t i,j; { uint8_t i,j;
uip_ds6_nbr_t *nbr;
PRINTF_P(PSTR("\n\rAddresses [%u max]\n\r"),UIP_DS6_ADDR_NB); PRINTF_P(PSTR("\n\rAddresses [%u max]\n\r"),UIP_DS6_ADDR_NB);
for (i=0;i<UIP_DS6_ADDR_NB;i++) { for (i=0;i<UIP_DS6_ADDR_NB;i++) {
if (uip_ds6_if.addr_list[i].isused) { if (uip_ds6_if.addr_list[i].isused) {
@ -591,21 +590,24 @@ extern uip_ds6_netif_t uip_ds6_if;
PRINTF_P(PSTR("\n\r")); PRINTF_P(PSTR("\n\r"));
} }
} }
PRINTF_P(PSTR("\n\rNeighbors [%u max]\n\r"),UIP_DS6_NBR_NB); PRINTF_P(PSTR("\n\rNeighbors [%u max]\n\r"),NEIGHBOR_TABLE_MAX_NEIGHBORS);
for(i = 0,j=1; i < UIP_DS6_NBR_NB; i++) {
if(uip_ds6_nbr_cache[i].isused) { for(nbr = nbr_table_head(ds6_neighbors);
ipaddr_add(&uip_ds6_nbr_cache[i].ipaddr); nbr != NULL;
PRINTF_P(PSTR("\n\r")); nbr = nbr_table_next(ds6_neighbors, nbr)) {
j=0; ipaddr_add(&nbr->ipaddr);
} PRINTF_P(PSTR("\n\r"));
j=0;
} }
if (j) PRINTF_P(PSTR(" <none>")); if (j) PRINTF_P(PSTR(" <none>"));
PRINTF_P(PSTR("\n\rRoutes [%u max]\n\r"),UIP_DS6_ROUTE_NB); PRINTF_P(PSTR("\n\rRoutes [%u max]\n\r"),UIP_DS6_ROUTE_NB);
uip_ds6_route_t *route; uip_ds6_route_t *route;
for(route = uip_ds6_route_list_head(),j=1; route != NULL; route = list_item_next(route)) { for(route = uip_ds6_route_head();
route != NULL;
route = uip_ds6_route_next(r)) {
ipaddr_add(&route->ipaddr); ipaddr_add(&route->ipaddr);
PRINTF_P(PSTR("/%u (via "), route->length); PRINTF_P(PSTR("/%u (via "), route->length);
ipaddr_add(&route->nexthop); ipaddr_add(uip_ds6_route_nexthop(route));
if(route->state.lifetime < 600) { if(route->state.lifetime < 600) {
PRINTF_P(PSTR(") %lus\n\r"), route->state.lifetime); PRINTF_P(PSTR(") %lus\n\r"), route->state.lifetime);
} else { } else {

View file

@ -652,12 +652,12 @@ if ((rtime%PINGS)==1) {
#if ROUTES && UIP_CONF_IPV6_RPL #if ROUTES && UIP_CONF_IPV6_RPL
if ((rtime%ROUTES)==2) { if ((rtime%ROUTES)==2) {
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
extern uip_ds6_route_t uip_ds6_routing_table[];
extern uip_ds6_netif_t uip_ds6_if; extern uip_ds6_netif_t uip_ds6_if;
uint8_t i,j; uint8_t i,j;
uip_ds6_nbr_t *nbr;
PRINTA("\nAddresses [%u max]\n",UIP_DS6_ADDR_NB); PRINTA("\nAddresses [%u max]\n",UIP_DS6_ADDR_NB);
for (i=0;i<UIP_DS6_ADDR_NB;i++) { for (i=0;i<UIP_DS6_ADDR_NB;i++) {
if (uip_ds6_if.addr_list[i].isused) { if (uip_ds6_if.addr_list[i].isused) {
@ -665,23 +665,27 @@ extern uip_ds6_netif_t uip_ds6_if;
PRINTA("\n"); PRINTA("\n");
} }
} }
PRINTA("\nNeighbors [%u max]\n",UIP_DS6_NBR_NB); PRINTA("\nNeighbors [%u max]\n",NEIGHBOR_TABLE_MAX_NEIGHBORS);
for(i = 0,j=1; i < UIP_DS6_NBR_NB; i++) {
if(uip_ds6_nbr_cache[i].isused) { for(nbr = nbr_table_head(ds6_neighbors);
uip_debug_ipaddr_print(&uip_ds6_nbr_cache[i].ipaddr); nbr != NULL;
PRINTA("\n"); nbr = nbr_table_next(ds6_neighbors, nbr)) {
j=0; uip_debug_ipaddr_print(&nbr->ipaddr);
} PRINTA("\n");
j=0;
} }
if (j) PRINTA(" <none>"); if (j) PRINTA(" <none>");
PRINTA("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); PRINTA("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB);
for(i = 0,j=1; i < UIP_DS6_ROUTE_NB; i++) { uip_ds6_route_t *r;
if(uip_ds6_routing_table[i].isused) { for(r = uip_ds6_route_head();
uip_debug_ipaddr_print(&uip_ds6_routing_table[i].ipaddr); r != NULL;
PRINTA("/%u (via ", uip_ds6_routing_table[i].length); r = uip_ds6_route_next(r)) {
uip_debug_ipaddr_print(&uip_ds6_routing_table[i].nexthop); if(r->isused) {
// if(uip_ds6_routing_table[i].state.lifetime < 600) { uip_debug_ipaddr_print(&r->ipaddr);
PRINTA(") %lus\n", uip_ds6_routing_table[i].state.lifetime); PRINTA("/%u (via ", r->length);
uip_debug_ipaddr_print(uip_ds6_route_nexthop(r));
// if(r->state.lifetime < 600) {
PRINTA(") %lus\n", r->state.lifetime);
// } else { // } else {
// PRINTA(")\n"); // PRINTA(")\n");
// } // }

View file

@ -243,10 +243,6 @@ ipaddr_add(const uip_ipaddr_t *addr)
const char TOP1[] PROGMEM = "<html><head><title>ContikiRPL(Jackdaw)"; const char TOP1[] PROGMEM = "<html><head><title>ContikiRPL(Jackdaw)";
const char TOP2[] PROGMEM = "</title></head><body>"; const char TOP2[] PROGMEM = "</title></head><body>";
const char BOTTOM[] PROGMEM = "</body></html>"; const char BOTTOM[] PROGMEM = "</body></html>";
#if UIP_CONF_IPV6
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
extern uip_ds6_route_t uip_ds6_routing_table[];
#endif
static static
PT_THREAD(generate_routes(struct httpd_state *s)) PT_THREAD(generate_routes(struct httpd_state *s))
@ -259,30 +255,33 @@ PT_THREAD(generate_routes(struct httpd_state *s))
#if UIP_CONF_IPV6 //allow ip4 builds #if UIP_CONF_IPV6 //allow ip4 builds
blen = 0; blen = 0;
ADD("<h2>Neighbors [%u max]</h2>",UIP_DS6_NBR_NB); ADD("<h2>Neighbors [%u max]</h2>",NEIGHBOR_CONF_MAX_NEIGHBORS);
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf); PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
blen = 0; blen = 0;
for(i = 0; i < UIP_DS6_NBR_NB; i++) { uip_ds6_nbr_t *nbr;
if(uip_ds6_nbr_cache[i].isused) { for(nbr = nbr_table_head(ds6_neighbors);
ipaddr_add(&uip_ds6_nbr_cache[i].ipaddr); nbr != NULL;
nbr = nbr_table_next(ds6_neighbors, nbr)) {
ipaddr_add(&nbr->ipaddr);
ADD("<br>"); ADD("<br>");
// if(blen > sizeof(buf) - 45) { // if(blen > sizeof(buf) - 45) {
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf); PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
blen = 0; blen = 0;
// } // }
}
} }
ADD("<h2>Routes [%u max]</h2>",UIP_DS6_ROUTE_NB); ADD("<h2>Routes [%u max]</h2>",UIP_DS6_ROUTE_NB);
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf); PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
blen = 0; blen = 0;
uip_ds6_route_t *route; uip_ds6_route_t *route;
for(route = uip_ds6_route_list_head(); route != NULL; route = list_item_next(route)) { for(route = uip_ds6_route_head();
route != NULL;
route = uip_ds6_route_next(route)) {
ipaddr_add(&route->ipaddr); ipaddr_add(&route->ipaddr);
ADD("/%u (via ", route->length); ADD("/%u (via ", route->length);
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf); PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
blen=0; blen=0;
ipaddr_add(&route->nexthop); ipaddr_add(uip_ds6_route_nexthop(route));
if(route->state.lifetime < 600) { if(route->state.lifetime < 600) {
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf); PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
blen=0; blen=0;

View file

@ -69,7 +69,6 @@ static int8_t len;
#define REQUEST_TYPE_TOTALS 0xFF #define REQUEST_TYPE_TOTALS 0xFF
extern uip_ds6_netif_t uip_ds6_if; extern uip_ds6_netif_t uip_ds6_if;
extern uip_ds6_nbr_t uip_ds6_nbr_cache[UIP_DS6_NBR_NB];
static uip_ds6_route_t *rt; static uip_ds6_route_t *rt;
static uip_ds6_defrt_t *defrt; static uip_ds6_defrt_t *defrt;
static uip_ipaddr_t *addr; static uip_ipaddr_t *addr;
@ -82,6 +81,7 @@ process_request() CC_NON_BANKED
uint8_t i; uint8_t i;
uint8_t left; uint8_t left;
uint8_t entry_size; uint8_t entry_size;
uip_ds6_nbr_t *nbr;
left = VIZTOOL_MAX_PAYLOAD_LEN - 1; left = VIZTOOL_MAX_PAYLOAD_LEN - 1;
len = 2; /* start filling the buffer from position [2] */ len = 2; /* start filling the buffer from position [2] */
@ -89,46 +89,44 @@ process_request() CC_NON_BANKED
if(buf[0] == REQUEST_TYPE_ND) { if(buf[0] == REQUEST_TYPE_ND) {
/* Neighbors */ /* Neighbors */
PRINTF("Neighbors\n"); PRINTF("Neighbors\n");
for(i = buf[1]; i < UIP_DS6_NBR_NB; i++) { for(nbr = nbr_table_head(ds6_neighbors);
if(uip_ds6_nbr_cache[i].isused) { nbr != NULL;
entry_size = sizeof(i) + sizeof(uip_ipaddr_t) + sizeof(uip_lladdr_t) nbr = nbr_table_next(ds6_neighbors, nbr)) {
+ sizeof(uip_ds6_nbr_cache[i].state); entry_size = sizeof(i) + sizeof(uip_ipaddr_t) + sizeof(uip_lladdr_t)
PRINTF("%02u: ", i); + sizeof(nbr->state);
PRINT6ADDR(&uip_ds6_nbr_cache[i].ipaddr); PRINTF("%02u: ", i);
PRINTF(" - "); PRINT6ADDR(&nbr->ipaddr);
PRINTLLADDR(&uip_ds6_nbr_cache[i].lladdr); PRINTF(" - ");
PRINTF(" - %u\n", uip_ds6_nbr_cache[i].state); PRINTLLADDR(&nbr->lladdr);
PRINTF(" - %u\n", nbr->state);
memcpy(buf + len, &i, sizeof(i)); memcpy(buf + len, &i, sizeof(i));
len += sizeof(i); len += sizeof(i);
memcpy(buf + len, &uip_ds6_nbr_cache[i].ipaddr, sizeof(uip_ipaddr_t)); memcpy(buf + len, uip_ds6_nbr_get_ipaddr(nbr), sizeof(uip_ipaddr_t));
len += sizeof(uip_ipaddr_t); len += sizeof(uip_ipaddr_t);
memcpy(buf + len, &uip_ds6_nbr_cache[i].lladdr, sizeof(uip_lladdr_t)); memcpy(buf + len, uip_ds6_nbr_get_ll(nbr), sizeof(uip_lladdr_t));
len += sizeof(uip_lladdr_t); len += sizeof(uip_lladdr_t);
memcpy(buf + len, &uip_ds6_nbr_cache[i].state, memcpy(buf + len, &nbr->state,
sizeof(uip_ds6_nbr_cache[i].state)); sizeof(nbr->state));
len += sizeof(uip_ds6_nbr_cache[i].state); len += sizeof(nbr->state);
count++; count++;
left -= entry_size; left -= entry_size;
if(left < entry_size) { if(left < entry_size) {
break; break;
}
} }
} }
} else if(buf[0] == REQUEST_TYPE_RT) { } else if(buf[0] == REQUEST_TYPE_RT) {
uint32_t flip = 0; uint32_t flip = 0;
PRINTF("Routing table\n"); PRINTF("Routing table\n");
rt = uip_ds6_route_list_head(); rt = uip_ds6_route_head();
for(i = buf[1]; i < uip_ds6_route_num_routes(); i++) { for(i = buf[1]; i < uip_ds6_route_num_routes(); i++) {
if(rt != NULL) { if(rt != NULL) {
entry_size = sizeof(i) + sizeof(rt->ipaddr) entry_size = sizeof(i) + sizeof(rt->ipaddr)
+ sizeof(rt->length) + sizeof(rt->length)
+ sizeof(rt->metric)
+ sizeof(rt->nexthop)
+ sizeof(rt->state.lifetime) + sizeof(rt->state.lifetime)
+ sizeof(rt->state.learned_from); + sizeof(rt->state.learned_from);
@ -138,16 +136,11 @@ process_request() CC_NON_BANKED
len += sizeof(rt->ipaddr); len += sizeof(rt->ipaddr);
memcpy(buf + len, &rt->length, sizeof(rt->length)); memcpy(buf + len, &rt->length, sizeof(rt->length));
len += sizeof(rt->length); len += sizeof(rt->length);
memcpy(buf + len, &rt->metric, sizeof(rt->metric));
len += sizeof(rt->metric);
memcpy(buf + len, &rt->nexthop, sizeof(rt->nexthop));
len += sizeof(rt->nexthop);
PRINT6ADDR(&rt->ipaddr); PRINT6ADDR(&rt->ipaddr);
PRINTF(" - %02x", rt->length); PRINTF(" - %02x", rt->length);
PRINTF(" - %02x", rt->metric);
PRINTF(" - "); PRINTF(" - ");
PRINT6ADDR(&rt->nexthop); PRINT6ADDR(uip_ds6_route_nexthop(rt));
flip = uip_htonl(rt->state.lifetime); flip = uip_htonl(rt->state.lifetime);
memcpy(buf + len, &flip, sizeof(flip)); memcpy(buf + len, &flip, sizeof(flip));
@ -163,7 +156,7 @@ process_request() CC_NON_BANKED
count++; count++;
left -= entry_size; left -= entry_size;
rt = list_item_next(rt); rt = uip_ds6_route_next(rt);
if(left < entry_size) { if(left < entry_size) {
break; break;
@ -226,10 +219,10 @@ process_request() CC_NON_BANKED
buf[2]++; buf[2]++;
} }
} }
for(i = 0; i < UIP_DS6_NBR_NB; i++) { for(nbr = nbr_table_head(ds6_neighbors);
if(uip_ds6_nbr_cache[i].isused) { nbr != NULL;
nbr = nbr_table_next(ds6_neighbors, nbr)) {
buf[3]++; buf[3]++;
}
} }
buf[4] = uip_ds6_route_num_routes(); buf[4] = uip_ds6_route_num_routes();

View file

@ -239,7 +239,7 @@ radio_uip_uaodv_send(void)
} }
/* Add header and buffer packet for persistent transmission */ /* Add header and buffer packet for persistent transmission */
uip_len = radio_uip_uaodv_add_header(&uip_buf[UIP_LLH_LEN], uip_len, &route->nexthop); /* TODO Correct? */ uip_len = radio_uip_uaodv_add_header(&uip_buf[UIP_LLH_LEN], uip_len, uip_ds6_route_nexthop(route)); /* TODO Correct? */
return radio_uip_buffer_outgoing_packet( return radio_uip_buffer_outgoing_packet(
&uip_buf[UIP_LLH_LEN], &uip_buf[UIP_LLH_LEN],
uip_len, uip_len,

View file

@ -593,8 +593,6 @@ if ((clocktime%PINGS)==1) {
#if ROUTES && UIP_CONF_IPV6 #if ROUTES && UIP_CONF_IPV6
if ((clocktime%ROUTES)==2) { if ((clocktime%ROUTES)==2) {
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
extern uip_ds6_route_t uip_ds6_routing_table[];
extern uip_ds6_netif_t uip_ds6_if; extern uip_ds6_netif_t uip_ds6_if;
uint8_t i,j; uint8_t i,j;
@ -605,13 +603,14 @@ extern uip_ds6_netif_t uip_ds6_if;
printf("\n"); printf("\n");
} }
} }
printf("\nNeighbors [%u max]\n",UIP_DS6_NBR_NB); printf("\nNeighbors [%u max]\n",NEIGHBOR_TABLE_MAX_NEIGHBORS);
for(i = 0,j=1; i < UIP_DS6_NBR_NB; i++) { uip_ds6_nbr_t *nbr;
if(uip_ds6_nbr_cache[i].isused) { for(nbr = nbr_table_head(ds6_neighbors);
uip_debug_ipaddr_print(&uip_ds6_nbr_cache[i].ipaddr); nbr != NULL;
nbr = nbr_table_next(ds6_neighbors, nbr)) {
uip_debug_ipaddr_print(&nbr->ipaddr);
printf("\n"); printf("\n");
j=0; j=0;
}
} }
if (j) printf(" <none>"); if (j) printf(" <none>");
PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB);
@ -619,17 +618,13 @@ extern uip_ds6_netif_t uip_ds6_if;
uip_ds6_route_t *r; uip_ds6_route_t *r;
PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB);
j = 1; j = 1;
for(r = uip_ds6_route_list_head(); for(r = uip_ds6_route_head();
r != NULL; r != NULL;
r = list_item_next(r)) { r = uip_ds6_route_next(r)) {
ipaddr_add(&r->ipaddr); ipaddr_add(&r->ipaddr);
PRINTF("/%u (via ", r->length); PRINTF("/%u (via ", r->length);
ipaddr_add(&r->nexthop); ipaddr_add(uip_ds6_route_nexthop(r));
// if(uip_ds6_routing_table[i].state.lifetime < 600) { PRINTF(") %lus\n", r->state.lifetime);
PRINTF(") %lus\n", r->state.lifetime);
// } else {
// PRINTF(")\n");
// }
j = 0; j = 0;
} }
} }

View file

@ -69,7 +69,6 @@ static int8_t len;
#define REQUEST_TYPE_TOTALS 0xFF #define REQUEST_TYPE_TOTALS 0xFF
extern uip_ds6_netif_t uip_ds6_if; extern uip_ds6_netif_t uip_ds6_if;
extern uip_ds6_nbr_t uip_ds6_nbr_cache[UIP_DS6_NBR_NB];
static uip_ds6_route_t *rt; static uip_ds6_route_t *rt;
static uip_ds6_defrt_t *defrt; static uip_ds6_defrt_t *defrt;
static uip_ipaddr_t *addr; static uip_ipaddr_t *addr;
@ -82,6 +81,7 @@ process_request() CC_NON_BANKED
uint8_t i; uint8_t i;
uint8_t left; uint8_t left;
uint8_t entry_size; uint8_t entry_size;
uip_ds6_nbr_t *nbr;
left = VIZTOOL_MAX_PAYLOAD_LEN - 1; left = VIZTOOL_MAX_PAYLOAD_LEN - 1;
len = 2; /* start filling the buffer from position [2] */ len = 2; /* start filling the buffer from position [2] */
@ -89,46 +89,44 @@ process_request() CC_NON_BANKED
if(buf[0] == REQUEST_TYPE_ND) { if(buf[0] == REQUEST_TYPE_ND) {
/* Neighbors */ /* Neighbors */
PRINTF("Neighbors\n"); PRINTF("Neighbors\n");
for(i = buf[1]; i < UIP_DS6_NBR_NB; i++) { for(nbr = nbr_table_head(ds6_neighbors);
if(uip_ds6_nbr_cache[i].isused) { nbr != NULL;
entry_size = sizeof(i) + sizeof(uip_ipaddr_t) + sizeof(uip_lladdr_t) nbr = nbr_table_next(ds6_neighbors, nbr)) {
+ sizeof(uip_ds6_nbr_cache[i].state); entry_size = sizeof(i) + sizeof(uip_ipaddr_t) + sizeof(uip_lladdr_t)
PRINTF("%02u: ", i); + sizeof(nbr->state);
PRINT6ADDR(&uip_ds6_nbr_cache[i].ipaddr); PRINTF("%02u: ", i);
PRINTF(" - "); PRINT6ADDR(&nbr->ipaddr);
PRINTLLADDR(&uip_ds6_nbr_cache[i].lladdr); PRINTF(" - ");
PRINTF(" - %u\n", uip_ds6_nbr_cache[i].state); PRINTLLADDR(&nbr->lladdr);
PRINTF(" - %u\n", nbr->state);
memcpy(buf + len, &i, sizeof(i)); memcpy(buf + len, &i, sizeof(i));
len += sizeof(i); len += sizeof(i);
memcpy(buf + len, &uip_ds6_nbr_cache[i].ipaddr, sizeof(uip_ipaddr_t)); memcpy(buf + len, uip_ds6_nbr_get_ipaddr(nbr), sizeof(uip_ipaddr_t));
len += sizeof(uip_ipaddr_t); len += sizeof(uip_ipaddr_t);
memcpy(buf + len, &uip_ds6_nbr_cache[i].lladdr, sizeof(uip_lladdr_t)); memcpy(buf + len, uip_ds6_nbr_get_ll(nbr), sizeof(uip_lladdr_t));
len += sizeof(uip_lladdr_t); len += sizeof(uip_lladdr_t);
memcpy(buf + len, &uip_ds6_nbr_cache[i].state, memcpy(buf + len, &nbr->state,
sizeof(uip_ds6_nbr_cache[i].state)); sizeof(nbr->state));
len += sizeof(uip_ds6_nbr_cache[i].state); len += sizeof(nbr->state);
count++; count++;
left -= entry_size; left -= entry_size;
if(left < entry_size) { if(left < entry_size) {
break; break;
}
} }
} }
} else if(buf[0] == REQUEST_TYPE_RT) { } else if(buf[0] == REQUEST_TYPE_RT) {
uint32_t flip = 0; uint32_t flip = 0;
PRINTF("Routing table\n"); PRINTF("Routing table\n");
rt = uip_ds6_route_list_head(); rt = uip_ds6_route_head();
for(i = buf[1]; i < uip_ds6_route_num_routes(); i++) { for(i = buf[1]; i < uip_ds6_route_num_routes(); i++) {
if(rt != NULL) { if(rt != NULL) {
entry_size = sizeof(i) + sizeof(rt->ipaddr) entry_size = sizeof(i) + sizeof(rt->ipaddr)
+ sizeof(rt->length) + sizeof(rt->length)
+ sizeof(rt->metric)
+ sizeof(rt->nexthop)
+ sizeof(rt->state.lifetime) + sizeof(rt->state.lifetime)
+ sizeof(rt->state.learned_from); + sizeof(rt->state.learned_from);
@ -138,16 +136,11 @@ process_request() CC_NON_BANKED
len += sizeof(rt->ipaddr); len += sizeof(rt->ipaddr);
memcpy(buf + len, &rt->length, sizeof(rt->length)); memcpy(buf + len, &rt->length, sizeof(rt->length));
len += sizeof(rt->length); len += sizeof(rt->length);
memcpy(buf + len, &rt->metric, sizeof(rt->metric));
len += sizeof(rt->metric);
memcpy(buf + len, &rt->nexthop, sizeof(rt->nexthop));
len += sizeof(rt->nexthop);
PRINT6ADDR(&rt->ipaddr); PRINT6ADDR(&rt->ipaddr);
PRINTF(" - %02x", rt->length); PRINTF(" - %02x", rt->length);
PRINTF(" - %02x", rt->metric);
PRINTF(" - "); PRINTF(" - ");
PRINT6ADDR(&rt->nexthop); PRINT6ADDR(uip_ds6_route_nexthop(rt));
flip = uip_htonl(rt->state.lifetime); flip = uip_htonl(rt->state.lifetime);
memcpy(buf + len, &flip, sizeof(flip)); memcpy(buf + len, &flip, sizeof(flip));
@ -163,7 +156,7 @@ process_request() CC_NON_BANKED
count++; count++;
left -= entry_size; left -= entry_size;
rt = list_item_next(rt); rt = uip_ds6_route_next(rt);
if(left < entry_size) { if(left < entry_size) {
break; break;
@ -226,10 +219,10 @@ process_request() CC_NON_BANKED
buf[2]++; buf[2]++;
} }
} }
for(i = 0; i < UIP_DS6_NBR_NB; i++) { for(nbr = nbr_table_head(ds6_neighbors);
if(uip_ds6_nbr_cache[i].isused) { nbr != NULL;
nbr = nbr_table_next(ds6_neighbors, nbr)) {
buf[3]++; buf[3]++;
}
} }
buf[4] = uip_ds6_route_num_routes(); buf[4] = uip_ds6_route_num_routes();

View file

@ -127,3 +127,10 @@ uip_icmp6chksum(void)
{ {
return upper_layer_chksum(UIP_PROTO_ICMP6); return upper_layer_chksum(UIP_PROTO_ICMP6);
} }
/*---------------------------------------------------------------------------*/
void
uip_ds6_link_neighbor_callback(int status, int numtx)
{
}

View file

@ -127,3 +127,9 @@ uip_icmp6chksum(void)
{ {
return upper_layer_chksum(UIP_PROTO_ICMP6); return upper_layer_chksum(UIP_PROTO_ICMP6);
} }
/*---------------------------------------------------------------------------*/
void
uip_ds6_link_neighbor_callback(int status, int numtx)
{
}

View file

@ -73,3 +73,9 @@ uip_icmp6chksum(void)
{ {
return upper_layer_chksum(UIP_PROTO_ICMP6); return upper_layer_chksum(UIP_PROTO_ICMP6);
} }
/*---------------------------------------------------------------------------*/
void
uip_ds6_link_neighbor_callback(int status, int numtx)
{
}