- if (ioctl(fd, SIOCGIFHWADDR, &ifr) == 0) {
- 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]);
- } else {
- bb_perror_msg("SIOCGIFHWADDR failed");
+ log1("adapter index %d", ifr->ifr_ifindex);
+ *ifindex = ifr->ifr_ifindex;
+ }
+
+ if (mac) {
+ if (ioctl_or_warn(fd, SIOCGIFHWADDR, ifr) != 0) {