From 24a38a3aa82097f0cc35422b4d7ffb5564310ebc Mon Sep 17 00:00:00 2001 From: Joakim Eriksson Date: Tue, 29 Sep 2015 18:24:03 +0200 Subject: [PATCH] check if objective function is supported before adding as parent and creating a dag --- core/net/rpl/rpl-dag.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index 89be40184..9d140fbd4 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -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) {