Return to BSD News archive
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msuinfo!agate!howland.reston.ans.net!gatech!news-feed-1.peachnet.edu!news.duke.edu!MathWorks.Com!uhog.mit.edu!grapevine.lcs.mit.edu!ginger.lcs.mit.edu!wollman From: wollman@ginger.lcs.mit.edu (Garrett Wollman) Newsgroups: comp.os.386bsd.questions Subject: Re: finding out about enetaddr Date: 6 Sep 1994 17:01:21 GMT Organization: MIT Laboratory for Computer Science Lines: 28 Message-ID: <34i791$hjs@GRAPEVINE.LCS.MIT.EDU> References: <346pan$84h@urmel.informatik.rwth-aachen.de> NNTP-Posting-Host: ginger.lcs.mit.edu In article <346pan$84h@urmel.informatik.rwth-aachen.de>, Christoph Kukulies <kuku@acds.physik.rwth-aachen.de> wrote: >Does anyone have an idea how to niceley extract the ethernet address >of a given interface out of the kernel? Use the SIOCGIFCONF socket ioctl (you'll need to create a socket for this, but it doesn't have to be bound to anything). This will give you a list that looks like this, for each interface in the system: struct ifreq struct sockaddr_dl (other struct sockaddr's for each configured network layer) Note that the items in this list are variable-length; you must use the sa_len field of the sockaddr to figure out where the next one is. For more information, see the networking(4) manual page (which doesn't tell you a whole lot) and then look at the `ifconf' function in /sys/net/if.c. -GAWollman -- Garrett A. Wollman | Shashish is simple, it's discreet, it's brief. ... wollman@lcs.mit.edu | Shashish is the bonding of hearts in spite of distance. Opinions not those of| It is a bond more powerful than absence. We like people MIT, LCS, ANA, or NSA| who like Shashish. - Claude McKenzie + Florent Vollant