integrate changes from bind 4.9 (most of them); continue to use address
[unix-history] / usr / src / lib / libc / net / res_debug.c
index bac8d0b..34096b2 100644 (file)
@@ -3,12 +3,30 @@
  * All rights reserved.
  *
  * %sccs.include.redist.c%
  * All rights reserved.
  *
  * %sccs.include.redist.c%
- *
- *     @(#)res_debug.c 5.36 (Berkeley) %G%
+ * -
+ * 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
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * --Copyright--
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)res_debug.c        5.36 (Berkeley) %G%";
+static char sccsid[] = "@(#)res_debug.c        5.37 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
@@ -21,7 +39,8 @@ static char sccsid[] = "@(#)res_debug.c       5.36 (Berkeley) %G%";
 
 void __fp_query();
 char *__p_class(), *__p_time(), *__p_type();
 
 void __fp_query();
 char *__p_class(), *__p_time(), *__p_type();
-static char *p_cdname(), *p_rr();
+char *p_cdname(), *p_fqname(), *p_rr();
+static char *p_option __P((u_int32_t));
 
 char *_res_opcodes[] = {
        "QUERY",
 
 char *_res_opcodes[] = {
        "QUERY",
@@ -61,10 +80,135 @@ char *_res_resultcodes[] = {
        "NOCHANGE",
 };
 
        "NOCHANGE",
 };
 
+static char retbuf[16];
+
+static char *
+dewks(wks)
+       int wks;
+{
+       switch (wks) {
+       case 5: return("rje");
+       case 7: return("echo");
+       case 9: return("discard");
+       case 11: return("systat");
+       case 13: return("daytime");
+       case 15: return("netstat");
+       case 17: return("qotd");
+       case 19: return("chargen");
+       case 20: return("ftp-data");
+       case 21: return("ftp");
+       case 23: return("telnet");
+       case 25: return("smtp");
+       case 37: return("time");
+       case 39: return("rlp");
+       case 42: return("name");
+       case 43: return("whois");
+       case 53: return("domain");
+       case 57: return("apts");
+       case 59: return("apfs");
+       case 67: return("bootps");
+       case 68: return("bootpc");
+       case 69: return("tftp");
+       case 77: return("rje");
+       case 79: return("finger");
+       case 87: return("link");
+       case 95: return("supdup");
+       case 100: return("newacct");
+       case 101: return("hostnames");
+       case 102: return("iso-tsap");
+       case 103: return("x400");
+       case 104: return("x400-snd");
+       case 105: return("csnet-ns");
+       case 109: return("pop-2");
+       case 111: return("sunrpc");
+       case 113: return("auth");
+       case 115: return("sftp");
+       case 117: return("uucp-path");
+       case 119: return("nntp");
+       case 121: return("erpc");
+       case 123: return("ntp");
+       case 133: return("statsrv");
+       case 136: return("profile");
+       case 144: return("NeWS");
+       case 161: return("snmp");
+       case 162: return("snmp-trap");
+       case 170: return("print-srv");
+       default: (void) sprintf(retbuf, "%d", wks); return(retbuf);
+       }
+}
+
+static char *
+deproto(protonum)
+       int protonum;
+{
+       switch (protonum) {
+       case 1: return("icmp");
+       case 2: return("igmp");
+       case 3: return("ggp");
+       case 5: return("st");
+       case 6: return("tcp");
+       case 7: return("ucl");
+       case 8: return("egp");
+       case 9: return("igp");
+       case 11: return("nvp-II");
+       case 12: return("pup");
+       case 16: return("chaos");
+       case 17: return("udp");
+       default: (void) sprintf(retbuf, "%d", protonum); return(retbuf);
+       }
+}
+
+static char *
+do_rrset(msg, cp, cnt, pflag, file, hs)
+       int cnt, pflag;
+       char *cp,*msg, *hs;
+       FILE *file;
+{
+       int n;
+       int sflag;
+       /*
+        * Print  answer records
+        */
+       sflag = (_res.pfcode & pflag);
+       if (n = ntohs(cnt)) {
+               if ((!_res.pfcode) || ((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
+                       fprintf(file, hs);
+               while (--n >= 0) {
+                       cp = p_rr(cp, msg, file);
+                       if ((cp-msg) > PACKETSZ)
+                               return (NULL);
+               }
+               if ((!_res.pfcode) || ((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
+                       putc('\n', file);
+       }
+       return(cp);
+}
+
 __p_query(msg)
        char *msg;
 {
 __p_query(msg)
        char *msg;
 {
-       __fp_query(msg,stdout);
+       __fp_query(msg, stdout);
+}
+
+/*
+ * Print the current options.
+ * This is intended to be primarily a debugging routine.
+ */
+void
+__fp_resstat(statp, file)
+       struct __res_state *statp;
+       FILE *file;
+{
+       int bit;
+
+       fprintf(file, ";; res options:");
+       if (!statp)
+               statp = &_res;
+       for (bit = 0;  bit < 32;  bit++) {      /* XXX 32 - bad assumption! */
+               if (statp->options & (1<<bit))
+                       fprintf(file, " %s", p_option(1<<bit));
+       }
+       putc('\n', file);
 }
 
 /*
 }
 
 /*
@@ -85,83 +229,87 @@ __fp_query(msg,file)
         */
        hp = (HEADER *)msg;
        cp = msg + sizeof(HEADER);
         */
        hp = (HEADER *)msg;
        cp = msg + sizeof(HEADER);
-       fprintf(file,"HEADER:\n");
-       fprintf(file,"\topcode = %s", _res_opcodes[hp->opcode]);
-       fprintf(file,", id = %d", ntohs(hp->id));
-       fprintf(file,", rcode = %s\n", _res_resultcodes[hp->rcode]);
-       fprintf(file,"\theader flags: ");
-       if (hp->qr)
-               fprintf(file," qr");
-       if (hp->aa)
-               fprintf(file," aa");
-       if (hp->tc)
-               fprintf(file," tc");
-       if (hp->rd)
-               fprintf(file," rd");
-       if (hp->ra)
-               fprintf(file," ra");
-       if (hp->pr)
-               fprintf(file," pr");
-       fprintf(file,"\n\tqdcount = %d", ntohs(hp->qdcount));
-       fprintf(file,", ancount = %d", ntohs(hp->ancount));
-       fprintf(file,", nscount = %d", ntohs(hp->nscount));
-       fprintf(file,", arcount = %d\n\n", ntohs(hp->arcount));
+       if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX) || hp->rcode) {
+               fprintf(file,";; ->>HEADER<<- opcode: %s, status: %s, id: %d",
+                       _res_opcodes[hp->opcode],
+                       _res_resultcodes[hp->rcode],
+                       ntohs(hp->id));
+               putc('\n', file);
+       }
+       putc(';', file);
+       if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD2)) {
+               fprintf(file,"; flags:");
+               if (hp->qr)
+                       fprintf(file," qr");
+               if (hp->aa)
+                       fprintf(file," aa");
+               if (hp->tc)
+                       fprintf(file," tc");
+               if (hp->rd)
+                       fprintf(file," rd");
+               if (hp->ra)
+                       fprintf(file," ra");
+               if (hp->pr)
+                       fprintf(file," pr");
+       }
+       if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD1)) {
+               fprintf(file,"; Ques: %d", ntohs(hp->qdcount));
+               fprintf(file,", Ans: %d", ntohs(hp->ancount));
+               fprintf(file,", Auth: %d", ntohs(hp->nscount));
+               fprintf(file,", Addit: %d\n", ntohs(hp->arcount));
+       }
+#if 0
+       if (_res.pfcode & (RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1)) {
+               putc('\n',file);
+       }
+#endif
        /*
         * Print question records.
         */
        if (n = ntohs(hp->qdcount)) {
        /*
         * Print question records.
         */
        if (n = ntohs(hp->qdcount)) {
-               fprintf(file,"QUESTIONS:\n");
+               if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
+                       fprintf(file,";; QUESTIONS:\n");
                while (--n >= 0) {
                while (--n >= 0) {
-                       fprintf(file,"\t");
+                       fprintf(file,";;\t");
                        cp = p_cdname(cp, msg, file);
                        if (cp == NULL)
                                return;
                        cp = p_cdname(cp, msg, file);
                        if (cp == NULL)
                                return;
-                       fprintf(file,", type = %s", __p_type(_getshort(cp)));
-                       cp += sizeof(u_short);
-                       fprintf(file,
-                           ", class = %s\n\n", __p_class(_getshort(cp)));
-                       cp += sizeof(u_short);
+                       if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
+                               fprintf(file, ", type = %s",
+                                       __p_type(_getshort(cp)));
+                       cp += sizeof(u_int16_t);
+                       if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
+                               fprintf(file, ", class = %s\n\n",
+                                       __p_class(_getshort(cp)));
+                       cp += sizeof(u_int16_t);
                }
        }
        /*
         * Print authoritative answer records
         */
                }
        }
        /*
         * Print authoritative answer records
         */
-       if (n = ntohs(hp->ancount)) {
-               fprintf(file,"ANSWERS:\n");
-               while (--n >= 0) {
-                       fprintf(file,"\t");
-                       cp = p_rr(cp, msg, file);
-                       if (cp == NULL)
-                               return;
-               }
-       }
+       cp = do_rrset(msg, cp, hp->ancount, RES_PRF_ANS, file,
+                     ";; ANSWERS:\n");
+       if (cp == NULL)
+               return;
+
        /*
         * print name server records
         */
        /*
         * print name server records
         */
-       if (n = ntohs(hp->nscount)) {
-               fprintf(file,"NAME SERVERS:\n");
-               while (--n >= 0) {
-                       fprintf(file,"\t");
-                       cp = p_rr(cp, msg, file);
-                       if (cp == NULL)
-                               return;
-               }
-       }
+       cp = do_rrset(msg, cp, hp->nscount, RES_PRF_AUTH, file,
+                     ";; AUTHORITY RECORDS:\n");
+       if (!cp)
+               return;
+
        /*
         * print additional records
         */
        /*
         * print additional records
         */
-       if (n = ntohs(hp->arcount)) {
-               fprintf(file,"ADDITIONAL RECORDS:\n");
-               while (--n >= 0) {
-                       fprintf(file,"\t");
-                       cp = p_rr(cp, msg, file);
-                       if (cp == NULL)
-                               return;
-               }
-       }
+       cp = do_rrset(msg, cp, hp->arcount, RES_PRF_ADD, file,
+                     ";; ADDITIONAL RECORDS:\n");
+       if (!cp)
+               return;
 }
 
 }
 
