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 https://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 
13 #ifndef DNS_DBTABLE_H
14 #define DNS_DBTABLE_H 1
15 
16 /*****
17  ***** Module Info
18  *****/
19 
20 /*! \file dns/dbtable.h
21  * \brief
22  * DNS DB Tables
23  *
24  * XXX TBS XXX
25  *
26  * MP:
27  *\li	The module ensures appropriate synchronization of data structures it
28  *	creates and manipulates.
29  *
30  * Reliability:
31  *\li	No anticipated impact.
32  *
33  * Resources:
34  *\li	None.
35  *
36  * Security:
37  *\li	No anticipated impact.
38  *
39  * Standards:
40  *\li	None.
41  */
42 
43 #include <isc/lang.h>
44 
45 #include <dns/types.h>
46 
47 #define DNS_DBTABLEFIND_NOEXACT		0x01
48 
49 ISC_LANG_BEGINDECLS
50 
51 isc_result_t
52 dns_dbtable_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
53 		   dns_dbtable_t **dbtablep);
54 /*%<
55  * Make a new dbtable of class 'rdclass'
56  *
57  * Requires:
58  *\li	mctx != NULL
59  * \li	dbtablep != NULL && *dptablep == NULL
60  *\li	'rdclass' is a valid class
61  *
62  * Returns:
63  *\li	#ISC_R_SUCCESS
64  *\li	#ISC_R_NOMEMORY
65  *\li	#ISC_R_UNEXPECTED
66  */
67 
68 void
69 dns_dbtable_attach(dns_dbtable_t *source, dns_dbtable_t **targetp);
70 /*%<
71  * Attach '*targetp' to 'source'.
72  *
73  * Requires:
74  *
75  *\li	'source' is a valid dbtable.
76  *
77  *\li	'targetp' points to a NULL dns_dbtable_t *.
78  *
79  * Ensures:
80  *
81  *\li	*targetp is attached to source.
82  */
83 
84 void
85 dns_dbtable_detach(dns_dbtable_t **dbtablep);
86 /*%<
87  * Detach *dbtablep from its dbtable.
88  *
89  * Requires:
90  *
91  *\li	'*dbtablep' points to a valid dbtable.
92  *
93  * Ensures:
94  *
95  *\li	*dbtablep is NULL.
96  *
97  *\li	If '*dbtablep' is the last reference to the dbtable,
98  *		all resources used by the dbtable will be freed
99  */
100 
101 isc_result_t
102 dns_dbtable_add(dns_dbtable_t *dbtable, dns_db_t *db);
103 /*%<
104  * Add 'db' to 'dbtable'.
105  *
106  * Requires:
107  *\li	'dbtable' is a valid dbtable.
108  *
109  *\li	'db' is a valid database with the same class as 'dbtable'
110  */
111 
112 void
113 dns_dbtable_remove(dns_dbtable_t *dbtable, dns_db_t *db);
114 /*%<
115  * Remove 'db' from 'dbtable'.
116  *
117  * Requires:
118  *\li	'db' was previously added to 'dbtable'.
119  */
120 
121 void
122 dns_dbtable_adddefault(dns_dbtable_t *dbtable, dns_db_t *db);
123 /*%<
124  * Use 'db' as the result of a dns_dbtable_find() if no better match is
125  * available.
126  */
127 
128 void
129 dns_dbtable_getdefault(dns_dbtable_t *dbtable, dns_db_t **db);
130 /*%<
131  * Get the 'db' used as the result of a dns_dbtable_find()
132  * if no better match is available.
133  */
134 
135 void
136 dns_dbtable_removedefault(dns_dbtable_t *dbtable);
137 /*%<
138  * Remove the default db from 'dbtable'.
139  */
140 
141 isc_result_t
142 dns_dbtable_find(dns_dbtable_t *dbtable, dns_name_t *name,
143 		 unsigned int options, dns_db_t **dbp);
144 /*%<
145  * Find the deepest match to 'name' in the dbtable, and return it
146  *
147  * Notes:
148  *\li	If the DNS_DBTABLEFIND_NOEXACT option is set, the best partial
149  *	match (if any) to 'name' will be returned.
150  *
151  * Returns:
152  * \li #ISC_R_SUCCESS		on success
153  *\li	     something else:		no default and match
154  */
155 
156 ISC_LANG_ENDDECLS
157 
158 #endif /* DNS_DBTABLE_H */
159