- use xlisten/xsocket some more. Saves .25 kB

This commit is contained in:
Bernhard Reutner-Fischer
2006-12-19 16:31:09 +00:00
parent 359d7ca0e7
commit 28fbd69bf8
6 changed files with 9 additions and 35 deletions

View File

@@ -40,20 +40,12 @@ int raw_socket(int ifindex)
struct sockaddr_ll sock;
DEBUG("Opening raw socket on ifindex %d", ifindex);
fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
if (fd < 0) {
bb_perror_msg("socket");
return -1;
}
fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
sock.sll_family = AF_PACKET;
sock.sll_protocol = htons(ETH_P_IP);
sock.sll_ifindex = ifindex;
if (bind(fd, (struct sockaddr *) &sock, sizeof(sock)) < 0) {
bb_perror_msg("bind");
close(fd);
return -1;
}
xbind(fd, (struct sockaddr *) &sock, sizeof(sock));
return fd;
}