"Fossies" - the Fresh Open Source Software Archive

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