"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/lib/dns/rdata/in_1/dhcid_49.c" (7 Sep 2020, 5532 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 "dhcid_49.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 
   13 /* RFC 4701 */
   14 
   15 #ifndef RDATA_IN_1_DHCID_49_C
   16 #define RDATA_IN_1_DHCID_49_C 1
   17 
   18 #define RRTYPE_DHCID_ATTRIBUTES 0
   19 
   20 static inline isc_result_t
   21 fromtext_in_dhcid(ARGS_FROMTEXT) {
   22 
   23     REQUIRE(type == dns_rdatatype_dhcid);
   24     REQUIRE(rdclass == dns_rdataclass_in);
   25 
   26     UNUSED(type);
   27     UNUSED(rdclass);
   28     UNUSED(origin);
   29     UNUSED(options);
   30     UNUSED(callbacks);
   31 
   32     return (isc_base64_tobuffer(lexer, target, -2));
   33 }
   34 
   35 static inline isc_result_t
   36 totext_in_dhcid(ARGS_TOTEXT) {
   37     isc_region_t sr, sr2;
   38     /* " ; 64000 255 64000" */
   39     char buf[5 + 3*11 + 1];
   40 
   41     REQUIRE(rdata->type == dns_rdatatype_dhcid);
   42     REQUIRE(rdata->rdclass == dns_rdataclass_in);
   43     REQUIRE(rdata->length != 0);
   44 
   45     dns_rdata_toregion(rdata, &sr);
   46     sr2 = sr;
   47 
   48     if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
   49         RETERR(str_totext("( " /*)*/, target));
   50     if (tctx->width == 0)   /* No splitting */
   51         RETERR(isc_base64_totext(&sr, 60, "", target));
   52     else
   53         RETERR(isc_base64_totext(&sr, tctx->width - 2,
   54                      tctx->linebreak, target));
   55     if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
   56         RETERR(str_totext(/* ( */ " )", target));
   57         if (rdata->length > 2) {
   58             snprintf(buf, sizeof(buf), " ; %u %u %u",
   59                  sr2.base[0] * 256U + sr2.base[1],
   60                  sr2.base[2], rdata->length - 3U);
   61             RETERR(str_totext(buf, target));
   62         }
   63     }
   64     return (ISC_R_SUCCESS);
   65 }
   66 
   67 static inline isc_result_t
   68 fromwire_in_dhcid(ARGS_FROMWIRE) {
   69     isc_region_t sr;
   70 
   71     REQUIRE(type == dns_rdatatype_dhcid);
   72     REQUIRE(rdclass == dns_rdataclass_in);
   73 
   74     UNUSED(type);
   75     UNUSED(rdclass);
   76     UNUSED(dctx);
   77     UNUSED(options);
   78 
   79     isc_buffer_activeregion(source, &sr);
   80     if (sr.length == 0)
   81         return (ISC_R_UNEXPECTEDEND);
   82 
   83     isc_buffer_forward(source, sr.length);
   84     return (mem_tobuffer(target, sr.base, sr.length));
   85 }
   86 
   87 static inline isc_result_t
   88 towire_in_dhcid(ARGS_TOWIRE) {
   89     isc_region_t sr;
   90 
   91     REQUIRE(rdata->type == dns_rdatatype_dhcid);
   92     REQUIRE(rdata->rdclass == dns_rdataclass_in);
   93     REQUIRE(rdata->length != 0);
   94 
   95     UNUSED(cctx);
   96 
   97     dns_rdata_toregion(rdata, &sr);
   98     return (mem_tobuffer(target, sr.base, sr.length));
   99 }
  100 
  101 static inline int
  102 compare_in_dhcid(ARGS_COMPARE) {
  103     isc_region_t r1;
  104     isc_region_t r2;
  105 
  106     REQUIRE(rdata1->type == rdata2->type);
  107     REQUIRE(rdata1->rdclass == rdata2->rdclass);
  108     REQUIRE(rdata1->type == dns_rdatatype_dhcid);
  109     REQUIRE(rdata1->rdclass == dns_rdataclass_in);
  110     REQUIRE(rdata1->length != 0);
  111     REQUIRE(rdata2->length != 0);
  112 
  113     dns_rdata_toregion(rdata1, &r1);
  114     dns_rdata_toregion(rdata2, &r2);
  115     return (isc_region_compare(&r1, &r2));
  116 }
  117 
  118 static inline isc_result_t
  119 fromstruct_in_dhcid(ARGS_FROMSTRUCT) {
  120     dns_rdata_in_dhcid_t *dhcid;
  121 
  122     REQUIRE(type == dns_rdatatype_dhcid);
  123     REQUIRE(rdclass == dns_rdataclass_in);
  124     REQUIRE(((dns_rdata_in_dhcid_t *)source) != NULL);
  125     REQUIRE(((dns_rdata_in_dhcid_t *)source)->common.rdtype == type);
  126     REQUIRE(((dns_rdata_in_dhcid_t *)source)->common.rdclass == rdclass);
  127     REQUIRE(((dns_rdata_in_dhcid_t *)source)->length != 0);
  128 
  129     dhcid = source;
  130 
  131     UNUSED(type);
  132     UNUSED(rdclass);
  133 
  134     return (mem_tobuffer(target, dhcid->dhcid, dhcid->length));
  135 }
  136 
  137 static inline isc_result_t
  138 tostruct_in_dhcid(ARGS_TOSTRUCT) {
  139     dns_rdata_in_dhcid_t *dhcid;
  140     isc_region_t region;
  141 
  142     REQUIRE(((dns_rdata_in_dhcid_t *)target) != NULL);
  143     REQUIRE(rdata->type == dns_rdatatype_dhcid);
  144     REQUIRE(rdata->rdclass == dns_rdataclass_in);
  145     REQUIRE(rdata->length != 0);
  146 
  147     dhcid = target;
  148 
  149     dhcid->common.rdclass = rdata->rdclass;
  150     dhcid->common.rdtype = rdata->type;
  151     ISC_LINK_INIT(&dhcid->common, link);
  152 
  153     dns_rdata_toregion(rdata, &region);
  154 
  155     dhcid->dhcid = mem_maybedup(mctx, region.base, region.length);
  156     if (dhcid->dhcid == NULL)
  157         return (ISC_R_NOMEMORY);
  158 
  159     dhcid->mctx = mctx;
  160     return (ISC_R_SUCCESS);
  161 }
  162 
  163 static inline void
  164 freestruct_in_dhcid(ARGS_FREESTRUCT) {
  165     dns_rdata_in_dhcid_t *dhcid;
  166 
  167     REQUIRE(((dns_rdata_in_dhcid_t *)source) != NULL);
  168     REQUIRE(((dns_rdata_in_dhcid_t *)source)->common.rdtype ==
  169         dns_rdatatype_dhcid);
  170     REQUIRE(((dns_rdata_in_dhcid_t *)source)->common.rdclass ==
  171         dns_rdataclass_in);
  172 
  173     dhcid = source;
  174 
  175     if (dhcid->mctx == NULL)
  176         return;
  177 
  178     if (dhcid->dhcid != NULL)
  179         isc_mem_free(dhcid->mctx, dhcid->dhcid);
  180     dhcid->mctx = NULL;
  181 }
  182 
  183 static inline isc_result_t
  184 additionaldata_in_dhcid(ARGS_ADDLDATA) {
  185     REQUIRE(rdata->type == dns_rdatatype_dhcid);
  186     REQUIRE(rdata->rdclass == dns_rdataclass_in);
  187 
  188     UNUSED(rdata);
  189     UNUSED(add);
  190     UNUSED(arg);
  191 
  192     return (ISC_R_SUCCESS);
  193 }
  194 
  195 static inline isc_result_t
  196 digest_in_dhcid(ARGS_DIGEST) {
  197     isc_region_t r;
  198 
  199     REQUIRE(rdata->type == dns_rdatatype_dhcid);
  200     REQUIRE(rdata->rdclass == dns_rdataclass_in);
  201 
  202     dns_rdata_toregion(rdata, &r);
  203 
  204     return ((digest)(arg, &r));
  205 }
  206 
  207 static inline bool
  208 checkowner_in_dhcid(ARGS_CHECKOWNER) {
  209 
  210     REQUIRE(type == dns_rdatatype_dhcid);
  211     REQUIRE(rdclass == dns_rdataclass_in);
  212 
  213     UNUSED(name);
  214     UNUSED(type);
  215     UNUSED(rdclass);
  216     UNUSED(wildcard);
  217 
  218     return (true);
  219 }
  220 
  221 static inline bool
  222 checknames_in_dhcid(ARGS_CHECKNAMES) {
  223 
  224     REQUIRE(rdata->type == dns_rdatatype_dhcid);
  225     REQUIRE(rdata->rdclass == dns_rdataclass_in);
  226 
  227     UNUSED(rdata);
  228     UNUSED(owner);
  229     UNUSED(bad);
  230 
  231     return (true);
  232 }
  233 
  234 static inline int
  235 casecompare_in_dhcid(ARGS_COMPARE) {
  236     return (compare_in_dhcid(rdata1, rdata2));
  237 }
  238 
  239 #endif  /* RDATA_IN_1_DHCID_49_C */