a_1.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004, 2007, 2009, 2014  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1999-2002  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id: a_1.c,v 1.33 2009/12/04 22:06:37 tbox Exp $ */
00019 
00020 /* reviewed: Thu Mar 16 15:58:36 PST 2000 by brister */
00021 
00022 #ifndef RDATA_HS_4_A_1_C
00023 #define RDATA_HS_4_A_1_C
00024 
00025 #include <isc/net.h>
00026 
00027 #define RRTYPE_A_ATTRIBUTES (0)
00028 
00029 static inline isc_result_t
00030 fromtext_hs_a(ARGS_FROMTEXT) {
00031         isc_token_t token;
00032         struct in_addr addr;
00033         isc_region_t region;
00034 
00035         REQUIRE(type == 1);
00036         REQUIRE(rdclass == 4);
00037 
00038         UNUSED(type);
00039         UNUSED(origin);
00040         UNUSED(options);
00041         UNUSED(rdclass);
00042 
00043         RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
00044                                       ISC_FALSE));
00045 
00046         if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1)
00047                 RETTOK(DNS_R_BADDOTTEDQUAD);
00048         isc_buffer_availableregion(target, &region);
00049         if (region.length < 4)
00050                 return (ISC_R_NOSPACE);
00051         memmove(region.base, &addr, 4);
00052         isc_buffer_add(target, 4);
00053         return (ISC_R_SUCCESS);
00054 }
00055 
00056 static inline isc_result_t
00057 totext_hs_a(ARGS_TOTEXT) {
00058         isc_region_t region;
00059 
00060         REQUIRE(rdata->type == 1);
00061         REQUIRE(rdata->rdclass == 4);
00062         REQUIRE(rdata->length == 4);
00063 
00064         UNUSED(tctx);
00065 
00066         dns_rdata_toregion(rdata, &region);
00067         return (inet_totext(AF_INET, &region, target));
00068 }
00069 
00070 static inline isc_result_t
00071 fromwire_hs_a(ARGS_FROMWIRE) {
00072         isc_region_t sregion;
00073         isc_region_t tregion;
00074 
00075         REQUIRE(type == 1);
00076         REQUIRE(rdclass == 4);
00077 
00078         UNUSED(type);
00079         UNUSED(dctx);
00080         UNUSED(options);
00081         UNUSED(rdclass);
00082 
00083         isc_buffer_activeregion(source, &sregion);
00084         isc_buffer_availableregion(target, &tregion);
00085         if (sregion.length < 4)
00086                 return (ISC_R_UNEXPECTEDEND);
00087         if (tregion.length < 4)
00088                 return (ISC_R_NOSPACE);
00089 
00090         memmove(tregion.base, sregion.base, 4);
00091         isc_buffer_forward(source, 4);
00092         isc_buffer_add(target, 4);
00093         return (ISC_R_SUCCESS);
00094 }
00095 
00096 static inline isc_result_t
00097 towire_hs_a(ARGS_TOWIRE) {
00098         isc_region_t region;
00099 
00100         REQUIRE(rdata->type == 1);
00101         REQUIRE(rdata->rdclass == 4);
00102         REQUIRE(rdata->length == 4);
00103 
00104         UNUSED(cctx);
00105 
00106         isc_buffer_availableregion(target, &region);
00107         if (region.length < rdata->length)
00108                 return (ISC_R_NOSPACE);
00109         memmove(region.base, rdata->data, rdata->length);
00110         isc_buffer_add(target, 4);
00111         return (ISC_R_SUCCESS);
00112 }
00113 
00114 static inline int
00115 compare_hs_a(ARGS_COMPARE) {
00116         int order;
00117 
00118         REQUIRE(rdata1->type == rdata2->type);
00119         REQUIRE(rdata1->rdclass == rdata2->rdclass);
00120         REQUIRE(rdata1->type == 1);
00121         REQUIRE(rdata1->rdclass == 4);
00122         REQUIRE(rdata1->length == 4);
00123         REQUIRE(rdata2->length == 4);
00124 
00125         order = memcmp(rdata1->data, rdata2->data, 4);
00126         if (order != 0)
00127                 order = (order < 0) ? -1 : 1;
00128 
00129         return (order);
00130 }
00131 
00132 static inline isc_result_t
00133 fromstruct_hs_a(ARGS_FROMSTRUCT) {
00134         dns_rdata_hs_a_t *a = source;
00135         isc_uint32_t n;
00136 
00137         REQUIRE(type == 1);
00138         REQUIRE(rdclass == 4);
00139         REQUIRE(source != NULL);
00140         REQUIRE(a->common.rdtype == type);
00141         REQUIRE(a->common.rdclass == rdclass);
00142 
00143         UNUSED(type);
00144         UNUSED(rdclass);
00145 
00146         n = ntohl(a->in_addr.s_addr);
00147 
00148         return (uint32_tobuffer(n, target));
00149 }
00150 
00151 static inline isc_result_t
00152 tostruct_hs_a(ARGS_TOSTRUCT) {
00153         dns_rdata_hs_a_t *a = target;
00154         isc_uint32_t n;
00155         isc_region_t region;
00156 
00157         REQUIRE(rdata->type == 1);
00158         REQUIRE(rdata->rdclass == 4);
00159         REQUIRE(rdata->length == 4);
00160 
00161         UNUSED(mctx);
00162 
00163         a->common.rdclass = rdata->rdclass;
00164         a->common.rdtype = rdata->type;
00165         ISC_LINK_INIT(&a->common, link);
00166 
00167         dns_rdata_toregion(rdata, &region);
00168         n = uint32_fromregion(&region);
00169         a->in_addr.s_addr = htonl(n);
00170 
00171         return (ISC_R_SUCCESS);
00172 }
00173 
00174 static inline void
00175 freestruct_hs_a(ARGS_FREESTRUCT) {
00176         UNUSED(source);
00177 
00178         REQUIRE(source != NULL);
00179 }
00180 
00181 static inline isc_result_t
00182 additionaldata_hs_a(ARGS_ADDLDATA) {
00183         REQUIRE(rdata->type == 1);
00184         REQUIRE(rdata->rdclass == 4);
00185 
00186         UNUSED(rdata);
00187         UNUSED(add);
00188         UNUSED(arg);
00189 
00190         return (ISC_R_SUCCESS);
00191 }
00192 
00193 static inline isc_result_t
00194 digest_hs_a(ARGS_DIGEST) {
00195         isc_region_t r;
00196 
00197         REQUIRE(rdata->type == 1);
00198         REQUIRE(rdata->rdclass == 4);
00199 
00200         dns_rdata_toregion(rdata, &r);
00201 
00202         return ((digest)(arg, &r));
00203 }
00204 
00205 static inline isc_boolean_t
00206 checkowner_hs_a(ARGS_CHECKOWNER) {
00207 
00208         REQUIRE(type == 1);
00209         REQUIRE(rdclass == 4);
00210 
00211         UNUSED(name);
00212         UNUSED(type);
00213         UNUSED(rdclass);
00214         UNUSED(wildcard);
00215 
00216         return (ISC_TRUE);
00217 }
00218 
00219 static inline isc_boolean_t
00220 checknames_hs_a(ARGS_CHECKNAMES) {
00221 
00222         REQUIRE(rdata->type == 1);
00223         REQUIRE(rdata->rdclass == 4);
00224 
00225         UNUSED(rdata);
00226         UNUSED(owner);
00227         UNUSED(bad);
00228 
00229         return (ISC_TRUE);
00230 }
00231 
00232 static inline int
00233 casecompare_hs_a(ARGS_COMPARE) {
00234         return (compare_hs_a(rdata1, rdata2));
00235 }
00236 
00237 #endif  /* RDATA_HS_4_A_1_C */

Generated on Tue Apr 28 17:40:59 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha