From owner-freebsd-net Wed Oct 10 9:59:42 2001 Delivered-To: freebsd-net@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id 05F6537B409 for ; Wed, 10 Oct 2001 09:59:29 -0700 (PDT) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.6/8.11.2) id f9AGwaq66858; Wed, 10 Oct 2001 19:58:36 +0300 (EEST) (envelope-from ru) Date: Wed, 10 Oct 2001 19:58:36 +0300 From: Ruslan Ermilov To: Kim Kyung-hwan Cc: freebsd-net@FreeBSD.ORG Subject: Re: Getting link level addr using SIOCGIFADDR Message-ID: <20011010195836.A63046@sunbay.com> References: <20011010234039.A2120@ada.snu.ac.kr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20011010234039.A2120@ada.snu.ac.kr>; from redjade@ada.snu.ac.kr on Wed, Oct 10, 2001 at 11:40:39PM +0900 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Wed, Oct 10, 2001 at 11:40:39PM +0900, Kim Kyung-hwan wrote: > Hello, > > In most case of printing (ethernet) link level address, > program does a SIOCGIFCONF ioctl, gets a ifconf structure(the whole > interface list), finds the very interface and prints the address. > What I want to is to use SIOCGIFADDR so that program finds the > address. > > My program does > 1) get a socket (AF_INET) > 2) make appropriate ifreq structure; > copy interface name and set sa_family to AF_LINK > 3) SIOCGIFADDR ioctl > > But returned ifreq structure doesn't have sockaddr_dl structure. > It is impossible to get link level address using SIOCGIFADDR? > Nope, not possible. But this could be done with CTL_NET.PF_ROUTE.NET_RT_IFLIST sysctl(3), by setting the fourth level to AF_LINK. See lib/libc/net/getifaddrs.c for a working example. Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message