From 05f90cac85760b4edef2962209df49ea019c180f Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 2 Sep 1999 06:40:15 +0000 Subject: [PATCH] Adjust / add stucture definitions for NS/SOA/A/AAAA/A6 records. --- lib/dns/rdata/generic/ns_2.c | 19 +++++++++++++------ lib/dns/rdata/generic/ns_2.h | 5 +++-- lib/dns/rdata/generic/soa_6.c | 34 +++++++++++++++++++++++----------- lib/dns/rdata/generic/soa_6.h | 9 ++++++--- lib/dns/rdata/in_1/a6_38.h | 10 +++++++++- lib/dns/rdata/in_1/a_1.c | 18 ++++++++++++++---- lib/dns/rdata/in_1/a_1.h | 4 ++-- lib/dns/rdata/in_1/aaaa_28.h | 7 ++++++- lib/dns/rdata/rdatastructpre.h | 1 + 9 files changed, 77 insertions(+), 30 deletions(-) diff --git a/lib/dns/rdata/generic/ns_2.c b/lib/dns/rdata/generic/ns_2.c index 1fa21677a4..38352c9b46 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.17 1999/08/31 22:05:54 halley Exp $ */ + /* $Id: ns_2.c,v 1.18 1999/09/02 06:40:14 marka Exp $ */ #ifndef RDATA_GENERIC_NS_2_C #define RDATA_GENERIC_NS_2_C @@ -145,27 +145,34 @@ static inline dns_result_t 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; REQUIRE(rdata->type == 2); REQUIRE(target != NULL); - - mctx = mctx; /*unused*/ + REQUIRE(mctx != NULL); ns->common.rdclass = rdata->rdclass; ns->common.rdtype = rdata->type; ISC_LINK_INIT(&ns->common, link); + dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); - dns_fixedname_init(&ns->name); - dns_name_fromregion(dns_fixedname_name(&ns->name), ®ion); + dns_name_fromregion(&name, ®ion); + ns->mctx = mctx; + dns_name_init(&ns->name, NULL); + dns_name_dup(&name, ns->mctx, &ns->name); return (DNS_R_SUCCESS); } static inline void freestruct_ns(void *source) { + dns_rdata_ns_t *ns = source; + REQUIRE(source != NULL); - /* No action required. */ + + dns_name_free(&ns->name, ns->mctx); + ns->mctx = NULL; } static inline dns_result_t diff --git a/lib/dns/rdata/generic/ns_2.h b/lib/dns/rdata/generic/ns_2.h index 5e5c8727dd..b652d6ed10 100644 --- a/lib/dns/rdata/generic/ns_2.h +++ b/lib/dns/rdata/generic/ns_2.h @@ -15,12 +15,13 @@ * SOFTWARE. */ - /* $Id: ns_2.h,v 1.13 1999/07/05 00:32:37 marka Exp $ */ + /* $Id: ns_2.h,v 1.14 1999/09/02 06:40:14 marka Exp $ */ #include typedef struct dns_rdata_ns { dns_rdatacommon_t common; - dns_fixedname_t name; + isc_mem_t *mctx; + dns_name_t name; } dns_rdata_ns_t; diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c index 6371d7c9e1..2f17ee6233 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.22 1999/08/31 22:05:55 halley Exp $ */ + /* $Id: soa_6.c,v 1.23 1999/09/02 06:40:14 marka Exp $ */ #ifndef RDATA_GENERIC_SOA_6_C #define RDATA_GENERIC_SOA_6_C @@ -264,25 +264,34 @@ static inline dns_result_t tostruct_soa(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { isc_region_t region; dns_rdata_soa_t *soa = target; + dns_name_t name; + dns_result_t result; REQUIRE(rdata->type == 6); REQUIRE(target != NULL); - mctx = mctx; /*unused*/ - soa->common.rdclass = rdata->rdclass; soa->common.rdtype = rdata->type; ISC_LINK_INIT(&soa->common, link); + soa->mctx = mctx; + + dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); - dns_fixedname_init(&soa->origin); - dns_name_fromregion(dns_fixedname_name(&soa->origin), ®ion); - isc_region_consume(®ion, - name_length(dns_fixedname_name(&soa->origin))); - dns_fixedname_init(&soa->mname); - dns_name_fromregion(dns_fixedname_name(&soa->mname), ®ion); - isc_region_consume(®ion, - name_length(dns_fixedname_name(&soa->mname))); + dns_name_fromregion(&name, ®ion); + isc_region_consume(®ion, name_length(&name)); + dns_name_init(&soa->origin, NULL); + result = dns_name_dup(&name, soa->mctx, &soa->origin); + if (result != DNS_R_SUCCESS) + return (result); + + dns_name_fromregion(&name, ®ion); + isc_region_consume(®ion, name_length(&name)); + dns_name_init(&soa->mname, NULL); + result = dns_name_dup(&name, soa->mctx, &soa->mname); + if (result != DNS_R_SUCCESS) + return (result); + soa->serial = uint32_fromregion(®ion); isc_region_consume(®ion, 4); soa->refresh = uint32_fromregion(®ion); @@ -302,6 +311,9 @@ freestruct_soa(void *source) { REQUIRE(source != NULL); REQUIRE(soa->common.rdtype == 6); + dns_name_free(&soa->origin, soa->mctx); + dns_name_free(&soa->mname, soa->mctx); + soa->mctx = NULL; /* No action required */ } diff --git a/lib/dns/rdata/generic/soa_6.h b/lib/dns/rdata/generic/soa_6.h index 8956609623..c1647df0d3 100644 --- a/lib/dns/rdata/generic/soa_6.h +++ b/lib/dns/rdata/generic/soa_6.h @@ -15,12 +15,15 @@ * SOFTWARE. */ - /* $Id: soa_6.h,v 1.16 1999/05/07 03:24:12 marka Exp $ */ + /* $Id: soa_6.h,v 1.17 1999/09/02 06:40:14 marka Exp $ */ + +#include typedef struct dns_rdata_soa { dns_rdatacommon_t common; - dns_fixedname_t origin; - dns_fixedname_t mname; + isc_mem_t *mctx; + dns_name_t origin; + dns_name_t mname; isc_uint32_t serial; /* host order */ isc_uint32_t refresh; /* host order */ isc_uint32_t retry; /* host order */ diff --git a/lib/dns/rdata/in_1/a6_38.h b/lib/dns/rdata/in_1/a6_38.h index 5ab40a9bdb..e89bc68a50 100644 --- a/lib/dns/rdata/in_1/a6_38.h +++ b/lib/dns/rdata/in_1/a6_38.h @@ -15,7 +15,15 @@ * SOFTWARE. */ - /* $Id: a6_38.h,v 1.9 1999/05/07 03:24:13 marka Exp $ */ + /* $Id: a6_38.h,v 1.10 1999/09/02 06:40:14 marka Exp $ */ /* draft-ietf-ipngwg-dns-lookups-03.txt */ +typedef struct dns_rdata_in_a6 { + dns_rdatacommon_t common; + isc_mem_t *mctx; + dns_name_t prefix; + isc_uint32_t prefixlen; + struct in6_addr in6_addr; +} dns_rdata_in_a6_t; + diff --git a/lib/dns/rdata/in_1/a_1.c b/lib/dns/rdata/in_1/a_1.c index 63383eaa9e..6d18e54233 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.19 1999/08/31 22:03:59 halley Exp $ */ + /* $Id: a_1.c,v 1.20 1999/09/02 06:40:14 marka Exp $ */ #ifndef RDATA_IN_1_A_1_C #define RDATA_IN_1_A_1_C @@ -149,14 +149,24 @@ fromstruct_in_a(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, static inline dns_result_t tostruct_in_a(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) { + dns_rdata_in_a_t *a = target; + isc_uint32_t n; + isc_region_t region; REQUIRE(rdata->type == 1); REQUIRE(rdata->rdclass == 1); - target = target; - mctx = mctx; + mctx = mctx; /* unused */ - return (DNS_R_NOTIMPLEMENTED); + a->common.rdclass = rdata->rdclass; + a->common.rdtype = rdata->type; + ISC_LINK_INIT(&a->common, link); + + dns_rdata_toregion(rdata, ®ion); + n = uint32_fromregion(®ion); + a->in_addr.s_addr = htonl(n); + + return (DNS_R_SUCCESS); } static inline void diff --git a/lib/dns/rdata/in_1/a_1.h b/lib/dns/rdata/in_1/a_1.h index 04178bc9c8..2aaa9ddea9 100644 --- a/lib/dns/rdata/in_1/a_1.h +++ b/lib/dns/rdata/in_1/a_1.h @@ -15,9 +15,9 @@ * SOFTWARE. */ - /* $Id: a_1.h,v 1.14 1999/05/07 03:24:13 marka Exp $ */ + /* $Id: a_1.h,v 1.15 1999/09/02 06:40:15 marka Exp $ */ typedef struct dns_rdata_in_a { dns_rdatacommon_t common; - isc_uint32_t address; /* network order */ + struct in_addr in_addr; } dns_rdata_in_a_t; diff --git a/lib/dns/rdata/in_1/aaaa_28.h b/lib/dns/rdata/in_1/aaaa_28.h index 5f564357f3..33ee13a217 100644 --- a/lib/dns/rdata/in_1/aaaa_28.h +++ b/lib/dns/rdata/in_1/aaaa_28.h @@ -15,7 +15,12 @@ * SOFTWARE. */ - /* $Id: aaaa_28.h,v 1.8 1999/05/07 03:24:14 marka Exp $ */ + /* $Id: aaaa_28.h,v 1.9 1999/09/02 06:40:15 marka Exp $ */ /* RFC 1886 */ +typedef struct dns_rdata_in_aaaa { + dns_rdatacommon_t common; + struct in6_addr in6_addr; +} dns_rdata_in_aaaa_t; + diff --git a/lib/dns/rdata/rdatastructpre.h b/lib/dns/rdata/rdatastructpre.h index 0427308f7a..d573432478 100644 --- a/lib/dns/rdata/rdatastructpre.h +++ b/lib/dns/rdata/rdatastructpre.h @@ -3,6 +3,7 @@ #define DNS_RDATASTRUCT_H 1 #include +#include ISC_LANG_BEGINDECLS