hinfo_13.c revision 1.7
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.7 2020/02/24 17:44:44 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 68 69 70static inline isc_result_t 71tostruct_hinfo(ARGS_TOSTRUCT) { 72 dns_rdata_hinfo_t *hinfo = target; 73 isc_region_t region; 74 75 REQUIRE(rdata->type == dns_rdatatype_hinfo); 76 REQUIRE(target != NULL); 77 REQUIRE(rdata->length != 0); 78 79 hinfo->common.rdclass = rdata->rdclass; 80 hinfo->common.rdtype = rdata->type; 81 ISC_LINK_INIT(&hinfo->common, link); 82 83 dns_rdata_toregion(rdata, ®ion); 84 hinfo->cpu_len = uint8_fromregion(®ion); 85 isc_region_consume(®ion, 1); 86 hinfo->cpu = mem_maybedup(region.base, hinfo->cpu_len); 87 if (hinfo->cpu == NULL) 88 return (ISC_R_NOMEMORY); 89 isc_region_consume(®ion, hinfo->cpu_len); 90 91 hinfo->os_len = uint8_fromregion(®ion); 92 isc_region_consume(®ion, 1); 93 hinfo->os = mem_maybedup(region.base, hinfo->os_len); 94 if (hinfo->os == NULL) 95 goto cleanup; 96 97 return (ISC_R_SUCCESS); 98 99 cleanup: 100 free(hinfo->cpu); 101 return (ISC_R_NOMEMORY); 102} 103 104 105 106#endif /* RDATA_GENERIC_HINFO_13_C */ 107