From 63ab1ffce0204502195f34ad607881d49ee273a2 Mon Sep 17 00:00:00 2001 From: joxe Date: Mon, 20 Sep 2010 15:30:12 +0000 Subject: [PATCH] clear default route when neighbour is removed --- core/net/rpl/rpl.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/core/net/rpl/rpl.c b/core/net/rpl/rpl.c index 7879b7e51..543fd1c54 100644 --- a/core/net/rpl/rpl.c +++ b/core/net/rpl/rpl.c @@ -32,7 +32,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rpl.c,v 1.8 2010/06/14 18:35:04 nvt-se Exp $ + * $Id: rpl.c,v 1.9 2010/09/20 15:30:12 joxe Exp $ */ /** * \file @@ -170,8 +170,19 @@ rpl_ipv6_neighbor_callback(uip_ds6_nbr_t *nbr) rpl_dag_t *dag; rpl_parent_t *p; + /* This only handles one DODAG - if multiple we need to check all */ dag = rpl_get_dag(RPL_ANY_INSTANCE); - if(!nbr->isused && dag) { + if(dag == NULL) { + return; + } + + /* if this is our default route then clean the dag->def_route state */ + if(dag->def_route != NULL && + uip_ipaddr_cmp(&dag->def_route->ipaddr, &nbr->ipaddr)) { + dag->def_route = NULL; + } + + if(!nbr->isused) { PRINTF("RPL: Removing neighbor "); PRINT6ADDR(&nbr->ipaddr); PRINTF("\n");