hinfo_13.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004, 2007, 2009, 2014  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1998-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: hinfo_13.c,v 1.46 2009/12/04 22:06:37 tbox Exp $ */
00019 
00020 /*
00021  * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley.
00022  */
00023 
00024 #ifndef RDATA_GENERIC_HINFO_13_C
00025 #define RDATA_GENERIC_HINFO_13_C
00026 
00027 #define RRTYPE_HINFO_ATTRIBUTES (0)
00028 
00029 static inline isc_result_t
00030 fromtext_hinfo(ARGS_FROMTEXT) {
00031         isc_token_t token;
00032         int i;
00033 
00034         UNUSED(type);
00035         UNUSED(rdclass);
00036         UNUSED(origin);
00037         UNUSED(options);
00038         UNUSED(callbacks);
00039 
00040         REQUIRE(type == 13);
00041 
00042         for (i = 0; i < 2; i++) {
00043                 RETERR(isc_lex_getmastertoken(lexer, &token,
00044                                               isc_tokentype_qstring,
00045                                               ISC_FALSE));
00046                 RETTOK(txt_fromtext(&token.value.as_textregion, target));
00047         }
00048         return (ISC_R_SUCCESS);
00049 }
00050 
00051 static inline isc_result_t
00052 totext_hinfo(ARGS_TOTEXT) {
00053         isc_region_t region;
00054 
00055         UNUSED(tctx);
00056 
00057         REQUIRE(rdata->type == 13);
00058         REQUIRE(rdata->length != 0);
00059 
00060         dns_rdata_toregion(rdata, &region);
00061         RETERR(txt_totext(&region, ISC_TRUE, target));
00062         RETERR(str_totext(" ", target));
00063         return (txt_totext(&region, ISC_TRUE, target));
00064 }
00065 
00066 static inline isc_result_t
00067 fromwire_hinfo(ARGS_FROMWIRE) {
00068 
00069         REQUIRE(type == 13);
00070 
00071         UNUSED(type);
00072         UNUSED(dctx);
00073         UNUSED(rdclass);
00074         UNUSED(options);
00075 
00076         RETERR(txt_fromwire(source, target));
00077         return (txt_fromwire(source, target));
00078 }
00079 
00080 static inline isc_result_t
00081 towire_hinfo(ARGS_TOWIRE) {
00082 
00083         UNUSED(cctx);
00084 
00085         REQUIRE(rdata->type == 13);
00086         REQUIRE(rdata->length != 0);
00087 
00088         return (mem_tobuffer(target, rdata->data, rdata->length));
00089 }
00090 
00091 static inline int
00092 compare_hinfo(ARGS_COMPARE) {
00093         isc_region_t r1;
00094         isc_region_t r2;
00095 
00096         REQUIRE(rdata1->type == rdata2->type);
00097         REQUIRE(rdata1->rdclass == rdata2->rdclass);
00098         REQUIRE(rdata1->type == 13);
00099         REQUIRE(rdata1->length != 0);
00100         REQUIRE(rdata2->length != 0);
00101 
00102         dns_rdata_toregion(rdata1, &r1);
00103         dns_rdata_toregion(rdata2, &r2);
00104         return (isc_region_compare(&r1, &r2));
00105 }
00106 
00107 static inline isc_result_t
00108 fromstruct_hinfo(ARGS_FROMSTRUCT) {
00109         dns_rdata_hinfo_t *hinfo = source;
00110 
00111         REQUIRE(type == 13);
00112         REQUIRE(source != NULL);
00113         REQUIRE(hinfo->common.rdtype == type);
00114         REQUIRE(hinfo->common.rdclass == rdclass);
00115 
00116         UNUSED(type);
00117         UNUSED(rdclass);
00118 
00119         RETERR(uint8_tobuffer(hinfo->cpu_len, target));
00120         RETERR(mem_tobuffer(target, hinfo->cpu, hinfo->cpu_len));
00121         RETERR(uint8_tobuffer(hinfo->os_len, target));
00122         return (mem_tobuffer(target, hinfo->os, hinfo->os_len));
00123 }
00124 
00125 static inline isc_result_t
00126 tostruct_hinfo(ARGS_TOSTRUCT) {
00127         dns_rdata_hinfo_t *hinfo = target;
00128         isc_region_t region;
00129 
00130         REQUIRE(rdata->type == 13);
00131         REQUIRE(target != NULL);
00132         REQUIRE(rdata->length != 0);
00133 
00134         hinfo->common.rdclass = rdata->rdclass;
00135         hinfo->common.rdtype = rdata->type;
00136         ISC_LINK_INIT(&hinfo->common, link);
00137 
00138         dns_rdata_toregion(rdata, &region);
00139         hinfo->cpu_len = uint8_fromregion(&region);
00140         isc_region_consume(&region, 1);
00141         hinfo->cpu = mem_maybedup(mctx, region.base, hinfo->cpu_len);
00142         if (hinfo->cpu == NULL)
00143                 return (ISC_R_NOMEMORY);
00144         isc_region_consume(&region, hinfo->cpu_len);
00145 
00146         hinfo->os_len = uint8_fromregion(&region);
00147         isc_region_consume(&region, 1);
00148         hinfo->os = mem_maybedup(mctx, region.base, hinfo->os_len);
00149         if (hinfo->os == NULL)
00150                 goto cleanup;
00151 
00152         hinfo->mctx = mctx;
00153         return (ISC_R_SUCCESS);
00154 
00155  cleanup:
00156         if (mctx != NULL && hinfo->cpu != NULL)
00157                 isc_mem_free(mctx, hinfo->cpu);
00158         return (ISC_R_NOMEMORY);
00159 }
00160 
00161 static inline void
00162 freestruct_hinfo(ARGS_FREESTRUCT) {
00163         dns_rdata_hinfo_t *hinfo = source;
00164 
00165         REQUIRE(source != NULL);
00166 
00167         if (hinfo->mctx == NULL)
00168                 return;
00169 
00170         if (hinfo->cpu != NULL)
00171                 isc_mem_free(hinfo->mctx, hinfo->cpu);
00172         if (hinfo->os != NULL)
00173                 isc_mem_free(hinfo->mctx, hinfo->os);
00174         hinfo->mctx = NULL;
00175 }
00176 
00177 static inline isc_result_t
00178 additionaldata_hinfo(ARGS_ADDLDATA) {
00179         REQUIRE(rdata->type == 13);
00180 
00181         UNUSED(add);
00182         UNUSED(arg);
00183         UNUSED(rdata);
00184 
00185         return (ISC_R_SUCCESS);
00186 }
00187 
00188 static inline isc_result_t
00189 digest_hinfo(ARGS_DIGEST) {
00190         isc_region_t r;
00191 
00192         REQUIRE(rdata->type == 13);
00193 
00194         dns_rdata_toregion(rdata, &r);
00195 
00196         return ((digest)(arg, &r));
00197 }
00198 
00199 static inline isc_boolean_t
00200 checkowner_hinfo(ARGS_CHECKOWNER) {
00201 
00202         REQUIRE(type == 13);
00203 
00204         UNUSED(name);
00205         UNUSED(type);
00206         UNUSED(rdclass);
00207         UNUSED(wildcard);
00208 
00209         return (ISC_TRUE);
00210 }
00211 
00212 static inline isc_boolean_t
00213 checknames_hinfo(ARGS_CHECKNAMES) {
00214 
00215         REQUIRE(rdata->type == 13);
00216 
00217         UNUSED(rdata);
00218         UNUSED(owner);
00219         UNUSED(bad);
00220 
00221         return (ISC_TRUE);
00222 }
00223 
00224 static inline int
00225 casecompare_hinfo(ARGS_COMPARE) {
00226         return (compare_hinfo(rdata1, rdata2));
00227 }
00228 #endif  /* RDATA_GENERIC_HINFO_13_C */

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