2015-08-26 13:26:32 +00:00
|
|
|
#include "contiki.h"
|
|
|
|
#include "contiki-net.h"
|
|
|
|
#include "ip64.h"
|
|
|
|
#include "net/netstack.h"
|
2015-10-01 15:08:44 +00:00
|
|
|
#include "net/rpl/rpl-dag-root.h"
|
2015-09-22 18:13:31 +00:00
|
|
|
#include "net/rpl/rpl.h"
|
|
|
|
#include "net/ipv6/uip-ds6-route.h"
|
|
|
|
#include <stdio.h>
|
2015-08-26 13:26:32 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
PROCESS(router_node_process, "Router node");
|
|
|
|
AUTOSTART_PROCESSES(&router_node_process);
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2015-09-22 18:13:31 +00:00
|
|
|
uip_lladdr_t * uip_ds6_route_nexthop_lladdr(uip_ds6_route_t *route);
|
|
|
|
|
|
|
|
|
2015-08-26 13:26:32 +00:00
|
|
|
PROCESS_THREAD(router_node_process, ev, data)
|
|
|
|
{
|
2015-09-22 18:13:31 +00:00
|
|
|
uip_ipaddr_t *nexthop = NULL;
|
|
|
|
uip_ds6_defrt_t *defrt;
|
|
|
|
uip_ipaddr_t *ipaddr;
|
|
|
|
uip_ds6_route_t *r;
|
|
|
|
static struct etimer et;
|
2015-08-26 13:26:32 +00:00
|
|
|
PROCESS_BEGIN();
|
|
|
|
|
|
|
|
/* Set us up as a RPL root node. */
|
|
|
|
rpl_dag_root_init_dag();
|
|
|
|
|
|
|
|
/* Initialize the IP64 module so we'll start translating packets */
|
|
|
|
ip64_init();
|
|
|
|
|
2015-09-22 18:13:31 +00:00
|
|
|
/* etimer_set(&et, CLOCK_SECOND * 60); */
|
|
|
|
/* PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); */
|
|
|
|
|
2015-08-26 13:26:32 +00:00
|
|
|
/* ... and do nothing more. */
|
|
|
|
while(1) {
|
2015-09-22 18:13:31 +00:00
|
|
|
etimer_set(&et, CLOCK_SECOND * 20);
|
|
|
|
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
|
|
|
|
|
|
|
defrt = NULL;
|
|
|
|
if((ipaddr = uip_ds6_defrt_choose()) != NULL) {
|
|
|
|
defrt = uip_ds6_defrt_lookup(ipaddr);
|
|
|
|
}
|
|
|
|
if(defrt != NULL) {
|
|
|
|
printf("DefRT: :: -> %02d", defrt->ipaddr.u8[15]);
|
|
|
|
printf(" lt:%lu inf:%d\n", stimer_remaining(&defrt->lifetime),
|
|
|
|
defrt->isinfinite);
|
|
|
|
} else {
|
|
|
|
printf("DefRT: :: -> NULL\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(uip_ds6_route_head() != NULL) {
|
|
|
|
printf("found head\n");
|
|
|
|
for(r = uip_ds6_route_head();
|
|
|
|
r != NULL;
|
|
|
|
r = uip_ds6_route_next(r)) {
|
|
|
|
nexthop = uip_ds6_route_nexthop(r);
|
|
|
|
if(nexthop != NULL) {
|
|
|
|
printf("Route: %02d -> %02d", r->ipaddr.u8[15], nexthop->u8[15]);
|
|
|
|
} else {
|
|
|
|
//printf("Route: %p %02d -> ? nbr-routes:%p", r, r->ipaddr.u8[15],
|
|
|
|
//r->neighbor_routes);
|
|
|
|
}
|
|
|
|
printf(" lt:%lu\n", r->state.lifetime);
|
|
|
|
}
|
|
|
|
}
|
2015-08-26 13:26:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PROCESS_END();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|