Set arp socket as nonblocking.

This commit is contained in:
Nicholas J. Kain 2010-12-26 18:19:39 -05:00
parent 6f483045f4
commit 11e71837fd
3 changed files with 7 additions and 2 deletions

View File

@ -17,6 +17,7 @@
#include "arp.h" #include "arp.h"
#include "dhcpmsg.h" #include "dhcpmsg.h"
#include "packet.h" #include "packet.h"
#include "socket.h"
#include "sys.h" #include "sys.h"
#include "ifchange.h" #include "ifchange.h"
#include "dhcpd.h" #include "dhcpd.h"
@ -50,6 +51,8 @@ static int arpping(uint32_t test_nip, const uint8_t *safe_mac,
return -1; return -1;
} }
set_sock_nonblock(arpfd);
/* send arp request */ /* send arp request */
memset(&arp, 0, sizeof arp); memset(&arp, 0, sizeof arp);
memset(arp.h_dest, 0xff, 6); /* MAC DA */ memset(arp.h_dest, 0xff, 6); /* MAC DA */

View File

@ -39,7 +39,7 @@
#include "strl.h" #include "strl.h"
#include "dhcpd.h" /* For SERVER_PORT and CLIENT_PORT */ #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; int ret = 0, flags;
flags = fcntl(fd, F_GETFL); flags = fcntl(fd, F_GETFL);

View File

@ -1,7 +1,9 @@
/* socket.h */
#ifndef SOCKET_H_ #ifndef SOCKET_H_
#define SOCKET_H_ #define SOCKET_H_
#include <stdint.h>
int set_sock_nonblock(int fd);
int read_interface(char *interface, int *ifindex, uint32_t *addr, int read_interface(char *interface, int *ifindex, uint32_t *addr,
uint8_t *mac); uint8_t *mac);
int listen_socket(unsigned int ip, int port, char *inf); int listen_socket(unsigned int ip, int port, char *inf);