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
29 #if defined (BIND_VERSION_9_8)
30 # error Bind 9.8 is not supported!
31 #elif defined (BIND_VERSION_9_9)
32 # error Bind 9.9 is not supported!
33 #elif defined (BIND_VERSION_9_10)
34 # define DLZ_DLOPEN_VERSION 3
35 # define DNS_CLIENTINFO_VERSION 1
36 # define ISC_BOOLEAN_AS_BOOL 0
37 #elif defined (BIND_VERSION_9_11)
38 # define DLZ_DLOPEN_VERSION 3
39 # define DNS_CLIENTINFO_VERSION 2
40 # define ISC_BOOLEAN_AS_BOOL 0
41 #elif defined (BIND_VERSION_9_12)
42 # define DLZ_DLOPEN_VERSION 3
43 # define DNS_CLIENTINFO_VERSION 2
44 # define ISC_BOOLEAN_AS_BOOL 0
45 #elif defined (BIND_VERSION_9_14)
46 # define DLZ_DLOPEN_VERSION 3
47 # define DNS_CLIENTINFO_VERSION 2
48 #elif defined (BIND_VERSION_9_16)
49 # define DLZ_DLOPEN_VERSION 3
50 # define DNS_CLIENTINFO_VERSION 2
51 #elif defined (BIND_VERSION_9_18)
52 # define DLZ_DLOPEN_VERSION 3
53 # define DNS_CLIENTINFO_VERSION 2
55 # error Unsupported BIND version
58 #ifndef ISC_BOOLEAN_AS_BOOL
59 #define ISC_BOOLEAN_AS_BOOL 1
62 # define DLZ_DLOPEN_AGE 0
64 typedef unsigned int isc_result_t
;
65 #if ISC_BOOLEAN_AS_BOOL == 1
66 typedef bool isc_boolean_t
;
68 typedef int isc_boolean_t
;
70 typedef uint32_t dns_ttl_t
;
72 /* return these in flags from dlz_version() */
73 #define DNS_SDLZFLAG_THREADSAFE 0x00000001U
74 #define DNS_SDLZFLAG_RELATIVEOWNER 0x00000002U
75 #define DNS_SDLZFLAG_RELATIVERDATA 0x00000004U
78 #define ISC_R_SUCCESS 0
79 #define ISC_R_NOMEMORY 1
80 #define ISC_R_NOPERM 6
81 #define ISC_R_NOSPACE 19
82 #define ISC_R_NOTFOUND 23
83 #define ISC_R_FAILURE 25
84 #define ISC_R_NOTIMPLEMENTED 27
85 #define ISC_R_NOMORE 29
86 #define ISC_R_INVALIDFILE 30
87 #define ISC_R_UNEXPECTED 34
88 #define ISC_R_FILENOTFOUND 38
91 #if ISC_BOOLEAN_AS_BOOL == 1
93 #define ISC_FALSE false
100 #define ISC_LOG_INFO (-1)
101 #define ISC_LOG_NOTICE (-2)
102 #define ISC_LOG_WARNING (-3)
103 #define ISC_LOG_ERROR (-4)
104 #define ISC_LOG_CRITICAL (-5)
105 #define ISC_LOG_DEBUG(level) (level)
107 /* opaque structures */
108 typedef void *dns_sdlzlookup_t
;
109 typedef void *dns_sdlzallnodes_t
;
110 typedef void *dns_view_t
;
111 typedef void *dns_dlzdb_t
;
114 * Method and type definitions needed for retrieval of client info
117 typedef struct isc_sockaddr
{
120 struct sockaddr_in sin
;
121 struct sockaddr_in6 sin6
;
122 struct sockaddr_un sunix
;
128 #if DNS_CLIENTINFO_VERSION == 1
130 typedef struct dns_clientinfo
{
135 typedef isc_result_t (*dns_clientinfo_sourceip_t
)(dns_clientinfo_t
*client
,
136 isc_sockaddr_t
**addrp
);
138 #define DNS_CLIENTINFOMETHODS_VERSION 1
139 #define DNS_CLIENTINFOMETHODS_AGE 0
141 typedef struct dns_clientinfomethods
{
144 dns_clientinfo_sourceip_t sourceip
;
145 } dns_clientinfomethods_t
;
147 #elif DNS_CLIENTINFO_VERSION == 2
149 typedef struct dns_clientinfo
{
155 typedef isc_result_t (*dns_clientinfo_sourceip_t
)(dns_clientinfo_t
*client
,
156 isc_sockaddr_t
**addrp
);
158 typedef isc_result_t (*dns_clientinfo_version_t
)(dns_clientinfo_t
*client
,
161 #define DNS_CLIENTINFOMETHODS_VERSION 2
162 #define DNS_CLIENTINFOMETHODS_AGE 1
164 typedef struct dns_clientinfomethods
{
167 dns_clientinfo_sourceip_t sourceip
;
168 dns_clientinfo_version_t dbversion
;
169 } dns_clientinfomethods_t
;
171 #endif /* DNS_CLIENTINFO_VERSION */
175 * Method definitions for callbacks provided by the dlopen driver
178 typedef void log_t(int level
, const char *fmt
, ...);
180 typedef isc_result_t
dns_sdlz_putrr_t(dns_sdlzlookup_t
*lookup
,
185 typedef isc_result_t
dns_sdlz_putnamedrr_t(dns_sdlzallnodes_t
*allnodes
,
191 typedef isc_result_t
dns_dlz_writeablezone_t(dns_view_t
*view
,
193 const char *zone_name
);
197 * prototypes for the functions you can include in your module
201 * dlz_version() is required for all DLZ external drivers. It should
202 * return DLZ_DLOPEN_VERSION. 'flags' is updated to indicate capabilities
203 * of the module. In particular, if the module is thread-safe then it
204 * sets 'flags' to include DNS_SDLZFLAG_THREADSAFE. Other capability
205 * flags may be added in the future.
208 dlz_version(unsigned int *flags
);
211 * dlz_create() is required for all DLZ external drivers.
214 dlz_create(const char *dlzname
, unsigned int argc
, const char *argv
[],
218 * dlz_destroy() is optional, and will be called when the driver is
219 * unloaded if supplied
222 dlz_destroy(void *dbdata
);
225 * dlz_findzonedb is required for all DLZ external drivers
228 dlz_findzonedb(void *dbdata
, const char *name
,
229 dns_clientinfomethods_t
*methods
,
230 dns_clientinfo_t
*clientinfo
);
233 * dlz_lookup is required for all DLZ external drivers
236 dlz_lookup(const char *zone
, const char *name
, void *dbdata
,
237 dns_sdlzlookup_t
*lookup
,
238 dns_clientinfomethods_t
*methods
,
239 dns_clientinfo_t
*clientinfo
);
242 * dlz_authority() is optional if dlz_lookup() supplies
243 * authority information (i.e., SOA, NS) for the dns record
246 dlz_authority(const char *zone
, void *dbdata
, dns_sdlzlookup_t
*lookup
);
249 * dlz_allowzonexfr() is optional, and should be supplied if you want to
250 * support zone transfers
253 dlz_allowzonexfr(void *dbdata
, const char *name
, const char *client
);
256 * dlz_allnodes() is optional, but must be supplied if supply a
257 * dlz_allowzonexfr() function
260 dlz_allnodes(const char *zone
, void *dbdata
, dns_sdlzallnodes_t
*allnodes
);
263 * dlz_newversion() is optional. It should be supplied if you want to
264 * support dynamic updates.
267 dlz_newversion(const char *zone
, void *dbdata
, void **versionp
);
270 * dlz_closeversion() is optional, but must be supplied if you supply a
271 * dlz_newversion() function
274 dlz_closeversion(const char *zone
, isc_boolean_t commit
, void *dbdata
,
278 * dlz_configure() is optional, but must be supplied if you want to support
282 dlz_configure(dns_view_t
*view
, dns_dlzdb_t
*dlzdb
, void *dbdata
);
285 * dlz_ssumatch() is optional, but must be supplied if you want to support
289 dlz_ssumatch(const char *signer
, const char *name
, const char *tcpaddr
,
290 const char *type
, const char *key
, uint32_t keydatalen
,
291 uint8_t *keydata
, void *dbdata
);
294 * dlz_addrdataset() is optional, but must be supplied if you want to
295 * support dynamic updates
298 dlz_addrdataset(const char *name
, const char *rdatastr
, void *dbdata
,
302 * dlz_subrdataset() is optional, but must be supplied if you want to
303 * support dynamic updates
306 dlz_subrdataset(const char *name
, const char *rdatastr
, void *dbdata
,
310 * dlz_delrdataset() is optional, but must be supplied if you want to
311 * support dynamic updates
314 dlz_delrdataset(const char *name
, const char *type
, void *dbdata
,
317 #endif /* DLZ_MINIMAL_H */