Subject: Re: PPPoE?
To: None <tech-net@netbsd.org>
From: Justin C. Walker <justin@apple.com>
List: tech-net
Date: 10/07/1999 21:26:53
> From: itojun@iijlab.net
> Date: 1999-10-07 20:13:23 -0700
> To: der Mouse <mouse@Rodents.Montreal.QC.CA>
> Subject: Re: PPPoE?
> Cc: tech-net@netbsd.org
> In-reply-to: "07 Oct 1999 22:42:49
> -0400."<"199910080242.WAA00693"@Twig.Rodents.Montreal.QC.CA>
> X-Template-Return-Receipt-To: itojun@itojun.org
> X-Template-Reply-To: itojun@itojun.org
> Delivered-to: tech-net@netbsd.org
> X-PGP-Fingerprint: F8 24 B4 2C 8C 98 57 FD 90 5F B4 60 79 54 16 E2
>
>
> >And related to that, given an interface name, what API should I use to
> >find its MAC address? (I'm perfectly willing, for the moment, to
> >assume it's an Ethernet interface, though it'd be nice to get an error
> >rather than garbage if not.) I'd really *like* to do an AF_LINK
> >SIOCGIFADDR, but it appears to be impossible to create an AF_LINK (or
> >AF_UNSPEC) socket, and SIOCGIFADDR seems to get the address
family from
> >the socket the ioctl is done on.
>
> I do not really recommend SIOCGIFADDR these days as there can be
> multiple address assigned to an interface in a family
> (for AF_LINK it may be safe to assume that there's only one,
but...)
>
> I think SIOCGIFCONF (then loop through the chain of addresses)
> is the best one.
There is (?) also the sysctl() approach, documented in Stevens'
UNPV12E tome (and code on his web site - www.kohala.com). It
depends on support in your particular kernel, but it's an alternative
(and "more modern"?).
The mib setup is roughly
mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
mib[2] = 0;
mib[3] = family; /* only addresses of this
family */
mib[4] = NET_RT_IFLIST;
mib[5] = flags; /* interface index, or 0 */
Regards,
Justin
--
Justin C. Walker, Curmudgeon-At-Large *
Institute for General Semantics |
Manager, CoreOS Networking | When crypto is outlawed,
Apple Computer, Inc. | Only outlaws will have crypto.
2 Infinite Loop |
Cupertino, CA 95014 |
*-------------------------------------*-------------------------------*