Merge pull request #116 from cetic/rpl-lifetimes

RPL Lifetimes
This commit is contained in:
Adam Dunkels 2013-03-10 13:04:07 -07:00
commit 4e40cb8a8d
3 changed files with 22 additions and 6 deletions

View File

@ -165,4 +165,23 @@
#define RPL_INIT_LINK_METRIC NEIGHBOR_INFO_ETX2FIX(RPL_CONF_INIT_LINK_METRIC)
#endif
/*
* Default route lifetime unit. This is the granularity of time
* used in RPL lifetime values, in seconds.
*/
#ifndef RPL_CONF_DEFAULT_LIFETIME_UNIT
#define RPL_DEFAULT_LIFETIME_UNIT 0xffff
#else
#define RPL_DEFAULT_LIFETIME_UNIT RPL_CONF_DEFAULT_LIFETIME_UNIT
#endif
/*
* Default route lifetime as a multiple of the lifetime unit.
*/
#ifndef RPL_CONF_DEFAULT_LIFETIME
#define RPL_DEFAULT_LIFETIME 0xff
#else
#define RPL_DEFAULT_LIFETIME RPL_CONF_DEFAULT_LIFETIME
#endif
#endif /* RPL_CONF_H */

View File

@ -1223,6 +1223,9 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
rpl_schedule_dao(instance);
}
/* 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));
}
p->dtsn = dio->dtsn;
}

View File

@ -112,12 +112,6 @@
/* Special value indicating immediate removal. */
#define RPL_ZERO_LIFETIME 0
/* Default route lifetime unit. */
#define RPL_DEFAULT_LIFETIME_UNIT 0xffff
/* Default route lifetime as a multiple of the lifetime unit. */
#define RPL_DEFAULT_LIFETIME 0xff
#define RPL_LIFETIME(instance, lifetime) \
((unsigned long)(instance)->lifetime_unit * (lifetime))