]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
If we send using pcap, use pcap to receive
authorNick Porter <nick@portercomputing.co.uk>
Wed, 9 Jul 2025 11:29:20 +0000 (12:29 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Wed, 9 Jul 2025 11:29:20 +0000 (12:29 +0100)
Calling recvfrom() on the pcap fd returns EWOULDBLOCK or EAGAIN

src/bin/dhcpclient.c

index 947494f504c088541f2e9abbcbf6173927e6959a..6960516e59799888a306756583ff989e7583856d 100644 (file)
@@ -55,7 +55,7 @@ static fr_time_delta_t        timeout;
 
 static int sockfd;
 #ifdef HAVE_LIBPCAP
-static fr_pcap_t       *pcap;
+static fr_pcap_t       *pcap = NULL;
 #endif
 
 static char *iface = NULL;
@@ -259,14 +259,17 @@ static fr_packet_t *fr_dhcpv4_recv_raw_loop(int lsockfd,
                if (retval > 0 && FD_ISSET(lsockfd, &read_fd)) {
                        /* There is something to read on our socket */
 
+#ifdef HAVE_LIBPCAP
+                       if (pcap) {
+                               reply = fr_dhcpv4_pcap_recv(pcap);
+                       } else
+#endif
 #ifdef HAVE_LINUX_IF_PACKET_H
-                       reply = fr_dhcpv4_raw_packet_recv(lsockfd, p_ll, request, request_list);
-#else
-#  ifdef HAVE_LIBPCAP
-                       reply = fr_dhcpv4_pcap_recv(pcap);
-#  else
+                       {
+                               reply = fr_dhcpv4_raw_packet_recv(lsockfd, p_ll, request, request_list);
+                       }
+#elif !defined(HAVE_LIBPCAP)
 #    error Need <if/packet.h> or <pcap.h>
-#  endif
 #endif
                } else {
                        our_timeout = fr_time_delta_wrap(0);