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