"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/lib/dns/rdata/in_1/aaaa_28.c" (7 Sep 2020, 5760 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 "aaaa_28.c" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 9.17.2_vs_9.17.3.

    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 /* RFC1886 */
   13 
   14 #ifndef RDATA_IN_1_AAAA_28_C
   15 #define RDATA_IN_1_AAAA_28_C
   16 
   17 #include <isc/net.h>
   18 
   19 #define RRTYPE_AAAA_ATTRIBUTES (0)
   20 
   21 static inline isc_result_t
   22 fromtext_in_aaaa(ARGS_FROMTEXT) {
   23     isc_token_t token;
   24     unsigned char addr[16];
   25     isc_region_t region;
   26 
   27     REQUIRE(type == dns_rdatatype_aaaa);
   28     REQUIRE(rdclass == dns_rdataclass_in);
   29 
   30     UNUSED(type);
   31     UNUSED(origin);
   32     UNUSED(options);
   33     UNUSED(rdclass);
   34     UNUSED(callbacks);
   35 
   36     RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
   37                       false));
   38 
   39     if (inet_pton(AF_INET6, DNS_AS_STR(token), addr) != 1)
   40         RETTOK(DNS_R_BADAAAA);
   41     isc_buffer_availableregion(target, &region);
   42     if (region.length < 16)
   43         return (ISC_R_NOSPACE);
   44     memmove(region.base, addr, 16);
   45     isc_buffer_add(target, 16);
   46     return (ISC_R_SUCCESS);
   47 }
   48 
   49 static inline isc_result_t
   50 totext_in_aaaa(ARGS_TOTEXT) {
   51     isc_region_t region;
   52 
   53     UNUSED(tctx);
   54 
   55     REQUIRE(rdata->type == dns_rdatatype_aaaa);
   56     REQUIRE(rdata->rdclass == dns_rdataclass_in);
   57     REQUIRE(rdata->length == 16);
   58 
   59     dns_rdata_toregion(rdata, &region);
   60     return (inet_totext(AF_INET6, tctx->flags, &region, target));
   61 }
   62 
   63 static inline isc_result_t
   64 fromwire_in_aaaa(ARGS_FROMWIRE) {
   65     isc_region_t sregion;
   66     isc_region_t tregion;
   67 
   68     REQUIRE(type == dns_rdatatype_aaaa);
   69     REQUIRE(rdclass == dns_rdataclass_in);
   70 
   71     UNUSED(type);
   72     UNUSED(dctx);
   73     UNUSED(options);
   74     UNUSED(rdclass);
   75 
   76     isc_buffer_activeregion(source, &sregion);
   77     isc_buffer_availableregion(target, &tregion);
   78     if (sregion.length < 16)
   79         return (ISC_R_UNEXPECTEDEND);
   80     if (tregion.length < 16)
   81         return (ISC_R_NOSPACE);
   82 
   83     memmove(tregion.base, sregion.base, 16);
   84     isc_buffer_forward(source, 16);
   85     isc_buffer_add(target, 16);
   86     return (ISC_R_SUCCESS);
   87 }
   88 
   89 static inline isc_result_t
   90 towire_in_aaaa(ARGS_TOWIRE) {
   91     isc_region_t region;
   92 
   93     UNUSED(cctx);
   94 
   95     REQUIRE(rdata->type == dns_rdatatype_aaaa);
   96     REQUIRE(rdata->rdclass == dns_rdataclass_in);
   97     REQUIRE(rdata->length == 16);
   98 
   99     isc_buffer_availableregion(target, &region);
  100     if (region.length < rdata->length)
  101         return (ISC_R_NOSPACE);
  102     memmove(region.base, rdata->data, rdata->length);
  103     isc_buffer_add(target, 16);
  104     return (ISC_R_SUCCESS);
  105 }
  106 
  107 static inline int
  108 compare_in_aaaa(ARGS_COMPARE) {
  109     isc_region_t r1;
  110     isc_region_t r2;
  111 
  112     REQUIRE(rdata1->type == rdata2->type);
  113     REQUIRE(rdata1->rdclass == rdata2->rdclass);
  114     REQUIRE(rdata1->type == dns_rdatatype_aaaa);
  115     REQUIRE(rdata1->rdclass == dns_rdataclass_in);
  116     REQUIRE(rdata1->length == 16);
  117     REQUIRE(rdata2->length == 16);
  118 
  119     dns_rdata_toregion(rdata1, &r1);
  120     dns_rdata_toregion(rdata2, &r2);
  121     return (isc_region_compare(&r1, &r2));
  122 }
  123 
  124 static inline isc_result_t
  125 fromstruct_in_aaaa(ARGS_FROMSTRUCT) {
  126     dns_rdata_in_aaaa_t *aaaa;
  127 
  128     REQUIRE(type == dns_rdatatype_aaaa);
  129     REQUIRE(rdclass == dns_rdataclass_in);
  130     REQUIRE(((dns_rdata_in_aaaa_t *)source) != NULL);
  131     REQUIRE(((dns_rdata_in_aaaa_t *)source)->common.rdtype == type);
  132     REQUIRE(((dns_rdata_in_aaaa_t *)source)->common.rdclass == rdclass);
  133 
  134     aaaa = source;
  135 
  136     UNUSED(type);
  137     UNUSED(rdclass);
  138 
  139     return (mem_tobuffer(target, aaaa->in6_addr.s6_addr, 16));
  140 }
  141 
  142 static inline isc_result_t
  143 tostruct_in_aaaa(ARGS_TOSTRUCT) {
  144     dns_rdata_in_aaaa_t *aaaa;
  145     isc_region_t r;
  146 
  147     REQUIRE(((dns_rdata_in_aaaa_t *)target) != NULL);
  148     REQUIRE(rdata->type == dns_rdatatype_aaaa);
  149     REQUIRE(rdata->rdclass == dns_rdataclass_in);
  150     REQUIRE(rdata->length == 16);
  151 
  152     aaaa = target;
  153 
  154     UNUSED(mctx);
  155 
  156     aaaa->common.rdclass = rdata->rdclass;
  157     aaaa->common.rdtype = rdata->type;
  158     ISC_LINK_INIT(&aaaa->common, link);
  159 
  160     dns_rdata_toregion(rdata, &r);
  161     INSIST(r.length == 16);
  162     memmove(aaaa->in6_addr.s6_addr, r.base, 16);
  163 
  164     return (ISC_R_SUCCESS);
  165 }
  166 
  167 static inline void
  168 freestruct_in_aaaa(ARGS_FREESTRUCT) {
  169     dns_rdata_in_aaaa_t *aaaa;
  170 
  171     REQUIRE(((dns_rdata_in_aaaa_t *)source) != NULL);
  172     REQUIRE(((dns_rdata_in_aaaa_t *)source)->common.rdtype ==
  173         dns_rdatatype_aaaa);
  174     REQUIRE(((dns_rdata_in_aaaa_t *)source)->common.rdclass ==
  175         dns_rdataclass_in);
  176 
  177     aaaa = source;
  178 
  179     UNUSED(aaaa);
  180 }
  181 
  182 static inline isc_result_t
  183 additionaldata_in_aaaa(ARGS_ADDLDATA) {
  184     REQUIRE(rdata->type == dns_rdatatype_aaaa);
  185     REQUIRE(rdata->rdclass == dns_rdataclass_in);
  186 
  187     UNUSED(rdata);
  188     UNUSED(add);
  189     UNUSED(arg);
  190 
  191     return (ISC_R_SUCCESS);
  192 }
  193 
  194 static inline isc_result_t
  195 digest_in_aaaa(ARGS_DIGEST) {
  196     isc_region_t r;
  197 
  198     REQUIRE(rdata->type == dns_rdatatype_aaaa);
  199     REQUIRE(rdata->rdclass == dns_rdataclass_in);
  200 
  201     dns_rdata_toregion(rdata, &r);
  202 
  203     return ((digest)(arg, &r));
  204 }
  205 
  206 static inline bool
  207 checkowner_in_aaaa(ARGS_CHECKOWNER) {
  208     dns_name_t prefix, suffix;
  209 
  210     REQUIRE(type == dns_rdatatype_aaaa);
  211     REQUIRE(rdclass == dns_rdataclass_in);
  212 
  213     UNUSED(type);
  214     UNUSED(rdclass);
  215 
  216     /*
  217      * Handle Active Directory gc._msdcs.<forest> name.
  218      */
  219     if (dns_name_countlabels(name) > 2U) {
  220         dns_name_init(&prefix, NULL);
  221         dns_name_init(&suffix, NULL);
  222         dns_name_split(name, dns_name_countlabels(name) - 2,
  223                    &prefix, &suffix);
  224         if (dns_name_equal(&gc_msdcs, &prefix) &&
  225             dns_name_ishostname(&suffix, false))
  226             return (true);
  227     }
  228 
  229     return (dns_name_ishostname(name, wildcard));
  230 }
  231 
  232 static inline bool
  233 checknames_in_aaaa(ARGS_CHECKNAMES) {
  234 
  235     REQUIRE(rdata->type == dns_rdatatype_aaaa);
  236     REQUIRE(rdata->rdclass == dns_rdataclass_in);
  237 
  238     UNUSED(rdata);
  239     UNUSED(owner);
  240     UNUSED(bad);
  241 
  242     return (true);
  243 }
  244 
  245 static inline int
  246 casecompare_in_aaaa(ARGS_COMPARE) {
  247     return (compare_in_aaaa(rdata1, rdata2));
  248 }
  249 #endif  /* RDATA_IN_1_AAAA_28_C */