Merge pull request #2052 from cetic/pr-rpl-route-infinite-lifetime

Make RPL route lifetime RFC compliant
This commit is contained in:
Antonio Lignan 2017-01-13 16:07:09 +01:00 committed by GitHub
commit 0fb4a68332
3 changed files with 9 additions and 3 deletions

View file

@ -145,8 +145,14 @@
/* Special value indicating immediate removal. */ /* Special value indicating immediate removal. */
#define RPL_ZERO_LIFETIME 0 #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) \ #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 #ifndef RPL_CONF_MIN_HOPRANKINC
/* RFC6550 defines the default MIN_HOPRANKINC as 256. /* 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 /* Set up another DAO within half the expiration time, if such a
time has been configured */ 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; clock_time_t expiration_time;
expiration_time = (clock_time_t)instance->default_lifetime * expiration_time = (clock_time_t)instance->default_lifetime *
(clock_time_t)instance->lifetime_unit * (clock_time_t)instance->lifetime_unit *

View file

@ -122,7 +122,7 @@ rpl_purge_routes(void)
r = uip_ds6_route_head(); r = uip_ds6_route_head();
while(r != NULL) { 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 * 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, * immediate removal below. This achieves the same as the original code,