Merge pull request #1016 from cetic/pr-cleanup-dodag-when-root
Remove all the DODAG from the instance when the node is set as Root
This commit is contained in:
commit
71427ed4cc
|
@ -269,18 +269,28 @@ rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id)
|
||||||
rpl_dag_t *dag;
|
rpl_dag_t *dag;
|
||||||
rpl_instance_t *instance;
|
rpl_instance_t *instance;
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
|
int i;
|
||||||
|
|
||||||
version = RPL_LOLLIPOP_INIT;
|
version = RPL_LOLLIPOP_INIT;
|
||||||
dag = get_dag(instance_id, dag_id);
|
instance = rpl_get_instance(instance_id);
|
||||||
if(dag != NULL) {
|
if(instance != NULL) {
|
||||||
|
for(i = 0; i < RPL_MAX_DAG_PER_INSTANCE; ++i) {
|
||||||
|
dag = &instance->dag_table[i];
|
||||||
|
if(dag->used) {
|
||||||
|
if(uip_ipaddr_cmp(&dag->dag_id, dag_id)) {
|
||||||
version = dag->version;
|
version = dag->version;
|
||||||
RPL_LOLLIPOP_INCREMENT(version);
|
RPL_LOLLIPOP_INCREMENT(version);
|
||||||
PRINTF("RPL: Dropping a joined DAG when setting this node as root");
|
}
|
||||||
if(dag == dag->instance->current_dag) {
|
if(dag == dag->instance->current_dag) {
|
||||||
|
PRINTF("RPL: Dropping a joined DAG when setting this node as root");
|
||||||
dag->instance->current_dag = NULL;
|
dag->instance->current_dag = NULL;
|
||||||
|
} else {
|
||||||
|
PRINTF("RPL: Dropping a DAG when setting this node as root");
|
||||||
}
|
}
|
||||||
rpl_free_dag(dag);
|
rpl_free_dag(dag);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dag = rpl_alloc_dag(instance_id, dag_id);
|
dag = rpl_alloc_dag(instance_id, dag_id);
|
||||||
if(dag == NULL) {
|
if(dag == NULL) {
|
||||||
|
|
Loading…
Reference in a new issue