322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews/*
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews *
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews */
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews#ifndef RDATA_GENERIC_SMIMEA_53_C
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews#define RDATA_GENERIC_SMIMEA_53_C
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews#define RRTYPE_SMIMEA_ATTRIBUTES 0
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsstatic inline isc_result_t
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsfromtext_smimea(ARGS_FROMTEXT) {
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(type == dns_rdatatype_smimea);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews return (generic_fromtext_tlsa(rdclass, type, lexer, origin, options,
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews target, callbacks));
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews}
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsstatic inline isc_result_t
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewstotext_smimea(ARGS_TOTEXT) {
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(rdata->type == dns_rdatatype_smimea);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews return (generic_totext_tlsa(rdata, tctx, target));
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews}
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsstatic inline isc_result_t
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsfromwire_smimea(ARGS_FROMWIRE) {
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(type == dns_rdatatype_smimea);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews return (generic_fromwire_tlsa(rdclass, type, source, dctx, options,
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews target));
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews}
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsstatic inline isc_result_t
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewstowire_smimea(ARGS_TOWIRE) {
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews isc_region_t sr;
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(rdata->type == dns_rdatatype_smimea);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(rdata->length != 0);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews UNUSED(cctx);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews dns_rdata_toregion(rdata, &sr);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews return (mem_tobuffer(target, sr.base, sr.length));
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews}
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsstatic inline int
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewscompare_smimea(ARGS_COMPARE) {
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews isc_region_t r1;
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews isc_region_t r2;
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(rdata1->type == rdata2->type);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(rdata1->rdclass == rdata2->rdclass);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(rdata1->type == dns_rdatatype_smimea);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(rdata1->length != 0);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(rdata2->length != 0);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews dns_rdata_toregion(rdata1, &r1);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews dns_rdata_toregion(rdata2, &r2);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews return (isc_region_compare(&r1, &r2));
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews}
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsstatic inline isc_result_t
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsfromstruct_smimea(ARGS_FROMSTRUCT) {
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(type == dns_rdatatype_smimea);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews return (generic_fromstruct_tlsa(rdclass, type, source, target));
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews}
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsstatic inline isc_result_t
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewstostruct_smimea(ARGS_TOSTRUCT) {
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews dns_rdata_txt_t *txt = target;
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(rdata->type == dns_rdatatype_smimea);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(target != NULL);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews txt->common.rdclass = rdata->rdclass;
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews txt->common.rdtype = rdata->type;
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews ISC_LINK_INIT(&txt->common, link);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews return (generic_tostruct_tlsa(rdata, target, mctx));
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews}
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsstatic inline void
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsfreestruct_smimea(ARGS_FREESTRUCT) {
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews dns_rdata_txt_t *txt = source;
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(source != NULL);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(txt->common.rdtype == dns_rdatatype_smimea);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews generic_freestruct_tlsa(source);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews}
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsstatic inline isc_result_t
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsadditionaldata_smimea(ARGS_ADDLDATA) {
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(rdata->type == dns_rdatatype_smimea);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews UNUSED(rdata);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews UNUSED(add);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews UNUSED(arg);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews return (ISC_R_SUCCESS);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews}
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsstatic inline isc_result_t
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsdigest_smimea(ARGS_DIGEST) {
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews isc_region_t r;
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(rdata->type == dns_rdatatype_smimea);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews dns_rdata_toregion(rdata, &r);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews return ((digest)(arg, &r));
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews}
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsstatic inline isc_boolean_t
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewscheckowner_smimea(ARGS_CHECKOWNER) {
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(type == dns_rdatatype_smimea);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews UNUSED(name);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews UNUSED(type);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews UNUSED(rdclass);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews UNUSED(wildcard);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews return (ISC_TRUE);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews}
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsstatic inline isc_boolean_t
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewschecknames_smimea(ARGS_CHECKNAMES) {
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews REQUIRE(rdata->type == dns_rdatatype_smimea);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews UNUSED(rdata);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews UNUSED(owner);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews UNUSED(bad);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews return (ISC_TRUE);
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews}
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewsstatic inline int
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrewscasecompare_smimea(ARGS_COMPARE) {
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews return (compare_smimea(rdata1, rdata2));
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews}
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews
322e6b5be784d79d15fea9db9440dd821162c574Mark Andrews#endif /* RDATA_GENERIC_SMIMEA_53_C */