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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…