Merge the 4.9.3-rel code into the res_* parts. The gethostXXXbyYYY

parts are not quite so simple..
This commit is contained in:
Peter Wemm 1996-01-07 09:15:02 +00:00
parent 0c83bb499c
commit ab83cd2d54
7 changed files with 159 additions and 181 deletions

View File

@ -9,8 +9,8 @@ SRCS+= gethostbydns.c gethostbyht.c gethostbynis.c gethostnamadr.c \
getservbyport.c getservent.c herror.c inet_addr.c inet_lnaof.c \
inet_makeaddr.c inet_netof.c inet_network.c inet_ntoa.c \
iso_addr.c linkaddr.c ns_addr.c ns_ntoa.c rcmd.c recv.c res_comp.c \
res_debug.c res_init.c res_mkquery.c res_query.c res_send.c \
send.c ether_addr.c
res_data.c res_debug.c res_init.c res_mkquery.c res_query.c \
res_send.c send.c ether_addr.c
# machine-dependent net sources
.include "${.CURDIR}/${MACHINE}/net/Makefile.inc"

View File

@ -53,7 +53,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "$Id: res_comp.c,v 1.2 1994/09/25 02:12:32 pst Exp $";
static char rcsid[] = "$Id: res_comp.c,v 1.3 1995/05/30 05:40:54 rgrimes Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -95,7 +95,7 @@ dn_expand(msg, eomorig, comp_dn, exp_dn, length)
/*
* fetch next label in domain name
*/
while ((n = *cp++)) {
while (n = *cp++) {
/*
* Check for indirection
*/
@ -110,14 +110,14 @@ dn_expand(msg, eomorig, comp_dn, exp_dn, length)
return (-1);
checked += n + 1;
while (--n >= 0) {
if ((c = *cp++) == '.') {
if (((c = *cp++) == '.') || (c == '\\')) {
if (dn + n + 2 >= eom)
return (-1);
*dn++ = '\\';
}
*dn++ = c;
if (cp >= eomorig) /* out of range */
return(-1);
return (-1);
}
break;
@ -126,7 +126,7 @@ dn_expand(msg, eomorig, comp_dn, exp_dn, length)
len = cp - comp_dn + 1;
cp = msg + (((n & 0x3f) << 8) | (*cp & 0xff));
if (cp < msg || cp >= eomorig) /* out of range */
return(-1);
return (-1);
checked += 2;
/*
* Check for loops in the compressed name;
@ -262,12 +262,12 @@ __dn_skipname(comp_dn, eom)
cp++;
break;
default: /* illegal type */
return -1;
return (-1);
}
break;
}
if (cp > eom)
return -1;
return (-1);
return (cp - comp_dn);
}
@ -298,7 +298,7 @@ dn_find(exp_dn, msg, dnptrs, lastdnptr)
for (cpp = dnptrs; cpp < lastdnptr; cpp++) {
dn = exp_dn;
sp = cp = *cpp;
while ((n = *cp++)) {
while (n = *cp++) {
/*
* check for indirection
*/
@ -318,11 +318,12 @@ dn_find(exp_dn, msg, dnptrs, lastdnptr)
continue;
goto next;
default: /* illegal type */
return (-1);
case INDIR_MASK: /* indirection */
cp = msg + (((n & 0x3f) << 8) | *cp);
break;
default: /* illegal type */
return (-1);
}
}
if (*dn == '\0')
@ -333,11 +334,7 @@ dn_find(exp_dn, msg, dnptrs, lastdnptr)
}
/*
* Routines to insert/extract short/long's. Must account for byte
* order and non-alignment problems. This code at least has the
* advantage of being portable.
*
* used by sendmail.
* Routines to insert/extract short/long's.
*/
u_int16_t

View File

