Make DODAG ID selection RFC 6550-compliant

Some calls to `rpl_set_root` select a hardcoded DODAG ID
(0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011)

This is against what RFC 6550 says. We change these calls
to select a DODAG ID corresponding to a routable v6 address
corresponding to the root
This commit is contained in:
George Oikonomou 2014-06-12 00:09:53 +01:00
parent 32bc98b0da
commit a9e7bea675
2 changed files with 14 additions and 18 deletions

View file

@ -61,8 +61,6 @@
#define MAX_SENSORS 4 #define MAX_SENSORS 4
uint16_t dag_id[] = {0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011};
extern long slip_sent; extern long slip_sent;
extern long slip_received; extern long slip_received;
@ -290,6 +288,7 @@ border_router_set_sensors(const char *data, int len)
static void static void
set_prefix_64(const uip_ipaddr_t *prefix_64) set_prefix_64(const uip_ipaddr_t *prefix_64)
{ {
rpl_dag_t *dag;
uip_ipaddr_t ipaddr; uip_ipaddr_t ipaddr;
memcpy(&prefix, prefix_64, 16); memcpy(&prefix, prefix_64, 16);
memcpy(&ipaddr, prefix_64, 16); memcpy(&ipaddr, prefix_64, 16);
@ -297,12 +296,17 @@ set_prefix_64(const uip_ipaddr_t *prefix_64)
prefix_set = 1; prefix_set = 1;
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &ipaddr);
if(dag != NULL) {
rpl_set_prefix(dag, &prefix, 64);
PRINTF("created a new RPL dag\n");
}
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_THREAD(border_router_process, ev, data) PROCESS_THREAD(border_router_process, ev, data)
{ {
static struct etimer et; static struct etimer et;
rpl_dag_t *dag;
PROCESS_BEGIN(); PROCESS_BEGIN();
prefix_set = 0; prefix_set = 0;
@ -336,12 +340,6 @@ PROCESS_THREAD(border_router_process, ev, data)
} }
} }
dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id);
if(dag != NULL) {
rpl_set_prefix(dag, &prefix, 64);
PRINTF("created a new RPL dag\n");
}
#if DEBUG #if DEBUG
print_local_addresses(); print_local_addresses();
#endif #endif

View file

@ -54,8 +54,6 @@
#define DEBUG DEBUG_NONE #define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h" #include "net/ip/uip-debug.h"
uint16_t dag_id[] = {0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011};
static uip_ipaddr_t prefix; static uip_ipaddr_t prefix;
static uint8_t prefix_set; static uint8_t prefix_set;
@ -320,18 +318,24 @@ request_prefix(void)
void void
set_prefix_64(uip_ipaddr_t *prefix_64) set_prefix_64(uip_ipaddr_t *prefix_64)
{ {
rpl_dag_t *dag;
uip_ipaddr_t ipaddr; uip_ipaddr_t ipaddr;
memcpy(&prefix, prefix_64, 16); memcpy(&prefix, prefix_64, 16);
memcpy(&ipaddr, prefix_64, 16); memcpy(&ipaddr, prefix_64, 16);
prefix_set = 1; prefix_set = 1;
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &ipaddr);
if(dag != NULL) {
rpl_set_prefix(dag, &prefix, 64);
PRINTF("created a new RPL dag\n");
}
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_THREAD(border_router_process, ev, data) PROCESS_THREAD(border_router_process, ev, data)
{ {
static struct etimer et; static struct etimer et;
rpl_dag_t *dag;
PROCESS_BEGIN(); PROCESS_BEGIN();
@ -363,12 +367,6 @@ PROCESS_THREAD(border_router_process, ev, data)
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
} }
dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id);
if(dag != NULL) {
rpl_set_prefix(dag, &prefix, 64);
PRINTF("created a new RPL dag\n");
}
/* Now turn the radio on, but disable radio duty cycling. /* Now turn the radio on, but disable radio duty cycling.
* Since we are the DAG root, reception delays would constrain mesh throughbut. * Since we are the DAG root, reception delays would constrain mesh throughbut.
*/ */