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

nib/_nib-6ln: correct ABR timeout in ABRO

This commit is contained in:
Fabian Hüßler 2022-09-28 14:49:30 +02:00
parent c79a7f7065
commit 23fa33774f
3 changed files with 18 additions and 6 deletions

View File

@ -260,6 +260,20 @@ static inline void sixlowpan_nd_opt_abr_set_version(sixlowpan_nd_opt_abr_t *abr_
abr_opt->vhigh = byteorder_htons((uint16_t)(version >> 16));
}
/**
* @brief Get the lifetime of an Authoritative Border Router from an ABR option
*
* @param[in] abr_opt An Authoritative Border Router option (ABRO).
*
* @return The lifetime of @p abr_opt in minutes. If the lifetime is 0,
* @ref SIXLOWPAN_ND_OPT_ABR_LTIME_DEFAULT is returned.
*/
static inline uint16_t gnrc_sixlowpan_nd_opt_get_ltime(const sixlowpan_nd_opt_abr_t *abr_opt)
{
uint16_t ltime = byteorder_ntohs(abr_opt->ltime);
return (ltime == 0) ? SIXLOWPAN_ND_OPT_ABR_LTIME_DEFAULT : ltime;
}
#ifdef __cplusplus
}
#endif

View File

@ -249,11 +249,9 @@ _nib_abr_entry_t *_handle_abro(const sixlowpan_nd_opt_abr_t *abro)
abr = _nib_abr_add(&abro->braddr);
if (abr != NULL) {
uint32_t abro_version = sixlowpan_nd_opt_abr_get_version(abro);
uint16_t ltime = byteorder_ntohs(abro->ltime);
/* correct for default value */
ltime = (ltime == 0) ? SIXLOWPAN_ND_OPT_ABR_LTIME_DEFAULT : ltime;
uint32_t ltime_ms = MS_PER_SEC * SEC_PER_MIN * ltime;
uint32_t ltime_ms = MS_PER_SEC * SEC_PER_MIN *
gnrc_sixlowpan_nd_opt_get_ltime(abro);
if (abr->version >= abro_version) {
abr->version = abro_version;

View File

@ -701,8 +701,8 @@ static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
}
/* UINT16_MAX * 60 * 1000 < UINT32_MAX so there are no overflows */
next_timeout = _min(next_timeout,
byteorder_ntohs(abro->ltime) * SEC_PER_MIN *
MS_PER_SEC);
MS_PER_SEC * SEC_PER_MIN *
gnrc_sixlowpan_nd_opt_get_ltime(abro));
}
#if !IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)
else if (gnrc_netif_is_6lr(netif)) {