mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-08 20:32:06 -04:00
dns_rdataset_towire() now returns the number of RRs added to target
This commit is contained in:
parent
c810fcbf6c
commit
ccbfddc70e
2 changed files with 18 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue