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

From: Jens David (dg1kjd@dl0td.afthd.tu-darmstadt.de)
Date: Wed Sep 13 2000 - 18:41:34 EST


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
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org



This archive was generated by hypermail 2b29 : Fri Sep 15 2000 - 21:00:29 EST