Finish remerging busybox udhcp and udhcp. Some cleanups as well.

This commit is contained in:
Russ Dill
2003-12-18 22:25:38 +00:00
parent e30495654d
commit 4e864a36b6
25 changed files with 512 additions and 287 deletions

View File

@@ -130,29 +130,3 @@ int listen_socket(unsigned int ip, int port, char *inf)
return fd;
}
int raw_socket(int ifindex)
{
int fd;
struct sockaddr_ll sock;
DEBUG(LOG_INFO, "Opening raw socket on ifindex %d", ifindex);
if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
DEBUG(LOG_ERR, "socket call failed: %m");
return -1;
}
while (fd >= 0 && fd < 3) fd = dup(fd); /* don't let daemon close fds on us */
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) {
DEBUG(LOG_ERR, "bind call failed: %m");
close(fd);
return -1;
}
return fd;
}