moved code for autoconfiguring global address into join_dag

This commit is contained in:
joxe 2010-06-03 18:37:47 +00:00
parent a9498df8f5
commit 17209e8fa4
2 changed files with 17 additions and 20 deletions

View file

@ -32,7 +32,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rpl-dag.c,v 1.17 2010/06/03 15:20:56 nvt-se Exp $
* $Id: rpl-dag.c,v 1.18 2010/06/03 18:37:47 joxe Exp $
*/
/**
* \file
@ -398,6 +398,21 @@ join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
return;
}
/* Autoconfigure an address if this node does not already have an address
with this prefix. */
if((dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS)) {
uip_ipaddr_t ipaddr;
/* assume that the prefix ends with zeros! */
memcpy(&ipaddr, &dio->prefix_info.prefix, 16);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
if(uip_ds6_addr_lookup(&ipaddr) == NULL) {
PRINTF("RPL: adding global IP address ");
PRINT6ADDR(&ipaddr);
PRINTF("\n");
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
}
}
dag->joined = 1;
dag->used = 1;
dag->of = of;