-static char *
+char *
 p_cdname(cp, msg, file)
        char *cp, *msg;
        FILE *file;
 p_cdname(cp, msg, file)
        char *cp, *msg;
        FILE *file;
@@ -169,21 +317,41 @@ p_cdname(cp, msg, file)
        char name[MAXDNAME];
        int n;
 
        char name[MAXDNAME];
        int n;
 
-       if ((n = dn_expand((u_char *)msg, (u_char *)msg + 512, (u_char *)cp,
-           (u_char *)name, sizeof(name))) < 0)
+       if ((n = dn_expand((u_char *)msg, (u_char *)msg + MAXCDNAME,
+           (u_char *)cp, (u_char *)name, sizeof(name))) < 0)
+               return (NULL);
+       if (name[0] == '\0')
+               putc('.', file);
+       else
+               fputs(name, file);
+       return (cp + n);
+}
+
+char *
+p_fqname(cp, msg, file)
+       char *cp, *msg;
+       FILE *file;
+{
+       char name[MAXDNAME];
+       int n, len;
+
+       if ((n = dn_expand((u_char *)msg, (u_char *)msg + MAXCDNAME,
+           (u_char *)cp, (u_char *)name, sizeof(name))) < 0)
                return (NULL);
        if (name[0] == '\0') {
                return (NULL);
        if (name[0] == '\0') {
-               name[0] = '.';
-               name[1] = '\0';
+               putc('.', file);
+       } else {
+               fputs(name, file);
+               if (name[strlen(name) - 1] != '.')
+                       putc('.', file);
        }
        }
-       fputs(name, file);
        return (cp + n);
 }
 
 /*
  * Print resource record fields in human readable form.
  */
        return (cp + n);
 }
 
 /*
  * Print resource record fields in human readable form.
  */
