diff --git a/bin/tests/printmsg.c b/bin/tests/printmsg.c index 9ec3544ff6..f872af9cdd 100644 --- a/bin/tests/printmsg.c +++ b/bin/tests/printmsg.c @@ -15,8 +15,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: printmsg.c,v 1.31 2011/08/25 23:46:42 tbox Exp $ */ - #include #include @@ -24,49 +22,12 @@ #include #include +#include +#include #include #include "printmsg.h" -static const char *opcodetext[] = { - "QUERY", - "IQUERY", - "STATUS", - "RESERVED3", - "NOTIFY", - "UPDATE", - "RESERVED6", - "RESERVED7", - "RESERVED8", - "RESERVED9", - "RESERVED10", - "RESERVED11", - "RESERVED12", - "RESERVED13", - "RESERVED14", - "RESERVED15" -}; - -static const char *rcodetext[] = { - "NOERROR", - "FORMERR", - "SERVFAIL", - "NXDOMAIN", - "NOTIMP", - "REFUSED", - "YXDOMAIN", - "YXRRSET", - "NXRRSET", - "NOTAUTH", - "NOTZONE", - "RESERVED11", - "RESERVED12", - "RESERVED13", - "RESERVED14", - "RESERVED15", - "BADVERS" -}; - static isc_result_t printsection(dns_message_t *msg, dns_section_t sectionid, const char *section_name) @@ -167,11 +128,21 @@ printmessage(dns_message_t *msg) { isc_result_t result; dns_rdataset_t *opt, *tsig; dns_name_t *tsigname; + char opcode[64], rcode[64]; + isc_buffer_t b; result = ISC_R_SUCCESS; + isc_buffer_init(&b, opcode, sizeof(opcode)); + dns_opcode_totext(msg->opcode, &b); + isc_buffer_putuint8(&b, 0); + + isc_buffer_init(&b, rcode, sizeof(rcode)); + dns_rcode_totext(msg->rcode, &b); + isc_buffer_putuint8(&b, 0); + printf(";; ->>HEADER<<- opcode: %s, status: %s, id: %u\n", - opcodetext[msg->opcode], rcodetext[msg->rcode], msg->id); + opcode, rcode, msg->id); printf(";; flags:"); if ((msg->flags & DNS_MESSAGEFLAG_QR) != 0)