How to retrieve an interface's MAC address

Arnout Vandecappelle arnout at mind.be
Fri Apr 4 10:04:43 UTC 2008


  Hoi,

 I need to get the network interface's MAC address from my application. 
According to the Wiki (Obtaining_Interface_Information), this can be
obtained by ioctl'ing for SIOCGIFADDR.  However, this gives the IP
address (ether_ioctl does return the MAC address, but it never gets
there as it is intercepted by in_control).  As far as I can see, there
is no simple way to retrieve the MAC address from the application.  (You
can get it from within the networking stack one you have the struct
ifnet, like is done in the DHCP client, but this is not supposed to be
accessible from the application.)

 Is there a way to retrieve it that I missed?
 Should I add a SIOCGIFHWADDR ioctl like in Linux?

 Regards,
 Arnout

-- 
Arnout Vandecappelle                     arnout at mind be
Senior Embedded Software Architect       +32-16-286540
Mind Embedded Development (an Essensium division)




More information about the users mailing list