-static char *
+char *
 p_rr(cp, msg, file)
        char *cp, *msg;
        FILE *file;
 p_rr(cp, msg, file)
        char *cp, *msg;
        FILE *file;
@@ -191,18 +359,25 @@ p_rr(cp, msg, file)
        int type, class, dlen, n, c;
        struct in_addr inaddr;
        char *cp1, *cp2;
        int type, class, dlen, n, c;
        struct in_addr inaddr;
        char *cp1, *cp2;
+       u_int32_t tmpttl, t;
+       int lcnt;
 
 
-       if ((cp = p_cdname(cp, msg, file)) == NULL)
+       if ((cp = p_fqname(cp, msg, file)) == NULL)
                return (NULL);                  /* compression error */
                return (NULL);                  /* compression error */
-       fprintf(file,"\n\ttype = %s", __p_type(type = _getshort(cp)));
-       cp += sizeof(u_short);
-       fprintf(file,", class = %s", __p_class(class = _getshort(cp)));
-       cp += sizeof(u_short);
-       fprintf(file,", ttl = %s", __p_time(_getlong(cp)));
-       cp += sizeof(u_long);
-       fprintf(file,", dlen = %d\n", dlen = _getshort(cp));
-       cp += sizeof(u_short);
+       type = _getshort(cp);
+       cp += sizeof(u_int16_t);
+       class = _getshort(cp);
+       cp += sizeof(u_int16_t);
+       tmpttl = _getlong(cp);
+       cp += sizeof(u_int32_t);
+       dlen = _getshort(cp);
+       cp += sizeof(u_int16_t);
        cp1 = cp;
        cp1 = cp;
