Allow rpl default route lifetime to be infinite

This commit is contained in:
Laurent Deru 2014-09-10 16:56:53 +02:00
parent a32598f658
commit fc8415e1ad
2 changed files with 18 additions and 3 deletions

View file

@ -105,6 +105,22 @@
#define RPL_MAX_DAG_PER_INSTANCE 2
#endif /* RPL_CONF_MAX_DAG_PER_INSTANCE */
/*
* RPL Default route lifetime
* The RPL route lifetime is used for the downward routes and for the default
* route. In a high density network with DIO suppression activated it may happen
* that a node will never send a DIO once the DIO interval becomes high as it
* has heard DIO from many neighbors already. As the default route to the
* preferred parent has a lifetime reset by receiving DIO from the parent, it
* means that the default route can be destroyed after a while. Setting the
* default route with infinite lifetime secures the upstream route.
*/
#ifdef RPL_CONF_DEFAULT_ROUTE_INFINITE_LIFETIME
#define RPL_DEFAULT_ROUTE_INFINITE_LIFETIME RPL_CONF_DEFAULT_ROUTE_INFINITE_LIFETIME
#else
#define RPL_DEFAULT_ROUTE_INFINITE_LIFETIME 0
#endif /* RPL_CONF_DEFAULT_ROUTE_INFINITE_LIFETIME */
/*
*
*/

View file

@ -481,8 +481,7 @@ rpl_set_default_route(rpl_instance_t *instance, uip_ipaddr_t *from)
PRINT6ADDR(from);
PRINTF("\n");
instance->def_route = uip_ds6_defrt_add(from,
RPL_LIFETIME(instance,
instance->default_lifetime));
RPL_DEFAULT_ROUTE_INFINITE_LIFETIME ? 0 : RPL_LIFETIME(instance, instance->default_lifetime));
if(instance->def_route == NULL) {
return 0;
}
@ -1398,7 +1397,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
}
/* We received a new DIO from our preferred parent.
* Call uip_ds6_defrt_add to set a fresh value for the lifetime counter */
uip_ds6_defrt_add(from, RPL_LIFETIME(instance, instance->default_lifetime));
uip_ds6_defrt_add(from, RPL_DEFAULT_ROUTE_INFINITE_LIFETIME ? 0 : RPL_LIFETIME(instance, instance->default_lifetime));
}
p->dtsn = dio->dtsn;
}