s4-dns: Update dlz_minimal.h based on BIND release 9.10
[obnox/samba/samba-obnox.git] / source4 / dns_server / dlz_minimal.h
1 /*
2  * Copyright (C) 2010 Andrew Tridgell
3  *
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.
8  *
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.
17  */
18
19 /* This header is updated based on BIND 9.10.1 source.
20  *    contrib/dlz/modules/include/dlz_minimal.h
21  */
22
23 #ifndef DLZ_MINIMAL_H
24 #define DLZ_MINIMAL_H 1
25
26 #ifdef BIND_VERSION_9_8
27 #define DLZ_DLOPEN_VERSION 1
28 #elif BIND_VERSION_9_9
29 #define DLZ_DLOPEN_VERSION 2
30 #elif BIND_VERSION_9_10
31 #define DLZ_DLOPEN_VERSION 3
32 #define DLZ_DLOPEN_AGE 0
33 #else
34 #error Unsupported BIND version
35 #endif
36
37 typedef unsigned int isc_result_t;
38 #if DLZ_DLOPEN_VERSION == 1
39 typedef bool isc_boolean_t;
40 #else
41 typedef int isc_boolean_t;
42 #endif
43 typedef uint32_t dns_ttl_t;
44
45 /* return these in flags from dlz_version() */
46 #define DNS_SDLZFLAG_THREADSAFE         0x00000001U
47 #define DNS_SDLZFLAG_RELATIVEOWNER      0x00000002U
48 #define DNS_SDLZFLAG_RELATIVERDATA      0x00000004U
49
50 /* result codes */
51 #define ISC_R_SUCCESS                   0
52 #define ISC_R_NOMEMORY                  1
53 #define ISC_R_NOPERM                    6
54 #define ISC_R_NOSPACE                   19
55 #define ISC_R_NOTFOUND                  23
56 #define ISC_R_FAILURE                   25
57 #define ISC_R_NOTIMPLEMENTED            27
58 #define ISC_R_NOMORE                    29
59 #define ISC_R_INVALIDFILE               30
60 #define ISC_R_UNEXPECTED                34
61 #define ISC_R_FILENOTFOUND              38
62
63 /* boolean values */
64 #define ISC_TRUE        1
65 #define ISC_FALSE       0
66
67 /* log levels */
68 #define ISC_LOG_INFO            (-1)
69 #define ISC_LOG_NOTICE          (-2)
70 #define ISC_LOG_WARNING         (-3)
71 #define ISC_LOG_ERROR           (-4)
72 #define ISC_LOG_CRITICAL        (-5)
73 #define ISC_LOG_DEBUG(level)    (level)
74
75 /* opaque structures */
76 typedef void *dns_sdlzlookup_t;
77 typedef void *dns_sdlzallnodes_t;
78 typedef void *dns_view_t;
79 typedef void *dns_dlzdb_t;
80
81 #if DLZ_DLOPEN_VERSION > 1
82 /*
83  * Method and type definitions needed for retrieval of client info
84  * from the caller.
85  */
86 typedef struct isc_sockaddr {
87         union {
88                 struct sockaddr         sa;
89                 struct sockaddr_in      sin;
90                 struct sockaddr_in6     sin6;
91                 struct sockaddr_un      sunix;
92         }                               type;
93         unsigned int                    length;
94         void *                          link;
95 } isc_sockaddr_t;
96
97 #define DNS_CLIENTINFO_VERSION 1
98 typedef struct dns_clientinfo {
99         uint16_t version;
100         void *data;
101 } dns_clientinfo_t;
102
103 typedef isc_result_t (*dns_clientinfo_sourceip_t)(dns_clientinfo_t *client,
104                                                   isc_sockaddr_t **addrp);
105
106 #define DNS_CLIENTINFOMETHODS_VERSION 1
107 #define DNS_CLIENTINFOMETHODS_AGE 0
108
109 typedef struct dns_clientinfomethods {
110         uint16_t version;
111         uint16_t age;
112         dns_clientinfo_sourceip_t sourceip;
113 } dns_clientinfomethods_t;
114 #endif /* DLZ_DLOPEN_VERSION > 1 */
115
116 /*
117  * Method definitions for callbacks provided by the dlopen driver
118  */
119
120 typedef void log_t(int level, const char *fmt, ...);
121
122 typedef isc_result_t dns_sdlz_putrr_t(dns_sdlzlookup_t *lookup,
123                                       const char *type,
124                                       dns_ttl_t ttl,
125                                       const char *data);
126
127 typedef isc_result_t dns_sdlz_putnamedrr_t(dns_sdlzallnodes_t *allnodes,
128                                            const char *name,
129                                            const char *type,
130                                            dns_ttl_t ttl,
131                                            const char *data);
132
133 #if DLZ_DLOPEN_VERSION < 3
134 typedef isc_result_t dns_dlz_writeablezone_t(dns_view_t *view,
135                                              const char *zone_name);
136 #else /* DLZ_DLOPEN_VERSION >= 3 */
137 typedef isc_result_t dns_dlz_writeablezone_t(dns_view_t *view,
138                                              dns_dlzdb_t *dlzdb,
139                                              const char *zone_name);
140 #endif /* DLZ_DLOPEN_VERSION */
141
142 /*
143  * prototypes for the functions you can include in your module
144  */
145
146 /*
147  * dlz_version() is required for all DLZ external drivers. It should
148  * return DLZ_DLOPEN_VERSION.  'flags' is updated to indicate capabilities
149  * of the module.  In particular, if the module is thread-safe then it
150  * sets 'flags' to include DNS_SDLZFLAG_THREADSAFE.  Other capability
151  * flags may be added in the future.
152  */
153 int
154 dlz_version(unsigned int *flags);
155
156 /*
157  * dlz_create() is required for all DLZ external drivers.
158  */
159 isc_result_t
160 dlz_create(const char *dlzname, unsigned int argc, const char *argv[],
161            void **dbdata, ...);
162
163 /*
164  * dlz_destroy() is optional, and will be called when the driver is
165  * unloaded if supplied
166  */
167 void
168 dlz_destroy(void *dbdata);
169
170 /*
171  * dlz_findzonedb is required for all DLZ external drivers
172  */
173 #if DLZ_DLOPEN_VERSION < 3
174 isc_result_t
175 dlz_findzonedb(void *dbdata, const char *name);
176 #else /* DLZ_DLOPEN_VERSION >= 3 */
177 isc_result_t
178 dlz_findzonedb(void *dbdata, const char *name,
179                dns_clientinfomethods_t *methods,
180                dns_clientinfo_t *clientinfo);
181 #endif /* DLZ_DLOPEN_VERSION */
182
183 /*
184  * dlz_lookup is required for all DLZ external drivers
185  */
186 #if DLZ_DLOPEN_VERSION == 1
187 isc_result_t
188 dlz_lookup(const char *zone, const char *name, void *dbdata,
189            dns_sdlzlookup_t *lookup);
190 #else /* DLZ_DLOPEN_VERSION > 1 */
191 isc_result_t
192 dlz_lookup(const char *zone, const char *name, void *dbdata,
193            dns_sdlzlookup_t *lookup,
194            dns_clientinfomethods_t *methods,
195            dns_clientinfo_t *clientinfo);
196 #endif /* DLZ_DLOPEN_VERSION */
197
198 /*
199  * dlz_authority() is optional if dlz_lookup() supplies
200  * authority information (i.e., SOA, NS) for the dns record
201  */
202 isc_result_t
203 dlz_authority(const char *zone, void *dbdata, dns_sdlzlookup_t *lookup);
204
205 /*
206  * dlz_allowzonexfr() is optional, and should be supplied if you want to
207  * support zone transfers
208  */
209 isc_result_t
210 dlz_allowzonexfr(void *dbdata, const char *name, const char *client);
211
212 /*
213  * dlz_allnodes() is optional, but must be supplied if supply a
214  * dlz_allowzonexfr() function
215  */
216 isc_result_t
217 dlz_allnodes(const char *zone, void *dbdata, dns_sdlzallnodes_t *allnodes);
218
219 /*
220  * dlz_newversion() is optional. It should be supplied if you want to
221  * support dynamic updates.
222  */
223 isc_result_t
224 dlz_newversion(const char *zone, void *dbdata, void **versionp);
225
226 /* 
227  * dlz_closeversion() is optional, but must be supplied if you supply a
228  * dlz_newversion() function
229  */
230 void
231 dlz_closeversion(const char *zone, isc_boolean_t commit, void *dbdata,
232                  void **versionp);
233
234 /*
235  * dlz_configure() is optional, but must be supplied if you want to support
236  * dynamic updates
237  */
238 #if DLZ_DLOPEN_VERSION < 3
239 isc_result_t
240 dlz_configure(dns_view_t *view, void *dbdata);
241 #else /* DLZ_DLOPEN_VERSION >= 3 */
242 isc_result_t
243 dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb, void *dbdata);
244 #endif /* DLZ_DLOPEN_VERSION */
245
246 /*
247  * dlz_ssumatch() is optional, but must be supplied if you want to support
248  * dynamic updates
249  */
250 isc_boolean_t
251 dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,
252              const char *type, const char *key, uint32_t keydatalen,
253              uint8_t *keydata, void *dbdata);
254
255 /*
256  * dlz_addrdataset() is optional, but must be supplied if you want to
257  * support dynamic updates
258  */
259 isc_result_t
260 dlz_addrdataset(const char *name, const char *rdatastr, void *dbdata,
261                 void *version);
262
263 /*
264  * dlz_subrdataset() is optional, but must be supplied if you want to
265  * support dynamic updates
266  */
267 isc_result_t
268 dlz_subrdataset(const char *name, const char *rdatastr, void *dbdata,
269                 void *version);
270
271 /*
272  * dlz_delrdataset() is optional, but must be supplied if you want to
273  * support dynamic updates
274  */
275 isc_result_t
276 dlz_delrdataset(const char *name, const char *type, void *dbdata,
277                 void *version);
278
279 #endif /* DLZ_MINIMAL_H */