On Fri, 4 Aug 2006, Mario Lobo wrote:

Would anyone have a tip on how to get the MAC from a C program?

I tried:

   struct ifreq ifreq;
   unsigned char *hw;

   strcpy(ifreq.ifr_name, "rl0");
   ioctl(fd, SIOCGIFMAC, &ifreq);
   hw = ifreq.ifr_ifru.ifru_data; ????

but i don't know if this is right or, if it is, where to get the MAC from the structure. I doesn't issue any error compiling or running though.

Usually the general purpose interface recommended for inspecting interface information is getifaddrs(), which will build a userspace list of interfaces and their various addresses, including link-layer addresses. Something like the above will work, but may not be preferred.

Robert N M Watson
Computer Laboratory
University of Cambridge


In linux i used:

   struct ifreq ifreq;
   unsigned char *hw;

   strcpy(ifreq.ifr_name, "rl0");
   ioctl(fd, SIOCGIFHWADDR, &ifreq);
   hw = ifreq.ifr_hwaddr.sa_data;

Thanks,

Mario
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to