dhcpv6_for_each_option(ia_pd, ia_pd + ia_pd_len, otype, olen, odata) {
struct dhcpv6_ia_prefix *p = (void*)&odata[-4];
uint32_t valid = ntohl(p->valid);
- p->valid = (valid < elapsed) ? 0 : htonl(valid - elapsed);
+ if (valid != UINT32_MAX)
+ p->valid = (valid < elapsed) ? 0 : htonl(valid - elapsed);
uint32_t pref = ntohl(p->preferred);
- p->preferred = (pref < elapsed) ? 0 : htonl(pref - elapsed);
+ if (pref != UINT32_MAX)
+ p->preferred = (pref < elapsed) ? 0 : htonl(pref - elapsed);
}
// Decrease valid and preferred lifetime of addresses
dhcpv6_for_each_option(ia_na, ia_na + ia_na_len, otype, olen, odata) {
struct dhcpv6_ia_addr *p = (void*)&odata[-4];
uint32_t valid = ntohl(p->valid);
- p->valid = (valid < elapsed) ? 0 : htonl(valid - elapsed);
+ if (valid != UINT32_MAX)
+ p->valid = (valid < elapsed) ? 0 : htonl(valid - elapsed);
uint32_t pref = ntohl(p->preferred);
- p->preferred = (pref < elapsed) ? 0 : htonl(pref - elapsed);
+ if (pref != UINT32_MAX)
+ p->preferred = (pref < elapsed) ? 0 : htonl(pref - elapsed);
}
// Parse and find all matching IAs
int init_rtnetlink(void);
int set_rtnetlink_addr(int ifindex, const struct in6_addr *addr,
- time_t pref, time_t valid);
+ uint32_t pref, uint32_t valid);
int script_init(const char *path, const char *ifname);
ssize_t script_unhexlify(uint8_t *dst, size_t len, const char *src);
// CRUD addresses to interface
int set_rtnetlink_addr(int ifindex, const struct in6_addr *addr,
- time_t pref, time_t valid)
+ uint32_t pref, uint32_t valid)
{
int flags = NLM_F_REQUEST | NLM_F_ACK;
int cmd = RTM_DELADDR;
- if (valid > 0) {
+ if (valid) {
flags |= NLM_F_CREATE | NLM_F_REPLACE;
cmd = RTM_NEWADDR;
}