mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-07 00:30:32 +01:00
lease: add n_dhcp4_client_lease_get_basetime()
The API already had n_dhcp4_client_lease_get_lifetime(), which is the CLOCK_BOOTTIME when the lease expires (or ((uint64_t)-1)). But it might be interesting to know the actual lease duration and when the lease was received (and the time started to count). Expose an API for that. With this, one can also calculate the original, exact lease lifetime, by subtracting n_dhcp4_client_lease_get_basetime() from n_dhcp4_client_lease_get_lifetime(), while taking care of ((uint64_t)-1).
This commit is contained in:
parent
d29c8b615a
commit
d688019bf8
2 changed files with 13 additions and 0 deletions
|
|
@ -217,6 +217,18 @@ _c_public_ void n_dhcp4_client_lease_get_siaddr(NDhcp4ClientLease *lease, struct
|
|||
siaddr->s_addr = header->siaddr;
|
||||
}
|
||||
|
||||
/**
|
||||
* n_dhcp4_client_lease_get_basetime() - get the timestamp when the lease was received.
|
||||
* @lease: the lease to operate on
|
||||
* @ns_basetimep: return argument for the base time in nano seconds
|
||||
*
|
||||
* Gets the timestamp when the lease was received in CLOCK_BOOTTIME. This
|
||||
* is also the base timestamp for the expiration of the lifetime and t1/t2.
|
||||
*/
|
||||
_c_public_ void n_dhcp4_client_lease_get_basetime(NDhcp4ClientLease *lease, uint64_t *ns_basetimep) {
|
||||
*ns_basetimep = lease->message->userdata.base_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* n_dhcp4_client_lease_get_lifetime() - get the lifetime
|
||||
* @lease: the lease to operate on
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ NDhcp4ClientLease *n_dhcp4_client_lease_unref(NDhcp4ClientLease *lease);
|
|||
|
||||
void n_dhcp4_client_lease_get_yiaddr(NDhcp4ClientLease *lease, struct in_addr *yiaddr);
|
||||
void n_dhcp4_client_lease_get_siaddr(NDhcp4ClientLease *lease, struct in_addr *siaddr);
|
||||
void n_dhcp4_client_lease_get_basetime(NDhcp4ClientLease *lease, uint64_t *ns_basetimep);
|
||||
void n_dhcp4_client_lease_get_lifetime(NDhcp4ClientLease *lease, uint64_t *ns_lifetimep);
|
||||
int n_dhcp4_client_lease_query(NDhcp4ClientLease *lease, uint8_t option, uint8_t **datap, size_t *n_datap);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue