]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2512. [func] Print a summary of the cached records which make up
authorMark Andrews <marka@isc.org>
Fri, 12 Dec 2008 04:41:25 +0000 (04:41 +0000)
committerMark Andrews <marka@isc.org>
Fri, 12 Dec 2008 04:41:25 +0000 (04:41 +0000)
                        the negative response.  [RT #18885]

CHANGES
lib/dns/masterdump.c

diff --git a/CHANGES b/CHANGES
index 4e729e2f3818defc052b26e4042ff22663097be7..b85fb93640a6722bbe5083f8a015205a4c09dab5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+2512.  [func]          Print a summary of the cached records which make up
+                       the negative response.  [RT #18885]
+
 2511.  [cleanup]       dns_rdata_tofmttext() add const to linebreak.
                        [RT #18885]
 
index 3d464582047d55fbfdf8e5e8ff86638c13490bd0..6e6a16a8d679ac5b2098b332a063b5d65424baf8 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: masterdump.c,v 1.94 2008/09/24 02:46:22 marka Exp $ */
+/* $Id: masterdump.c,v 1.95 2008/12/12 04:41:25 marka Exp $ */
 
 /*! \file */
 
@@ -42,6 +42,7 @@
 #include <dns/log.h>
 #include <dns/master.h>
 #include <dns/masterdump.h>
+#include <dns/ncache.h>
 #include <dns/rdata.h>
 #include <dns/rdataclass.h>
 #include <dns/rdataset.h>
                return (_r); \
        } while (0)
 
+#define CHECK(x) do { \
+       if ((x) != ISC_R_SUCCESS) \
+               goto cleanup; \
+       } while (0)
+
 struct dns_master_style {
        unsigned int flags;             /* DNS_STYLEFLAG_* */
        unsigned int ttl_column;
@@ -336,6 +342,52 @@ str_totext(const char *source, isc_buffer_t *target) {
        return (ISC_R_SUCCESS);
 }
 
+static isc_result_t
+ncache_summary(dns_rdataset_t *rdataset, isc_boolean_t omit_final_dot,
+              isc_buffer_t *target)
+{
+       isc_result_t result = ISC_R_SUCCESS;
+       dns_rdataset_t rds;
+       dns_name_t name;
+
+       dns_rdataset_init(&rds);
+       dns_name_init(&name, NULL);
+
+       do {
+               dns_ncache_current(rdataset, &name, &rds);
+               for (result = dns_rdataset_first(&rds);
+                    result == ISC_R_SUCCESS;
+                    result = dns_rdataset_next(&rds)) {
+                       CHECK(str_totext("; ", target));
+                       CHECK(dns_name_totext(&name, omit_final_dot, target));
+                       CHECK(str_totext(" ", target));
+                       CHECK(dns_rdatatype_totext(rds.type, target));
+                       if (rds.type == dns_rdatatype_rrsig) {
+                               CHECK(str_totext(" ", target));
+                               CHECK(dns_rdatatype_totext(rds.covers, target));
+                               CHECK(str_totext(" ...\n", target));
+                       } else {
+                               dns_rdata_t rdata = DNS_RDATA_INIT;
+                               dns_rdataset_current(&rds, &rdata);
+                               CHECK(str_totext(" ", target));
+                               CHECK(dns_rdata_tofmttext(&rdata, dns_rootname,
+                                                         0, 0, " ", target));
+                               CHECK(str_totext("\n", target));
+                       }
+               }
+               dns_rdataset_disassociate(&rds);
+               result = dns_rdataset_next(rdataset);
+       } while (result == ISC_R_SUCCESS);
+
+       if (result == ISC_R_NOMORE)
+               result = ISC_R_SUCCESS;
+ cleanup:
+       if (dns_rdataset_isassociated(&rds))
+               dns_rdataset_disassociate(&rds);
+
+       return (result);
+}
+
 /*
  * Convert 'rdataset' to master file text format according to 'ctx',
  * storing the result in 'target'.  If 'owner_name' is NULL, it
@@ -464,6 +516,13 @@ rdataset_totext(dns_rdataset_t *rdataset,
                                RETERR(str_totext(";-$NXDOMAIN\n", target));
                        else
                                RETERR(str_totext(";-$NXRRSET\n", target));
+                       /*
+                        * Print a summary of the cached records which make
+                        * up the negative response.
+                        */
+                       RETERR(ncache_summary(rdataset, omit_final_dot,
+                                             target));
+                       break;
                } else {
                        dns_rdata_t rdata = DNS_RDATA_INIT;
                        isc_region_t r;