"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/lib/dns/rdata/generic/dname_39.c" (7 Sep 2020, 5223 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 "dname_39.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 /* RFC2672 */
   13 
   14 #ifndef RDATA_GENERIC_DNAME_39_C
   15 #define RDATA_GENERIC_DNAME_39_C
   16 
   17 #define RRTYPE_DNAME_ATTRIBUTES (DNS_RDATATYPEATTR_SINGLETON)
   18 
   19 static inline isc_result_t
   20 fromtext_dname(ARGS_FROMTEXT) {
   21     isc_token_t token;
   22     dns_name_t name;
   23     isc_buffer_t buffer;
   24 
   25     REQUIRE(type == dns_rdatatype_dname);
   26 
   27     UNUSED(type);
   28     UNUSED(rdclass);
   29     UNUSED(callbacks);
   30 
   31     RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
   32                       false));
   33 
   34     dns_name_init(&name, NULL);
   35     buffer_fromregion(&buffer, &token.value.as_region);
   36     if (origin == NULL)
   37         origin = dns_rootname;
   38     RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
   39     return (ISC_R_SUCCESS);
   40 }
   41 
   42 static inline isc_result_t
   43 totext_dname(ARGS_TOTEXT) {
   44     isc_region_t region;
   45     dns_name_t name;
   46     dns_name_t prefix;
   47     bool sub;
   48 
   49     REQUIRE(rdata->type == dns_rdatatype_dname);
   50     REQUIRE(rdata->length != 0);
   51 
   52     dns_name_init(&name, NULL);
   53     dns_name_init(&prefix, NULL);
   54 
   55     dns_rdata_toregion(rdata, &region);
   56     dns_name_fromregion(&name, &region);
   57 
   58     sub = name_prefix(&name, tctx->origin, &prefix);
   59 
   60     return (dns_name_totext(&prefix, sub, target));
   61 }
   62 
   63 static inline isc_result_t
   64 fromwire_dname(ARGS_FROMWIRE) {
   65     dns_name_t name;
   66 
   67     REQUIRE(type == dns_rdatatype_dname);
   68 
   69     UNUSED(type);
   70     UNUSED(rdclass);
   71 
   72     dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
   73 
   74     dns_name_init(&name, NULL);
   75     return(dns_name_fromwire(&name, source, dctx, options, target));
   76 }
   77 
   78 static inline isc_result_t
   79 towire_dname(ARGS_TOWIRE) {
   80     dns_name_t name;
   81     dns_offsets_t offsets;
   82     isc_region_t region;
   83 
   84     REQUIRE(rdata->type == dns_rdatatype_dname);
   85     REQUIRE(rdata->length != 0);
   86 
   87     dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
   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_dname(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_dname);
  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_dname(ARGS_FROMSTRUCT) {
  122     dns_rdata_dname_t *dname;
  123     isc_region_t region;
  124 
  125     REQUIRE(type == dns_rdatatype_dname);
  126     REQUIRE(((dns_rdata_dname_t *)source) != NULL);
  127     REQUIRE(((dns_rdata_dname_t *)source)->common.rdtype == type);
  128     REQUIRE(((dns_rdata_dname_t *)source)->common.rdclass == rdclass);
  129 
  130     dname = source;
  131 
  132     UNUSED(type);
  133     UNUSED(rdclass);
  134 
  135     dns_name_toregion(&dname->dname, &region);
  136     return (isc_buffer_copyregion(target, &region));
  137 }
  138 
  139 static inline isc_result_t
  140 tostruct_dname(ARGS_TOSTRUCT) {
  141     isc_region_t region;
  142     dns_rdata_dname_t *dname;
  143     dns_name_t name;
  144 
  145     REQUIRE(((dns_rdata_dname_t *)target) != NULL);
  146     REQUIRE(rdata->type == dns_rdatatype_dname);
  147     REQUIRE(rdata->length != 0);
  148 
  149     dname = target;
  150 
  151     dname->common.rdclass = rdata->rdclass;
  152     dname->common.rdtype = rdata->type;
  153     ISC_LINK_INIT(&dname->common, link);
  154 
  155     dns_name_init(&name, NULL);
  156     dns_rdata_toregion(rdata, &region);
  157     dns_name_fromregion(&name, &region);
  158     dns_name_init(&dname->dname, NULL);
  159     RETERR(name_duporclone(&name, mctx, &dname->dname));
  160     dname->mctx = mctx;
  161     return (ISC_R_SUCCESS);
  162 }
  163 
  164 static inline void
  165 freestruct_dname(ARGS_FREESTRUCT) {
  166     dns_rdata_dname_t *dname;
  167 
  168     REQUIRE(((dns_rdata_dname_t *)source) != NULL);
  169     REQUIRE(((dns_rdata_dname_t *)source)->common.rdtype ==
  170         dns_rdatatype_dname);
  171 
  172     dname = source;
  173 
  174     if (dname->mctx == NULL)
  175         return;
  176 
  177     dns_name_free(&dname->dname, dname->mctx);
  178     dname->mctx = NULL;
  179 }
  180 
  181 static inline isc_result_t
  182 additionaldata_dname(ARGS_ADDLDATA) {
  183     UNUSED(rdata);
  184     UNUSED(add);
  185     UNUSED(arg);
  186 
  187     REQUIRE(rdata->type == dns_rdatatype_dname);
  188 
  189     return (ISC_R_SUCCESS);
  190 }
  191 
  192 static inline isc_result_t
  193 digest_dname(ARGS_DIGEST) {
  194     isc_region_t r;
  195     dns_name_t name;
  196 
  197     REQUIRE(rdata->type == dns_rdatatype_dname);
  198 
  199     dns_rdata_toregion(rdata, &r);
  200     dns_name_init(&name, NULL);
  201     dns_name_fromregion(&name, &r);
  202 
  203     return (dns_name_digest(&name, digest, arg));
  204 }
  205 
  206 static inline bool
  207 checkowner_dname(ARGS_CHECKOWNER) {
  208 
  209     REQUIRE(type == dns_rdatatype_dname);
  210 
  211     UNUSED(name);
  212     UNUSED(type);
  213     UNUSED(rdclass);
  214     UNUSED(wildcard);
  215 
  216     return (true);
  217 }
  218 
  219 static inline bool
  220 checknames_dname(ARGS_CHECKNAMES) {
  221 
  222     REQUIRE(rdata->type == dns_rdatatype_dname);
  223 
  224     UNUSED(rdata);
  225     UNUSED(owner);
  226     UNUSED(bad);
  227 
  228     return (true);
  229 }
  230 
  231 static inline int
  232 casecompare_dname(ARGS_COMPARE) {
  233     return (compare_dname(rdata1, rdata2));
  234 }
  235 #endif  /* RDATA_GENERIC_DNAME_39_C */