2 * Portions Copyright (C) 2005-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
3 * Portions Copyright (C) 1999-2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
19 * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
21 * Permission to use, copy, modify, and distribute this software for any
22 * purpose with or without fee is hereby granted, provided that the
23 * above copyright notice and this permission notice appear in all
26 * THE SOFTWARE IS PROVIDED "AS IS" AND STICHTING NLNET
27 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
29 * STICHTING NLNET BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
30 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
31 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
32 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
33 * USE OR PERFORMANCE OF THIS SOFTWARE.
35 * The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
36 * conceived and contributed by Rob Butler.
38 * Permission to use, copy, modify, and distribute this software for any
39 * purpose with or without fee is hereby granted, provided that the
40 * above copyright notice and this permission notice appear in all
43 * THE SOFTWARE IS PROVIDED "AS IS" AND ROB BUTLER
44 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
46 * ROB BUTLER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
47 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
48 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
49 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
50 * USE OR PERFORMANCE OF THIS SOFTWARE.
53 /* $Id: dlz.h,v 1.7.332.2 2009/01/18 23:47:41 tbox Exp $ */
55 /*! \file dns/dlz.h */
67 * The DLZ interface allows zones to be looked up using a driver instead of
68 * Bind's default in memory zone table.
72 * No anticipated impact.
77 * No anticipated impact.
88 #include <dns/types.h>
99 #define DNS_DLZ_MAGIC ISC_MAGIC('D','L','Z','D')
100 #define DNS_DLZ_VALID(dlz) ISC_MAGIC_VALID(dlz, DNS_DLZ_MAGIC)
103 (*dns_dlzallowzonexfr_t)(void *driverarg, void *dbdata, isc_mem_t *mctx,
104 dns_rdataclass_t rdclass, dns_name_t *name,
105 isc_sockaddr_t *clientaddr,
109 * Method prototype. Drivers implementing the DLZ interface MUST
110 * supply an allow zone transfer method. This method is called when
111 * the DNS server is performing a zone transfer query. The driver's
112 * method should return ISC_R_SUCCESS and a database pointer to the
113 * name server if the zone is supported by the database, and zone
114 * transfer is allowed. Otherwise it will return ISC_R_NOTFOUND if
115 * the zone is not supported by the database, or ISC_R_NOPERM if zone
116 * transfers are not allowed. If an error occurs it should return a
117 * result code indicating the type of error.
121 (*dns_dlzcreate_t)(isc_mem_t *mctx, const char *dlzname, unsigned int argc,
122 char *argv[], void *driverarg, void **dbdata);
125 * Method prototype. Drivers implementing the DLZ interface MUST
126 * supply a create method. This method is called when the DNS server
127 * is starting up and creating drivers for use later.
131 (*dns_dlzdestroy_t)(void *driverarg, void **dbdata);
134 * Method prototype. Drivers implementing the DLZ interface MUST
135 * supply a destroy method. This method is called when the DNS server
136 * is shutting down and no longer needs the driver.
140 (*dns_dlzfindzone_t)(void *driverarg, void *dbdata, isc_mem_t *mctx,
141 dns_rdataclass_t rdclass, dns_name_t *name,
146 * Method prototype. Drivers implementing the DLZ interface MUST
147 * supply a find zone method. This method is called when the DNS
148 * server is performing a query. The find zone method will be called
149 * with the longest possible name first, and continue to be called
150 * with successively shorter domain names, until any of the following
153 * \li 1) a match is found, and the function returns (ISC_R_SUCCESS)
155 * \li 2) a problem occurs, and the functions returns anything other
156 * than (ISC_R_NOTFOUND)
157 * \li 3) we run out of domain name labels. I.E. we have tried the
158 * shortest domain name
159 * \li 4) the number of labels in the domain name is less than
160 * min_labels for dns_dlzfindzone
162 * The driver's find zone method should return ISC_R_SUCCESS and a
163 * database pointer to the name server if the zone is supported by the
164 * database. Otherwise it will return ISC_R_NOTFOUND, and a null
165 * pointer if the zone is not supported. If an error occurs it should
166 * return a result code indicating the type of error.
169 /*% the methods supplied by a DLZ driver */
170 typedef struct dns_dlzmethods {
171 dns_dlzcreate_t create;
172 dns_dlzdestroy_t destroy;
173 dns_dlzfindzone_t findzone;
174 dns_dlzallowzonexfr_t allowzonexfr;
177 /*% information about a DLZ driver */
178 struct dns_dlzimplementation {
180 const dns_dlzmethods_t *methods;
183 ISC_LINK(dns_dlzimplementation_t) link;
186 /*% an instance of a DLZ driver */
190 dns_dlzimplementation_t *implementation;
196 *** Method declarations
200 dns_dlzallowzonexfr(dns_view_t *view, dns_name_t *name,
201 isc_sockaddr_t *clientaddr, dns_db_t **dbp);
204 * This method is called when the DNS server is performing a zone
205 * transfer query. It will call the DLZ driver's allow zone transfer
210 dns_dlzcreate(isc_mem_t *mctx, const char *dlzname,
211 const char *drivername, unsigned int argc,
212 char *argv[], dns_dlzdb_t **dbp);
215 * This method is called when the DNS server is starting up and
216 * creating drivers for use later. It will search the DLZ driver list
217 * for 'drivername' and return a DLZ driver via dbp if a match is
218 * found. If the DLZ driver supplies a create method, this function
223 dns_dlzdestroy(dns_dlzdb_t **dbp);
226 * This method is called when the DNS server is shutting down and no
227 * longer needs the driver. If the DLZ driver supplies a destroy
228 * methods, this function will call it.
232 dns_dlzfindzone(dns_view_t *view, dns_name_t *name,
233 unsigned int minlabels, dns_db_t **dbp);
236 * This method is called when the DNS server is performing a query.
237 * It will call the DLZ driver's find zone method.
241 dns_dlzregister(const char *drivername, const dns_dlzmethods_t *methods,
242 void *driverarg, isc_mem_t *mctx,
243 dns_dlzimplementation_t **dlzimp);
246 * Register a dynamically loadable zones (DLZ) driver for the database
247 * type 'drivername', implemented by the functions in '*methods'.
249 * dlzimp must point to a NULL dlz_implementation_t pointer. That is,
250 * dlzimp != NULL && *dlzimp == NULL. It will be assigned a value that
251 * will later be used to identify the driver when deregistering it.
255 dns_dlzstrtoargv(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp);
258 * This method is called when the name server is starting up to parse
259 * the DLZ driver command line from named.conf. Basically it splits
260 * up a string into and argc / argv. The primary difference of this
261 * method is items between braces { } are considered only 1 word. for
262 * example the command line "this is { one grouped phrase } and this
263 * isn't" would be parsed into:
265 * \li argv[0]: "this"
267 * \li argv{2]: " one grouped phrase "
269 * \li argv[4]: "this"
270 * \li argv{5}: "isn't"
272 * braces should NOT be nested, more than one grouping in the command
273 * line is allowed. Notice, argv[2] has an extra space at the
274 * beginning and end. Extra spaces are not stripped between a
275 * grouping. You can do so in your driver if needed, or be sure not
276 * to put extra spaces before / after the braces.
280 dns_dlzunregister(dns_dlzimplementation_t **dlzimp);
283 * Removes the dlz driver from the list of registered dlz drivers.
284 * There must be no active dlz drivers of this type when this function