diff --git a/ndhc/packet.c b/ndhc/packet.c index 1162e31..c89ddbc 100644 --- a/ndhc/packet.c +++ b/ndhc/packet.c @@ -169,7 +169,7 @@ int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int fd, r = -1; unsigned int padding; - if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) { + if ((fd = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) { log_error("raw_packet: socket failed: %s", strerror(errno)); goto out; } @@ -178,6 +178,8 @@ int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, memset(&packet, 0, offsetof(struct ip_udp_dhcp_packet, data)); packet.data = *payload; /* struct copy */ + set_sock_nonblock(fd); + dest.sll_family = AF_PACKET; dest.sll_protocol = htons(ETH_P_IP); dest.sll_ifindex = ifindex; diff --git a/ndhc/socket.c b/ndhc/socket.c index b8a3734..1dee9b7 100644 --- a/ndhc/socket.c +++ b/ndhc/socket.c @@ -126,7 +126,7 @@ int raw_socket(int ifindex) memset(&sock, 0, sizeof sock); log_line("Opening raw socket on ifindex %d", ifindex); - if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) { + if ((fd = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) { log_error("socket call failed: %s", strerror(errno)); return -1; }