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