ptr_12.c revision e0a30050c8516a3d54a4f8dcdd88435704a8a3ed
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews/*
503ffdad3bc62e6458e4b60e329aa448ce1803a1Tinderbox User * Copyright (C) 2004, 2007, 2009, 2015 Internet Systems Consortium, Inc. ("ISC")
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington * Copyright (C) 1998-2001 Internet Software Consortium.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * Permission to use, copy, modify, and/or distribute this software for any
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * purpose with or without fee is hereby granted, provided that the above
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews */
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
4b6dc226f78862286daa69fba761eac9fd5da16aAutomatic Updater/* $Id: ptr_12.c,v 1.45 2009/12/04 22:06:37 tbox Exp $ */
940e4ef72b64a8a82a1038fdf08b324eec6e43a9Michael Graff
940e4ef72b64a8a82a1038fdf08b324eec6e43a9Michael Graff/* Reviewed: Thu Mar 16 14:05:12 PST 2000 by explorer */
3761c433912beabe43abeed2c3513b6201c59f64Mark Andrews
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews#ifndef RDATA_GENERIC_PTR_12_C
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews#define RDATA_GENERIC_PTR_12_C
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
6324997211a5e2d82528dcde98e8981190a35faeMichael Graff#define RRTYPE_PTR_ATTRIBUTES (0)
6324997211a5e2d82528dcde98e8981190a35faeMichael Graff
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefromtext_ptr(ARGS_FROMTEXT) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_token_t token;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t name;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_buffer_t buffer;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_ptr);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington UNUSED(type);
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington UNUSED(rdclass);
bddfe77128b0f16af263ff149db40f0d885f43d0Mark Andrews UNUSED(callbacks);
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington
add4043305ca411202ed9cf1929a4179016515ceBrian Wellington RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
add4043305ca411202ed9cf1929a4179016515ceBrian Wellington ISC_FALSE));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_init(&name, NULL);
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence buffer_fromregion(&buffer, &token.value.as_region);
e0a30050c8516a3d54a4f8dcdd88435704a8a3edMark Andrews if (origin == NULL)
e0a30050c8516a3d54a4f8dcdd88435704a8a3edMark Andrews origin = dns_rootname;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews if (rdclass == dns_rdataclass_in &&
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews (options & DNS_RDATA_CHECKNAMES) != 0 &&
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews (options & DNS_RDATA_CHECKREVERSE) != 0) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews isc_boolean_t ok;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews ok = dns_name_ishostname(&name, ISC_FALSE);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0)
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews RETTOK(DNS_R_BADNAME);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews if (!ok && callbacks != NULL)
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews warn_badname(&name, lexer, callbacks);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews }
9ac7076ebad044afb15e9e2687e3696868778538Mark Andrews return (ISC_R_SUCCESS);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencetotext_ptr(ARGS_TOTEXT) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_region_t region;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t name;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t prefix;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_boolean_t sub;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_ptr);
b589e90689c6e87bf9608424ca8d99571c18bc61Mark Andrews REQUIRE(rdata->length != 0);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_init(&name, NULL);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_init(&prefix, NULL);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_rdata_toregion(rdata, &region);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_fromregion(&name, &region);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson sub = name_prefix(&name, tctx->origin, &prefix);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews return (dns_name_totext(&prefix, sub, target));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefromwire_ptr(ARGS_FROMWIRE) {
4b6dc226f78862286daa69fba761eac9fd5da16aAutomatic Updater dns_name_t name;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_ptr);
1ef8965366d91e02a4672c35a187d30aa4a4c72cMark Andrews
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington UNUSED(type);
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington UNUSED(rdclass);
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington
94a08e09db3dc844b6ee4841c368a2d7074a9c3fAndreas Gustafsson dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
4b6dc226f78862286daa69fba761eac9fd5da16aAutomatic Updater dns_name_init(&name, NULL);
4b6dc226f78862286daa69fba761eac9fd5da16aAutomatic Updater return (dns_name_fromwire(&name, source, dctx, options, target));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencetowire_ptr(ARGS_TOWIRE) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t name;
cdc50af0bff41accc02c613b9c6d8cd41b171ffeBrian Wellington dns_offsets_t offsets;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_region_t region;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_ptr);
b589e90689c6e87bf9608424ca8d99571c18bc61Mark Andrews REQUIRE(rdata->length != 0);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
94a08e09db3dc844b6ee4841c368a2d7074a9c3fAndreas Gustafsson dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews
cdc50af0bff41accc02c613b9c6d8cd41b171ffeBrian Wellington dns_name_init(&name, offsets);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_rdata_toregion(rdata, &region);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_fromregion(&name, &region);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews return (dns_name_towire(&name, cctx, target));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
4529cdaedaf1a0a5f8ff89aeca510b7a4475446cBob Halleystatic inline int
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencecompare_ptr(ARGS_COMPARE) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t name1;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t name2;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_region_t region1;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_region_t region2;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3d5cad69ec20157912e95cf3b79316dfb0a314f3Mark Andrews REQUIRE(rdata1->type == rdata2->type);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley REQUIRE(rdata1->rdclass == rdata2->rdclass);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata1->type == dns_rdatatype_ptr);
b589e90689c6e87bf9608424ca8d99571c18bc61Mark Andrews REQUIRE(rdata1->length != 0);
b589e90689c6e87bf9608424ca8d99571c18bc61Mark Andrews REQUIRE(rdata2->length != 0);
f7b99290c31abeb20c55fc55391510450ce60423Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_init(&name1, NULL);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_init(&name2, NULL);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_rdata_toregion(rdata1, &region1);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_rdata_toregion(rdata2, &region2);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_fromregion(&name1, &region1);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_fromregion(&name2, &region2);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
7c0539bea56022274da04263eb41fbb5b8835c38Mark Andrews return (dns_name_rdatacompare(&name1, &name2));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefromstruct_ptr(ARGS_FROMSTRUCT) {
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews dns_rdata_ptr_t *ptr = source;
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews isc_region_t region;
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_ptr);
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews REQUIRE(source != NULL);
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews REQUIRE(ptr->common.rdtype == type);
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews REQUIRE(ptr->common.rdclass == rdclass);
f7b99290c31abeb20c55fc55391510450ce60423Mark Andrews
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington UNUSED(type);
63cef8bde8b92aeb30ccdcf21d4e44c9be9cc6e3Andreas Gustafsson UNUSED(rdclass);
63cef8bde8b92aeb30ccdcf21d4e44c9be9cc6e3Andreas Gustafsson
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews dns_name_toregion(&ptr->ptr, &region);
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews return (isc_buffer_copyregion(target, &region));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencetostruct_ptr(ARGS_TOSTRUCT) {
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews isc_region_t region;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_rdata_ptr_t *ptr = target;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_name_t name;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_ptr);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews REQUIRE(target != NULL);
b589e90689c6e87bf9608424ca8d99571c18bc61Mark Andrews REQUIRE(rdata->length != 0);
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews ptr->common.rdclass = rdata->rdclass;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews ptr->common.rdtype = rdata->type;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews ISC_LINK_INIT(&ptr->common, link);
f7b99290c31abeb20c55fc55391510450ce60423Mark Andrews
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_name_init(&name, NULL);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_rdata_toregion(rdata, &region);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_name_fromregion(&name, &region);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_name_init(&ptr->ptr, NULL);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews RETERR(name_duporclone(&name, mctx, &ptr->ptr));
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews ptr->mctx = mctx;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews return (ISC_R_SUCCESS);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews
4529cdaedaf1a0a5f8ff89aeca510b7a4475446cBob Halleystatic inline void
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefreestruct_ptr(ARGS_FREESTRUCT) {
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_rdata_ptr_t *ptr = source;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews REQUIRE(source != NULL);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(ptr->common.rdtype == dns_rdatatype_ptr);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews if (ptr->mctx == NULL)
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews return;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_name_free(&ptr->ptr, ptr->mctx);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews ptr->mctx = NULL;
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews}
d981ca645597116d227a48bf37cc5edc061c854dBob Halley
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrenceadditionaldata_ptr(ARGS_ADDLDATA) {
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_ptr);
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson UNUSED(rdata);
940e4ef72b64a8a82a1038fdf08b324eec6e43a9Michael Graff UNUSED(add);
940e4ef72b64a8a82a1038fdf08b324eec6e43a9Michael Graff UNUSED(arg);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff return (ISC_R_SUCCESS);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley}
d981ca645597116d227a48bf37cc5edc061c854dBob Halley
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencedigest_ptr(ARGS_DIGEST) {
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley isc_region_t r;
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley dns_name_t name;
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_ptr);
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley dns_rdata_toregion(rdata, &r);
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley dns_name_init(&name, NULL);
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley dns_name_fromregion(&name, &r);
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley return (dns_name_digest(&name, digest, arg));
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley}
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic inline isc_boolean_t
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewscheckowner_ptr(ARGS_CHECKOWNER) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_ptr);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(name);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(type);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(rdclass);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(wildcard);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews return (ISC_TRUE);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews}
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic unsigned char ip6_arpa_data[] = "\003IP6\004ARPA";
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic unsigned char ip6_arpa_offsets[] = { 0, 4, 9 };
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic const dns_name_t ip6_arpa =
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews{
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews DNS_NAME_MAGIC,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews ip6_arpa_data, 10, 3,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews ip6_arpa_offsets, NULL,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews {(void *)-1, (void *)-1},
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews {NULL, NULL}
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews};
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic unsigned char ip6_int_data[] = "\003IP6\003INT";
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic unsigned char ip6_int_offsets[] = { 0, 4, 8 };
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic const dns_name_t ip6_int =
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews{
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews DNS_NAME_MAGIC,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews ip6_int_data, 9, 3,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews ip6_int_offsets, NULL,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews {(void *)-1, (void *)-1},
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews {NULL, NULL}
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews};
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic unsigned char in_addr_arpa_data[] = "\007IN-ADDR\004ARPA";
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic unsigned char in_addr_arpa_offsets[] = { 0, 8, 13 };
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic const dns_name_t in_addr_arpa =
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews{
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews DNS_NAME_MAGIC,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews in_addr_arpa_data, 14, 3,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews in_addr_arpa_offsets, NULL,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews {(void *)-1, (void *)-1},
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews {NULL, NULL}
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews};
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic inline isc_boolean_t
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewschecknames_ptr(ARGS_CHECKNAMES) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews isc_region_t region;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews dns_name_t name;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_ptr);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews if (rdata->rdclass != dns_rdataclass_in)
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews return (ISC_TRUE);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
5855fd79e375c74fc9df57ce0b4c4ef1b9fcdc3eMark Andrews if (dns_name_isdnssd(owner))
5855fd79e375c74fc9df57ce0b4c4ef1b9fcdc3eMark Andrews return (ISC_TRUE);
5855fd79e375c74fc9df57ce0b4c4ef1b9fcdc3eMark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews if (dns_name_issubdomain(owner, &in_addr_arpa) ||
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews dns_name_issubdomain(owner, &ip6_arpa) ||
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews dns_name_issubdomain(owner, &ip6_int)) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews dns_rdata_toregion(rdata, &region);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews dns_name_init(&name, NULL);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews dns_name_fromregion(&name, &region);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews if (!dns_name_ishostname(&name, ISC_FALSE)) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews if (bad != NULL)
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews dns_name_clone(&name, bad);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews return (ISC_FALSE);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews }
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews }
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews return (ISC_TRUE);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews}
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrewsstatic inline int
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrewscasecompare_ptr(ARGS_COMPARE) {
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews return (compare_ptr(rdata1, rdata2));
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews}
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews#endif /* RDATA_GENERIC_PTR_12_C */