Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Nov 1997 17:40:12 +1030
From:      Mike Smith <mike@smith.net.au>
To:        Jim Carroll <jim@carroll.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Retrieve ethernet mac address 
Message-ID:  <199711250710.RAA00411@word.smith.net.au>
In-Reply-To: Your message of "Mon, 24 Nov 1997 20:15:15 CDT." <Pine.BSD.3.91.971124201015.32350Y-100000@apollo.carroll.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
> 
>  Could someone point me towards how to retrieve an ethernet mac address from
>  user-land code ?  If it matters, we are running 2.2.1

The best way is using sysctl() as with ifconfig(8).  I realise that 
this is a little fugly.

Can you be more specific about which MAC address you want, and what 
associations you want with the address?

>  If  someone  has  a  working  snippet,  I would be grateful. A good pointer
>  towards a FAQ or doc would also be helpful.

The best suggestion I can make is to look at the source, and the way 
that the sysctl variables are established when an interface is created. 

>  I  have been staring at netstat and ifconfig source for a few hours, but am
>  having trouble making heads or tails. netstat usese kvm() and ifconfig uses
>  sysctl(). I can't find enough docs of either method to get my  head  around
>  what is needed to just extract mac address.

If all you want is a list of MAC addresses for the local system, I 
would use ifconfig(8) and awk(1).  8)

mike





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