From 6bc227b4052c3ed894cc99b3abd2db4245118bf8 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Sun, 20 Aug 1995 22:32:57 +0000 Subject: [PATCH] Update the DNS tools from 4.9.3-b9 -> 4.9.3-b24 --- usr.bin/dig/dig.c | 71 ++++++++++++++++++++------------- usr.bin/host/host.c | 48 +++++++++++++--------- usr.sbin/nslookup/debug.c | 23 +++++++---- usr.sbin/nslookup/list.c | 59 +++++++++++++++++++++------ usr.sbin/nslookup/nslookup.help | 2 +- usr.sbin/nslookup/subr.c | 12 +++++- 6 files changed, 147 insertions(+), 68 deletions(-) diff --git a/usr.bin/dig/dig.c b/usr.bin/dig/dig.c index e88b5d57d83d..0557412088d9 100644 --- a/usr.bin/dig/dig.c +++ b/usr.bin/dig/dig.c @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "$Id: dig.c,v 1.3 1995/05/09 13:13:21 rgrimes Exp $"; +static char rcsid[] = "$Id: dig.c,v 1.4 1995/05/30 06:29:46 rgrimes Exp $"; #endif /* @@ -164,7 +164,7 @@ static char rcsid[] = "$Id: dig.c,v 1.3 1995/05/09 13:13:21 rgrimes Exp $"; #include #include -#include "../../usr.sbin/nslookup/res.h" +#include "res.h" #define PRF_DEF 0x2ff9 #define PRF_MIN 0xA930 @@ -197,8 +197,7 @@ jmp_buf env; HostInfo *defaultPtr = NULL; HostInfo curHostInfo, defaultRec; int curHostValid = FALSE; -int queryType = T_A; -int queryClass = C_IN; +int queryType, queryClass; extern int StringToClass(), StringToType(); /* subr.c */ #if defined(BSD) && BSD >= 199006 && !defined(RISCOS_BSD) FILE *yyin = NULL; @@ -221,7 +220,7 @@ stackarg(y, l) case '\t': case ' ': l++; break; - case NULL: + case '\0': case '\n': done++; *y = NULL; @@ -246,7 +245,12 @@ main(argc, argv) { struct hostent *hp; short port = htons(NAMESERVER_PORT); - u_char packet[PACKETSZ]; + /* Wierd stuff for SPARC alignment, hurts nothing else. */ + union { + HEADER header_; + u_char packet_[PACKETSZ]; + } packet_; +#define packet (packet_.packet_) u_char answer[8*1024]; int n; char doping[90]; @@ -259,8 +263,8 @@ main(argc, argv) char *srv; int anyflag = 0; int sticky = 0; - int tmp; - int qtype = 1, qclass = 1; + int tmp; + int qtypeSet; int addrflag = 0; int zone = 0; int bytes_out, bytes_in; @@ -283,6 +287,7 @@ main(argc, argv) res_init(); _res.pfcode = PRF_DEF; + qtypeSet = 0; gethostname(myhostname, (sizeof myhostname)); defsrv = strcat(defbuf, inet_ntoa(_res.nsaddr.sin_addr)); res_x = _res; @@ -296,7 +301,7 @@ main(argc, argv) if ((((afile = (char *) getenv("LOCALDEF")) != (char *) NULL) && ((fp = open(afile, O_RDONLY)) > 0)) || ((fp = open(SAVEENV, O_RDONLY)) > 0)) { - read(fp, &res_x, (sizeof res_x)); + read(fp, (char *)&res_x, (sizeof res_x)); close(fp); _res = res_x; } @@ -362,7 +367,8 @@ main(argc, argv) stackarg(ay, qptr); /* defaults */ - qtype = qclass = 1; + queryType = T_NS; + queryClass = C_IN; zone = 0; *pingstr = 0; srv = NULL; @@ -408,11 +414,11 @@ main(argc, argv) case 'c': if ((tmp = atoi(*++argv)) || *argv[0]=='0') { - qclass = tmp; + queryClass = tmp; } else if (tmp = StringToClass(*argv, 0, NULL) ) { - qclass = tmp; + queryClass = tmp; } else { printf( "; invalid class specified\n" @@ -422,11 +428,13 @@ main(argc, argv) case 't': if ((tmp = atoi(*++argv)) || *argv[0]=='0') { - qtype = tmp; + queryType = tmp; + qtypeSet++; } else if (tmp = StringToType(*argv, 0, NULL) ) { - qtype = tmp; + queryType = tmp; + qtypeSet++; } else { printf( "; invalid type specified\n" @@ -434,8 +442,10 @@ main(argc, argv) } break; case 'x': - if (qtype == T_A) - qtype = T_ANY; + if (!qtypeSet) { + queryType = T_ANY; + qtypeSet++; + } if (!(addrc = *++argv)) { printf( "; no arg for -x?\n" @@ -470,20 +480,21 @@ main(argc, argv) continue; } /* if '-' */ - if ((tmp = StringToType(*argv, -1, NULL)) != -1) { - if ((T_ANY == tmp) && anyflag++) { - qclass = C_ANY; - continue; + if ((tmp = StringToType(*argv, -1, NULL)) != -1) { + if ((T_ANY == tmp) && anyflag++) { + queryClass = C_ANY; + continue; } if (T_AXFR == tmp) { _res.pfcode = PRF_ZONE; zone++; } else { - qtype = tmp; + queryType = tmp; + qtypeSet++; } } else if ((tmp = StringToClass(*argv, -1, NULL)) - != -1) { - qclass = tmp; + != -1) { + queryClass = tmp; } else { bzero(domain, (sizeof domain)); sprintf(domain,"%s",*argv); @@ -518,7 +529,7 @@ main(argc, argv) ((fp = open(SAVEENV, O_WRONLY|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE)) > 0)) { - write(fp, &_res, (sizeof _res)); + write(fp, (char *)&_res, (sizeof _res)); close(fp); } envsave = 0; @@ -622,7 +633,13 @@ main(argc, argv) continue; } - bytes_out = n = res_mkquery(QUERY, domain, qclass, qtype, + if (*domain && !qtypeSet) { + queryType = T_A; + qtypeSet++; + } + + bytes_out = n = res_mkquery(QUERY, domain, + queryClass, queryType, NULL, 0, NULL, packet, sizeof(packet)); if (n < 0) { @@ -1011,7 +1028,7 @@ printZone(zone, sin) __putshort(msglen, (u_char *)&len); if (write(sockFD, (char *)&len, INT16SZ) != INT16SZ || - write(sockFD, (char *) &buf, msglen) != msglen) { + write(sockFD, (char *)&buf, msglen) != msglen) { int e = errno; perror(";; write"); (void) close(sockFD); @@ -1046,7 +1063,7 @@ printZone(zone, sin) * The server sent too much data to fit the existing buffer -- * allocate a new one. */ - if (len > answerLen) { + if (len > (u_int)answerLen) { if (answerLen != 0) { free(answer); } diff --git a/usr.bin/host/host.c b/usr.bin/host/host.c index 8a138783a6d1..22839c3b76d4 100644 --- a/usr.bin/host/host.c +++ b/usr.bin/host/host.c @@ -67,7 +67,7 @@ char copyright[] = */ #ifndef lint -static char rcsid[] = "$Id: host.c,v 1.2 1994/09/22 21:52:03 pst Exp $"; +static char rcsid[] = "$Id: host.c,v 1.3 1995/05/30 06:30:50 rgrimes Exp $"; #endif /* not lint */ #include @@ -360,10 +360,10 @@ printanswer(hp) printf("\n\n"); } -hperror(errno) -int errno; +hperror(errnum) +int errnum; { -switch(errno) { +switch(errnum) { case HOST_NOT_FOUND: fprintf(stderr,"Host not found.\n"); break; @@ -459,7 +459,7 @@ gethostinfo(name) char *name; { register char *cp, **domain; - int n; + u_int n; int hp; int nDomain; int asis = 0; @@ -765,15 +765,20 @@ pr_rr(cp, msg, file, filter) case T_HINFO: case T_ISDN: - if (n = *cp++) { - if (doprint) - fprintf(file,"%c%.*s", punc, n, cp); - cp += n; - } - if (n = *cp++) { - if (doprint) - fprintf(file,"%c%.*s", punc, n, cp); - cp += n; + { + u_char *cp2 = cp + dlen; + if (n = *cp++) { + if (doprint) + fprintf(file,"%c%.*s", punc, n, cp); + cp += n; + } + if ((cp < cp2) && (n = *cp++)) { + if (doprint) + fprintf(file,"%c%.*s", punc, n, cp); + cp += n; + } else if (type == T_HINFO) + if (doprint) + fprintf(file,"\n; *** Warning *** OS-type missing"); } break; @@ -805,10 +810,13 @@ pr_rr(cp, msg, file, filter) case T_AFSDB: case T_RT: if (doprint) - if (verbose) - fprintf(file,"\t%ld ",_getshort(cp)); + if (type == T_MX) + fprintf(file," (pri=%d) by ", _getshort(cp)); else - fprintf(file," "); + if (verbose) + fprintf(file,"\t%d ", _getshort(cp)); + else + fprintf(file," "); cp += sizeof(u_short); cp = (u_char *)pr_cdname(cp, msg, name, sizeof(name)); if (doprint) @@ -842,7 +850,7 @@ pr_rr(cp, msg, file, filter) while (cp < end) { if (n = *cp++) { for (j = n; j > 0 && cp < end ; j --) - if (*cp == '\n') { + if ((*cp == '\n') || (*cp == '"')) { if (doprint){ (void) putc('\\', file); (void) putc(*cp++, file); @@ -947,7 +955,7 @@ pr_type(type) case T_MG: /* mail group member */ return("MG"); case T_MX: /* mail routing info */ - return(verbose? "MX" : "mail is handled by"); + return(verbose? "MX" : "mail is handled"); case T_TXT: /* TXT - descriptive info */ return(verbose? "TXT" : "descriptive text"); case T_AFSDB: /* AFS/DCE info */ @@ -1447,7 +1455,9 @@ DecodeError(result) case NXDOMAIN: return("Non-existent domain"); break; case NOTIMP: return("Not implemented"); break; case REFUSED: return("Query refused"); break; +#ifdef NOCHANGE case NOCHANGE: return("No change"); break; +#endif case NO_INFO: return("No information"); break; case ERROR: return("Unspecified error"); break; case TIME_OUT: return("Timed out"); break; diff --git a/usr.sbin/nslookup/debug.c b/usr.sbin/nslookup/debug.c index 9f63873c1ece..24a5ca7e60fc 100644 --- a/usr.sbin/nslookup/debug.c +++ b/usr.sbin/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 1.2 1994/09/22 21:50:31 pst Exp $"; +static char rcsid[] = "$Id: debug.c,v 1.3 1995/05/30 03:49:13 rgrimes Exp $"; #endif /* not lint */ /* @@ -140,8 +140,6 @@ Fprint_query(msg, eom, printHeader,file) fprintf(file,", want recursion"); if (hp->ra) fprintf(file,", recursion avail."); - if (hp->pr) - fprintf(file,", primary"); fprintf(file,"\n\tquestions = %d", ntohs(hp->qdcount)); fprintf(file,", answers = %d", ntohs(hp->ancount)); fprintf(file,", authority records = %d", ntohs(hp->nscount)); @@ -335,6 +333,15 @@ Print_rr(cp, msg, eom, file) cp += INT16SZ; fprintf(file,", mail exchanger = "); 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); + fprintf(file,"\nX.400 = "); + cp = Print_cdname(cp, msg, eom, file); + (void) putc('\n', file); + break; case T_RT: fprintf(file,"\tpreference = %u",_getshort((u_char*)cp)); cp += INT16SZ; @@ -356,22 +363,24 @@ doname: break; case T_HINFO: + cp2 = cp + dlen; if (n = *cp++) { fprintf(file,"\tCPU = %.*s", n, cp); cp += n; } - if (n = *cp++) { + if ((cp < cp2) && (n = *cp++)) { fprintf(file,"\tOS = %.*s\n", n, cp); cp += n; - } + } else fprintf(file, "\n*** Warning *** OS-type missing\n"); break; case T_ISDN: + cp2 = cp + dlen; if (n = *cp++) { fprintf(file,"\tISDN = \"%.*s", n, cp); cp += n; } - if (n = *cp++) { + if ((cp < cp2) && (n = *cp++)) { fprintf(file,"-%.*s\"\n", n, cp); cp += n; } else fprintf(file,"\"\n"); @@ -427,7 +436,7 @@ doname: while (cp < cp2) { if (n = (unsigned char) *cp++) { for (c = n; c > 0 && cp < cp2; c--) - if (*cp == '\n') { + if ((*cp == '\n') || (*cp == '"')) { (void) putc('\\', file); (void) putc(*cp++, file); } else diff --git a/usr.sbin/nslookup/list.c b/usr.sbin/nslookup/list.c index bc187fad8ddc..da9c7e07fb8b 100644 --- a/usr.sbin/nslookup/list.c +++ b/usr.sbin/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 1.2 1994/09/22 21:50:34 pst Exp $"; +static char rcsid[] = "$Id: list.c,v 1.3 1995/05/30 03:49:15 rgrimes Exp $"; #endif /* not lint */ /* @@ -204,6 +204,8 @@ ListHosts(string, putToFile) qtype = T_HINFO; } else if (strcmp("-m", option) == 0) { qtype = T_MX; + } else if (strcmp("-p", option) == 0) { + qtype = T_PX; } else if (strcmp("-s", option) == 0) { qtype = T_WKS; } else if (strcmp("-d", option) == 0) { @@ -357,6 +359,9 @@ ListSubr(qtype, domain, cmd) 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; @@ -402,6 +407,9 @@ ListSubr(qtype, domain, cmd) 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; @@ -446,7 +454,7 @@ ListSubr(qtype, domain, cmd) * The server sent too much data to fit the existing buffer -- * allocate a new one. */ - if (len > answerLen) { + if (len > (u_int)answerLen) { if (answerLen != 0) { free(answer); } @@ -688,6 +696,7 @@ PrintListInfo(file, msg, eom, qtype, domain) case T_NS: case T_PTR: + case T_NSAP_PTR: putc(' ', file); if (qtype != T_ANY) fprintf(file,"%s = ", type == T_PTR ? "host" : "server"); @@ -696,16 +705,21 @@ PrintListInfo(file, msg, eom, qtype, domain) case T_HINFO: case T_ISDN: - if (n = *cp++) { - (void)sprintf(name,"%.*s", n, cp); - fprintf(file," %-10s", name); - cp += n; - } else { - fprintf(file," %-10s", " "); - } - if (n = *cp++) { - fprintf(file," %.*s", n, cp); - cp += n; + { + u_char *cp2 = cp + dlen; + if (n = *cp++) { + (void)sprintf(name,"%.*s", n, cp); + fprintf(file," %-10s", name); + cp += n; + } else { + fprintf(file," %-10s", " "); + } + if (cp == cp2) + break; + if (n = *cp++) { + fprintf(file," %.*s", n, cp); + cp += n; + } } break; @@ -748,6 +762,25 @@ PrintListInfo(file, msg, eom, qtype, domain) fprintf(file, " %s", name2); break; + case T_PX: + pref = _getshort((u_char*)cp); + cp += INT16SZ; + fprintf(file," %-3d ",pref); + nameLen = dn_expand(msg, eom, cp, name2, sizeof name2); + if (nameLen < 0) { + fprintf(file, " ***\n"); + return (ERROR); + } + fprintf(file, " %s", name2); + cp += strlen((char *)cp) + 1; + nameLen = dn_expand(msg, eom, cp, name2, sizeof name2); + if (nameLen < 0) { + fprintf(file, " ***\n"); + return (ERROR); + } + fprintf(file, " %s", name2); + break; + case T_TXT: case T_X25: { @@ -758,7 +791,7 @@ PrintListInfo(file, msg, eom, qtype, domain) while (cp < cp2) { if (n = (unsigned char) *cp++) { for (c = n; c > 0 && cp < cp2; c--) - if (*cp == '\n') { + if ((*cp == '\n') || (*cp == '"')) { (void) putc('\\', file); (void) putc(*cp++, file); } else diff --git a/usr.sbin/nslookup/nslookup.help b/usr.sbin/nslookup/nslookup.help index 09b689704771..00340e3cd391 100644 --- a/usr.sbin/nslookup/nslookup.help +++ b/usr.sbin/nslookup/nslookup.help @@ -1,4 +1,4 @@ -$Id: nslookup.help,v 8.2 1995/06/29 09:26:34 vixie Exp $ +$Id: nslookup.help,v 1.1.1.2 1995/08/18 22:31:32 peter Exp $ Commands: (identifiers are shown in uppercase, [] means optional) NAME - print info about the host/domain NAME using default server diff --git a/usr.sbin/nslookup/subr.c b/usr.sbin/nslookup/subr.c index 9f86d1502e9d..d7cca0e2a66a 100644 --- a/usr.sbin/nslookup/subr.c +++ b/usr.sbin/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 1.2 1994/09/22 21:50:41 pst Exp $"; +static char rcsid[] = "$Id: subr.c,v 1.3 1995/05/30 03:49:20 rgrimes Exp $"; #endif /* not lint */ /* @@ -372,7 +372,9 @@ DecodeError(result) 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; @@ -428,6 +430,8 @@ StringToType(type, dflt, errorfile) 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) @@ -474,6 +478,8 @@ StringToType(type, dflt, errorfile) 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 (errorfile) fprintf(errorfile, "unknown query type: %s\n", type); return(dflt); @@ -524,6 +530,8 @@ DecodeType(type) return("mailbox information"); case T_MX: return("mail exchanger"); + case T_PX: + return("mapping information"); case T_TXT: return("text"); case T_RP: @@ -538,6 +546,8 @@ DecodeType(type) 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: