aboutsummaryrefslogtreecommitdiff
path: root/contrib/bind/tools
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>1996-12-31 19:51:17 +0000
committerPeter Wemm <peter@FreeBSD.org>1996-12-31 19:51:17 +0000
commite5167894d109d3ef5c3d8bd402f3067ed042fc46 (patch)
treea2327c4e40b3c074798fd7f0ddd86f66879ceab5 /contrib/bind/tools
parentd6da9453b6e80776476dcc3f65c3abb0fd530479 (diff)
Notes
Diffstat (limited to 'contrib/bind/tools')
-rw-r--r--contrib/bind/tools/dnsquery.c88
-rw-r--r--contrib/bind/tools/host.c306
-rw-r--r--contrib/bind/tools/nslookup/debug.c86
-rw-r--r--contrib/bind/tools/nslookup/getinfo.c15
-rw-r--r--contrib/bind/tools/nslookup/list.c168
-rw-r--r--contrib/bind/tools/nslookup/main.c6
-rw-r--r--contrib/bind/tools/nslookup/nslookup.help4
-rw-r--r--contrib/bind/tools/nslookup/res.h11
-rw-r--r--contrib/bind/tools/nslookup/subr.c200
9 files changed, 366 insertions, 518 deletions
diff --git a/contrib/bind/tools/dnsquery.c b/contrib/bind/tools/dnsquery.c
index 48ef9f1c9b77..73949caf0a3a 100644
--- a/contrib/bind/tools/dnsquery.c
+++ b/contrib/bind/tools/dnsquery.c
@@ -54,82 +54,32 @@ char *argv[];
case 'h' : strcpy(name, optarg);
break;
- case 'c' : if (!strcasecmp(optarg, "IN"))
- class = C_IN;
- else if (!strcasecmp(optarg, "HS"))
- class = C_HS;
- else if (!strcasecmp(optarg, "CHAOS"))
- class = C_CHAOS;
- else if (!strcasecmp(optarg, "ANY"))
- class = C_ANY;
+ case 'c' : {
+ int success, proto_class;
+
+ proto_class = sym_ston(__p_class_syms,
+ optarg, &success);
+ if (success)
+ class = proto_class;
else {
- class = T_ANY;
- fprintf(stderr, "optarg=%s\n", optarg);
+ fprintf(stderr, "Bad class (%s)\n", optarg);
+ exit(-1);
}
+ }
break;
- case 't' : if (!strcasecmp(optarg, "A"))
- type = T_A;
- else if (!strcasecmp(optarg, "NS"))
- type = T_NS;
- else if (!strcasecmp(optarg, "MD"))
- type = T_MD;
- else if (!strcasecmp(optarg, "MF"))
- type = T_MF;
- else if (!strcasecmp(optarg, "CNAME"))
- type = T_CNAME;
- else if (!strcasecmp(optarg, "SOA"))
- type = T_SOA;
- else if (!strcasecmp(optarg, "MB"))
- type = T_MB;
- else if (!strcasecmp(optarg, "MG"))
- type = T_MG;
- else if (!strcasecmp(optarg, "MR"))
- type = T_MR;
- else if (!strcasecmp(optarg, "NULL"))
- type = T_NULL;
- else if (!strcasecmp(optarg, "WKS"))
- type = T_WKS;
- else if (!strcasecmp(optarg, "PTR"))
- type = T_PTR;
- else if (!strcasecmp(optarg, "HINFO"))
- type = T_HINFO;
- else if (!strcasecmp(optarg, "MINFO"))
- type = T_MINFO;
- else if (!strcasecmp(optarg, "MX"))
- type = T_MX;
- else if (!strcasecmp(optarg, "TXT"))
- type = T_TXT;
- else if (!strcasecmp(optarg, "RP"))
- type = T_RP;
- else if (!strcasecmp(optarg, "AFSDB"))
- type = T_AFSDB;
- else if (!strcasecmp(optarg, "ANY"))
- type = T_ANY;
- else if (!strcasecmp(optarg, "X25"))
- type = T_X25;
- else if (!strcasecmp(optarg, "ISDN"))
- type = T_ISDN;
- else if (!strcasecmp(optarg, "RT"))
- type = T_RT;
- else if (!strcasecmp(optarg, "NSAP"))
- type = T_NSAP;
- else if (!strcasecmp(optarg, "SIG"))
- type = T_SIG;
- else if (!strcasecmp(optarg, "KEY"))
- type = T_KEY;
- else if (!strcasecmp(optarg, "PX"))
- type = T_PX;
- else if (!strcasecmp(optarg, "GPOS"))
- type = T_GPOS;
- else if (!strcasecmp(optarg, "AAAA"))
- type = T_AAAA;
- else if (!strcasecmp(optarg, "LOC"))
- type = T_LOC;
+ case 't' : {
+ int success, proto_type;
+
+ proto_type = sym_ston(__p_type_syms,
+ optarg, &success);
+ if (success)
+ type = proto_type;
else {
- fprintf(stderr, "Bad type (%s)\n", optarg);
+ fprintf(stderr, "Bad type (%s)\n", optarg);
exit(-1);
}
+ }
break;
case 'd' : debug++;
diff --git a/contrib/bind/tools/host.c b/contrib/bind/tools/host.c
index b4abb2296d42..9cba5b82bfbc 100644
--- a/contrib/bind/tools/host.c
+++ b/contrib/bind/tools/host.c
@@ -67,7 +67,7 @@ char copyright[] =
*/
#ifndef lint
-static char rcsid[] = "$Id: host.c,v 8.8 1995/12/06 20:34:52 vixie Exp $";
+static char rcsid[] = "$Id: host.c,v 8.12 1996/10/08 04:51:07 vixie Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -121,8 +121,8 @@ int list = 0;
int server_specified = 0;
u_char *pr_cdname();
-char *pr_class(), *pr_rr(), *pr_type();
-extern char *hostalias();
+char *pr_class(), *pr_rr();
+const char *pr_type();
main(c, v)
int c;
@@ -268,82 +268,36 @@ main(c, v)
}
+int
parsetype(s)
char *s;
{
-if (strcmp(s,"a") == 0)
- return(T_A);
-if (strcmp(s,"ns") == 0)
- return(T_NS);
-if (strcmp(s,"md") == 0)
- return(T_MD);
-if (strcmp(s,"mf") == 0)
- return(T_MF);
-if (strcmp(s,"cname") == 0)
- return(T_CNAME);
-if (strcmp(s,"soa") == 0)
- return(T_SOA);
-if (strcmp(s,"mb") == 0)
- return(T_MB);
-if (strcmp(s,"mg") == 0)
- return(T_MG);
-if (strcmp(s,"mr") == 0)
- return(T_MR);
-if (strcmp(s,"null") == 0)
- return(T_NULL);
-if (strcmp(s,"wks") == 0)
- return(T_WKS);
-if (strcmp(s,"ptr") == 0)
- return(T_PTR);
-if (strcmp(s,"hinfo") == 0)
- return(T_HINFO);
-if (strcmp(s,"minfo") == 0)
- return(T_MINFO);
-if (strcmp(s,"mx") == 0)
- return(T_MX);
-if (strcmp(s,"txt") == 0)
- return(T_TXT);
-if (strcmp(s,"rp") == 0)
- return(T_RP);
-if (strcmp(s,"afsdb") == 0)
- return(T_AFSDB);
-if (strcmp(s,"x25") == 0)
- return(T_X25);
-if (strcmp(s,"isdn") == 0)
- return(T_ISDN);
-if (strcmp(s,"rt") == 0)
- return(T_RT);
-if (strcmp(s,"uinfo") == 0)
- return(T_UINFO);
-if (strcmp(s,"uid") == 0)
- return(T_UID);
-if (strcmp(s,"gid") == 0)
- return(T_GID);
-if (strcmp(s,"unspec") == 0)
- return(T_UNSPEC);
-if (strcmp(s,"any") == 0)
- return(T_ANY);
-if (strcmp(s,"*") == 0)
- return(T_ANY);
-if (atoi(s))
- return(atoi(s));
-fprintf(stderr, "Invalid query type: %s\n", s);
-exit(2);
+ int type, success;
+
+ type = sym_ston(__p_type_syms, s, &success);
+ if (success)
+ return type;
+ if (strcmp(s,"*") == 0)
+ return(T_ANY);
+ if (atoi(s))
+ return(atoi(s));
+ fprintf(stderr, "Invalid query type: %s\n", s);
+ exit(2);
}
+int
parseclass(s)
char *s;
{
-if (strcmp(s,"in") == 0)
- return(C_IN);
-if (strcmp(s,"hs") == 0)
- return(C_HS);
-if (strcmp(s,"any") == 0)
- return(C_ANY);
-if (atoi(s))
- return(atoi(s));
-fprintf(stderr, "Invalid query class: %s\n", s);
-exit(2);
+ int class, success;
+
+ class = sym_ston(__p_class_syms, s, &success);
+ if (success)
+ return class;
+ if (atoi(s))
+ return(atoi(s));
+ fprintf(stderr, "Invalid query class: %s\n", s);
+ exit(2);
}
printanswer(hp)
@@ -438,6 +392,12 @@ switch(errnum) {
case T_GID:
fprintf(stderr,"a Group ID.\n");
break;
+ case T_SRV:
+ fprintf(stderr,"a Server Selector.\n");
+ break;
+ case T_NAPTR:
+ fprintf(stderr,"a URN Naming Authority.\n");
+ break;
case T_UNSPEC:
fprintf(stderr,"any Unspecified Format data.\n");
break;
@@ -460,7 +420,8 @@ static u_char hostbuf[BUFSIZ+1];
gethostinfo(name)
char *name;
{
- register char *cp, **domain;
+ char *cp, **domain;
+ const char *tp;
u_int n;
int hp;
int nDomain;
@@ -479,11 +440,11 @@ gethostinfo(name)
cp[-1] = '.';
return (hp);
}
- if (n == 0 && (cp = hostalias(name))) {
+ if (n == 0 && (tp = hostalias(name))) {
if (verbose)
- printf("Aliased to \"%s\"\n", cp);
+ printf("Aliased to \"%s\"\n", tp);
_res.options |= RES_DEFNAMES;
- return (getdomaininfo(cp, (char *)NULL));
+ return (getdomaininfo(tp, (char *)NULL));
}
if (n >= _res.ndots) {
asis = 1;
@@ -549,7 +510,7 @@ getinfo(name, domain, type)
querybuf buf, answer;
int n, n1, i, j, nmx, ancount, nscount, arcount, qdcount, buflen;
u_short pref, class;
- char host[2*MAXDNAME+2];
+ char host[MAXDNAME];
if (domain == NULL)
(void)sprintf(host, "%.*s", MAXDNAME, name);
@@ -573,7 +534,7 @@ getinfo(name, domain, type)
}
eom = (char *)&answer + n;
return(printinfo(&answer, eom, T_ANY, 0));
- }
+}
printinfo(answer, eom, filter, isls)
querybuf *answer;
@@ -826,6 +787,64 @@ pr_rr(cp, msg, file, filter)
fprintf(file, "%s", name);
break;
+ case T_SRV:
+ /* priority */
+ if (doprint)
+ fprintf(file," %d", _getshort(cp));
+ cp += sizeof(u_short);
+ /* weight */
+ if (doprint)
+ fprintf(file," %d", _getshort(cp));
+ cp += sizeof(u_short);
+ /* port */
+ if (doprint)
+ fprintf(file," %d", _getshort(cp));
+ cp += sizeof(u_short);
+ /* target */
+ cp = (u_char *)pr_cdname(cp, msg, name, sizeof(name));
+ if (doprint)
+ fprintf(file,"%s",name);
+ break;
+
+ case T_NAPTR:
+ /* order */
+ if (doprint)
+ fprintf(file," %d", _getshort(cp));
+ cp += sizeof(u_short);
+ /* preference */
+ if (doprint)
+ fprintf(file," %d", _getshort(cp));
+ cp += sizeof(u_short);
+ /* Flags */
+ n = *cp++;
+ if (doprint)
+ if(n)
+ fprintf(file,"%c%.*s", punc, n, cp);
+ else
+ fprintf(file,"%c\"\"",punc);
+ cp += n;
+ /* Service */
+ n = *cp++;
+ if (doprint)
+ if(n)
+ fprintf(file,"%c%.*s", punc, n, cp);
+ else
+ fprintf(file,"%c\"\"",punc);
+ cp += n;
+ /* Regexp */
+ n = *cp++;
+ if (doprint)
+ if(n)
+ fprintf(file,"%c%.*s", punc, n, cp);
+ else
+ fprintf(file,"%c\"\"",punc);
+ cp += n;
+ /* replacement */
+ cp = (u_char *)pr_cdname(cp, msg, name, sizeof(name));
+ if (doprint)
+ fprintf(file,"%s",name);
+ break;
+
case T_MINFO:
case T_RP:
cp = (u_char *)pr_cdname(cp, msg, name, sizeof(name));
@@ -842,31 +861,37 @@ pr_rr(cp, msg, file, filter)
fprintf(file, " %s", name);
break;
- case T_TXT:
case T_X25:
+ if (n = *cp++) {
+ if (doprint)
+ fprintf(file,"%c%.*s", punc, n, cp);
+ cp += n;
+ }
+ break;
+
+ case T_TXT:
{
int n,j;
u_char * end = cp + dlen;
- if (doprint)
- (void) fputs(" \"", file);
while (cp < end) {
- if (n = *cp++) {
- for (j = n; j > 0 && cp < end ; j --)
- if ((*cp == '\n') || (*cp == '"')) {
- if (doprint){
+ if (doprint)
+ (void) fputs(" \"", file);
+ if (n = *cp++)
+ for (j = n; j > 0 && cp < end ; j --) {
+ if (doprint) {
+ if ((*cp == '\n') || (*cp == '"') || (*cp == '\\'))
(void) putc('\\', file);
- (void) putc(*cp++, file);
- }
- } else
- if (doprint)
- (void) putc(*cp++, file);
- }
+ (void) putc(*cp, file);
+ }
+ cp++;
+ }
+ if (doprint)
+ (void) putc('"', file);
}
- if (doprint)
- (void) fputs("\"", file);
- break;
}
+ break;
+
case T_UINFO:
if (doprint)
fprintf(file,"%c%s", punc, cp);
@@ -929,78 +954,33 @@ pr_rr(cp, msg, file, filter)
return (char *)cp;
}
-static char nbuf[20];
-
/*
- * Return a string for the type
+ * Return a string for the type. A few get special treatment when
+ * not in verbose mode, to make the program more chatty and easier to
+ * understand.
*/
-char *
+const char *
pr_type(type)
int type;
{
- switch (type) {
+
+ if (!verbose) switch (type) {
case T_A:
- return(verbose? "A" : "has address");
- case T_NS: /* authoritative server */
- return("NS");
-#ifdef OLDRR
- case T_MD: /* mail destination */
- return("MD");
- case T_MF: /* mail forwarder */
- return("MF");
-#endif /* OLDRR */
+ return("has address");
case T_CNAME: /* connonical name */
- return(verbose? "CNAME" : "is a nickname for");
- case T_SOA: /* start of authority zone */
- return("SOA");
- case T_MB: /* mailbox domain name */
- return("MB");
- case T_MG: /* mail group member */
- return("MG");
+ return("is a nickname for");
case T_MX: /* mail routing info */
- return(verbose? "MX" : "mail is handled");
+ return("mail is handled");
case T_TXT: /* TXT - descriptive info */
- return(verbose? "TXT" : "descriptive text");
+ return("descriptive text");
case T_AFSDB: /* AFS/DCE info */
- return(verbose? "AFSDB" : "DCE or AFS service from");
- case T_X25: /* X25 */
- return(verbose? "X25" : "X25 address");
- case T_ISDN: /* ISDN */
- return(verbose? "ISDN" : "ISDN address");
- case T_RT: /* Router */
- return(verbose? "RT" : "router");
- case T_MR: /* mail rename name */
- return("MR");
- case T_NULL: /* null resource record */
- return("NULL");
- case T_WKS: /* well known service */
- return("WKS");
- case T_PTR: /* domain name pointer */
- return("PTR");
- case T_HINFO: /* host information */
- return("HINFO");
- case T_MINFO: /* mailbox information */
- return("MINFO");
- case T_RP: /* responsible person */
- return(verbose?"RP":"responsible person");
- case T_AXFR: /* zone transfer */
- return("AXFR");
- case T_MAILB: /* mail box */
- return("MAILB");
- case T_MAILA: /* mail address */
- return("MAILA");
- case T_ANY: /* matches any type */
- return("ANY");
- case T_UINFO:
- return("UINFO");
- case T_UID:
- return("UID");
- case T_GID:
- return("GID");
- default:
- sprintf(nbuf, "%d", type);
- return nbuf;
+ return("DCE or AFS service from");
}
+
+ if (verbose)
+ return (sym_ntos(__p_type_syms, type, NULL));
+ else
+ return (sym_ntop(__p_type_syms, type, NULL));
}
/*
@@ -1010,18 +990,18 @@ char *
pr_class(class)
int class;
{
+ static char spacestr[20];
- switch (class) {
+ if (!verbose) switch (class) {
case C_IN: /* internet class */
- return(verbose? " IN" : "");
- case C_HS: /* internet class */
- return(verbose? " HS" : "");
- case C_ANY: /* matches any class */
- return(" ANY");
- default:
- (void) sprintf(nbuf," %d", class);
- return nbuf;
+ return "";
+ case C_HS: /* internet class FIXME? */
+ return "";
}
+
+ spacestr[0] = ' ';
+ strcpy (&spacestr[1], p_class (class));
+ return spacestr;
}
u_char *
diff --git a/contrib/bind/tools/nslookup/debug.c b/contrib/bind/tools/nslookup/debug.c
index e523ae6626ec..e61c08f99b2f 100644
--- a/contrib/bind/tools/nslookup/debug.c
+++ b/contrib/bind/tools/nslookup/debug.c
@@ -55,7 +55,7 @@
#ifndef lint
static char sccsid[] = "@(#)debug.c 5.26 (Berkeley) 3/21/91";
-static char rcsid[] = "$Id: debug.c,v 8.4 1996/05/21 07:04:38 vixie Exp $";
+static char rcsid[] = "$Id: debug.c,v 8.10 1996/12/18 04:09:50 vixie Exp $";
#endif /* not lint */
/*
@@ -141,6 +141,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));
@@ -170,6 +176,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);
@@ -248,17 +259,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 */
}
@@ -333,6 +344,45 @@ 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;
@@ -467,19 +517,22 @@ doname:
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:
@@ -506,8 +559,9 @@ doname:
case T_AAAA: {
char t[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
- fprintf(file, "IPv6 address = %s\n",
+ fprintf(file, "\tIPv6 address = %s\n",
inet_ntop(AF_INET6, cp, t, sizeof t));
+ cp += IN6ADDRSZ;
break;
}
@@ -574,7 +628,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/contrib/bind/tools/nslookup/getinfo.c b/contrib/bind/tools/nslookup/getinfo.c
index 4587fb6241b4..9d31b8fe2397 100644
--- a/contrib/bind/tools/nslookup/getinfo.c
+++ b/contrib/bind/tools/nslookup/getinfo.c
@@ -55,7 +55,7 @@
#ifndef lint
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[] = "$Id: getinfo.c,v 8.6 1996/12/02 09:17:24 vixie Exp $";
#endif /* not lint */
/*
@@ -85,11 +85,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];
@@ -313,6 +308,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;
@@ -570,7 +570,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/contrib/bind/tools/nslookup/list.c b/contrib/bind/tools/nslookup/list.c
index 6225e4f67673..6d746d77ffff 100644
--- a/contrib/bind/tools/nslookup/list.c
+++ b/contrib/bind/tools/nslookup/list.c
@@ -55,7 +55,7 @@
#ifndef lint
static char sccsid[] = "@(#)list.c 5.23 (Berkeley) 3/21/91";
-static char rcsid[] = "$Id: list.c,v 8.5 1996/05/21 07:04:38 vixie Exp $";
+static char rcsid[] = "$Id: list.c,v 8.9 1996/11/26 10:11:26 vixie Exp $";
#endif /* not lint */
/*
@@ -209,6 +209,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;
}
@@ -339,97 +341,6 @@ 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_AAAA:
- fprintf(filePtr, " %-30s\n", "IPv6 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';
for (done = 0; !done; NULL) {
unsigned short tmp;
@@ -810,22 +721,30 @@ PrintListInfo(file, msg, eom, qtype, domain)
cp += nameLen;
break;
- case T_TXT:
case T_X25:
+ if (n = *cp++) {
+ fprintf(file," %.*s", n, cp);
+ cp += n;
+ }
+ break;
+
+ case T_TXT:
{
u_char *cp2 = cp + dlen;
int c;
- (void) fputs(" \"", file);
- while (cp < cp2)
+ while (cp < cp2) {
+ (void) putc('"', file);
if (n = (unsigned char) *cp++)
- for (c = n; c > 0 && cp < cp2; c--)
- if (strchr("\n\"\\", *cp)) {
+ for (c = n; c > 0 && cp < cp2; c--) {
+ if (strchr("\n\"\\", *cp))
(void) putc('\\', file);
- (void) putc(*cp++, file);
- } else
- (void) putc(*cp++, file);
- (void) putc('"', file);
+ (void) putc(*cp++, file);
+ }
+ (void) putc('"', file);
+ if (cp < cp2)
+ (void) putc(' ', file);
+ }
}
break;
@@ -838,9 +757,56 @@ PrintListInfo(file, msg, eom, qtype, domain)
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);
diff --git a/contrib/bind/tools/nslookup/main.c b/contrib/bind/tools/nslookup/main.c
index fb674b5f08ad..ff2e42954f2a 100644
--- a/contrib/bind/tools/nslookup/main.c
+++ b/contrib/bind/tools/nslookup/main.c
@@ -61,7 +61,7 @@ char copyright[] =
#ifndef lint
static char sccsid[] = "@(#)main.c 5.42 (Berkeley) 3/3/91";
-static char rcsid[] = "$Id: main.c,v 8.3 1996/06/02 08:20:41 vixie Exp $";
+static char rcsid[] = "$Id: main.c,v 8.4 1996/11/11 06:36:54 vixie Exp $";
#endif /* not lint */
/*
@@ -1102,7 +1102,9 @@ ReadRC()
register char *cp;
char buf[PATH_MAX];
- if ((cp = getenv("HOME")) != NULL) {
+ if ((cp = getenv("HOME")) != NULL &&
+ (strlen(cp) + strlen(_PATH_NSLOOKUPRC)) < sizeof(buf)) {
+
(void) strcpy(buf, cp);
(void) strcat(buf, _PATH_NSLOOKUPRC);
diff --git a/contrib/bind/tools/nslookup/nslookup.help b/contrib/bind/tools/nslookup/nslookup.help
index 18f2e6bb2343..9876e6f76652 100644
--- a/contrib/bind/tools/nslookup/nslookup.help
+++ b/contrib/bind/tools/nslookup/nslookup.help
@@ -1,4 +1,4 @@
-$Id: nslookup.help,v 8.3 1996/08/05 08:31:39 vixie Exp $
+$Id: 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
@@ -16,7 +16,7 @@ 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
diff --git a/contrib/bind/tools/nslookup/res.h b/contrib/bind/tools/nslookup/res.h
index 9363f38d6663..6fe43c84ed82 100644
--- a/contrib/bind/tools/nslookup/res.h
+++ b/contrib/bind/tools/nslookup/res.h
@@ -55,7 +55,7 @@
/*
* @(#)res.h 5.10 (Berkeley) 6/1/90
- * $Id: res.h,v 8.1 1994/12/15 06:24:31 vixie Exp $
+ * $Id: res.h,v 8.3 1996/12/02 09:17:24 vixie Exp $
*/
/*
@@ -77,6 +77,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
@@ -159,8 +164,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/contrib/bind/tools/nslookup/subr.c b/contrib/bind/tools/nslookup/subr.c
index 59a47f5c820e..615e6ebc2c53 100644
--- a/contrib/bind/tools/nslookup/subr.c
+++ b/contrib/bind/tools/nslookup/subr.c
@@ -55,7 +55,7 @@
#ifndef lint
static char sccsid[] = "@(#)subr.c 5.24 (Berkeley) 3/2/91";
-static char rcsid[] = "$Id: subr.c,v 8.5 1996/05/21 07:04:38 vixie Exp $";
+static char rcsid[] = "$Id: subr.c,v 8.6 1996/08/08 06:54:51 vixie Exp $";
#endif /* not lint */
/*
@@ -84,6 +84,7 @@ static char rcsid[] = "$Id: subr.c,v 8.5 1996/05/21 07:04:38 vixie Exp $";
#include <signal.h>
#include <setjmp.h>
#include <stdio.h>
+#include "resolv.h"
#include "res.h"
#include "../../conf/portability.h"
@@ -371,28 +372,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");
}
@@ -402,15 +410,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);
@@ -434,67 +439,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 */
- if (strcasecmp(type, "AAAA") == 0)
- return(T_AAAA); /* IPv6 address */
+ 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,75 +462,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_AAAA:
- return("IPv6 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));
}