I am looking for a portable way to read the IPv6 address of a network interface when its name is given. This is mainly needed to add some functionality to GNU ifconfig [1] and while looking around came across the USAGI FAQ [2], which says that SIOCGIFADDR does not work with IPv6 although it does for IPv4. Therefore variants of programs like this [3] do not work for IPv6. I also found that the variant of ifconfig provided by net-tools [4] parses files within /proc/net to read the information instead of using ioctl commands. Another option seems to be to use SIOCGIFCONF, to read all the available interfaces in a linked list [5].
Now both these options seem problematic to me. Firstly /proc/net/ does not seem to exist on GNU/Hurd [6] and NetBSD [7], while I do not want to read all the interfaces when all I want is the IPv6 address of a specific interface.
What do you suggest?
Thanks, Debarshi
[1] http://www.gnu.org/software/inetutils [2] http://www.linux-ipv6.org/faq.html [3] http://rishi.fedorapeople.org/gnu/getip.c [4] http://www.tazenda.demon.co.uk/phil/net-tools/ [5] http://www.ibm.com/developerworks/aix/library/au-ioctl-socket.html [6] flubber.bddebian.com [7] freeshell.org