From owner-freebsd-hackers Mon Nov 24 23:15:00 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id XAA19523 for hackers-outgoing; Mon, 24 Nov 1997 23:15:00 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from word.smith.net.au (vh1.gsoft.com.au [203.38.152.122]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id XAA19513 for ; Mon, 24 Nov 1997 23:14:56 -0800 (PST) (envelope-from mike@word.smith.net.au) Received: from word (localhost [127.0.0.1]) by word.smith.net.au (8.8.7/8.8.5) with ESMTP id RAA00411; Tue, 25 Nov 1997 17:40:13 +1030 (CST) Message-Id: <199711250710.RAA00411@word.smith.net.au> X-Mailer: exmh version 2.0zeta 7/24/97 To: Jim Carroll cc: freebsd-hackers@freebsd.org Subject: Re: Retrieve ethernet mac address In-reply-to: Your message of "Mon, 24 Nov 1997 20:15:15 CDT." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 25 Nov 1997 17:40:12 +1030 From: Mike Smith Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > 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