我编写或修改执行名称解析的程序并需要
过程控制良好。 所以我不使用getaddrinfo()
,我去
更深入并在 resolv.h
中使用 res_query()
/ res_send()
/ 等,已记录
在解析器(3)中。
尽管没有记录,但设置解析器的常用方法是
更新_res.nsaddr_list
。 但是这个数组,在 resolv.h 中定义,存储
struct sockaddr_in
,仅是 IPv4 地址。 (IPv6 地址
是 struct sockaddr_in6 ,独立于系列的系统将使用 struct sockaddr 。)
我正在寻找一种方法(最好是可移植的,至少在
各种 Unix)告诉 _res
我也想要 IPv6 地址。
显然,很久以前,FreeBSD 中有一个 _res_ext
与此
能力,但我在最近的 FreeBSD 7 中找不到它了(grep
_res_ext /usr/include/resolv.h
找不到任何内容)。 你仍然可以找到
使用它的代码(自己尝试使用 Google Codesearch )。
感谢 Alnitak,我注意到它现在显然是 _res._ext
而不是 .res_ext
。 我想知道这些事情在哪里记录或宣布...我不知道 _res._ext
的可移植性如何。 我可以在 Debian 和 FreeBSD 上找到它。 似乎很少有程序使用它。
I write or modify programs which perform name resolution and need a
good control of the process. So I do not use getaddrinfo()
, I go
deeper and use res_query()
/ res_send()
/ etc in resolv.h
, documented
in resolver(3).
Although not documented, the common way to set the resolver used is to
update _res.nsaddr_list
. But this array, defined in resolv.h, stores
struct sockaddr_in
, that is IPv4 addresses only. (IPv6 addresses
are struct sockaddr_in6
, a family-independant system would use struct sockaddr
.)
I'm looking for a way (preferrably portable, at least among the
various Unix) to tell _res
that I want also IPv6 addresses.
Apparently, a long time ago, there was in FreeBSD a _res_ext
with this
ability but I cannot find it anymore in a recent FreeBSD 7 (grep
_res_ext /usr/include/resolv.h
finds nothing). You can still find
code which uses it (try yourself with Google Codesearch).
Thanks to Alnitak, I noticed it is apparently now _res._ext
and not .res_ext
. I wonder where these sort of things are documented or announced... I have no idea how portable _res._ext
is. I can find it on Debian and FreeBSD. It seems there are few programs which use it.
发布评论
评论(2)
Stéphane - 如果您的
resolv.h
不包含对sockaddr_in6
的任何支持,那么这表明在您的特定操作系统上,解析器本身不支持 IPv6 传输。我在这里检查了我的一些系统:
MacOS X 10.5.6 - 支持 BIND 9 库,该库具有
res_setservers()
函数,可以采用 IPv6地址,无_res._ext
扩展名。CentOS 5.2 - 具有
_res._ext
扩展名,尽管resolv.conf
的手册页中没有提及 IPv6,只是有一个设置告诉解析器在查找gethostbyname()
的 A 记录之前返回 AAAA 记录。编辑 - 另外,FreeBSD 的 CVS 存储库 建议FreeBSD 7.0(请参阅标记
FREEBSD_7_0_0_RELEASE
)也支持 Bind 9 中的res_setservers()
。Stéphane - if your
resolv.h
doesn't include any support forsockaddr_in6
then that suggests that on your particular O/S the resolver does not itself support IPv6 transport.I've checked some of my systems here:
MacOS X 10.5.6 - supports the BIND 9 library, which has a
res_setservers()
function which can take IPv6 addresses, no_res._ext
extension.CentOS 5.2 - has the
_res._ext
extension, although there's no mention of IPv6 in the man page forresolv.conf
except that there's a setting to tell the resolver to return AAAA records before looking for A records forgethostbyname()
.EDIT - also, the CVS repository for FreeBSD suggests that FreeBSD 7.0 (see tag
FREEBSD_7_0_0_RELEASE
) does also supportres_setservers()
from Bind 9.glibc:
根据以下内容将后者设置为 MAXNS+1:
http:// sourceware.org/ml/libc-hacker/2002-05/msg00035.html
BSD-libc:
对我来说似乎很混乱,您可能需要 autoconf。
glibc:
set the latter to MAXNS+1 according to:
http://sourceware.org/ml/libc-hacker/2002-05/msg00035.html
BSD-libc:
Seems messy to me and you'll probably need autoconf.