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: aaaa_28.c,v 1.11 2020/09/14 08:39:12 florian Exp $ */ 18 19 /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */ 20 21 /* RFC1886 */ 22 23 #ifndef RDATA_IN_1_AAAA_28_C 24 #define RDATA_IN_1_AAAA_28_C 25 26 static inline isc_result_t 27 totext_in_aaaa(ARGS_TOTEXT) { 28 isc_region_t region; 29 30 UNUSED(tctx); 31 32 REQUIRE(rdata->type == dns_rdatatype_aaaa); 33 REQUIRE(rdata->rdclass == dns_rdataclass_in); 34 REQUIRE(rdata->length == 16); 35 36 dns_rdata_toregion(rdata, ®ion); 37 return (inet_totext(AF_INET6, ®ion, target)); 38 } 39 40 static inline isc_result_t 41 fromwire_in_aaaa(ARGS_FROMWIRE) { 42 isc_region_t sregion; 43 isc_region_t tregion; 44 45 REQUIRE(type == dns_rdatatype_aaaa); 46 REQUIRE(rdclass == dns_rdataclass_in); 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 < 16) 56 return (ISC_R_UNEXPECTEDEND); 57 if (tregion.length < 16) 58 return (ISC_R_NOSPACE); 59 60 memmove(tregion.base, sregion.base, 16); 61 isc_buffer_forward(source, 16); 62 isc_buffer_add(target, 16); 63 return (ISC_R_SUCCESS); 64 } 65 66 static inline isc_result_t 67 towire_in_aaaa(ARGS_TOWIRE) { 68 isc_region_t region; 69 70 UNUSED(cctx); 71 72 REQUIRE(rdata->type == dns_rdatatype_aaaa); 73 REQUIRE(rdata->rdclass == dns_rdataclass_in); 74 REQUIRE(rdata->length == 16); 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, 16); 81 return (ISC_R_SUCCESS); 82 } 83 84 #endif /* RDATA_IN_1_AAAA_28_C */ 85