Make raw listen sockets nonblocking. They should have been so all along.

Minor constant correction: PF_PACKET -> AF_PACKET
This commit is contained in:
Nicholas J. Kain 2011-06-25 10:18:14 -04:00
parent 19f7e6d11e
commit 7d206e45b6
2 changed files with 4 additions and 2 deletions

View File

@ -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;

View File

@ -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;
}