Commit ccbfddc7 authored by Bob Halley's avatar Bob Halley
Browse files

dns_rdataset_towire() now returns the number of RRs added to target

parent c810fcbf
......@@ -207,7 +207,8 @@ dns_result_t
dns_rdataset_towire(dns_rdataset_t *rdataset,
dns_name_t *owner_name,
dns_compress_t *cctx,
isc_buffer_t *target);
isc_buffer_t *target,
unsigned int *countp);
/*
* Convert 'rdataset' to wire format, compressing names as specified
* in cctx, and storing the result in 'target'.
......@@ -215,16 +216,23 @@ dns_rdataset_towire(dns_rdataset_t *rdataset,
* Notes:
* The rdata cursor position will be changed.
*
* The number of RRs added to target will be added to *countp.
*
* Requires:
* 'rdataset' is a valid rdataset.
*
* 'rdataset' is not empty.
*
* 'countp' is a valid pointer.
*
* Ensures:
* On a return of DNS_R_SUCCESS, 'target' contains a wire format
* for the data contained in 'rdataset'. Any error return leaves
* the buffer in an undefined state.
*
* *countp has been incremented by the number of RRs added to
* target.
*
* Returns:
* DNS_R_SUCCESS - all ok
* DNS_R_NOSPACE - 'target' doesn't have enough room
......
......@@ -265,11 +265,13 @@ dns_result_t
dns_rdataset_towire(dns_rdataset_t *rdataset,
dns_name_t *owner_name,
dns_compress_t *cctx,
isc_buffer_t *target)
isc_buffer_t *target,
unsigned int *countp)
{
dns_rdata_t rdata;
isc_region_t r;
dns_result_t result;
unsigned int count;
/*
* Convert 'rdataset' to wire format, compressing names as specified
......@@ -279,7 +281,9 @@ dns_rdataset_towire(dns_rdataset_t *rdataset,
REQUIRE(DNS_RDATASET_VALID(rdataset));
result = dns_rdataset_first(rdataset);
REQUIRE(result == DNS_R_SUCCESS);
REQUIRE(countp != NULL);
count = 0;
do {
/*
* copy out the name, type, class, ttl.
......@@ -310,11 +314,15 @@ dns_rdataset_towire(dns_rdataset_t *rdataset,
if (result != DNS_R_SUCCESS)
return (result);
count++;
result = dns_rdataset_next(rdataset);
} while (result == DNS_R_SUCCESS);
if (result != DNS_R_NOMORE)
return (result);
*countp += count;
return (DNS_R_SUCCESS);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment