"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.16.7/lib/dns/rdata/generic/talink_58.c" (4 Sep 2020, 6076 Bytes) of package /linux/misc/dns/bind9/9.16.7/bind-9.16.7.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 "talink_58.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_TALINK_58_C
   13 #define RDATA_GENERIC_TALINK_58_C
   14 
   15 #define RRTYPE_TALINK_ATTRIBUTES 0
   16 
   17 static inline isc_result_t
   18 fromtext_talink(ARGS_FROMTEXT) {
   19     isc_token_t token;
   20     dns_name_t name;
   21     isc_buffer_t buffer;
   22     int i;
   23 
   24     REQUIRE(type == dns_rdatatype_talink);
   25 
   26     UNUSED(type);
   27     UNUSED(rdclass);
   28     UNUSED(callbacks);
   29 
   30     if (origin == NULL) {
   31         origin = dns_rootname;
   32     }
   33 
   34     for (i = 0; i < 2; i++) {
   35         RETERR(isc_lex_getmastertoken(lexer, &token,
   36                           isc_tokentype_string, false));
   37 
   38         dns_name_init(&name, NULL);
   39         buffer_fromregion(&buffer, &token.value.as_region);
   40         RETTOK(dns_name_fromtext(&name, &buffer, origin, options,
   41                      target));
   42     }
   43 
   44     return (ISC_R_SUCCESS);
   45 }
   46 
   47 static inline isc_result_t
   48 totext_talink(ARGS_TOTEXT) {
   49     isc_region_t dregion;
   50     dns_name_t prev;
   51     dns_name_t next;
   52     dns_name_t prefix;
   53     bool sub;
   54 
   55     REQUIRE(rdata->type == dns_rdatatype_talink);
   56     REQUIRE(rdata->length != 0);
   57 
   58     dns_name_init(&prev, NULL);
   59     dns_name_init(&next, NULL);
   60     dns_name_init(&prefix, NULL);
   61 
   62     dns_rdata_toregion(rdata, &dregion);
   63 
   64     dns_name_fromregion(&prev, &dregion);
   65     isc_region_consume(&dregion, name_length(&prev));
   66 
   67     dns_name_fromregion(&next, &dregion);
   68     isc_region_consume(&dregion, name_length(&next));
   69 
   70     sub = name_prefix(&prev, tctx->origin, &prefix);
   71     RETERR(dns_name_totext(&prefix, sub, target));
   72 
   73     RETERR(str_totext(" ", target));
   74 
   75     sub = name_prefix(&next, tctx->origin, &prefix);
   76     return (dns_name_totext(&prefix, sub, target));
   77 }
   78 
   79 static inline isc_result_t
   80 fromwire_talink(ARGS_FROMWIRE) {
   81     dns_name_t prev;
   82     dns_name_t next;
   83 
   84     REQUIRE(type == dns_rdatatype_talink);
   85 
   86     UNUSED(type);
   87     UNUSED(rdclass);
   88 
   89     dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
   90 
   91     dns_name_init(&prev, NULL);
   92     dns_name_init(&next, NULL);
   93 
   94     RETERR(dns_name_fromwire(&prev, source, dctx, options, target));
   95     return (dns_name_fromwire(&next, source, dctx, options, target));
   96 }
   97 
   98 static inline isc_result_t
   99 towire_talink(ARGS_TOWIRE) {
  100     isc_region_t sregion;
  101     dns_name_t prev;
  102     dns_name_t next;
  103     dns_offsets_t moffsets;
  104     dns_offsets_t roffsets;
  105 
  106     REQUIRE(rdata->type == dns_rdatatype_talink);
  107     REQUIRE(rdata->length != 0);
  108 
  109     dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
  110 
  111     dns_name_init(&prev, moffsets);
  112     dns_name_init(&next, roffsets);
  113 
  114     dns_rdata_toregion(rdata, &sregion);
  115 
  116     dns_name_fromregion(&prev, &sregion);
  117     isc_region_consume(&sregion, name_length(&prev));
  118     RETERR(dns_name_towire(&prev, cctx, target));
  119 
  120     dns_name_fromregion(&next, &sregion);
  121     isc_region_consume(&sregion, name_length(&next));
  122     return (dns_name_towire(&next, cctx, target));
  123 }
  124 
  125 static inline int
  126 compare_talink(ARGS_COMPARE) {
  127     isc_region_t region1;
  128     isc_region_t region2;
  129 
  130     REQUIRE(rdata1->type == rdata2->type);
  131     REQUIRE(rdata1->rdclass == rdata2->rdclass);
  132     REQUIRE(rdata1->type == dns_rdatatype_talink);
  133     REQUIRE(rdata1->length != 0);
  134     REQUIRE(rdata2->length != 0);
  135 
  136     dns_rdata_toregion(rdata1, &region1);
  137     dns_rdata_toregion(rdata2, &region2);
  138     return (isc_region_compare(&region1, &region2));
  139 }
  140 
  141 static inline isc_result_t
  142 fromstruct_talink(ARGS_FROMSTRUCT) {
  143     dns_rdata_talink_t *talink = source;
  144     isc_region_t region;
  145 
  146     REQUIRE(type == dns_rdatatype_talink);
  147     REQUIRE(talink != NULL);
  148     REQUIRE(talink->common.rdtype == type);
  149     REQUIRE(talink->common.rdclass == rdclass);
  150 
  151     UNUSED(type);
  152     UNUSED(rdclass);
  153 
  154     dns_name_toregion(&talink->prev, &region);
  155     RETERR(isc_buffer_copyregion(target, &region));
  156     dns_name_toregion(&talink->next, &region);
  157     return (isc_buffer_copyregion(target, &region));
  158 }
  159 
  160 static inline isc_result_t
  161 tostruct_talink(ARGS_TOSTRUCT) {
  162     isc_region_t region;
  163     dns_rdata_talink_t *talink = target;
  164     dns_name_t name;
  165     isc_result_t result;
  166 
  167     REQUIRE(rdata->type == dns_rdatatype_talink);
  168     REQUIRE(talink != NULL);
  169     REQUIRE(rdata->length != 0);
  170 
  171     talink->common.rdclass = rdata->rdclass;
  172     talink->common.rdtype = rdata->type;
  173     ISC_LINK_INIT(&talink->common, link);
  174 
  175     dns_rdata_toregion(rdata, &region);
  176 
  177     dns_name_init(&name, NULL);
  178     dns_name_fromregion(&name, &region);
  179     isc_region_consume(&region, name_length(&name));
  180     dns_name_init(&talink->prev, NULL);
  181     RETERR(name_duporclone(&name, mctx, &talink->prev));
  182 
  183     dns_name_fromregion(&name, &region);
  184     isc_region_consume(&region, name_length(&name));
  185     dns_name_init(&talink->next, NULL);
  186     result = name_duporclone(&name, mctx, &talink->next);
  187     if (result != ISC_R_SUCCESS) {
  188         goto cleanup;
  189     }
  190 
  191     talink->mctx = mctx;
  192     return (ISC_R_SUCCESS);
  193 
  194 cleanup:
  195     if (mctx != NULL) {
  196         dns_name_free(&talink->prev, mctx);
  197     }
  198     return (ISC_R_NOMEMORY);
  199 }
  200 
  201 static inline void
  202 freestruct_talink(ARGS_FREESTRUCT) {
  203     dns_rdata_talink_t *talink = source;
  204 
  205     REQUIRE(talink != NULL);
  206     REQUIRE(talink->common.rdtype == dns_rdatatype_talink);
  207 
  208     if (talink->mctx == NULL) {
  209         return;
  210     }
  211 
  212     dns_name_free(&talink->prev, talink->mctx);
  213     dns_name_free(&talink->next, talink->mctx);
  214     talink->mctx = NULL;
  215 }
  216 
  217 static inline isc_result_t
  218 additionaldata_talink(ARGS_ADDLDATA) {
  219     UNUSED(rdata);
  220     UNUSED(add);
  221     UNUSED(arg);
  222 
  223     REQUIRE(rdata->type == dns_rdatatype_talink);
  224 
  225     return (ISC_R_SUCCESS);
  226 }
  227 
  228 static inline isc_result_t
  229 digest_talink(ARGS_DIGEST) {
  230     isc_region_t r;
  231 
  232     REQUIRE(rdata->type == dns_rdatatype_talink);
  233 
  234     dns_rdata_toregion(rdata, &r);
  235     return ((digest)(arg, &r));
  236 }
  237 
  238 static inline bool
  239 checkowner_talink(ARGS_CHECKOWNER) {
  240     REQUIRE(type == dns_rdatatype_talink);
  241 
  242     UNUSED(name);
  243     UNUSED(type);
  244     UNUSED(rdclass);
  245     UNUSED(wildcard);
  246 
  247     return (true);
  248 }
  249 
  250 static inline bool
  251 checknames_talink(ARGS_CHECKNAMES) {
  252     REQUIRE(rdata->type == dns_rdatatype_talink);
  253 
  254     UNUSED(bad);
  255     UNUSED(owner);
  256 
  257     return (true);
  258 }
  259 
  260 static inline int
  261 casecompare_talink(ARGS_COMPARE) {
  262     return (compare_talink(rdata1, rdata2));
  263 }
  264 
  265 #endif /* RDATA_GENERIC_TALINK_58_C */