2 * Copyright (C) 2010 Andrew Tridgell
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
10 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
11 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
12 * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
13 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
14 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
16 * USE OR PERFORMANCE OF THIS SOFTWARE.
19 /* This header is updated based on BIND 9.10.1 source.
20 * contrib/dlz/modules/include/dlz_minimal.h
24 #define DLZ_MINIMAL_H 1
26 #if defined (BIND_VERSION_9_8)
27 # define DLZ_DLOPEN_VERSION 1
28 #elif defined (BIND_VERSION_9_9)
29 # define DLZ_DLOPEN_VERSION 2
30 # define DNS_CLIENTINFO_VERSION 1
31 #elif defined (BIND_VERSION_9_10)
32 # define DLZ_DLOPEN_VERSION 3
33 # define DNS_CLIENTINFO_VERSION 1
34 #elif defined (BIND_VERSION_9_11)
35 # define DLZ_DLOPEN_VERSION 3
36 # define DNS_CLIENTINFO_VERSION 2
37 #elif defined (BIND_VERSION_9_12)
38 # define DLZ_DLOPEN_VERSION 3
39 # define DNS_CLIENTINFO_VERSION 2
41 # error Unsupported BIND version
44 #if DLZ_DLOPEN_VERSION > 1
45 # define DLZ_DLOPEN_AGE 0
48 typedef unsigned int isc_result_t
;
49 #if DLZ_DLOPEN_VERSION == 1
50 typedef bool isc_boolean_t
;
52 typedef int isc_boolean_t
;
54 typedef uint32_t dns_ttl_t
;
56 /* return these in flags from dlz_version() */
57 #define DNS_SDLZFLAG_THREADSAFE 0x00000001U
58 #define DNS_SDLZFLAG_RELATIVEOWNER 0x00000002U
59 #define DNS_SDLZFLAG_RELATIVERDATA 0x00000004U
62 #define ISC_R_SUCCESS 0
63 #define ISC_R_NOMEMORY 1
64 #define ISC_R_NOPERM 6
65 #define ISC_R_NOSPACE 19
66 #define ISC_R_NOTFOUND 23
67 #define ISC_R_FAILURE 25
68 #define ISC_R_NOTIMPLEMENTED 27
69 #define ISC_R_NOMORE 29
70 #define ISC_R_INVALIDFILE 30
71 #define ISC_R_UNEXPECTED 34
72 #define ISC_R_FILENOTFOUND 38
79 #define ISC_LOG_INFO (-1)
80 #define ISC_LOG_NOTICE (-2)
81 #define ISC_LOG_WARNING (-3)
82 #define ISC_LOG_ERROR (-4)
83 #define ISC_LOG_CRITICAL (-5)
84 #define ISC_LOG_DEBUG(level) (level)
86 /* opaque structures */
87 typedef void *dns_sdlzlookup_t
;
88 typedef void *dns_sdlzallnodes_t
;
89 typedef void *dns_view_t
;
90 typedef void *dns_dlzdb_t
;
92 #if DLZ_DLOPEN_VERSION > 1
94 * Method and type definitions needed for retrieval of client info
97 typedef struct isc_sockaddr
{
100 struct sockaddr_in sin
;
101 struct sockaddr_in6 sin6
;
102 struct sockaddr_un sunix
;
108 #if DNS_CLIENTINFO_VERSION == 1
110 typedef struct dns_clientinfo
{
115 typedef isc_result_t (*dns_clientinfo_sourceip_t
)(dns_clientinfo_t
*client
,
116 isc_sockaddr_t
**addrp
);
118 #define DNS_CLIENTINFOMETHODS_VERSION 1
119 #define DNS_CLIENTINFOMETHODS_AGE 0
121 typedef struct dns_clientinfomethods
{
124 dns_clientinfo_sourceip_t sourceip
;
125 } dns_clientinfomethods_t
;
127 #elif DNS_CLIENTINFO_VERSION == 2
129 typedef struct dns_clientinfo
{
135 typedef isc_result_t (*dns_clientinfo_sourceip_t
)(dns_clientinfo_t
*client
,
136 isc_sockaddr_t
**addrp
);
138 typedef isc_result_t (*dns_clientinfo_version_t
)(dns_clientinfo_t
*client
,
141 #define DNS_CLIENTINFOMETHODS_VERSION 2
142 #define DNS_CLIENTINFOMETHODS_AGE 1
144 typedef struct dns_clientinfomethods
{
147 dns_clientinfo_sourceip_t sourceip
;
148 dns_clientinfo_version_t dbversion
;
149 } dns_clientinfomethods_t
;
151 #endif /* DNS_CLIENTINFO_VERSION */
153 #endif /* DLZ_DLOPEN_VERSION > 1 */
156 * Method definitions for callbacks provided by the dlopen driver
159 typedef void log_t(int level
, const char *fmt
, ...);
161 typedef isc_result_t
dns_sdlz_putrr_t(dns_sdlzlookup_t
*lookup
,
166 typedef isc_result_t
dns_sdlz_putnamedrr_t(dns_sdlzallnodes_t
*allnodes
,
172 #if DLZ_DLOPEN_VERSION < 3
173 typedef isc_result_t
dns_dlz_writeablezone_t(dns_view_t
*view
,
174 const char *zone_name
);
175 #else /* DLZ_DLOPEN_VERSION >= 3 */
176 typedef isc_result_t
dns_dlz_writeablezone_t(dns_view_t
*view
,
178 const char *zone_name
);
179 #endif /* DLZ_DLOPEN_VERSION */
182 * prototypes for the functions you can include in your module
186 * dlz_version() is required for all DLZ external drivers. It should
187 * return DLZ_DLOPEN_VERSION. 'flags' is updated to indicate capabilities
188 * of the module. In particular, if the module is thread-safe then it
189 * sets 'flags' to include DNS_SDLZFLAG_THREADSAFE. Other capability
190 * flags may be added in the future.
193 dlz_version(unsigned int *flags
);
196 * dlz_create() is required for all DLZ external drivers.
199 dlz_create(const char *dlzname
, unsigned int argc
, const char *argv
[],
203 * dlz_destroy() is optional, and will be called when the driver is
204 * unloaded if supplied
207 dlz_destroy(void *dbdata
);
210 * dlz_findzonedb is required for all DLZ external drivers
212 #if DLZ_DLOPEN_VERSION < 3
214 dlz_findzonedb(void *dbdata
, const char *name
);
215 #else /* DLZ_DLOPEN_VERSION >= 3 */
217 dlz_findzonedb(void *dbdata
, const char *name
,
218 dns_clientinfomethods_t
*methods
,
219 dns_clientinfo_t
*clientinfo
);
220 #endif /* DLZ_DLOPEN_VERSION */
223 * dlz_lookup is required for all DLZ external drivers
225 #if DLZ_DLOPEN_VERSION == 1
227 dlz_lookup(const char *zone
, const char *name
, void *dbdata
,
228 dns_sdlzlookup_t
*lookup
);
229 #else /* DLZ_DLOPEN_VERSION > 1 */
231 dlz_lookup(const char *zone
, const char *name
, void *dbdata
,
232 dns_sdlzlookup_t
*lookup
,
233 dns_clientinfomethods_t
*methods
,
234 dns_clientinfo_t
*clientinfo
);
235 #endif /* DLZ_DLOPEN_VERSION */
238 * dlz_authority() is optional if dlz_lookup() supplies
239 * authority information (i.e., SOA, NS) for the dns record
242 dlz_authority(const char *zone
, void *dbdata
, dns_sdlzlookup_t
*lookup
);
245 * dlz_allowzonexfr() is optional, and should be supplied if you want to
246 * support zone transfers
249 dlz_allowzonexfr(void *dbdata
, const char *name
, const char *client
);
252 * dlz_allnodes() is optional, but must be supplied if supply a
253 * dlz_allowzonexfr() function
256 dlz_allnodes(const char *zone
, void *dbdata
, dns_sdlzallnodes_t
*allnodes
);
259 * dlz_newversion() is optional. It should be supplied if you want to
260 * support dynamic updates.
263 dlz_newversion(const char *zone
, void *dbdata
, void **versionp
);
266 * dlz_closeversion() is optional, but must be supplied if you supply a
267 * dlz_newversion() function
270 dlz_closeversion(const char *zone
, isc_boolean_t commit
, void *dbdata
,
274 * dlz_configure() is optional, but must be supplied if you want to support
277 #if DLZ_DLOPEN_VERSION < 3
279 dlz_configure(dns_view_t
*view
, void *dbdata
);
280 #else /* DLZ_DLOPEN_VERSION >= 3 */
282 dlz_configure(dns_view_t
*view
, dns_dlzdb_t
*dlzdb
, void *dbdata
);
283 #endif /* DLZ_DLOPEN_VERSION */
286 * dlz_ssumatch() is optional, but must be supplied if you want to support
290 dlz_ssumatch(const char *signer
, const char *name
, const char *tcpaddr
,
291 const char *type
, const char *key
, uint32_t keydatalen
,
292 uint8_t *keydata
, void *dbdata
);
295 * dlz_addrdataset() is optional, but must be supplied if you want to
296 * support dynamic updates
299 dlz_addrdataset(const char *name
, const char *rdatastr
, void *dbdata
,
303 * dlz_subrdataset() is optional, but must be supplied if you want to
304 * support dynamic updates
307 dlz_subrdataset(const char *name
, const char *rdatastr
, void *dbdata
,
311 * dlz_delrdataset() is optional, but must be supplied if you want to
312 * support dynamic updates
315 dlz_delrdataset(const char *name
, const char *type
, void *dbdata
,
318 #endif /* DLZ_MINIMAL_H */