LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-10-2002, 04:54 AM   #1
obashir
LQ Newbie
 
Registered: Nov 2002
Location: Loughborough, UK
Distribution: Redhat 9, Fedora, Yellow Dog
Posts: 29

Rep: Reputation: 15
Detecting IPv6 addresses of interfaces


I am trying to detect the number and type of interfaces installed on a host and their IP addresses using the ioctl function. It returns the type of interfaces and their IPv4 addresses but is unable to return the the correct IPv6 addresses. Richard Stevens suggested in his book that IPv6 implementations do not return IP addresses with ioctl function.

I shall be grateful for any suggestion of an alternative.

OMAR
 
Old 11-11-2002, 06:34 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 46
Well according to the netdevice(7) man page the ipv6 addresses can be retrieved either from /proc/net or through rtnetlink.

You might want to read the rtnelink 3 and 7 man pages.
 
Old 11-12-2002, 12:47 AM   #3
obashir
LQ Newbie
 
Registered: Nov 2002
Location: Loughborough, UK
Distribution: Redhat 9, Fedora, Yellow Dog
Posts: 29

Original Poster
Rep: Reputation: 15
Hello Mik

I tried man rtnetlink(7) and it talks about message formats. man rtnetlink(3) shows an incomplete example but in the end the man page suggests that the page is incomplete and incorrect.

If I understand it correctly, I need to form an appropriate message and send it over the socket opened for PF_NETLINK family. The reply I will receive will contain the required IP addresses.

OMAR.
 
Old 11-12-2002, 07:39 AM   #4
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 46
Well I've never worked with ipv6 addresses nor with the netlink interface. I found some source code which describes how to use the netlink interface to get ip addresses, it is however for ipv4 addresses but it should work with ipv6 with a few modifications. Basically changing the family to AF_INET6 and changing the way the addresses are displayed should be enough. Anyways the example program is here:

http://linux-kernel.skylab.org/20010902/msg00920.html

The example program does however require you to be root to bind to the socket. But to get netlink information it's not necessary to bind to a socket. So just remove the bind part and you can run it as a normal user. Hope that helps somehow.
 
Old 11-13-2002, 07:25 PM   #5
wirelessman
LQ Newbie
 
Registered: Apr 2002
Posts: 10

Rep: Reputation: 0
I was struggle with this for quite a while. And my best solution for this is open the file in /proc/net/if_inet6 and read out from there. That is how the net-tools did. It is the cheapest and easier way for getting the information that you want. You just need to play around with the file reading format. That is the tricky part.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ipv6 vito_huang Linux - Networking 1 10-30-2004 02:28 AM
ipv6 (help) moonspell Linux - Networking 0 03-09-2004 12:47 PM
ipv6 fontoura Linux - General 0 11-05-2003 05:04 AM
IPv6 n3wb1e Linux - Networking 2 10-20-2003 04:05 PM
IPv6 Russman67 Linux - Networking 2 09-02-2002 01:32 AM


All times are GMT -5. The time now is 11:05 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration