]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[v9_9] use libdns functions to convert rcode and opcode to text
authorEvan Hunt <each@isc.org>
Tue, 11 Aug 2015 03:29:01 +0000 (20:29 -0700)
committerEvan Hunt <each@isc.org>
Tue, 11 Aug 2015 03:29:01 +0000 (20:29 -0700)
bin/tests/printmsg.c

index 9ec3544ff600807cae5486c4bf3054c93e373fa8..f872af9cdd16f23835c653d0dd5e3848cb0abf28 100644 (file)
@@ -15,8 +15,6 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: printmsg.c,v 1.31 2011/08/25 23:46:42 tbox Exp $ */
-
 #include <config.h>
 
 #include <isc/buffer.h>
 #include <isc/util.h>
 
 #include <dns/name.h>
+#include <dns/opcode.h>
+#include <dns/rcode.h>
 #include <dns/rdataset.h>
 
 #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)