Skip to content

Commit

Permalink
Merge pull request #718 from g-oikonomou/rpl-dodagid-compliance
Browse files Browse the repository at this point in the history
Make DODAG ID selection RFC 6550-compliant
  • Loading branch information
Nicolas Tsiftes committed Jun 13, 2014
2 parents 4ce3e4d + a9e7bea commit 24e2609
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion core/net/rpl/rpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ struct rpl_instance {
/* Public RPL functions. */
void rpl_init(void);
void uip_rpl_input(void);
rpl_dag_t *rpl_set_root(uint8_t instance_id, uip_ipaddr_t * dag_id);
rpl_dag_t *rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id);
int rpl_set_prefix(rpl_dag_t *dag, uip_ipaddr_t *prefix, unsigned len);
int rpl_repair_root(uint8_t instance_id);
int rpl_set_default_route(rpl_instance_t *instance, uip_ipaddr_t *from);
Expand Down
16 changes: 7 additions & 9 deletions examples/ipv6/native-border-router/border-router.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@

#define MAX_SENSORS 4

uint16_t dag_id[] = {0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011};

extern long slip_sent;
extern long slip_received;

Expand Down Expand Up @@ -290,19 +288,25 @@ border_router_set_sensors(const char *data, int len)
static void
set_prefix_64(const uip_ipaddr_t *prefix_64)
{
rpl_dag_t *dag;
uip_ipaddr_t ipaddr;
memcpy(&prefix, prefix_64, 16);
memcpy(&ipaddr, prefix_64, 16);

prefix_set = 1;
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
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)
{
static struct etimer et;
rpl_dag_t *dag;

PROCESS_BEGIN();
prefix_set = 0;
Expand Down Expand Up @@ -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
print_local_addresses();
#endif
Expand Down
16 changes: 7 additions & 9 deletions examples/ipv6/rpl-border-router/border-router.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"

uint16_t dag_id[] = {0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011};

static uip_ipaddr_t prefix;
static uint8_t prefix_set;

Expand Down Expand Up @@ -320,18 +318,24 @@ request_prefix(void)
void
set_prefix_64(uip_ipaddr_t *prefix_64)
{
rpl_dag_t *dag;
uip_ipaddr_t ipaddr;
memcpy(&prefix, prefix_64, 16);
memcpy(&ipaddr, prefix_64, 16);
prefix_set = 1;
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
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)
{
static struct etimer et;
rpl_dag_t *dag;

PROCESS_BEGIN();

Expand Down Expand Up @@ -363,12 +367,6 @@ PROCESS_THREAD(border_router_process, ev, data)
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.
* Since we are the DAG root, reception delays would constrain mesh throughbut.
*/
Expand Down

0 comments on commit 24e2609

Please sign in to comment.