1 /* $NetBSD: rdatatype.h,v 1.5 2022/09/23 12:15:30 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16 #ifndef DNS_RDATATYPE_H 17 #define DNS_RDATATYPE_H 1 18 19 /*! \file dns/rdatatype.h */ 20 21 #include <isc/lang.h> 22 23 #include <dns/types.h> 24 25 ISC_LANG_BEGINDECLS 26 27 isc_result_t 28 dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source); 29 /*%< 30 * Convert the text 'source' refers to into a DNS rdata type. 31 * 32 * Requires: 33 *\li 'typep' is a valid pointer. 34 * 35 *\li 'source' is a valid text region. 36 * 37 * Returns: 38 *\li ISC_R_SUCCESS on success 39 *\li DNS_R_UNKNOWN type is unknown 40 */ 41 42 isc_result_t 43 dns_rdatatype_totext(dns_rdatatype_t type, isc_buffer_t *target); 44 /*%< 45 * Put a textual representation of type 'type' into 'target'. 46 * 47 * Requires: 48 *\li 'type' is a valid type. 49 * 50 *\li 'target' is a valid text buffer. 51 * 52 * Ensures, 53 * if the result is success: 54 *\li The used space in 'target' is updated. 55 * 56 * Returns: 57 *\li #ISC_R_SUCCESS on success 58 *\li #ISC_R_NOSPACE target buffer is too small 59 */ 60 61 isc_result_t 62 dns_rdatatype_tounknowntext(dns_rdatatype_t type, isc_buffer_t *target); 63 /*%< 64 * Put textual RFC3597 TYPEXXXX representation of type 'type' into 65 * 'target'. 66 * 67 * Requires: 68 *\li 'type' is a valid type. 69 * 70 *\li 'target' is a valid text buffer. 71 * 72 * Ensures, 73 * if the result is success: 74 *\li The used space in 'target' is updated. 75 * 76 * Returns: 77 *\li #ISC_R_SUCCESS on success 78 *\li #ISC_R_NOSPACE target buffer is too small 79 */ 80 81 void 82 dns_rdatatype_format(dns_rdatatype_t rdtype, char *array, unsigned int size); 83 /*%< 84 * Format a human-readable representation of the type 'rdtype' 85 * into the character array 'array', which is of size 'size'. 86 * The resulting string is guaranteed to be null-terminated. 87 */ 88 89 #define DNS_RDATATYPE_FORMATSIZE sizeof("NSEC3PARAM") 90 91 /*%< 92 * Minimum size of array to pass to dns_rdatatype_format(). 93 * May need to be adjusted if a new RR type with a very long 94 * name is defined. 95 */ 96 97 ISC_LANG_ENDDECLS 98 99 #endif /* DNS_RDATATYPE_H */ 100