xref: /minix/external/bsd/bind/dist/lib/dns/include/dns/zt.h (revision bb9622b5)
1 /*	$NetBSD: zt.h,v 1.4 2014/12/10 04:37:58 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2004-2007, 2011  Internet Systems Consortium, Inc. ("ISC")
5  * Copyright (C) 1999-2002  Internet Software Consortium.
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /* Id: zt.h,v 1.40 2011/09/02 23:46:32 tbox Exp  */
21 
22 #ifndef DNS_ZT_H
23 #define DNS_ZT_H 1
24 
25 /*! \file dns/zt.h */
26 
27 #include <isc/lang.h>
28 
29 #include <dns/types.h>
30 
31 #define DNS_ZTFIND_NOEXACT		0x01
32 
33 ISC_LANG_BEGINDECLS
34 
35 typedef isc_result_t
36 (*dns_zt_allloaded_t)(void *arg);
37 /*%<
38  * Method prototype: when all pending zone loads are complete,
39  * the zone table can inform the caller via a callback function with
40  * this signature.
41  */
42 
43 typedef isc_result_t
44 (*dns_zt_zoneloaded_t)(dns_zt_t *zt, dns_zone_t *zone, isc_task_t *task);
45 /*%<
46  * Method prototype: when a zone finishes loading, the zt object
47  * can be informed via a callback function with this signature.
48  */
49 
50 isc_result_t
51 dns_zt_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, dns_zt_t **zt);
52 /*%<
53  * Creates a new zone table.
54  *
55  * Requires:
56  * \li	'mctx' to be initialized.
57  *
58  * Returns:
59  * \li	#ISC_R_SUCCESS on success.
60  * \li	#ISC_R_NOMEMORY
61  */
62 
63 isc_result_t
64 dns_zt_mount(dns_zt_t *zt, dns_zone_t *zone);
65 /*%<
66  * Mounts the zone on the zone table.
67  *
68  * Requires:
69  * \li	'zt' to be valid
70  * \li	'zone' to be valid
71  *
72  * Returns:
73  * \li	#ISC_R_SUCCESS
74  * \li	#ISC_R_EXISTS
75  * \li	#ISC_R_NOSPACE
76  * \li	#ISC_R_NOMEMORY
77  */
78 
79 isc_result_t
80 dns_zt_unmount(dns_zt_t *zt, dns_zone_t *zone);
81 /*%<
82  * Unmount the given zone from the table.
83  *
84  * Requires:
85  * 	'zt' to be valid
86  * \li	'zone' to be valid
87  *
88  * Returns:
89  * \li	#ISC_R_SUCCESS
90  * \li	#ISC_R_NOTFOUND
91  * \li	#ISC_R_NOMEMORY
92  */
93 
94 isc_result_t
95 dns_zt_find(dns_zt_t *zt, dns_name_t *name, unsigned int options,
96 	    dns_name_t *foundname, dns_zone_t **zone);
97 /*%<
98  * Find the best match for 'name' in 'zt'.  If foundname is non NULL
99  * then the name of the zone found is returned.
100  *
101  * Notes:
102  * \li	If the DNS_ZTFIND_NOEXACT is set, the best partial match (if any)
103  *	to 'name' will be returned.
104  *
105  * Requires:
106  * \li	'zt' to be valid
107  * \li	'name' to be valid
108  * \li	'foundname' to be initialized and associated with a fixedname or NULL
109  * \li	'zone' to be non NULL and '*zone' to be NULL
110  *
111  * Returns:
112  * \li	#ISC_R_SUCCESS
113  * \li	#DNS_R_PARTIALMATCH
114  * \li	#ISC_R_NOTFOUND
115  * \li	#ISC_R_NOSPACE
116  */
117 
118 void
119 dns_zt_detach(dns_zt_t **ztp);
120 /*%<
121  * Detach the given zonetable, if the reference count goes to zero the
122  * zonetable will be freed.  In either case 'ztp' is set to NULL.
123  *
124  * Requires:
125  * \li	'*ztp' to be valid
126  */
127 
128 void
129 dns_zt_flushanddetach(dns_zt_t **ztp);
130 /*%<
131  * Detach the given zonetable, if the reference count goes to zero the
132  * zonetable will be flushed and then freed.  In either case 'ztp' is
133  * set to NULL.
134  *
135  * Requires:
136  * \li	'*ztp' to be valid
137  */
138 
139 void
140 dns_zt_attach(dns_zt_t *zt, dns_zt_t **ztp);
141 /*%<
142  * Attach 'zt' to '*ztp'.
143  *
144  * Requires:
145  * \li	'zt' to be valid
146  * \li	'*ztp' to be NULL
147  */
148 
149 isc_result_t
150 dns_zt_load(dns_zt_t *zt, isc_boolean_t stop);
151 
152 isc_result_t
153 dns_zt_loadnew(dns_zt_t *zt, isc_boolean_t stop);
154 
155 isc_result_t
156 dns_zt_asyncload(dns_zt_t *zt, dns_zt_allloaded_t alldone, void *arg);
157 /*%<
158  * Load all zones in the table.  If 'stop' is ISC_TRUE,
159  * stop on the first error and return it.  If 'stop'
160  * is ISC_FALSE, ignore errors.
161  *
162  * dns_zt_loadnew() only loads zones that are not yet loaded.
163  * dns_zt_load() also loads zones that are already loaded and
164  * and whose master file has changed since the last load.
165  * dns_zt_asyncload() loads zones asynchronously; when all
166  * zones in the zone table have finished loaded (or failed due
167  * to errors), the caller is informed by calling 'alldone'
168  * with an argument of 'arg'.
169  *
170  * Requires:
171  * \li	'zt' to be valid
172  */
173 
174 isc_result_t
175 dns_zt_freezezones(dns_zt_t *zt, isc_boolean_t freeze);
176 /*%<
177  * Freeze/thaw updates to master zones.
178  * Any pending updates will be flushed.
179  * Zones will be reloaded on thaw.
180  */
181 
182 isc_result_t
183 dns_zt_apply(dns_zt_t *zt, isc_boolean_t stop,
184 	     isc_result_t (*action)(dns_zone_t *, void *), void *uap);
185 
186 isc_result_t
187 dns_zt_apply2(dns_zt_t *zt, isc_boolean_t stop, isc_result_t *sub,
188 	      isc_result_t (*action)(dns_zone_t *, void *), void *uap);
189 /*%<
190  * Apply a given 'action' to all zone zones in the table.
191  * If 'stop' is 'ISC_TRUE' then walking the zone tree will stop if
192  * 'action' does not return ISC_R_SUCCESS.
193  *
194  * Requires:
195  * \li	'zt' to be valid.
196  * \li	'action' to be non NULL.
197  *
198  * Returns:
199  * \li	ISC_R_SUCCESS if action was applied to all nodes.  If 'stop' is
200  *	ISC_FALSE and 'sub' is non NULL then the first error (if any)
201  *	reported by 'action' is returned in '*sub';
202  *	any error code from 'action'.
203  */
204 
205 isc_boolean_t
206 dns_zt_loadspending(dns_zt_t *zt);
207 /*%<
208  * Returns ISC_TRUE if and only if there are zones still waiting to
209  * be loaded in zone table 'zt'.
210  *
211  * Requires:
212  * \li	'zt' to be valid.
213  */
214 
215 ISC_LANG_ENDDECLS
216 
217 #endif /* DNS_ZT_H */
218