summaryrefslogtreecommitdiffhomepage
path: root/networking/udhcp/socket.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-11-20 19:40:36 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-11-20 19:40:36 +0000
commit736230e2098e55720a1e235b1c13bdd1a3372c86 (patch)
tree8269cafd5207e1d2d3f3870c83b2e0b2bdc3bf42 /networking/udhcp/socket.c
parentc9cdeaa3fef3f93eb259957d36c760ec8902e0c1 (diff)
dhcprelay: new applet
Diffstat (limited to 'networking/udhcp/socket.c')
-rw-r--r--networking/udhcp/socket.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c
index ea2913172..c19131d65 100644
--- a/networking/udhcp/socket.c
+++ b/networking/udhcp/socket.c
@@ -63,23 +63,27 @@ int read_interface(char *interface, int *ifindex, uint32_t *addr, uint8_t *arp)
DEBUG("%s (our ip) = %s", ifr.ifr_name, inet_ntoa(our_ip->sin_addr));
}
- if (ioctl(fd, SIOCGIFINDEX, &ifr) == 0) {
- bb_perror_msg("SIOCGIFINDEX failed");
- close(fd);
- return -1;
+ if (ifindex) {
+ if (ioctl(fd, SIOCGIFINDEX, &ifr) == 0) {
+ bb_perror_msg("SIOCGIFINDEX failed");
+ close(fd);
+ return -1;
+ }
+ DEBUG("adapter index %d", ifr.ifr_ifindex);
+ *ifindex = ifr.ifr_ifindex;
}
- DEBUG("adapter index %d", ifr.ifr_ifindex);
- *ifindex = ifr.ifr_ifindex;
- if (ioctl(fd, SIOCGIFHWADDR, &ifr) != 0) {
- bb_perror_msg("SIOCGIFHWADDR failed");
- close(fd);
- return -1;
+ if (arp) {
+ if (ioctl(fd, SIOCGIFHWADDR, &ifr) != 0) {
+ bb_perror_msg("SIOCGIFHWADDR failed");
+ close(fd);
+ return -1;
+ }
+ memcpy(arp, ifr.ifr_hwaddr.sa_data, 6);
+ DEBUG("adapter hardware address %02x:%02x:%02x:%02x:%02x:%02x",
+ arp[0], arp[1], arp[2], arp[3], arp[4], arp[5]);
}
- memcpy(arp, ifr.ifr_hwaddr.sa_data, 6);
- DEBUG("adapter hardware address %02x:%02x:%02x:%02x:%02x:%02x",
- arp[0], arp[1], arp[2], arp[3], arp[4], arp[5]);
return 0;
}