mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
sd-dhcpv4: Allow to configure lease lifetime
This commit is contained in:
parent
d08a6ec39c
commit
4c0b8d563d
@ -87,6 +87,7 @@ struct sd_dhcp_client {
|
||||
char *mudurl;
|
||||
char **user_class;
|
||||
uint32_t mtu;
|
||||
uint32_t fallback_lease_lifetime;
|
||||
uint32_t xid;
|
||||
usec_t start_time;
|
||||
uint64_t attempt;
|
||||
@ -612,6 +613,15 @@ int sd_dhcp_client_set_service_type(sd_dhcp_client *client, int type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_dhcp_client_set_fallback_lease_lifetime(sd_dhcp_client *client, uint32_t fallback_lease_lifetime) {
|
||||
assert_return(client, -EINVAL);
|
||||
assert_return(fallback_lease_lifetime > 0, -EINVAL);
|
||||
|
||||
client->fallback_lease_lifetime = fallback_lease_lifetime;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int client_notify(sd_dhcp_client *client, int event) {
|
||||
assert(client);
|
||||
|
||||
@ -1419,6 +1429,9 @@ static int client_handle_offer(sd_dhcp_client *client, DHCPMessage *offer, size_
|
||||
lease->next_server = offer->siaddr;
|
||||
lease->address = offer->yiaddr;
|
||||
|
||||
if (lease->lifetime == 0 && client->fallback_lease_lifetime > 0)
|
||||
lease->lifetime = client->fallback_lease_lifetime;
|
||||
|
||||
if (lease->address == 0 ||
|
||||
lease->server_address == 0 ||
|
||||
lease->lifetime == 0) {
|
||||
|
@ -185,6 +185,9 @@ int sd_dhcp_client_get_lease(
|
||||
int sd_dhcp_client_set_service_type(
|
||||
sd_dhcp_client *client,
|
||||
int type);
|
||||
int sd_dhcp_client_set_fallback_lease_lifetime(
|
||||
sd_dhcp_client *client,
|
||||
uint32_t fallback_lease_lifetime);
|
||||
|
||||
int sd_dhcp_client_add_option(sd_dhcp_client *client, sd_dhcp_option *v);
|
||||
int sd_dhcp_client_add_vendor_option(sd_dhcp_client *client, sd_dhcp_option *v);
|
||||
|
Loading…
Reference in New Issue
Block a user