+       if ((!_res.pfcode) || (_res.pfcode & RES_PRF_TTLID))
+               fprintf(file, "\t%lu", tmpttl);
+       if ((!_res.pfcode) || (_res.pfcode & RES_PRF_CLASS))
+               fprintf(file, "\t%s", __p_class(class));
+       fprintf(file, "\t%s", __p_type(type));
        /*
         * Print type specific data, if appropriate
         */
        /*
         * Print type specific data, if appropriate
         */
@@ -213,16 +388,21 @@ p_rr(cp, msg, file)
                case C_HS:
                        bcopy(cp, (char *)&inaddr, sizeof(inaddr));
                        if (dlen == 4) {
                case C_HS:
                        bcopy(cp, (char *)&inaddr, sizeof(inaddr));
                        if (dlen == 4) {
-                               fprintf(file,"\tinternet address = %s\n",
-                                       inet_ntoa(inaddr));
+                               fprintf(file,"\t%s", inet_ntoa(inaddr));
                                cp += dlen;
                        } else if (dlen == 7) {
                                cp += dlen;
                        } else if (dlen == 7) {
-                               fprintf(file,"\tinternet address = %s",
-                                       inet_ntoa(inaddr));
-                               fprintf(file,", protocol = %d", cp[4]);
-                               fprintf(file,", port = %d\n",
-                                       (cp[5] << 8) + cp[6]);
-                               cp += dlen;
+                               char *address;
+                               u_char protocol;
+                               u_short port;
+
+                               address = inet_ntoa(inaddr);
+                               cp += sizeof(inaddr);
+                               protocol = *(u_char*)cp;
+                               cp += sizeof(u_char);
+                               port = _getshort(cp);
+                               cp += sizeof(u_int16_t);
+                               fprintf(file, "\t%s\t; proto %d, port %d",
+                                       address, protocol, port);
                        }
                        break;
                default:
                        }
                        break;
                default:
