diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index 09362137f..248c60b87 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.5 2010/05/10 11:16:35 joxe Exp $ + * $Id: rpl-dag.c,v 1.6 2010/05/10 13:46:35 nifi Exp $ */ /** * \file @@ -175,7 +175,11 @@ rpl_set_default_route(rpl_dag_t *dag, uip_ipaddr_t *from) PRINTF("RPL: Adding default route through "); PRINT6ADDR(from); PRINTF("\n"); - dag->def_route = uip_ds6_defrt_add(from, DEFAULT_ROUTE_LIFETIME); + if(DEFAULT_ROUTE_LIFETIME == INFINITE_LIFETIME) { + dag->def_route = uip_ds6_defrt_add(from, 0); + } else { + dag->def_route = uip_ds6_defrt_add(from, DEFAULT_ROUTE_LIFETIME); + } if(dag->def_route == NULL) { return 0; } diff --git a/core/net/uip-ds6.c b/core/net/uip-ds6.c index 2e38fca5e..d56e16943 100755 --- a/core/net/uip-ds6.c +++ b/core/net/uip-ds6.c @@ -196,7 +196,8 @@ uip_ds6_periodic(void) /* Periodic processing on default routers */ for(locdefrt = uip_ds6_defrt_list; locdefrt < uip_ds6_defrt_list + UIP_DS6_DEFRT_NB; locdefrt++) { - if((locdefrt->isused) && (stimer_expired(&(locdefrt->lifetime)))) { + if((locdefrt->isused) && (!locdefrt->isinfinite) && + (stimer_expired(&(locdefrt->lifetime)))) { uip_ds6_defrt_rm(locdefrt); } } @@ -374,7 +375,12 @@ uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval) (uip_ds6_element_t **) & locdefrt) == FREESPACE) { locdefrt->isused = 1; uip_ipaddr_copy(&(locdefrt->ipaddr), ipaddr); - stimer_set(&(locdefrt->lifetime), interval); + if(interval != 0) { + stimer_set(&(locdefrt->lifetime), interval); + locdefrt->isinfinite = 0; + } else { + locdefrt->isinfinite = 1; + } PRINTF("Adding defrouter with ip addr"); PRINT6ADDR(&locdefrt->ipaddr); diff --git a/core/net/uip-ds6.h b/core/net/uip-ds6.h index c251e1dbb..501ff4cb0 100755 --- a/core/net/uip-ds6.h +++ b/core/net/uip-ds6.h @@ -173,6 +173,7 @@ typedef struct uip_ds6_defrt { uint8_t isused; uip_ipaddr_t ipaddr; struct stimer lifetime; + uint8_t isinfinite; } uip_ds6_defrt_t; /** \brief A prefix list entry */