"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/lib/dns/rdata/generic/talink_58.c" (7 Sep 2020, 6242 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 "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     for (i = 0; i < 2; i++) {
   34         RETERR(isc_lex_getmastertoken(lexer, &token,
   35                           isc_tokentype_string,
   36                           false));
   37 
   38         dns_name_init(&name, NULL);
   39         buffer_fromregion(&buffer, &token.value.as_region);
   40         RETTOK(dns_name_fromtext(&name, &buffer, origin,
   41                      options, 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;
  144     isc_region_t region;
  145 
  146     REQUIRE(type == dns_rdatatype_talink);
  147     REQUIRE(((dns_rdata_talink_t *)source) != NULL);
  148     REQUIRE(((dns_rdata_talink_t *)source)->common.rdtype == type);
  149     REQUIRE(((dns_rdata_talink_t *)source)->common.rdclass == rdclass);
  150 
  151     talink = source;
  152 
  153     UNUSED(type);
  154     UNUSED(rdclass);
  155 
  156     dns_name_toregion(&talink->prev, &region);
  157     RETERR(isc_buffer_copyregion(target, &region));
  158     dns_name_toregion(&talink->next, &region);
  159     return(isc_buffer_copyregion(target, &region));
  160 }
  161 
  162 static inline isc_result_t
  163 tostruct_talink(ARGS_TOSTRUCT) {
  164     isc_region_t region;
  165     dns_rdata_talink_t *talink;
  166     dns_name_t name;
  167     isc_result_t result;
  168 
  169     REQUIRE(((dns_rdata_talink_t *)target) != NULL);
  170     REQUIRE(rdata->type == dns_rdatatype_talink);
  171     REQUIRE(rdata->length != 0);
  172 
  173     talink = target;
  174 
  175     talink->common.rdclass = rdata->rdclass;
  176     talink->common.rdtype = rdata->type;
  177     ISC_LINK_INIT(&talink->common, link);
  178 
  179     dns_rdata_toregion(rdata, &region);
  180 
  181     dns_name_init(&name, NULL);
  182     dns_name_fromregion(&name, &region);
  183     isc_region_consume(&region, name_length(&name));
  184     dns_name_init(&talink->prev, NULL);
  185     RETERR(name_duporclone(&name, mctx, &talink->prev));
  186 
  187     dns_name_fromregion(&name, &region);
  188     isc_region_consume(&region, name_length(&name));
  189     dns_name_init(&talink->next, NULL);
  190     result = name_duporclone(&name, mctx, &talink->next);
  191     if (result != ISC_R_SUCCESS)
  192         goto cleanup;
  193 
  194     talink->mctx = mctx;
  195     return (ISC_R_SUCCESS);
  196 
  197  cleanup:
  198     if (mctx != NULL)
  199         dns_name_free(&talink->prev, mctx);
  200     return (ISC_R_NOMEMORY);
  201 }
  202 
  203 static inline void
  204 freestruct_talink(ARGS_FREESTRUCT) {
  205     dns_rdata_talink_t *talink;
  206 
  207     REQUIRE(((dns_rdata_talink_t *)source) != NULL);
  208     REQUIRE(((dns_rdata_talink_t *)source)->common.rdtype ==
  209         dns_rdatatype_talink);
  210 
  211     talink = source;
  212 
  213     if (talink->mctx == NULL)
  214         return;
  215 
  216     dns_name_free(&talink->prev, talink->mctx);
  217     dns_name_free(&talink->next, talink->mctx);
  218     talink->mctx = NULL;
  219 }
  220 
  221 static inline isc_result_t
  222 additionaldata_talink(ARGS_ADDLDATA) {
  223     UNUSED(rdata);
  224     UNUSED(add);
  225     UNUSED(arg);
  226 
  227     REQUIRE(rdata->type == dns_rdatatype_talink);
  228 
  229     return (ISC_R_SUCCESS);
  230 }
  231 
  232 static inline isc_result_t
  233 digest_talink(ARGS_DIGEST) {
  234     isc_region_t r;
  235 
  236     REQUIRE(rdata->type == dns_rdatatype_talink);
  237 
  238     dns_rdata_toregion(rdata, &r);
  239     return ((digest)(arg, &r));
  240 }
  241 
  242 static inline bool
  243 checkowner_talink(ARGS_CHECKOWNER) {
  244 
  245     REQUIRE(type == dns_rdatatype_talink);
  246 
  247     UNUSED(name);
  248     UNUSED(type);
  249     UNUSED(rdclass);
  250     UNUSED(wildcard);
  251 
  252     return (true);
  253 }
  254 
  255 static inline bool
  256 checknames_talink(ARGS_CHECKNAMES) {
  257 
  258     REQUIRE(rdata->type == dns_rdatatype_talink);
  259 
  260     UNUSED(bad);
  261     UNUSED(owner);
  262 
  263     return (true);
  264 }
  265 
  266 static inline int
  267 casecompare_talink(ARGS_COMPARE) {
  268     return (compare_talink(rdata1, rdata2));
  269 }
  270 
  271 #endif  /* RDATA_GENERIC_TALINK_58_C */