diff options
author | ume <ume@FreeBSD.org> | 2006-03-21 16:11:11 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2006-03-21 16:11:11 +0000 |
commit | b09a8950a1301d97aef8e2975e34a3ba5bc451c3 (patch) | |
tree | e821dd9b60869dd20f6817bbe100b41cd574f673 /lib/libc/net/gethostbyht.c | |
parent | a2c94cecc033518580f28713e669d3f2a7783306 (diff) | |
download | FreeBSD-src-b09a8950a1301d97aef8e2975e34a3ba5bc451c3.zip FreeBSD-src-b09a8950a1301d97aef8e2975e34a3ba5bc451c3.tar.gz |
Update the resolver in libc to BIND9's one.
Since, res_sendsigned(3) and the friends use MD5 functions, it is
hard to include them without having MD5 functions in libc. So,
res_sendsigned(3) is not merged into libc.
Since, res_update(3) in BIND9 is not binary compatible with our
res_update(3), res_update(3) is leaved as is, except some
necessary modifications.
The res_update(3) and the friends are not essential part of the
resolver. They are not defined in resolv.h but defined in
res_update.h separately in BIND9. Further, they are not called from
our tree. So, I hide them from our resolv.h, but leave them only
for binary backward compatibility (perhaps, no one calls them).
Since, struct __res_state_ext is not exposed in BIND9, I hide it
from our resolv.h. And, global variable _res_ext is removed. It
breaks binary backward compatibility. But, since it is not used from
outside of our libc, I think it is safe.
Reviewed by: arch@ (no objection)
Diffstat (limited to 'lib/libc/net/gethostbyht.c')
-rw-r--r-- | lib/libc/net/gethostbyht.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/libc/net/gethostbyht.c b/lib/libc/net/gethostbyht.c index d1ef23b..462cd5c 100644 --- a/lib/libc/net/gethostbyht.c +++ b/lib/libc/net/gethostbyht.c @@ -99,12 +99,12 @@ gethostent_p(struct hostent *he, struct hostent_data *hed, int mapped) char hostbuf[BUFSIZ + 1]; if (!hed->hostf && !(hed->hostf = fopen(_PATH_HOSTS, "r"))) { - h_errno = NETDB_INTERNAL; + RES_SET_H_ERRNO(hed->res, NETDB_INTERNAL); return -1; } again: if (!(p = fgets(hostbuf, sizeof hostbuf, hed->hostf))) { - h_errno = HOST_NOT_FOUND; + RES_SET_H_ERRNO(hed->res, HOST_NOT_FOUND); return -1; } if (*p == '#') @@ -146,7 +146,7 @@ gethostent_p(struct hostent *he, struct hostent_data *hed, int mapped) *p++ = '\0'; len = strlen(cp) + 1; if (ep - bp < len) { - h_errno = NO_RECOVERY; + RES_SET_H_ERRNO(hed->res, NO_RECOVERY); return -1; } strlcpy(bp, cp, ep - bp); @@ -170,14 +170,19 @@ gethostent_p(struct hostent *he, struct hostent_data *hed, int mapped) cp = p; } *q = NULL; - h_errno = NETDB_SUCCESS; + RES_SET_H_ERRNO(hed->res, NETDB_SUCCESS); return 0; } int gethostent_r(struct hostent *he, struct hostent_data *hed) { - return gethostent_p(he, hed, _res.options & RES_USE_INET6); + hed->res = __res_state(); + if ((hed->res->options & RES_INIT) == 0 && res_ninit(hed->res) == -1) { + RES_SET_H_ERRNO(hed->res, NETDB_INTERNAL); + return -1; + } + return gethostent_p(he, hed, hed->res->options & RES_USE_INET6); } struct hostent * @@ -212,7 +217,7 @@ _ht_gethostbyname(void *rval, void *cb_data, va_list ap) if (he->h_addrtype != af) continue; if (he->h_addrtype == AF_INET && - _res.options & RES_USE_INET6) { + hed->res->options & RES_USE_INET6) { _map_v4v6_address(he->h_addr, he->h_addr); he->h_length = IN6ADDRSZ; he->h_addrtype = AF_INET6; @@ -248,7 +253,7 @@ _ht_gethostbyaddr(void *rval, void *cb_data, va_list ap) while ((error = gethostent_p(he, hed, 0)) == 0) if (he->h_addrtype == af && !bcmp(he->h_addr, addr, len)) { if (he->h_addrtype == AF_INET && - _res.options & RES_USE_INET6) { + hed->res->options & RES_USE_INET6) { _map_v4v6_address(he->h_addr, he->h_addr); he->h_length = IN6ADDRSZ; he->h_addrtype = AF_INET6; |