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,17 +269,27 @@ 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) {
|
||||||
version = dag->version;
|
for(i = 0; i < RPL_MAX_DAG_PER_INSTANCE; ++i) {
|
||||||
RPL_LOLLIPOP_INCREMENT(version);
|
dag = &instance->dag_table[i];
|
||||||
PRINTF("RPL: Dropping a joined DAG when setting this node as root");
|
if(dag->used) {
|
||||||
if(dag == dag->instance->current_dag) {
|
if(uip_ipaddr_cmp(&dag->dag_id, dag_id)) {
|
||||||
dag->instance->current_dag = NULL;
|
version = dag->version;
|
||||||
|
RPL_LOLLIPOP_INCREMENT(version);
|
||||||
|
}
|
||||||
|
if(dag == dag->instance->current_dag) {
|
||||||
|
PRINTF("RPL: Dropping a joined DAG when setting this node as root");
|
||||||
|
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);
|
||||||
|
|
Loading…
Reference in a new issue