Merge pull request #1288 from joakimeriksson/rpl-early-ocp-check

RPL: check if objective function is supported before creating dag.
This commit is contained in:
Nicolas Tsiftes 2015-09-29 21:56:55 +02:00
commit 881cd25484

View File

@ -938,6 +938,15 @@ rpl_join_instance(uip_ipaddr_t *from, rpl_dio_t *dio)
rpl_parent_t *p;
rpl_of_t *of;
/* Determine the objective function by using the
objective code point of the DIO. */
of = rpl_find_of(dio->ocp);
if(of == NULL) {
PRINTF("RPL: DIO for DAG instance %u does not specify a supported OF: %u\n",
dio->instance_id, dio->ocp);
return;
}
dag = rpl_alloc_dag(dio->instance_id, &dio->dag_id);
if(dag == NULL) {
PRINTF("RPL: Failed to allocate a DAG object!\n");
@ -958,17 +967,6 @@ rpl_join_instance(uip_ipaddr_t *from, rpl_dio_t *dio)
p->dtsn = dio->dtsn;
PRINTF("succeeded\n");
/* Determine the objective function by using the
objective code point of the DIO. */
of = rpl_find_of(dio->ocp);
if(of == NULL) {
PRINTF("RPL: DIO for DAG instance %u does not specify a supported OF\n",
dio->instance_id);
rpl_remove_parent(p);
instance->used = 0;
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) {