"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/lib/dns/rdata/generic/mf_4.c" (7 Sep 2020, 5141 Bytes) of package /linux/misc/dns/bind9/9.11.23/bind-9.11.23.tar.gz:


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     RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
   37     return (ISC_R_SUCCESS);
   38 }
   39 
   40 static inline isc_result_t
   41 totext_mf(ARGS_TOTEXT) {
   42     isc_region_t region;
   43     dns_name_t name;
   44     dns_name_t prefix;
   45     bool sub;
   46 
   47     REQUIRE(rdata->type == dns_rdatatype_mf);
   48     REQUIRE(rdata->length != 0);
   49 
   50     dns_name_init(&name, NULL);
   51     dns_name_init(&prefix, NULL);
   52 
   53     dns_rdata_toregion(rdata, &region);
   54     dns_name_fromregion(&name, &region);
   55 
   56     sub = name_prefix(&name, tctx->origin, &prefix);
   57 
   58     return (dns_name_totext(&prefix, sub, target));
   59 }
   60 
   61 static inline isc_result_t
   62 fromwire_mf(ARGS_FROMWIRE) {
   63     dns_name_t name;
   64 
   65     REQUIRE(type == dns_rdatatype_mf);
   66 
   67     UNUSED(type);
   68     UNUSED(rdclass);
   69 
   70     dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
   71 
   72     dns_name_init(&name, NULL);
   73     return (dns_name_fromwire(&name, source, dctx, options, target));
   74 }
   75 
   76 static inline isc_result_t
   77 towire_mf(ARGS_TOWIRE) {
   78     dns_name_t name;
   79     dns_offsets_t offsets;
   80     isc_region_t region;
   81 
   82     REQUIRE(rdata->type == dns_rdatatype_mf);
   83     REQUIRE(rdata->length != 0);
   84 
   85     dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
   86 
   87     dns_name_init(&name, offsets);
   88     dns_rdata_toregion(rdata, &region);
   89     dns_name_fromregion(&name, &region);
   90 
   91     return (dns_name_towire(&name, cctx, target));
   92 }
   93 
   94 static inline int
   95 compare_mf(ARGS_COMPARE) {
   96     dns_name_t name1;
   97     dns_name_t name2;
   98     isc_region_t region1;
   99     isc_region_t region2;
  100 
  101     REQUIRE(rdata1->type == rdata2->type);
  102     REQUIRE(rdata1->rdclass == rdata2->rdclass);
  103     REQUIRE(rdata1->type == dns_rdatatype_mf);
  104     REQUIRE(rdata1->length != 0);
  105     REQUIRE(rdata2->length != 0);
  106 
  107     dns_name_init(&name1, NULL);
  108     dns_name_init(&name2, NULL);
  109 
  110     dns_rdata_toregion(rdata1, &region1);
  111     dns_rdata_toregion(rdata2, &region2);
  112 
  113     dns_name_fromregion(&name1, &region1);
  114     dns_name_fromregion(&name2, &region2);
  115 
  116     return (dns_name_rdatacompare(&name1, &name2));
  117 }
  118 
  119 static inline isc_result_t
  120 fromstruct_mf(ARGS_FROMSTRUCT) {
  121     dns_rdata_mf_t *mf;
  122     isc_region_t region;
  123 
  124     REQUIRE(type == dns_rdatatype_mf);
  125     REQUIRE(((dns_rdata_mf_t *)source) != NULL);
  126     REQUIRE(((dns_rdata_mf_t *)source)->common.rdtype == type);
  127     REQUIRE(((dns_rdata_mf_t *)source)->common.rdclass == rdclass);
  128 
  129     mf = source;
  130 
  131     UNUSED(type);
  132     UNUSED(rdclass);
  133 
  134     dns_name_toregion(&mf->mf, &region);
  135     return (isc_buffer_copyregion(target, &region));
  136 }
  137 
  138 static inline isc_result_t
  139 tostruct_mf(ARGS_TOSTRUCT) {
  140     dns_rdata_mf_t *mf;
  141     isc_region_t r;
  142     dns_name_t name;
  143 
  144     REQUIRE(((dns_rdata_mf_t *)target) != NULL);
  145     REQUIRE(rdata->type == dns_rdatatype_mf);
  146     REQUIRE(rdata->length != 0);
  147 
  148     mf = target;
  149 
  150     mf->common.rdclass = rdata->rdclass;
  151     mf->common.rdtype = rdata->type;
  152     ISC_LINK_INIT(&mf->common, link);
  153 
  154     dns_name_init(&name, NULL);
  155     dns_rdata_toregion(rdata, &r);
  156     dns_name_fromregion(&name, &r);
  157     dns_name_init(&mf->mf, NULL);
  158     RETERR(name_duporclone(&name, mctx, &mf->mf));
  159     mf->mctx = mctx;
  160     return (ISC_R_SUCCESS);
  161 }
  162 
  163 static inline void
  164 freestruct_mf(ARGS_FREESTRUCT) {
  165     dns_rdata_mf_t *mf;
  166 
  167     REQUIRE(((dns_rdata_mf_t *)source) != NULL);
  168     REQUIRE(((dns_rdata_mf_t *)source)->common.rdtype == dns_rdatatype_mf);
  169 
  170     mf = source;
  171 
  172     if (mf->mctx == NULL)
  173         return;
  174     dns_name_free(&mf->mf, mf->mctx);
  175     mf->mctx = NULL;
  176 }
  177 
  178 static inline isc_result_t
  179 additionaldata_mf(ARGS_ADDLDATA) {
  180     dns_name_t name;
  181     dns_offsets_t offsets;
  182     isc_region_t region;
  183 
  184     REQUIRE(rdata->type == dns_rdatatype_mf);
  185 
  186     dns_name_init(&name, offsets);
  187     dns_rdata_toregion(rdata, &region);
  188     dns_name_fromregion(&name, &region);
  189 
  190     return ((add)(arg, &name, dns_rdatatype_a));
  191 }
  192 
  193 static inline isc_result_t
  194 digest_mf(ARGS_DIGEST) {
  195     isc_region_t r;
  196     dns_name_t name;
  197 
  198     REQUIRE(rdata->type == dns_rdatatype_mf);
  199 
  200     dns_rdata_toregion(rdata, &r);
  201     dns_name_init(&name, NULL);
  202     dns_name_fromregion(&name, &r);
  203 
  204     return (dns_name_digest(&name, digest, arg));
  205 }
  206 
  207 static inline bool
  208 checkowner_mf(ARGS_CHECKOWNER) {
  209 
  210     REQUIRE(type == dns_rdatatype_mf);
  211 
  212     UNUSED(name);
  213     UNUSED(type);
  214     UNUSED(rdclass);
  215     UNUSED(wildcard);
  216 
  217     return (true);
  218 }
  219 
  220 static inline bool
  221 checknames_mf(ARGS_CHECKNAMES) {
  222 
  223     REQUIRE(rdata->type == dns_rdatatype_mf);
  224 
  225     UNUSED(rdata);
  226     UNUSED(owner);
  227     UNUSED(bad);
  228 
  229     return (true);
  230 }
  231 
  232 static inline int
  233 casecompare_mf(ARGS_COMPARE) {
  234     return (compare_mf(rdata1, rdata2));
  235 }
  236 
  237 #endif  /* RDATA_GENERIC_MF_4_C */