hinfo_13.c revision 1.1
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.1 2020/02/07 09:58:53 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 29fromtext_hinfo(ARGS_FROMTEXT) { 30 isc_token_t token; 31 int i; 32 33 UNUSED(type); 34 UNUSED(rdclass); 35 UNUSED(origin); 36 UNUSED(options); 37 UNUSED(callbacks); 38 39 REQUIRE(type == dns_rdatatype_hinfo); 40 41 for (i = 0; i < 2; i++) { 42 RETERR(isc_lex_getmastertoken(lexer, &token, 43 isc_tokentype_qstring, 44 ISC_FALSE)); 45 RETTOK(txt_fromtext(&token.value.as_textregion, target)); 46 } 47 return (ISC_R_SUCCESS); 48} 49 50static inline isc_result_t 51totext_hinfo(ARGS_TOTEXT) { 52 isc_region_t region; 53 54 UNUSED(tctx); 55 56 REQUIRE(rdata->type == dns_rdatatype_hinfo); 57 REQUIRE(rdata->length != 0); 58 59 dns_rdata_toregion(rdata, ®ion); 60 RETERR(txt_totext(®ion, ISC_TRUE, target)); 61 RETERR(str_totext(" ", target)); 62 return (txt_totext(®ion, ISC_TRUE, target)); 63} 64 65static inline isc_result_t 66fromwire_hinfo(ARGS_FROMWIRE) { 67 68 REQUIRE(type == dns_rdatatype_hinfo); 69 70 UNUSED(type); 71 UNUSED(dctx); 72 UNUSED(rdclass); 73 UNUSED(options); 74 75 RETERR(txt_fromwire(source, target)); 76 return (txt_fromwire(source, target)); 77} 78 79static inline isc_result_t 80towire_hinfo(ARGS_TOWIRE) { 81 82 UNUSED(cctx); 83 84 REQUIRE(rdata->type == dns_rdatatype_hinfo); 85 REQUIRE(rdata->length != 0); 86 87 return (mem_tobuffer(target, rdata->data, rdata->length)); 88} 89 90static inline int 91compare_hinfo(ARGS_COMPARE) { 92 isc_region_t r1; 93 isc_region_t r2; 94 95 REQUIRE(rdata1->type == rdata2->type); 96 REQUIRE(rdata1->rdclass == rdata2->rdclass); 97 REQUIRE(rdata1->type == dns_rdatatype_hinfo); 98 REQUIRE(rdata1->length != 0); 99 REQUIRE(rdata2->length != 0); 100 101 dns_rdata_toregion(rdata1, &r1); 102 dns_rdata_toregion(rdata2, &r2); 103 return (isc_region_compare(&r1, &r2)); 104} 105 106static inline isc_result_t 107fromstruct_hinfo(ARGS_FROMSTRUCT) { 108 dns_rdata_hinfo_t *hinfo = source; 109 110 REQUIRE(type == dns_rdatatype_hinfo); 111 REQUIRE(source != NULL); 112 REQUIRE(hinfo->common.rdtype == type); 113 REQUIRE(hinfo->common.rdclass == rdclass); 114 115 UNUSED(type); 116 UNUSED(rdclass); 117 118 RETERR(uint8_tobuffer(hinfo->cpu_len, target)); 119 RETERR(mem_tobuffer(target, hinfo->cpu, hinfo->cpu_len)); 120 RETERR(uint8_tobuffer(hinfo->os_len, target)); 121 return (mem_tobuffer(target, hinfo->os, hinfo->os_len)); 122} 123 124static inline isc_result_t 125tostruct_hinfo(ARGS_TOSTRUCT) { 126 dns_rdata_hinfo_t *hinfo = target; 127 isc_region_t region; 128 129 REQUIRE(rdata->type == dns_rdatatype_hinfo); 130 REQUIRE(target != NULL); 131 REQUIRE(rdata->length != 0); 132 133 hinfo->common.rdclass = rdata->rdclass; 134 hinfo->common.rdtype = rdata->type; 135 ISC_LINK_INIT(&hinfo->common, link); 136 137 dns_rdata_toregion(rdata, ®ion); 138 hinfo->cpu_len = uint8_fromregion(®ion); 139 isc_region_consume(®ion, 1); 140 hinfo->cpu = mem_maybedup(region.base, hinfo->cpu_len); 141 if (hinfo->cpu == NULL) 142 return (ISC_R_NOMEMORY); 143 isc_region_consume(®ion, hinfo->cpu_len); 144 145 hinfo->os_len = uint8_fromregion(®ion); 146 isc_region_consume(®ion, 1); 147 hinfo->os = mem_maybedup(region.base, hinfo->os_len); 148 if (hinfo->os == NULL) 149 goto cleanup; 150 151 return (ISC_R_SUCCESS); 152 153 cleanup: 154 free(hinfo->cpu); 155 return (ISC_R_NOMEMORY); 156} 157 158static inline void 159freestruct_hinfo(ARGS_FREESTRUCT) { 160 dns_rdata_hinfo_t *hinfo = source; 161 162 REQUIRE(source != NULL); 163 164 free(hinfo->cpu); 165 free(hinfo->os); 166} 167 168static inline isc_result_t 169additionaldata_hinfo(ARGS_ADDLDATA) { 170 REQUIRE(rdata->type == dns_rdatatype_hinfo); 171 172 UNUSED(add); 173 UNUSED(arg); 174 UNUSED(rdata); 175 176 return (ISC_R_SUCCESS); 177} 178 179static inline isc_result_t 180digest_hinfo(ARGS_DIGEST) { 181 isc_region_t r; 182 183 REQUIRE(rdata->type == dns_rdatatype_hinfo); 184 185 dns_rdata_toregion(rdata, &r); 186 187 return ((digest)(arg, &r)); 188} 189 190static inline isc_boolean_t 191checkowner_hinfo(ARGS_CHECKOWNER) { 192 193 REQUIRE(type == dns_rdatatype_hinfo); 194 195 UNUSED(name); 196 UNUSED(type); 197 UNUSED(rdclass); 198 UNUSED(wildcard); 199 200 return (ISC_TRUE); 201} 202 203static inline isc_boolean_t 204checknames_hinfo(ARGS_CHECKNAMES) { 205 206 REQUIRE(rdata->type == dns_rdatatype_hinfo); 207 208 UNUSED(rdata); 209 UNUSED(owner); 210 UNUSED(bad); 211 212 return (ISC_TRUE); 213} 214 215static inline int 216casecompare_hinfo(ARGS_COMPARE) { 217 return (compare_hinfo(rdata1, rdata2)); 218} 219#endif /* RDATA_GENERIC_HINFO_13_C */ 220