2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

implement dns_rdataset_towire()

This commit is contained in:
Michael Graff 1999-01-27 05:54:39 +00:00
parent edd4f79b4b
commit 76883e8cee

View File

@ -261,6 +261,12 @@ dns_rdataset_towire(dns_rdataset_t *rdataset,
dns_compress_t *cctx, dns_compress_t *cctx,
isc_buffer_t *target) isc_buffer_t *target)
{ {
dns_rdata_t rdata;
isc_region_t r;
dns_rdataclass_t rclass;
dns_rdatatype_t rtype;
dns_ttl_t rttl;
dns_result_t result;
/* /*
* Convert 'rdataset' to wire format, compressing names as specified * Convert 'rdataset' to wire format, compressing names as specified
@ -268,11 +274,56 @@ dns_rdataset_towire(dns_rdataset_t *rdataset,
*/ */
REQUIRE(DNS_RDATASET_VALID(rdataset)); REQUIRE(DNS_RDATASET_VALID(rdataset));
result = dns_rdataset_first(rdataset);
REQUIRE(result == DNS_R_SUCCESS);
/* XXX stop warnings. */ do {
owner_name = NULL; /*
cctx = NULL; * copy out the name, type, class, ttl.
target = NULL; */
result = dns_name_towire(owner_name, cctx, target);
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_available(target, &r);
if (r.length < (sizeof(dns_rdataclass_t)
+ sizeof(dns_rdatatype_t)
+ sizeof(dns_ttl_t)
+ 2)) /* XXX 2? it's for the rdata length */
return (DNS_R_NOSPACE);
rtype = rdataset->type;
r.base[0] = (rtype & 0xff00) >> 8;
r.base[1] = (rtype & 0xff);
rclass = rdataset->class;
r.base[2] = (rclass & 0xff00) >> 8;
r.base[3] = (rclass & 0x00ff);
rttl = rdataset->ttl;
r.base[4] = (rttl & 0xff000000) >> 24;
r.base[5] = (rttl & 0x00ff0000) >> 16;
r.base[6] = (rttl & 0x0000ff00) >> 8;
r.base[7] = (rttl & 0x000000ff);
isc_buffer_add(target, (sizeof(dns_rdataclass_t)
+ sizeof(dns_rdatatype_t)
+ sizeof(dns_ttl_t)
+ 2)); /* XXX see XXX above */
/*
* copy out the rdata length
*/
dns_rdataset_current(rdataset, &rdata);
r.base[8] = (rdata.length & 0xff00) >> 8;
r.base[9] = (rdata.length & 0x00ff);
return (DNS_R_NOTIMPLEMENTED); /*
* copy out the rdata
*/
result = dns_rdata_towire(&rdata, cctx, target);
if (result != DNS_R_SUCCESS)
return (result);
result = dns_rdataset_next(rdataset);
} while (result == DNS_R_SUCCESS);
if (result != DNS_R_NOMORE)
return (result);
return (DNS_R_SUCCESS);
} }