Commit 373ce674 authored by Mark Andrews's avatar Mark Andrews
Browse files

Implement dns_rdata_fromstruct() where not already done.

Add missing REQUIRE tests to existing implementations.
parent 0103f423
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tsig_250.c,v 1.37 2000/05/19 13:04:45 marka Exp $ */
/* $Id: tsig_250.c,v 1.38 2000/05/22 12:37:28 marka Exp $ */
/* Reviewed: Thu Mar 16 13:39:43 PST 2000 by gson */
......@@ -336,13 +336,14 @@ static inline isc_result_t
fromstruct_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
void *source, isc_buffer_t *target)
{
dns_rdata_any_tsig_t *tsig = source;
isc_region_t tr;
dns_rdata_any_tsig_t *tsig;
REQUIRE(type == 250);
REQUIRE(rdclass == 255);
tsig = (dns_rdata_any_tsig_t *)source;
REQUIRE(source != NULL);
REQUIRE(tsig->common.rdclass == rdclass);
REQUIRE(tsig->common.rdtype == type);
/*
* Algorithm Name.
......@@ -374,13 +375,7 @@ fromstruct_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/*
* Signature.
*/
if (tsig->siglen > 0) {
isc_buffer_availableregion(target, &tr);
if (tr.length < tsig->siglen)
return (ISC_R_NOSPACE);
memcpy(tr.base, tsig->signature, tsig->siglen);
isc_buffer_add(target, tsig->siglen);
}
RETERR(mem_tobuffer(target, tsig->signature, tsig->siglen));
isc_buffer_availableregion(target, &tr);
if (tr.length < 2 + 2 + 2)
......@@ -404,15 +399,7 @@ fromstruct_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
/*
* Other Data.
*/
if (tsig->otherlen > 0) {
isc_buffer_availableregion(target, &tr);
if (tr.length < tsig->otherlen)
return (ISC_R_NOSPACE);
memcpy(tr.base, tsig->other, tsig->otherlen);
isc_buffer_add(target, tsig->otherlen);
}
return (ISC_R_SUCCESS);
return (mem_tobuffer(target, tsig->other, tsig->otherlen));
}
static inline isc_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: afsdb_18.c,v 1.27 2000/05/15 21:14:20 tale Exp $ */
/* $Id: afsdb_18.c,v 1.28 2000/05/22 12:37:29 marka Exp $ */
/* Reviewed: Wed Mar 15 14:59:00 PST 2000 by explorer */
......@@ -170,13 +170,17 @@ static inline isc_result_t
fromstruct_afsdb(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
dns_rdata_afsdb_t *afsdb = source;
isc_region_t region;
REQUIRE(type == 18);
REQUIRE(source != NULL);
REQUIRE(afsdb->common.rdclass == rdclass);
REQUIRE(afsdb->common.rdtype == type);
return (ISC_R_NOTIMPLEMENTED);
RETERR(uint16_tobuffer(afsdb->subtype, target));
dns_name_toregion(&afsdb->server, &region);
return (isc_buffer_copyregion(target, &region));
}
static inline isc_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: cert_37.c,v 1.28 2000/05/19 02:02:11 marka Exp $ */
/* $Id: cert_37.c,v 1.29 2000/05/22 12:37:30 marka Exp $ */
/* Reviewed: Wed Mar 15 21:14:32 EST 2000 by tale */
......@@ -166,14 +166,18 @@ static inline isc_result_t
fromstruct_cert(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
dns_rdata_cert_t *cert = source;
REQUIRE(type == 37);
REQUIRE(source != NULL);
REQUIRE(cert->common.rdtype == type);
REQUIRE(cert->common.rdclass == rdclass);
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
RETERR(uint16_tobuffer(cert->type, target));
RETERR(uint16_tobuffer(cert->key_tag, target));
RETERR(uint8_tobuffer(cert->algorithm, target));
return (ISC_R_NOTIMPLEMENTED);
return (mem_tobuffer(target, cert->certificate, cert->length));
}
static inline isc_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: cname_5.c,v 1.29 2000/05/05 05:49:42 marka Exp $ */
/* $Id: cname_5.c,v 1.30 2000/05/22 12:37:31 marka Exp $ */
/* reviewed: Wed Mar 15 16:48:45 PST 2000 by brister */
......@@ -129,14 +129,16 @@ static inline isc_result_t
fromstruct_cname(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
dns_rdata_cname_t *cname = source;
isc_region_t region;
REQUIRE(type == 5);
REQUIRE(source != NULL);
REQUIRE(cname->common.rdtype == type);
REQUIRE(cname->common.rdclass == rdclass);
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
return (ISC_R_NOTIMPLEMENTED);
dns_name_toregion(&cname->cname, &region);
return (isc_buffer_copyregion(target, &region));
}
static inline isc_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: dname_39.c,v 1.21 2000/05/05 05:49:43 marka Exp $ */
/* $Id: dname_39.c,v 1.22 2000/05/22 12:37:32 marka Exp $ */
/* Reviewed: Wed Mar 15 16:52:38 PST 2000 by explorer */
......@@ -130,13 +130,16 @@ static inline isc_result_t
fromstruct_dname(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
dns_rdata_dname_t *dname = source;
isc_region_t region;
REQUIRE(type == 39);
REQUIRE(source != NULL);
REQUIRE(dname->common.rdtype == type);
REQUIRE(dname->common.rdclass == rdclass);
return (ISC_R_NOTIMPLEMENTED);
dns_name_toregion(&dname->dname, &region);
return (isc_buffer_copyregion(target, &region));
}
static inline isc_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: gpos_27.c,v 1.19 2000/05/19 13:05:51 marka Exp $ */
/* $Id: gpos_27.c,v 1.20 2000/05/22 12:37:33 marka Exp $ */
/* reviewed: Wed Mar 15 16:48:45 PST 2000 by brister */
......@@ -118,15 +118,19 @@ static inline isc_result_t
fromstruct_gpos(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
dns_rdata_gpos_t *gpos = source;
REQUIRE(type == 27);
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
return (ISC_R_NOTIMPLEMENTED);
REQUIRE(source != NULL);
REQUIRE(gpos->common.rdtype == type);
REQUIRE(gpos->common.rdclass == rdclass);
RETERR(uint8_tobuffer(gpos->long_len, target));
RETERR(mem_tobuffer(target, gpos->longitude, gpos->long_len));
RETERR(uint8_tobuffer(gpos->lat_len, target));
RETERR(mem_tobuffer(target, gpos->latitude, gpos->lat_len));
RETERR(uint8_tobuffer(gpos->alt_len, target));
return (mem_tobuffer(target, gpos->altitude, gpos->alt_len));
}
static inline isc_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: hinfo_13.c,v 1.24 2000/05/05 05:49:45 marka Exp $ */
/* $Id: hinfo_13.c,v 1.25 2000/05/22 12:37:34 marka Exp $ */
/*
* Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley.
......@@ -108,13 +108,17 @@ static inline isc_result_t
fromstruct_hinfo(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
dns_rdata_hinfo_t *hinfo = source;
REQUIRE(type == 13);
REQUIRE(source != NULL);
REQUIRE(hinfo->common.rdtype == type);
REQUIRE(hinfo->common.rdclass == rdclass);
return (ISC_R_NOTIMPLEMENTED);
RETERR(uint8_tobuffer(hinfo->cpu_len, target));
RETERR(mem_tobuffer(target, hinfo->cpu, hinfo->cpu_len));
RETERR(uint8_tobuffer(hinfo->os_len, target));
return (mem_tobuffer(target, hinfo->os, hinfo->os_len));
}
static inline isc_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: isdn_20.c,v 1.18 2000/05/05 05:49:46 marka Exp $ */
/* $Id: isdn_20.c,v 1.19 2000/05/22 12:37:36 marka Exp $ */
/* Reviewed: Wed Mar 15 16:53:11 PST 2000 by bwelling */
......@@ -115,13 +115,17 @@ static inline isc_result_t
fromstruct_isdn(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
dns_rdata_isdn_t *isdn = source;
REQUIRE(type == 20);
REQUIRE(source != NULL);
REQUIRE(isdn->common.rdtype == type);
REQUIRE(isdn->common.rdclass == rdclass);
return (ISC_R_NOTIMPLEMENTED);
RETERR(uint8_tobuffer(isdn->isdn_len, target));
RETERR(mem_tobuffer(target, isdn->isdn, isdn->isdn_len));
RETERR(uint8_tobuffer(isdn->subaddress_len, target));
return (mem_tobuffer(target, isdn->subaddress, isdn->subaddress_len));
}
static inline isc_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: key_25.c,v 1.24 2000/05/05 05:49:47 marka Exp $ */
/* $Id: key_25.c,v 1.25 2000/05/22 12:37:37 marka Exp $ */
/*
* Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley.
......@@ -165,16 +165,12 @@ static inline isc_result_t
fromstruct_key(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
dns_rdata_key_t *key;
isc_region_t tr;
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
dns_rdata_key_t *key = source;
REQUIRE(type == 25);
key = (dns_rdata_key_t *) source;
REQUIRE(source != NULL);
REQUIRE(key->common.rdtype == type);
REQUIRE(key->common.rdclass == rdclass);
/* Flags */
RETERR(uint16_tobuffer(key->flags, target));
......@@ -186,15 +182,7 @@ fromstruct_key(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
RETERR(uint8_tobuffer(key->algorithm, target));
/* Data */
if (key->datalen > 0) {
isc_buffer_availableregion(target, &tr);
if (tr.length < key->datalen)
return (ISC_R_NOSPACE);
memcpy(tr.base, key->data, key->datalen);
isc_buffer_add(target, key->datalen);
}
return (ISC_R_SUCCESS);
return (mem_tobuffer(target, key->data, key->datalen));
}
static inline isc_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: loc_29.c,v 1.19 2000/05/15 21:14:22 tale Exp $ */
/* $Id: loc_29.c,v 1.20 2000/05/22 12:37:38 marka Exp $ */
/* Reviewed: Wed Mar 15 18:13:09 PST 2000 by explorer */
......@@ -615,13 +615,43 @@ static inline isc_result_t
fromstruct_loc(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
dns_rdata_loc_t *loc = source;
isc_uint8_t c;
REQUIRE(type == 29);
REQUIRE(source != NULL);
REQUIRE(loc->common.rdtype == type);
REQUIRE(loc->common.rdclass == rdclass);
return (ISC_R_NOTIMPLEMENTED);
if (loc->v.v0.version != 0)
return (ISC_R_NOTIMPLEMENTED);
RETERR(uint8_tobuffer(loc->v.v0.version, target));
c = loc->v.v0.size;
if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0)
return (ISC_R_RANGE);
RETERR(uint8_tobuffer(loc->v.v0.size, target));
c = loc->v.v0.horizontal;
if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0)
return (ISC_R_RANGE);
RETERR(uint8_tobuffer(loc->v.v0.horizontal, target));
c = loc->v.v0.vertical;
if ((c&0xf) > 9 || ((c>>4)&0xf) > 9 || ((c>>4)&0xf) == 0)
return (ISC_R_RANGE);
RETERR(uint8_tobuffer(loc->v.v0.vertical, target));
if (loc->v.v0.latitude < (0x80000000UL - 90 * 3600000) ||
loc->v.v0.latitude > (0x80000000UL + 90 * 3600000))
return (ISC_R_RANGE);
RETERR(uint32_tobuffer(loc->v.v0.latitude, target));
if (loc->v.v0.longitude < (0x80000000UL - 180 * 3600000) ||
loc->v.v0.longitude > (0x80000000UL + 180 * 3600000))
return (ISC_R_RANGE);
RETERR(uint32_tobuffer(loc->v.v0.longitude, target));
return (uint32_tobuffer(loc->v.v0.altitude, target));
}
static inline isc_result_t
......
......@@ -18,7 +18,7 @@
#ifndef GENERIC_LOC_29_H
#define GENERIC_LOC_29_H 1
/* $Id: loc_29.h,v 1.10 2000/05/05 05:49:49 marka Exp $ */
/* $Id: loc_29.h,v 1.11 2000/05/22 12:37:39 marka Exp $ */
/* RFC 1876 */
......@@ -27,9 +27,9 @@ typedef struct dns_rdata_loc_0 {
isc_uint8_t size;
isc_uint8_t horizontal;
isc_uint8_t vertical;
isc_int32_t latitude;
isc_int32_t longitude;
isc_int32_t altitude;
isc_uint32_t latitude;
isc_uint32_t longitude;
isc_uint32_t altitude;
} dns_rdata_loc_0_t;
typedef struct dns_rdata_loc {
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mb_7.c,v 1.28 2000/05/05 05:49:51 marka Exp $ */
/* $Id: mb_7.c,v 1.29 2000/05/22 12:37:40 marka Exp $ */
/* Reviewed: Wed Mar 15 17:31:26 PST 2000 by bwelling */
......@@ -127,13 +127,16 @@ static inline isc_result_t
fromstruct_mb(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
dns_rdata_mb_t *mb = source;
isc_region_t region;
REQUIRE(type == 7);
REQUIRE(source != NULL);
REQUIRE(mb->common.rdtype == type);
REQUIRE(mb->common.rdclass == rdclass);
return (ISC_R_NOTIMPLEMENTED);
dns_name_toregion(&mb->mb, &region);
return (isc_buffer_copyregion(target, &region));
}
static inline isc_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: md_3.c,v 1.30 2000/05/05 05:49:52 marka Exp $ */
/* $Id: md_3.c,v 1.31 2000/05/22 12:37:41 marka Exp $ */
/* Reviewed: Wed Mar 15 17:48:20 PST 2000 by bwelling */
......@@ -127,13 +127,16 @@ static inline isc_result_t
fromstruct_md(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
dns_rdata_md_t *md = source;
isc_region_t region;
REQUIRE(type == 3);
REQUIRE(source != NULL);
REQUIRE(md->common.rdtype == type);
REQUIRE(md->common.rdclass == rdclass);
return (ISC_R_NOTIMPLEMENTED);
dns_name_toregion(&md->md, &region);
return (isc_buffer_copyregion(target, &region));
}
static inline isc_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mf_4.c,v 1.28 2000/05/05 05:49:53 marka Exp $ */
/* $Id: mf_4.c,v 1.29 2000/05/22 12:37:42 marka Exp $ */
/* reviewed: Wed Mar 15 17:47:33 PST 2000 by brister */
......@@ -129,15 +129,16 @@ static inline isc_result_t
fromstruct_mf(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
dns_rdata_mf_t *mf = source;
isc_region_t region;
REQUIRE(type == 4);
REQUIRE(source != NULL);
REQUIRE(mf->common.rdtype == type);
REQUIRE(mf->common.rdclass == rdclass);
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
return (ISC_R_NOTIMPLEMENTED);
dns_name_toregion(&mf->mf, &region);
return (isc_buffer_copyregion(target, &region));
}
static inline isc_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mg_8.c,v 1.26 2000/05/05 05:49:54 marka Exp $ */
/* $Id: mg_8.c,v 1.27 2000/05/22 12:37:43 marka Exp $ */
/* reviewed: Wed Mar 15 17:49:21 PST 2000 by brister */
......@@ -129,15 +129,16 @@ static inline isc_result_t
fromstruct_mg(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
dns_rdata_mg_t *mg = source;
isc_region_t region;
REQUIRE(type == 8);
REQUIRE(source != NULL);
REQUIRE(mg->common.rdtype == type);
REQUIRE(mg->common.rdclass == rdclass);
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
return (ISC_R_NOTIMPLEMENTED);
dns_name_toregion(&mg->mg, &region);
return (isc_buffer_copyregion(target, &region));
}
static inline isc_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: minfo_14.c,v 1.27 2000/05/05 05:49:55 marka Exp $ */
/* $Id: minfo_14.c,v 1.28 2000/05/22 12:37:44 marka Exp $ */
/* reviewed: Wed Mar 15 17:45:32 PST 2000 by brister */
......@@ -175,24 +175,27 @@ static inline isc_result_t
fromstruct_minfo(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
dns_rdata_minfo_t *minfo = source;
isc_region_t region;
REQUIRE(type == 14);
REQUIRE(source != NULL);
REQUIRE(minfo->common.rdtype == type);
REQUIRE(minfo->common.rdclass == rdclass);
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
return (ISC_R_NOTIMPLEMENTED);
dns_name_toregion(&minfo->rmailbox, &region);
RETERR(isc_buffer_copyregion(target, &region));
dns_name_toregion(&minfo->emailbox, &region);
return (isc_buffer_copyregion(target, &region));
}
static inline isc_result_t
tostruct_minfo(dns_rdata_t *rdata, void *target, isc_mem_t *mctx)
{
isc_region_t region;
isc_result_t result;
dns_rdata_minfo_t *minfo = target;
isc_region_t region;
dns_name_t name;
isc_result_t result;
REQUIRE(rdata->type == 14);
REQUIRE(target != NULL);
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mr_9.c,v 1.25 2000/05/05 05:49:56 marka Exp $ */
/* $Id: mr_9.c,v 1.26 2000/05/22 12:37:46 marka Exp $ */
/* Reviewed: Wed Mar 15 21:30:35 EST 2000 by tale */
......@@ -126,13 +126,16 @@ static inline isc_result_t
fromstruct_mr(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
isc_buffer_t *target)
{
REQUIRE(type == 9);
dns_rdata_mr_t *mr = source;
isc_region_t region;
UNUSED(rdclass);
UNUSED(source);
UNUSED(target);
REQUIRE(type == 9);
REQUIRE(source != NULL);
REQUIRE(mr->common.rdtype == type);
REQUIRE(mr->common.rdclass == rdclass);
return (ISC_R_NOTIMPLEMENTED);