From owner-freebsd-hackers@FreeBSD.ORG Sat Jun 26 09:17:05 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7933216A4CE for ; Sat, 26 Jun 2004 09:17:05 +0000 (GMT) Received: from geri.cc.fer.hr (geri.cc.fer.hr [161.53.72.107]) by mx1.FreeBSD.org (Postfix) with ESMTP id AC1C143D54 for ; Sat, 26 Jun 2004 09:17:04 +0000 (GMT) (envelope-from ivoras@fer.hr) Received: from [127.0.0.1] (root@geri.cc.fer.hr [161.53.72.107]) by geri.cc.fer.hr (8.12.9p2/8.12.8) with ESMTP id i5Q9EasU087697; Sat, 26 Jun 2004 11:14:37 +0200 (CEST) (envelope-from ivoras@fer.hr) Message-ID: <40DD3EC1.9000106@fer.hr> Date: Sat, 26 Jun 2004 11:15:45 +0200 From: Ivan Voras User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dmitry Morozovsky References: <40DCC57F.5090209@fer.hr> <20040626104947.T93253@woozle.rinet.ru> In-Reply-To: <20040626104947.T93253@woozle.rinet.ru> X-Enigmail-Version: 0.84.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: hackers@freebsd.org Subject: Re: Getting MAC address? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Jun 2004 09:17:05 -0000 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?