"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/lib/dns/rdata/generic/cname_5.c" (7 Sep 2020, 5168 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 "cname_5.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_CNAME_5_C
   13 #define RDATA_GENERIC_CNAME_5_C
   14 
   15 #define RRTYPE_CNAME_ATTRIBUTES \
   16     (DNS_RDATATYPEATTR_EXCLUSIVE | DNS_RDATATYPEATTR_SINGLETON)
   17 
   18 static inline isc_result_t
   19 fromtext_cname(ARGS_FROMTEXT) {
   20     isc_token_t token;
   21     dns_name_t name;
   22     isc_buffer_t buffer;
   23 
   24     REQUIRE(type == dns_rdatatype_cname);
   25 
   26     UNUSED(type);
   27     UNUSED(rdclass);
   28     UNUSED(callbacks);
   29 
   30     RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
   31                       false));
   32 
   33     dns_name_init(&name, NULL);
   34     buffer_fromregion(&buffer, &token.value.as_region);
   35     if (origin == NULL)
   36         origin = dns_rootname;
   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_cname(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_cname);
   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_cname(ARGS_FROMWIRE) {
   64     dns_name_t name;
   65 
   66     REQUIRE(type == dns_rdatatype_cname);
   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_cname(ARGS_TOWIRE) {
   79     dns_name_t name;
   80     dns_offsets_t offsets;
   81     isc_region_t region;
   82 
   83     REQUIRE(rdata->type == dns_rdatatype_cname);
   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_cname(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_cname);
  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_cname(ARGS_FROMSTRUCT) {
  122     dns_rdata_cname_t *cname;
  123     isc_region_t region;
  124 
  125     REQUIRE(type == dns_rdatatype_cname);
  126     REQUIRE(((dns_rdata_cname_t *)source) != NULL);
  127     REQUIRE(((dns_rdata_cname_t *)source)->common.rdtype == type);
  128     REQUIRE(((dns_rdata_cname_t *)source)->common.rdclass == rdclass);
  129 
  130     cname = source;
  131 
  132     UNUSED(type);
  133     UNUSED(rdclass);
  134 
  135     dns_name_toregion(&cname->cname, &region);
  136     return (isc_buffer_copyregion(target, &region));
  137 }
  138 
  139 static inline isc_result_t
  140 tostruct_cname(ARGS_TOSTRUCT) {
  141     isc_region_t region;
  142     dns_rdata_cname_t *cname;
  143     dns_name_t name;
  144 
  145     REQUIRE(((dns_rdata_cname_t *)target) != NULL);
  146     REQUIRE(rdata->type == dns_rdatatype_cname);
  147     REQUIRE(rdata->length != 0);
  148 
  149     cname = target;
  150 
  151     cname->common.rdclass = rdata->rdclass;
  152     cname->common.rdtype = rdata->type;
  153     ISC_LINK_INIT(&cname->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(&cname->cname, NULL);
  159     RETERR(name_duporclone(&name, mctx, &cname->cname));
  160     cname->mctx = mctx;
  161     return (ISC_R_SUCCESS);
  162 }
  163 
  164 static inline void
  165 freestruct_cname(ARGS_FREESTRUCT) {
  166     dns_rdata_cname_t *cname;
  167 
  168     REQUIRE(((dns_rdata_cname_t *)source) != NULL);
  169 
  170     cname = source;
  171 
  172     if (cname->mctx == NULL)
  173         return;
  174 
  175     dns_name_free(&cname->cname, cname->mctx);
  176     cname->mctx = NULL;
  177 }
  178 
  179 static inline isc_result_t
  180 additionaldata_cname(ARGS_ADDLDATA) {
  181     UNUSED(rdata);
  182     UNUSED(add);
  183     UNUSED(arg);
  184 
  185     REQUIRE(rdata->type == dns_rdatatype_cname);
  186 
  187     return (ISC_R_SUCCESS);
  188 }
  189 
  190 static inline isc_result_t
  191 digest_cname(ARGS_DIGEST) {
  192     isc_region_t r;
  193     dns_name_t name;
  194 
  195     REQUIRE(rdata->type == dns_rdatatype_cname);
  196 
  197     dns_rdata_toregion(rdata, &r);
  198     dns_name_init(&name, NULL);
  199     dns_name_fromregion(&name, &r);
  200 
  201     return (dns_name_digest(&name, digest, arg));
  202 }
  203 
  204 static inline bool
  205 checkowner_cname(ARGS_CHECKOWNER) {
  206 
  207     REQUIRE(type == dns_rdatatype_cname);
  208 
  209     UNUSED(name);
  210     UNUSED(type);
  211     UNUSED(rdclass);
  212     UNUSED(wildcard);
  213 
  214     return (true);
  215 }
  216 
  217 static inline bool
  218 checknames_cname(ARGS_CHECKNAMES) {
  219 
  220     REQUIRE(rdata->type == dns_rdatatype_cname);
  221 
  222     UNUSED(rdata);
  223     UNUSED(owner);
  224     UNUSED(bad);
  225 
  226     return (true);
  227 }
  228 
  229 static inline int
  230 casecompare_cname(ARGS_COMPARE) {
  231     return (compare_cname(rdata1, rdata2));
  232 }
  233 
  234 #endif  /* RDATA_GENERIC_CNAME_5_C */