From owner-freebsd-questions@FreeBSD.ORG Tue Feb 20 22:49:32 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 BA3EF16C83C for ; Tue, 20 Feb 2007 22:49:32 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from mail-out3.apple.com (mail-out3.apple.com [17.254.13.22]) by mx1.freebsd.org (Postfix) with ESMTP id A2B2113C474 for ; Tue, 20 Feb 2007 22:49:32 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from relay8.apple.com (a17-128-113-38.apple.com [17.128.113.38]) by mail-out3.apple.com (8.13.8/8.13.8) with ESMTP id l1KMnWH1003947; Tue, 20 Feb 2007 14:49:32 -0800 (PST) Received: from relay8.apple.com (unknown [127.0.0.1]) by relay8.apple.com (Symantec Mail Security) with ESMTP id 71F4C404F4; Tue, 20 Feb 2007 14:49:32 -0800 (PST) X-AuditID: 11807126-9d7c9bb00000685d-58-45db7afcc47d Received: from [17.214.13.96] (cswiger1.apple.com [17.214.13.96]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by relay8.apple.com (Apple SCV relay) with ESMTP id 60937400B1; Tue, 20 Feb 2007 14:49:32 -0800 (PST) In-Reply-To: <45DB7751.3010401@swehack.se> References: <45DB63B1.7050004@swehack.se> <45DB7751.3010401@swehack.se> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Chuck Swiger Date: Tue, 20 Feb 2007 14:49:31 -0800 To: nocturnal X-Mailer: Apple Mail (2.752.2) X-Brightmail-Tracker: AAAAAA== 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:49:32 -0000 On Feb 20, 2007, at 2:33 PM, nocturnal wrote: [ ...looking up one's MAC address... ] > 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. I don't think PCAP offers an easy way to get the MAC address of a given interface, short of capturing a packet sent from the host via that particular interface, and then figuring out the right offset to the source/sender MAC based on the datalink type header, which presumably will be DLT_EN10MB (14 bytes in size, IIRC). > 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. Nope, sorry. I remember trying to make this go myself a while back, and decided that using the libnet call was much easier than figuring out why the SIOCGIFMAC ioctl wasn't working as expected... > 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. Well, you could always invoke and parse the output of ifconfig (or arp), but I can understand wanting to get the information directly without frobbing external programs. :-) -- -Chuck