hinfo_13.c revision 1.2
1/* 2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 10 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 14 * PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17/* $Id: hinfo_13.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ 18 19/* 20 * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley. 21 */ 22 23#ifndef RDATA_GENERIC_HINFO_13_C 24#define RDATA_GENERIC_HINFO_13_C 25 26#define RRTYPE_HINFO_ATTRIBUTES (0) 27 28static inline isc_result_t 29totext_hinfo(ARGS_TOTEXT) { 30 isc_region_t region; 31 32 UNUSED(tctx); 33 34 REQUIRE(rdata->type == dns_rdatatype_hinfo); 35 REQUIRE(rdata->length != 0); 36 37 dns_rdata_toregion(rdata, ®ion); 38 RETERR(txt_totext(®ion, ISC_TRUE, target)); 39 RETERR(str_totext(" ", target)); 40 return (txt_totext(®ion, ISC_TRUE, target)); 41} 42 43static inline isc_result_t 44fromwire_hinfo(ARGS_FROMWIRE) { 45 46 REQUIRE(type == dns_rdatatype_hinfo); 47 48 UNUSED(type); 49 UNUSED(dctx); 50 UNUSED(rdclass); 51 UNUSED(options); 52 53 RETERR(txt_fromwire(source, target)); 54 return (txt_fromwire(source, target)); 55} 56 57static inline isc_result_t 58towire_hinfo(ARGS_TOWIRE) { 59 60 UNUSED(cctx); 61 62 REQUIRE(rdata->type == dns_rdatatype_hinfo); 63 REQUIRE(rdata->length != 0); 64 65 return (mem_tobuffer(target, rdata->data, rdata->length)); 66} 67 68static inline int 69compare_hinfo(ARGS_COMPARE) { 70 isc_region_t r1; 71 isc_region_t r2; 72 73 REQUIRE(rdata1->type == rdata2->type); 74 REQUIRE(rdata1->rdclass == rdata2->rdclass); 75 REQUIRE(rdata1->type == dns_rdatatype_hinfo); 76 REQUIRE(rdata1->length != 0); 77 REQUIRE(rdata2->length != 0); 78 79 dns_rdata_toregion(rdata1, &r1); 80 dns_rdata_toregion(rdata2, &r2); 81 return (isc_region_compare(&r1, &r2)); 82} 83 84static inline isc_result_t 85fromstruct_hinfo(ARGS_FROMSTRUCT) { 86 dns_rdata_hinfo_t *hinfo = source; 87 88 REQUIRE(type == dns_rdatatype_hinfo); 89 REQUIRE(source != NULL); 90 REQUIRE(hinfo->common.rdtype == type); 91 REQUIRE(hinfo->common.rdclass == rdclass); 92 93 UNUSED(type); 94 UNUSED(rdclass); 95 96 RETERR(uint8_tobuffer(hinfo->cpu_len, target)); 97 RETERR(mem_tobuffer(target, hinfo->cpu, hinfo->cpu_len)); 98 RETERR(uint8_tobuffer(hinfo->os_len, target)); 99 return (mem_tobuffer(target, hinfo->os, hinfo->os_len)); 100} 101 102static inline isc_result_t 103tostruct_hinfo(ARGS_TOSTRUCT) { 104 dns_rdata_hinfo_t *hinfo = target; 105 isc_region_t region; 106 107 REQUIRE(rdata->type == dns_rdatatype_hinfo); 108 REQUIRE(target != NULL); 109 REQUIRE(rdata->length != 0); 110 111 hinfo->common.rdclass = rdata->rdclass; 112 hinfo->common.rdtype = rdata->type; 113 ISC_LINK_INIT(&hinfo->common, link); 114 115 dns_rdata_toregion(rdata, ®ion); 116 hinfo->cpu_len = uint8_fromregion(®ion); 117 isc_region_consume(®ion, 1); 118 hinfo->cpu = mem_maybedup(region.base, hinfo->cpu_len); 119 if (hinfo->cpu == NULL) 120 return (ISC_R_NOMEMORY); 121 isc_region_consume(®ion, hinfo->cpu_len); 122 123 hinfo->os_len = uint8_fromregion(®ion); 124 isc_region_consume(®ion, 1); 125 hinfo->os = mem_maybedup(region.base, hinfo->os_len); 126 if (hinfo->os == NULL) 127 goto cleanup; 128 129 return (ISC_R_SUCCESS); 130 131 cleanup: 132 free(hinfo->cpu); 133 return (ISC_R_NOMEMORY); 134} 135 136static inline void 137freestruct_hinfo(ARGS_FREESTRUCT) { 138 dns_rdata_hinfo_t *hinfo = source; 139 140 REQUIRE(source != NULL); 141 142 free(hinfo->cpu); 143 free(hinfo->os); 144} 145 146static inline isc_result_t 147additionaldata_hinfo(ARGS_ADDLDATA) { 148 REQUIRE(rdata->type == dns_rdatatype_hinfo); 149 150 UNUSED(add); 151 UNUSED(arg); 152 UNUSED(rdata); 153 154 return (ISC_R_SUCCESS); 155} 156 157static inline isc_result_t 158digest_hinfo(ARGS_DIGEST) { 159 isc_region_t r; 160 161 REQUIRE(rdata->type == dns_rdatatype_hinfo); 162 163 dns_rdata_toregion(rdata, &r); 164 165 return ((digest)(arg, &r)); 166} 167 168static inline isc_boolean_t 169checkowner_hinfo(ARGS_CHECKOWNER) { 170 171 REQUIRE(type == dns_rdatatype_hinfo); 172 173 UNUSED(name); 174 UNUSED(type); 175 UNUSED(rdclass); 176 UNUSED(wildcard); 177 178 return (ISC_TRUE); 179} 180 181static inline isc_boolean_t 182checknames_hinfo(ARGS_CHECKNAMES) { 183 184 REQUIRE(rdata->type == dns_rdatatype_hinfo); 185 186 UNUSED(rdata); 187 UNUSED(owner); 188 UNUSED(bad); 189 190 return (ISC_TRUE); 191} 192 193static inline int 194casecompare_hinfo(ARGS_COMPARE) { 195 return (compare_hinfo(rdata1, rdata2)); 196} 197#endif /* RDATA_GENERIC_HINFO_13_C */ 198