diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index f3c3f63c0..e4fe78596 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -32,7 +32,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rpl-dag.c,v 1.10 2010/05/29 22:23:21 nvt-se Exp $ + * $Id: rpl-dag.c,v 1.11 2010/05/31 14:22:00 nvt-se Exp $ */ /** * \file @@ -459,6 +459,7 @@ global_repair(uip_ipaddr_t *from, rpl_dag_t *dag, rpl_dio_t *dio) dag->rank = INFINITE_RANK; } else { rpl_set_default_route(dag, from); + dag->of->reset(dag); dag->rank = dag->of->increment_rank(dio->dag_rank, p); rpl_reset_dio_timer(dag, 1); } @@ -505,8 +506,20 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio) return; } + if(memcmp(&dag->dag_id, &dio->dag_id, sizeof(dag->dag_id))) { + PRINTF("RPL: Ignoring DIO for another DAG within our instance\n"); + return; + } + if(dio->sequence_number > dag->sequence_number) { - global_repair(from, dag, dio); + if(dag->rank == ROOT_RANK) { + PRINTF("RPL: Root received inconsistent DIO sequence number\n"); + dag->sequence_number = dio->sequence_number + 1; + rpl_reset_dio_timer(dag, 1); + return; + } else { + global_repair(from, dag, dio); + } return; } diff --git a/core/net/rpl/rpl-of-etx.c b/core/net/rpl/rpl-of-etx.c index 34b5ed7c8..ec73933f1 100644 --- a/core/net/rpl/rpl-of-etx.c +++ b/core/net/rpl/rpl-of-etx.c @@ -32,7 +32,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rpl-of-etx.c,v 1.1 2010/05/29 22:23:21 nvt-se Exp $ + * $Id: rpl-of-etx.c,v 1.2 2010/05/31 14:22:00 nvt-se Exp $ */ /** * \file @@ -46,11 +46,13 @@ #define DEBUG DEBUG_ANNOTATE #include "net/uip-debug.h" +static void reset(void *); static void parent_state_callback(rpl_parent_t *, int, int); static rpl_parent_t *best_parent(rpl_parent_t *, rpl_parent_t *); static rpl_rank_t increment_rank(rpl_rank_t, rpl_parent_t *); rpl_of_t rpl_of_etx = { + reset, parent_state_callback, best_parent, increment_rank, @@ -68,6 +70,12 @@ typedef unsigned char etx_t; static etx_t min_path_etx = INFINITY; +static void +reset(void *dag) +{ + min_path_etx = INFINITY; +} + static void parent_state_callback(rpl_parent_t *parent, int known, int etx) { diff --git a/core/net/rpl/rpl-of0.c b/core/net/rpl/rpl-of0.c index 8a924cd7a..0cf795d14 100644 --- a/core/net/rpl/rpl-of0.c +++ b/core/net/rpl/rpl-of0.c @@ -32,7 +32,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rpl-of0.c,v 1.3 2010/05/29 22:23:21 nvt-se Exp $ + * $Id: rpl-of0.c,v 1.4 2010/05/31 14:22:00 nvt-se Exp $ */ /** * \file @@ -46,10 +46,12 @@ #define DEBUG DEBUG_ANNOTATE #include "net/uip-debug.h" +static void reset(void *); static rpl_parent_t *best_parent(rpl_parent_t *, rpl_parent_t *); static rpl_rank_t increment_rank(rpl_rank_t, rpl_parent_t *); rpl_of_t rpl_of0 = { + reset, NULL, best_parent, increment_rank, @@ -61,6 +63,12 @@ rpl_of_t rpl_of0 = { #define MAXIMUM_RANK_INCREMENT 16 #define MAXIMUM_RANK_STRETCH 4 +static void +reset(void *dag) +{ + PRINTF("RPL: Resetting OF0\n"); +} + static rpl_rank_t increment_rank(rpl_rank_t rank, rpl_parent_t *parent) { diff --git a/core/net/rpl/rpl.h b/core/net/rpl/rpl.h index 0d04d12ac..79fe7564d 100644 --- a/core/net/rpl/rpl.h +++ b/core/net/rpl/rpl.h @@ -30,7 +30,7 @@ * * Author: Joakim Eriksson, Nicolas Tsiftes * - * $Id: rpl.h,v 1.5 2010/05/29 22:23:21 nvt-se Exp $ + * $Id: rpl.h,v 1.6 2010/05/31 14:22:00 nvt-se Exp $ */ #ifndef RPL_H @@ -138,6 +138,7 @@ struct rpl_parent { typedef struct rpl_parent rpl_parent_t; struct rpl_of { + void (*reset)(void *); void (*parent_state_callback)(rpl_parent_t *, int, int); rpl_parent_t *(*best_parent)(rpl_parent_t *, rpl_parent_t *); rpl_rank_t (*increment_rank)(rpl_rank_t, rpl_parent_t *);