mirror of
https://github.com/systemd/systemd.git
synced 2024-11-08 11:27:32 +03:00
sd-dhcp6-lease: Add helper function to compute remaining expiry time
Create a helper function to compute the remaining time in seconds from time T2 to the IPv6 address with the longest lifetime. The computed time is used as the Maximum Retransmission Duration in Rebinding state. See RFC 3315, section 18.1.4. for details.
This commit is contained in:
parent
da6fe470e1
commit
709d6710d0
@ -42,6 +42,7 @@ struct sd_dhcp6_lease {
|
||||
};
|
||||
|
||||
int dhcp6_lease_clear_timers(DHCP6IA *ia);
|
||||
int dhcp6_lease_ia_rebind_expire(const DHCP6IA *ia, uint32_t *expire);
|
||||
DHCP6IA *dhcp6_lease_free_ia(DHCP6IA *ia);
|
||||
|
||||
int dhcp6_lease_set_serverid(sd_dhcp6_lease *lease, const uint8_t *id,
|
||||
|
@ -33,6 +33,28 @@ int dhcp6_lease_clear_timers(DHCP6IA *ia) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dhcp6_lease_ia_rebind_expire(const DHCP6IA *ia, uint32_t *expire) {
|
||||
DHCP6Address *addr;
|
||||
uint32_t valid = 0, t;
|
||||
|
||||
assert_return(ia, -EINVAL);
|
||||
assert_return(expire, -EINVAL);
|
||||
|
||||
LIST_FOREACH(addresses, addr, ia->addresses) {
|
||||
t = be32toh(addr->lifetime_valid);
|
||||
if (valid < t)
|
||||
valid = t;
|
||||
}
|
||||
|
||||
t = be32toh(ia->lifetime_t2);
|
||||
if (t > valid)
|
||||
return -EINVAL;
|
||||
|
||||
*expire = valid - t;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DHCP6IA *dhcp6_lease_free_ia(DHCP6IA *ia) {
|
||||
DHCP6Address *address;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user