- if (ioctl(fd, SIOCGIFHWADDR, &ifr) == 0) {
- memcpy(arp, ifr.ifr_hwaddr.sa_data, 6);
- DEBUG(LOG_INFO, "adapter hardware address %02x:%02x:%02x:%02x:%02x:%02x",
- arp[0], arp[1], arp[2], arp[3], arp[4], arp[5]);
- } else {
- LOG(LOG_ERR, "SIOCGIFHWADDR failed!: %m");
+ log1("adapter index %d", ifr->ifr_ifindex);
+ *ifindex = ifr->ifr_ifindex;
+ }
+
+ if (mac) {
+ if (ioctl_or_warn(fd, SIOCGIFHWADDR, ifr) != 0) {
+ close(fd);