Date: Sat, 26 Jun 2004 11:15:45 +0200 From: Ivan Voras <ivoras@fer.hr> To: Dmitry Morozovsky <marck@rinet.ru> Cc: hackers@freebsd.org Subject: Re: Getting MAC address? Message-ID: <40DD3EC1.9000106@fer.hr> In-Reply-To: <20040626104947.T93253@woozle.rinet.ru> References: <40DCC57F.5090209@fer.hr> <20040626104947.T93253@woozle.rinet.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
Dmitry Morozovsky wrote: > On Sat, 26 Jun 2004, Ivan Voras wrote: > > IV> How to get the MAC address for an (ethernet) interface? The linux code > IV> does this: > IV> retval = ioctl(thisint->sockInt, SIOCGIFHWADDR, &ifr); > IV> > IV> After some searching, I found SIOCSIFLLADDR ioctl, but it appears there > IV> isn't a "GET" counterpart. > IV> > IV> (I've got interface name & index available...) > > Take a look at ifconfig(8) source. > > getifaddrs(3), case when sa_family == AF_LINK I was looking at it and came across getifaddrs(). This function does not depend on a open socket (yes, mine is AF_LINK, sockaddr_dl), and apparently returns a list of all interfaces. Is there really no other way than to traverse this list? -- What part of "Ph'nglui mglw'nath Cthulhu R'lyeh wgah'nagl fhtagn" don't you understand?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40DD3EC1.9000106>