ctdb-tests: Update statd-callout tests to handle both modes
[samba4-gss.git] / source4 / dns_server / dlz_minimal.h
blobb7e36e7f8e6571667895afbf8779f130d8e5c3c7
1 /*
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
7 * copies.
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
23 #ifndef DLZ_MINIMAL_H
24 #define DLZ_MINIMAL_H 1
26 #include <stdint.h>
27 #include <stdbool.h>
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
54 #else
55 # error Unsupported BIND version
56 #endif
58 #ifndef ISC_BOOLEAN_AS_BOOL
59 #define ISC_BOOLEAN_AS_BOOL 1
60 #endif
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;
67 #else
68 typedef int isc_boolean_t;
69 #endif
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
77 /* result codes */
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
90 /* boolean values */
91 #if ISC_BOOLEAN_AS_BOOL == 1
92 #define ISC_TRUE true
93 #define ISC_FALSE false
94 #else
95 #define ISC_TRUE 1
96 #define ISC_FALSE 0
97 #endif
99 /* log levels */
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
115 * from the caller.
117 typedef struct isc_sockaddr {
118 union {
119 struct sockaddr sa;
120 struct sockaddr_in sin;
121 struct sockaddr_in6 sin6;
122 struct sockaddr_un sunix;
123 } type;
124 unsigned int length;
125 void * link;
126 } isc_sockaddr_t;
128 #if DNS_CLIENTINFO_VERSION == 1
130 typedef struct dns_clientinfo {
131 uint16_t version;
132 void *data;
133 } dns_clientinfo_t;
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 {
142 uint16_t version;
143 uint16_t age;
144 dns_clientinfo_sourceip_t sourceip;
145 } dns_clientinfomethods_t;
147 #elif DNS_CLIENTINFO_VERSION == 2
149 typedef struct dns_clientinfo {
150 uint16_t version;
151 void *data;
152 void *dbversion;
153 } dns_clientinfo_t;
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,
159 void **addrp);
161 #define DNS_CLIENTINFOMETHODS_VERSION 2
162 #define DNS_CLIENTINFOMETHODS_AGE 1
164 typedef struct dns_clientinfomethods {
165 uint16_t version;
166 uint16_t age;
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,
181 const char *type,
182 dns_ttl_t ttl,
183 const char *data);
185 typedef isc_result_t dns_sdlz_putnamedrr_t(dns_sdlzallnodes_t *allnodes,
186 const char *name,
187 const char *type,
188 dns_ttl_t ttl,
189 const char *data);
191 typedef isc_result_t dns_dlz_writeablezone_t(dns_view_t *view,
192 dns_dlzdb_t *dlzdb,
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.
213 isc_result_t
214 dlz_create(const char *dlzname, unsigned int argc, const char *argv[],
215 void **dbdata, ...);
218 * dlz_destroy() is optional, and will be called when the driver is
219 * unloaded if supplied
221 void
222 dlz_destroy(void *dbdata);
225 * dlz_findzonedb is required for all DLZ external drivers
227 isc_result_t
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
235 isc_result_t
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
245 isc_result_t
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
252 isc_result_t
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
259 isc_result_t
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.
266 isc_result_t
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
273 void
274 dlz_closeversion(const char *zone, isc_boolean_t commit, void *dbdata,
275 void **versionp);
278 * dlz_configure() is optional, but must be supplied if you want to support
279 * dynamic updates
281 isc_result_t
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
286 * dynamic updates
288 isc_boolean_t
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
297 isc_result_t
298 dlz_addrdataset(const char *name, const char *rdatastr, void *dbdata,
299 void *version);
302 * dlz_subrdataset() is optional, but must be supplied if you want to
303 * support dynamic updates
305 isc_result_t
306 dlz_subrdataset(const char *name, const char *rdatastr, void *dbdata,
307 void *version);
310 * dlz_delrdataset() is optional, but must be supplied if you want to
311 * support dynamic updates
313 isc_result_t
314 dlz_delrdataset(const char *name, const char *type, void *dbdata,
315 void *version);
317 #endif /* DLZ_MINIMAL_H */