Make RPL route lifetime RFC compliant

This commit is contained in:
Laurent Deru 2016-04-07 11:40:00 +02:00
parent c1f11cfaa9
commit d866e6bd34
3 changed files with 9 additions and 3 deletions

View File

@ -145,8 +145,14 @@
/* Special value indicating immediate removal. */
#define RPL_ZERO_LIFETIME 0
/* Special value indicating infinite lifetime. */
#define RPL_INFINITE_LIFETIME 0xFF
#define RPL_ROUTE_INFINITE_LIFETIME 0xFFFFFFFF
#define RPL_LIFETIME(instance, lifetime) \
((unsigned long)(instance)->lifetime_unit * (lifetime))
(((lifetime) == RPL_INFINITE_LIFETIME) ? RPL_ROUTE_INFINITE_LIFETIME : (unsigned long)(instance)->lifetime_unit * (lifetime))
#ifndef RPL_CONF_MIN_HOPRANKINC
/* RFC6550 defines the default MIN_HOPRANKINC as 256.

View File

@ -238,7 +238,7 @@ set_dao_lifetime_timer(rpl_instance_t *instance)
/* Set up another DAO within half the expiration time, if such a
time has been configured */
if(instance->lifetime_unit != 0xffff && instance->default_lifetime != 0xff) {
if(instance->default_lifetime != RPL_INFINITE_LIFETIME) {
clock_time_t expiration_time;
expiration_time = (clock_time_t)instance->default_lifetime *
(clock_time_t)instance->lifetime_unit *

View File

@ -122,7 +122,7 @@ rpl_purge_routes(void)
r = uip_ds6_route_head();
while(r != NULL) {
if(r->state.lifetime >= 1) {
if(r->state.lifetime >= 1 && r->state.lifetime != RPL_ROUTE_INFINITE_LIFETIME) {
/*
* If a route is at lifetime == 1, set it to 0, scheduling it for
* immediate removal below. This achieves the same as the original code,