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.10 2020/02/26 18:38:15 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 #include <isc/net.h> 25 26 static inline isc_result_t 27 totext_hs_a(ARGS_TOTEXT) { 28 isc_region_t region; 29 30 REQUIRE(rdata->type == dns_rdatatype_a); 31 REQUIRE(rdata->rdclass == dns_rdataclass_hs); 32 REQUIRE(rdata->length == 4); 33 34 UNUSED(tctx); 35 36 dns_rdata_toregion(rdata, ®ion); 37 return (inet_totext(AF_INET, ®ion, target)); 38 } 39 40 static inline isc_result_t 41 fromwire_hs_a(ARGS_FROMWIRE) { 42 isc_region_t sregion; 43 isc_region_t tregion; 44 45 REQUIRE(type == dns_rdatatype_a); 46 REQUIRE(rdclass == dns_rdataclass_hs); 47 48 UNUSED(type); 49 UNUSED(dctx); 50 UNUSED(options); 51 UNUSED(rdclass); 52 53 isc_buffer_activeregion(source, &sregion); 54 isc_buffer_availableregion(target, &tregion); 55 if (sregion.length < 4) 56 return (ISC_R_UNEXPECTEDEND); 57 if (tregion.length < 4) 58 return (ISC_R_NOSPACE); 59 60 memmove(tregion.base, sregion.base, 4); 61 isc_buffer_forward(source, 4); 62 isc_buffer_add(target, 4); 63 return (ISC_R_SUCCESS); 64 } 65 66 static inline isc_result_t 67 towire_hs_a(ARGS_TOWIRE) { 68 isc_region_t region; 69 70 REQUIRE(rdata->type == dns_rdatatype_a); 71 REQUIRE(rdata->rdclass == dns_rdataclass_hs); 72 REQUIRE(rdata->length == 4); 73 74 UNUSED(cctx); 75 76 isc_buffer_availableregion(target, ®ion); 77 if (region.length < rdata->length) 78 return (ISC_R_NOSPACE); 79 memmove(region.base, rdata->data, rdata->length); 80 isc_buffer_add(target, 4); 81 return (ISC_R_SUCCESS); 82 } 83 84 #endif /* RDATA_HS_4_A_1_C */ 85