Date: Wed, 10 Oct 2001 19:58:36 +0300 From: Ruslan Ermilov <ru@FreeBSD.ORG> To: Kim Kyung-hwan <redjade@ada.snu.ac.kr> Cc: freebsd-net@FreeBSD.ORG Subject: Re: Getting link level addr using SIOCGIFADDR Message-ID: <20011010195836.A63046@sunbay.com> In-Reply-To: <20011010234039.A2120@ada.snu.ac.kr>; from redjade@ada.snu.ac.kr on Wed, Oct 10, 2001 at 11:40:39PM %2B0900 References: <20011010234039.A2120@ada.snu.ac.kr>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011010195836.A63046>