@@ -235,44 +415,43 @@ p_rr(cp, msg, file)
        case T_MR:
        case T_NS:
        case T_PTR:
        case T_MR:
        case T_NS:
        case T_PTR:
-               fprintf(file,"\tdomain name = ");
-               cp = p_cdname(cp, msg, file);
-               fprintf(file,"\n");
+               putc('\t', file);
+               cp = p_fqname(cp, msg, file);
                break;
 
        case T_HINFO:
                if (n = *cp++) {
                break;
 
        case T_HINFO:
                if (n = *cp++) {
-                       fprintf(file,"\tCPU=%.*s\n", n, cp);
+                       fprintf(file,"\t%.*s", n, cp);
                        cp += n;
                }
                if (n = *cp++) {
                        cp += n;
                }
                if (n = *cp++) {
-                       fprintf(file,"\tOS=%.*s\n", n, cp);
+                       fprintf(file,"\t%.*s", n, cp);
                        cp += n;
                }
                break;
 
        case T_SOA:
                        cp += n;
                }
                break;
 
        case T_SOA:
-               fprintf(file,"\torigin = ");
-               cp = p_cdname(cp, msg, file);
-               fprintf(file,"\n\tmail addr = ");
-               cp = p_cdname(cp, msg, file);
-               fprintf(file,"\n\tserial = %ld", _getlong(cp));
-               cp += sizeof(u_long);
-               fprintf(file,"\n\trefresh = %s", __p_time(_getlong(cp)));
-               cp += sizeof(u_long);
-               fprintf(file,"\n\tretry = %s", __p_time(_getlong(cp)));
-               cp += sizeof(u_long);
-               fprintf(file,"\n\texpire = %s", __p_time(_getlong(cp)));
-               cp += sizeof(u_long);
-               fprintf(file,"\n\tmin = %s\n", __p_time(_getlong(cp)));
-               cp += sizeof(u_long);
+               putc('\t', file);
+               cp = p_fqname(cp, msg, file);   /* origin */
+               putc(' ', file);
+               cp = p_fqname(cp, msg, file);   /* mail addr */
+               fputs(" (\n", file);
+               t = _getlong(cp);  cp += sizeof(u_int32_t);
+               fprintf(file,"\t\t\t%lu\t; serial\n", t);
+               t = _getlong(cp);  cp += sizeof(u_int32_t);
+               fprintf(file,"\t\t\t%lu\t; refresh (%s)\n", t, __p_time(t));
+               t = _getlong(cp);  cp += sizeof(u_int32_t);
+               fprintf(file,"\t\t\t%lu\t; retry (%s)\n", t, __p_time(t));
+               t = _getlong(cp);  cp += sizeof(u_int32_t);
+               fprintf(file,"\t\t\t%lu\t; expire (%s)\n", t, __p_time(t));
+               t = _getlong(cp);  cp += sizeof(u_int32_t);
+               fprintf(file,"\t\t\t%lu )\t; minimum (%s)", t, __p_time(t));
                break;
 
        case T_MX:
                break;
 
        case T_MX:
-               fprintf(file,"\tpreference = %ld,",_getshort(cp));
-               cp += sizeof(u_short);
-               fprintf(file," name = ");
-               cp = p_cdname(cp, msg, file);
+               fprintf(file,"\t%d ", _getshort(cp));
+               cp += sizeof(u_int16_t);
+               cp = p_fqname(cp, msg, file);
                break;
 
        case T_TXT:
                break;
 
        case T_TXT:
@@ -288,46 +467,58 @@ p_rr(cp, msg, file)
                                            (void) putc(*cp++, file);
                        }
                }
                                            (void) putc(*cp++, file);
                        }
                }
