Add BIND 9.2.4rc7.
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / dns / include / dns / sdb.h
blob154ee027e4c51965335bf6976e4d8ffdebfbc4fc
1 /*
2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000, 2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and 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.
18 /* $Id: sdb.h,v 1.12.2.1 2004/03/09 06:11:22 marka Exp $ */
20 #ifndef DNS_SDB_H
21 #define DNS_SDB_H 1
23 /*****
24 ***** Module Info
25 *****/
28 * Simple database API.
31 /***
32 *** Imports
33 ***/
35 #include <isc/lang.h>
37 #include <dns/types.h>
39 /***
40 *** Types
41 ***/
44 * A simple database. This is an opaque type.
46 typedef struct dns_sdb dns_sdb_t;
49 * A simple database lookup in progress. This is an opaque type.
51 typedef struct dns_sdblookup dns_sdblookup_t;
54 * A simple database traversal in progress. This is an opaque type.
56 typedef struct dns_sdballnodes dns_sdballnodes_t;
58 typedef isc_result_t
59 (*dns_sdblookupfunc_t)(const char *zone, const char *name, void *dbdata,
60 dns_sdblookup_t *);
62 typedef isc_result_t
63 (*dns_sdbauthorityfunc_t)(const char *zone, void *dbdata, dns_sdblookup_t *);
65 typedef isc_result_t
66 (*dns_sdballnodesfunc_t)(const char *zone, void *dbdata,
67 dns_sdballnodes_t *allnodes);
69 typedef isc_result_t
70 (*dns_sdbcreatefunc_t)(const char *zone, int argc, char **argv,
71 void *driverdata, void **dbdata);
73 typedef void
74 (*dns_sdbdestroyfunc_t)(const char *zone, void *driverdata, void **dbdata);
77 typedef struct dns_sdbmethods {
78 dns_sdblookupfunc_t lookup;
79 dns_sdbauthorityfunc_t authority;
80 dns_sdballnodesfunc_t allnodes;
81 dns_sdbcreatefunc_t create;
82 dns_sdbdestroyfunc_t destroy;
83 } dns_sdbmethods_t;
85 /***
86 *** Functions
87 ***/
89 ISC_LANG_BEGINDECLS
91 #define DNS_SDBFLAG_RELATIVEOWNER 0x00000001U
92 #define DNS_SDBFLAG_RELATIVERDATA 0x00000002U
93 #define DNS_SDBFLAG_THREADSAFE 0x00000004U
95 isc_result_t
96 dns_sdb_register(const char *drivername, const dns_sdbmethods_t *methods,
97 void *driverdata, unsigned int flags, isc_mem_t *mctx,
98 dns_sdbimplementation_t **sdbimp);
100 * Register a simple database driver for the database type 'drivername',
101 * implemented by the functions in '*methods'.
103 * sdbimp must point to a NULL dns_sdbimplementation_t pointer. That is,
104 * sdbimp != NULL && *sdbimp == NULL. It will be assigned a value that
105 * will later be used to identify the driver when deregistering it.
107 * The name server will perform lookups in the database by calling the
108 * function 'lookup', passing it a printable zone name 'zone', a printable
109 * domain name 'name', and a copy of the argument 'dbdata' that
110 * was potentially returned by the create function. The 'dns_sdblookup_t'
111 * argument to 'lookup' and 'authority' is an opaque pointer to be passed to
112 * ns_sdb_putrr().
114 * The lookup function returns the lookup results to the name server
115 * by calling ns_sdb_putrr() once for each record found.
117 * Lookups at the zone apex will cause the server to also call the
118 * function 'authority' (if non-NULL), which must provide an SOA record
119 * and NS records for the zone by calling ns_sdb_putrr() once for each of
120 * these records. The 'authority' function may be NULL if invoking
121 * the 'lookup' function on the zone apex will return SOA and NS records.
123 * The allnodes function, if non-NULL, fills in an opaque structure to be
124 * used by a database iterator. This allows the zone to be transferred.
125 * This may use a considerable amount of memory for large zones, and the
126 * zone transfer may not be fully RFC 1035 compliant if the zone is
127 * frequently changed.
129 * The create function will be called for each zone configured
130 * into the name server using this database type. It can be used
131 * to create a "database object" containg zone specific data,
132 * which can make use of the database arguments specified in the
133 * name server configuration.
135 * The destroy function will be called to free the database object
136 * when its zone is destroyed.
138 * The create and destroy functions may be NULL.
140 * If flags includes DNS_SDBFLAG_RELATIVEOWNER, the lookup and authority
141 * functions will be called with relative names rather than absolute names.
142 * The string "@" represents the zone apex in this case.
144 * If flags includes DNS_SDBFLAG_RELATIVERDATA, the rdata strings may
145 * include relative names. Otherwise, all names in the rdata string must
146 * be absolute. Be aware that if relative names are allowed, any
147 * absolute names must contain a trailing dot.
149 * If flags includes DNS_SDBFLAG_THREADSAFE, the driver must be able to
150 * handle multiple lookups in parallel. Otherwise, calls into the driver
151 * are serialized.
154 void
155 dns_sdb_unregister(dns_sdbimplementation_t **sdbimp);
157 * Removes the simple database driver from the list of registered database
158 * types. There must be no active databases of this type when this function
159 * is called.
162 isc_result_t
163 dns_sdb_putrr(dns_sdblookup_t *lookup, const char *type, dns_ttl_t ttl,
164 const char *data);
166 * Add a single resource record to the lookup structure to be later
167 * parsed into a query response.
170 isc_result_t
171 dns_sdb_putnamedrr(dns_sdballnodes_t *allnodes, const char *name,
172 const char *type, dns_ttl_t ttl, const char *data);
174 * Add a single resource record to the allnodes structure to be later
175 * parsed into a zone transfer response.
178 isc_result_t
179 dns_sdb_putsoa(dns_sdblookup_t *lookup, const char *mname, const char *rname,
180 isc_uint32_t serial);
182 * This function may optionally be called from the 'authority' callback
183 * to simplify construction of the SOA record for 'zone'. It will
184 * provide a SOA listing 'mname' as as the master server and 'rname' as
185 * the responsible person mailbox. It is the responsibility of the
186 * driver to increment the serial number between responses if necessary.
187 * All other SOA fields will have reasonable default values.
190 ISC_LANG_ENDDECLS
192 #endif /* DNS_SDB_H */