Will also need to do gethostinfo, but that's probably about it.
It was cleaner to do it at this level, rather than speaking in terms
of DNS packets.
Change-Id: I047cc459979ffb0170a3eb0d432a7e827fb71c26
In order not to conflict with the symbols defined in file
libc/netbsd/getaddrinfo.c, this patch makes the internal/helper
functions static.
Change-Id: I0f85599e0b4ce0a637d005ff1680e1805dec4380
Also add missing declarations to misc. functions.
Fix clearerr() implementation (previous was broken).
Handle feature test macros like _POSIX_C_SOURCE properly.
Change-Id: Icdc973a6b9d550a166fc2545f727ea837fe800c4
Typo assigned prefixlen1 twice instead of to the two different variables
for comparison and difference computation.
Change-Id: I6631b8269ca6aae264c8d7d414127b756838df96
The problem was that the 'defdname' field of res_state structure
was not properly initialized in __res_vinit(). This field is used
to store the default domain name, which is normally build from
calling gethostname() (see line 549 of res_init.c).
Unfortunately, in the typical Android case, gethostname() returns
an error (the hostname is configured) and a random stack string is
used later to build the DNS search list (see lines 556+ in res_init.c)
For the sake of illustration, let's say the search list is set to
a random value like 'xWLK'.
The end result is that when trying to result an unknown domain name
(e.g. 'www.ptn'), the query fails then the resolver tries to make a
new query with the DNS search list path(s) appended (e.g. 'www.ptn.xWLK').
The patch simply initializes 'defdname' to an empty string to avoid
this when the net.dns.search system property is not set.
Also contains whitespace/formatting fixes
Java changes required not to mess up the ordering from bionic will arrive in a
later commit.) In particular, this will give us more correct behavior when on a
6to4 network, in that IPv4 will usually be preferred over 6to4.
Most of RFC 3484 is implemented -- what's not is rule 3 (avoid deprecated
addresses), 4 (prefer home addresses) and 7 (prefer native transport) as they
require low-level access to the kernel routing table via netlink. (glibc also
started out this way, and these rules are primarily useful in pretty obscure
circumstances, so we should be fine for the time being.)
Also, rule 9 (use longest matching prefix) has been modified so it does not try
to sort IPv4 addresses; given current IPv4 addressing practice these rules are
pretty much meaningless. Finally, I've added support for Teredo as a separate
label, with slightly lower preference than 6to4. (Vista puts the preference
below IPv4 by default. glibc puts the preference together with non-tunneled
IPv6.)
Note that this patch removes support for the "sortlist" directive in
resolv.conf; I've never seen it in actual use, it's irrelevant for Android
(since we don't use resolv.conf anyway), and it's not clear how it would be
implemented alongside RFC 3484.
Merge commit '3773d35eb98e22b5edab4d82fb72bdf86ff80494'
* commit '3773d35eb98e22b5edab4d82fb72bdf86ff80494':
Make the DNS resolver accept domain names with an underscore.
More precisely, this accepts domain labels with an underscore in
the middle (i.e. not at the start or the end of the label). This
is needed to perform complex CNAME chain resolution in certain
VPN networks.
the issue is that the BSD implementation doesn't accept a call like:
getaddrinfo(SERVER_NAME, "9999", NULL, &res);
because if will reject a numerical string in the second parameter if no hints are explicitely
provided. This technically doesn't violate POSIX but might make porting Linux software a bit
difficult. For more details see:
http://groups.google.com/group/android-ndk/browse_thread/thread/818ab9c53f24c87
also comment debugging printf() calls which shouldn't be there.
The current solution is to read the net.dns.search property,
and expand the list during the resolve initialization. In the
future, we could implement search list per process.
Update: refine the code accordingly.
Update: remove unnecessary code.
Update: remove the unused variable.