dlz.h

Go to the documentation of this file.
00001 /*
00002  * Portions Copyright (C) 2005-2007, 2009-2013  Internet Systems Consortium, Inc. ("ISC")
00003  * Portions Copyright (C) 1999-2001  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /*
00019  * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
00020  *
00021  * Permission to use, copy, modify, and distribute this software for any
00022  * purpose with or without fee is hereby granted, provided that the
00023  * above copyright notice and this permission notice appear in all
00024  * copies.
00025  *
00026  * THE SOFTWARE IS PROVIDED "AS IS" AND STICHTING NLNET
00027  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
00029  * STICHTING NLNET BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
00030  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
00031  * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00032  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
00033  * USE OR PERFORMANCE OF THIS SOFTWARE.
00034  *
00035  * The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
00036  * conceived and contributed by Rob Butler.
00037  *
00038  * Permission to use, copy, modify, and distribute this software for any
00039  * purpose with or without fee is hereby granted, provided that the
00040  * above copyright notice and this permission notice appear in all
00041  * copies.
00042  *
00043  * THE SOFTWARE IS PROVIDED "AS IS" AND ROB BUTLER
00044  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
00045  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
00046  * ROB BUTLER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
00047  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
00048  * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00049  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
00050  * USE OR PERFORMANCE OF THIS SOFTWARE.
00051  */
00052 
00053 /* $Id$ */
00054 
00055 /*! \file dns/dlz.h */
00056 
00057 #ifndef DLZ_H
00058 #define DLZ_H 1
00059 
00060 /*****
00061  ***** Module Info
00062  *****/
00063 
00064 /*
00065  * DLZ Interface
00066  *
00067  * The DLZ interface allows zones to be looked up using a driver instead of
00068  * Bind's default in memory zone table.
00069  *
00070  *
00071  * Reliability:
00072  *      No anticipated impact.
00073  *
00074  * Resources:
00075  *
00076  * Security:
00077  *      No anticipated impact.
00078  *
00079  * Standards:
00080  *      None.
00081  */
00082 
00083 /*****
00084  ***** Imports
00085  *****/
00086 
00087 #include <dns/clientinfo.h>
00088 #include <dns/name.h>
00089 #include <dns/types.h>
00090 #include <dns/view.h>
00091 #include <dst/dst.h>
00092 
00093 #include <isc/lang.h>
00094 
00095 ISC_LANG_BEGINDECLS
00096 
00097 /***
00098  *** Types
00099  ***/
00100 
00101 #define DNS_DLZ_MAGIC           ISC_MAGIC('D','L','Z','D')
00102 #define DNS_DLZ_VALID(dlz)      ISC_MAGIC_VALID(dlz, DNS_DLZ_MAGIC)
00103 
00104 typedef isc_result_t
00105 (*dns_dlzallowzonexfr_t)(void *driverarg, void *dbdata, isc_mem_t *mctx,
00106                          dns_rdataclass_t rdclass, dns_name_t *name,
00107                          isc_sockaddr_t *clientaddr,
00108                          dns_db_t **dbp);
00109 
00110 /*%<
00111  * Method prototype.  Drivers implementing the DLZ interface MUST
00112  * supply an allow zone transfer method.  This method is called when
00113  * the DNS server is performing a zone transfer query.  The driver's
00114  * method should return ISC_R_SUCCESS and a database pointer to the
00115  * name server if the zone is supported by the database, and zone
00116  * transfer is allowed.  Otherwise it will return ISC_R_NOTFOUND if
00117  * the zone is not supported by the database, or ISC_R_NOPERM if zone
00118  * transfers are not allowed.  If an error occurs it should return a
00119  * result code indicating the type of error.
00120  */
00121 
00122 typedef isc_result_t
00123 (*dns_dlzcreate_t)(isc_mem_t *mctx, const char *dlzname, unsigned int argc,
00124                    char *argv[], void *driverarg, void **dbdata);
00125 
00126 /*%<
00127  * Method prototype.  Drivers implementing the DLZ interface MUST
00128  * supply a create method.  This method is called when the DNS server
00129  * is starting up and creating drivers for use later.
00130  */
00131 
00132 typedef void
00133 (*dns_dlzdestroy_t)(void *driverarg, void **dbdata);
00134 
00135 /*%<
00136  * Method prototype.  Drivers implementing the DLZ interface MUST
00137  * supply a destroy method.  This method is called when the DNS server
00138  * is shutting down and no longer needs the driver.
00139  */
00140 
00141 typedef isc_result_t
00142 (*dns_dlzfindzone_t)(void *driverarg, void *dbdata, isc_mem_t *mctx,
00143                      dns_rdataclass_t rdclass, dns_name_t *name,
00144                      dns_clientinfomethods_t *methods,
00145                      dns_clientinfo_t *clientinfo,
00146                      dns_db_t **dbp);
00147 
00148 /*%<
00149  * Method prototype.  Drivers implementing the DLZ interface MUST
00150  * supply a find zone method.  This method is called when the DNS
00151  * server is performing a query.  The find zone method will be called
00152  * with the longest possible name first, and continue to be called
00153  * with successively shorter domain names, until any of the following
00154  * occur:
00155  *
00156  * \li  1) a match is found, and the function returns (ISC_R_SUCCESS)
00157  *
00158  * \li  2) a problem occurs, and the functions returns anything other
00159  *         than (ISC_R_NOTFOUND)
00160  * \li  3) we run out of domain name labels. I.E. we have tried the
00161  *         shortest domain name
00162  * \li  4) the number of labels in the domain name is less than
00163  *         min_labels for dns_dlzfindzone
00164  *
00165  * The driver's find zone method should return ISC_R_SUCCESS and a
00166  * database pointer to the name server if the zone is supported by the
00167  * database.  Otherwise it will return ISC_R_NOTFOUND, and a null
00168  * pointer if the zone is not supported.  If an error occurs it should
00169  * return a result code indicating the type of error.
00170  */
00171 
00172 
00173 typedef isc_result_t
00174 (*dns_dlzconfigure_t)(void *driverarg, void *dbdata,
00175                       dns_view_t *view, dns_dlzdb_t *dlzdb);
00176 /*%<
00177  * Method prototype.  Drivers implementing the DLZ interface may
00178  * optionally supply a configure method. If supplied, this will be
00179  * called immediately after the create method is called. The driver
00180  * may call configuration functions during the configure call
00181  */
00182 
00183 
00184 typedef isc_boolean_t (*dns_dlzssumatch_t)(dns_name_t *signer,
00185                                            dns_name_t *name,
00186                                            isc_netaddr_t *tcpaddr,
00187                                            dns_rdatatype_t type,
00188                                            const dst_key_t *key,
00189                                            void *driverarg, void *dbdata);
00190 /*%<
00191  * Method prototype.  Drivers implementing the DLZ interface may
00192  * optionally supply a ssumatch method. If supplied, this will be
00193  * called to authorize update requests
00194  */
00195 
00196 /*% the methods supplied by a DLZ driver */
00197 typedef struct dns_dlzmethods {
00198         dns_dlzcreate_t         create;
00199         dns_dlzdestroy_t        destroy;
00200         dns_dlzfindzone_t       findzone;
00201         dns_dlzallowzonexfr_t   allowzonexfr;
00202         dns_dlzconfigure_t      configure;
00203         dns_dlzssumatch_t       ssumatch;
00204 } dns_dlzmethods_t;
00205 
00206 /*% information about a DLZ driver */
00207 struct dns_dlzimplementation {
00208         const char                              *name;
00209         const dns_dlzmethods_t                  *methods;
00210         isc_mem_t                               *mctx;
00211         void                                    *driverarg;
00212         ISC_LINK(dns_dlzimplementation_t)       link;
00213 };
00214 
00215 typedef isc_result_t (*dlzconfigure_callback_t)(dns_view_t *, dns_dlzdb_t *,
00216                                                 dns_zone_t *);
00217 
00218 /*% An instance of a DLZ driver */
00219 struct dns_dlzdb {
00220         unsigned int            magic;
00221         isc_mem_t               *mctx;
00222         dns_dlzimplementation_t *implementation;
00223         void                    *dbdata;
00224         dlzconfigure_callback_t configure_callback;
00225         isc_boolean_t           search;
00226         char                    *dlzname;
00227         ISC_LINK(dns_dlzdb_t)   link;
00228         dns_ssutable_t          *ssutable;
00229 };
00230 
00231 
00232 /***
00233  *** Method declarations
00234  ***/
00235 
00236 isc_result_t
00237 dns_dlzallowzonexfr(dns_view_t *view, dns_name_t *name,
00238                     isc_sockaddr_t *clientaddr, dns_db_t **dbp);
00239 
00240 /*%<
00241  * This method is called when the DNS server is performing a zone
00242  * transfer query.  It will call the DLZ driver's allow zone transfer
00243  * method.
00244  */
00245 
00246 isc_result_t
00247 dns_dlzcreate(isc_mem_t *mctx, const char *dlzname,
00248               const char *drivername, unsigned int argc,
00249               char *argv[], dns_dlzdb_t **dbp);
00250 
00251 /*%<
00252  * This method is called when the DNS server is starting up and
00253  * creating drivers for use later.  It will search the DLZ driver list
00254  * for 'drivername' and return a DLZ driver via dbp if a match is
00255  * found.  If the DLZ driver supplies a create method, this function
00256  * will call it.
00257  */
00258 
00259 void
00260 dns_dlzdestroy(dns_dlzdb_t **dbp);
00261 
00262 /*%<
00263  * This method is called when the DNS server is shutting down and no
00264  * longer needs the driver.  If the DLZ driver supplies a destroy
00265  * methods, this function will call it.
00266  */
00267 
00268 isc_result_t
00269 dns_dlzregister(const char *drivername, const dns_dlzmethods_t *methods,
00270                  void *driverarg, isc_mem_t *mctx,
00271                 dns_dlzimplementation_t **dlzimp);
00272 
00273 /*%<
00274  * Register a dynamically loadable zones (DLZ) driver for the database
00275  * type 'drivername', implemented by the functions in '*methods'.
00276  *
00277  * dlzimp must point to a NULL dlz_implementation_t pointer.  That is,
00278  * dlzimp != NULL && *dlzimp == NULL.  It will be assigned a value that
00279  * will later be used to identify the driver when deregistering it.
00280  */
00281 
00282 isc_result_t
00283 dns_dlzstrtoargv(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp);
00284 
00285 /*%<
00286  * This method is called when the name server is starting up to parse
00287  * the DLZ driver command line from named.conf.  Basically it splits
00288  * up a string into and argc / argv.  The primary difference of this
00289  * method is items between braces { } are considered only 1 word.  for
00290  * example the command line "this is { one grouped phrase } and this
00291  * isn't" would be parsed into:
00292  *
00293  * \li  argv[0]: "this"
00294  * \li  argv[1]: "is"
00295  * \li  argv{2]: " one grouped phrase "
00296  * \li  argv[3]: "and"
00297  * \li  argv[4]: "this"
00298  * \li  argv{5}: "isn't"
00299  *
00300  * braces should NOT be nested, more than one grouping in the command
00301  * line is allowed.  Notice, argv[2] has an extra space at the
00302  * beginning and end.  Extra spaces are not stripped between a
00303  * grouping.  You can do so in your driver if needed, or be sure not
00304  * to put extra spaces before / after the braces.
00305  */
00306 
00307 void
00308 dns_dlzunregister(dns_dlzimplementation_t **dlzimp);
00309 
00310 /*%<
00311  * Removes the dlz driver from the list of registered dlz drivers.
00312  * There must be no active dlz drivers of this type when this function
00313  * is called.
00314  */
00315 
00316 
00317 typedef isc_result_t dns_dlz_writeablezone_t(dns_view_t *view,
00318                                              dns_dlzdb_t *dlzdb,
00319                                              const char *zone_name);
00320 dns_dlz_writeablezone_t dns_dlz_writeablezone;
00321 /*%<
00322  * creates a writeable DLZ zone. Must be called from within the
00323  * configure() method of a DLZ driver.
00324  */
00325 
00326 
00327 isc_result_t
00328 dns_dlzconfigure(dns_view_t *view, dns_dlzdb_t *dlzdb,
00329                  dlzconfigure_callback_t callback);
00330 /*%<
00331  * call a DLZ drivers configure method, if supplied
00332  */
00333 
00334 isc_boolean_t
00335 dns_dlz_ssumatch(dns_dlzdb_t *dlzdatabase,
00336                   dns_name_t *signer, dns_name_t *name, isc_netaddr_t *tcpaddr,
00337                   dns_rdatatype_t type, const dst_key_t *key);
00338 /*%<
00339  * call a DLZ drivers ssumatch method, if supplied. Otherwise return ISC_FALSE
00340  */
00341 
00342 ISC_LANG_ENDDECLS
00343 
00344 #endif /* DLZ_H */

Generated on Tue Apr 28 17:40:57 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha