From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 4 10:55:12 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4C34B16A4E0 for ; Fri, 4 Aug 2006 10:55:12 +0000 (UTC) (envelope-from mario.lobo@ipad.com.br) Received: from recife.ipad.com.br (recife.ipadnet.com.br [200.249.204.129]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6F6CF43D5C for ; Fri, 4 Aug 2006 10:55:09 +0000 (GMT) (envelope-from mario.lobo@ipad.com.br) Received: from lobo.ipad.com.br ([192.168.64.1]) (authenticated bits=0) by recife.ipad.com.br (8.12.8/8.12.8) with ESMTP id k74BLfZX000544 for ; Fri, 4 Aug 2006 08:21:41 -0300 From: Mario Lobo Organization: IPAD To: freebsd-hackers@freebsd.org Date: Fri, 4 Aug 2006 07:59:48 +0000 User-Agent: KMail/1.9.3 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200608040759.49390.mario.lobo@ipad.com.br> Subject: getting interface MAC addr from C 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: Fri, 04 Aug 2006 10:55:12 -0000 Hi; Would anyone have a tip on how to get the MAC from a C program? I tried: struct ifreq ifreq; unsigned char *hw; strcpy(ifreq.ifr_name, "rl0"); ioctl(fd, SIOCGIFMAC, &ifreq); hw = ifreq.ifr_ifru.ifru_data; ???? but i don't know if this is right or, if it is, where to get the MAC from the structure. I doesn't issue any error compiling or running though. In linux i used: struct ifreq ifreq; unsigned char *hw; strcpy(ifreq.ifr_name, "rl0"); ioctl(fd, SIOCGIFHWADDR, &ifreq); hw = ifreq.ifr_hwaddr.sa_data; Thanks, Mario