sdb.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2007, 2009, 2011, 2012  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 2000, 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 /* $Id: sdb.h,v 1.25 2011/10/11 23:46:45 tbox Exp $ */
00019 
00020 #ifndef DNS_SDB_H
00021 #define DNS_SDB_H 1
00022 
00023 /*****
00024  ***** Module Info
00025  *****/
00026 
00027 /*! \file dns/sdb.h
00028  * \brief
00029  * Simple database API.
00030  */
00031 
00032 /***
00033  *** Imports
00034  ***/
00035 
00036 #include <isc/lang.h>
00037 
00038 #include <dns/clientinfo.h>
00039 #include <dns/types.h>
00040 
00041 /***
00042  *** Types
00043  ***/
00044 
00045 /*%
00046  * A simple database.  This is an opaque type.
00047  */
00048 typedef struct dns_sdb dns_sdb_t;
00049 
00050 /*%
00051  * A simple database lookup in progress.  This is an opaque type.
00052  */
00053 typedef struct dns_sdblookup dns_sdblookup_t;
00054 
00055 /*%
00056  * A simple database traversal in progress.  This is an opaque type.
00057  */
00058 typedef struct dns_sdballnodes dns_sdballnodes_t;
00059 
00060 typedef isc_result_t
00061 (*dns_sdblookupfunc_t)(const char *zone, const char *name, void *dbdata,
00062                        dns_sdblookup_t *lookup,
00063                        dns_clientinfomethods_t *methods,
00064                        dns_clientinfo_t *clientinfo);
00065 typedef isc_result_t
00066 (*dns_sdblookup2func_t)(const dns_name_t *zone, const dns_name_t *name,
00067                         void *dbdata, dns_sdblookup_t *lookup,
00068                         dns_clientinfomethods_t *methods,
00069                         dns_clientinfo_t *clientinfo);
00070 
00071 typedef isc_result_t
00072 (*dns_sdbauthorityfunc_t)(const char *zone, void *dbdata, dns_sdblookup_t *);
00073 
00074 typedef isc_result_t
00075 (*dns_sdballnodesfunc_t)(const char *zone, void *dbdata,
00076                          dns_sdballnodes_t *allnodes);
00077 
00078 typedef isc_result_t
00079 (*dns_sdbcreatefunc_t)(const char *zone, int argc, char **argv,
00080                        void *driverdata, void **dbdata);
00081 
00082 typedef void
00083 (*dns_sdbdestroyfunc_t)(const char *zone, void *driverdata, void **dbdata);
00084 
00085 
00086 typedef struct dns_sdbmethods {
00087         dns_sdblookupfunc_t     lookup;
00088         dns_sdbauthorityfunc_t  authority;
00089         dns_sdballnodesfunc_t   allnodes;
00090         dns_sdbcreatefunc_t     create;
00091         dns_sdbdestroyfunc_t    destroy;
00092         dns_sdblookup2func_t    lookup2;
00093 } dns_sdbmethods_t;
00094 
00095 /***
00096  *** Functions
00097  ***/
00098 
00099 ISC_LANG_BEGINDECLS
00100 
00101 #define DNS_SDBFLAG_RELATIVEOWNER 0x00000001U
00102 #define DNS_SDBFLAG_RELATIVERDATA 0x00000002U
00103 #define DNS_SDBFLAG_THREADSAFE 0x00000004U
00104 #define DNS_SDBFLAG_DNS64 0x00000008U
00105 
00106 isc_result_t
00107 dns_sdb_register(const char *drivername, const dns_sdbmethods_t *methods,
00108                  void *driverdata, unsigned int flags, isc_mem_t *mctx,
00109                  dns_sdbimplementation_t **sdbimp);
00110 /*%<
00111  * Register a simple database driver for the database type 'drivername',
00112  * implemented by the functions in '*methods'.
00113  *
00114  * sdbimp must point to a NULL dns_sdbimplementation_t pointer.  That is,
00115  * sdbimp != NULL && *sdbimp == NULL.  It will be assigned a value that
00116  * will later be used to identify the driver when deregistering it.
00117  *
00118  * The name server will perform lookups in the database by calling the
00119  * function 'lookup', passing it a printable zone name 'zone', a printable
00120  * domain name 'name', and a copy of the argument 'dbdata' that
00121  * was potentially returned by the create function.  The 'dns_sdblookup_t'
00122  * argument to 'lookup' and 'authority' is an opaque pointer to be passed to
00123  * ns_sdb_putrr().
00124  *
00125  * The lookup function returns the lookup results to the name server
00126  * by calling ns_sdb_putrr() once for each record found.  On success,
00127  * the return value of the lookup function should be ISC_R_SUCCESS.
00128  * If the domain name 'name' does not exist, the lookup function should
00129  * ISC_R_NOTFOUND.  Any other return value is treated as an error.
00130  *
00131  * Lookups at the zone apex will cause the server to also call the
00132  * function 'authority' (if non-NULL), which must provide an SOA record
00133  * and NS records for the zone by calling ns_sdb_putrr() once for each of
00134  * these records.  The 'authority' function may be NULL if invoking
00135  * the 'lookup' function on the zone apex will return SOA and NS records.
00136  *
00137  * The allnodes function, if non-NULL, fills in an opaque structure to be
00138  * used by a database iterator.  This allows the zone to be transferred.
00139  * This may use a considerable amount of memory for large zones, and the
00140  * zone transfer may not be fully RFC1035 compliant if the zone is
00141  * frequently changed.
00142  *
00143  * The create function will be called for each zone configured
00144  * into the name server using this database type.  It can be used
00145  * to create a "database object" containing zone specific data,
00146  * which can make use of the database arguments specified in the
00147  * name server configuration.
00148  *
00149  * The destroy function will be called to free the database object
00150  * when its zone is destroyed.
00151  *
00152  * The create and destroy functions may be NULL.
00153  *
00154  * If flags includes DNS_SDBFLAG_RELATIVEOWNER, the lookup and authority
00155  * functions will be called with relative names rather than absolute names.
00156  * The string "@" represents the zone apex in this case.
00157  *
00158  * If flags includes DNS_SDBFLAG_RELATIVERDATA, the rdata strings may
00159  * include relative names.  Otherwise, all names in the rdata string must
00160  * be absolute.  Be aware that if relative names are allowed, any
00161  * absolute names must contain a trailing dot.
00162  *
00163  * If flags includes DNS_SDBFLAG_THREADSAFE, the driver must be able to
00164  * handle multiple lookups in parallel.  Otherwise, calls into the driver
00165  * are serialized.
00166  */
00167 
00168 void
00169 dns_sdb_unregister(dns_sdbimplementation_t **sdbimp);
00170 /*%<
00171  * Removes the simple database driver from the list of registered database
00172  * types.  There must be no active databases of this type when this function
00173  * is called.
00174  */
00175 
00176 /*% See dns_sdb_putradata() */
00177 isc_result_t
00178 dns_sdb_putrr(dns_sdblookup_t *lookup, const char *type, dns_ttl_t ttl,
00179               const char *data);
00180 isc_result_t
00181 dns_sdb_putrdata(dns_sdblookup_t *lookup, dns_rdatatype_t type, dns_ttl_t ttl,
00182                  const unsigned char *rdata, unsigned int rdlen);
00183 /*%<
00184  * Add a single resource record to the lookup structure to be
00185  * returned in the query response.  dns_sdb_putrr() takes the
00186  * resource record in master file text format as a null-terminated
00187  * string, and dns_sdb_putrdata() takes the raw RDATA in
00188  * uncompressed wire format.
00189  */
00190 
00191 /*% See dns_sdb_putnamerdata() */
00192 isc_result_t
00193 dns_sdb_putnamedrr(dns_sdballnodes_t *allnodes, const char *name,
00194                    const char *type, dns_ttl_t ttl, const char *data);
00195 isc_result_t
00196 dns_sdb_putnamedrdata(dns_sdballnodes_t *allnodes, const char *name,
00197                       dns_rdatatype_t type, dns_ttl_t ttl,
00198                       const void *rdata, unsigned int rdlen);
00199 /*%<
00200  * Add a single resource record to the allnodes structure to be
00201  * included in a zone transfer response, in text or wire
00202  * format as above.
00203  */
00204 
00205 isc_result_t
00206 dns_sdb_putsoa(dns_sdblookup_t *lookup, const char *mname, const char *rname,
00207                isc_uint32_t serial);
00208 /*%<
00209  * This function may optionally be called from the 'authority' callback
00210  * to simplify construction of the SOA record for 'zone'.  It will
00211  * provide a SOA listing 'mname' as as the master server and 'rname' as
00212  * the responsible person mailbox.  It is the responsibility of the
00213  * driver to increment the serial number between responses if necessary.
00214  * All other SOA fields will have reasonable default values.
00215  */
00216 
00217 ISC_LANG_ENDDECLS
00218 
00219 #endif /* DNS_SDB_H */

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