"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.17.5/lib/dns/rdata/in_1/nimloc_32.c" (4 Sep 2020, 5178 Bytes) of package /linux/misc/dns/bind9/9.17.5/bind-9.17.5.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 "nimloc_32.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 /* http://ana-3.lcs.mit.edu/~jnc/nimrod/dns.txt */
   13 
   14 #ifndef RDATA_IN_1_NIMLOC_32_C
   15 #define RDATA_IN_1_NIMLOC_32_C
   16 
   17 #define RRTYPE_NIMLOC_ATTRIBUTES (0)
   18 
   19 static inline isc_result_t
   20 fromtext_in_nimloc(ARGS_FROMTEXT) {
   21     REQUIRE(type == dns_rdatatype_nimloc);
   22     REQUIRE(rdclass == dns_rdataclass_in);
   23 
   24     UNUSED(type);
   25     UNUSED(origin);
   26     UNUSED(options);
   27     UNUSED(rdclass);
   28     UNUSED(callbacks);
   29 
   30     return (isc_hex_tobuffer(lexer, target, -2));
   31 }
   32 
   33 static inline isc_result_t
   34 totext_in_nimloc(ARGS_TOTEXT) {
   35     isc_region_t region;
   36 
   37     REQUIRE(rdata->type == dns_rdatatype_nimloc);
   38     REQUIRE(rdata->rdclass == dns_rdataclass_in);
   39     REQUIRE(rdata->length != 0);
   40 
   41     dns_rdata_toregion(rdata, &region);
   42 
   43     if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
   44         RETERR(str_totext("( ", target));
   45     }
   46     if (tctx->width == 0) {
   47         RETERR(isc_hex_totext(&region, 60, "", target));
   48     } else {
   49         RETERR(isc_hex_totext(&region, tctx->width - 2, tctx->linebreak,
   50                       target));
   51     }
   52     if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
   53         RETERR(str_totext(" )", target));
   54     }
   55     return (ISC_R_SUCCESS);
   56 }
   57 
   58 static inline isc_result_t
   59 fromwire_in_nimloc(ARGS_FROMWIRE) {
   60     isc_region_t region;
   61 
   62     REQUIRE(type == dns_rdatatype_nimloc);
   63     REQUIRE(rdclass == dns_rdataclass_in);
   64 
   65     UNUSED(type);
   66     UNUSED(dctx);
   67     UNUSED(options);
   68     UNUSED(rdclass);
   69 
   70     isc_buffer_activeregion(source, &region);
   71     if (region.length < 1) {
   72         return (ISC_R_UNEXPECTEDEND);
   73     }
   74 
   75     RETERR(mem_tobuffer(target, region.base, region.length));
   76     isc_buffer_forward(source, region.length);
   77     return (ISC_R_SUCCESS);
   78 }
   79 
   80 static inline isc_result_t
   81 towire_in_nimloc(ARGS_TOWIRE) {
   82     REQUIRE(rdata->type == dns_rdatatype_nimloc);
   83     REQUIRE(rdata->rdclass == dns_rdataclass_in);
   84     REQUIRE(rdata->length != 0);
   85 
   86     UNUSED(cctx);
   87 
   88     return (mem_tobuffer(target, rdata->data, rdata->length));
   89 }
   90 
   91 static inline int
   92 compare_in_nimloc(ARGS_COMPARE) {
   93     isc_region_t r1;
   94     isc_region_t r2;
   95 
   96     REQUIRE(rdata1->type == rdata2->type);
   97     REQUIRE(rdata1->rdclass == rdata2->rdclass);
   98     REQUIRE(rdata1->type == dns_rdatatype_nimloc);
   99     REQUIRE(rdata1->rdclass == dns_rdataclass_in);
  100     REQUIRE(rdata1->length != 0);
  101     REQUIRE(rdata2->length != 0);
  102 
  103     dns_rdata_toregion(rdata1, &r1);
  104     dns_rdata_toregion(rdata2, &r2);
  105     return (isc_region_compare(&r1, &r2));
  106 }
  107 
  108 static inline isc_result_t
  109 fromstruct_in_nimloc(ARGS_FROMSTRUCT) {
  110     dns_rdata_in_nimloc_t *nimloc = source;
  111 
  112     REQUIRE(type == dns_rdatatype_nimloc);
  113     REQUIRE(rdclass == dns_rdataclass_in);
  114     REQUIRE(nimloc != NULL);
  115     REQUIRE(nimloc->common.rdtype == type);
  116     REQUIRE(nimloc->common.rdclass == rdclass);
  117     REQUIRE(nimloc->nimloc != NULL || nimloc->nimloc_len == 0);
  118 
  119     UNUSED(type);
  120     UNUSED(rdclass);
  121 
  122     return (mem_tobuffer(target, nimloc->nimloc, nimloc->nimloc_len));
  123 }
  124 
  125 static inline isc_result_t
  126 tostruct_in_nimloc(ARGS_TOSTRUCT) {
  127     dns_rdata_in_nimloc_t *nimloc = target;
  128     isc_region_t r;
  129 
  130     REQUIRE(rdata->type == dns_rdatatype_nimloc);
  131     REQUIRE(rdata->rdclass == dns_rdataclass_in);
  132     REQUIRE(nimloc != NULL);
  133     REQUIRE(rdata->length != 0);
  134 
  135     nimloc->common.rdclass = rdata->rdclass;
  136     nimloc->common.rdtype = rdata->type;
  137     ISC_LINK_INIT(&nimloc->common, link);
  138 
  139     dns_rdata_toregion(rdata, &r);
  140     nimloc->nimloc_len = r.length;
  141     nimloc->nimloc = mem_maybedup(mctx, r.base, r.length);
  142     if (nimloc->nimloc == NULL) {
  143         return (ISC_R_NOMEMORY);
  144     }
  145 
  146     nimloc->mctx = mctx;
  147     return (ISC_R_SUCCESS);
  148 }
  149 
  150 static inline void
  151 freestruct_in_nimloc(ARGS_FREESTRUCT) {
  152     dns_rdata_in_nimloc_t *nimloc = source;
  153 
  154     REQUIRE(nimloc != NULL);
  155     REQUIRE(nimloc->common.rdclass == dns_rdataclass_in);
  156     REQUIRE(nimloc->common.rdtype == dns_rdatatype_nimloc);
  157 
  158     if (nimloc->mctx == NULL) {
  159         return;
  160     }
  161 
  162     if (nimloc->nimloc != NULL) {
  163         isc_mem_free(nimloc->mctx, nimloc->nimloc);
  164     }
  165     nimloc->mctx = NULL;
  166 }
  167 
  168 static inline isc_result_t
  169 additionaldata_in_nimloc(ARGS_ADDLDATA) {
  170     REQUIRE(rdata->type == dns_rdatatype_nimloc);
  171     REQUIRE(rdata->rdclass == dns_rdataclass_in);
  172 
  173     UNUSED(rdata);
  174     UNUSED(add);
  175     UNUSED(arg);
  176 
  177     return (ISC_R_SUCCESS);
  178 }
  179 
  180 static inline isc_result_t
  181 digest_in_nimloc(ARGS_DIGEST) {
  182     isc_region_t r;
  183 
  184     REQUIRE(rdata->type == dns_rdatatype_nimloc);
  185     REQUIRE(rdata->rdclass == dns_rdataclass_in);
  186 
  187     dns_rdata_toregion(rdata, &r);
  188 
  189     return ((digest)(arg, &r));
  190 }
  191 
  192 static inline bool
  193 checkowner_in_nimloc(ARGS_CHECKOWNER) {
  194     REQUIRE(type == dns_rdatatype_nimloc);
  195     REQUIRE(rdclass == dns_rdataclass_in);
  196 
  197     UNUSED(name);
  198     UNUSED(type);
  199     UNUSED(rdclass);
  200     UNUSED(wildcard);
  201 
  202     return (true);
  203 }
  204 
  205 static inline bool
  206 checknames_in_nimloc(ARGS_CHECKNAMES) {
  207     REQUIRE(rdata->type == dns_rdatatype_nimloc);
  208     REQUIRE(rdata->rdclass == dns_rdataclass_in);
  209 
  210     UNUSED(rdata);
  211     UNUSED(owner);
  212     UNUSED(bad);
  213 
  214     return (true);
  215 }
  216 
  217 static inline int
  218 casecompare_in_nimloc(ARGS_COMPARE) {
  219     return (compare_in_nimloc(rdata1, rdata2));
  220 }
  221 
  222 #endif /* RDATA_IN_1_NIMLOC_32_C */