From fe9a6d7d84b540f8c7da3b9ef5396b073a8d75af Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Fri, 23 Jul 2021 17:40:06 +0200 Subject: [PATCH] gnrc_dhcpv6_client: dhcp-helper-function return valid seconds left dhcpv6_client_prefix_valid_until returned the valid timestamp this fixes it according to the documentation given in /sys/include/net/dhcpv6/client.h to return seconds left --- sys/net/gnrc/application_layer/dhcpv6/client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/net/gnrc/application_layer/dhcpv6/client.c b/sys/net/gnrc/application_layer/dhcpv6/client.c index 2c95e3277c..0139ea623a 100644 --- a/sys/net/gnrc/application_layer/dhcpv6/client.c +++ b/sys/net/gnrc/application_layer/dhcpv6/client.c @@ -25,6 +25,7 @@ #include "net/gnrc/rpl.h" #include "net/sock.h" #include "timex.h" +#include "evtimer.h" #include "net/dhcpv6/client.h" @@ -183,13 +184,14 @@ uint32_t dhcpv6_client_prefix_valid_until(unsigned netif, gnrc_ipv6_nib_pl_t ple; void *state = NULL; uint32_t max_valid = 0; + uint32_t now = evtimer_now_msec(); while (gnrc_ipv6_nib_pl_iter(netif, &state, &ple)) { if ((ple.pfx_len == pfx_len) && - ((ple.valid_until / MS_PER_SEC) > max_valid) && + (((ple.valid_until - now) / MS_PER_SEC) > max_valid) && (ipv6_addr_match_prefix(&ple.pfx, pfx) >= ple.pfx_len)) { - max_valid = ple.valid_until / MS_PER_SEC; + max_valid = (ple.valid_until - now) / MS_PER_SEC; } } return max_valid;