From 11e71837fd3de5f20145c937874080cff11935be Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Sun, 26 Dec 2010 18:19:39 -0500 Subject: [PATCH] Set arp socket as nonblocking. --- ndhc/arp.c | 3 +++ ndhc/socket.c | 2 +- ndhc/socket.h | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ndhc/arp.c b/ndhc/arp.c index c2b2664..2487892 100644 --- a/ndhc/arp.c +++ b/ndhc/arp.c @@ -17,6 +17,7 @@ #include "arp.h" #include "dhcpmsg.h" #include "packet.h" +#include "socket.h" #include "sys.h" #include "ifchange.h" #include "dhcpd.h" @@ -50,6 +51,8 @@ static int arpping(uint32_t test_nip, const uint8_t *safe_mac, return -1; } + set_sock_nonblock(arpfd); + /* send arp request */ memset(&arp, 0, sizeof arp); memset(arp.h_dest, 0xff, 6); /* MAC DA */ diff --git a/ndhc/socket.c b/ndhc/socket.c index adb700e..66bf6e3 100644 --- a/ndhc/socket.c +++ b/ndhc/socket.c @@ -39,7 +39,7 @@ #include "strl.h" #include "dhcpd.h" /* For SERVER_PORT and CLIENT_PORT */ -static int set_sock_nonblock(int fd) +int set_sock_nonblock(int fd) { int ret = 0, flags; flags = fcntl(fd, F_GETFL); diff --git a/ndhc/socket.h b/ndhc/socket.h index db0b50b..6f46a6e 100644 --- a/ndhc/socket.h +++ b/ndhc/socket.h @@ -1,7 +1,9 @@ -/* socket.h */ #ifndef SOCKET_H_ #define SOCKET_H_ +#include + +int set_sock_nonblock(int fd); int read_interface(char *interface, int *ifindex, uint32_t *addr, uint8_t *mac); int listen_socket(unsigned int ip, int port, char *inf);