diff options
Diffstat (limited to 'lib/libc/net/res_debug.c')
-rw-r--r-- | lib/libc/net/res_debug.c | 97 |
1 files changed, 38 insertions, 59 deletions
diff --git a/lib/libc/net/res_debug.c b/lib/libc/net/res_debug.c index b0a82b2..af80833 100644 --- a/lib/libc/net/res_debug.c +++ b/lib/libc/net/res_debug.c @@ -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; } |