Merge send_renew() and send_rebind() into send_renew_or_rebind().

This commit is contained in:
Nicholas J. Kain 2020-10-19 05:26:47 -04:00
parent 23d23c108a
commit 5dc35eca6d
2 changed files with 13 additions and 17 deletions

View File

@ -470,7 +470,7 @@ ssize_t send_selecting(struct client_state_t cs[static 1])
return send_dhcp_raw(&packet);
}
ssize_t send_renew(struct client_state_t cs[static 1])
ssize_t send_renew_or_rebind(struct client_state_t cs[static 1], bool is_renew)
{
struct dhcpmsg packet = {.xid = cs->xid};
init_packet(&packet, DHCPREQUEST);
@ -478,20 +478,9 @@ ssize_t send_renew(struct client_state_t cs[static 1])
add_option_maxsize(&packet);
add_option_request_list(&packet);
add_options_vendor_hostname(&packet);
log_line("%s: Sending a renew request...", client_config.interface);
return send_dhcp_unicast(cs, &packet);
}
ssize_t send_rebind(struct client_state_t cs[static 1])
{
struct dhcpmsg packet = {.xid = cs->xid};
init_packet(&packet, DHCPREQUEST);
packet.ciaddr = cs->clientAddr;
add_option_maxsize(&packet);
add_option_request_list(&packet);
add_options_vendor_hostname(&packet);
log_line("%s: Sending a rebind request...", client_config.interface);
return send_dhcp_raw(&packet);
log_line("%s: Sending a %s request...", client_config.interface,
is_renew? "renew" : "rebind");
return is_renew? send_dhcp_unicast(cs, &packet) : send_dhcp_raw(&packet);
}
ssize_t send_decline(struct client_state_t cs[static 1], uint32_t server)

View File

@ -89,8 +89,15 @@ bool dhcp_packet_get(struct client_state_t cs[static 1],
uint32_t srcaddr[static 1]);
ssize_t send_discover(struct client_state_t cs[static 1]);
ssize_t send_selecting(struct client_state_t cs[static 1]);
ssize_t send_renew(struct client_state_t cs[static 1]);
ssize_t send_rebind(struct client_state_t cs[static 1]);
ssize_t send_renew_or_rebind(struct client_state_t cs[static 1], bool is_renew);
static inline ssize_t send_renew(struct client_state_t cs[static 1])
{
return send_renew_or_rebind(cs, true);
}
static inline ssize_t send_rebind(struct client_state_t cs[static 1])
{
return send_renew_or_rebind(cs, false);
}
ssize_t send_decline(struct client_state_t cs[static 1], uint32_t server);
ssize_t send_release(struct client_state_t cs[static 1]);