s4-dns: Check DLZ_DLOPEN_VERSION for different BIND versions
[Samba.git] / source4 / dns_server / dlz_minimal.h
blobaf0d6bc1631b9184403375e6bf05f94411680ad8
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 #ifdef BIND_VERSION_9_8
20 #define DLZ_DLOPEN_VERSION 1
21 #elif BIND_VERSION_9_9
22 #define DLZ_DLOPEN_VERSION 2
23 #else
24 #error Unsupported BIND version
25 #endif
27 typedef unsigned int isc_result_t;
28 #if DLZ_DLOPEN_VERSION == 1
29 typedef bool isc_boolean_t;
30 #else
31 typedef int isc_boolean_t;
32 #endif
33 typedef uint32_t dns_ttl_t;
35 /* return this in flags to dlz_version() if thread safe */
36 #define DNS_SDLZFLAG_THREADSAFE 0x00000001U
38 /* result codes */
39 #define ISC_R_SUCCESS 0
40 #define ISC_R_NOMEMORY 1
41 #define ISC_R_NOPERM 6
42 #define ISC_R_NOTFOUND 23
43 #define ISC_R_FAILURE 25
44 #define ISC_R_NOMORE 29
46 /* boolean values */
47 #define ISC_TRUE 1
48 #define ISC_FALSE 0
50 /* log levels */
51 #define ISC_LOG_INFO (-1)
52 #define ISC_LOG_NOTICE (-2)
53 #define ISC_LOG_WARNING (-3)
54 #define ISC_LOG_ERROR (-4)
55 #define ISC_LOG_CRITICAL (-5)
57 /* some opaque structures */
58 typedef void *dns_sdlzlookup_t;
59 typedef void *dns_sdlzallnodes_t;
60 typedef void *dns_view_t;
61 typedef void *dns_clientinfomethods_t;
62 typedef void *dns_clientinfo_t;
65 * method definitions for callbacks provided by dlopen driver
68 typedef void log_t(int level, const char *fmt, ...);
70 typedef isc_result_t dns_sdlz_putrr_t(dns_sdlzlookup_t *lookup,
71 const char *type,
72 dns_ttl_t ttl,
73 const char *data);
75 typedef isc_result_t dns_sdlz_putnamedrr_t(dns_sdlzallnodes_t *allnodes,
76 const char *name,
77 const char *type,
78 dns_ttl_t ttl,
79 const char *data);
81 typedef isc_result_t dns_dlz_writeablezone_t(dns_view_t *view,
82 const char *zone_name);
86 * prototypes for the functions you can include in your driver
91 * dlz_version() is required for all DLZ external drivers. It should
92 * return DLZ_DLOPEN_VERSION
94 int dlz_version(unsigned int *flags);
97 * dlz_create() is required for all DLZ external drivers.
99 isc_result_t dlz_create(const char *dlzname, unsigned int argc, const char **argv, void **dbdata, ...);
102 * dlz_destroy() is optional, and will be called when the driver is
103 * unloaded if supplied
105 void dlz_destroy(void *dbdata);
108 dlz_findzonedb is required for all DLZ external drivers
110 isc_result_t dlz_findzonedb(void *dbdata, const char *name);
113 dlz_lookup is required for all DLZ external drivers
115 #ifdef BIND_VERSION_9_8
116 isc_result_t dlz_lookup(const char *zone, const char *name,
117 void *dbdata, dns_sdlzlookup_t *lookup);
118 #else
119 isc_result_t dlz_lookup(const char *zone, const char *name,
120 void *dbdata, dns_sdlzlookup_t *lookup,
121 dns_clientinfomethods_t *methods,
122 dns_clientinfo_t *clientinfo);
123 #endif
126 dlz_allowzonexfr() is optional, and should be supplied if you want
127 to support zone transfers
129 isc_result_t dlz_allowzonexfr(void *dbdata, const char *name, const char *client);
133 dlz_allnodes() is optional, but must be supplied if supply a
134 dlz_allowzonexfr() function
136 isc_result_t dlz_allnodes(const char *zone, void *dbdata, dns_sdlzallnodes_t *allnodes);
139 dlz_newversion() is optional. It should be supplied if you want to
140 support dynamic updates.
142 isc_result_t dlz_newversion(const char *zone, void *dbdata, void **versionp);
145 dlz_closeversion() is optional, but must be supplied if you supply
146 a dlz_newversion() function
148 void dlz_closeversion(const char *zone, isc_boolean_t commit, void *dbdata, void **versionp);
151 dlz_configure() is optional, but must be supplied if you want to
152 support dynamic updates
154 isc_result_t dlz_configure(dns_view_t *view, void *dbdata);
157 dlz_ssumatch() is optional, but must be supplied if you want to
158 support dynamic updates
160 isc_boolean_t dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,
161 const char *type, const char *key, uint32_t keydatalen, uint8_t *keydata,
162 void *dbdata);
165 dlz_addrdataset() is optional, but must be supplied if you want to
166 support dynamic updates
168 isc_result_t dlz_addrdataset(const char *name, const char *rdatastr, void *dbdata, void *version);
171 dlz_subrdataset() is optional, but must be supplied if you want to
172 support dynamic updates
174 isc_result_t dlz_subrdataset(const char *name, const char *rdatastr, void *dbdata, void *version);
177 dlz_delrdataset() is optional, but must be supplied if you want to
178 support dynamic updates
180 isc_result_t dlz_delrdataset(const char *name, const char *type, void *dbdata, void *version);