From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 21 23:45:00 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3F3E716A400; Wed, 21 Feb 2007 23:45:00 +0000 (UTC) (envelope-from don.hinton@vanderbilt.edu) Received: from mailgate04.smtp.vanderbilt.edu (mailgate04.smtp.Vanderbilt.Edu [129.59.1.75]) by mx1.freebsd.org (Postfix) with ESMTP id E6A8613C467; Wed, 21 Feb 2007 23:44:59 +0000 (UTC) (envelope-from don.hinton@vanderbilt.edu) Received: from smtp10.smtp.vanderbilt.edu (smtp10.smtp.Vanderbilt.Edu [129.59.1.11]) by mailgate04.smtp.vanderbilt.edu (8.13.7/8.13.7) with ESMTP id l1LMnou3002608 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 21 Feb 2007 16:49:50 -0600 Received: from smtp10.smtp.vanderbilt.edu (localhost [127.0.0.1]) by smtp10.smtp.vanderbilt.edu (8.12.11/8.12.11/VU-3.7.9C+d3.7.9) with ESMTP id l1LMno63002256; Wed, 21 Feb 2007 16:49:50 -0600 (CST) Received: from a129103.n1.vanderbilt.edu (A129103.N1.Vanderbilt.Edu [129.59.129.103]) by smtp10.smtp.vanderbilt.edu (8.12.11/8.12.11/VU-3.7.9.3B+d3.7.9) with ESMTP id l1LMnnEO002253 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 21 Feb 2007 16:49:50 -0600 (CST) From: Don Hinton Organization: ISIS To: freebsd-questions@freebsd.org Date: Wed, 21 Feb 2007 16:49:41 -0600 User-Agent: KMail/1.9.4 References: <45DB63B1.7050004@swehack.se> <45DCB3AC.8090609@swehack.se> In-Reply-To: <45DCB3AC.8090609@swehack.se> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart6855273.rMar1JWdIm"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200702211649.49108.don.hinton@vanderbilt.edu> X-Proofpoint-Virus-Version: vendor=fsecure engine=4.65.5502:2.3.11, 1.2.37, 4.0.164 definitions=2007-02-21_07:2007-02-21, 2007-02-21, 2007-02-21 signatures=0 X-PPS: No, score=0 Cc: nocturnal , freebsd-hackers@freebsd.org, Pietro Cerutti Subject: Re: Which file to request SIOCGIFMAC on? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Feb 2007 23:45:00 -0000 --nextPart6855273.rMar1JWdIm Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Wednesday 21 February 2007 15:03, nocturnal wrote: > Hi > > Well that's weird, is MAC defined by default at all? I tried searching > for the definition but couldn't find it. > > I never thought it would be this hard just to get the ethernet address > from an ethernet interface in FreeBSD. I think i'll take a look at the > netlib source next, something tells me it will be easier to just > plagiarize their method than going through the kernel source any more. Have you tried google? This was asked on freebsd-hackers a few months ago: http://lists.freebsd.org/pipermail/freebsd-hackers/2006-August/017601.html hth... don > > > > Med v=C3=A4nliga h=C3=A4lsningar > > Stefan Midjich aka nocturnal > [Swehack] http://swehack.se > > Pietro Cerutti wrote: > > On 2/20/07, nocturnal wrote: > >> Hi > >> > >> The original plan is to only run it on FreeBSD 5 and higher, actually > >> only 6 by now. It's a program i'm writing for work and at work the most > >> active servers run FreeBSD 6 and are updated frequently. The ones with > >> older versions don't run anything of interest. > >> > >> I am buying a MacBook for personal use though so it would be nice to r= un > >> it on osx. I wouldn't like to start using another library just to get > >> the hardware address of an interface though, that seems kinda overkill > >> for what should be a simple task. The program is already using libpcap > >> but that is included in FreeBSD by default so you don't have to > >> install it. > >> > >> Do you have any idea of why i'm getting this error from ioctl when i'm > >> doing what the manual says i should do? I am of course running it as > >> root to because the libpcap operations require it. > >> > >> What might help me is to take a look at the source of that > >> libnet_get_hwaddr function in libnet. I'll try that, thank you very mu= ch > >> for the tip. > >> > >> So far i've been trying to look at the source for ifconfig to figure o= ut > >> how it gets the hardware address. Of course it uses SIOCGIFMAC but i > >> can't find the socket it opens because i can't find where it uses the > >> maclabel_status function. > > > > The problem isn't with the socket type or options. > > If you debug ifconfig, you'll find out that the ioctl call always > > returns -1, and the program goes on to the "goto mac_free" line. > > > > Take a look at /usr/src/sys/net/if.c, line 1258 > > > > Should we deduce that the particular ioctl isn't supported? > > > > P.S. I'm forwarding this to freebsd-hackers@ too, so sorry for cross > > posting > > > >> Med v=C3=A4nliga h=C3=A4lsningar > >> > >> Stefan Midjich aka nocturnal > >> [Swehack] http://swehack.se > >> > >> Chuck Swiger wrote: > >> > On Feb 20, 2007, at 1:10 PM, nocturnal wrote: > >> >> I'm trying to get the ethernet address and from the manuals i > >> >> understand that i need the ifreq structure for this. So i'm trying = to > >> >> request SIOCGIFMAC with ioctl on a socket of type SOCK_DGRAM. > >> > > >> > If you're just targetting FreeBSD >=3D 5.x platforms, your current > >> > approach is reasonable (assuming you can fix whatever the problem is= ); > >> > if you're targetting other platforms such FreeBSD 4, Dfly, OS X, or > >> > >> SysV > >> > >> > things like Solaris, try installing the libnet port and invoke > >> > libnet_get_hwaddr(). > >> > > >> > ---Chuck > >> > >> _______________________________________________ > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" =2D-=20 Don Hinton or Institute for Software Integrated Systems (ISIS), Vanderbilt University tel: 615.480.5667 or 615.870.9728 --nextPart6855273.rMar1JWdIm Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD4DBQBF3MyM0U0xbM5cLs0RApisAJjup24/r9abRSffaFdlOdLS3IAPAKDCsx/9 O07xX/nrHhQWVldfRVKx9w== =7V6+ -----END PGP SIGNATURE----- --nextPart6855273.rMar1JWdIm--