@ -53,7 +53,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "$Id: res_debug.c,v 1.4 1995/08/20 20:02:48 peter Exp $";
static char rcsid[] = "$Id: res_debug.c,v 1.5 1995/08/21 09:15:34 bde Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -63,49 +63,14 @@ static char rcsid[] = "$Id: res_debug.c,v 1.4 1995/08/20 20:02:48 peter Exp $";
#include <arpa/nameser.h>
#include <stdio.h>
#include <netdb.h>
#include <resolv.h>
#include <string.h>
#include <netdb.h>
#include "res_config.h"
const char *_res_opcodes[] = {
"QUERY",
"IQUERY",
"CQUERYM",
"CQUERYU", /* experimental */
"NOTIFY", /* experimental */
"5",
"6",
"7",
"8",
"UPDATEA",
"UPDATED",
"UPDATEDA",
"UPDATEM",
"UPDATEMA",
"ZONEINIT",
"ZONEREF",
};
const char *_res_resultcodes[] = {
"NOERROR",
"FORMERR",
"SERVFAIL",
"NXDOMAIN",
"NOTIMP",
"REFUSED",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"NOCHANGE",
};
extern const char *_res_opcodes[];
extern const char *_res_resultcodes[];
/* XXX: we should use getservbyport() instead. */
static const char *
@ -203,13 +168,13 @@ do_rrset(msg, len, cp, cnt, pflag, file, hs)
* Print answer records.
*/
sflag = (_res.pfcode & pflag);
if ((n = ntohs(cnt))) {
if (n = ntohs(cnt)) {
if ((!_res.pfcode) ||
((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
fprintf(file, hs);
while (--n >= 0) {
if ((!_res.pfcode) || sflag) {
cp = p_rr(cp, msg, file);
cp = p_rr(cp, msg, file);
} else {
unsigned int dlen;
cp += __dn_skipname(cp, cp + MAXCDNAME);
@ -290,9 +255,10 @@ __fp_nquery(msg, len, file)
ntohs(hp->id));
putc('\n', file);
}
putc(';', file);
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX))
putc(';', file);
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD2)) {
fprintf(file,"; flags:");
fprintf(file, "; flags:");
if (hp->qr)
fprintf(file, " qr");
if (hp->aa)
@ -310,7 +276,7 @@ __fp_nquery(msg, len, file)
fprintf(file, ", Auth: %d", ntohs(hp->nscount));
fprintf(file, ", Addit: %d", ntohs(hp->arcount));
}
if ((!_res.pfcode) || (_res.pfcode &
if ((!_res.pfcode) || (_res.pfcode &
(RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1))) {
putc('\n',file);
}
@ -319,11 +285,23 @@ __fp_nquery(msg, len, file)
*/
if (n = ntohs(hp->qdcount)) {
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
fprintf(file,";; QUESTIONS:\n");
fprintf(file, ";; QUESTIONS:\n");
while (--n >= 0) {
fprintf(file,";;\t");
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
fprintf(file, ";;\t");
TruncTest(cp);
cp = p_cdnname(cp, msg, len, file);
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
cp = p_cdnname(cp, msg, len, file);
else {
int n;
char name[MAXDNAME];
if ((n = dn_expand(msg, msg+len, cp, name,
sizeof name)) < 0)
cp = NULL;
else
cp += n;
}
ErrorTest(cp);
TruncTest(cp);
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
@ -335,7 +313,8 @@ __fp_nquery(msg, len, file)
fprintf(file, ", class = %s\n",
__p_class(_getshort((u_char*)cp)));
cp += INT16SZ;
putc('\n', file);
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
putc('\n', file);
}
}
/*
@ -471,7 +450,7 @@ __p_rr(cp, msg, file)
case C_HS:
bcopy(cp, (char *)&inaddr, INADDRSZ);
if (dlen == 4) {
fprintf(file,"\t%s", inet_ntoa(inaddr));
fprintf(file, "\t%s", inet_ntoa(inaddr));
cp += dlen;
} else if (dlen == 7) {
char *address;
@ -507,11 +486,11 @@ __p_rr(cp, msg, file)
case T_ISDN:
cp2 = cp + dlen;
if (n = *cp++) {
fprintf(file,"\t%.*s", n, cp);
fprintf(file, "\t%.*s", n, cp);
cp += n;
}
if ((cp < cp2) && (n = *cp++)) {
fprintf(file,"\t%.*s", n, cp);
fprintf(file, "\t%.*s", n, cp);
cp += n;
} else if (type == T_HINFO)
fprintf(file, "\n;; *** Warning *** OS-type missing");
@ -544,7 +523,7 @@ __p_rr(cp, msg, file)
case T_MX:
case T_AFSDB:
case T_RT:
fprintf(file,"\t%d ", _getshort((u_char*)cp));
fprintf(file, "\t%d ", _getshort((u_char*)cp));
cp += INT16SZ;
if ((cp = p_fqname(cp, msg, file)) == NULL)
return (NULL);
@ -560,7 +539,7 @@ __p_rr(cp, msg, file)
return (NULL);
break;
case T_TXT:
case T_TXT:
case T_X25:
(void) fputs("\t\"", file);
cp2 = cp1 + dlen;
@ -575,7 +554,7 @@ __p_rr(cp, msg, file)
}
}
putc('"', file);
break;
break;
case T_NSAP:
isoa.isoa_len = dlen;
@ -605,7 +584,7 @@ __p_rr(cp, msg, file)
case T_UID:
case T_GID:
if (dlen == 4) {
fprintf(file,"\t%u", _getlong((u_char*)cp));
fprintf(file, "\t%u", _getlong((u_char*)cp));
cp += INT32SZ;
}
break;
@ -624,7 +603,7 @@ __p_rr(cp, msg, file)
while (cp < cp1 + dlen) {
c = *cp++;
do {
if (c & 0200) {
if (c & 0200) {
if (lcnt == 0) {
fputs("\n\t\t\t", file);
lcnt = 5;
@ -633,7 +612,7 @@ __p_rr(cp, msg, file)
putc(' ', file);
lcnt--;
}
c <<= 1;
c <<= 1;
} while (++n & 07);
}
putc(')', file);
@ -657,7 +636,7 @@ __p_rr(cp, msg, file)
#endif /* ALLOW_T_UNSPEC */
default:
fprintf(file,"\t?%d?", type);
fprintf(file, "\t?%d?", type);
cp += dlen;
}
#if 0
@ -666,7 +645,7 @@ __p_rr(cp, msg, file)
putc('\n', file);
#endif
if (cp - cp1 != dlen) {
fprintf(file,";; packet size error (found %d, dlen was %d)\n",
fprintf(file, ";; packet size error (found %d, dlen was %d)\n",
cp - cp1, dlen);
cp = NULL;
}

View File

@ -53,7 +53,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
static char rcsid[] = "$Id: res_init.c,v 1.5 1995/08/20 20:02:52 peter Exp $";
static char rcsid[] = "$Id: res_init.c,v 1.6 1995/08/21 09:15:36 bde Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -96,7 +96,7 @@ struct __res_state _res;
* since it was noted that INADDR_ANY actually meant ``the first interface
* you "ifconfig"'d at boot time'' and if this was a SLIP or PPP interface,
* it had to be "up" in order for you to reach your own name server. It
* was later decided that since the recommended practice is to always
* was later decided that since the recommended practice is to always
* install local static routes through 127.0.0.1 for all your network
* interfaces, that we could solve this problem without a code change.
*
@ -223,8 +223,7 @@ res_init()
cp++;
if ((*cp == '\0') || (*cp == '\n'))
continue;
(void)strncpy(_res.defdname, cp,
sizeof(_res.defdname) - 1);
strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL)
*cp = '\0';
havesearch = 0;
@ -239,8 +238,7 @@ res_init()
cp++;
if ((*cp == '\0') || (*cp == '\n'))
continue;
(void)strncpy(_res.defdname, cp,
sizeof(_res.defdname) - 1);
strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
if ((cp = strchr(_res.defdname, '\n')) != NULL)
*cp = '\0';
/*
@ -269,7 +267,7 @@ res_init()
}
/* read nameservers to query */
if (MATCH(buf, "nameserver") && nserv < MAXNS) {
struct in_addr a;
struct in_addr a;
cp = buf + sizeof("nameserver") - 1;
while (*cp == ' ' || *cp == '\t')
@ -295,7 +293,7 @@ res_init()
break;
net = cp;
while (*cp && !ISSORTMASK(*cp) && *cp != ';' &&
isascii(*cp) && !isspace(*cp))
isascii(*cp) && !isspace(*cp))
cp++;
n = *cp;
*cp = 0;
@ -312,11 +310,11 @@ res_init()
if (inet_aton(net, &a)) {
_res.sort_list[nsort].mask = a.s_addr;
} else {
_res.sort_list[nsort].mask =
_res.sort_list[nsort].mask =
net_mask(_res.sort_list[nsort].addr);
}
} else {
_res.sort_list[nsort].mask =
_res.sort_list[nsort].mask =
net_mask(_res.sort_list[nsort].addr);
}
nsort++;
@ -331,7 +329,7 @@ res_init()
continue;
}
}
if (nserv > 1)
if (nserv > 1)
_res.nscount = nserv;
#ifdef RESOLVSORT
_res.nsort = nsort;
@ -351,7 +349,7 @@ res_init()
#ifndef RFC1535
dots = 0;
for (cp = _res.defdname; *cp; cp++)
for (cp = _res.defdname; *cp; cp++)
dots += (*cp == '.');
cp = _res.defdname;
@ -371,7 +369,7 @@ res_init()
printf(";;\t..END..\n");
}
#endif /* DEBUG */
#endif /*!RFC1535*/
#endif /* !RFC1535 */
}
if ((cp = getenv("RES_OPTIONS")) != NULL)
@ -397,7 +395,7 @@ res_setoptions(options, source)
while (*cp == ' ' || *cp == '\t')
cp++;
/* search for and process individual options */
if (!strncmp(cp, "ndots:", sizeof("ndots:")-1)) {
if (!strncmp(cp, "ndots:", sizeof("ndots:") - 1)) {
i = atoi(cp + sizeof("ndots:") - 1);
if (i <= RES_MAXNDOTS)
_res.ndots = i;
@ -407,7 +405,7 @@ res_setoptions(options, source)
if (_res.options & RES_DEBUG)
printf(";;\tndots=%d\n", _res.ndots);
#endif
} else if (!strncmp(cp, "debug", sizeof("debug")-1)) {
} else if (!strncmp(cp, "debug", sizeof("debug") - 1)) {
#ifdef DEBUG
if (!(_res.options & RES_DEBUG)) {
printf(";; res_setoptions(\"%s\", \"%s\")..\n",
@ -431,12 +429,12 @@ static u_int32_t
net_mask(in) /* XXX - should really use system's version of this */
struct in_addr in;
{
register u_int32_t i = ntohl(in.s_addr);
register u_int32_t i = ntohl(in.s_addr);
if (IN_CLASSA(i))
return (htonl(IN_CLASSA_NET));
else if (IN_CLASSB(i))
return (htonl(IN_CLASSB_NET));
if (IN_CLASSA(i))
return (htonl(IN_CLASSA_NET));
else if (IN_CLASSB(i))
return (htonl(IN_CLASSB_NET));
return (htonl(IN_CLASSC_NET));
}
#endif

View File

@ -53,7 +53,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "$Id: res_mkquery.c,v 1.5 1995/08/20 20:02:56 peter Exp $";
static char rcsid[] = "$Id: res_mkquery.c,v 1.6 1995/08/21 09:15:37 bde Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -61,9 +61,9 @@ static char rcsid[] = "$Id: res_mkquery.c,v 1.5 1995/08/20 20:02:56 peter Exp $"
#include <arpa/nameser.h>
#include <stdio.h>
#include <netdb.h>
#include <resolv.h>
#include <string.h>
#include <netdb.h>
#include "res_config.h"
@ -103,7 +103,7 @@ res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
* Initialize header fields.
*/
if ((buf == NULL) || (buflen < HFIXEDSZ))
return(-1);
return (-1);
bzero(buf, HFIXEDSZ);
hp = (HEADER *) buf;
hp->id = htons(++_res.id);
@ -123,7 +123,7 @@ res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
case QUERY: /*FALLTHROUGH*/
case NS_NOTIFY_OP:
if ((buflen -= QFIXEDSZ) < 0)
return(-1);
return (-1);
if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
return (-1);
cp += n;
@ -197,13 +197,13 @@ res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
return (-1);
cp += n;
__putshort(type, cp);
cp += INT16SZ;
__putshort(class, cp);
cp += INT16SZ;
cp += INT16SZ;
__putshort(class, cp);
cp += INT16SZ;
__putlong(0, cp);
cp += INT32SZ;
__putshort(datalen, cp);
cp += INT16SZ;
cp += INT16SZ;
if (datalen) {
bcopy(data, cp, datalen);
cp += datalen;
@ -220,13 +220,13 @@ res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
return (-1);
cp += n;
__putshort(newrr->r_type, cp);
cp += INT16SZ;
__putshort(newrr->r_class, cp);
cp += INT16SZ;
cp += INT16SZ;
__putshort(newrr->r_class, cp);
cp += INT16SZ;
__putlong(0, cp);
cp += INT32SZ;
__putshort(newrr->r_size, cp);
cp += INT16SZ;
cp += INT16SZ;
if (newrr->r_size) {
bcopy(newrr->r_data, cp, newrr->r_size);
cp += newrr->r_size;

View File

@ -53,7 +53,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "$Id: res_query.c,v 1.5 1995/08/20 20:03:00 peter Exp $";
static char rcsid[] = "$Id: res_query.c,v 1.6 1995/08/21 09:15:39 bde Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -139,21 +139,21 @@ res_query(name, class, type, answer, anslen)
ntohs(hp->ancount));
#endif
switch (hp->rcode) {
case NXDOMAIN:
h_errno = HOST_NOT_FOUND;
break;
case SERVFAIL:
h_errno = TRY_AGAIN;
break;
case NOERROR:
h_errno = NO_DATA;
break;
case FORMERR:
case NOTIMP:
case REFUSED:
default:
h_errno = NO_RECOVERY;
break;
case NXDOMAIN:
h_errno = HOST_NOT_FOUND;
break;
case SERVFAIL:
h_errno = TRY_AGAIN;
break;
case NOERROR:
h_errno = NO_DATA;
break;
case FORMERR:
case NOTIMP:
case REFUSED:
default:
h_errno = NO_RECOVERY;
break;
}
return (-1);
}
@ -186,7 +186,7 @@ res_search(name, class, type, answer, anslen)
errno = 0;
h_errno = HOST_NOT_FOUND; /* default, if we never query */
dots = 0;
for (cp = name; *cp; cp++)
for (cp = name; *cp; cp++)
dots += (*cp == '.');
trailing_dot = 0;
if (cp > name && *--cp == '.')

View File

@ -53,7 +53,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "$Id: res_send.c,v 1.5 1995/08/20 20:03:06 peter Exp $";
static char rcsid[] = "$Id: res_send.c,v 1.6 1995/08/21 09:15:40 bde Exp $";
#endif /* LIBC_SCCS and not lint */
/* change this to "0"
@ -102,38 +102,38 @@ static int vc = 0; /* is the socket a virtual ciruit? */
fprintf args;\
__fp_nquery(query, size, stdout);\
} else {}
static void
Aerror(file, string, error, address)
FILE *file;
char *string;
int error;
struct sockaddr_in address;
{
int save = errno;
static void
Aerror(file, string, error, address)
FILE *file;
char *string;
int error;
struct sockaddr_in address;
{
int save = errno;
if (_res.options & RES_DEBUG) {
if (_res.options & RES_DEBUG) {
fprintf(file, "res_send: %s ([%s].%u): %s\n",
string,
inet_ntoa(address.sin_addr),
string,
inet_ntoa(address.sin_addr),
ntohs(address.sin_port),
strerror(error));
strerror(error));
}
errno = save;
}
errno = save;
}
static void
Perror(file, string, error)
FILE *file;
char *string;
int error;
{
int save = errno;
static void
Perror(file, string, error)
FILE *file;
char *string;
int error;
{
int save = errno;
if (_res.options & RES_DEBUG) {
fprintf(file, "res_send: %s: %s\n",
string, strerror(error));
if (_res.options & RES_DEBUG) {
fprintf(file, "res_send: %s: %s\n",
string, strerror(error));
}
errno = save;
}
errno = save;
}
#endif
static res_send_qhook Qhook = NULL;
@ -214,7 +214,7 @@ res_nameinquery(name, type, class, buf, eom)
if (n < 0)
return (-1);
cp += n;
ttype = _getshort(cp); cp += INT16SZ;
ttype = _getshort(cp); cp += INT16SZ;
tclass = _getshort(cp); cp += INT16SZ;
if (ttype == type &&
tclass == class &&
@ -263,20 +263,20 @@ res_queriesmatch(buf1, eom1, buf2, eom2)
int
res_send(buf, buflen, ans, anssiz)
const u_char *buf;
int buflen;
u_char *ans;
int anssiz;
const u_char *buf;
int buflen;
u_char *ans;
int anssiz;
{
HEADER *hp = (HEADER *) buf;
HEADER *anhp = (HEADER *) ans;
HEADER *hp = (HEADER *) buf;
HEADER *anhp = (HEADER *) ans;
int gotsomewhere, connreset, terrno, try, v_circuit, resplen, ns;
register int n;
u_int badns; /* XXX NSMAX can't exceed #/bits in this var */
register int n;
u_int badns; /* XXX NSMAX can't exceed #/bits in this var */
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
/* errno should have been set by res_init() in this case. */
return (-1);
return (-1);
}
DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_QUERY),
(stdout, ";; res_send()\n"), buf, buflen);
@ -293,7 +293,7 @@ res_send(buf, buflen, ans, anssiz)
for (ns = 0; ns < _res.nscount; ns++) {
struct sockaddr_in *nsap = &_res.nsaddr_list[ns];
same_ns:
if (badns & (1<<ns)) {
if (badns & (1 << ns)) {
_res_close();
goto next_ns;
}
@ -330,13 +330,13 @@ res_send(buf, buflen, ans, anssiz)
Dprint(_res.options & RES_DEBUG,
(stdout, ";; Querying server (# %d) address = %s\n",
ns+1, inet_ntoa(nsap->sin_addr)));
ns + 1, inet_ntoa(nsap->sin_addr)));
if (v_circuit) {
int truncated;
struct iovec iov[2];
u_short len;
u_char *cp;
int truncated;
struct iovec iov[2];
u_short len;
u_char *cp;
/*
* Use virtual circuit;
@ -360,7 +360,7 @@ res_send(buf, buflen, ans, anssiz)
terrno = errno;
Aerror(stderr, "connect/vc",
errno, *nsap);
badns |= (1<<ns);
badns |= (1 << ns);
_res_close();
goto next_ns;
}
@ -377,7 +377,7 @@ res_send(buf, buflen, ans, anssiz)
if (writev(s, iov, 2) != (INT16SZ + buflen)) {
terrno = errno;
Perror(stderr, "write failed", errno);
badns |= (1<<ns);
badns |= (1 << ns);
_res_close();
goto next_ns;
}
@ -456,10 +456,10 @@ res_send(buf, buflen, ans, anssiz)
/*
* Use datagrams.
*/
struct timeval timeout;
fd_set dsmask;
struct timeval timeout;
fd_set dsmask;
struct sockaddr_in from;
int fromlen;
int fromlen;
if ((s < 0) || vc) {
if (vc)
@ -499,7 +499,7 @@ res_send(buf, buflen, ans, anssiz)
Aerror(stderr,
"connect(dg)",
errno, *nsap);
badns |= (1<<ns);
badns |= (1 << ns);
_res_close();
goto next_ns;
}
@ -507,7 +507,7 @@ res_send(buf, buflen, ans, anssiz)
}
if (send(s, (char*)buf, buflen, 0) != buflen) {
Perror(stderr, "send", errno);
badns |= (1<<ns);
badns |= (1 << ns);
_res_close();
goto next_ns;
}
@ -534,7 +534,7 @@ res_send(buf, buflen, ans, anssiz)
sizeof(struct sockaddr))
!= buflen) {
Aerror(stderr, "sendto", errno, *nsap);
badns |= (1<<ns);
badns |= (1 << ns);
_res_close();
goto next_ns;
}
@ -608,7 +608,7 @@ res_send(buf, buflen, ans, anssiz)
#endif
if (!(_res.options & RES_INSECURE2) &&
!res_queriesmatch(buf, buf + buflen,
ans, ans + anssiz)) {
ans, ans + anssiz)) {
/*
* response contains wrong query? ignore it.
* XXX - potential security hazard could
@ -626,11 +626,11 @@ res_send(buf, buflen, ans, anssiz)
DprintQ(_res.options & RES_DEBUG,
(stdout, "server rejected query:\n"),
ans, resplen);
badns |= (1<<ns);
badns |= (1 << ns);
_res_close();
/* don't retry if called from dig */
if (!_res.pfcode)
goto next_ns;
goto next_ns;
}
if (!(_res.options & RES_IGNTC) && anhp->tc) {
/*
@ -644,9 +644,13 @@ res_send(buf, buflen, ans, anssiz)
goto same_ns;
}
} /*if vc/dg*/
Dprint((_res.options & RES_DEBUG) ||
((_res.pfcode & RES_PRF_REPLY) &&
(_res.pfcode & RES_PRF_HEAD1)),
(stdout, ";; got answer:\n"));
DprintQ((_res.options & RES_DEBUG) ||
(_res.pfcode & RES_PRF_REPLY),
(stdout, ";; got answer:\n"),
(stdout, ""),
ans, resplen);
/*
* If using virtual circuits, we assume that the first server