afsdb_18.c revision c661868379d709416c773f6d53b5cec69c88e00f
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff/*
2bdfb330af70122f9ca5aae2556a112a3010e9efMark Andrews * Copyright (C) 1999, 2000 Internet Software Consortium.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews *
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff * copyright notice and this permission notice appear in all copies.
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff *
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * SOFTWARE.
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff */
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff
28a8f5b0de57d269cf2845c69cb6abe18cbd3b3aMark Andrews/* $Id: afsdb_18.c,v 1.26 2000/05/12 12:59:22 marka Exp $ */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/* Reviewed: Wed Mar 15 14:59:00 PST 2000 by explorer */
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff/* RFC 1183 */
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington#ifndef RDATA_GENERIC_AFSDB_18_C
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington#define RDATA_GENERIC_AFSDB_18_C
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff#define RRTYPE_AFSDB_ATTRIBUTES (0)
6028d1ce0380d0ba7f6c6ecd1ad20b31ddd1becbDavid Lawrence
364a82f7c25b62967678027043425201a5e5171aBob Halleystatic inline isc_result_t
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Grafffromtext_afsdb(dns_rdataclass_t rdclass, dns_rdatatype_t type,
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff isc_lex_t *lexer, dns_name_t *origin,
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff isc_boolean_t downcase, isc_buffer_t *target)
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff{
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff isc_token_t token;
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff isc_buffer_t buffer;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_name_t name;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews UNUSED(rdclass);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews REQUIRE(type == 18);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews /* subtype */
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews if (token.value.as_ulong > 0xffff)
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews return (DNS_R_RANGE);
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews RETERR(uint16_tobuffer(token.value.as_ulong, target));
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews /* hostname */
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews dns_name_init(&name, NULL);
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews buffer_fromregion(&buffer, &token.value.as_region);
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews origin = (origin != NULL) ? origin : dns_rootname;
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews}
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews
4a4066453f45c869fc9f91d9807b7b8b25b004a0Mark Andrewsstatic inline isc_result_t
65085946d4f92481699678e276e3ced04bcfdafbMark Andrewstotext_afsdb(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews isc_buffer_t *target)
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews{
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_name_t name;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_name_t prefix;
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews isc_region_t region;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews char buf[sizeof "64000 "];
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_boolean_t sub;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews unsigned int num;
bdfaef63f576f810fab27f64395faccf2fcd9434Francis Dupont
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews REQUIRE(rdata->type == 18);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_name_init(&name, NULL);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_name_init(&prefix, NULL);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_rdata_toregion(rdata, &region);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews num = uint16_fromregion(&region);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_region_consume(&region, 2);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews sprintf(buf, "%u ", num);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews RETERR(str_totext(buf, target));
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_name_fromregion(&name, &region);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews sub = name_prefix(&name, tctx->origin, &prefix);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews return (dns_name_totext(&prefix, sub, target));
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews}
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrewsstatic inline isc_result_t
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrewsfromwire_afsdb(dns_rdataclass_t rdclass, dns_rdatatype_t type,
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_buffer_t *source, dns_decompress_t *dctx,
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein isc_boolean_t downcase, isc_buffer_t *target)
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington{
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington dns_name_t name;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_region_t sr;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_region_t tr;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews UNUSED(rdclass);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews REQUIRE(type == 18);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_name_init(&name, NULL);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_buffer_activeregion(source, &sr);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_buffer_availableregion(target, &tr);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews if (tr.length < 2)
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews return (ISC_R_NOSPACE);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews if (sr.length < 2)
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews return (ISC_R_UNEXPECTEDEND);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews memcpy(tr.base, sr.base, 2);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_buffer_forward(source, 2);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_buffer_add(target, 2);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews return (dns_name_fromwire(&name, source, dctx, downcase, target));
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews}
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrewsstatic inline isc_result_t
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrewstowire_afsdb(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target)
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews{
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_region_t tr;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_region_t sr;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_name_t name;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews REQUIRE(rdata->type == 18);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_buffer_availableregion(target, &tr);
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington dns_rdata_toregion(rdata, &sr);
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews if (tr.length < 2)
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington return (ISC_R_NOSPACE);
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff memcpy(tr.base, sr.base, 2);
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff isc_region_consume(&sr, 2);
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff isc_buffer_add(target, 2);
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff
735ca24fa61ad9cd0285776c2fc4c14032f8f194Mark Andrews dns_name_init(&name, NULL);
735ca24fa61ad9cd0285776c2fc4c14032f8f194Mark Andrews dns_name_fromregion(&name, &sr);
735ca24fa61ad9cd0285776c2fc4c14032f8f194Mark Andrews
735ca24fa61ad9cd0285776c2fc4c14032f8f194Mark Andrews return (dns_name_towire(&name, cctx, target));
735ca24fa61ad9cd0285776c2fc4c14032f8f194Mark Andrews}
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graffstatic inline int
65085946d4f92481699678e276e3ced04bcfdafbMark Andrewscompare_afsdb(dns_rdata_t *rdata1, dns_rdata_t *rdata2)
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews{
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews int result;
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff dns_name_t name1;
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff dns_name_t name2;
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff isc_region_t region1;
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington isc_region_t region2;
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews REQUIRE(rdata1->type == rdata2->type);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews REQUIRE(rdata1->rdclass == rdata2->rdclass);
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews REQUIRE(rdata1->type == 18);
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff result = memcmp(rdata1->data, rdata2->data, 2);
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff if (result != 0)
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington return (result < 0 ? -1 : 1);
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington dns_name_init(&name1, NULL);
c1ee8bb4ba3e9ab1463403ed685729631de406b1Mark Andrews dns_name_init(&name2, NULL);
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington dns_rdata_toregion(rdata1, &region1);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_rdata_toregion(rdata2, &region2);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews isc_region_consume(&region1, 2);
784a904bd06c7492361ed09a882d10c636b1291bAutomatic Updater isc_region_consume(&region2, 2);
c1ee8bb4ba3e9ab1463403ed685729631de406b1Mark Andrews
c1ee8bb4ba3e9ab1463403ed685729631de406b1Mark Andrews dns_name_fromregion(&name1, &region1);
c1ee8bb4ba3e9ab1463403ed685729631de406b1Mark Andrews dns_name_fromregion(&name2, &region2);
c1ee8bb4ba3e9ab1463403ed685729631de406b1Mark Andrews
c1ee8bb4ba3e9ab1463403ed685729631de406b1Mark Andrews return (dns_name_rdatacompare(&name1, &name2));
c1ee8bb4ba3e9ab1463403ed685729631de406b1Mark Andrews}
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellingtonstatic inline isc_result_t
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellingtonfromstruct_afsdb(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington isc_buffer_t *target)
1b088f46804fd569bf1b2274583d48e83f4f7aebAndreas Gustafsson{
c1ee8bb4ba3e9ab1463403ed685729631de406b1Mark Andrews UNUSED(rdclass);
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley UNUSED(source);
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley UNUSED(target);
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews REQUIRE(type == 18);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
735ca24fa61ad9cd0285776c2fc4c14032f8f194Mark Andrews return (ISC_R_NOTIMPLEMENTED);
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews}
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
65085946d4f92481699678e276e3ced04bcfdafbMark Andrewsstatic inline isc_result_t
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellingtontostruct_afsdb(dns_rdata_t *rdata, void *target, isc_mem_t *mctx)
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington{
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley isc_region_t region;
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley dns_rdata_afsdb_t *afsdb = target;
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley dns_name_t name;
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley REQUIRE(rdata->type == 18);
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley REQUIRE(target != NULL);
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley afsdb->common.rdclass = rdata->rdclass;
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley afsdb->common.rdtype = rdata->type;
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley ISC_LINK_INIT(&afsdb->common, link);
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_name_init(&afsdb->server, NULL);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_rdata_toregion(rdata, &region);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington afsdb->subtype = uint16_fromregion(&region);
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington isc_region_consume(&region, 2);
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley dns_name_init(&name, NULL);
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley dns_name_fromregion(&name, &region);
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley RETERR(name_duporclone(&name, mctx, &afsdb->server));
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews afsdb->mctx = mctx;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews return (ISC_R_SUCCESS);
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington}
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrewsstatic inline void
735ca24fa61ad9cd0285776c2fc4c14032f8f194Mark Andrewsfreestruct_afsdb(void *source)
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews{
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews dns_rdata_afsdb_t *afsdb = source;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews REQUIRE(source != NULL);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews REQUIRE(afsdb->common.rdtype == 18);
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews if (afsdb->mctx == NULL)
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews return;
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews dns_name_free(&afsdb->server, afsdb->mctx);
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews afsdb->mctx = NULL;
d76ed813a51465e5c47d521ab09ea20c06f1428dMark Andrews}
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews
65085946d4f92481699678e276e3ced04bcfdafbMark Andrewsstatic inline isc_result_t
65085946d4f92481699678e276e3ced04bcfdafbMark Andrewsadditionaldata_afsdb(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews void *arg)
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews{
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews dns_name_t name;
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews isc_region_t region;
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews REQUIRE(rdata->type == 18);
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff dns_name_init(&name, NULL);
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley dns_rdata_toregion(rdata, &region);
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff isc_region_consume(&region, 2);
c1ee8bb4ba3e9ab1463403ed685729631de406b1Mark Andrews dns_name_fromregion(&name, &region);
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews
c1ee8bb4ba3e9ab1463403ed685729631de406b1Mark Andrews return ((add)(arg, &name, dns_rdatatype_a));
65085946d4f92481699678e276e3ced04bcfdafbMark Andrews}
c1ee8bb4ba3e9ab1463403ed685729631de406b1Mark Andrews
65085946d4f92481699678e276e3ced04bcfdafbMark Andrewsstatic inline isc_result_t
c1ee8bb4ba3e9ab1463403ed685729631de406b1Mark Andrewsdigest_afsdb(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg)
c1ee8bb4ba3e9ab1463403ed685729631de406b1Mark Andrews{
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews isc_region_t r1, r2;
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews dns_name_t name;
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews REQUIRE(rdata->type == 18);
a76b380643a22f23a67a9df284e86cd7ef7608c1Mark Andrews
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff dns_rdata_toregion(rdata, &r1);
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley r2 = r1;
bab57cc87ffc890ba1ba3dbc6c022ae1a36726bcBob Halley isc_region_consume(&r2, 2);
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley r1.length = 2;
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley RETERR((digest)(arg, &r1));
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley dns_name_init(&name, NULL);
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley dns_name_fromregion(&name, &r2);
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley return (dns_name_digest(&name, digest, arg));
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley}
383665e42ad838046472e847b16c4e0d3f1aaf76Bob Halley
88b9c12a3cbafc3bebedf50a731bec9ce2f99a13Brian Wellington#endif /* RDATA_GENERIC_AFSDB_18_C */
cd82aa8fa32698240ecd6634f11e3052ca7a2448Michael Graff