2512. [func] Print a summary of the cached records which make up

the negative response.  [RT #18885]
This commit is contained in:
Mark Andrews
2008-12-12 04:41:25 +00:00
parent a5746c4ec1
commit 47d89fcd4f
2 changed files with 63 additions and 1 deletions

View File

@@ -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]

View 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>
@@ -60,6 +61,11 @@
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;