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_RDATATYPE_H
15 #define DNS_RDATATYPE_H 1
16 
17 /*! \file dns/rdatatype.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_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source);
27 /*%<
28  * Convert the text 'source' refers to into a DNS rdata type.
29  *
30  * Requires:
31  *\li	'typep' 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			type is unknown
38  */
39 
40 isc_result_t
41 dns_rdatatype_totext(dns_rdatatype_t type, isc_buffer_t *target);
42 /*%<
43  * Put a textual representation of type 'type' into 'target'.
44  *
45  * Requires:
46  *\li	'type' is a valid type.
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_rdatatype_tounknowntext(dns_rdatatype_t type, isc_buffer_t *target);
61 /*%<
62  * Put textual RFC3597 TYPEXXXX representation of type 'type' into
63  * 'target'.
64  *
65  * Requires:
66  *\li	'type' is a valid type.
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_rdatatype_format(dns_rdatatype_t rdtype, char *array, unsigned int size);
81 /*%<
82  * Format a human-readable representation of the type 'rdtype'
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_RDATATYPE_FORMATSIZE sizeof("NSEC3PARAM")
88 
89 /*%<
90  * Minimum size of array to pass to dns_rdatatype_format().
91  * May need to be adjusted if a new RR type with a very long
92  * name is defined.
93  */
94 
95 ISC_LANG_ENDDECLS
96 
97 #endif /* DNS_RDATATYPE_H */
98