Using resolv.h name resolver with IPv6

I write or modify programs that do name resolution and have good control over the process. Therefore, I do not use getaddrinfo(), I go deeper and use res_query()/ res_send()/ etc in resolv.h, documented in resolver (3).

Although the documentation is not documented, the general way to install the inverter used is to upgrade _res.nsaddr_list. But this array, defined in resolv.h, stores struct sockaddr_in, that is, only IPv4 addresses. (IPv6 addresses struct sockaddr_in6, a family-specific system will use struct sockaddr.)

I am looking for a way (preferably portable, at least among various Unix), to report _resthat I want IPv6 addresses as well.

Apparently, a long time ago a appeared in FreeBSD _res_extwith this, but I can not find it in recent FreeBSD 7 ( grep _res_ext /usr/include/resolv.hit does not find anything). You can still find the code that uses it (try with Google Codesearch ).

Thanks to Alnitak, I noticed that he, apparently, is now _res._ext, not .res_ext. I wonder where these things are documented or announced ... I have no idea how portable it is _res._ext. I can find it on Debian and FreeBSD. It seems that there are several programs that use it.

+3
source share
2 answers

Stéphane - resolv.h sockaddr_in6, , O/S IPv6.

:

  • MacOS X 10.5.6 - BIND 9, res_setservers(), IPv6-, _res._ext.

  • CentOS 5.2 - _res._ext, man- resolv.conf IPv6, , , AAAA-, A gethostbyname().

EDIT - , CVS FreeBSD , FreeBSD 7.0 (. FREEBSD_7_0_0_RELEASE) res_setservers() Bind 9.

+2

Glibc:

res_setservers: no
__res_state._u._ext.nsaddrs
__res_state._u._ext.nsmap

MAXNS + 1 :

http://sourceware.org/ml/libc-hacker/2002-05/msg00035.html

BSD-Libc:

res_setservers: yes
__res_state._u._ext.__res_state_ext

, , , autoconf.

+1

All Articles