From 2e8215dda9e102355baca77e4e59132eff8e2357 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 17 Jan 2000 03:21:53 +0000 Subject: [PATCH] checkpoint to/from struct support --- lib/dns/rdata/generic/ns_2.c | 13 ++++--- lib/dns/rdata/in_1/a6_38.c | 21 +++++++++-- lib/dns/rdata/in_1/kx_36.c | 46 ++++++++++++++++++------ lib/dns/rdata/in_1/kx_36.h | 8 ++++- lib/dns/rdata/in_1/naptr_35.h | 12 ++++++- lib/dns/rdata/in_1/nsap-ptr_23.h | 7 +++- lib/dns/rdata/in_1/nsap_22.h | 8 ++++- lib/dns/rdata/in_1/px_26.c | 61 ++++++++++++++++++++++++++------ lib/dns/rdata/in_1/px_26.h | 9 ++++- lib/dns/rdata/in_1/srv_33.h | 11 +++++- lib/dns/rdata/in_1/wks_11.h | 10 +++++- 11 files changed, 171 insertions(+), 35 deletions(-) diff --git a/lib/dns/rdata/generic/ns_2.c b/lib/dns/rdata/generic/ns_2.c index 6ac35bfa41..b93cb3e1da 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.19 1999/12/23 00:08:55 explorer Exp $ */ + /* $Id: ns_2.c,v 1.20 2000/01/17 03:21:53 marka Exp $ */ #ifndef RDATA_GENERIC_NS_2_C #define RDATA_GENERIC_NS_2_C @@ -31,7 +31,7 @@ fromtext_ns(dns_rdataclass_t rdclass, dns_rdatatype_t type, REQUIRE(type == 2); - rdclass = rdclass; /*unused*/ + UNUSED(rdclass); RETERR(gettoken(lexer, &token,isc_tokentype_string, ISC_FALSE)); @@ -73,7 +73,7 @@ fromwire_ns(dns_rdataclass_t rdclass, dns_rdatatype_t type, REQUIRE(type == 2); - rdclass = rdclass; /*unused*/ + UNUSED(rdclass); if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx)) dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL); @@ -146,6 +146,7 @@ tostruct_ns(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { isc_region_t region; dns_rdata_ns_t *ns = target; dns_name_t name; + isc_result_t result; REQUIRE(rdata->type == 2); REQUIRE(target != NULL); @@ -160,9 +161,11 @@ tostruct_ns(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { dns_name_fromregion(&name, ®ion); ns->mctx = mctx; dns_name_init(&ns->name, NULL); - dns_name_dup(&name, ns->mctx, &ns->name); + result = dns_name_dup(&name, ns->mctx, &ns->name); + if (result != ISC_R_SUCCESS) + ns->mctx = NULL; - return (DNS_R_SUCCESS); + return (result); } static inline void diff --git a/lib/dns/rdata/in_1/a6_38.c b/lib/dns/rdata/in_1/a6_38.c index 9a49dc8e60..c949c25092 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.18 1999/12/23 00:09:01 explorer Exp $ */ + /* $Id: a6_38.c,v 1.19 2000/01/17 03:21:49 marka Exp $ */ /* draft-ietf-ipngwg-dns-lookups-03.txt */ @@ -262,12 +262,27 @@ static inline isc_result_t 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; REQUIRE(type == 1); REQUIRE(rdclass == 1); + REQUIRE(source != NULL); + REQUIRE(a6->common.rdtype == type); + REQUIRE(a6->common.rdclass == rdclass); - source = source; - target = target; + if (a6->prefixlen > 128) + return (DNS_R_RANGE); + + prefixlen = a6->prefixlen; + RETERR(mem_tobuffer(target, &prefixlen, 1)); + + if (a6->prefixlen != 128) { + + } + + octets = 16 - prefixlen / 8; return (DNS_R_NOTIMPLEMENTED); } diff --git a/lib/dns/rdata/in_1/kx_36.c b/lib/dns/rdata/in_1/kx_36.c index edb53e339e..a7fa374ad5 100644 --- a/lib/dns/rdata/in_1/kx_36.c +++ b/lib/dns/rdata/in_1/kx_36.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: kx_36.c,v 1.14 1999/12/23 00:09:02 explorer Exp $ */ + /* $Id: kx_36.c,v 1.15 2000/01/17 03:21:50 marka Exp $ */ /* RFC 2230 */ @@ -159,33 +159,59 @@ static inline isc_result_t fromstruct_in_kx(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { + dns_rdata_in_kx_t *kx = source; + isc_region_t region; REQUIRE(type == 36); REQUIRE(rdclass == 1); + REQUIRE(source != NULL); + REQUIRE(kx->common.rdtype == type); + REQUIRE(kx->common.rdclass == rdclass); - source = source; - target = target; - - return (DNS_R_NOTIMPLEMENTED); + RETERR(uint16_tobuffer(kx->preference, target)); + dns_name_toregion(&kx->exchange, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t tostruct_in_kx(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + isc_region_t region; + dns_rdata_in_kx_t *kx = target; + dns_name_t name; + isc_result_t result; REQUIRE(rdata->type == 36); REQUIRE(rdata->rdclass == 1); + REQUIRE(target != NULL); + REQUIRE(mctx != NULL); - target = target; - mctx = mctx; + kx->common.rdclass = rdata->rdclass; + kx->common.rdtype = rdata->type; + ISC_LINK_INIT(&kx->common, link); - return (DNS_R_NOTIMPLEMENTED); + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + + kx->preference = uint16_fromregion(®ion); + isc_region_consume(®ion, 2); + + dns_name_fromregion(&name, ®ion); + kx->mctx = mctx; + dns_name_init(&kx->exchange, NULL); + result = dns_name_dup(&name, kx->mctx, &kx->exchange); + if (result != ISC_R_SUCCESS) + kx->mctx = NULL; + return (result); } static inline void freestruct_in_kx(void *source) { - REQUIRE(source != NULL); - REQUIRE(ISC_FALSE); + dns_rdata_in_kx_t *kx = source; + REQUIRE(source != NULL); + + dns_name_free(&kx->exchange, kx->mctx); + kx->mctx = NULL; } static inline isc_result_t diff --git a/lib/dns/rdata/in_1/kx_36.h b/lib/dns/rdata/in_1/kx_36.h index f616961cb0..697968d52a 100644 --- a/lib/dns/rdata/in_1/kx_36.h +++ b/lib/dns/rdata/in_1/kx_36.h @@ -15,7 +15,13 @@ * SOFTWARE. */ - /* $Id: kx_36.h,v 1.8 1999/09/15 23:03:35 explorer Exp $ */ + /* $Id: kx_36.h,v 1.9 2000/01/17 03:21:50 marka Exp $ */ /* RFC 2230 */ +typedef struct dns_rdata_in_kx { + dns_rdatacommon_t common; + isc_mem_t *mctx; + isc_uint16_t preference; + dns_name_t exchange; +} dns_rdata_in_kx_t; diff --git a/lib/dns/rdata/in_1/naptr_35.h b/lib/dns/rdata/in_1/naptr_35.h index eaadc4dda0..c411c228ce 100644 --- a/lib/dns/rdata/in_1/naptr_35.h +++ b/lib/dns/rdata/in_1/naptr_35.h @@ -15,7 +15,17 @@ * SOFTWARE. */ - /* $Id: naptr_35.h,v 1.8 1999/09/15 23:03:36 explorer Exp $ */ + /* $Id: naptr_35.h,v 1.9 2000/01/17 03:21:50 marka Exp $ */ /* RFC 2168 */ +typedef struct dns_rdata_in_naptr { + dns_rdatacommon_t common; + isc_mem_t *mctx; + isc_uint16_t order; + isc_uint16_t preference; + char *flags; + char *service; + char *regexp; + dns_name_t replacement; +} dns_rdata_in_naptr_t; diff --git a/lib/dns/rdata/in_1/nsap-ptr_23.h b/lib/dns/rdata/in_1/nsap-ptr_23.h index 8a7e12ef28..1da0669faf 100644 --- a/lib/dns/rdata/in_1/nsap-ptr_23.h +++ b/lib/dns/rdata/in_1/nsap-ptr_23.h @@ -15,7 +15,12 @@ * SOFTWARE. */ - /* $Id: nsap-ptr_23.h,v 1.7 1999/09/15 23:03:36 explorer Exp $ */ + /* $Id: nsap-ptr_23.h,v 1.8 2000/01/17 03:21:50 marka Exp $ */ /* RFC 1348 */ +typedef struct dns_rdata_in_nsap_ptr { + dns_rdatacommon_t common; + isc_mem_t *mctx; + dns_name_t owner; +} dns_rdata_in_nsap_ptr_t; diff --git a/lib/dns/rdata/in_1/nsap_22.h b/lib/dns/rdata/in_1/nsap_22.h index 2e6665787d..97fd7fec2a 100644 --- a/lib/dns/rdata/in_1/nsap_22.h +++ b/lib/dns/rdata/in_1/nsap_22.h @@ -15,7 +15,13 @@ * SOFTWARE. */ - /* $Id: nsap_22.h,v 1.5 1999/09/15 23:03:36 explorer Exp $ */ + /* $Id: nsap_22.h,v 1.6 2000/01/17 03:21:51 marka Exp $ */ /* RFC 1706 */ +typedef struct dns_rdata_in_nsap { + dns_rdatacommon_t common; + isc_mem_t *mctx; + unsigned char *nsap; + isc_uint16_t length; +} dns_rdata_in_nsap_t; diff --git a/lib/dns/rdata/in_1/px_26.c b/lib/dns/rdata/in_1/px_26.c index fef7aa385c..ff2087a936 100644 --- a/lib/dns/rdata/in_1/px_26.c +++ b/lib/dns/rdata/in_1/px_26.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: px_26.c,v 1.12 1999/12/23 00:09:03 explorer Exp $ */ + /* $Id: px_26.c,v 1.13 2000/01/17 03:21:51 marka Exp $ */ /* RFC 2163 */ @@ -201,33 +201,74 @@ static inline isc_result_t fromstruct_in_px(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target) { + dns_rdata_in_px_t *px = source; + isc_region_t region; REQUIRE(type == 26); REQUIRE(rdclass == 1); + REQUIRE(source != NULL); + REQUIRE(px->common.rdtype == type); + REQUIRE(px->common.rdclass == rdclass); - source = source; - target = target; - - return (DNS_R_NOTIMPLEMENTED); + RETERR(uint16_tobuffer(px->preference, target)); + dns_name_toregion(&px->map822, ®ion); + RETERR(isc_buffer_copyregion(target, ®ion)); + dns_name_toregion(&px->mapx400, ®ion); + return (isc_buffer_copyregion(target, ®ion)); } static inline isc_result_t tostruct_in_px(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + isc_region_t region; + isc_region_t nr; + dns_rdata_in_px_t *px = target; + dns_name_t name; + isc_result_t result; REQUIRE(rdata->type == 26); REQUIRE(rdata->rdclass == 1); + REQUIRE(target != NULL); + REQUIRE(mctx != NULL); - target = target; - mctx = mctx; + px->common.rdclass = rdata->rdclass; + px->common.rdtype = rdata->type; + ISC_LINK_INIT(&px->common, link); - return (DNS_R_NOTIMPLEMENTED); + dns_name_init(&name, NULL); + dns_rdata_toregion(rdata, ®ion); + + px->preference = uint16_fromregion(®ion); + isc_region_consume(®ion, 2); + + dns_name_fromregion(&name, ®ion); + dns_name_toregion(&name, &nr); + isc_region_consume(®ion, nr.length); + px->mctx = mctx; + dns_name_init(&px->map822, NULL); + result = dns_name_dup(&name, px->mctx, &px->map822); + if (result != ISC_R_SUCCESS) { + px->mctx = NULL; + return (result); + } + + dns_name_init(&px->mapx400, NULL); + result = dns_name_dup(&name, px->mctx, &px->map822); + if (result != ISC_R_SUCCESS) { + dns_name_free(&px->map822, px->mctx); + px->mctx = NULL; + } + return (result); } static inline void freestruct_in_px(void *source) { - REQUIRE(source != NULL); - REQUIRE(ISC_FALSE); /*XXX*/ + dns_rdata_in_px_t *px = source; + REQUIRE(source != NULL); + + dns_name_free(&px->map822, px->mctx); + dns_name_free(&px->mapx400, px->mctx); + px->mctx = NULL; } static inline isc_result_t diff --git a/lib/dns/rdata/in_1/px_26.h b/lib/dns/rdata/in_1/px_26.h index e20cede5c0..2d843c072e 100644 --- a/lib/dns/rdata/in_1/px_26.h +++ b/lib/dns/rdata/in_1/px_26.h @@ -15,7 +15,14 @@ * SOFTWARE. */ - /* $Id: px_26.h,v 1.7 1999/09/15 23:03:37 explorer Exp $ */ + /* $Id: px_26.h,v 1.8 2000/01/17 03:21:52 marka Exp $ */ /* RFC 2163 */ +typedef struct dns_rdata_in_px { + dns_rdatacommon_t common; + isc_mem_t *mctx; + isc_uint16_t preference; + dns_name_t map822; + dns_name_t mapx400; +} dns_rdata_in_px_t; diff --git a/lib/dns/rdata/in_1/srv_33.h b/lib/dns/rdata/in_1/srv_33.h index 807d07c3e6..207a03b2bd 100644 --- a/lib/dns/rdata/in_1/srv_33.h +++ b/lib/dns/rdata/in_1/srv_33.h @@ -15,7 +15,16 @@ * SOFTWARE. */ - /* $Id: srv_33.h,v 1.7 1999/09/15 23:03:37 explorer Exp $ */ + /* $Id: srv_33.h,v 1.8 2000/01/17 03:21:52 marka Exp $ */ /* RFC 2052 bis */ +typedef struct dns_rdata_in_srv { + dns_rdatacommon_t common; + isc_mem_t *mctx; + isc_uint16_t priority; + isc_uint16_t weight; + isc_uint16_t port; + dns_name_t target; +} dns_rdata_in_srv_t; + diff --git a/lib/dns/rdata/in_1/wks_11.h b/lib/dns/rdata/in_1/wks_11.h index 648f276375..b6aee2de8e 100644 --- a/lib/dns/rdata/in_1/wks_11.h +++ b/lib/dns/rdata/in_1/wks_11.h @@ -15,5 +15,13 @@ * SOFTWARE. */ - /* $Id: wks_11.h,v 1.11 1999/09/15 23:03:38 explorer Exp $ */ + /* $Id: wks_11.h,v 1.12 2000/01/17 03:21:52 marka Exp $ */ +typedef struct dns_rdata_in_wks { + dns_rdatacommon_t common; + isc_mem_t *mctx; + struct in_addr in_addr; + isc_uint16_t protocol; + unsigned char *map; + isc_uint16_t length; +} dns_rdata_in_wks_t;