diff options
author | Fernando Fernandez Mancera <ffmancera@riseup.net> | 2024-01-29 11:26:12 +0100 |
---|---|---|
committer | Fernando Fernandez Mancera <ffmancera@riseup.net> | 2024-03-06 11:14:16 +0100 |
commit | 243cc433fb77e0590db5929d2eb76d862eb007ab (patch) | |
tree | e8b563a50826e00d4970cfbdd81d48d8770d6d2a | |
parent | 0f0f1bbf8aa5c8d47252e6b8349186948f7529f5 (diff) |
n-dhcp4: add new client probe function to send RELEASE message
The new function uses the client probe connection to send a RELEASE
message. Returns zero if successful otherwise returns non-zero value.
-rw-r--r-- | src/n-dhcp4/src/n-dhcp4-c-probe.c | 27 | ||||
-rw-r--r-- | src/n-dhcp4/src/n-dhcp4.h | 1 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/n-dhcp4/src/n-dhcp4-c-probe.c b/src/n-dhcp4/src/n-dhcp4-c-probe.c index a5b38bcd3d..ee3a8886bd 100644 --- a/src/n-dhcp4/src/n-dhcp4-c-probe.c +++ b/src/n-dhcp4/src/n-dhcp4-c-probe.c @@ -1319,3 +1319,30 @@ int n_dhcp4_client_probe_dispatch_io(NDhcp4ClientProbe *probe, uint32_t events) int n_dhcp4_client_probe_update_mtu(NDhcp4ClientProbe *probe, uint16_t mtu) { return 0; } + +/** + * n_dhcp4_client_probe_release() - send a release request + * @probe: probe to operate on + * + * This sends a RELEASE message on the connection used by the probe. + * + * Return: 0 if successful otherwise non-zero value is returned. + */ +int n_dhcp4_client_probe_release(NDhcp4ClientProbe *probe) { + _c_cleanup_(n_dhcp4_outgoing_freep) NDhcp4Outgoing *request_out = NULL; + int r; + + r = n_dhcp4_c_connection_release_new(&probe->connection, &request_out, NULL); + if (r) + return r; + + r = n_dhcp4_c_connection_start_request(&probe->connection, request_out, 0); + if (r) + return r; + + probe->state = N_DHCP4_CLIENT_PROBE_STATE_INIT; + n_dhcp4_client_lease_unlink(probe->current_lease); + request_out = NULL; + + return 0; +} diff --git a/src/n-dhcp4/src/n-dhcp4.h b/src/n-dhcp4/src/n-dhcp4.h index f6c87a8d80..f3cf4210fc 100644 --- a/src/n-dhcp4/src/n-dhcp4.h +++ b/src/n-dhcp4/src/n-dhcp4.h @@ -161,6 +161,7 @@ NDhcp4ClientProbe *n_dhcp4_client_probe_free(NDhcp4ClientProbe *probe); void n_dhcp4_client_probe_set_userdata(NDhcp4ClientProbe *probe, void *userdata); void n_dhcp4_client_probe_get_userdata(NDhcp4ClientProbe *probe, void **userdatap); +int n_dhcp4_client_probe_release(NDhcp4ClientProbe *probe); /* client leases */ |