-               (void) fputs("\"\n", file);
+               putc('"', file);
                break;
 
        case T_MINFO:
                break;
 
        case T_MINFO:
-               fprintf(file,"\trequests = ");
-               cp = p_cdname(cp, msg, file);
-               fprintf(file,"\n\terrors = ");
-               cp = p_cdname(cp, msg, file);
+       case T_RP:
+               putc('\t', file);
+               cp = p_fqname(cp, msg, file);
+               putc(' ', file);
+               cp = p_fqname(cp, msg, file);
                break;
 
        case T_UINFO:
                break;
 
        case T_UINFO:
-               fprintf(file,"\t%s\n", cp);
+               putc('\t', file);
+               fputs(cp, file);
                cp += dlen;
                break;
 
        case T_UID:
        case T_GID:
                if (dlen == 4) {
                cp += dlen;
                break;
 
        case T_UID:
        case T_GID:
                if (dlen == 4) {
-                       fprintf(file,"\t%ld\n", _getlong(cp));
-                       cp += sizeof(int);
+                       fprintf(file,"\t%u", _getlong(cp));
+                       cp += sizeof(int32_t);
                }
                break;
 
        case T_WKS:
                }
                break;
 
        case T_WKS:
-               if (dlen < sizeof(u_long) + 1)
+               if (dlen < sizeof(u_int32_t) + 1)
                        break;
                bcopy(cp, (char *)&inaddr, sizeof(inaddr));
                        break;
                bcopy(cp, (char *)&inaddr, sizeof(inaddr));
-               cp += sizeof(u_long);
-               fprintf(file,"\tinternet address = %s, protocol = %d\n\t",
-                       inet_ntoa(inaddr), *cp++);
+               cp += sizeof(u_int32_t);
+               fprintf(file, "\t%s %s ( ",
+                       inet_ntoa(inaddr),
+                       deproto((int) *cp));
+               cp += sizeof(u_char);
                n = 0;
                n = 0;
+               lcnt = 0;
                while (cp < cp1 + dlen) {
                        c = *cp++;
                        do {
                while (cp < cp1 + dlen) {
                        c = *cp++;
                        do {
-                               if (c & 0200)
-                                       fprintf(file," %d", n);
+                               if (c & 0200) {
+                                       if (lcnt == 0) {
+                                               fputs("\n\t\t\t", file);
+                                               lcnt = 5;
+                                       }
+                                       fputs(dewks(n), file);
+                                       putc(' ', file);
+                                       lcnt--;
+                               }
                                c <<= 1;
                        } while (++n & 07);
                }
                                c <<= 1;
                        } while (++n & 07);
                }
-               putc('\n',file);
+               putc(')', file);
                break;
 
 #ifdef ALLOW_T_UNSPEC
                break;
 
 #ifdef ALLOW_T_UNSPEC
@@ -342,21 +533,25 @@ p_rr(cp, msg, file)
                                NumBytes);
                        for (i = 0, DataPtr = cp; i < NumBytes; i++, DataPtr++)
                                fprintf(file, " %x", *DataPtr);
                                NumBytes);
                        for (i = 0, DataPtr = cp; i < NumBytes; i++, DataPtr++)
                                fprintf(file, " %x", *DataPtr);
-                       fputs("\n", file);
                        cp += dlen;
                }
                break;
 #endif /* ALLOW_T_UNSPEC */
 
        default:
                        cp += dlen;
                }
                break;
 #endif /* ALLOW_T_UNSPEC */
 
        default:
-               fprintf(file,"\t???\n");
+               fprintf(file,"\t?%d?", type);
                cp += dlen;
        }
                cp += dlen;
        }
