From 203f2b67c0bea9646b4cf18bafba6e735df4efe3 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 27 May 2025 18:07:34 -0400 Subject: Pull the ARP-ping from libdhcp to net_iface --- libdhcp/dhcp_client.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'libdhcp/dhcp_client.c') diff --git a/libdhcp/dhcp_client.c b/libdhcp/dhcp_client.c index bf88961..13dc292 100644 --- a/libdhcp/dhcp_client.c +++ b/libdhcp/dhcp_client.c @@ -700,14 +700,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 +797,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 { -- cgit v1.2.3-2-g168b From 148deaba00b5710135ebf4f6ff0577d4a9483654 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 27 May 2025 17:48:15 -0400 Subject: libdhcp: Reword a comment I had to re-read it 3 times before I understood what it was trying to say. --- libdhcp/dhcp_client.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'libdhcp/dhcp_client.c') diff --git a/libdhcp/dhcp_client.c b/libdhcp/dhcp_client.c index 13dc292..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: \ -- cgit v1.2.3-2-g168b