Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/n-dhcp4-c-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,3 +1305,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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will keep resending the DHCPDECLINE message, since it stays in connection->request. I think you need to use n_dhcp4_c_connection_send_request() directly, don't you?


probe->state = N_DHCP4_CLIENT_PROBE_STATE_INIT;
n_dhcp4_client_lease_unlink(probe->current_lease);
request_out = NULL;

return 0;
}
1 change: 1 addition & 0 deletions src/n-dhcp4.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,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 */

Expand Down