-       if (cp != cp1 + dlen) {
-               fprintf(file,"packet size error (%#x != %#x)\n", cp, cp1+dlen);
+#if 0
+       fprintf(file, "\t; dlen=%d, ttl %s\n", dlen, __p_time(tmpttl));
+#else
+       putc('\n', file);
+#endif
+       if (cp - cp1 != dlen) {
+               fprintf(file,";; packet size error (found %d, dlen was %d)\n",
+                       cp - cp1, dlen);
                cp = NULL;
        }
                cp = NULL;
        }
-       fprintf(file,"\n");
        return (cp);
 }
 
        return (cp);
 }
 
@@ -398,6 +593,8 @@ __p_type(type)
                return("MX");
        case T_TXT:             /* text */
                return("TXT");
                return("MX");
        case T_TXT:             /* text */
                return("TXT");
+       case T_RP:              /* responsible person */
+               return("RP");
        case T_AXFR:            /* zone transfer */
                return("AXFR");
        case T_MAILB:           /* mail box */
        case T_AXFR:            /* zone transfer */
                return("AXFR");
        case T_MAILB:           /* mail box */
@@ -443,14 +640,36 @@ __p_class(class)
        }
 }
 
        }
 }
 
+/*
+ * Return a mnemonic for an option
+ */
+static char *
+p_option(option)
+       u_int32_t option;
+{
+       switch (option) {
+       case RES_INIT:          return "init";
+       case RES_DEBUG:         return "debug";
+       case RES_AAONLY:        return "aaonly";
+       case RES_USEVC:         return "usevc";
+       case RES_PRIMARY:       return "primry";
+       case RES_IGNTC:         return "igntc";
+       case RES_RECURSE:       return "recurs";
+       case RES_DEFNAMES:      return "defnam";
+       case RES_STAYOPEN:      return "styopn";
+       case RES_DNSRCH:        return "dnsrch";
+       default:                sprintf(nbuf, "?0x%x?", option); return nbuf;
+       }
+}
+
 /*
  * Return a mnemonic for a time to live
  */
 char *
 __p_time(value)
 /*
  * Return a mnemonic for a time to live
  */
 char *
 __p_time(value)
-       u_long value;
+       u_int32_t value;
 {
 {
-       int secs, mins, hours;
+       int secs, mins, hours, days;
        register char *p;
 
        if (value == 0) {
        register char *p;
 
        if (value == 0) {
@@ -464,27 +683,29 @@ __p_time(value)
        value /= 60;
        hours = value % 24;
        value /= 24;
        value /= 60;
        hours = value % 24;
        value /= 24;
+       days = value;
+       value = 0;
 
 #define        PLURALIZE(x)    x, (x == 1) ? "" : "s"
        p = nbuf;
 
 #define        PLURALIZE(x)    x, (x == 1) ? "" : "s"
        p = nbuf;
-       if (value) {
-               (void)sprintf(p, "%d day%s", PLURALIZE(value));
+       if (days) {
+               (void)sprintf(p, "%d day%s", PLURALIZE(days));
                while (*++p);
        }
        if (hours) {
                while (*++p);
        }
        if (hours) {
-               if (value)
+               if (days)
                        *p++ = ' ';
                (void)sprintf(p, "%d hour%s", PLURALIZE(hours));
                while (*++p);
        }
        if (mins) {
                        *p++ = ' ';
                (void)sprintf(p, "%d hour%s", PLURALIZE(hours));
                while (*++p);
        }
        if (mins) {
-               if (value || hours)
+               if (days || hours)
                        *p++ = ' ';
                (void)sprintf(p, "%d min%s", PLURALIZE(mins));
                while (*++p);
        }
                        *p++ = ' ';
                (void)sprintf(p, "%d min%s", PLURALIZE(mins));
                while (*++p);
        }
-       if (secs || ! (value || hours || mins)) {
-               if (value || hours || mins)
+       if (secs || ! (days || hours || mins)) {
+               if (days || hours || mins)
                        *p++ = ' ';
                (void)sprintf(p, "%d sec%s", PLURALIZE(secs));
        }
                        *p++ = ' ';
                (void)sprintf(p, "%d sec%s", PLURALIZE(secs));
        }