Re: Obtaining a list of MAC address for interfaces without IP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Marc Schneider wrote:
> 
> I am trying to get a list of the MAC address for all ethernet interfaces
> in a machine. I was doing this using ioctl SIOCGIFCONF and SIOCGIFHWADDR
> calls, but this seems to only work for interfaces which have an IP
> address configured for them. I would like to be able to obtain this
> information for all interfaces, any ideas on how to do this?

SIOCGIFCONF is handled by a special handler for each protocol.
ipv4 implements it in devinet.c in function inet_gifconf(). This is
some kind of a fallback implementation if anything else failes (i.e.
nobody else registered a gifconf-handler for the interface), but
of cause it can only work if the interface is an IP interface (has an
IP address). Every other protocol stack should implement the gifconf
function on its own. If one does not, it's imho broken. Then you have
two more solutions: 1.) parsing /proc/net/dev (ugly) or 2.) retrieving
interface info via rtnetlink (complex).

  -- Jens
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux