On Mon, 2005-05-09 at 08:49 -0400, Donald McLachlan wrote:
> 
> > From [EMAIL PROTECTED] Sun May  8 11:03:56 2005
> > Subject: Re: Application tool to acquire all ipv6 addresses on a specified
> >     int erface
> > 
> > On Fri, 2005-05-06 at 08:29 -0400, Bellino, Phil wrote:
> > > Hello,
> > > I am running 2.6.11 linux and have IPv6 addresses on eth0, eth1, tun6to4,
> > > etc.
> > > 
> > > I am looking for a tool that my applcation can use that will give me back
> > > all of the IPv6 addresses that are on a specified interface.
> > > I am trying to prevent having to execute a shell command(such as "ip" or
> > > "ifconfig") and then having to parse all that is returned for the IPv6
> > > addresses in question.
> > > 
> > > Does anyone know of such a tool?
> > 
> > It is called 'cat', or grep if you want a single entry
> > 
> > [EMAIL PROTECTED]:~$ cat /proc/net/if_inet6 
> > 00000000000000000000000000000001 02 80 10 80       lo
> > fe800000000000000a002bfffee702b3 03 40 20 80     eth1
> > 200107b8000500100f71000000000002 03 50 00 80     eth1
> > 200107b803000000029027fffe24c19f 01 40 00 80     eth0
> > fe80000000000000029027fffe24c19f 01 40 20 80     eth0
> > 
> > Notez bien, this will only work on linux and not any other platform.
> > Then again doing it crossplatform is I guess almost impossible anyway
> > except if one codes a part for every separate OS.
> > 
> > Greets,
> >  Jeroen
> 
> 
> That give the interface names, not the addresses, as was requested.

Did you notice that this line:

200107b803000000029027fffe24c19f 01 40 00 80     eth0

reads:

2001:7b8:20d:0:290:27ff:fe24:c19f .. prefixlen .. .. .. iface name

Which gives exactly what was requested on the platform mentioned by the
person who requested it, not so weird also when two linux lists are
mentioned.

(The first is the requested IPv6 address if you did not notice yet)

> RFC 3493 shows if_nameindex() will provide the list of available interfaces
> in a portable manner.

Which is very importably implemented on most platforms that you will
find it on, if, as it is not implemented on many platforms in the first
place.

>   The problem from the original quesiton is how to get
> the addresses associated with the names without using ip or ifconfig.

'cat' does not use any of those tools now does it ? :)
And one can also do it using a number of other tools including standard
fopen() and fread() calls. But as you might have noticed the question
was for an 'application tool' which means external, eg callable from a
script etc. Of course one can do that with if_nameindex() and friends
too, but using /proc is much easier.

</stupid argument contest>

Greets,
 Jeroen

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to