Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # headers elided
- int main()
- {
- char buf[1024];
- struct ifconf ifc;
- struct ifreq *ifr;
- int sck;
- int count;
- int i;
- sck = socket(2, 2, 0);
- if (sck < 0)
- {
- perror("socket");
- return 1;
- }
- ifc.ifc_len = sizeof(buf);
- ifc.ifc_ifcu.ifcu_buf = buf;
- if (ioctl(sck, (0x80000000|(((long)sizeof(struct ifconf)&0x7f)<<16)|('s'<<8)|100), &ifc) < 0)
- {
- perror("ioerror");
- return 1;
- }
- ifr = ifc.ifc_ifcu.ifcu_req;
- count = ifc.ifc_len / sizeof(struct ifreq);
- for (i = 0; i < count; i++)
- {
- struct ifreq *item = &ifr[i];
- fprintf(((__getreent())->_stdout), "name: %s\n", item->ifr_ifrn.ifrn_name);
- fprintf(((__getreent())->_stdout), "hwaddr: %02x:%02x:%02x:%02x:%02x:%02x\n",
- (unsigned char)item->ifr_ifru.ifru_hwaddr.sa_data[0],
- (unsigned char)item->ifr_ifru.ifru_hwaddr.sa_data[1],
- (unsigned char)item->ifr_ifru.ifru_hwaddr.sa_data[2],
- (unsigned char)item->ifr_ifru.ifru_hwaddr.sa_data[3],
- (unsigned char)item->ifr_ifru.ifru_hwaddr.sa_data[4],
- (unsigned char)item->ifr_ifru.ifru_hwaddr.sa_data[5]);
- }
- }
Add Comment
Please, Sign In to add comment