From 373ce67419680a398ba3dc51a14a486caaf0afb0 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 22 May 2000 12:38:12 +0000 Subject: [PATCH] Implement dns_rdata_fromstruct() where not already done. Add missing REQUIRE tests to existing implementations. --- lib/dns/rdata/any_255/tsig_250.c | 27 ++++++-------------- lib/dns/rdata/generic/afsdb_18.c | 14 +++++++---- lib/dns/rdata/generic/cert_37.c | 14 +++++++---- lib/dns/rdata/generic/cname_5.c | 14 ++++++----- lib/dns/rdata/generic/dname_39.c | 13 ++++++---- lib/dns/rdata/generic/gpos_27.c | 18 ++++++++------ lib/dns/rdata/generic/hinfo_13.c | 14 +++++++---- lib/dns/rdata/generic/isdn_20.c | 14 +++++++---- lib/dns/rdata/generic/key_25.c | 24 +++++------------- lib/dns/rdata/generic/loc_29.c | 40 ++++++++++++++++++++++++++---- lib/dns/rdata/generic/loc_29.h | 8 +++--- lib/dns/rdata/generic/mb_7.c | 13 ++++++---- lib/dns/rdata/generic/md_3.c | 13 ++++++---- lib/dns/rdata/generic/mf_4.c | 15 +++++------ lib/dns/rdata/generic/mg_8.c | 15 +++++------ lib/dns/rdata/generic/minfo_14.c | 21 +++++++++------- lib/dns/rdata/generic/mr_9.c | 15 ++++++----- lib/dns/rdata/generic/mx_15.c | 17 +++++++------ lib/dns/rdata/generic/ns_2.c | 13 ++++++---- lib/dns/rdata/generic/null_10.c | 13 ++++++---- lib/dns/rdata/generic/nxt_30.c | 15 +++++------ lib/dns/rdata/generic/opt_41.c | 28 +++++++++++++++++---- lib/dns/rdata/generic/proforma.c | 9 +++++-- lib/dns/rdata/generic/ptr_12.c | 15 ++++++----- lib/dns/rdata/generic/rp_17.c | 15 +++++++---- lib/dns/rdata/generic/rt_21.c | 15 ++++++----- lib/dns/rdata/generic/sig_24.c | 24 ++++++------------ lib/dns/rdata/generic/soa_6.c | 20 +++++++++++---- lib/dns/rdata/generic/tkey_249.c | 36 ++++++++------------------- lib/dns/rdata/generic/txt_16.c | 25 +++++++++++++++---- lib/dns/rdata/generic/unspec_103.c | 14 ++++++----- lib/dns/rdata/generic/x25_19.c | 19 ++++++++++---- lib/dns/rdata/hs_4/a_1.c | 12 ++++++--- lib/dns/rdata/in_1/a6_38.c | 40 +++++++++++++++++++----------- lib/dns/rdata/in_1/a_1.c | 14 ++++++++--- lib/dns/rdata/in_1/aaaa_28.c | 12 +++++---- lib/dns/rdata/in_1/naptr_35.c | 26 ++++++++++++++++--- lib/dns/rdata/in_1/nsap-ptr_23.c | 13 ++++++---- lib/dns/rdata/in_1/nsap_22.c | 13 ++++++---- lib/dns/rdata/in_1/srv_33.c | 15 ++++++++--- lib/dns/rdata/in_1/wks_11.c | 14 ++++++++--- 41 files changed, 445 insertions(+), 284 deletions(-) diff --git a/lib/dns/rdata/any_255/tsig_250.c b/lib/dns/rdata/any_255/tsig_250.c index a0748d2812..6195040ce2 100644 --- a/lib/dns/rdata/any_255/tsig_250.c +++ b/lib/dns/rdata/any_255/tsig_250.c @@ -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 diff --git a/lib/dns/rdata/generic/afsdb_18.c b/lib/dns/rdata/generic/afsdb_18.c index 1e71d9408b..aa9d2c1624 100644 --- a/lib/dns/rdata/generic/afsdb_18.c +++ b/lib/dns/rdata/generic/afsdb_18.c @@ -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, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/cert_37.c b/lib/dns/rdata/generic/cert_37.c index 0ec2288875..08f51f9ca0 100644 --- a/lib/dns/rdata/generic/cert_37.c +++ b/lib/dns/rdata/generic/cert_37.c @@ -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 diff --git a/lib/dns/rdata/generic/cname_5.c b/lib/dns/rdata/generic/cname_5.c index 10df4e8af8..6fb04f17b8 100644 --- a/lib/dns/rdata/generic/cname_5.c +++ b/lib/dns/rdata/generic/cname_5.c @@ -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, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/dname_39.c b/lib/dns/rdata/generic/dname_39.c index c434b75db3..2d262f995e 100644 --- a/lib/dns/rdata/generic/dname_39.c +++ b/lib/dns/rdata/generic/dname_39.c @@ -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, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/gpos_27.c b/lib/dns/rdata/generic/gpos_27.c index 5a5cf39827..7ef878ced6 100644 --- a/lib/dns/rdata/generic/gpos_27.c +++ b/lib/dns/rdata/generic/gpos_27.c @@ -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); + REQUIRE(source != NULL); + REQUIRE(gpos->common.rdtype == type); + REQUIRE(gpos->common.rdclass == rdclass); - UNUSED(rdclass); - - UNUSED(source); - UNUSED(target); - - return (ISC_R_NOTIMPLEMENTED); + 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 diff --git a/lib/dns/rdata/generic/hinfo_13.c b/lib/dns/rdata/generic/hinfo_13.c index fa6e483411..9086ca735e 100644 --- a/lib/dns/rdata/generic/hinfo_13.c +++ b/lib/dns/rdata/generic/hinfo_13.c @@ -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 diff --git a/lib/dns/rdata/generic/isdn_20.c b/lib/dns/rdata/generic/isdn_20.c index 05f20d8192..6fbc936f6f 100644 --- a/lib/dns/rdata/generic/isdn_20.c +++ b/lib/dns/rdata/generic/isdn_20.c @@ -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 diff --git a/lib/dns/rdata/generic/key_25.c b/lib/dns/rdata/generic/key_25.c index 2f4809ae46..27c6014f0a 100644 --- a/lib/dns/rdata/generic/key_25.c +++ b/lib/dns/rdata/generic/key_25.c @@ -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 diff --git a/lib/dns/rdata/generic/loc_29.c b/lib/dns/rdata/generic/loc_29.c index 0b21f8da54..ebd19919a6 100644 --- a/lib/dns/rdata/generic/loc_29.c +++ b/lib/dns/rdata/generic/loc_29.c @@ -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 diff --git a/lib/dns/rdata/generic/loc_29.h b/lib/dns/rdata/generic/loc_29.h index 4097c32dc2..18c774bfee 100644 --- a/lib/dns/rdata/generic/loc_29.h +++ b/lib/dns/rdata/generic/loc_29.h @@ -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 { diff --git a/lib/dns/rdata/generic/mb_7.c b/lib/dns/rdata/generic/mb_7.c index 56238ed6ff..1f6c2f613e 100644 --- a/lib/dns/rdata/generic/mb_7.c +++ b/lib/dns/rdata/generic/mb_7.c @@ -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, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/md_3.c b/lib/dns/rdata/generic/md_3.c index 7810af2654..a7435655d2 100644 --- a/lib/dns/rdata/generic/md_3.c +++ b/lib/dns/rdata/generic/md_3.c @@ -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, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/mf_4.c b/lib/dns/rdata/generic/mf_4.c index 5c3f6d73d8..4a9400e2eb 100644 --- a/lib/dns/rdata/generic/mf_4.c +++ b/lib/dns/rdata/generic/mf_4.c @@ -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, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/mg_8.c b/lib/dns/rdata/generic/mg_8.c index 1590dffaba..f30ec576c2 100644 --- a/lib/dns/rdata/generic/mg_8.c +++ b/lib/dns/rdata/generic/mg_8.c @@ -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, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/minfo_14.c b/lib/dns/rdata/generic/minfo_14.c index 69198df336..dc4f5a97a4 100644 --- a/lib/dns/rdata/generic/minfo_14.c +++ b/lib/dns/rdata/generic/minfo_14.c @@ -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, ®ion); + RETERR(isc_buffer_copyregion(target, ®ion)); + dns_name_toregion(&minfo->emailbox, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } 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); diff --git a/lib/dns/rdata/generic/mr_9.c b/lib/dns/rdata/generic/mr_9.c index 6673e657c7..1d77eb39cb 100644 --- a/lib/dns/rdata/generic/mr_9.c +++ b/lib/dns/rdata/generic/mr_9.c @@ -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) { + dns_rdata_mr_t *mr = source; + isc_region_t region; + REQUIRE(type == 9); + REQUIRE(source != NULL); + REQUIRE(mr->common.rdtype == type); + REQUIRE(mr->common.rdclass == rdclass); - UNUSED(rdclass); - UNUSED(source); - UNUSED(target); - - return (ISC_R_NOTIMPLEMENTED); + dns_name_toregion(&mr->mr, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/mx_15.c b/lib/dns/rdata/generic/mx_15.c index a13391c038..fbebdc9ffb 100644 --- a/lib/dns/rdata/generic/mx_15.c +++ b/lib/dns/rdata/generic/mx_15.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: mx_15.c,v 1.35 2000/05/15 21:14:24 tale Exp $ */ +/* $Id: mx_15.c,v 1.36 2000/05/22 12:37:47 marka Exp $ */ /* reviewed: Wed Mar 15 18:05:46 PST 2000 by brister */ @@ -156,14 +156,17 @@ static inline isc_result_t fromstruct_mx(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { + dns_rdata_mx_t *mx = source; + isc_region_t region; + REQUIRE(type == 15); + REQUIRE(source != NULL); + REQUIRE(mx->common.rdtype == type); + REQUIRE(mx->common.rdclass == rdclass); - UNUSED(rdclass); - - UNUSED(source); - UNUSED(target); - - return (ISC_R_NOTIMPLEMENTED); + RETERR(uint16_tobuffer(mx->pref, target)); + dns_name_toregion(&mx->mx, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/ns_2.c b/lib/dns/rdata/generic/ns_2.c index 6dec8568a6..7b5e8b55f5 100644 --- a/lib/dns/rdata/generic/ns_2.c +++ b/lib/dns/rdata/generic/ns_2.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: ns_2.c,v 1.29 2000/05/18 06:27:07 marka Exp $ */ +/* $Id: ns_2.c,v 1.30 2000/05/22 12:37:48 marka Exp $ */ /* Reviewed: Wed Mar 15 18:15:00 PST 2000 by bwelling */ @@ -127,13 +127,16 @@ static inline isc_result_t fromstruct_ns(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - UNUSED(rdclass); - UNUSED(source); - UNUSED(target); + dns_rdata_ns_t *ns = source; + isc_region_t region; REQUIRE(type == 2); + REQUIRE(source != NULL); + REQUIRE(ns->common.rdtype == type); + REQUIRE(ns->common.rdclass == rdclass); - return (ISC_R_NOTIMPLEMENTED); + dns_name_toregion(&ns->name, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/null_10.c b/lib/dns/rdata/generic/null_10.c index abe9c0ec09..ebb5b2f4eb 100644 --- a/lib/dns/rdata/generic/null_10.c +++ b/lib/dns/rdata/generic/null_10.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: null_10.c,v 1.23 2000/05/05 05:50:00 marka Exp $ */ +/* $Id: null_10.c,v 1.24 2000/05/22 12:37:49 marka Exp $ */ /* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */ @@ -101,13 +101,16 @@ static inline isc_result_t fromstruct_null(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - UNUSED(rdclass); - UNUSED(source); - UNUSED(target); + dns_rdata_null_t *null = source; REQUIRE(type == 10); + REQUIRE(source != NULL); + REQUIRE(null->common.rdtype == type); + REQUIRE(null->common.rdclass == rdclass); + REQUIRE((null->data != NULL && null->length != 0) || + (null->data == NULL && null->length == 0)); - return (ISC_R_NOTIMPLEMENTED); + return (mem_tobuffer(target, null->data, null->length)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/nxt_30.c b/lib/dns/rdata/generic/nxt_30.c index 6110dc6499..65433be4c8 100644 --- a/lib/dns/rdata/generic/nxt_30.c +++ b/lib/dns/rdata/generic/nxt_30.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: nxt_30.c,v 1.34 2000/05/15 21:14:25 tale Exp $ */ +/* $Id: nxt_30.c,v 1.35 2000/05/22 12:37:50 marka Exp $ */ /* reviewed: Wed Mar 15 18:21:15 PST 2000 by brister */ @@ -201,15 +201,16 @@ static inline isc_result_t fromstruct_nxt(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { + dns_rdata_nxt_t *nxt = source; REQUIRE(type == 30); + REQUIRE(source != NULL); + REQUIRE(nxt->common.rdtype == type); + REQUIRE(nxt->common.rdclass == rdclass); + REQUIRE((nxt->nxt != NULL && nxt->len != 0) || + (nxt->nxt == NULL && nxt->len == 0)); - UNUSED(rdclass); - - UNUSED(source); - UNUSED(target); - - return (ISC_R_NOTIMPLEMENTED); + return (mem_tobuffer(target, nxt->nxt, nxt->len)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/opt_41.c b/lib/dns/rdata/generic/opt_41.c index d06f52f9db..f3754c4191 100644 --- a/lib/dns/rdata/generic/opt_41.c +++ b/lib/dns/rdata/generic/opt_41.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: opt_41.c,v 1.13 2000/05/17 03:39:29 marka Exp $ */ +/* $Id: opt_41.c,v 1.14 2000/05/22 12:37:51 marka Exp $ */ /* Reviewed: Thu Mar 16 14:06:44 PST 2000 by gson */ @@ -166,13 +166,31 @@ static inline isc_result_t fromstruct_opt(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { + dns_rdata_opt_t *opt = source; + isc_region_t region; + isc_uint8_t length; + REQUIRE(type == 41); + REQUIRE(source != NULL); + REQUIRE(opt->common.rdtype == type); + REQUIRE(opt->common.rdclass == rdclass); + REQUIRE((opt->options != NULL && opt->length != 0) || + (opt->options == NULL && opt->length == 0)); - UNUSED(rdclass); - UNUSED(source); - UNUSED(target); + region.base = opt->options; + region.length = opt->length; + while (region.length >= 4) { + isc_region_consume(®ion, 2); /* opt */ + length = uint16_fromregion(®ion); + isc_region_consume(®ion, 2); + if (region.length < length) + return (ISC_R_UNEXPECTEDEND); + isc_region_consume(®ion, length); + } + if (region.length != 0) + return (ISC_R_UNEXPECTEDEND); - return (ISC_R_NOTIMPLEMENTED); + return (mem_tobuffer(target, opt->options, opt->length)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/proforma.c b/lib/dns/rdata/generic/proforma.c index a7f785b7db..ae29afa640 100644 --- a/lib/dns/rdata/generic/proforma.c +++ b/lib/dns/rdata/generic/proforma.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: proforma.c,v 1.22 2000/05/04 22:19:20 gson Exp $ */ +/* $Id: proforma.c,v 1.23 2000/05/22 12:37:52 marka Exp $ */ #ifndef RDATA_GENERIC_#_#_C #define RDATA_GENERIC_#_#_C @@ -90,10 +90,15 @@ compare_#(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { static inline isc_result_t fromstruct_#(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, - isc_buffer_t *target) { + isc_buffer_t *target) +{ + dns_rdata_#_t *# = source; REQUIRE(type == #); REQUIRE(rdclass == #); + REQUIRE(source != NULL); + REQUIRE(#->common.rdtype == type); + REQUIRE(#->common.rdclass == rdclass); return (ISC_R_NOTIMPLEMENTED); } diff --git a/lib/dns/rdata/generic/ptr_12.c b/lib/dns/rdata/generic/ptr_12.c index de6055d1d0..23bef291bf 100644 --- a/lib/dns/rdata/generic/ptr_12.c +++ b/lib/dns/rdata/generic/ptr_12.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: ptr_12.c,v 1.26 2000/05/05 05:50:03 marka Exp $ */ +/* $Id: ptr_12.c,v 1.27 2000/05/22 12:37:53 marka Exp $ */ /* Reviewed: Thu Mar 16 14:05:12 PST 2000 by explorer */ @@ -129,13 +129,16 @@ static inline isc_result_t fromstruct_ptr(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { + dns_rdata_ptr_t *ptr = source; + isc_region_t region; + REQUIRE(type == 12); + REQUIRE(source != NULL); + REQUIRE(ptr->common.rdtype == type); + REQUIRE(ptr->common.rdclass == rdclass); - UNUSED(rdclass); - UNUSED(source); - UNUSED(target); - - return (ISC_R_NOTIMPLEMENTED); + dns_name_toregion(&ptr->ptr, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/rp_17.c b/lib/dns/rdata/generic/rp_17.c index acbca5aa54..9e20ba1e57 100644 --- a/lib/dns/rdata/generic/rp_17.c +++ b/lib/dns/rdata/generic/rp_17.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: rp_17.c,v 1.23 2000/05/05 05:50:04 marka Exp $ */ +/* $Id: rp_17.c,v 1.24 2000/05/22 12:37:54 marka Exp $ */ /* RFC 1183 */ @@ -173,13 +173,18 @@ static inline isc_result_t fromstruct_rp(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - UNUSED(rdclass); - UNUSED(source); - UNUSED(target); + dns_rdata_rp_t *rp = source; + isc_region_t region; REQUIRE(type == 17); + REQUIRE(source != NULL); + REQUIRE(rp->common.rdtype == type); + REQUIRE(rp->common.rdclass == rdclass); - return (ISC_R_NOTIMPLEMENTED); + dns_name_toregion(&rp->mail, ®ion); + RETERR(isc_buffer_copyregion(target, ®ion)); + dns_name_toregion(&rp->text, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/rt_21.c b/lib/dns/rdata/generic/rt_21.c index c2bfc220ae..ea40c803ca 100644 --- a/lib/dns/rdata/generic/rt_21.c +++ b/lib/dns/rdata/generic/rt_21.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: rt_21.c,v 1.25 2000/05/15 21:14:26 tale Exp $ */ +/* $Id: rt_21.c,v 1.26 2000/05/22 12:37:55 marka Exp $ */ /* reviewed: Thu Mar 16 15:02:31 PST 2000 by brister */ @@ -165,14 +165,17 @@ static inline isc_result_t fromstruct_rt(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { + dns_rdata_rt_t *rt = source; + isc_region_t region; REQUIRE(type == 21); + REQUIRE(source != NULL); + REQUIRE(rt->common.rdtype == type); + REQUIRE(rt->common.rdclass == rdclass); - UNUSED(rdclass); - UNUSED(source); - UNUSED(target); - - return (ISC_R_NOTIMPLEMENTED); + RETERR(uint16_tobuffer(rt->preference, target)); + dns_name_toregion(&rt->host, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/sig_24.c b/lib/dns/rdata/generic/sig_24.c index 2939c4f6d3..f764b5aceb 100644 --- a/lib/dns/rdata/generic/sig_24.c +++ b/lib/dns/rdata/generic/sig_24.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: sig_24.c,v 1.40 2000/05/19 02:03:56 marka Exp $ */ +/* $Id: sig_24.c,v 1.41 2000/05/22 12:37:56 marka Exp $ */ /* Reviewed: Fri Mar 17 09:05:02 PST 2000 by gson */ @@ -343,15 +343,15 @@ static inline isc_result_t fromstruct_sig(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - isc_region_t tr; - dns_rdata_sig_t *sig; + dns_rdata_sig_t *sig = source; REQUIRE(type == 24); + REQUIRE(source != NULL); + REQUIRE(sig->common.rdtype == type); + REQUIRE(sig->common.rdclass == rdclass); + REQUIRE((sig->signature != NULL && sig->siglen != 0) || + (sig->signature == NULL && sig->siglen == 0)); - UNUSED(rdclass); - - sig = (dns_rdata_sig_t *)source; - /* * Type covered. */ @@ -395,15 +395,7 @@ fromstruct_sig(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, /* * Signature. */ - if (sig->siglen > 0) { - isc_buffer_availableregion(target, &tr); - if (tr.length < sig->siglen) - return (ISC_R_NOSPACE); - memcpy(tr.base, sig->signature, sig->siglen); - isc_buffer_add(target, sig->siglen); - } - - return (ISC_R_SUCCESS); + return (mem_tobuffer(target, sig->signature, sig->siglen)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c index a584502d96..14dd56791b 100644 --- a/lib/dns/rdata/generic/soa_6.c +++ b/lib/dns/rdata/generic/soa_6.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: soa_6.c,v 1.37 2000/05/18 05:46:52 marka Exp $ */ +/* $Id: soa_6.c,v 1.38 2000/05/22 12:37:58 marka Exp $ */ /* Reviewed: Thu Mar 16 15:18:32 PST 2000 by explorer */ @@ -256,13 +256,23 @@ static inline isc_result_t fromstruct_soa(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - UNUSED(rdclass); - UNUSED(source); - UNUSED(target); + dns_rdata_soa_t *soa = source; + isc_region_t region; REQUIRE(type == 6); + REQUIRE(source != NULL); + REQUIRE(soa->common.rdtype == type); + REQUIRE(soa->common.rdclass == rdclass); - return (ISC_R_NOTIMPLEMENTED); + dns_name_toregion(&soa->origin, ®ion); + RETERR(isc_buffer_copyregion(target, ®ion)); + dns_name_toregion(&soa->mname, ®ion); + RETERR(isc_buffer_copyregion(target, ®ion)); + RETERR(uint32_tobuffer(soa->serial, target)); + RETERR(uint32_tobuffer(soa->refresh, target)); + RETERR(uint32_tobuffer(soa->retry, target)); + RETERR(uint32_tobuffer(soa->expire, target)); + return (uint32_tobuffer(soa->minimum, target)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/tkey_249.c b/lib/dns/rdata/generic/tkey_249.c index d835629057..e2b4abdc9a 100644 --- a/lib/dns/rdata/generic/tkey_249.c +++ b/lib/dns/rdata/generic/tkey_249.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: tkey_249.c,v 1.33 2000/05/15 21:14:28 tale Exp $ */ +/* $Id: tkey_249.c,v 1.34 2000/05/22 12:37:59 marka Exp $ */ /* * Reviewed: Thu Mar 16 17:35:30 PST 2000 by halley. @@ -339,16 +339,16 @@ static inline isc_result_t fromstruct_tkey(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - isc_region_t tr; - dns_rdata_tkey_t *tkey; - - UNUSED(rdclass); - UNUSED(source); - UNUSED(target); + dns_rdata_tkey_t *tkey = source; REQUIRE(type == 249); - - tkey = (dns_rdata_tkey_t *)source; + REQUIRE(source != NULL); + REQUIRE(tkey->common.rdtype == type); + REQUIRE(tkey->common.rdclass == rdclass); + REQUIRE((tkey->key == NULL && tkey->keylen == 0) || + (tkey->key != NULL && tkey->keylen != 0)); + REQUIRE((tkey->other == NULL && tkey->otherlen == 0) || + (tkey->other != NULL && tkey->otherlen != 0)); /* * Algorithm Name. @@ -383,13 +383,7 @@ fromstruct_tkey(dns_rdataclass_t rdclass, dns_rdatatype_t type, /* * Key. */ - if (tkey->keylen > 0) { - isc_buffer_availableregion(target, &tr); - if (tr.length < tkey->keylen) - return (ISC_R_NOSPACE); - memcpy(tr.base, tkey->key, tkey->keylen); - isc_buffer_add(target, tkey->keylen); - } + RETERR(mem_tobuffer(target, tkey->key, tkey->keylen)); /* * Other size: 16 bits. @@ -399,15 +393,7 @@ fromstruct_tkey(dns_rdataclass_t rdclass, dns_rdatatype_t type, /* * Other data. */ - if (tkey->otherlen > 0) { - isc_buffer_availableregion(target, &tr); - if (tr.length < tkey->otherlen) - return (ISC_R_NOSPACE); - memcpy(tr.base, tkey->other, tkey->otherlen); - isc_buffer_add(target, tkey->otherlen); - } - - return (ISC_R_SUCCESS); + return (mem_tobuffer(target, tkey->other, tkey->otherlen)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/txt_16.c b/lib/dns/rdata/generic/txt_16.c index 26f07da7ca..ba70f42fe8 100644 --- a/lib/dns/rdata/generic/txt_16.c +++ b/lib/dns/rdata/generic/txt_16.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: txt_16.c,v 1.25 2000/05/05 05:50:10 marka Exp $ */ +/* $Id: txt_16.c,v 1.26 2000/05/22 12:38:00 marka Exp $ */ /* Reviewed: Thu Mar 16 15:40:00 PST 2000 by bwelling */ @@ -127,13 +127,28 @@ static inline isc_result_t fromstruct_txt(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - UNUSED(rdclass); - UNUSED(source); - UNUSED(target); + dns_rdata_txt_t *txt = source; + isc_region_t region; + isc_uint8_t length; REQUIRE(type == 16); + REQUIRE(source != NULL); + REQUIRE(txt->common.rdtype == type); + REQUIRE(txt->common.rdclass == rdclass); + REQUIRE((txt->txt == NULL && txt->txt_len == 0) || + (txt->txt != NULL && txt->txt_len != 0)); - return (ISC_R_NOTIMPLEMENTED); + region.base = txt->txt; + region.length = txt->txt_len; + while (region.length > 0) { + length = uint8_fromregion(®ion); + isc_region_consume(®ion, 1); + if (region.length <= length) + return (ISC_R_UNEXPECTEDEND); + isc_region_consume(®ion, length); + } + + return (mem_tobuffer(target, txt->txt, txt->txt_len)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/unspec_103.c b/lib/dns/rdata/generic/unspec_103.c index 79bfe74d48..4dbfa303bf 100644 --- a/lib/dns/rdata/generic/unspec_103.c +++ b/lib/dns/rdata/generic/unspec_103.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: unspec_103.c,v 1.19 2000/05/13 22:39:03 tale Exp $ */ +/* $Id: unspec_103.c,v 1.20 2000/05/22 12:38:01 marka Exp $ */ #ifndef RDATA_GENERIC_UNSPEC_103_C #define RDATA_GENERIC_UNSPEC_103_C @@ -95,14 +95,16 @@ static inline isc_result_t fromstruct_unspec(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { + dns_rdata_unspec_t *unspec = source; REQUIRE(type == 103); + REQUIRE(source != NULL); + REQUIRE(unspec->common.rdtype == type); + REQUIRE(unspec->common.rdclass == rdclass); + REQUIRE((unspec->data != NULL && unspec->datalen != 0) || + (unspec->data == NULL && unspec->datalen == 0)); - UNUSED(rdclass); - UNUSED(source); - UNUSED(target); - - return (ISC_R_NOTIMPLEMENTED); + return (mem_tobuffer(target, unspec->data, unspec->datalen)); } static inline isc_result_t diff --git a/lib/dns/rdata/generic/x25_19.c b/lib/dns/rdata/generic/x25_19.c index d6155c2e07..565ed6bc0b 100644 --- a/lib/dns/rdata/generic/x25_19.c +++ b/lib/dns/rdata/generic/x25_19.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: x25_19.c,v 1.19 2000/05/19 02:12:56 marka Exp $ */ +/* $Id: x25_19.c,v 1.20 2000/05/22 12:38:02 marka Exp $ */ /* Reviewed: Thu Mar 16 16:15:57 PST 2000 by bwelling */ @@ -109,13 +109,22 @@ static inline isc_result_t fromstruct_x25(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - UNUSED(rdclass); - UNUSED(source); - UNUSED(target); + dns_rdata_x25_t *x25 = source; + isc_uint8_t i; REQUIRE(type == 19); + REQUIRE(source != NULL); + REQUIRE(x25->common.rdtype == type); + REQUIRE(x25->common.rdclass == rdclass); + REQUIRE((x25->x25 == NULL && x25->x25_len == 0) || + (x25->x25 != NULL && x25->x25_len != 0)); - return (ISC_R_NOTIMPLEMENTED); + for (i = 0; i < x25->x25_len; i++) + if (!isdigit(x25->x25[i] & 0xff)) + return (ISC_R_RANGE); + + RETERR(uint8_tobuffer(x25->x25_len, target)); + return (mem_tobuffer(target, x25->x25, x25->x25_len)); } static inline isc_result_t diff --git a/lib/dns/rdata/hs_4/a_1.c b/lib/dns/rdata/hs_4/a_1.c index 3ac21ac435..c52a845fe5 100644 --- a/lib/dns/rdata/hs_4/a_1.c +++ b/lib/dns/rdata/hs_4/a_1.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: a_1.c,v 1.12 2000/05/19 13:27:45 marka Exp $ */ +/* $Id: a_1.c,v 1.13 2000/05/22 12:38:03 marka Exp $ */ /* reviewed: Thu Mar 16 15:58:36 PST 2000 by brister */ @@ -141,14 +141,18 @@ static inline isc_result_t fromstruct_hs_a(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { + dns_rdata_hs_a_t *a = source; + isc_uint32_t n; REQUIRE(type == 1); REQUIRE(rdclass == 4); + REQUIRE(source != NULL); + REQUIRE(a->common.rdtype == type); + REQUIRE(a->common.rdclass == rdclass); - UNUSED(source); - UNUSED(target); + n = ntohl(a->in_addr.s_addr); - return (ISC_R_NOTIMPLEMENTED); + return (uint32_tobuffer(n, target)); } static inline isc_result_t diff --git a/lib/dns/rdata/in_1/a6_38.c b/lib/dns/rdata/in_1/a6_38.c index 006d5e2f4f..7e5c75e9d3 100644 --- a/lib/dns/rdata/in_1/a6_38.c +++ b/lib/dns/rdata/in_1/a6_38.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: a6_38.c,v 1.31 2000/05/15 21:14:31 tale Exp $ */ + /* $Id: a6_38.c,v 1.32 2000/05/22 12:38:05 marka Exp $ */ /* draft-ietf-ipngwg-dns-lookups-03.txt */ @@ -267,10 +267,13 @@ fromstruct_in_a6(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { dns_rdata_in_a6_t *a6 = source; - unsigned char prefixlen; - unsigned char octets; + isc_region_t region; + int octets; + isc_uint8_t bits; + isc_uint8_t first; + isc_uint8_t mask; - REQUIRE(type == 1); + REQUIRE(type == 38); REQUIRE(rdclass == 1); REQUIRE(source != NULL); REQUIRE(a6->common.rdtype == type); @@ -279,21 +282,28 @@ fromstruct_in_a6(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, if (a6->prefixlen > 128) return (ISC_R_RANGE); - prefixlen = a6->prefixlen; - RETERR(mem_tobuffer(target, &prefixlen, 1)); + RETERR(uint8_tobuffer(a6->prefixlen, target)); + /* Suffix */ if (a6->prefixlen != 128) { - /* XXX fix this! */ + octets = 16 - a6->prefixlen / 8; + bits = a6->prefixlen % 8; + if (bits != 0) { + mask = 0xffU >> bits; + first = a6->in6_addr.s6_addr[16 - octets] & mask; + RETERR(uint8_tobuffer(first, target)); + octets--; + } + if (octets > 0) + RETERR(mem_tobuffer(target, + a6->in6_addr.s6_addr + 16 - octets, + octets)); } - octets = 16 - prefixlen / 8; - - /* - * XXXDCL shut up IRIX compiler until this function is finished. - */ - UNUSED(octets); - - return (ISC_R_NOTIMPLEMENTED); + if (a6->prefixlen == 0) + return (ISC_R_SUCCESS); + dns_name_toregion(&a6->prefix, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/in_1/a_1.c b/lib/dns/rdata/in_1/a_1.c index a279b6bf36..bffaf1dd50 100644 --- a/lib/dns/rdata/in_1/a_1.c +++ b/lib/dns/rdata/in_1/a_1.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: a_1.c,v 1.32 2000/05/13 20:50:35 tale Exp $ */ +/* $Id: a_1.c,v 1.33 2000/05/22 12:38:06 marka Exp $ */ /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */ @@ -139,15 +139,21 @@ static inline isc_result_t fromstruct_in_a(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - UNUSED(source); - UNUSED(target); + dns_rdata_in_a_t *a = source; + isc_uint32_t n; REQUIRE(type == 1); REQUIRE(rdclass == 1); + REQUIRE(source != NULL); + REQUIRE(a->common.rdtype == type); + REQUIRE(a->common.rdclass == rdclass); - return (ISC_R_NOTIMPLEMENTED); + n = ntohl(a->in_addr.s_addr); + + return (uint32_tobuffer(n, target)); } + static inline isc_result_t tostruct_in_a(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { dns_rdata_in_a_t *a = target; diff --git a/lib/dns/rdata/in_1/aaaa_28.c b/lib/dns/rdata/in_1/aaaa_28.c index 23998b8819..4946444928 100644 --- a/lib/dns/rdata/in_1/aaaa_28.c +++ b/lib/dns/rdata/in_1/aaaa_28.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: aaaa_28.c,v 1.23 2000/05/08 16:12:28 tale Exp $ */ +/* $Id: aaaa_28.c,v 1.24 2000/05/22 12:38:07 marka Exp $ */ /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */ @@ -139,13 +139,15 @@ static inline isc_result_t fromstruct_in_aaaa(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - UNUSED(source); - UNUSED(target); + dns_rdata_in_aaaa_t *aaaa = source; - REQUIRE(type == 1); + REQUIRE(type == 28); REQUIRE(rdclass == 1); + REQUIRE(source != NULL); + REQUIRE(aaaa->common.rdtype == type); + REQUIRE(aaaa->common.rdclass == rdclass); - return (ISC_R_NOTIMPLEMENTED); + return (mem_tobuffer(target, aaaa->in6_addr.s6_addr, 16)); } static inline isc_result_t diff --git a/lib/dns/rdata/in_1/naptr_35.c b/lib/dns/rdata/in_1/naptr_35.c index 91a6138a99..a08be99da2 100644 --- a/lib/dns/rdata/in_1/naptr_35.c +++ b/lib/dns/rdata/in_1/naptr_35.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: naptr_35.c,v 1.28 2000/05/19 13:28:36 marka Exp $ */ +/* $Id: naptr_35.c,v 1.29 2000/05/22 12:38:08 marka Exp $ */ /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */ @@ -303,13 +303,31 @@ static inline isc_result_t fromstruct_in_naptr(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - UNUSED(source); - UNUSED(target); + dns_rdata_in_naptr_t *naptr = source; + isc_region_t region; REQUIRE(type == 35); REQUIRE(rdclass == 1); + REQUIRE(source != NULL); + REQUIRE(naptr->common.rdtype == type); + REQUIRE(naptr->common.rdclass == rdclass); + REQUIRE((naptr->flags == NULL && naptr->flags_len == 0) || + (naptr->flags != NULL && naptr->flags_len != 0)); + REQUIRE((naptr->service == NULL && naptr->service_len == 0) || + (naptr->service != NULL && naptr->service_len != 0)); + REQUIRE((naptr->regexp == NULL && naptr->regexp_len == 0) || + (naptr->regexp != NULL && naptr->regexp_len != 0)); - return (ISC_R_NOTIMPLEMENTED); + RETERR(uint16_tobuffer(naptr->order, target)); + RETERR(uint16_tobuffer(naptr->preference, target)); + RETERR(uint8_tobuffer(naptr->flags_len, target)); + RETERR(mem_tobuffer(target, naptr->flags, naptr->flags_len)); + RETERR(uint8_tobuffer(naptr->service_len, target)); + RETERR(mem_tobuffer(target, naptr->service, naptr->service_len)); + RETERR(uint8_tobuffer(naptr->regexp_len, target)); + RETERR(mem_tobuffer(target, naptr->regexp, naptr->regexp_len)); + dns_name_toregion(&naptr->replacement, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/in_1/nsap-ptr_23.c b/lib/dns/rdata/in_1/nsap-ptr_23.c index 651b7e7c5f..20d907990d 100644 --- a/lib/dns/rdata/in_1/nsap-ptr_23.c +++ b/lib/dns/rdata/in_1/nsap-ptr_23.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: nsap-ptr_23.c,v 1.20 2000/05/05 23:20:06 marka Exp $ */ +/* $Id: nsap-ptr_23.c,v 1.21 2000/05/22 12:38:09 marka Exp $ */ /* Reviewed: Fri Mar 17 10:16:02 PST 2000 by gson */ @@ -131,14 +131,17 @@ static inline isc_result_t fromstruct_in_nsap_ptr(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { + dns_rdata_in_nsap_ptr_t *nsap_ptr = source; + isc_region_t region; REQUIRE(type == 23); REQUIRE(rdclass == 1); + REQUIRE(source != NULL); + REQUIRE(nsap_ptr->common.rdtype == type); + REQUIRE(nsap_ptr->common.rdclass == rdclass); - UNUSED(source); - UNUSED(target); - - return (ISC_R_NOTIMPLEMENTED); + dns_name_toregion(&nsap_ptr->owner, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/in_1/nsap_22.c b/lib/dns/rdata/in_1/nsap_22.c index 061faf4d0e..01c5f8bc28 100644 --- a/lib/dns/rdata/in_1/nsap_22.c +++ b/lib/dns/rdata/in_1/nsap_22.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: nsap_22.c,v 1.20 2000/05/08 16:12:29 tale Exp $ */ +/* $Id: nsap_22.c,v 1.21 2000/05/22 12:38:10 marka Exp $ */ /* Reviewed: Fri Mar 17 10:41:07 PST 2000 by gson */ @@ -147,14 +147,17 @@ static inline isc_result_t fromstruct_in_nsap(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { + dns_rdata_in_nsap_t *nsap = source; REQUIRE(type == 22); REQUIRE(rdclass == 1); + REQUIRE(source != NULL); + REQUIRE(nsap->common.rdtype == type); + REQUIRE(nsap->common.rdclass == rdclass); + REQUIRE((nsap->nsap == NULL && nsap->nsap_len == 0) || + (nsap->nsap != NULL && nsap->nsap_len != 0)); - UNUSED(source); - UNUSED(target); - - return (ISC_R_NOTIMPLEMENTED); + return (mem_tobuffer(target, nsap->nsap, nsap->nsap_len)); } static inline isc_result_t diff --git a/lib/dns/rdata/in_1/srv_33.c b/lib/dns/rdata/in_1/srv_33.c index 3b08204da8..b45d343072 100644 --- a/lib/dns/rdata/in_1/srv_33.c +++ b/lib/dns/rdata/in_1/srv_33.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: srv_33.c,v 1.24 2000/05/15 21:14:35 tale Exp $ */ +/* $Id: srv_33.c,v 1.25 2000/05/22 12:38:11 marka Exp $ */ /* Reviewed: Fri Mar 17 13:01:00 PST 2000 by bwelling */ @@ -220,13 +220,20 @@ static inline isc_result_t fromstruct_in_srv(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - UNUSED(source); - UNUSED(target); + dns_rdata_in_srv_t *srv = source; + isc_region_t region; REQUIRE(type == 33); REQUIRE(rdclass == 1); + REQUIRE(source != NULL); + REQUIRE(srv->common.rdtype == type); + REQUIRE(srv->common.rdclass == rdclass); - return (ISC_R_NOTIMPLEMENTED); + RETERR(uint16_tobuffer(srv->priority, target)); + RETERR(uint16_tobuffer(srv->weight, target)); + RETERR(uint16_tobuffer(srv->port, target)); + dns_name_toregion(&srv->target, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index a885b90bed..815784ad9e 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: wks_11.c,v 1.30 2000/05/19 02:07:16 marka Exp $ */ +/* $Id: wks_11.c,v 1.31 2000/05/22 12:38:12 marka Exp $ */ /* Reviewed: Fri Mar 17 15:01:49 PST 2000 by explorer */ @@ -240,13 +240,19 @@ static inline isc_result_t fromstruct_in_wks(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - UNUSED(source); - UNUSED(target); + dns_rdata_in_wks_t *wks = source; + isc_uint32_t a; REQUIRE(type == 11); REQUIRE(rdclass == 1); + REQUIRE(source != NULL); + REQUIRE(wks->common.rdtype == type); + REQUIRE(wks->common.rdclass == rdclass); - return (ISC_R_NOTIMPLEMENTED); + a = ntohl(wks->in_addr.s_addr); + RETERR(uint32_tobuffer(a, target)); + RETERR(uint16_tobuffer(wks->protocol, target)); + return (mem_tobuffer(target, wks->map, wks->map_len)); } static inline isc_result_t