From owner-freebsd-questions@FreeBSD.ORG Tue Feb 20 21:09:52 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 BF08416B972 for ; Tue, 20 Feb 2007 21:09:52 +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 53FFC13C4AA for ; Tue, 20 Feb 2007 21:09:52 +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 l1KL9oV9018849 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 20 Feb 2007 22:09:50 +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 l1KL4iIi083840 for ; Tue, 20 Feb 2007 22:04:44 +0100 (CET) Message-ID: <45DB63B1.7050004@swehack.se> Date: Tue, 20 Feb 2007 22:10:09 +0100 From: nocturnal User-Agent: Thunderbird 1.5 (X11/20060317) MIME-Version: 1.0 To: freebsd-questions@freebsd.org 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 Subject: 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 21:09:52 -0000 Hi 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. Now i couldn't figure out from the manuals which format but i've tried PF_LOCAL, PF_INET and AF_INET. With PF_LOCAL i get the error "Operation not supported" from ioctl but with AF_INET or PF_INET i get "Invalid argument". This is a snippet of code that i use to get the ethernet address. Earlier code has already verified the char *ifname which contains the interface name. [..] int if_socket; struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); [..] strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if((if_socket = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { perror("socket: "); exit(-1); } if(ioctl(if_socket, SIOCGIFMAC, &ifr) < 0) { perror("ioctl: SIOCGIFMAC: "); exit(-1); } [..] I know the rest of the code works fine because this is something i'm adding to a working program. Also it's obviously stopping at the ioctl since i get the error "ioctl: SIOCGIFMAC: : Invalid argument". -- Med vänliga hälsningar Stefan Midjich aka nocturnal [Swehack] http://swehack.se