Fix an issue where the _res symbol is undeclared due to another symbol with

the same name somewhere else( I think). At least it works now.  Renamed
to _resolve_configuration (probably will never clash with anything else ever)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3565 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Niels Sascha Reedijk 2003-06-18 19:03:37 +00:00
parent 3ffe393cd6
commit 26e367740a
9 changed files with 226 additions and 226 deletions

View File

@ -527,10 +527,10 @@ explore_fqdn(pai, hostname, servname, res)
if (get_portmatch(pai, servname) != 0)
return 0;
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1)
strncpy(lookups, "f", sizeof lookups);
else {
memcpy(lookups, _res.lookups, sizeof lookups);
memcpy(lookups, _resolver_configuration.lookups, sizeof lookups);
if (lookups[0] == '\0')
strncpy(lookups, "bf", sizeof lookups);
}
@ -1542,7 +1542,7 @@ res_queryN(name, target)
rcode = NOERROR;
ancount = 0;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1) {
h_errno = NETDB_INTERNAL;
return (-1);
}
@ -1561,17 +1561,17 @@ res_queryN(name, target)
answer = t->answer;
anslen = t->anslen;
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf(";; res_query(%s, %d, %d)\n", name, class, type);
#endif
n = res_mkquery(QUERY, name, class, type, NULL, 0, NULL,
buf, sizeof(buf));
if (n > 0 && (_res.options & RES_USE_EDNS0) != 0)
if (n > 0 && (_resolver_configuration.options & RES_USE_EDNS0) != 0)
n = res_opt(n, buf, sizeof(buf), anslen);
if (n <= 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf(";; res_query: mkquery failed\n");
#endif
h_errno = NO_RECOVERY;
@ -1581,7 +1581,7 @@ res_queryN(name, target)
#if 0
if (n < 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf(";; res_query: send error\n");
#endif
h_errno = TRY_AGAIN;
@ -1592,7 +1592,7 @@ res_queryN(name, target)
if (n < 0 || hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
rcode = hp->rcode; /* record most recent error */
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf(";; rcode = %d, ancount=%d\n", hp->rcode,
ntohs(hp->ancount));
#endif
@ -1644,7 +1644,7 @@ res_searchN(name, target)
int trailing_dot, ret, saved_herrno;
int got_nodata = 0, got_servfail = 0, tried_as_is = 0;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1) {
h_errno = NETDB_INTERNAL;
return (-1);
}
@ -1669,7 +1669,7 @@ res_searchN(name, target)
* 'as is'. The threshold can be set with the "ndots" option.
*/
saved_herrno = -1;
if (dots >= _res.ndots) {
if (dots >= _resolver_configuration.ndots) {
ret = res_querydomainN(name, NULL, target);
if (ret > 0)
return (ret);
@ -1683,11 +1683,11 @@ res_searchN(name, target)
* - there is at least one dot, there is no trailing dot,
* and RES_DNSRCH is set.
*/
if ((!dots && (_res.options & RES_DEFNAMES)) ||
(dots && !trailing_dot && (_res.options & RES_DNSRCH))) {
if ((!dots && (_resolver_configuration.options & RES_DEFNAMES)) ||
(dots && !trailing_dot && (_resolver_configuration.options & RES_DNSRCH))) {
int done = 0;
for (domain = (const char * const *)_res.dnsrch;
for (domain = (const char * const *)_resolver_configuration.dnsrch;
*domain && !done;
domain++) {
@ -1735,7 +1735,7 @@ res_searchN(name, target)
* if we got here for some reason other than DNSRCH,
* we only wanted one iteration of the loop, so stop.
*/
if (!(_res.options & RES_DNSRCH))
if (!(_resolver_configuration.options & RES_DNSRCH))
done++;
}
}
@ -1781,12 +1781,12 @@ res_querydomainN(name, domain, target)
const char *longname = nbuf;
size_t n, d;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1) {
h_errno = NETDB_INTERNAL;
return (-1);
}
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf(";; res_querydomain(%s, %s)\n",
name, domain?domain:"<Nil>");
#endif

View File

@ -350,7 +350,7 @@ static struct hostent *getanswer(const querybuf *answer,
break;
#else
host.h_name = bp;
if (_res.options & RES_USE_INET6) {
if (_resolver_configuration.options & RES_USE_INET6) {
n = strlen(bp) + 1; /* for the \0 */
bp += n;
buflen -= n;
@ -386,7 +386,7 @@ static struct hostent *getanswer(const querybuf *answer,
if (bp + n >= &hostbuf[sizeof hostbuf]) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf("size (%d) too big\n", n);
#endif
had_error++;
@ -395,7 +395,7 @@ static struct hostent *getanswer(const querybuf *answer,
if (hap >= &h_addr_ptrs[MAXADDRS-1]) {
if (!toobig++)
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf("Too many addresses (%d)\n", MAXADDRS);
#endif
cp += n;
@ -419,7 +419,7 @@ static struct hostent *getanswer(const querybuf *answer,
* in its return structures - should give it the "best"
* address in that case, not some random one
*/
if (_res.nsort && haveanswer > 1 && qtype == T_A)
if (_resolver_configuration.nsort && haveanswer > 1 && qtype == T_A)
addrsort(h_addr_ptrs, haveanswer);
# endif /*RESOLVSORT*/
if (!host.h_name) {
@ -432,7 +432,7 @@ static struct hostent *getanswer(const querybuf *answer,
buflen -= n;
}
#if INET6
if (_res.options & RES_USE_INET6)
if (_resolver_configuration.options & RES_USE_INET6)
map_v4v6_hostent(&host, &bp, &buflen);
#endif
h_errno = NETDB_SUCCESS;
@ -507,10 +507,10 @@ struct hostent * gethostbyname(const char *name)
gethostnamadr = create_sem(1, "gethostnamadr");
acquire_sem_etc(gethostnamadr,1, B_CAN_INTERRUPT, 0);
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1)
hp = _gethtbyname2(name, AF_INET);
#if INET6
else if (_res.options & RES_USE_INET6) {
else if (_resolver_configuration.options & RES_USE_INET6) {
hp = gethostbyname2(name, AF_INET6);
if (hp == NULL)
hp = gethostbyname2(name, AF_INET);
@ -533,7 +533,7 @@ struct hostent *gethostbyname2(const char *name, int af)
register struct hostent *hp;
char lookups[MAXDNSLUS];
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1)
return (_gethtbyname2(name, af));
switch (af) {
@ -592,7 +592,7 @@ struct hostent *gethostbyname2(const char *name, int af)
h_addr_ptrs[1] = NULL;
host.h_addr_list = h_addr_ptrs;
#if INET6
if (_res.options & RES_USE_INET6)
if (_resolver_configuration.options & RES_USE_INET6)
map_v4v6_hostent(&host, &bp, &len);
#endif
h_errno = NETDB_SUCCESS;
@ -632,7 +632,7 @@ struct hostent *gethostbyname2(const char *name, int af)
break;
}
memcpy(lookups, _res.lookups, sizeof lookups);
memcpy(lookups, _resolver_configuration.lookups, sizeof lookups);
if (lookups[0] == '\0')
strncpy(lookups, "bf", sizeof lookups);
@ -650,7 +650,7 @@ struct hostent *gethostbyname2(const char *name, int af)
if ((n = res_search(name, C_IN, type, buf.buf,
sizeof(buf))) < 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf("res_search failed\n");
#endif
break;
@ -679,7 +679,7 @@ struct hostent *gethostbyaddr(const char *addr, int len, int af)
struct hostent *res;
acquire_sem(gethostnamadr);
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1) {
//printf("gethostbyaddr: calling _gethtbyaddr\n");
res = _gethtbyaddr(addr, len, af);
release_sem_etc(gethostnamadr,1, B_CAN_INTERRUPT);
@ -736,7 +736,7 @@ struct hostent *gethostbyaddr(const char *addr, int len, int af)
break;
}
memcpy(lookups, _res.lookups, sizeof lookups);
memcpy(lookups, _resolver_configuration.lookups, sizeof lookups);
if (lookups[0] == '\0')
strncpy(lookups, "bf", sizeof lookups);
@ -756,7 +756,7 @@ struct hostent *gethostbyaddr(const char *addr, int len, int af)
sizeof buf.buf);
if (n < 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf("res_query failed\n");
#endif
break;
@ -768,7 +768,7 @@ struct hostent *gethostbyaddr(const char *addr, int len, int af)
memcpy(host_addr, addr, len);
h_addr_ptrs[0] = (char *)host_addr;
h_addr_ptrs[1] = NULL;
if (af == AF_INET && (_res.options & RES_USE_INET6)) {
if (af == AF_INET && (_resolver_configuration.options & RES_USE_INET6)) {
#ifdef INET6
map_v4v6_address((char*)host_addr,
(char*)host_addr);
@ -844,7 +844,7 @@ struct hostent *_gethtent()
af = AF_INET6;
len = IN6ADDRSZ;
} else if (inet_pton(AF_INET, p, host_addr) > 0) {
if (_res.options & RES_USE_INET6) {
if (_resolver_configuration.options & RES_USE_INET6) {
#ifdef INET6
map_v4v6_address((char*)host_addr, (char*)host_addr);
af = AF_INET6;
@ -884,7 +884,7 @@ struct hostent *_gethtent()
*cp++ = '\0';
}
*q = NULL;
if (_res.options & RES_USE_INET6) {
if (_resolver_configuration.options & RES_USE_INET6) {
#ifdef INET6
char *bp = hostbuf;
int buflen = sizeof hostbuf;
@ -901,7 +901,7 @@ struct hostent *_gethtbyname(const char *name)
extern struct hostent *_gethtbyname2();
struct hostent *hp;
if (_res.options & RES_USE_INET6) {
if (_resolver_configuration.options & RES_USE_INET6) {
hp = _gethtbyname2(name, AF_INET6);
if (hp)
return (hp);
@ -1149,9 +1149,9 @@ addrsort(ap, num)
p = ap;
for (i = 0; i < num; i++, p++) {
for (j = 0 ; (unsigned)j < _res.nsort; j++)
if (_res.sort_list[j].addr.s_addr ==
(((struct in_addr *)(*p))->s_addr & _res.sort_list[j].mask))
for (j = 0 ; (unsigned)j < _resolver_configuration.nsort; j++)
if (_resolver_configuration.sort_list[j].addr.s_addr ==
(((struct in_addr *)(*p))->s_addr & _resolver_configuration.sort_list[j].mask))
break;
aval[i] = j;
if (needsort == 0 && i > 0 && j < aval[i-1])

View File

@ -246,10 +246,10 @@ getnetbyaddr(net, net_type)
char lookups[MAXDNSLUS];
int i;
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1)
return(_getnetbyaddr(net, net_type));
memcpy(lookups, _res.lookups, sizeof lookups);
memcpy(lookups, _resolver_configuration.lookups, sizeof lookups);
if (lookups[0] == '\0')
strncpy(lookups, "bf", sizeof lookups);
@ -313,7 +313,7 @@ getnetbyaddr(net, net_type)
sizeof(buf));
if (anslen < 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf("res_query failed\n");
#endif
break;
@ -351,10 +351,10 @@ getnetbyname(net)
char lookups[MAXDNSLUS];
int i;
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1)
return (_getnetbyname(net));
memcpy(lookups, _res.lookups, sizeof lookups);
memcpy(lookups, _resolver_configuration.lookups, sizeof lookups);
if (lookups[0] == '\0')
strncpy(lookups, "bf", sizeof lookups);
@ -371,7 +371,7 @@ getnetbyname(net)
sizeof(buf));
if (anslen < 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf("res_query failed\n");
#endif
break;

View File

@ -187,13 +187,13 @@ do_rrset(msg, len, cp, cnt, pflag, file, hs)
/*
* Print answer records.
*/
sflag = (_res.pfcode & pflag);
sflag = (_resolver_configuration.pfcode & pflag);
if ((n = ntohs(cnt))) {
if ((!_res.pfcode) ||
((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
if ((!_resolver_configuration.pfcode) ||
((sflag) && (_resolver_configuration.pfcode & RES_PRF_HEAD1)))
fprintf(file, "%s", hs);
while (--n >= 0) {
if ((!_res.pfcode) || sflag) {
if ((!_resolver_configuration.pfcode) || sflag) {
cp = p_rr(cp, msg, file);
} else {
unsigned int dlen;
@ -208,8 +208,8 @@ do_rrset(msg, len, cp, cnt, pflag, file, hs)
if ((cp - msg) > len)
return (NULL);
}
if ((!_res.pfcode) ||
((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
if ((!_resolver_configuration.pfcode) ||
((sflag) && (_resolver_configuration.pfcode & RES_PRF_HEAD1)))
putc('\n', file);
}
return (cp);
@ -227,7 +227,7 @@ __p_query(msg)
* This is intended to be primarily a debugging routine.
*/
void
__fp_resstat(statp, file)
__fp_resolver_configurationstat(statp, file)
struct __res_state *statp;
FILE *file;
{
@ -235,7 +235,7 @@ __fp_resstat(statp, file)
fprintf(file, ";; res options:");
if (!statp)
statp = &_res;
statp = &_resolver_configuration;
for (mask = 1; mask != 0; mask <<= 1)
if (statp->options & mask)
fprintf(file, " %s", p_option(mask));
@ -256,7 +256,7 @@ __fp_nquery(msg, len, file)
register const HEADER *hp;
register int n;
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1)
return;
#define TruncTest(x) if (x > endMark) goto trunc
@ -268,16 +268,16 @@ __fp_nquery(msg, len, file)
hp = (HEADER *)msg;
cp = msg + HFIXEDSZ;
endMark = msg + len;
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX) || hp->rcode) {
if ((!_resolver_configuration.pfcode) || (_resolver_configuration.pfcode & RES_PRF_HEADX) || hp->rcode) {
fprintf(file, ";; ->>HEADER<<- opcode: %s, status: %s, id: %d",
_res_opcodes[hp->opcode],
_res_resultcodes[hp->rcode],
ntohs(hp->id));
putc('\n', file);
}
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX))
if ((!_resolver_configuration.pfcode) || (_resolver_configuration.pfcode & RES_PRF_HEADX))
putc(';', file);
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD2)) {
if ((!_resolver_configuration.pfcode) || (_resolver_configuration.pfcode & RES_PRF_HEAD2)) {
fprintf(file, "; flags:");
if (hp->qr)
fprintf(file, " qr");
@ -296,13 +296,13 @@ __fp_nquery(msg, len, file)
if (hp->cd)
fprintf(file, " cd");
}
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD1)) {
if ((!_resolver_configuration.pfcode) || (_resolver_configuration.pfcode & RES_PRF_HEAD1)) {
fprintf(file, "; Ques: %d", ntohs(hp->qdcount));
fprintf(file, ", Ans: %d", ntohs(hp->ancount));
fprintf(file, ", Auth: %d", ntohs(hp->nscount));
fprintf(file, ", Addit: %d", ntohs(hp->arcount));
}
if ((!_res.pfcode) || (_res.pfcode &
if ((!_resolver_configuration.pfcode) || (_resolver_configuration.pfcode &
(RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1))) {
putc('\n',file);
}
@ -310,13 +310,13 @@ __fp_nquery(msg, len, file)
* Print question records.
*/
if ((n = ntohs(hp->qdcount))) {
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
if ((!_resolver_configuration.pfcode) || (_resolver_configuration.pfcode & RES_PRF_QUES))
fprintf(file, ";; QUESTIONS:\n");
while (--n >= 0) {
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
if ((!_resolver_configuration.pfcode) || (_resolver_configuration.pfcode & RES_PRF_QUES))
fprintf(file, ";;\t");
TruncTest(cp);
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
if ((!_resolver_configuration.pfcode) || (_resolver_configuration.pfcode & RES_PRF_QUES))
cp = p_cdnname(cp, msg, len, file);
else {
int n;
@ -330,16 +330,16 @@ __fp_nquery(msg, len, file)
}
ErrorTest(cp);
TruncTest(cp);
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
if ((!_resolver_configuration.pfcode) || (_resolver_configuration.pfcode & RES_PRF_QUES))
fprintf(file, ", type = %s",
__p_type(_getshort((u_char*)cp)));
cp += INT16SZ;
TruncTest(cp);
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
if ((!_resolver_configuration.pfcode) || (_resolver_configuration.pfcode & RES_PRF_QUES))
fprintf(file, ", class = %s\n",
__p_class(_getshort((u_char*)cp)));
cp += INT16SZ;
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
if ((!_resolver_configuration.pfcode) || (_resolver_configuration.pfcode & RES_PRF_QUES))
putc('\n', file);
}
}
@ -468,7 +468,7 @@ __p_rr(cp, msg, file)
char rrname[MAXDNAME]; /* The fqdn of this RR */
char base64_key[MAX_KEY_BASE64];
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1) {
h_errno = NETDB_INTERNAL;
return (NULL);
}
@ -486,9 +486,9 @@ __p_rr(cp, msg, file)
dlen = _getshort((u_char*)cp);
cp += INT16SZ;
cp1 = cp;
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_TTLID))
if ((!_resolver_configuration.pfcode) || (_resolver_configuration.pfcode & RES_PRF_TTLID))
fprintf(file, "\t%lu", (u_long)tmpttl);
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_CLASS))
if ((!_resolver_configuration.pfcode) || (_resolver_configuration.pfcode & RES_PRF_CLASS))
fprintf(file, "\t%s", __p_class(class));
fprintf(file, "\t%s", __p_type(type));
/*

View File

@ -105,7 +105,7 @@ static uint32 net_mask (struct in_addr);
* Resolver state default settings.
*/
struct __res_state _res
struct __res_state _resolver_configuration
# if defined(__BIND_RES_TEXT)
= { RES_TIMEOUT, } /* Motorola, et al. */
# endif
@ -173,33 +173,33 @@ res_init()
* set in RES_DEFAULT). Our solution is to declare such applications
* "broken". They could fool us by setting RES_INIT but none do (yet).
*/
if (!_res.retrans)
_res.retrans = RES_TIMEOUT;
if (!_res.retry)
_res.retry = 4;
if (!(_res.options & RES_INIT))
_res.options = RES_DEFAULT;
if (!_resolver_configuration.retrans)
_resolver_configuration.retrans = RES_TIMEOUT;
if (!_resolver_configuration.retry)
_resolver_configuration.retry = 4;
if (!(_resolver_configuration.options & RES_INIT))
_resolver_configuration.options = RES_DEFAULT;
#ifdef USELOOPBACK
_res.nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
_resolver_configuration.nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
#else
_res.nsaddr.sin_addr.s_addr = INADDR_ANY;
_resolver_configuration.nsaddr.sin_addr.s_addr = INADDR_ANY;
#endif
_res.nsaddr.sin_family = AF_INET;
_res.nsaddr.sin_port = htons(NAMESERVER_PORT);
_res.nsaddr.sin_len = sizeof(struct sockaddr_in);
_resolver_configuration.nsaddr.sin_family = AF_INET;
_resolver_configuration.nsaddr.sin_port = htons(NAMESERVER_PORT);
_resolver_configuration.nsaddr.sin_len = sizeof(struct sockaddr_in);
#ifdef INET6
if (sizeof(_res_ext.nsaddr) >= _res.nsaddr.sin_len)
memcpy(&_res_ext.nsaddr, &_res.nsaddr, _res.nsaddr.sin_len);
if (sizeof(_resolver_configuration_ext.nsaddr) >= _resolver_configuration.nsaddr.sin_len)
memcpy(&_resolver_configuration_ext.nsaddr, &_resolver_configuration.nsaddr, _resolver_configuration.nsaddr.sin_len);
#endif
_res.nscount = 1;
_res.ndots = 1;
_res.pfcode = 0;
strncpy(_res.lookups, "f", sizeof _res.lookups);
_resolver_configuration.nscount = 1;
_resolver_configuration.ndots = 1;
_resolver_configuration.pfcode = 0;
strncpy(_resolver_configuration.lookups, "f", sizeof _resolver_configuration.lookups);
/* Allow user to override the local domain definition */
if ((cp = getenv("LOCALDOMAIN")) != NULL) {
strncpy(_res.defdname, cp, sizeof(_res.defdname));
strncpy(_resolver_configuration.defdname, cp, sizeof(_resolver_configuration.defdname));
haveenv++;
/*
@ -209,10 +209,10 @@ res_init()
* one that they want to use as an individual (even more
* important now that the rfc1535 stuff restricts searches)
*/
cp = _res.defdname;
pp = _res.dnsrch;
cp = _resolver_configuration.defdname;
pp = _resolver_configuration.dnsrch;
*pp++ = cp;
for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) {
for (n = 0; *cp && pp < _resolver_configuration.dnsrch + MAXDNSRCH; cp++) {
if (*cp == '\n') /* silly backwards compat */
break;
else if (*cp == ' ' || *cp == '\t') {
@ -237,7 +237,7 @@ res_init()
line[sizeof(name) - 1] == '\t'))
if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
strncpy(_res.lookups, "bf", sizeof _res.lookups);
strncpy(_resolver_configuration.lookups, "bf", sizeof _resolver_configuration.lookups);
/* read the config file */
buf[0] = '\0';
@ -263,8 +263,8 @@ res_init()
cp++;
if ((*cp == '\0') || (*cp == '\n'))
continue;
strncpy(_res.defdname, cp, sizeof(_res.defdname));
if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL)
strncpy(_resolver_configuration.defdname, cp, sizeof(_resolver_configuration.defdname));
if ((cp = strpbrk(_resolver_configuration.defdname, " \t\n")) != NULL)
*cp = '\0';
havesearch = 0;
continue;
@ -272,7 +272,7 @@ res_init()
/* lookup types */
if (MATCH(buf, "lookup")) {
char *sp = NULL;
memset(_res.lookups, 0, sizeof _res.lookups);
memset(_resolver_configuration.lookups, 0, sizeof _resolver_configuration.lookups);
cp = buf + sizeof("lookup") - 1;
for (n = 0;; cp++) {
if (n == MAXDNSLUS)
@ -280,14 +280,14 @@ res_init()
if ((*cp == '\0') || (*cp == '\n')) {
if (sp) {
if (*sp=='y' || *sp=='b' || *sp=='f')
_res.lookups[n++] = *sp;
_resolver_configuration.lookups[n++] = *sp;
sp = NULL;
}
break;
} else if ((*cp == ' ') || (*cp == '\t') || (*cp == ',')) {
if (sp) {
if (*sp=='y' || *sp=='b' || *sp=='f')
_res.lookups[n++] = *sp;
_resolver_configuration.lookups[n++] = *sp;
sp = NULL;
}
} else if (sp == NULL)
@ -304,17 +304,17 @@ res_init()
cp++;
if ((*cp == '\0') || (*cp == '\n'))
continue;
strncpy(_res.defdname, cp, sizeof(_res.defdname));
if ((cp = strchr(_res.defdname, '\n')) != NULL)
strncpy(_resolver_configuration.defdname, cp, sizeof(_resolver_configuration.defdname));
if ((cp = strchr(_resolver_configuration.defdname, '\n')) != NULL)
*cp = '\0';
/*
* Set search list to be blank-separated strings
* on rest of line.
*/
cp = _res.defdname;
pp = _res.dnsrch;
cp = _resolver_configuration.defdname;
pp = _resolver_configuration.dnsrch;
*pp++ = cp;
for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) {
for (n = 0; *cp && pp < _resolver_configuration.dnsrch + MAXDNSRCH; cp++) {
if (*cp == ' ' || *cp == '\t') {
*cp = 0;
n = 1;
@ -359,19 +359,19 @@ res_init()
res = NULL;
if (getaddrinfo(cp, pbuf, &hints, &res) == 0 &&
res->ai_next == NULL) {
if (res->ai_addrlen <= sizeof(_res_ext.nsaddr_list[nserv])) {
memcpy(&_res_ext.nsaddr_list[nserv], res->ai_addr,
if (res->ai_addrlen <= sizeof(_resolver_configuration_ext.nsaddr_list[nserv])) {
memcpy(&_resolver_configuration_ext.nsaddr_list[nserv], res->ai_addr,
res->ai_addrlen);
} else {
memset(&_res_ext.nsaddr_list[nserv], 0,
sizeof(_res_ext.nsaddr_list[nserv]));
memset(&_resolver_configuration_ext.nsaddr_list[nserv], 0,
sizeof(_resolver_configuration_ext.nsaddr_list[nserv]));
}
if (res->ai_addrlen <= sizeof(_res.nsaddr_list[nserv])) {
memcpy(&_res.nsaddr_list[nserv], res->ai_addr,
if (res->ai_addrlen <= sizeof(_resolver_configuration.nsaddr_list[nserv])) {
memcpy(&_resolver_configuration.nsaddr_list[nserv], res->ai_addr,
res->ai_addrlen);
} else {
memset(&_res.nsaddr_list[nserv], 0,
sizeof(_res.nsaddr_list[nserv]));
memset(&_resolver_configuration.nsaddr_list[nserv], 0,
sizeof(_resolver_configuration.nsaddr_list[nserv]));
}
nserv++;
}
@ -379,10 +379,10 @@ res_init()
freeaddrinfo(res);
#else /* INET6 */
if ((*cp != '\0') && (*cp != '\n') && inet_aton(cp, &a)) {
_res.nsaddr_list[nserv].sin_addr = a;
_res.nsaddr_list[nserv].sin_family = AF_INET;
_res.nsaddr_list[nserv].sin_port = htons(NAMESERVER_PORT);
_res.nsaddr_list[nserv].sin_len = sizeof(struct sockaddr_in);
_resolver_configuration.nsaddr_list[nserv].sin_addr = a;
_resolver_configuration.nsaddr_list[nserv].sin_family = AF_INET;
_resolver_configuration.nsaddr_list[nserv].sin_port = htons(NAMESERVER_PORT);
_resolver_configuration.nsaddr_list[nserv].sin_len = sizeof(struct sockaddr_in);
nserv++;
}
#endif /* INET6 */
@ -410,7 +410,7 @@ res_init()
n = *cp;
*cp = 0;
if (inet_aton(net, &a)) {
_res.sort_list[nsort].addr = a;
_resolver_configuration.sort_list[nsort].addr = a;
if (ISSORTMASK(n)) {
*cp++ = n;
net = cp;
@ -420,29 +420,29 @@ res_init()
n = *cp;
*cp = 0;
if (inet_aton(net, &a)) {
_res.sort_list[nsort].mask = a.s_addr;
_resolver_configuration.sort_list[nsort].mask = a.s_addr;
} else {
_res.sort_list[nsort].mask =
net_mask(_res.sort_list[nsort].addr);
_resolver_configuration.sort_list[nsort].mask =
net_mask(_resolver_configuration.sort_list[nsort].addr);
}
} else {
_res.sort_list[nsort].mask =
net_mask(_res.sort_list[nsort].addr);
_resolver_configuration.sort_list[nsort].mask =
net_mask(_resolver_configuration.sort_list[nsort].addr);
}
#ifdef INET6
_res_ext.sort_list[nsort].af = AF_INET;
_res_ext.sort_list[nsort].addr.ina =
_res.sort_list[nsort].addr;
_res_ext.sort_list[nsort].mask.ina.s_addr =
_res.sort_list[nsort].mask;
_resolver_configuration_ext.sort_list[nsort].af = AF_INET;
_resolver_configuration_ext.sort_list[nsort].addr.ina =
_resolver_configuration.sort_list[nsort].addr;
_resolver_configuration_ext.sort_list[nsort].mask.ina.s_addr =
_resolver_configuration.sort_list[nsort].mask;
#endif /* INET6 */
nsort++;
}
#ifdef INET6
else if (inet_pton(AF_INET6, net, &a6) == 1) {
_res_ext.sort_list[nsort].af = AF_INET6;
_res_ext.sort_list[nsort].addr.in6a = a6;
u = (u_char *)&_res_ext.sort_list[nsort].mask.in6a;
_resolver_configuration_ext.sort_list[nsort].af = AF_INET6;
_resolver_configuration_ext.sort_list[nsort].addr.in6a = a6;
u = (u_char *)&_resolver_configuration_ext.sort_list[nsort].mask.in6a;
*cp++ = n;
net = cp;
while (*cp && *cp != ';' &&
@ -492,33 +492,33 @@ res_init()
}
}
if (nserv > 1)
_res.nscount = nserv;
_resolver_configuration.nscount = nserv;
#ifdef RESOLVSORT
_res.nsort = nsort;
_resolver_configuration.nsort = nsort;
#endif
(void) fclose(fp);
}
if (_res.defdname[0] == 0 &&
gethostname(buf, sizeof(_res.defdname) - 1) == 0 &&
if (_resolver_configuration.defdname[0] == 0 &&
gethostname(buf, sizeof(_resolver_configuration.defdname) - 1) == 0 &&
(cp = strchr(buf, '.')) != NULL)
{
strncpy(_res.defdname, cp + 1,
sizeof(_res.defdname));
strncpy(_resolver_configuration.defdname, cp + 1,
sizeof(_resolver_configuration.defdname));
}
/* find components of local domain that might be searched */
if (havesearch == 0) {
pp = _res.dnsrch;
*pp++ = _res.defdname;
pp = _resolver_configuration.dnsrch;
*pp++ = _resolver_configuration.defdname;
*pp = NULL;
#ifndef RFC1535
dots = 0;
for (cp = _res.defdname; *cp; cp++)
for (cp = _resolver_configuration.defdname; *cp; cp++)
dots += (*cp == '.');
cp = _res.defdname;
while (pp < _res.dnsrch + MAXDFLSRCH) {
cp = _resolver_configuration.defdname;
while (pp < _resolver_configuration.dnsrch + MAXDFLSRCH) {
if (dots < LOCALDOMAINPARTS)
break;
cp = strchr(cp, '.') + 1; /* we know there is one */
@ -527,9 +527,9 @@ res_init()
}
*pp = NULL;
#ifdef DEBUG
if (_res.options & RES_DEBUG) {
if (_resolver_configuration.options & RES_DEBUG) {
printf(";; res_init()... default dnsrch list:\n");
for (pp = _res.dnsrch; *pp; pp++)
for (pp = _resolver_configuration.dnsrch; *pp; pp++)
printf(";;\t%s\n", *pp);
printf(";;\t..END..\n");
}
@ -538,11 +538,11 @@ res_init()
}
// if (issetugid())
// _res.options |= RES_NOALIASES;
// _resolver_configuration.options |= RES_NOALIASES;
// else
if ((cp = getenv("RES_OPTIONS")) != NULL)
res_setoptions(cp, "env");
_res.options |= RES_INIT;
_resolver_configuration.options |= RES_INIT;
return (0);
}
@ -556,7 +556,7 @@ res_setoptions(options, source)
long l;
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf(";; res_setoptions(\"%s\", \"%s\")...\n",
options, source);
#endif
@ -571,31 +571,31 @@ res_setoptions(options, source)
if (l >= 0 && endp != p &&
(*endp = '\0' || isspace(*endp))) {
if (l <= RES_MAXNDOTS)
_res.ndots = l;
_resolver_configuration.ndots = l;
else
_res.ndots = RES_MAXNDOTS;
_resolver_configuration.ndots = RES_MAXNDOTS;
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf(";;\tndots=%d\n", _res.ndots);
if (_resolver_configuration.options & RES_DEBUG)
printf(";;\tndots=%d\n", _resolver_configuration.ndots);
#endif
}
} else if (!strncmp(cp, "debug", sizeof("debug") - 1)) {
#ifdef DEBUG
if (!(_res.options & RES_DEBUG)) {
if (!(_resolver_configuration.options & RES_DEBUG)) {
printf(";; res_setoptions(\"%s\", \"%s\")..\n",
options, source);
_res.options |= RES_DEBUG;
_resolver_configuration.options |= RES_DEBUG;
}
printf(";;\tdebug\n");
#endif
} else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) {
_res.options |= RES_USE_INET6;
_resolver_configuration.options |= RES_USE_INET6;
} else if (!strncmp(cp, "insecure1", sizeof("insecure1") - 1)) {
_res.options |= RES_INSECURE1;
_resolver_configuration.options |= RES_INSECURE1;
} else if (!strncmp(cp, "insecure2", sizeof("insecure2") - 1)) {
_res.options |= RES_INSECURE2;
_resolver_configuration.options |= RES_INSECURE2;
} else if (!strncmp(cp, "edns0", sizeof("edns0") - 1)) {
_res.options |= RES_USE_EDNS0;
_resolver_configuration.options |= RES_USE_EDNS0;
} else {
/* XXX - print a warning here? */
}

View File

@ -85,12 +85,12 @@ res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
register int n;
u_char *dnptrs[20], **dpp, **lastdnptr;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1) {
h_errno = NETDB_INTERNAL;
return (-1);
}
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf(";; res_mkquery(%d, %s, %d, %d)\n",
op, dname, class, type);
#endif
@ -107,10 +107,10 @@ res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
memset(buf, 0, HFIXEDSZ);
hp = (HEADER *) buf;
_res.id = res_randomid();
hp->id = htons(_res.id);
_resolver_configuration.id = res_randomid();
hp->id = htons(_resolver_configuration.id);
hp->opcode = op;
hp->rd = (_res.options & RES_RECURSE) != 0;
hp->rd = (_resolver_configuration.options & RES_RECURSE) != 0;
hp->rcode = NOERROR;
cp = buf + HFIXEDSZ;
buflen -= HFIXEDSZ;
@ -212,9 +212,9 @@ res_opt(n0, buf, buflen, anslen)
cp += INT16SZ;
*cp++ = NOERROR; /* extended RCODE */
*cp++ = 0; /* EDNS version */
if (_res.options & RES_USE_DNSSEC) {
if (_resolver_configuration.options & RES_USE_DNSSEC) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf(";; res_opt()... ENDS0 DNSSEC OK\n");
#endif /* DEBUG */
__putshort(DNS_MESSAGEEXTFLAG_DO, cp); /* EDNS Z field */

View File

@ -101,25 +101,25 @@ res_query(name, class, type, answer, anslen)
hp->rcode = NOERROR; /* default */
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1) {
h_errno = NETDB_INTERNAL;
return (-1);
}
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf(";; res_query(%s, %d, %d)\n", name, class, type);
#endif
n = res_mkquery(QUERY, name, class, type, NULL, 0, NULL,
buf, sizeof(buf));
if (n > 0 && ((_res.options & RES_USE_EDNS0) ||
(_res.options & RES_USE_DNSSEC))) {
if (n > 0 && ((_resolver_configuration.options & RES_USE_EDNS0) ||
(_resolver_configuration.options & RES_USE_DNSSEC))) {
n = res_opt(n, buf, sizeof(buf), anslen);
}
if (n <= 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf(";; res_query: mkquery failed\n");
#endif
h_errno = NO_RECOVERY;
@ -128,7 +128,7 @@ res_query(name, class, type, answer, anslen)
n = res_send(buf, n, answer, anslen);
if (n < 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf(";; res_query: send error\n");
#endif
h_errno = TRY_AGAIN;
@ -137,7 +137,7 @@ res_query(name, class, type, answer, anslen)
if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf(";; rcode = %d, ancount=%d\n", hp->rcode,
ntohs(hp->ancount));
#endif
@ -182,7 +182,7 @@ res_search(name, class, type, answer, anslen)
int trailing_dot, ret, saved_herrno;
int got_nodata = 0, got_servfail = 0, tried_as_is = 0;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1) {
h_errno = NETDB_INTERNAL;
return (-1);
}
@ -206,7 +206,7 @@ res_search(name, class, type, answer, anslen)
* 'as is'. The threshold can be set with the "ndots" option.
*/
saved_herrno = -1;
if (dots >= _res.ndots) {
if (dots >= _resolver_configuration.ndots) {
ret = res_querydomain(name, NULL, class, type, answer, anslen);
if (ret > 0)
return (ret);
@ -220,11 +220,11 @@ res_search(name, class, type, answer, anslen)
* - there is at least one dot, there is no trailing dot,
* and RES_DNSRCH is set.
*/
if ((!dots && (_res.options & RES_DEFNAMES)) ||
(dots && !trailing_dot && (_res.options & RES_DNSRCH))) {
if ((!dots && (_resolver_configuration.options & RES_DEFNAMES)) ||
(dots && !trailing_dot && (_resolver_configuration.options & RES_DNSRCH))) {
int done = 0;
for (domain = (const char * const *)_res.dnsrch;
for (domain = (const char * const *)_resolver_configuration.dnsrch;
*domain && !done;
domain++) {
@ -273,7 +273,7 @@ res_search(name, class, type, answer, anslen)
/* if we got here for some reason other than DNSRCH,
* we only wanted one iteration of the loop, so stop.
*/
if (!(_res.options & RES_DNSRCH))
if (!(_resolver_configuration.options & RES_DNSRCH))
done++;
}
}
@ -319,12 +319,12 @@ res_querydomain(name, domain, class, type, answer, anslen)
const char *longname = nbuf;
int n;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1) {
h_errno = NETDB_INTERNAL;
return (-1);
}
#ifdef DEBUG
if (_res.options & RES_DEBUG)
if (_resolver_configuration.options & RES_DEBUG)
printf(";; res_querydomain(%s, %s, %d, %d)\n",
name, domain?domain:"<Nil>", class, type);
#endif
@ -356,7 +356,7 @@ hostalias(name)
static char abuf[MAXDNAME];
size_t len;
if (_res.options & RES_NOALIASES)
if (_resolver_configuration.options & RES_NOALIASES)
return (NULL);
file = getenv("HOSTALIASES");
// if (issetugid() != 0 || file == NULL || (fp = fopen(file, "r")) == NULL)

View File

@ -114,7 +114,7 @@ static void Perror (FILE *, char *, int);
{
int save = errno;
if (_res.options & RES_DEBUG) {
if (_resolver_configuration.options & RES_DEBUG) {
if (getnameinfo(address, address->sa_len, abuf, sizeof(abuf),
pbuf, sizeof(pbuf),
NI_NUMERICHOST|NI_NUMERICSERV|NI_WITHSCOPEID) != 0) {
@ -134,7 +134,7 @@ static void Perror (FILE *, char *, int);
{
int save = errno;
if (_res.options & RES_DEBUG) {
if (_resolver_configuration.options & RES_DEBUG) {
fprintf(file, "res_send: %s: %s\n",
string, strerror(error));
}
@ -172,29 +172,29 @@ get_nsaddr(n)
size_t n;
{
if (!_res.nsaddr_list[n].sin_family) {
if (!_resolver_configuration.nsaddr_list[n].sin_family) {
/*
* - _res_ext.nsaddr_list[n] holds an address that is larger
* - _resolver_configuration_ext.nsaddr_list[n] holds an address that is larger
* than struct sockaddr, and
* - user code did not update _res.nsaddr_list[n].
* - user code did not update _resolver_configuration.nsaddr_list[n].
*/
return (struct sockaddr *)&_res_ext.nsaddr_list[n];
return (struct sockaddr *)&_resolver_configuration_ext.nsaddr_list[n];
} else {
/*
* - user code updated _res.nsaddr_list[n], or
* - _res.nsaddr_list[n] has the same content as
* _res_ext.nsaddr_list[n].
* - user code updated _resolver_configuration.nsaddr_list[n], or
* - _resolver_configuration.nsaddr_list[n] has the same content as
* _resolver_configuration_ext.nsaddr_list[n].
*/
return (struct sockaddr *)&_res.nsaddr_list[n];
return (struct sockaddr *)&_resolver_configuration.nsaddr_list[n];
}
}
#else
#define get_nsaddr(n) ((struct sockaddr *)&_res.nsaddr_list[(n)])
#define get_nsaddr(n) ((struct sockaddr *)&_resolver_configuration.nsaddr_list[(n)])
#endif
/* int
* res_isourserver(ina)
* looks up "ina" in _res.ns_addr_list[]
* looks up "ina" in _resolver_configuration.ns_addr_list[]
* returns:
* 0 : not found
* >0 : found
@ -221,7 +221,7 @@ res_isourserver(inp)
switch (inp->sin_family) {
#ifdef INET6
case AF_INET6:
for (ns = 0; ns < _res.nscount; ns++) {
for (ns = 0; ns < _resolver_configuration.nscount; ns++) {
srv6 = (struct sockaddr_in6 *)get_nsaddr(ns);
if (srv6->sin6_family == in6p->sin6_family &&
srv6->sin6_port == in6p->sin6_port &&
@ -236,7 +236,7 @@ res_isourserver(inp)
break;
#endif
case AF_INET:
for (ns = 0; ns < _res.nscount; ns++) {
for (ns = 0; ns < _resolver_configuration.nscount; ns++) {
srv = (struct sockaddr_in *)get_nsaddr(ns);
if (srv->sin_family == inp->sin_family &&
srv->sin_port == inp->sin_port &&
@ -338,13 +338,13 @@ res_send(buf, buflen, ans, anssiz)
register int n;
u_int badns; /* XXX NSMAX can't exceed #/bits in this var */
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1) {
/* errno should have been set by res_init() in this case. */
return (-1);
}
DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_QUERY),
DprintQ((_resolver_configuration.options & RES_DEBUG) || (_resolver_configuration.pfcode & RES_PRF_QUERY),
(stdout, ";; res_send()\n"), buf, buflen);
v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ;
v_circuit = (_resolver_configuration.options & RES_USEVC) || buflen > PACKETSZ;
gotsomewhere = 0;
connreset = 0;
terrno = ETIMEDOUT;
@ -353,8 +353,8 @@ res_send(buf, buflen, ans, anssiz)
/*
* Send request, RETRY times, or until successful
*/
for (try = 0; try < _res.retry; try++) {
for (ns = 0; ns < _res.nscount; ns++) {
for (try = 0; try < _resolver_configuration.retry; try++) {
for (ns = 0; ns < _resolver_configuration.nscount; ns++) {
struct sockaddr *nsap = get_nsaddr(ns);
uint32 salen;
@ -406,7 +406,7 @@ res_send(buf, buflen, ans, anssiz)
} while (!done);
}
Dprint((_res.options & RES_DEBUG) &&
Dprint((_resolver_configuration.options & RES_DEBUG) &&
getnameinfo(nsap, salen, abuf, sizeof(abuf),
NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID) == 0,
(stdout, ";; Querying server (# %d) address = %s\n",
@ -422,7 +422,7 @@ res_send(buf, buflen, ans, anssiz)
* Use virtual circuit;
* at most one attempt per server.
*/
try = _res.retry;
try = _resolver_configuration.retry;
truncated = 0;
if ((s < 0) || (!vc) || (af != nsap->sa_family)) {
if (s >= 0)
@ -501,7 +501,7 @@ read_len:
}
resplen = _getshort(ans);
if (resplen > anssiz) {
Dprint(_res.options & RES_DEBUG,
Dprint(_resolver_configuration.options & RES_DEBUG,
(stdout, ";; response truncated\n")
);
truncated = 1;
@ -547,8 +547,8 @@ read_len:
* wait for the correct one.
*/
if (hp->id != anhp->id) {
DprintQ((_res.options & RES_DEBUG) ||
(_res.pfcode & RES_PRF_REPLY),
DprintQ((_resolver_configuration.options & RES_DEBUG) ||
(_resolver_configuration.pfcode & RES_PRF_REPLY),
(stdout, ";; old answer (unexpected):\n"),
ans, (resplen>anssiz)?anssiz:resplen);
goto read_len;
@ -606,8 +606,8 @@ read_len:
* as we wish to receive answers from the first
* server to respond.
*/
if (!(_res.options & RES_INSECURE1) &&
(_res.nscount == 1 || (try == 0 && ns == 0))) {
if (!(_resolver_configuration.options & RES_INSECURE1) &&
(_resolver_configuration.nscount == 1 || (try == 0 && ns == 0))) {
/*
* Connect only if we are sure we won't
* receive a response from another server.
@ -654,7 +654,7 @@ read_len:
goto bad_dg_sock;
(void) dup2(s1, s);
(void) close(s1);
Dprint(_res.options & RES_DEBUG,
Dprint(_resolver_configuration.options & RES_DEBUG,
(stdout, ";; new DG socket\n"))
#endif
#ifdef IPV6_MINMTU
@ -680,9 +680,9 @@ read_len:
/*
* Wait for reply
*/
timeout.tv_sec = (_res.retrans << try);
timeout.tv_sec = (_resolver_configuration.retrans << try);
if (try > 0)
timeout.tv_sec /= _res.nscount;
timeout.tv_sec /= _resolver_configuration.nscount;
if ((long) timeout.tv_sec <= 0)
timeout.tv_sec = 1;
timeout.tv_usec = 0;
@ -708,7 +708,7 @@ read_len:
/*
* timeout
*/
Dprint(_res.options & RES_DEBUG,
Dprint(_resolver_configuration.options & RES_DEBUG,
(stdout, ";; timeout\n"));
gotsomewhere = 1;
res_close();
@ -731,8 +731,8 @@ read_len:
* XXX - potential security hazard could
* be detected here.
*/
DprintQ((_res.options & RES_DEBUG) ||
(_res.pfcode & RES_PRF_REPLY),
DprintQ((_resolver_configuration.options & RES_DEBUG) ||
(_resolver_configuration.pfcode & RES_PRF_REPLY),
(stdout, ";; old answer:\n"),
ans, (resplen>anssiz)?anssiz:resplen);
goto wait;
@ -744,22 +744,22 @@ read_len:
* Can other people remove the comment and see if this works for them?
*/
#if 0//CHECK_SRVR_ADDR
if (!(_res.options & RES_INSECURE1) &&
if (!(_resolver_configuration.options & RES_INSECURE1) &&
!res_isourserver((struct sockaddr_in *)&from)) {
/*
* response from wrong server? ignore it.
* XXX - potential security hazard could
* be detected here.
*/
DprintQ((_res.options & RES_DEBUG) ||
(_res.pfcode & RES_PRF_REPLY),
DprintQ((_resolver_configuration.options & RES_DEBUG) ||
(_resolver_configuration.pfcode & RES_PRF_REPLY),
(stdout, ";; not our server:\n"),
ans, (resplen>anssiz)?anssiz:resplen);
goto wait;
}
#endif
if (!(_res.options & RES_INSECURE2) &&
if (!(_resolver_configuration.options & RES_INSECURE2) &&
!res_queriesmatch(buf, buf + buflen,
ans, ans + anssiz)) {
/*
@ -767,8 +767,8 @@ read_len:
* XXX - potential security hazard could
* be detected here.
*/
DprintQ((_res.options & RES_DEBUG) ||
(_res.pfcode & RES_PRF_REPLY),
DprintQ((_resolver_configuration.options & RES_DEBUG) ||
(_resolver_configuration.pfcode & RES_PRF_REPLY),
(stdout, ";; wrong query name:\n"),
ans, (resplen>anssiz)?anssiz:resplen);
goto wait;
@ -777,33 +777,33 @@ read_len:
if (anhp->rcode == SERVFAIL ||
anhp->rcode == NOTIMP ||
anhp->rcode == REFUSED) {
DprintQ(_res.options & RES_DEBUG,
DprintQ(_resolver_configuration.options & RES_DEBUG,
(stdout, "server rejected query:\n"),
ans, (resplen>anssiz)?anssiz:resplen);
badns |= (1 << ns);
res_close();
/* don't retry if called from dig */
if (!_res.pfcode)
if (!_resolver_configuration.pfcode)
goto next_ns;
}
if (!(_res.options & RES_IGNTC) && anhp->tc) {
if (!(_resolver_configuration.options & RES_IGNTC) && anhp->tc) {
/*
* get rest of answer;
* use TCP with same server.
*/
Dprint(_res.options & RES_DEBUG,
Dprint(_resolver_configuration.options & RES_DEBUG,
(stdout, ";; truncated answer\n"));
v_circuit = 1;
res_close();
goto same_ns;
}
} /*if vc/dg*/
Dprint((_res.options & RES_DEBUG) ||
((_res.pfcode & RES_PRF_REPLY) &&
(_res.pfcode & RES_PRF_HEAD1)),
Dprint((_resolver_configuration.options & RES_DEBUG) ||
((_resolver_configuration.pfcode & RES_PRF_REPLY) &&
(_resolver_configuration.pfcode & RES_PRF_HEAD1)),
(stdout, ";; got answer:\n"));
DprintQ((_res.options & RES_DEBUG) ||
(_res.pfcode & RES_PRF_REPLY),
DprintQ((_resolver_configuration.options & RES_DEBUG) ||
(_resolver_configuration.pfcode & RES_PRF_REPLY),
(stdout, "%s", ""),
ans, (resplen>anssiz)?anssiz:resplen);
/*
@ -814,8 +814,8 @@ read_len:
* or if we haven't been asked to keep a socket open,
* close the socket.
*/
if ((v_circuit && (!(_res.options & RES_USEVC) || ns != 0)) ||
!(_res.options & RES_STAYOPEN)) {
if ((v_circuit && (!(_resolver_configuration.options & RES_USEVC) || ns != 0)) ||
!(_resolver_configuration.options & RES_STAYOPEN)) {
res_close();
}
if (Rhook) {

View File

@ -42,15 +42,15 @@ sethostent(stayopen)
int stayopen;
{
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
if ((_resolver_configuration.options & RES_INIT) == 0 && res_init() == -1)
return;
if (stayopen)
_res.options |= RES_STAYOPEN | RES_USEVC;
_resolver_configuration.options |= RES_STAYOPEN | RES_USEVC;
}
void
endhostent()
{
_res.options &= ~(RES_STAYOPEN | RES_USEVC);
_resolver_configuration.options &= ~(RES_STAYOPEN | RES_USEVC);
res_close();
}