summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/res_debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/net/res_debug.c')
-rw-r--r--lib/libc/net/res_debug.c153
1 files changed, 80 insertions, 73 deletions
diff --git a/lib/libc/net/res_debug.c b/lib/libc/net/res_debug.c
index aff28a4..b0a82b2 100644
--- a/lib/libc/net/res_debug.c
+++ b/lib/libc/net/res_debug.c
@@ -1,9 +1,7 @@
-/*
- * ++Copyright++ 1985, 1990, 1993
- * -
+/*-
* Copyright (c) 1985, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
+ * The Regents of the University of California. All rights reserved.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -14,12 +12,12 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -33,14 +31,14 @@
* SUCH DAMAGE.
* -
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
+ *
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
@@ -55,29 +53,59 @@
#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 8.7 1995/12/22 10:20:39 vixie Exp $";
+static char rcsid[] = "$Id: res_debug.c,v 1.4 1995/08/20 20:02:48 peter Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <netinet/in.h>
+#include <netiso/iso.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <stdio.h>
-#include <netdb.h>
#include <resolv.h>
-#if defined(BSD) && (BSD >= 199103)
-# include <string.h>
-#else
-# include "../conf/portability.h"
-#endif
-
-#if defined(USE_OPTIONS_H)
-# include "../conf/options.h"
-#endif
+#include <string.h>
+#include <netdb.h>
-extern const char *_res_opcodes[];
-extern const char *_res_resultcodes[];
+#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",
+};
/* XXX: we should use getservbyport() instead. */
static const char *
@@ -175,13 +203,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);
@@ -209,18 +237,6 @@ __p_query(msg)
__fp_query(msg, stdout);
}
-#ifdef ultrix
-/* ultrix 4.0's packaging has some icky packaging. alias for it here.
- * there is more junk of this kind over in res_comp.c.
- */
-void
-p_query(msg)
- const u_char *msg;
-{
- __p_query(msg);
-}
-#endif
-
/*
* Print the current options.
* This is intended to be primarily a debugging routine.
@@ -274,10 +290,9 @@ __fp_nquery(msg, len, file)
ntohs(hp->id));
putc('\n', file);
}
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX))
- putc(';', file);
+ 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)
@@ -295,7 +310,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);
}
@@ -304,23 +319,11 @@ __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) {
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
- fprintf(file, ";;\t");
+ fprintf(file,";;\t");
TruncTest(cp);
- 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;
- }
+ cp = p_cdnname(cp, msg, len, file);
ErrorTest(cp);
TruncTest(cp);
if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
@@ -332,8 +335,7 @@ __fp_nquery(msg, len, file)
fprintf(file, ", class = %s\n",
__p_class(_getshort((u_char*)cp)));
cp += INT16SZ;
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
- putc('\n', file);
+ putc('\n', file);
}
}
/*
@@ -434,6 +436,7 @@ __p_rr(cp, msg, file)
{
int type, class, dlen, n, c;
struct in_addr inaddr;
+ struct iso_addr isoa;
const u_char *cp1, *cp2;
u_int32_t tmpttl, t;
int lcnt;
@@ -468,7 +471,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;
@@ -504,11 +507,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");
@@ -541,7 +544,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);
@@ -557,7 +560,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;
@@ -572,12 +575,16 @@ __p_rr(cp, msg, file)
}
}
putc('"', file);
- break;
-
- case T_NSAP:
- (void) fprintf(file, "\t%s", inet_nsap_ntoa(dlen, cp, NULL));
+ break;
+
+ case T_NSAP:
+ isoa.isoa_len = dlen;
+ if (isoa.isoa_len > sizeof(isoa.isoa_genaddr))
+ isoa.isoa_len = sizeof(isoa.isoa_genaddr);
+ bcopy(cp, isoa.isoa_genaddr, isoa.isoa_len);
+ (void) fprintf(file, "\t%s", iso_ntoa(&isoa));
cp += dlen;
- break;
+ break;
case T_MINFO:
case T_RP:
@@ -598,7 +605,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;
@@ -617,7 +624,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;
@@ -626,7 +633,7 @@ __p_rr(cp, msg, file)
putc(' ', file);
lcnt--;
}
- c <<= 1;
+ c <<= 1;
} while (++n & 07);
}
putc(')', file);
@@ -650,7 +657,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
@@ -659,7 +666,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;
}
OpenPOWER on IntegriCloud