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: rp_17.c,v 1.11 2020/02/26 18:47:59 florian Exp $ */ 18 19 /* RFC1183 */ 20 21 #ifndef RDATA_GENERIC_RP_17_C 22 #define RDATA_GENERIC_RP_17_C 23 24 static inline isc_result_t 25 totext_rp(ARGS_TOTEXT) { 26 isc_region_t region; 27 dns_name_t rmail; 28 dns_name_t email; 29 dns_name_t prefix; 30 isc_boolean_t sub; 31 32 REQUIRE(rdata->type == dns_rdatatype_rp); 33 REQUIRE(rdata->length != 0); 34 35 dns_name_init(&rmail, NULL); 36 dns_name_init(&email, NULL); 37 dns_name_init(&prefix, NULL); 38 39 dns_rdata_toregion(rdata, ®ion); 40 41 dns_name_fromregion(&rmail, ®ion); 42 isc_region_consume(®ion, rmail.length); 43 44 dns_name_fromregion(&email, ®ion); 45 isc_region_consume(®ion, email.length); 46 47 sub = name_prefix(&rmail, tctx->origin, &prefix); 48 RETERR(dns_name_totext(&prefix, sub, target)); 49 50 RETERR(isc_str_tobuffer(" ", target)); 51 52 sub = name_prefix(&email, tctx->origin, &prefix); 53 return (dns_name_totext(&prefix, sub, target)); 54 } 55 56 static inline isc_result_t 57 fromwire_rp(ARGS_FROMWIRE) { 58 dns_name_t rmail; 59 dns_name_t email; 60 61 REQUIRE(type == dns_rdatatype_rp); 62 63 UNUSED(type); 64 UNUSED(rdclass); 65 66 dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE); 67 68 dns_name_init(&rmail, NULL); 69 dns_name_init(&email, NULL); 70 71 RETERR(dns_name_fromwire(&rmail, source, dctx, options, target)); 72 return (dns_name_fromwire(&email, source, dctx, options, target)); 73 } 74 75 static inline isc_result_t 76 towire_rp(ARGS_TOWIRE) { 77 isc_region_t region; 78 dns_name_t rmail; 79 dns_name_t email; 80 dns_offsets_t roffsets; 81 dns_offsets_t eoffsets; 82 83 REQUIRE(rdata->type == dns_rdatatype_rp); 84 REQUIRE(rdata->length != 0); 85 86 dns_compress_setmethods(cctx, DNS_COMPRESS_NONE); 87 dns_name_init(&rmail, roffsets); 88 dns_name_init(&email, eoffsets); 89 90 dns_rdata_toregion(rdata, ®ion); 91 92 dns_name_fromregion(&rmail, ®ion); 93 isc_region_consume(®ion, rmail.length); 94 95 RETERR(dns_name_towire(&rmail, cctx, target)); 96 97 dns_name_fromregion(&rmail, ®ion); 98 isc_region_consume(®ion, rmail.length); 99 100 return (dns_name_towire(&rmail, cctx, target)); 101 } 102 103 #endif /* RDATA_GENERIC_RP_17_C */ 104