tlsa_52.c revision f2ea8c2f965be7ff4c59f805712c12d469226b7b
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff/*
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff *
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * Permission to use, copy, modify, and/or distribute this software for any
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * purpose with or without fee is hereby granted, provided that the above
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * copyright notice and this permission notice appear in all copies.
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff *
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * PERFORMANCE OF THIS SOFTWARE.
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff */
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff/* $Id$ */
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff/* rfc6698.txt */
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff#ifndef RDATA_GENERIC_TLSA_52_C
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff#define RDATA_GENERIC_TLSA_52_C
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff#define RRTYPE_TLSA_ATTRIBUTES 0
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffstatic inline isc_result_t
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Grafffromtext_tlsa(ARGS_FROMTEXT) {
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff isc_token_t token;
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff REQUIRE(type == 52);
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(type);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff UNUSED(rdclass);
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff UNUSED(origin);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(options);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(callbacks);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff /*
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * Certificate Usage.
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff */
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff ISC_FALSE));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff if (token.value.as_ulong > 0xffU)
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff RETTOK(ISC_R_RANGE);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff RETERR(uint8_tobuffer(token.value.as_ulong, target));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff /*
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * Selector.
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff */
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff ISC_FALSE));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff if (token.value.as_ulong > 0xffU)
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff RETTOK(ISC_R_RANGE);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff RETERR(uint8_tobuffer(token.value.as_ulong, target));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff /*
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Matching type.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff */
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff ISC_FALSE));
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff if (token.value.as_ulong > 0xffU)
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff RETTOK(ISC_R_RANGE);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff RETERR(uint8_tobuffer(token.value.as_ulong, target));
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff /*
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff * Certificate Association Data.
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff */
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff return (isc_hex_tobuffer(lexer, target, -1));
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff}
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graffstatic inline isc_result_t
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Grafftotext_tlsa(ARGS_TOTEXT) {
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff isc_region_t sr;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff char buf[sizeof("64000 ")];
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff unsigned int n;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff REQUIRE(rdata->type == 52);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff REQUIRE(rdata->length != 0);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff UNUSED(tctx);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff dns_rdata_toregion(rdata, &sr);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff /*
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff * Certificate Usage.
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff */
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff n = uint8_fromregion(&sr);
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff isc_region_consume(&sr, 1);
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff sprintf(buf, "%u ", n);
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff RETERR(str_totext(buf, target));
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff /*
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff * Selector.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff */
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff n = uint8_fromregion(&sr);
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff isc_region_consume(&sr, 1);
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff sprintf(buf, "%u ", n);
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff RETERR(str_totext(buf, target));
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff /*
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff * Matching type.
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff */
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff n = uint8_fromregion(&sr);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff isc_region_consume(&sr, 1);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff sprintf(buf, "%u", n);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff RETERR(str_totext(buf, target));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff /*
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * Certificate Association Data.
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff */
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff RETERR(str_totext(" (", target));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff RETERR(str_totext(tctx->linebreak, target));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff if (tctx->width == 0) /* No splitting */
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff RETERR(isc_hex_totext(&sr, 0, "", target));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff else
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff RETERR(isc_hex_totext(&sr, tctx->width - 2,
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff tctx->linebreak, target));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff RETERR(str_totext(" )", target));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff return (ISC_R_SUCCESS);
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff}
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graffstatic inline isc_result_t
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Grafffromwire_tlsa(ARGS_FROMWIRE) {
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff isc_region_t sr;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff REQUIRE(type == 52);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff UNUSED(type);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff UNUSED(rdclass);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff UNUSED(dctx);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff UNUSED(options);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff isc_buffer_activeregion(source, &sr);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff if (sr.length < 3)
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff return (ISC_R_UNEXPECTEDEND);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff isc_buffer_forward(source, sr.length);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff return (mem_tobuffer(target, sr.base, sr.length));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff}
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graffstatic inline isc_result_t
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Grafftowire_tlsa(ARGS_TOWIRE) {
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff isc_region_t sr;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff REQUIRE(rdata->type == 52);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff REQUIRE(rdata->length != 0);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff UNUSED(cctx);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff dns_rdata_toregion(rdata, &sr);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff return (mem_tobuffer(target, sr.base, sr.length));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff}
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graffstatic inline int
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graffcompare_tlsa(ARGS_COMPARE) {
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff isc_region_t r1;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff isc_region_t r2;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff REQUIRE(rdata1->type == rdata2->type);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff REQUIRE(rdata1->rdclass == rdata2->rdclass);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff REQUIRE(rdata1->type == 52);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff REQUIRE(rdata1->length != 0);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff REQUIRE(rdata2->length != 0);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff dns_rdata_toregion(rdata1, &r1);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff dns_rdata_toregion(rdata2, &r2);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff return (isc_region_compare(&r1, &r2));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff}
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graffstatic inline isc_result_t
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Grafffromstruct_tlsa(ARGS_FROMSTRUCT) {
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff dns_rdata_tlsa_t *tlsa = source;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff REQUIRE(type == 52);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff REQUIRE(source != NULL);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff REQUIRE(tlsa->common.rdtype == type);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff REQUIRE(tlsa->common.rdclass == rdclass);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(type);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(rdclass);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff RETERR(uint8_tobuffer(tlsa->usage, target));
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff RETERR(uint8_tobuffer(tlsa->selector, target));
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff RETERR(uint8_tobuffer(tlsa->match, target));
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff return (mem_tobuffer(target, tlsa->data, tlsa->length));
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff}
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffstatic inline isc_result_t
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Grafftostruct_tlsa(ARGS_TOSTRUCT) {
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff dns_rdata_tlsa_t *tlsa = target;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff isc_region_t region;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff REQUIRE(rdata->type == 52);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff REQUIRE(target != NULL);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff REQUIRE(rdata->length != 0);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff tlsa->common.rdclass = rdata->rdclass;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff tlsa->common.rdtype = rdata->type;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff ISC_LINK_INIT(&tlsa->common, link);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff dns_rdata_toregion(rdata, &region);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff tlsa->usage = uint8_fromregion(&region);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff isc_region_consume(&region, 1);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff tlsa->selector = uint8_fromregion(&region);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff isc_region_consume(&region, 1);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff tlsa->match = uint8_fromregion(&region);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff isc_region_consume(&region, 1);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff tlsa->length = region.length;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff tlsa->data = mem_maybedup(mctx, region.base, region.length);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff if (tlsa->data == NULL)
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff return (ISC_R_NOMEMORY);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff tlsa->mctx = mctx;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff return (ISC_R_SUCCESS);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff}
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffstatic inline void
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Grafffreestruct_tlsa(ARGS_FREESTRUCT) {
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff dns_rdata_tlsa_t *tlsa = source;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff REQUIRE(tlsa != NULL);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff REQUIRE(tlsa->common.rdtype == 52);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff if (tlsa->mctx == NULL)
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff return;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff if (tlsa->data != NULL)
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff isc_mem_free(tlsa->mctx, tlsa->data);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff tlsa->mctx = NULL;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff}
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffstatic inline isc_result_t
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffadditionaldata_tlsa(ARGS_ADDLDATA) {
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff REQUIRE(rdata->type == 52);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(rdata);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(add);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(arg);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff return (ISC_R_SUCCESS);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff}
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffstatic inline isc_result_t
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffdigest_tlsa(ARGS_DIGEST) {
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff isc_region_t r;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff REQUIRE(rdata->type == 52);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff dns_rdata_toregion(rdata, &r);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff return ((digest)(arg, &r));
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff}
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffstatic inline isc_boolean_t
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffcheckowner_tlsa(ARGS_CHECKOWNER) {
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff REQUIRE(type == 52);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(name);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(type);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(rdclass);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(wildcard);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff return (ISC_TRUE);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff}
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffstatic inline isc_boolean_t
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffchecknames_tlsa(ARGS_CHECKNAMES) {
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff REQUIRE(rdata->type == 52);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(rdata);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(owner);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff UNUSED(bad);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff return (ISC_TRUE);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff}
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffstatic inline int
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffcasecompare_tlsa(ARGS_COMPARE) {
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff return (compare_tlsa(rdata1, rdata2));
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff}
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff#endif /* RDATA_GENERIC_TLSA_52_C */
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff