lp_107.c revision e0a30050c8516a3d54a4f8dcdd88435704a8a3ed
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews/*
503ffdad3bc62e6458e4b60e329aa448ce1803a1Tinderbox User * Copyright (C) 2013, 2015 Internet Systems Consortium, Inc. ("ISC")
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews *
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews * Permission to use, copy, modify, and/or distribute this software for any
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews * purpose with or without fee is hereby granted, provided that the above
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews * copyright notice and this permission notice appear in all copies.
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews *
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews * PERFORMANCE OF THIS SOFTWARE.
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews */
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews#ifndef RDATA_GENERIC_LP_107_C
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews#define RDATA_GENERIC_LP_107_C
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews#include <string.h>
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews#include <isc/net.h>
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews#define RRTYPE_LP_ATTRIBUTES (0)
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline isc_result_t
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsfromtext_lp(ARGS_FROMTEXT) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_token_t token;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_t name;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_buffer_t buffer;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_lp);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(type);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(rdclass);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(callbacks);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews ISC_FALSE));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews if (token.value.as_ulong > 0xffffU)
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews RETTOK(ISC_R_RANGE);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews RETERR(uint16_tobuffer(token.value.as_ulong, target));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews ISC_FALSE));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_init(&name, NULL);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews buffer_fromregion(&buffer, &token.value.as_region);
e0a30050c8516a3d54a4f8dcdd88435704a8a3edMark Andrews if (origin == NULL)
e0a30050c8516a3d54a4f8dcdd88435704a8a3edMark Andrews origin = dns_rootname;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return (dns_name_fromtext(&name, &buffer, origin, options, target));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews}
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline isc_result_t
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewstotext_lp(ARGS_TOTEXT) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_t region;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_t name;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_t prefix;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_boolean_t sub;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews char buf[sizeof("64000")];
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews unsigned short num;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_lp);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(rdata->length != 0);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_init(&name, NULL);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_init(&prefix, NULL);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_rdata_toregion(rdata, &region);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews num = uint16_fromregion(&region);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_consume(&region, 2);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews sprintf(buf, "%u", num);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews RETERR(str_totext(buf, target));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews RETERR(str_totext(" ", target));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_fromregion(&name, &region);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews sub = name_prefix(&name, tctx->origin, &prefix);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return (dns_name_totext(&prefix, sub, target));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews}
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline isc_result_t
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsfromwire_lp(ARGS_FROMWIRE) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_t name;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_t sregion;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_lp);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(type);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(rdclass);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_init(&name, NULL);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_buffer_activeregion(source, &sregion);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews if (sregion.length < 2)
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return (ISC_R_UNEXPECTEDEND);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews RETERR(mem_tobuffer(target, sregion.base, 2));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_buffer_forward(source, 2);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return (dns_name_fromwire(&name, source, dctx, options, target));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews}
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline isc_result_t
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewstowire_lp(ARGS_TOWIRE) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_lp);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(rdata->length != 0);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(cctx);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return (mem_tobuffer(target, rdata->data, rdata->length));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews}
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline int
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewscompare_lp(ARGS_COMPARE) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_t region1;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_t region2;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(rdata1->type == rdata2->type);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(rdata1->rdclass == rdata2->rdclass);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata1->type == dns_rdatatype_lp);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(rdata1->length != 0);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(rdata2->length != 0);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_rdata_toregion(rdata1, &region1);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_rdata_toregion(rdata2, &region2);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return (isc_region_compare(&region1, &region2));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews}
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline isc_result_t
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsfromstruct_lp(ARGS_FROMSTRUCT) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_rdata_lp_t *lp = source;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_t region;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_lp);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(source != NULL);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(lp->common.rdtype == type);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(lp->common.rdclass == rdclass);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(type);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(rdclass);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews RETERR(uint16_tobuffer(lp->pref, target));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_toregion(&lp->lp, &region);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return (isc_buffer_copyregion(target, &region));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews}
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline isc_result_t
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewstostruct_lp(ARGS_TOSTRUCT) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_t region;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_rdata_lp_t *lp = target;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_t name;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_lp);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(target != NULL);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(rdata->length != 0);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews lp->common.rdclass = rdata->rdclass;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews lp->common.rdtype = rdata->type;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews ISC_LINK_INIT(&lp->common, link);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_init(&name, NULL);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_rdata_toregion(rdata, &region);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews lp->pref = uint16_fromregion(&region);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_consume(&region, 2);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_fromregion(&name, &region);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_init(&lp->lp, NULL);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews RETERR(name_duporclone(&name, mctx, &lp->lp));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews lp->mctx = mctx;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return (ISC_R_SUCCESS);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews}
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline void
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsfreestruct_lp(ARGS_FREESTRUCT) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_rdata_lp_t *lp = source;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(source != NULL);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(lp->common.rdtype == dns_rdatatype_lp);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews if (lp->mctx == NULL)
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_free(&lp->lp, lp->mctx);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews lp->mctx = NULL;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews}
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline isc_result_t
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsadditionaldata_lp(ARGS_ADDLDATA) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_t name;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_offsets_t offsets;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_t region;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_result_t result;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_lp);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_init(&name, offsets);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_rdata_toregion(rdata, &region);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_consume(&region, 2);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_fromregion(&name, &region);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews result = (add)(arg, &name, dns_rdatatype_l32);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews if (result != ISC_R_SUCCESS)
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return (result);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return ((add)(arg, &name, dns_rdatatype_l64));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews}
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline isc_result_t
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsdigest_lp(ARGS_DIGEST) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_t region;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_lp);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_rdata_toregion(rdata, &region);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return ((digest)(arg, &region));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews}
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline isc_boolean_t
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewscheckowner_lp(ARGS_CHECKOWNER) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_lp);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(type);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(rdclass);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(name);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(wildcard);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return (ISC_TRUE);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews}
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline isc_boolean_t
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewschecknames_lp(ARGS_CHECKNAMES) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_lp);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(bad);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews UNUSED(owner);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return (ISC_TRUE);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews}
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewsstatic inline int
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrewscasecompare_lp(ARGS_COMPARE) {
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_t name1;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_t name2;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_t region1;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_t region2;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews int order;
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(rdata1->type == rdata2->type);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(rdata1->rdclass == rdata2->rdclass);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata1->type == dns_rdatatype_lp);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(rdata1->length != 0);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews REQUIRE(rdata2->length != 0);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews order = memcmp(rdata1->data, rdata2->data, 2);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews if (order != 0)
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return (order < 0 ? -1 : 1);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_init(&name1, NULL);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_init(&name2, NULL);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_rdata_toregion(rdata1, &region1);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_rdata_toregion(rdata2, &region2);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_consume(&region1, 2);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews isc_region_consume(&region2, 2);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_fromregion(&name1, &region1);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews dns_name_fromregion(&name2, &region2);
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews return (dns_name_rdatacompare(&name1, &name2));
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews}
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews
f1c1aab2c9e720399d66d8db5f40515d47c45ecfMark Andrews#endif /* RDATA_GENERIC_LP_107_C */