if ((ioctl (mi->fd, SIOCGARP, (char *) & mi->arp))) {
err->errcode = errno;
snprintf (err->errmsg, GETMAC_MAX_MSGLEN, "ioctl(SIOCGARP) error (%d): %s", strerror(errno));
return GETMAC_ERROR;
} else {
sprintf (value, "%02x:%02x:%02x:%02x:%02x:%02x",
(unsigned char) mi->arp.arp_ha.sa_data[0],
(unsigned char) mi->arp.arp_ha.sa_data[1],
(unsigned char) mi->arp.arp_ha.sa_data[2],
(unsigned char) mi->arp.arp_ha.sa_data[3],
(unsigned char) mi->arp.arp_ha.sa_data[4],
(unsigned char) mi->arp.arp_ha.sa_data[5] );
}
} while (0);
#else
#if 0
do {
sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
(unsigned char) mi->buf[i].ifr_enaddr[0],
(unsigned char) mi->buf[i].ifr_enaddr[1],
(unsigned char) mi->buf[i].ifr_enaddr[2],
(unsigned char) mi->buf[i].ifr_enaddr[3],
(unsigned char) mi->buf[i].ifr_enaddr[4],
(unsigned char) mi->buf[i].ifr_enaddr[5]);
} while (0);
#else
do {
sprintf (value, "%02x:%02x:%02x:%02x:%02x:%02x",
(unsigned char) mi->buf[i].ifr_hwaddr.sa_data[0],
(unsigned char) mi->buf[i].ifr_hwaddr.sa_data[1],
(unsigned char) mi->buf[i].ifr_hwaddr.sa_data[2],
(unsigned char) mi->buf[i].ifr_hwaddr.sa_data[3],
(unsigned char) mi->buf[i].ifr_hwaddr.sa_data[4],
(unsigned char) mi->buf[i].ifr_hwaddr.sa_data[5]);
} while (0);
#endif
#endif
snprintf (err->errmsg, GETMAC_MAX_MSGLEN, "MAC address");
break;
default:
err->errcode = GETMAC_EATTR;
snprintf (err->errmsg, GETMAC_MAX_MSGLEN, "error attr specified");
return GETMAC_EATTR;
}
return GETMAC_SUCCESS;
}
void getmac_fini (getmac_info_t * mi)
{
if (mi->fd != -1) {
close (mi->fd);
mi->fd = -1;
}
}