diff --git a/sys/include/net/gnrc/rpl/structs.h b/sys/include/net/gnrc/rpl/structs.h index 15e893e391bebc8204a13185d16c3ea791f8470f..2ee8915b077ece3401fc1b8bfe9f641a6f17fbc5 100644 --- a/sys/include/net/gnrc/rpl/structs.h +++ b/sys/include/net/gnrc/rpl/structs.h @@ -177,7 +177,7 @@ struct gnrc_rpl_parent { uint16_t rank; /**< rank of the parent */ uint8_t dtsn; /**< last seen dtsn of this parent */ gnrc_rpl_dodag_t *dodag; /**< DODAG the parent belongs to */ - uint64_t lifetime; /**< lifetime of this parent */ + uint32_t lifetime; /**< lifetime of this parent in seconds */ double link_metric; /**< metric of the link */ uint8_t link_metric_type; /**< type of the metric */ }; diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl.c b/sys/net/gnrc/routing/rpl/gnrc_rpl.c index 4579815ae92009772a314533a934e4565e4a2a29..f6e568213e2cbb4954c773800ab450d0d398e210 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl.c @@ -230,20 +230,20 @@ static void *_event_loop(void *args) void _update_lifetime(void) { - uint64_t now = xtimer_now64(); + uint32_t now = xtimer_now(); gnrc_rpl_parent_t *parent; for (uint8_t i = 0; i < GNRC_RPL_PARENTS_NUMOF; ++i) { parent = &gnrc_rpl_parents[i]; if (parent->state != 0) { - if ((int64_t)(parent->lifetime - now) <= (int64_t) (GNRC_RPL_LIFETIME_UPDATE_STEP - * SEC_IN_USEC)) { + if ((int32_t)(parent->lifetime - (now / SEC_IN_USEC)) <= + GNRC_RPL_LIFETIME_UPDATE_STEP) { gnrc_rpl_dodag_t *dodag = parent->dodag; gnrc_rpl_parent_remove(parent); gnrc_rpl_parent_update(dodag, NULL); continue; } - else if ((int64_t)(parent->lifetime - now) <= - (int64_t) (GNRC_RPL_LIFETIME_UPDATE_STEP * SEC_IN_USEC * 2)) { + else if ((int32_t)(parent->lifetime - (now / SEC_IN_USEC)) + <= (GNRC_RPL_LIFETIME_UPDATE_STEP * 2)) { gnrc_rpl_send_DIS(parent->dodag->instance, &parent->addr); } } diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c b/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c index 87ef45d0ad3aef1bbdd19f3dfd599ccec3d098a3..65489768e724b253002978388a2ae59958f846ed 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c @@ -232,12 +232,12 @@ void gnrc_rpl_local_repair(gnrc_rpl_dodag_t *dodag) void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent) { uint16_t old_rank = dodag->my_rank; - uint64_t now = xtimer_now64(); + uint32_t now = xtimer_now(); ipv6_addr_t def = IPV6_ADDR_UNSPECIFIED; /* update Parent lifetime */ if (parent != NULL) { - parent->lifetime = now + ((dodag->default_lifetime * dodag->lifetime_unit) * SEC_IN_USEC); + parent->lifetime = (now / SEC_IN_USEC) + ((dodag->default_lifetime * dodag->lifetime_unit)); if (parent == dodag->parents) { ipv6_addr_t all_RPL_nodes = GNRC_RPL_ALL_NODES_ADDR; kernel_pid_t if_id; diff --git a/sys/shell/commands/sc_gnrc_rpl.c b/sys/shell/commands/sc_gnrc_rpl.c index f43544b45b73157f437cf5ced25f746bae55c1c1..d00cdc6a905f9c99d694af113b5f5efd4d77e5bc 100644 --- a/sys/shell/commands/sc_gnrc_rpl.c +++ b/sys/shell/commands/sc_gnrc_rpl.c @@ -212,10 +212,10 @@ int _gnrc_rpl_dodag_show(void) gnrc_rpl_parent_t *parent; LL_FOREACH(gnrc_rpl_instances[i].dodag.parents, parent) { - printf("\t\tparent [addr: %s | rank: %d | lifetime: %" PRIu64 "s]\n", + printf("\t\tparent [addr: %s | rank: %d | lifetime: %" PRIu32 "s]\n", ipv6_addr_to_str(addr_str, &parent->addr, sizeof(addr_str)), - parent->rank, ((int64_t) (parent->lifetime - xnow) < 0 ? 0 - : (parent->lifetime - xnow) / SEC_IN_USEC)); + parent->rank, ((int32_t) (parent->lifetime - (((uint32_t) xnow / SEC_IN_USEC)))) + < 0 ? 0 : (parent->lifetime - ((uint32_t) xnow / SEC_IN_USEC))); } } return 0;