diff options
Diffstat (limited to 'lib/libc/net/res_debug.c')
-rw-r--r-- | lib/libc/net/res_debug.c | 102 |
1 files changed, 58 insertions, 44 deletions
diff --git a/lib/libc/net/res_debug.c b/lib/libc/net/res_debug.c index 9f4d6569e6d2..74aef85b538f 100644 --- a/lib/libc/net/res_debug.c +++ b/lib/libc/net/res_debug.c @@ -58,22 +58,54 @@ static char rcsid[] = "$Id: res_debug.c,v 1.3.4.1 1995/08/30 04:06:48 davidg Exp #include <sys/param.h> #include <netinet/in.h> -#ifdef ISO #include <netiso/iso.h> -#endif - #include <arpa/inet.h> #include <arpa/nameser.h> #include <stdio.h> -#include <netdb.h> #include <resolv.h> #include <string.h> +#include <netdb.h> #include "res_config.h" -extern const char *_res_opcodes[]; -extern const char *_res_resultcodes[]; +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 * @@ -171,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); @@ -258,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) @@ -279,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); } @@ -288,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)) @@ -316,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); } } /* @@ -418,9 +436,7 @@ __p_rr(cp, msg, file) { int type, class, dlen, n, c; struct in_addr inaddr; -#ifdef ISO struct iso_addr isoa; -#endif const u_char *cp1, *cp2; u_int32_t tmpttl, t; int lcnt; @@ -455,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; @@ -491,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"); @@ -528,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); @@ -544,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; @@ -559,9 +575,8 @@ __p_rr(cp, msg, file) } } putc('"', file); - break; + break; -#ifdef ISO case T_NSAP: isoa.isoa_len = dlen; if (isoa.isoa_len > sizeof(isoa.isoa_genaddr)) @@ -570,7 +585,6 @@ __p_rr(cp, msg, file) (void) fprintf(file, "\t%s", iso_ntoa(&isoa)); cp += dlen; break; -#endif case T_MINFO: case T_RP: @@ -591,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; @@ -610,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; @@ -619,7 +633,7 @@ __p_rr(cp, msg, file) putc(' ', file); lcnt--; } - c <<= 1; + c <<= 1; } while (++n & 07); } putc(')', file); @@ -643,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 @@ -652,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; } |