summaryrefslogtreecommitdiff
path: root/usr.sbin/named/nslookup
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/named/nslookup')
-rw-r--r--usr.sbin/named/nslookup/Makefile6
-rw-r--r--usr.sbin/named/nslookup/commands.l3
-rw-r--r--usr.sbin/named/nslookup/debug.c135
-rw-r--r--usr.sbin/named/nslookup/getinfo.c23
-rw-r--r--usr.sbin/named/nslookup/list.c283
-rw-r--r--usr.sbin/named/nslookup/main.c17
-rw-r--r--usr.sbin/named/nslookup/nslookup.help7
-rw-r--r--usr.sbin/named/nslookup/pathnames.h4
-rw-r--r--usr.sbin/named/nslookup/res.h13
-rw-r--r--usr.sbin/named/nslookup/send.c8
-rw-r--r--usr.sbin/named/nslookup/skip.c8
-rw-r--r--usr.sbin/named/nslookup/subr.c202
12 files changed, 378 insertions, 331 deletions
diff --git a/usr.sbin/named/nslookup/Makefile b/usr.sbin/named/nslookup/Makefile
index 2169d4a10f4..caa4065f0d7 100644
--- a/usr.sbin/named/nslookup/Makefile
+++ b/usr.sbin/named/nslookup/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.2 1996/12/08 15:00:00 downsj Exp $
+# $OpenBSD: Makefile,v 1.3 1997/03/12 10:42:45 downsj Exp $
# $NetBSD: Makefile,v 1.1 1996/02/02 15:29:56 mrg Exp $
# from: $Id: Makefile,v 8.1 1994/12/15 06:23:48 vixie Exp
@@ -7,9 +7,9 @@
PROG= nslookup
SRCS= main.c getinfo.c debug.c send.c skip.c list.c subr.c commands.l
-CFLAGS+= ${INCLUDE}
+CFLAGS+= ${INCLUDE} ${CONFIG}
DPADD= ${LIBL}
-LDADD= -ll
+LDADD= ${LIBRESOLV} -ll
CLEANFILES+= commands.c lex.yy.c lex.yy.o
MAN= nslookup.8
diff --git a/usr.sbin/named/nslookup/commands.l b/usr.sbin/named/nslookup/commands.l
index 748f02db40d..f8e2302eb7e 100644
--- a/usr.sbin/named/nslookup/commands.l
+++ b/usr.sbin/named/nslookup/commands.l
@@ -1,6 +1,5 @@
%{
-
-/* $NetBSD: commands.l,v 1.1 1996/02/02 15:29:58 mrg Exp $ */
+/* $OpenBSD: commands.l,v 1.2 1997/03/12 10:42:46 downsj Exp $ */
/*
* ++Copyright++ 1985
diff --git a/usr.sbin/named/nslookup/debug.c b/usr.sbin/named/nslookup/debug.c
index 5dbebe1f6d3..9315e7a6345 100644
--- a/usr.sbin/named/nslookup/debug.c
+++ b/usr.sbin/named/nslookup/debug.c
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.1 1996/02/02 15:30:01 mrg Exp $ */
+/* $OpenBSD: debug.c,v 1.2 1997/03/12 10:42:46 downsj Exp $ */
/*
* ++Copyright++ 1985, 1989
@@ -56,8 +56,12 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)debug.c 5.26 (Berkeley) 3/21/91";
-static char rcsid[] = "$Id: debug.c,v 8.2 1995/06/29 09:26:34 vixie Exp ";
+static char rcsid[] = "$From: debug.c,v 8.10 1996/12/18 04:09:50 vixie Exp $";
+#else
+static char rcsid[] = "$OpenBSD: debug.c,v 1.2 1997/03/12 10:42:46 downsj Exp $";
+#endif
#endif /* not lint */
/*
@@ -73,6 +77,7 @@ static char rcsid[] = "$Id: debug.c,v 8.2 1995/06/29 09:26:34 vixie Exp ";
*/
#include <sys/param.h>
+#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
@@ -142,6 +147,12 @@ Fprint_query(msg, eom, printHeader,file)
fprintf(file,", want recursion");
if (hp->ra)
fprintf(file,", recursion avail.");
+ if (hp->unused)
+ fprintf(file,", UNUSED-QUERY_BIT");
+ if (hp->ad)
+ fprintf(file,", authentic data");
+ if (hp->cd)
+ fprintf(file,", checking disabled");
fprintf(file,"\n\tquestions = %d", ntohs(hp->qdcount));
fprintf(file,", answers = %d", ntohs(hp->ancount));
fprintf(file,", authority records = %d", ntohs(hp->nscount));
@@ -171,6 +182,11 @@ Fprint_query(msg, eom, printHeader,file)
*/
if (n = ntohs(hp->ancount)) {
fprintf(file," ANSWERS:\n");
+ if (type == T_A && n > MAXADDRS) {
+ printf("Limiting response to MAX Addrs = %d \n",
+ MAXADDRS);
+ n = MAXADDRS;
+ }
while (--n >= 0) {
fprintf(file, INDENT);
cp = Print_rr(cp, msg, eom, file);
@@ -249,17 +265,17 @@ Print_cdname2(cp, msg, eom, file)
* Print resource record fields in human readable form.
*/
u_char *
-Print_rr(cp, msg, eom, file)
- u_char *cp, *msg, *eom;
+Print_rr(ocp, msg, eom, file)
+ u_char *ocp, *msg, *eom;
FILE *file;
{
int type, class, dlen, n, c;
u_int32_t rrttl, ttl;
struct in_addr inaddr;
- u_char *cp1, *cp2;
+ u_char *cp, *cp1, *cp2;
int debug;
- if ((cp = Print_cdname(cp, msg, eom, file)) == NULL) {
+ if ((cp = Print_cdname(ocp, msg, eom, file)) == NULL) {
fprintf(file, "(name truncated?)\n");
return (NULL); /* compression error */
}
@@ -334,13 +350,60 @@ Print_rr(cp, msg, eom, file)
cp += INT16SZ;
fprintf(file,", mail exchanger = ");
goto doname;
+
+ case T_NAPTR:
+ fprintf(file, "\torder = %u",_getshort((u_char*)cp));
+ cp += INT16SZ;
+ fprintf(file,", preference = %u\n", _getshort((u_char*)cp));
+ cp += INT16SZ;
+ /* Flags */
+ n = *cp++;
+ fprintf(file,"\tflags = \"%.*s\"\n", (int)n, cp);
+ cp += n;
+ /* Service */
+ n = *cp++;
+ fprintf(file,"\tservices = \"%.*s\"\n", (int)n, cp);
+ cp += n;
+ /* Regexp */
+ n = *cp++;
+ fprintf(file,"\trule = \"%.*s\"\n", (int)n, cp);
+ cp += n;
+ /* Replacement */
+ fprintf(file,"\treplacement = ");
+ cp = Print_cdname(cp, msg, eom, file);
+ if (cp == NULL) {
+ fprintf(file, "(replacement truncated?)\n");
+ return (NULL); /* compression error */
+ }
+ (void) putc('\n', file);
+
+ break;
+ case T_SRV:
+ fprintf(file, "\tpriority = %u",_getshort((u_char*)cp));
+ cp += INT16SZ;
+ fprintf(file,", weight = %u", _getshort((u_char*)cp));
+ cp += INT16SZ;
+ fprintf(file,", port= %u\n", _getshort((u_char*)cp));
+ cp += INT16SZ;
+
+ fprintf(file,"\thost = ");
+ goto doname;
+
case T_PX:
fprintf(file,"\tpreference = %u",_getshort((u_char*)cp));
cp += INT16SZ;
fprintf(file,", RFC 822 = ");
cp = Print_cdname(cp, msg, eom, file);
+ if (cp == NULL) {
+ fprintf(file, "(name truncated?)\n");
+ return (NULL); /* compression error */
+ }
fprintf(file,"\nX.400 = ");
cp = Print_cdname(cp, msg, eom, file);
+ if (cp == NULL) {
+ fprintf(file, "(name truncated?)\n");
+ return (NULL); /* compression error */
+ }
(void) putc('\n', file);
break;
case T_RT:
@@ -360,6 +423,10 @@ Print_rr(cp, msg, eom, file)
fprintf(file,"\tname = ");
doname:
cp = Print_cdname(cp, msg, eom, file);
+ if (cp == NULL) {
+ fprintf(file, "(name truncated?)\n");
+ return (NULL); /* compression error */
+ }
(void) putc('\n', file);
break;
@@ -393,8 +460,16 @@ doname:
(void) putc('\n', file);
fprintf(file,"\torigin = ");
cp = Print_cdname(cp, msg, eom, file);
+ if (cp == NULL) {
+ fprintf(file, "(name truncated?)\n");
+ return (NULL); /* compression error */
+ }
fprintf(file,"\n\tmail addr = ");
cp = Print_cdname(cp, msg, eom, file);
+ if (cp == NULL) {
+ fprintf(file, "(name truncated?)\n");
+ return (NULL); /* compression error */
+ }
fprintf(file,"\n\tserial = %lu", _getlong((u_char*)cp));
cp += INT32SZ;
ttl = _getlong((u_char*)cp);
@@ -417,8 +492,16 @@ doname:
(void) putc('\n', file);
fprintf(file,"\trequests = ");
cp = Print_cdname(cp, msg, eom, file);
+ if (cp == NULL) {
+ fprintf(file, "(name truncated?)\n");
+ return (NULL); /* compression error */
+ }
fprintf(file,"\n\terrors = ");
cp = Print_cdname(cp, msg, eom, file);
+ if (cp == NULL) {
+ fprintf(file, "(name truncated?)\n");
+ return (NULL); /* compression error */
+ }
(void) putc('\n', file);
break;
case T_RP:
@@ -426,25 +509,36 @@ doname:
(void) putc('\n', file);
fprintf(file,"\tmailbox = ");
cp = Print_cdname(cp, msg, eom, file);
+ if (cp == NULL) {
+ fprintf(file, "(name truncated?)\n");
+ return (NULL); /* compression error */
+ }
fprintf(file,"\n\ttext = ");
cp = Print_cdname(cp, msg, eom, file);
+ if (cp == NULL) {
+ fprintf(file, "(name truncated?)\n");
+ return (NULL); /* compression error */
+ }
(void) putc('\n', file);
break;
case T_TXT:
- (void) fputs("\ttext = \"", file);
+ (void) fputs("\ttext = ", file);
cp2 = cp1 + dlen;
while (cp < cp2) {
+ (void) putc('"', file);
if (n = (unsigned char) *cp++) {
- for (c = n; c > 0 && cp < cp2; c--)
- if ((*cp == '\n') || (*cp == '"')) {
- (void) putc('\\', file);
- (void) putc(*cp++, file);
- } else
- (void) putc(*cp++, file);
+ for (c = n; c > 0 && cp < cp2; c--) {
+ if ((*cp == '\n') || (*cp == '"') || (*cp == '\\'))
+ (void) putc('\\', file);
+ (void) putc(*cp++, file);
+ }
}
+ (void) putc('"', file);
+ if (cp < cp2)
+ (void) putc(' ', file);
}
- (void) fputs("\"\n", file);
+ (void) putc('\n', file);
break;
case T_X25:
@@ -468,6 +562,15 @@ doname:
cp += dlen;
break;
+ case T_AAAA: {
+ char t[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
+
+ fprintf(file, "\tIPv6 address = %s\n",
+ inet_ntop(AF_INET6, cp, t, sizeof t));
+ cp += IN6ADDRSZ;
+ break;
+ }
+
case T_UINFO:
fprintf(file,"\tuser info = %s\n", cp);
cp += dlen;
@@ -531,7 +634,9 @@ doname:
break;
default:
- fprintf(file,"\t??? unknown type %d ???\n", type);
+ fprintf(file,"\trecord type %d, interpreted as:\n", type);
+ /* Let resolver library try to print it */
+ p_rr(ocp, msg, file);
cp += dlen;
}
if (_res.options & RES_DEBUG && type != T_SOA) {
diff --git a/usr.sbin/named/nslookup/getinfo.c b/usr.sbin/named/nslookup/getinfo.c
index a84bb2e1c54..51b0b55b39c 100644
--- a/usr.sbin/named/nslookup/getinfo.c
+++ b/usr.sbin/named/nslookup/getinfo.c
@@ -1,4 +1,4 @@
-/* $NetBSD: getinfo.c,v 1.1 1996/02/02 15:30:05 mrg Exp $ */
+/* $OpenBSD: getinfo.c,v 1.2 1997/03/12 10:42:47 downsj Exp $ */
/*
* ++Copyright++ 1985, 1989
@@ -56,8 +56,12 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)getinfo.c 5.26 (Berkeley) 3/21/91";
-static char rcsid[] = "$Id: getinfo.c,v 8.3 1995/12/29 07:16:27 vixie Exp ";
+static char rcsid[] = "$From: getinfo.c,v 8.6 1996/12/02 09:17:24 vixie Exp $";
+#else
+static char rcsid[] = "$OpenBSD: getinfo.c,v 1.2 1997/03/12 10:42:47 downsj Exp $";
+#endif
#endif /* not lint */
/*
@@ -87,11 +91,6 @@ static char rcsid[] = "$Id: getinfo.c,v 8.3 1995/12/29 07:16:27 vixie Exp ";
extern char *_res_resultcodes[];
extern char *res_skip();
-#define MAXALIASES 35
-#define MAXADDRS 35
-#define MAXDOMAINS 35
-#define MAXSERVERS 10
-
static char *addr_list[MAXADDRS + 1];
static char *host_aliases[MAXALIASES];
@@ -307,7 +306,7 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
hostPtr->name = Calloc(1, len);
bcopy(bp, hostPtr->name, len);
}
- bp += (((long)bp) % sizeof(align));
+ bp += (((u_int32_t)bp) % sizeof(align));
if (bp + dlen >= &hostbuf[sizeof(hostbuf)]) {
if (_res.options & RES_DEBUG) {
@@ -315,6 +314,11 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
}
break;
}
+ if (numAddresses >= MAXADDRS) {
+ printf("MAXADDRS exceeded: skipping address\n");
+ cp += dlen;
+ continue;
+ }
bcopy(cp, *addrPtr++ = (char *)bp, dlen);
bp +=dlen;
cp += dlen;
@@ -572,7 +576,8 @@ GetHostInfoByName(nsAddrPtr, queryClass, queryType, name, hostPtr, isServer)
{
int n;
register int result;
- register char *cp, **domain;
+ register char **domain;
+ const char *cp;
Boolean got_nodata = FALSE;
struct in_addr ina;
Boolean tried_as_is = FALSE;
diff --git a/usr.sbin/named/nslookup/list.c b/usr.sbin/named/nslookup/list.c
index de282eca469..cf26720f5b1 100644
--- a/usr.sbin/named/nslookup/list.c
+++ b/usr.sbin/named/nslookup/list.c
@@ -1,4 +1,4 @@
-/* $NetBSD: list.c,v 1.1 1996/02/02 15:30:09 mrg Exp $ */
+/* $OpenBSD: list.c,v 1.2 1997/03/12 10:42:47 downsj Exp $ */
/*
* ++Copyright++ 1985, 1989
@@ -56,8 +56,12 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)list.c 5.23 (Berkeley) 3/21/91";
-static char rcsid[] = "$Id: list.c,v 8.3 1994/12/19 08:35:16 vixie Exp ";
+static char rcsid[] = "$From: list.c,v 8.9 1996/11/26 10:11:26 vixie Exp $";
+#else
+static char rcsid[] = "$OpenBSD: list.c,v 1.2 1997/03/12 10:42:47 downsj Exp $";
+#endif
#endif /* not lint */
/*
@@ -211,6 +215,8 @@ ListHosts(string, putToFile)
qtype = T_WKS;
} else if (strcmp("-d", option) == 0) {
qtype = T_ANY;
+ } else if (strcmp("-n", option) == 0) {
+ qtype = T_NAPTR;
} else {
qtype = T_A;
}
@@ -239,12 +245,14 @@ ListSubr(qtype, domain, cmd)
HEADER *headerPtr;
int msglen;
int amtToRead;
- int numRead;
+ int numRead, n;
int numAnswers = 0;
+ int numRecords = 0;
int result;
int soacnt = 0;
+ int count, done;
u_short len;
- u_char *cp, *nmp;
+ u_char *cp;
char dname[2][NAME_LEN];
char file[NAME_LEN];
static u_char *answer = NULL;
@@ -339,96 +347,8 @@ ListSubr(qtype, domain, cmd)
defaultPtr->servers[0]->name);
}
-#if 0
- if (qtype == T_CNAME) {
- fprintf(filePtr, "%-30s", "Alias");
- } else if (qtype == T_TXT) {
- fprintf(filePtr, "%-30s", "Key");
- } else {
- fprintf(filePtr, "%-30s", "Host or domain name");
- }
- switch (qtype) {
- case T_A:
- fprintf(filePtr, " %-30s\n", "Internet Address");
- break;
- case T_HINFO:
- fprintf(filePtr, " %-30s\n", "CPU & OS");
- break;
- case T_CNAME:
- fprintf(filePtr, " %-30s\n", "Canonical Name");
- break;
- case T_MX:
- fprintf(filePtr, " %-30s\n", "Metric & Host");
- break;
- case T_PX:
- fprintf(filePtr, " %-30s\n", "Mapping information");
- break;
- case T_AFSDB:
- fprintf(filePtr, " %-30s\n", "Subtype & Host");
- break;
- case T_X25:
- fprintf(filePtr, " %-30s\n", "X25 Address");
- break
- case T_ISDN:
- fprintf(filePtr, " %-30s\n", "ISDN Address");
- break
- case T_WKS:
- fprintf(filePtr, " %-4s %s\n", "Protocol", "Services");
- break;
- case T_MB:
- fprintf(filePtr, " %-30s\n", "Mailbox");
- break;
- case T_MG:
- fprintf(filePtr, " %-30s\n", "Mail Group");
- break;
- case T_MR:
- fprintf(filePtr, " %-30s\n", "Mail Rename");
- break;
- case T_MINFO:
- fprintf(filePtr, " %-30s\n", "Mail List Requests & Errors");
- break;
- case T_UINFO:
- fprintf(filePtr, " %-30s\n", "User Information");
- break;
- case T_UID:
- fprintf(filePtr, " %-30s\n", "User ID");
- break;
- case T_GID:
- fprintf(filePtr, " %-30s\n", "Group ID");
- break;
- case T_TXT:
- fprintf(filePtr, " %-30s\n", "Text");
- break;
- case T_RP:
- fprintf(filePtr, " %-30s\n", "Responsible Person");
- break;
- case T_RT:
- fprintf(filePtr, " %-30s\n", "Router");
- break;
- case T_NSAP:
- fprintf(filePtr, " %-30s\n", "NSAP address");
- break;
- case T_NSAP_PTR:
- fprintf(filePtr, " %-30s\n", "NSAP pointer");
- break;
- case T_NS:
- fprintf(filePtr, " %-30s\n", "Name Servers");
- break;
- case T_PTR:
- fprintf(filePtr, " %-30s\n", "Pointers");
- break;
- case T_SOA:
- fprintf(filePtr, " %-30s\n", "Start of Authority");
- break;
- case T_ANY:
- fprintf(filePtr, " %-30s\n", "Resource Record Info.");
- break;
- }
-#endif
-
-
dname[0][0] = '\0';
- while (1) {
+ for (done = 0; !done; NULL) {
unsigned short tmp;
/*
@@ -483,34 +403,51 @@ ListSubr(qtype, domain, cmd)
error = ERR_PRINTING;
break;
}
-
+ numRecords += htons(((HEADER *)answer)->ancount);
numAnswers++;
if (cmd != NULL && ((numAnswers % HASH_SIZE) == 0)) {
fprintf(stdout, "#");
fflush(stdout);
}
+ /* Header. */
cp = answer + HFIXEDSZ;
- if (ntohs(((HEADER* )answer)->qdcount) > 0)
- cp += dn_skipname((u_char *)cp,
- (u_char *)answer + len) + QFIXEDSZ;
- nmp = cp;
- cp += dn_skipname((u_char *)cp, (u_char *)answer + len);
- if ((_getshort((u_char*)cp) == T_SOA)) {
- (void) dn_expand(answer, answer + len, nmp,
- dname[soacnt], sizeof dname[0]);
- if (soacnt) {
- if (strcmp(dname[0], dname[1]) == 0)
- break;
- } else
- soacnt++;
+ /* Question. */
+ for (count = ntohs(((HEADER* )answer)->qdcount);
+ count > 0;
+ count--)
+ cp += dn_skipname(cp, answer + len) + QFIXEDSZ;
+ /* Answer. */
+ for (count = ntohs(((HEADER* )answer)->ancount);
+ count > 0;
+ count--) {
+ int type, class, rlen;
+
+ n = dn_expand(answer, answer + len, cp,
+ dname[soacnt], sizeof dname[0]);
+ if (n < 0) {
+ error = ERR_PRINTING;
+ done++;
+ break;
+ }
+ cp += n;
+ GETSHORT(type, cp);
+ GETSHORT(class, cp);
+ cp += INT32SZ; /* ttl */
+ GETSHORT(rlen, cp);
+ cp += rlen;
+ if (type == T_SOA && soacnt++ &&
+ !strcasecmp(dname[0], dname[1])) {
+ done++;
+ break;
+ }
}
}
if (cmd != NULL) {
- fprintf(stdout, "%sReceived %d record%s.\n",
+ fprintf(stdout, "%sReceived %d answer%s (%d record%s).\n",
(numAnswers >= HASH_SIZE) ? "\n" : "",
- numAnswers,
- (numAnswers != 1) ? "s" : "");
+ numAnswers, (numAnswers != 1) ? "s" : "",
+ numRecords, (numRecords != 1) ? "s" : "");
}
(void) close(sockFD);
@@ -594,7 +531,7 @@ PrintListInfo(file, msg, eom, qtype, domain)
HEADER *headerPtr;
int type, class, dlen, nameLen;
u_int32_t ttl;
- int n, pref;
+ int n, pref, count;
struct in_addr inaddr;
char name[NAME_LEN];
char name2[NAME_LEN];
@@ -617,13 +554,14 @@ PrintListInfo(file, msg, eom, qtype, domain)
if (ntohs(headerPtr->ancount) == 0) {
return(NO_INFO);
- } else {
- if (ntohs(headerPtr->qdcount) > 0) {
- nameLen = dn_skipname(cp, eom);
- if (nameLen < 0)
- return (ERROR);
- cp += nameLen + QFIXEDSZ;
- }
+ }
+ for (n = ntohs(headerPtr->qdcount); n > 0; n--) {
+ nameLen = dn_skipname(cp, eom);
+ if (nameLen < 0)
+ return (ERROR);
+ cp += nameLen + QFIXEDSZ;
+ }
+ for (count = ntohs(headerPtr->ancount); count > 0; count--) {
nameLen = dn_expand(msg, eom, cp, name, sizeof name);
if (nameLen < 0)
return (ERROR);
@@ -680,6 +618,7 @@ PrintListInfo(file, msg, eom, qtype, domain)
} else
fprintf(file, " (dlen = %d?)", dlen);
}
+ cp += dlen;
break;
case T_CNAME:
@@ -692,6 +631,7 @@ PrintListInfo(file, msg, eom, qtype, domain)
return (ERROR);
}
fprintf(file, " %s", name2);
+ cp += nameLen;
break;
case T_NS:
@@ -701,10 +641,14 @@ PrintListInfo(file, msg, eom, qtype, domain)
if (qtype != T_ANY)
fprintf(file,"%s = ", type == T_PTR ? "host" : "server");
cp = (u_char *)Print_cdname2(cp, msg, eom, file);
+ if (!cp) {
+ fprintf(file, " ***\n");
+ return (ERROR);
+ }
break;
case T_HINFO:
- case T_ISDN:
+ case T_ISDN:
{
u_char *cp2 = cp + dlen;
if (n = *cp++) {
@@ -760,6 +704,7 @@ PrintListInfo(file, msg, eom, qtype, domain)
return (ERROR);
}
fprintf(file, " %s", name2);
+ cp += nameLen;
break;
case T_PX:
@@ -772,55 +717,127 @@ PrintListInfo(file, msg, eom, qtype, domain)
return (ERROR);
}
fprintf(file, " %s", name2);
- cp += strlen((char *)cp) + 1;
+ cp += nameLen;
nameLen = dn_expand(msg, eom, cp, name2, sizeof name2);
if (nameLen < 0) {
- fprintf(file, " ***\n");
- return (ERROR);
- }
+ fprintf(file, " ***\n");
+ return (ERROR);
+ }
fprintf(file, " %s", name2);
+ cp += nameLen;
+ break;
+
+ case T_X25:
+ if (n = *cp++) {
+ fprintf(file," %.*s", n, cp);
+ cp += n;
+ }
break;
case T_TXT:
- case T_X25:
{
u_char *cp2 = cp + dlen;
int c;
- (void) fputs(" \"", file);
while (cp < cp2) {
- if (n = (unsigned char) *cp++) {
- for (c = n; c > 0 && cp < cp2; c--)
- if ((*cp == '\n') || (*cp == '"')) {
- (void) putc('\\', file);
- (void) putc(*cp++, file);
- } else
- (void) putc(*cp++, file);
+ (void) putc('"', file);
+ if (n = (unsigned char) *cp++)
+ for (c = n; c > 0 && cp < cp2; c--) {
+ if (strchr("\n\"\\", *cp))
+ (void) putc('\\', file);
+ (void) putc(*cp++, file);
}
+ (void) putc('"', file);
+ if (cp < cp2)
+ (void) putc(' ', file);
}
- (void) putc('"', file);
}
break;
case T_NSAP:
fprintf(file, " %s", inet_nsap_ntoa(dlen, cp, NULL));
+ cp += dlen;
+ break;
+
+ case T_AAAA: {
+ char t[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
+
+ fprintf(file, " %s", inet_ntop(AF_INET6, cp, t, sizeof t));
+ cp += dlen;
+ break;
+ }
+
+ case T_LOC: {
+ char t[255];
+
+ fprintf(file, "\t%s", loc_ntoa(cp, t));
+ cp += dlen;
+ break;
+ }
+
+ case T_SRV: {
+ u_int priority, weight, port;
+
+ priority = _getshort(cp); cp += INT16SZ;
+ weight = _getshort(cp); cp += INT16SZ;
+ port = _getshort(cp); cp += INT16SZ;
+ fprintf(file, "\t%u %u %u ", priority, weight, port);
+ if ((cp = (u_char *)Print_cdname(cp, msg, eom, file)) == NULL)
+ return (ERROR);
break;
+ }
+
+ case T_NAPTR: {
+ u_int order, preference;
+
+ GETSHORT(order, cp);
+ fprintf(file, "\t%u", order);
+
+ GETSHORT(preference, cp);
+ fprintf(file, " %u", preference);
+
+ if (n = *cp++) {
+ fprintf(file, " \"%.*s\"", (int)n, cp);
+ cp += n;
+ }
+ if (n = *cp++) {
+ fprintf(file, " \"%.*s\"", (int)n, cp);
+ cp += n;
+ }
+ if (n = *cp++) {
+ fprintf(file, " \"%.*s\"", (int)n, cp);
+ cp += n;
+ }
+ if ((cp = (u_char *)Print_cdname(cp, msg, eom, file)) == NULL)
+ return (ERROR);
+ break;
+ }
case T_MINFO:
case T_RP:
(void) putc(' ', file);
cp = (u_char *)Print_cdname(cp, msg, eom, file);
+ if (!cp) {
+ fprintf(file, " ***\n");
+ return (ERROR);
+ }
fprintf(file, " ");
cp = (u_char *)Print_cdname(cp, msg, eom, file);
+ if (!cp) {
+ fprintf(file, " ***\n");
+ return (ERROR);
+ }
break;
case T_UINFO:
fprintf(file, " %s", cp);
+ cp += dlen;
break;
case T_UID:
case T_GID:
fprintf(file, " %lu", _getlong((u_char*)cp));
+ cp += dlen;
break;
case T_WKS:
diff --git a/usr.sbin/named/nslookup/main.c b/usr.sbin/named/nslookup/main.c
index 8d78510002c..1279f22a028 100644
--- a/usr.sbin/named/nslookup/main.c
+++ b/usr.sbin/named/nslookup/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.1 1996/02/02 15:30:13 mrg Exp $ */
+/* $OpenBSD: main.c,v 1.3 1997/03/12 10:42:48 downsj Exp $ */
/*
* ++Copyright++ 1985, 1989
@@ -62,8 +62,12 @@ char copyright[] =
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)main.c 5.42 (Berkeley) 3/3/91";
-static char rcsid[] = "$Id: main.c,v 8.2 1995/12/22 10:20:42 vixie Exp ";
+static char rcsid[] = "$From: main.c,v 8.4 1996/11/11 06:36:54 vixie Exp $";
+#else
+static char rcsid[] = "$OpenBSD: main.c,v 1.3 1997/03/12 10:42:48 downsj Exp $";
+#endif
#endif /* not lint */
/*
@@ -518,7 +522,14 @@ SetDefaultServer(string, local)
newServer, newDefPtr, 1);
}
- if (result == SUCCESS || result == NONAUTH) {
+ /* If we ask for an A record and get none back, but get an NS
+ record for the NS server, this is the NONAUTH case.
+ We must check whether we got an IP address for the NS
+ server or not. */
+ if ((result == SUCCESS || result == NONAUTH) &&
+ ((newDefPtr->addrList && newDefPtr->addrList[0] != 0) ||
+ (newDefPtr->servers && newDefPtr->servers[0] &&
+ newDefPtr->servers[0]->addrList[0] != 0))) {
/*
* Found info about the new server. Free the resources for
* the old server.
diff --git a/usr.sbin/named/nslookup/nslookup.help b/usr.sbin/named/nslookup/nslookup.help
index cbc914c62ec..00a2b341f71 100644
--- a/usr.sbin/named/nslookup/nslookup.help
+++ b/usr.sbin/named/nslookup/nslookup.help
@@ -1,5 +1,5 @@
-$NetBSD: nslookup.help,v 1.1 1996/02/02 15:30:17 mrg Exp $
-from: $Id: nslookup.help,v 8.2 1995/06/29 09:26:34 vixie Exp
+$OpenBSD: nslookup.help,v 1.2 1997/03/12 10:42:48 downsj Exp $
+$From: nslookup.help,v 8.4 1996/10/08 04:51:08 vixie Exp $
Commands: (identifiers are shown in uppercase, [] means optional)
NAME - print info about the host/domain NAME using default server
@@ -17,7 +17,8 @@ set OPTION - set an option
root=NAME - set root server to NAME
retry=X - set number of retries to X
timeout=X - set initial time-out interval to X seconds
- querytype=X - set query type, e.g., A,ANY,CNAME,HINFO,MX,PX,NS,PTR,SOA,TXT,WKS
+ querytype=X - set query type, e.g., A,ANY,CNAME,HINFO,MX,PX,NS,PTR,SOA,TXT,WKS,SRV,NAPTR
+ port=X - set port number to send query on
type=X - synonym for querytype
class=X - set query class to one of IN (Internet), CHAOS, HESIOD or ANY
server NAME - set default server to NAME, using current default server
diff --git a/usr.sbin/named/nslookup/pathnames.h b/usr.sbin/named/nslookup/pathnames.h
index 2f8ba319872..7924c824777 100644
--- a/usr.sbin/named/nslookup/pathnames.h
+++ b/usr.sbin/named/nslookup/pathnames.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pathnames.h,v 1.1 1996/02/02 15:30:21 mrg Exp $ */
+/* $OpenBSD: pathnames.h,v 1.2 1997/03/12 10:42:49 downsj Exp $ */
/*
* ++Copyright++ 1990
@@ -57,7 +57,7 @@
/*
* @(#)pathnames.h 5.1 (Berkeley) 5/28/90
- * $Id: pathnames.h,v 8.1 1994/12/15 06:24:31 vixie Exp
+ * $From: pathnames.h,v 8.1 1994/12/15 06:24:31 vixie Exp $
*/
#define _PATH_NSLOOKUPRC "/.nslookuprc"
diff --git a/usr.sbin/named/nslookup/res.h b/usr.sbin/named/nslookup/res.h
index d2e42a5c105..301dc954769 100644
--- a/usr.sbin/named/nslookup/res.h
+++ b/usr.sbin/named/nslookup/res.h
@@ -1,4 +1,4 @@
-/* $NetBSD: res.h,v 1.1 1996/02/02 15:30:25 mrg Exp $ */
+/* $OpenBSD: res.h,v 1.2 1997/03/12 10:42:49 downsj Exp $ */
/*
* ++Copyright++ 1985, 1989
@@ -57,7 +57,7 @@
/*
* @(#)res.h 5.10 (Berkeley) 6/1/90
- * $Id: res.h,v 8.1 1994/12/15 06:24:31 vixie Exp
+ * $From: res.h,v 8.3 1996/12/02 09:17:24 vixie Exp $
*/
/*
@@ -79,6 +79,11 @@
#define FALSE 0
typedef int Boolean;
+#define MAXALIASES 35
+#define MAXADDRS 35
+#define MAXDOMAINS 35
+#define MAXSERVERS 10
+
/*
* Define return statuses in addtion to the ones defined in namserv.h
* let SUCCESS be a synonym for NOERROR
@@ -161,8 +166,8 @@ extern int Print_query();
extern unsigned char *Print_cdname();
extern unsigned char *Print_cdname2(); /* fixed width */
extern unsigned char *Print_rr();
-extern char *DecodeType(); /* descriptive version of p_type */
-extern char *DecodeError();
+extern const char *DecodeType(); /* descriptive version of p_type */
+extern const char *DecodeError();
extern char *Calloc();
extern char *Malloc();
extern void NsError();
diff --git a/usr.sbin/named/nslookup/send.c b/usr.sbin/named/nslookup/send.c
index 6e3793a0320..a61f3ceed69 100644
--- a/usr.sbin/named/nslookup/send.c
+++ b/usr.sbin/named/nslookup/send.c
@@ -1,4 +1,4 @@
-/* $NetBSD: send.c,v 1.1 1996/02/02 15:30:27 mrg Exp $ */
+/* $OpenBSD: send.c,v 1.2 1997/03/12 10:42:50 downsj Exp $ */
/*
* ++Copyright++ 1985, 1989
@@ -56,8 +56,12 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)send.c 5.18 (Berkeley) 3/2/91";
-static char rcsid[] = "$Id: send.c,v 8.1 1994/12/15 06:24:31 vixie Exp ";
+static char rcsid[] = "$From: send.c,v 8.1 1994/12/15 06:24:31 vixie Exp $";
+#else
+static char rcsid[] = "$OpenBSD: send.c,v 1.2 1997/03/12 10:42:50 downsj Exp $";
+#endif
#endif /* not lint */
/*
diff --git a/usr.sbin/named/nslookup/skip.c b/usr.sbin/named/nslookup/skip.c
index c8abdd1d7aa..777037d5f52 100644
--- a/usr.sbin/named/nslookup/skip.c
+++ b/usr.sbin/named/nslookup/skip.c
@@ -1,4 +1,4 @@
-/* $NetBSD: skip.c,v 1.1 1996/02/02 15:30:28 mrg Exp $ */
+/* $OpenBSD: skip.c,v 1.2 1997/03/12 10:42:50 downsj Exp $ */
/*
* ++Copyright++ 1985, 1989
@@ -56,8 +56,12 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)skip.c 5.12 (Berkeley) 3/21/91";
-static char rcsid[] = "$Id: skip.c,v 8.1 1994/12/15 06:24:31 vixie Exp ";
+static char rcsid[] = "$From: skip.c,v 8.1 1994/12/15 06:24:31 vixie Exp $";
+#else
+static char rcsid[] = "$OpenBSD: skip.c,v 1.2 1997/03/12 10:42:50 downsj Exp $";
+#endif
#endif /* not lint */
/*
diff --git a/usr.sbin/named/nslookup/subr.c b/usr.sbin/named/nslookup/subr.c
index fd8a548ca73..fd03f6e1857 100644
--- a/usr.sbin/named/nslookup/subr.c
+++ b/usr.sbin/named/nslookup/subr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: subr.c,v 1.1 1996/02/02 15:30:30 mrg Exp $ */
+/* $OpenBSD: subr.c,v 1.2 1997/03/12 10:42:51 downsj Exp $ */
/*
* ++Copyright++ 1985, 1989
@@ -56,8 +56,12 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)subr.c 5.24 (Berkeley) 3/2/91";
-static char rcsid[] = "$Id: subr.c,v 8.4 1995/12/03 08:31:19 vixie Exp ";
+static char rcsid[] = "$From: subr.c,v 8.6 1996/08/08 06:54:51 vixie Exp $";
+#else
+static char rcsid[] = "$OpenBSD: subr.c,v 1.2 1997/03/12 10:42:51 downsj Exp $";
+#endif
#endif /* not lint */
/*
@@ -86,6 +90,7 @@ static char rcsid[] = "$Id: subr.c,v 8.4 1995/12/03 08:31:19 vixie Exp ";
#include <signal.h>
#include <setjmp.h>
#include <stdio.h>
+#include "resolv.h"
#include "res.h"
#include "conf/portability.h"
@@ -373,28 +378,35 @@ OpenFile(string, file)
*******************************************************************************
*/
-char *
+const struct res_sym error_syms[] = {
+ { NOERROR, "Success" },
+ { FORMERR, "Format error" },
+ { SERVFAIL, "Server failed" },
+ { NXDOMAIN, "Non-existent host/domain" },
+ { NOTIMP, "Not implemented" },
+ { REFUSED, "Query refused" },
+#ifdef NOCHANGE
+ { NOCHANGE, "No change" },
+#endif
+ { TIME_OUT, "Timed out" },
+ { NO_INFO, "No information" },
+ { ERROR, "Unspecified error" },
+ { NONAUTH, "Non-authoritative answer" },
+ { NO_RESPONSE, "No response from server" },
+ { 0, NULL }
+};
+
+const char *
DecodeError(result)
int result;
{
- switch (result) {
- case NOERROR: return("Success"); break;
- case FORMERR: return("Format error"); break;
- case SERVFAIL: return("Server failed"); break;
- case NXDOMAIN: return("Non-existent host/domain"); break;
- case NOTIMP: return("Not implemented"); break;
- case REFUSED: return("Query refused"); break;
-#ifdef NOCHANGE
- case NOCHANGE: return("No change"); break;
-#endif
- case TIME_OUT: return("Timed out"); break;
- case NO_INFO: return("No information"); break;
- case ERROR: return("Unspecified error"); break;
- case NONAUTH: return("Non-authoritative answer"); break;
- case NO_RESPONSE: return("No response from server"); break;
- default: break;
- }
- return("BAD ERROR VALUE");
+ const char *string;
+ int success;
+
+ string = sym_ntos(error_syms, result, &success);
+ if (success)
+ return string;
+ return ("BAD ERROR VALUE");
}
@@ -404,15 +416,12 @@ StringToClass(class, dflt, errorfile)
int dflt;
FILE *errorfile;
{
- if (strcasecmp(class, "IN") == 0)
- return(C_IN);
- if (strcasecmp(class, "HESIOD") == 0 ||
- strcasecmp(class, "HS") == 0)
- return(C_HS);
- if (strcasecmp(class, "CHAOS") == 0)
- return(C_CHAOS);
- if (strcasecmp(class, "ANY") == 0)
- return(C_ANY);
+ int result, success;
+
+ result = sym_ston(__p_class_syms, class, &success);
+ if (success)
+ return result;
+
if (errorfile)
fprintf(errorfile, "unknown query class: %s\n", class);
return(dflt);
@@ -436,65 +445,15 @@ StringToType(type, dflt, errorfile)
int dflt;
FILE *errorfile;
{
- if (strcasecmp(type, "A") == 0)
- return(T_A);
- if (strcasecmp(type, "NS") == 0)
- return(T_NS); /* authoritative server */
- if (strcasecmp(type, "MX") == 0)
- return(T_MX); /* mail exchanger */
- if (strcasecmp(type, "PX") == 0)
- return(T_PX); /* mapping information */
- if (strcasecmp(type, "CNAME") == 0)
- return(T_CNAME); /* canonical name */
- if (strcasecmp(type, "SOA") == 0)
- return(T_SOA); /* start of authority zone */
- if (strcasecmp(type, "MB") == 0)
- return(T_MB); /* mailbox domain name */
- if (strcasecmp(type, "MG") == 0)
- return(T_MG); /* mail group member */
- if (strcasecmp(type, "MR") == 0)
- return(T_MR); /* mail rename name */
- if (strcasecmp(type, "WKS") == 0)
- return(T_WKS); /* well known service */
- if (strcasecmp(type, "PTR") == 0)
- return(T_PTR); /* domain name pointer */
- if (strcasecmp(type, "HINFO") == 0)
- return(T_HINFO); /* host information */
- if (strcasecmp(type, "MINFO") == 0)
- return(T_MINFO); /* mailbox information */
- if (strcasecmp(type, "AXFR") == 0)
- return(T_AXFR); /* zone transfer */
- if (strcasecmp(type, "MAILA") == 0)
- return(T_MAILA); /* mail agent */
- if (strcasecmp(type, "MAILB") == 0)
- return(T_MAILB); /* mail box */
- if (strcasecmp(type, "ANY") == 0)
- return(T_ANY); /* matches any type */
- if (strcasecmp(type, "UINFO") == 0)
- return(T_UINFO); /* user info */
- if (strcasecmp(type, "UID") == 0)
- return(T_UID); /* user id */
- if (strcasecmp(type, "GID") == 0)
- return(T_GID); /* group id */
- if (strcasecmp(type, "TXT") == 0)
- return(T_TXT); /* text */
- if (strcasecmp(type, "RP") == 0)
- return(T_RP); /* responsible person */
- if (strcasecmp(type, "X25") == 0)
- return(T_X25); /* x25 address */
- if (strcasecmp(type, "ISDN") == 0)
- return(T_ISDN); /* isdn address */
- if (strcasecmp(type, "RT") == 0)
- return(T_RT); /* router */
- if (strcasecmp(type, "AFSDB") == 0)
- return(T_AFSDB); /* DCE or AFS server */
- if (strcasecmp(type, "NSAP") == 0)
- return(T_NSAP); /* NSAP address */
- if (strcasecmp(type, "NSAP_PTR") == 0)
- return(T_NSAP_PTR); /* NSAP reverse pointer */
+ int result, success;
+
+ result = sym_ston(__p_type_syms, type, &success);
+ if (success)
+ return (result);
+
if (errorfile)
fprintf(errorfile, "unknown query type: %s\n", type);
- return(dflt);
+ return (dflt);
}
/*
@@ -509,73 +468,10 @@ StringToType(type, dflt, errorfile)
*******************************************************************************
*/
-static char nbuf[20];
-
-char *
+const char *
DecodeType(type)
int type;
{
- switch (type) {
- case T_A:
- return("address");
- case T_NS:
- return("name server");
- case T_CNAME:
- return("canonical name");
- case T_SOA:
- return("start of authority");
- case T_MB:
- return("mailbox");
- case T_MG:
- return("mail group member");
- case T_MR:
- return("mail rename");
- case T_NULL:
- return("null");
- case T_WKS:
- return("well-known service");
- case T_PTR:
- return("domain name pointer");
- case T_HINFO:
- return("host information");
- case T_MINFO:
- return("mailbox information");
- case T_MX:
- return("mail exchanger");
- case T_PX:
- return("mapping information");
- case T_TXT:
- return("text");
- case T_RP:
- return("responsible person");
- case T_AFSDB:
- return("DCE or AFS server");
- case T_X25:
- return("X25 address");
- case T_ISDN:
- return("ISDN address");
- case T_RT:
- return("router");
- case T_NSAP:
- return("nsap address");
- case T_NSAP_PTR:
- return("domain name pointer");
- case T_UINFO:
- return("user information");
- case T_UID:
- return("user ID");
- case T_GID:
- return("group ID");
- case T_AXFR:
- return("zone transfer");
- case T_MAILB:
- return("mailbox-related data");
- case T_MAILA:
- return("mail agent");
- case T_ANY:
- return("\"any\"");
- default:
- (void) sprintf(nbuf, "%d", type);
- return (nbuf);
- }
+
+ return (sym_ntop(__p_type_syms, type, (int *)0));
}