unspec_103.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004, 2007, 2009  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: unspec_103.c,v 1.37 2009/12/04 22:06:37 tbox Exp $ */
00019 
00020 #ifndef RDATA_GENERIC_UNSPEC_103_C
00021 #define RDATA_GENERIC_UNSPEC_103_C
00022 
00023 #define RRTYPE_UNSPEC_ATTRIBUTES (0)
00024 
00025 static inline isc_result_t
00026 fromtext_unspec(ARGS_FROMTEXT) {
00027 
00028         REQUIRE(type == 103);
00029 
00030         UNUSED(type);
00031         UNUSED(rdclass);
00032         UNUSED(origin);
00033         UNUSED(options);
00034         UNUSED(callbacks);
00035 
00036         return (atob_tobuffer(lexer, target));
00037 }
00038 
00039 static inline isc_result_t
00040 totext_unspec(ARGS_TOTEXT) {
00041 
00042         REQUIRE(rdata->type == 103);
00043 
00044         UNUSED(tctx);
00045 
00046         return (btoa_totext(rdata->data, rdata->length, target));
00047 }
00048 
00049 static inline isc_result_t
00050 fromwire_unspec(ARGS_FROMWIRE) {
00051         isc_region_t sr;
00052 
00053         REQUIRE(type == 103);
00054 
00055         UNUSED(type);
00056         UNUSED(rdclass);
00057         UNUSED(dctx);
00058         UNUSED(options);
00059 
00060         isc_buffer_activeregion(source, &sr);
00061         isc_buffer_forward(source, sr.length);
00062         return (mem_tobuffer(target, sr.base, sr.length));
00063 }
00064 
00065 static inline isc_result_t
00066 towire_unspec(ARGS_TOWIRE) {
00067 
00068         REQUIRE(rdata->type == 103);
00069 
00070         UNUSED(cctx);
00071 
00072         return (mem_tobuffer(target, rdata->data, rdata->length));
00073 }
00074 
00075 static inline int
00076 compare_unspec(ARGS_COMPARE) {
00077         isc_region_t r1;
00078         isc_region_t r2;
00079 
00080         REQUIRE(rdata1->type == rdata2->type);
00081         REQUIRE(rdata1->rdclass == rdata2->rdclass);
00082         REQUIRE(rdata1->type == 103);
00083 
00084         dns_rdata_toregion(rdata1, &r1);
00085         dns_rdata_toregion(rdata2, &r2);
00086         return (isc_region_compare(&r1, &r2));
00087 }
00088 
00089 static inline isc_result_t
00090 fromstruct_unspec(ARGS_FROMSTRUCT) {
00091         dns_rdata_unspec_t *unspec = source;
00092 
00093         REQUIRE(type == 103);
00094         REQUIRE(source != NULL);
00095         REQUIRE(unspec->common.rdtype == type);
00096         REQUIRE(unspec->common.rdclass == rdclass);
00097         REQUIRE(unspec->data != NULL || unspec->datalen == 0);
00098 
00099         UNUSED(type);
00100         UNUSED(rdclass);
00101 
00102         return (mem_tobuffer(target, unspec->data, unspec->datalen));
00103 }
00104 
00105 static inline isc_result_t
00106 tostruct_unspec(ARGS_TOSTRUCT) {
00107         dns_rdata_unspec_t *unspec = target;
00108         isc_region_t r;
00109 
00110         REQUIRE(rdata->type == 103);
00111         REQUIRE(target != NULL);
00112 
00113         unspec->common.rdclass = rdata->rdclass;
00114         unspec->common.rdtype = rdata->type;
00115         ISC_LINK_INIT(&unspec->common, link);
00116 
00117         dns_rdata_toregion(rdata, &r);
00118         unspec->datalen = r.length;
00119         unspec->data = mem_maybedup(mctx, r.base, r.length);
00120         if (unspec->data == NULL)
00121                 return (ISC_R_NOMEMORY);
00122 
00123         unspec->mctx = mctx;
00124         return (ISC_R_SUCCESS);
00125 }
00126 
00127 static inline void
00128 freestruct_unspec(ARGS_FREESTRUCT) {
00129         dns_rdata_unspec_t *unspec = source;
00130 
00131         REQUIRE(source != NULL);
00132         REQUIRE(unspec->common.rdtype == 103);
00133 
00134         if (unspec->mctx == NULL)
00135                 return;
00136 
00137         if (unspec->data != NULL)
00138                 isc_mem_free(unspec->mctx, unspec->data);
00139         unspec->mctx = NULL;
00140 }
00141 
00142 static inline isc_result_t
00143 additionaldata_unspec(ARGS_ADDLDATA) {
00144         REQUIRE(rdata->type == 103);
00145 
00146         UNUSED(rdata);
00147         UNUSED(add);
00148         UNUSED(arg);
00149 
00150         return (ISC_R_SUCCESS);
00151 }
00152 
00153 static inline isc_result_t
00154 digest_unspec(ARGS_DIGEST) {
00155         isc_region_t r;
00156 
00157         REQUIRE(rdata->type == 103);
00158 
00159         dns_rdata_toregion(rdata, &r);
00160 
00161         return ((digest)(arg, &r));
00162 }
00163 
00164 static inline isc_boolean_t
00165 checkowner_unspec(ARGS_CHECKOWNER) {
00166 
00167         REQUIRE(type == 103);
00168 
00169         UNUSED(name);
00170         UNUSED(type);
00171         UNUSED(rdclass);
00172         UNUSED(wildcard);
00173 
00174         return (ISC_TRUE);
00175 }
00176 
00177 static inline isc_boolean_t
00178 checknames_unspec(ARGS_CHECKNAMES) {
00179 
00180         REQUIRE(rdata->type == 103);
00181 
00182         UNUSED(rdata);
00183         UNUSED(owner);
00184         UNUSED(bad);
00185 
00186         return (ISC_TRUE);
00187 }
00188 
00189 static inline int
00190 casecompare_unspec(ARGS_COMPARE) {
00191         return (compare_unspec(rdata1, rdata2));
00192 }
00193 
00194 #endif  /* RDATA_GENERIC_UNSPEC_103_C */

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