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: a_1.c,v 1.11 2020/09/14 08:39:12 florian Exp $ */ 18 19 /* reviewed: Thu Mar 16 15:58:36 PST 2000 by brister */ 20 21 #ifndef RDATA_HS_4_A_1_C 22 #define RDATA_HS_4_A_1_C 23 24 static inline isc_result_t 25 totext_hs_a(ARGS_TOTEXT) { 26 isc_region_t region; 27 28 REQUIRE(rdata->type == dns_rdatatype_a); 29 REQUIRE(rdata->rdclass == dns_rdataclass_hs); 30 REQUIRE(rdata->length == 4); 31 32 UNUSED(tctx); 33 34 dns_rdata_toregion(rdata, ®ion); 35 return (inet_totext(AF_INET, ®ion, target)); 36 } 37 38 static inline isc_result_t 39 fromwire_hs_a(ARGS_FROMWIRE) { 40 isc_region_t sregion; 41 isc_region_t tregion; 42 43 REQUIRE(type == dns_rdatatype_a); 44 REQUIRE(rdclass == dns_rdataclass_hs); 45 46 UNUSED(type); 47 UNUSED(dctx); 48 UNUSED(options); 49 UNUSED(rdclass); 50 51 isc_buffer_activeregion(source, &sregion); 52 isc_buffer_availableregion(target, &tregion); 53 if (sregion.length < 4) 54 return (ISC_R_UNEXPECTEDEND); 55 if (tregion.length < 4) 56 return (ISC_R_NOSPACE); 57 58 memmove(tregion.base, sregion.base, 4); 59 isc_buffer_forward(source, 4); 60 isc_buffer_add(target, 4); 61 return (ISC_R_SUCCESS); 62 } 63 64 static inline isc_result_t 65 towire_hs_a(ARGS_TOWIRE) { 66 isc_region_t region; 67 68 REQUIRE(rdata->type == dns_rdatatype_a); 69 REQUIRE(rdata->rdclass == dns_rdataclass_hs); 70 REQUIRE(rdata->length == 4); 71 72 UNUSED(cctx); 73 74 isc_buffer_availableregion(target, ®ion); 75 if (region.length < rdata->length) 76 return (ISC_R_NOSPACE); 77 memmove(region.base, rdata->data, rdata->length); 78 isc_buffer_add(target, 4); 79 return (ISC_R_SUCCESS); 80 } 81 82 #endif /* RDATA_HS_4_A_1_C */ 83