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: minfo_14.c,v 1.12 2020/09/14 08:40:43 florian Exp $ */ 18 19 /* reviewed: Wed Mar 15 17:45:32 PST 2000 by brister */ 20 21 #ifndef RDATA_GENERIC_MINFO_14_C 22 #define RDATA_GENERIC_MINFO_14_C 23 24 static inline isc_result_t 25 totext_minfo(ARGS_TOTEXT) { 26 isc_region_t region; 27 dns_name_t rmail; 28 dns_name_t email; 29 dns_name_t prefix; 30 int sub; 31 32 REQUIRE(rdata->type == dns_rdatatype_minfo); 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 49 RETERR(dns_name_totext(&prefix, sub, target)); 50 51 RETERR(isc_str_tobuffer(" ", target)); 52 53 sub = name_prefix(&email, tctx->origin, &prefix); 54 return (dns_name_totext(&prefix, sub, target)); 55 } 56 57 static inline isc_result_t 58 fromwire_minfo(ARGS_FROMWIRE) { 59 dns_name_t rmail; 60 dns_name_t email; 61 62 REQUIRE(type == dns_rdatatype_minfo); 63 64 UNUSED(type); 65 UNUSED(rdclass); 66 67 dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); 68 69 dns_name_init(&rmail, NULL); 70 dns_name_init(&email, NULL); 71 72 RETERR(dns_name_fromwire(&rmail, source, dctx, options, target)); 73 return (dns_name_fromwire(&email, source, dctx, options, target)); 74 } 75 76 static inline isc_result_t 77 towire_minfo(ARGS_TOWIRE) { 78 isc_region_t region; 79 dns_name_t rmail; 80 dns_name_t email; 81 dns_offsets_t roffsets; 82 dns_offsets_t eoffsets; 83 84 REQUIRE(rdata->type == dns_rdatatype_minfo); 85 REQUIRE(rdata->length != 0); 86 87 dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14); 88 89 dns_name_init(&rmail, roffsets); 90 dns_name_init(&email, eoffsets); 91 92 dns_rdata_toregion(rdata, ®ion); 93 94 dns_name_fromregion(&rmail, ®ion); 95 isc_region_consume(®ion, name_length(&rmail)); 96 97 RETERR(dns_name_towire(&rmail, cctx, target)); 98 99 dns_name_fromregion(&rmail, ®ion); 100 isc_region_consume(®ion, rmail.length); 101 102 return (dns_name_towire(&rmail, cctx, target)); 103 } 104 105 #endif /* RDATA_GENERIC_MINFO_14_C */ 106