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