How to retrieve an interface's MAC address

Arnout Vandecappelle arnout at mind.be
Mon Apr 14 13:17:23 UTC 2008


Chris Johns wrote:
> Arnout Vandecappelle wrote:
>>   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?
>
> There is the sysctl interface which is used by net-snmp to provide
> details about an interface. Not a nice interface but it does work.
> What about the SIOCGIFCONF ioctl ? See
> cpukit/libnetworking/libc/getifaddrs.c for an example of its use. Look
> for the socket part of the code. Check 'ifconf' in
> cpukit/libnetworking/net/if.c.
>
> Please update the Wiki if you get a solution.
 It took me a week to implement this, but here it goes.  I updated the
Wiki as well.

 Since I'm working with a 4.6.99 version, could someone try this on the
current RTEMS?

 Regards,
 Arnout

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: get_macaddr.c
Type: text/x-csrc
Size: 1286 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/users/attachments/20080414/d0d3703c/attachment-0001.bin>


More information about the users mailing list