]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add a test method to print QP keys
authorEvan Hunt <each@isc.org>
Tue, 30 Apr 2024 08:22:39 +0000 (01:22 -0700)
committerEvan Hunt <each@isc.org>
Tue, 30 Apr 2024 22:58:17 +0000 (15:58 -0700)
add a method qp_test_printkey() to print the name encoded in a QP key.

tests/include/tests/qp.h
tests/libtest/qp.c

index d0d73573155e1b292afedd443252a84a9512c536..34a84491d875ef7668579c03b43d2948dd7ffa84 100644 (file)
@@ -84,3 +84,9 @@ qp_test_dumptrie(dns_qpreadable_t qp);
  */
 void
 qp_test_dumpdot(dns_qp_t *qp);
+
+/*
+ * Print the name encoded in a QP key.
+ */
+void
+qp_test_printkey(const dns_qpkey_t key, size_t keylen);
index d6a1d3055f2a29775e1221dea7d9a0a66203bf6c..fb65962bbfec63d23f8f8cbef85a51d6519a187b 100644 (file)
@@ -23,6 +23,7 @@
 #include <isc/urcu.h>
 #include <isc/util.h>
 
+#include <dns/fixedname.h>
 #include <dns/name.h>
 #include <dns/qp.h>
 #include <dns/types.h>
@@ -338,4 +339,15 @@ qp_test_dumpdot(dns_qp_t *qp) {
        printf("}\n");
 }
 
+void
+qp_test_printkey(const dns_qpkey_t key, size_t keylen) {
+       dns_fixedname_t fn;
+       dns_name_t *n = dns_fixedname_initname(&fn);
+       char txt[DNS_NAME_FORMATSIZE];
+
+       dns_qpkey_toname(key, keylen, n);
+       dns_name_format(n, txt, sizeof(txt));
+       printf("%s%s\n", txt, dns_name_isabsolute(n) ? "." : "");
+}
+
 /**********************************************************************/