"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.17.5/lib/dns/rdata/generic/mf_4.c" (4 Sep 2020, 4987 Bytes) of package /linux/misc/dns/bind9/9.17.5/bind-9.17.5.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "mf_4.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 #ifndef RDATA_GENERIC_MF_4_C
   13 #define RDATA_GENERIC_MF_4_C
   14 
   15 #define RRTYPE_MF_ATTRIBUTES (0)
   16 
   17 static inline isc_result_t
   18 fromtext_mf(ARGS_FROMTEXT) {
   19     isc_token_t token;
   20     dns_name_t name;
   21     isc_buffer_t buffer;
   22 
   23     REQUIRE(type == dns_rdatatype_mf);
   24 
   25     UNUSED(type);
   26     UNUSED(rdclass);
   27     UNUSED(callbacks);
   28 
   29     RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
   30                       false));
   31 
   32     dns_name_init(&name, NULL);
   33     buffer_fromregion(&buffer, &token.value.as_region);
   34     if (origin == NULL) {
   35         origin = dns_rootname;
   36     }
   37     RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
   38     return (ISC_R_SUCCESS);
   39 }
   40 
   41 static inline isc_result_t
   42 totext_mf(ARGS_TOTEXT) {
   43     isc_region_t region;
   44     dns_name_t name;
   45     dns_name_t prefix;
   46     bool sub;
   47 
   48     REQUIRE(rdata->type == dns_rdatatype_mf);
   49     REQUIRE(rdata->length != 0);
   50 
   51     dns_name_init(&name, NULL);
   52     dns_name_init(&prefix, NULL);
   53 
   54     dns_rdata_toregion(rdata, &region);
   55     dns_name_fromregion(&name, &region);
   56 
   57     sub = name_prefix(&name, tctx->origin, &prefix);
   58 
   59     return (dns_name_totext(&prefix, sub, target));
   60 }
   61 
   62 static inline isc_result_t
   63 fromwire_mf(ARGS_FROMWIRE) {
   64     dns_name_t name;
   65 
   66     REQUIRE(type == dns_rdatatype_mf);
   67 
   68     UNUSED(type);
   69     UNUSED(rdclass);
   70 
   71     dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
   72 
   73     dns_name_init(&name, NULL);
   74     return (dns_name_fromwire(&name, source, dctx, options, target));
   75 }
   76 
   77 static inline isc_result_t
   78 towire_mf(ARGS_TOWIRE) {
   79     dns_name_t name;
   80     dns_offsets_t offsets;
   81     isc_region_t region;
   82 
   83     REQUIRE(rdata->type == dns_rdatatype_mf);
   84     REQUIRE(rdata->length != 0);
   85 
   86     dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
   87 
   88     dns_name_init(&name, offsets);
   89     dns_rdata_toregion(rdata, &region);
   90     dns_name_fromregion(&name, &region);
   91 
   92     return (dns_name_towire(&name, cctx, target));
   93 }
   94 
   95 static inline int
   96 compare_mf(ARGS_COMPARE) {
   97     dns_name_t name1;
   98     dns_name_t name2;
   99     isc_region_t region1;
  100     isc_region_t region2;
  101 
  102     REQUIRE(rdata1->type == rdata2->type);
  103     REQUIRE(rdata1->rdclass == rdata2->rdclass);
  104     REQUIRE(rdata1->type == dns_rdatatype_mf);
  105     REQUIRE(rdata1->length != 0);
  106     REQUIRE(rdata2->length != 0);
  107 
  108     dns_name_init(&name1, NULL);
  109     dns_name_init(&name2, NULL);
  110 
  111     dns_rdata_toregion(rdata1, &region1);
  112     dns_rdata_toregion(rdata2, &region2);
  113 
  114     dns_name_fromregion(&name1, &region1);
  115     dns_name_fromregion(&name2, &region2);
  116 
  117     return (dns_name_rdatacompare(&name1, &name2));
  118 }
  119 
  120 static inline isc_result_t
  121 fromstruct_mf(ARGS_FROMSTRUCT) {
  122     dns_rdata_mf_t *mf = source;
  123     isc_region_t region;
  124 
  125     REQUIRE(type == dns_rdatatype_mf);
  126     REQUIRE(mf != NULL);
  127     REQUIRE(mf->common.rdtype == type);
  128     REQUIRE(mf->common.rdclass == rdclass);
  129 
  130     UNUSED(type);
  131     UNUSED(rdclass);
  132 
  133     dns_name_toregion(&mf->mf, &region);
  134     return (isc_buffer_copyregion(target, &region));
  135 }
  136 
  137 static inline isc_result_t
  138 tostruct_mf(ARGS_TOSTRUCT) {
  139     dns_rdata_mf_t *mf = target;
  140     isc_region_t r;
  141     dns_name_t name;
  142 
  143     REQUIRE(rdata->type == dns_rdatatype_mf);
  144     REQUIRE(mf != NULL);
  145     REQUIRE(rdata->length != 0);
  146 
  147     mf->common.rdclass = rdata->rdclass;
  148     mf->common.rdtype = rdata->type;
  149     ISC_LINK_INIT(&mf->common, link);
  150 
  151     dns_name_init(&name, NULL);
  152     dns_rdata_toregion(rdata, &r);
  153     dns_name_fromregion(&name, &r);
  154     dns_name_init(&mf->mf, NULL);
  155     RETERR(name_duporclone(&name, mctx, &mf->mf));
  156     mf->mctx = mctx;
  157     return (ISC_R_SUCCESS);
  158 }
  159 
  160 static inline void
  161 freestruct_mf(ARGS_FREESTRUCT) {
  162     dns_rdata_mf_t *mf = source;
  163 
  164     REQUIRE(mf != NULL);
  165     REQUIRE(mf->common.rdtype == dns_rdatatype_mf);
  166 
  167     if (mf->mctx == NULL) {
  168         return;
  169     }
  170     dns_name_free(&mf->mf, mf->mctx);
  171     mf->mctx = NULL;
  172 }
  173 
  174 static inline isc_result_t
  175 additionaldata_mf(ARGS_ADDLDATA) {
  176     dns_name_t name;
  177     dns_offsets_t offsets;
  178     isc_region_t region;
  179 
  180     REQUIRE(rdata->type == dns_rdatatype_mf);
  181 
  182     dns_name_init(&name, offsets);
  183     dns_rdata_toregion(rdata, &region);
  184     dns_name_fromregion(&name, &region);
  185 
  186     return ((add)(arg, &name, dns_rdatatype_a));
  187 }
  188 
  189 static inline isc_result_t
  190 digest_mf(ARGS_DIGEST) {
  191     isc_region_t r;
  192     dns_name_t name;
  193 
  194     REQUIRE(rdata->type == dns_rdatatype_mf);
  195 
  196     dns_rdata_toregion(rdata, &r);
  197     dns_name_init(&name, NULL);
  198     dns_name_fromregion(&name, &r);
  199 
  200     return (dns_name_digest(&name, digest, arg));
  201 }
  202 
  203 static inline bool
  204 checkowner_mf(ARGS_CHECKOWNER) {
  205     REQUIRE(type == dns_rdatatype_mf);
  206 
  207     UNUSED(name);
  208     UNUSED(type);
  209     UNUSED(rdclass);
  210     UNUSED(wildcard);
  211 
  212     return (true);
  213 }
  214 
  215 static inline bool
  216 checknames_mf(ARGS_CHECKNAMES) {
  217     REQUIRE(rdata->type == dns_rdatatype_mf);
  218 
  219     UNUSED(rdata);
  220     UNUSED(owner);
  221     UNUSED(bad);
  222 
  223     return (true);
  224 }
  225 
  226 static inline int
  227 casecompare_mf(ARGS_COMPARE) {
  228     return (compare_mf(rdata1, rdata2));
  229 }
  230 
  231 #endif /* RDATA_GENERIC_MF_4_C */