From owner-freebsd-hackers Tue Jul 31 16:28:19 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from postal.edifecs.com (unknown [207.149.212.48]) by hub.freebsd.org (Postfix) with ESMTP id 76DE537B403 for ; Tue, 31 Jul 2001 16:28:12 -0700 (PDT) (envelope-from MichaelV@EDIFECS.COM) Received: from ecx1.edifecs.com (mail.edifecs.com [207.153.149.131]) by postal.edifecs.com (8.11.0/8.11.0) with ESMTP id f6VNaRT17113; Tue, 31 Jul 2001 16:36:28 -0700 Received: by ecx1.edifecs.com with Internet Mail Service (5.5.2653.19) id ; Tue, 31 Jul 2001 16:34:25 -0700 Message-ID: <36F7B20351634E4FBFFE6C6A216B30D54C81@ecx1.edifecs.com> From: Michael VanLoon To: "'Jag Johal'" , "'hackers@freebsd.org'" Cc: "'hackers@freebsd.org'" Subject: RE: Finding MAC address of interface - programming question Date: Tue, 31 Jul 2001 16:34:17 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Thanks that's just exactly the information I was looking for. :-) I'm slow grunging through the code and man pages that take this apart. As far as UNPv1 I assume you're referring to Stevens' "Unix Network Programming"? If I'm not mistaken he doesn't go much below the socket level. A quick glance through didn't reveal anything of this nature. Thanks for the info. > -----Original Message----- > From: Jag Johal [mailto:Jag@midstream.com] > Sent: Tuesday, July 31, 2001 4:21 PM > To: 'hackers@freebsd.org'; Michael VanLoon > Cc: 'hackers@freebsd.org' > Subject: RE: Finding MAC address of interface - programming question > > > Use sysctl(3), basically, its something like this. > mib[0] = CTL_NET; > mib[1] = AF_ROUTE; > mib[2] = 0; > mib[3] = AF_INET; > mib[4] = NET_RT_IFLIST; > mib[5] = 0; > > sysctl(mib, 6, buf, &len, NULL, 0); > buf will contain for each interface, an if_msghdr followed by > a sockaddr_dl, > the sockaddr_dl will contain the interface name and mac addr. > Following that > will be a ifa_msghdr for each ip address on the interface. > You may want to > check out UNPv1. > > Jag > > -----Original Message----- > From: Chris Faulhaber [mailto:jedgar@fxp.org] > Sent: Tuesday, July 31, 2001 3:56 PM > To: Michael VanLoon > Cc: 'hackers@freebsd.org' > Subject: Re: Finding MAC address of interface - programming question > > > On Tue, Jul 31, 2001 at 03:56:40PM -0700, Michael VanLoon wrote: > > Please point me to a more appropriate forum if there is > one. I'm kinda > out > > of my depth on this question. Pseudo code is fine. :-) > > > > What I'm looking for is how to enumerate the network > interfaces and get > the > > Ethernet MAC address of one programmatically. Can anyone > point me in the > > right direction? > > > > /usr/src/sbin/ifconfig > > -- > Chris D. Faulhaber - jedgar@fxp.org - jedgar@FreeBSD.org > -------------------------------------------------------- > FreeBSD: The Power To Serve - http://www.FreeBSD.org > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message