Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Jun 2002 14:53:56 -0600
From:      "Kenneth D. Merry" <ken@kdm.org>
To:        "Kevin D. Wooten" <kevin@wooten.com>
Cc:        Robert Watson <rwatson@FreeBSD.ORG>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Retrieving interface MAC address
Message-ID:  <20020618145356.A95073@panzer.kdm.org>
In-Reply-To: <3D0F9ADE.8070103@wooten.com>; from kevin@wooten.com on Tue, Jun 18, 2002 at 01:41:02PM -0700
References:  <Pine.NEB.3.96L.1020618130127.30505C-100000@fledge.watson.org> <3D0F9ADE.8070103@wooten.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jun 18, 2002 at 13:41:02 -0700, Kevin D. Wooten wrote:
> Robert Watson wrote:
> >I tend to retrieve address information about interfaces using
> >getifaddrs(), which will (among other things) retrieve the link layer
> >addresses of an interface.  It might be overkill for your application,
> >however.
> >
> >Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
> >robert@fledge.watson.org      Network Associates Laboratories
> >
> >On Tue, 18 Jun 2002, Kevin D. Wooten wrote:
> >
> >  
> >
> >>How can I go about retrieving the MAC address for an interface? Since 
> >>SIOCGHWADDR doesn't seem to be implemented. Can anyone help??
> >>
> >>Thanks,
> >>Kevin Wooten
> >>
> >>
> Thanks getifaddrs() works great, just one more thing is there a simple 
> way to tell the difference between "real" interfaces and virtual ones? I 
> could obviously exclude the easy ones ( i.e. lo, lp, faith, ... ) by 
> looking at the name, but I am not sure how many different virtual 
> interfaces there are ( or will be ).

You could cross-reference the interfaces returned by getifaddrs() with the
list of PCI devices from the PCIOCGETCONF ioctl.  (see pci(4))

It would only work for PCI NICs, but would be better than nothing.

There are probably other ways to do it as well.

Ken
-- 
Kenneth Merry
ken@kdm.org

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020618145356.A95073>