static char sccsid
[] = "@(#)res_debug.c 4.3 (Berkeley) %G%";
extern char *p_cdname(), *p_rr(), *p_type(), *p_class();
extern char *inet_ntoa();
* Print the contents of a query.
* This is intended to be primarily a debugging routine.
cp
= msg
+ sizeof(HEADER
);
printf("\topcode = %s", opcodes
[hp
->opcode
]);
printf(", id = %d", ntohs(hp
->id
));
printf(", rcode = %s\n", rcodes
[hp
->rcode
]);
printf("\theader flags: ");
printf("\n\tqdcount = %d", ntohs(hp
->qdcount
));
printf(", ancount = %d", ntohs(hp
->ancount
));
printf(", nscount = %d", ntohs(hp
->nscount
));
printf(", arcount = %d\n\n", ntohs(hp
->arcount
));
* Print question records.
if (n
= ntohs(hp
->qdcount
)) {
printf(", type = %s", p_type(getshort(cp
)));
printf(", class = %s\n\n", p_class(getshort(cp
)));
* Print authoritative answer records
if (n
= ntohs(hp
->ancount
)) {
* print name server records
if (n
= ntohs(hp
->nscount
)) {
printf("NAME SERVERS:\n");
* print additional records
if (n
= ntohs(hp
->arcount
)) {
printf("ADDITIONAL RECORDS:\n");
if ((n
= dn_expand(msg
, cp
, name
, sizeof(name
))) < 0)
* Print resource record fields in human readable form.
int type
, class, dlen
, n
, c
;
if ((cp
= p_cdname(cp
, msg
)) == NULL
)
return (NULL
); /* compression error */
printf("\n\ttype = %s", p_type(type
= getshort(cp
)));
printf(", class = %s", p_class(class = getshort(cp
)));
printf(", ttl = %ld", getlong(cp
));
printf(", dlen = %d\n", dlen
= getshort(cp
));
* Print type specific data, if appropriate
bcopy(cp
, (char *)&inaddr
, sizeof(inaddr
));
printf("\tinternet address = %s\n",
printf("\tinternet address = %s",
printf(", protocol = %d", cp
[4]);
printf("\tdomain name = ");
printf("\tCPU=%.*s\n", n
, cp
);
printf("\tOS=%.*s\n", n
, cp
);
printf("\n\tmail addr = ");
printf("\n\tserial=%ld", getlong(cp
));
printf(", refresh=%ld", getlong(cp
));
printf(", retry=%ld", getlong(cp
));
printf(", expire=%ld", getlong(cp
));
printf(", min=%ld\n", getlong(cp
));
printf("\t%ld\n", getlong(cp
));
if (dlen
< sizeof(u_long
) + 1)
bcopy(cp
, (char *)&inaddr
, sizeof(inaddr
));
printf("\tinternet address = %s, protocol = %d\n\t",
inet_ntoa(inaddr
), *cp
++);
while (cp
< cp1
+ dlen
) {
printf("packet size error (%#x != %#x)\n", cp
, cp1
+dlen
);
* Return a string for the type
case T_NS
: /* authoritative server */
case T_MD
: /* mail destination */
case T_MF
: /* mail forwarder */
case T_CNAME
: /* connonical name */
case T_SOA
: /* start of authority zone */
case T_MB
: /* mailbox domain name */
case T_MG
: /* mail group member */
case T_MR
: /* mail rename name */
case T_NULL
: /* null resource record */
case T_WKS
: /* well known service */
case T_PTR
: /* domain name pointer */
case T_HINFO
: /* host information */
case T_MINFO
: /* mailbox information */
case T_AXFR
: /* zone transfer */
case T_MAILB
: /* mail box */
case T_MAILA
: /* mail address */
case T_ANY
: /* matches any type */
return (sprintf(nbuf
, "%d", type
));
* Return a mnemonic for class
case C_IN
: /* internet class */
case C_CS
: /* csnet class */
case C_ANY
: /* matches any class */
return (sprintf(nbuf
, "%d", class));