netdev
[Top] [All Lists]

Re: looking for help with scanning of IPv6 interfaces

To: Michael Richardson <mcr@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: looking for help with scanning of IPv6 interfaces
From: Andi Kleen <ak@xxxxxxx>
Date: Fri, 15 Nov 2002 20:00:51 +0100
Cc: netdev@xxxxxxxxxxx
In-reply-to: <200211151738.gAFHcDwX006227@sandelman.ottawa.on.ca>
References: <200211151738.gAFHcDwX006227@sandelman.ottawa.on.ca>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.3.22.1i
On Fri, Nov 15, 2002 at 12:38:12PM -0500, Michael Richardson wrote:
> 1) Awhile ago there was a flame war about using SIOCGIFCONF/SIOCGLIFCONF
> to get lists of interfaces. This was suggested as being a bad way.
> 
> 2) bind 9.3snapshot is able to get a list of IPv4 addresses with SIOCGIFCONF,
> 
> 3) it is not able to get IPv6 addresses with SIOCGLIFCONF.
> 
> Marc Andrews, sitting next to me, asked if I knew what the offical magic
> was. Can someone point me that officially blessed way to do this?

Physical devices are read using /proc/net/dev

If you want IPv6 addresses you can read and parse /proc/net/if_inet6 

That is the old fashioned way.
 
The new fashioned one is to query them using rtnetlink. You use a RTM_GETADDR
NLM_F_REQUEST query with wildcard (NLM_F_ROOT) to get a full list.
See the netlink,rtnetlink, libnetlink manpages and iproute2 as an example. 
It is easier when you use libnetlink.

-Andi


<Prev in Thread] Current Thread [Next in Thread>