From owner-freebsd-questions@FreeBSD.ORG Tue Feb 20 22:33:38 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0FD1816B58F for ; Tue, 20 Feb 2007 22:33:38 +0000 (UTC) (envelope-from nocturnal@swehack.se) Received: from smtp1.inkorgen.com (smtp1.inkorgen.com [82.99.44.201]) by mx1.freebsd.org (Postfix) with ESMTP id 7EFB813C471 for ; Tue, 20 Feb 2007 22:33:37 +0000 (UTC) (envelope-from nocturnal@swehack.se) Received: from proxy1.inkorgen.com (proxy1 [192.168.100.1]) by smtp1.inkorgen.com (8.13.8/8.13.8) with ESMTP id l1KMXYCX032587 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 20 Feb 2007 23:33:35 +0100 (CET) Received: from [85.24.149.192] (h-149-192.A175.cust.bahnhof.se [85.24.149.192]) (authenticated bits=0) by proxy1.inkorgen.com (8.13.8/8.13.8) with ESMTP id l1KMSSbj084445; Tue, 20 Feb 2007 23:28:28 +0100 (CET) Message-ID: <45DB7751.3010401@swehack.se> Date: Tue, 20 Feb 2007 23:33:53 +0100 From: nocturnal User-Agent: Thunderbird 1.5 (X11/20060317) MIME-Version: 1.0 To: Chuck Swiger References: <45DB63B1.7050004@swehack.se> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV version 0.88.5, clamav-milter version 0.88.5 on washer1.inkorgen.com X-Virus-Status: Clean Cc: freebsd-questions@freebsd.org Subject: Re: Which file to request SIOCGIFMAC on? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Feb 2007 22:33:38 -0000 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 run 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 much for the tip. So far i've been trying to look at the source for ifconfig to figure out 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. Med vänliga hälsningar 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 >= 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 > > >