summaryrefslogtreecommitdiff
path: root/libdhcp/dhcp_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdhcp/dhcp_client.c')
-rw-r--r--libdhcp/dhcp_client.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/libdhcp/dhcp_client.c b/libdhcp/dhcp_client.c
index bf88961..57a2f60 100644
--- a/libdhcp/dhcp_client.c
+++ b/libdhcp/dhcp_client.c
@@ -179,9 +179,10 @@ static const char *state_strs[] = {
};
/**
- * For convenience in switch blocks, a list of the states that, when
- * msgtyp==DHCP_MSGTYP_REQUEST, dhcp_client_send() has assert()ed the state is
- * not.
+ * IMPOSSIBLE_REQUEST_STATES is a convenience macro for use in switch
+ * blocks; it is a list of the states that (when
+ * msgtyp==DHCP_MSGTYP_REQUEST) dhcp_client_send() has assert()ed the
+ * state is not.
*/
#define IMPOSSIBLE_REQUEST_STATES \
STATE_INIT: \
@@ -700,14 +701,6 @@ static ssize_t dhcp_client_recv(struct dhcp_client *client, struct dhcp_recv_msg
return 0;
}
-/** @return true if there's a conflict, false if the addr appears to be unused */
-static bool dhcp_check_conflict(lo_interface net_packet_conn sock, struct net_ip4_addr addr) {
- assert(!LO_IS_NULL(sock));
- ssize_t v = LO_CALL(sock, sendto, "CHECK_IP_CONFLICT", 17, addr, 5000);
- log_debugln("check_ip_conflict => ", v);
- return v != -NET_EARP_TIMEOUT;
-}
-
static void dhcp_client_take_lease(struct dhcp_client *client, struct dhcp_recv_msg *msg, bool ifup) {
assert(client);
assert(msg);
@@ -805,7 +798,7 @@ static void dhcp_client_setstate(struct dhcp_client *client,
dhcp_client_setstate(client, STATE_INIT, 0, NULL, scratch_msg);
break;
case DHCP_MSGTYP_ACK:
- if (dhcp_check_conflict(client->sock, client->lease_client_addr)) {
+ if (LO_CALL(client->iface, arp_ping, client->lease_client_addr)) {
log_debugln("IP ", (net_ip4_addr, client->lease_client_addr), " is already in use");
dhcp_client_setstate(client, STATE_INIT, DHCP_MSGTYP_DECLINE, "IP is already in use", scratch_msg);
} else {