1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

rpl: make parent lifetime consistent with other timers

This commit is contained in:
smlng 2017-04-19 17:19:27 +02:00
parent 45a5bb5978
commit 41c43fd837
3 changed files with 9 additions and 12 deletions

View File

@ -252,23 +252,22 @@ static void *_event_loop(void *args)
void _update_lifetime(void)
{
uint32_t now = xtimer_now_usec();
uint16_t now_sec = now / US_PER_SEC;
gnrc_rpl_parent_t *parent;
gnrc_rpl_instance_t *inst;
for (uint8_t i = 0; i < GNRC_RPL_PARENTS_NUMOF; ++i) {
parent = &gnrc_rpl_parents[i];
if (parent->state != 0) {
if ((int32_t)(parent->lifetime - now_sec) <= GNRC_RPL_LIFETIME_UPDATE_STEP) {
if (parent->lifetime > GNRC_RPL_LIFETIME_UPDATE_STEP) {
if (parent->lifetime > (2 * GNRC_RPL_LIFETIME_UPDATE_STEP)) {
gnrc_rpl_send_DIS(parent->dodag->instance, &parent->addr);
}
parent->lifetime -= GNRC_RPL_LIFETIME_UPDATE_STEP;
}
else {
gnrc_rpl_dodag_t *dodag = parent->dodag;
gnrc_rpl_parent_remove(parent);
gnrc_rpl_parent_update(dodag, NULL);
continue;
}
else if ((int32_t)(parent->lifetime - now_sec) <= (GNRC_RPL_LIFETIME_UPDATE_STEP * 2)) {
gnrc_rpl_send_DIS(parent->dodag->instance, &parent->addr);
}
}
}

View File

@ -265,8 +265,7 @@ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent)
{
/* update Parent lifetime */
if (parent != NULL) {
uint32_t now = xtimer_now_usec();
parent->lifetime = (now / US_PER_SEC) + (dodag->default_lifetime * dodag->lifetime_unit);
parent->lifetime = dodag->default_lifetime * dodag->lifetime_unit;
#ifdef MODULE_GNRC_RPL_P2P
if (dodag->instance->mop != GNRC_RPL_P2P_MOP) {
#endif

View File

@ -304,8 +304,7 @@ int _gnrc_rpl_dodag_show(void)
LL_FOREACH(gnrc_rpl_instances[i].dodag.parents, parent) {
printf("\t\tparent [addr: %s | rank: %d | lifetime: %" PRIu32 "s]\n",
ipv6_addr_to_str(addr_str, &parent->addr, sizeof(addr_str)),
parent->rank, ((int32_t) (parent->lifetime - (((uint32_t) xnow / US_PER_SEC))))
< 0 ? 0 : (parent->lifetime - ((uint32_t) xnow / US_PER_SEC)));
parent->rank, parent->lifetime);
}
}
return 0;