5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews/*
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 1998-2001, 2004, 2007, 2009, 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
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/.
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews */
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
4b6dc226f78862286daa69fba761eac9fd5da16aAutomatic Updater/* $Id: minfo_14.c,v 1.47 2009/12/04 22:06:37 tbox Exp $ */
ce8b84ce64a7f1b3b7b558a4aa14be946846080aJames Brister
ce8b84ce64a7f1b3b7b558a4aa14be946846080aJames Brister/* reviewed: Wed Mar 15 17:45:32 PST 2000 by brister */
3761c433912beabe43abeed2c3513b6201c59f64Mark Andrews
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews#ifndef RDATA_GENERIC_MINFO_14_C
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews#define RDATA_GENERIC_MINFO_14_C
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
6324997211a5e2d82528dcde98e8981190a35faeMichael Graff#define RRTYPE_MINFO_ATTRIBUTES (0)
6324997211a5e2d82528dcde98e8981190a35faeMichael Graff
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefromtext_minfo(ARGS_FROMTEXT) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_token_t token;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t name;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_buffer_t buffer;
deaaf94332abbfdb3aff53675546acfed16e5eb6Mark Andrews int i;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews isc_boolean_t ok;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_minfo);
f7b99290c31abeb20c55fc55391510450ce60423Mark Andrews
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington UNUSED(type);
ce8b84ce64a7f1b3b7b558a4aa14be946846080aJames Brister UNUSED(rdclass);
bddfe77128b0f16af263ff149db40f0d885f43d0Mark Andrews UNUSED(callbacks);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
e0a30050c8516a3d54a4f8dcdd88435704a8a3edMark Andrews if (origin == NULL)
e0a30050c8516a3d54a4f8dcdd88435704a8a3edMark Andrews origin = dns_rootname;
e0a30050c8516a3d54a4f8dcdd88435704a8a3edMark Andrews
f1b68725503ff3e46001eee5a1751e29a43a09d1Andreas Gustafsson for (i = 0; i < 2; i++) {
add4043305ca411202ed9cf1929a4179016515ceBrian Wellington RETERR(isc_lex_getmastertoken(lexer, &token,
add4043305ca411202ed9cf1929a4179016515ceBrian Wellington isc_tokentype_string,
add4043305ca411202ed9cf1929a4179016515ceBrian Wellington ISC_FALSE));
deaaf94332abbfdb3aff53675546acfed16e5eb6Mark Andrews dns_name_init(&name, NULL);
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence buffer_fromregion(&buffer, &token.value.as_region);
9ac7076ebad044afb15e9e2687e3696868778538Mark Andrews RETTOK(dns_name_fromtext(&name, &buffer, origin,
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews options, target));
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews ok = ISC_TRUE;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews if ((options & DNS_RDATA_CHECKNAMES) != 0)
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews ok = dns_name_ismailbox(&name);
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);
3d5cad69ec20157912e95cf3b79316dfb0a314f3Mark Andrews }
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff return (ISC_R_SUCCESS);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencetotext_minfo(ARGS_TOTEXT) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_region_t region;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t rmail;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t email;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t prefix;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_boolean_t sub;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_minfo);
b589e90689c6e87bf9608424ca8d99571c18bc61Mark Andrews REQUIRE(rdata->length != 0);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_init(&rmail, NULL);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_init(&email, NULL);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_init(&prefix, NULL);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_rdata_toregion(rdata, &region);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_fromregion(&rmail, &region);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_region_consume(&region, rmail.length);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_fromregion(&email, &region);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_region_consume(&region, email.length);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson sub = name_prefix(&rmail, tctx->origin, &prefix);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
deaaf94332abbfdb3aff53675546acfed16e5eb6Mark Andrews RETERR(dns_name_totext(&prefix, sub, target));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
deaaf94332abbfdb3aff53675546acfed16e5eb6Mark Andrews RETERR(str_totext(" ", target));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson sub = name_prefix(&email, tctx->origin, &prefix);
deaaf94332abbfdb3aff53675546acfed16e5eb6Mark Andrews return (dns_name_totext(&prefix, sub, target));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefromwire_minfo(ARGS_FROMWIRE) {
4b6dc226f78862286daa69fba761eac9fd5da16aAutomatic Updater dns_name_t rmail;
4b6dc226f78862286daa69fba761eac9fd5da16aAutomatic Updater dns_name_t email;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_minfo);
f7b99290c31abeb20c55fc55391510450ce60423Mark Andrews
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington UNUSED(type);
ce8b84ce64a7f1b3b7b558a4aa14be946846080aJames Brister UNUSED(rdclass);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington
4b6dc226f78862286daa69fba761eac9fd5da16aAutomatic Updater dns_name_init(&rmail, NULL);
4b6dc226f78862286daa69fba761eac9fd5da16aAutomatic Updater dns_name_init(&email, NULL);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
4b6dc226f78862286daa69fba761eac9fd5da16aAutomatic Updater RETERR(dns_name_fromwire(&rmail, source, dctx, options, target));
4b6dc226f78862286daa69fba761eac9fd5da16aAutomatic Updater return (dns_name_fromwire(&email, source, dctx, options, target));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencetowire_minfo(ARGS_TOWIRE) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_region_t region;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t rmail;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t email;
cdc50af0bff41accc02c613b9c6d8cd41b171ffeBrian Wellington dns_offsets_t roffsets;
cdc50af0bff41accc02c613b9c6d8cd41b171ffeBrian Wellington dns_offsets_t eoffsets;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_minfo);
b589e90689c6e87bf9608424ca8d99571c18bc61Mark Andrews REQUIRE(rdata->length != 0);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
94a08e09db3dc844b6ee4841c368a2d7074a9c3fAndreas Gustafsson dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews
cdc50af0bff41accc02c613b9c6d8cd41b171ffeBrian Wellington dns_name_init(&rmail, roffsets);
cdc50af0bff41accc02c613b9c6d8cd41b171ffeBrian Wellington dns_name_init(&email, eoffsets);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_rdata_toregion(rdata, &region);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_fromregion(&rmail, &region);
ffe74cc719aa0f10c38fbc1f2f3ea7db0960cb8fMark Andrews isc_region_consume(&region, name_length(&rmail));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
deaaf94332abbfdb3aff53675546acfed16e5eb6Mark Andrews RETERR(dns_name_towire(&rmail, cctx, target));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_fromregion(&rmail, &region);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_region_consume(&region, rmail.length);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
deaaf94332abbfdb3aff53675546acfed16e5eb6Mark Andrews return (dns_name_towire(&rmail, cctx, target));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
4529cdaedaf1a0a5f8ff89aeca510b7a4475446cBob Halleystatic inline int
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencecompare_minfo(ARGS_COMPARE) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_region_t region1;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_region_t region2;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t name1;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_t name2;
41aad56b6cc458cbf7b8483576d990a77ae9bac2Andreas Gustafsson int order;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3d5cad69ec20157912e95cf3b79316dfb0a314f3Mark Andrews REQUIRE(rdata1->type == rdata2->type);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley REQUIRE(rdata1->rdclass == rdata2->rdclass);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata1->type == dns_rdatatype_minfo);
b589e90689c6e87bf9608424ca8d99571c18bc61Mark Andrews REQUIRE(rdata1->length != 0);
b589e90689c6e87bf9608424ca8d99571c18bc61Mark Andrews REQUIRE(rdata2->length != 0);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_init(&name1, NULL);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_init(&name2, NULL);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_rdata_toregion(rdata1, &region1);
deaaf94332abbfdb3aff53675546acfed16e5eb6Mark Andrews dns_rdata_toregion(rdata2, &region2);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_fromregion(&name1, &region1);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_fromregion(&name2, &region2);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
41aad56b6cc458cbf7b8483576d990a77ae9bac2Andreas Gustafsson order = dns_name_rdatacompare(&name1, &name2);
41aad56b6cc458cbf7b8483576d990a77ae9bac2Andreas Gustafsson if (order != 0)
41aad56b6cc458cbf7b8483576d990a77ae9bac2Andreas Gustafsson return (order);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
deaaf94332abbfdb3aff53675546acfed16e5eb6Mark Andrews isc_region_consume(&region1, name_length(&name1));
deaaf94332abbfdb3aff53675546acfed16e5eb6Mark Andrews isc_region_consume(&region2, name_length(&name2));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_init(&name1, NULL);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_init(&name2, NULL);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_fromregion(&name1, &region1);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dns_name_fromregion(&name2, &region2);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
41aad56b6cc458cbf7b8483576d990a77ae9bac2Andreas Gustafsson order = dns_name_rdatacompare(&name1, &name2);
41aad56b6cc458cbf7b8483576d990a77ae9bac2Andreas Gustafsson return (order);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefromstruct_minfo(ARGS_FROMSTRUCT) {
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews dns_rdata_minfo_t *minfo = source;
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews isc_region_t region;
f7b99290c31abeb20c55fc55391510450ce60423Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_minfo);
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews REQUIRE(source != NULL);
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews REQUIRE(minfo->common.rdtype == type);
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews REQUIRE(minfo->common.rdclass == rdclass);
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington UNUSED(type);
63cef8bde8b92aeb30ccdcf21d4e44c9be9cc6e3Andreas Gustafsson UNUSED(rdclass);
63cef8bde8b92aeb30ccdcf21d4e44c9be9cc6e3Andreas Gustafsson
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews dns_name_toregion(&minfo->rmailbox, &region);
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews RETERR(isc_buffer_copyregion(target, &region));
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews dns_name_toregion(&minfo->emailbox, &region);
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews return (isc_buffer_copyregion(target, &region));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencetostruct_minfo(ARGS_TOSTRUCT) {
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_rdata_minfo_t *minfo = target;
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews isc_region_t region;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_name_t name;
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews isc_result_t result;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_minfo);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews REQUIRE(target != NULL);
b589e90689c6e87bf9608424ca8d99571c18bc61Mark Andrews REQUIRE(rdata->length != 0);
f7b99290c31abeb20c55fc55391510450ce60423Mark Andrews
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews minfo->common.rdclass = rdata->rdclass;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews minfo->common.rdtype = rdata->type;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews ISC_LINK_INIT(&minfo->common, link);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark 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(&minfo->rmailbox, NULL);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews RETERR(name_duporclone(&name, mctx, &minfo->rmailbox));
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews isc_region_consume(&region, name_length(&name));
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_name_fromregion(&name, &region);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_name_init(&minfo->emailbox, NULL);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews result = name_duporclone(&name, mctx, &minfo->emailbox);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews if (result != ISC_R_SUCCESS)
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews goto cleanup;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews minfo->mctx = mctx;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews return (ISC_R_SUCCESS);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews cleanup:
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews if (mctx != NULL)
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_name_free(&minfo->rmailbox, mctx);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews return (ISC_R_NOMEMORY);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews
4529cdaedaf1a0a5f8ff89aeca510b7a4475446cBob Halleystatic inline void
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefreestruct_minfo(ARGS_FREESTRUCT) {
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_rdata_minfo_t *minfo = source;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews REQUIRE(source != NULL);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(minfo->common.rdtype == dns_rdatatype_minfo);
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews if (minfo->mctx == NULL)
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews return;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_name_free(&minfo->rmailbox, minfo->mctx);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_name_free(&minfo->emailbox, minfo->mctx);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews minfo->mctx = NULL;
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews}
d981ca645597116d227a48bf37cc5edc061c854dBob Halley
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrenceadditionaldata_minfo(ARGS_ADDLDATA) {
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_minfo);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson UNUSED(rdata);
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson UNUSED(add);
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson UNUSED(arg);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff return (ISC_R_SUCCESS);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley}
d981ca645597116d227a48bf37cc5edc061c854dBob Halley
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencedigest_minfo(ARGS_DIGEST) {
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley isc_region_t r;
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley dns_name_t name;
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff isc_result_t result;
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_minfo);
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 result = dns_name_digest(&name, digest, arg);
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff if (result != ISC_R_SUCCESS)
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley return (result);
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley isc_region_consume(&r, name_length(&name));
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_minfo(ARGS_CHECKOWNER) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_minfo);
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 inline isc_boolean_t
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewschecknames_minfo(ARGS_CHECKNAMES) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews isc_region_t region;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews dns_name_t name;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_minfo);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(owner);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
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_ismailbox(&name)) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews if (bad != NULL)
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews dns_name_clone(&name, bad);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews return (ISC_FALSE);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews }
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews isc_region_consume(&region, name_length(&name));
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews dns_name_fromregion(&name, &region);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews if (!dns_name_ismailbox(&name)) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews if (bad != NULL)
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews dns_name_clone(&name, bad);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews return (ISC_FALSE);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews }
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews return (ISC_TRUE);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews}
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrewsstatic inline int
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrewscasecompare_minfo(ARGS_COMPARE) {
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews return (compare_minfo(rdata1, rdata2));
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews}
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews#endif /* RDATA_GENERIC_MINFO_14_C */