summaryrefslogtreecommitdiffstats
path: root/source4/dns_server/dlz_minimal.h
blob: b7e36e7f8e6571667895afbf8779f130d8e5c3c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
/*
 * Copyright (C) 2010 Andrew Tridgell
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the
 * above copyright notice and this permission notice appear in all
 * copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
 * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
 * USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/* This header is updated based on BIND 9.10.1 source.
 *    contrib/dlz/modules/include/dlz_minimal.h
 */

#ifndef DLZ_MINIMAL_H
#define DLZ_MINIMAL_H 1

#include <stdint.h>
#include <stdbool.h>

#if defined (BIND_VERSION_9_8)
# error Bind 9.8 is not supported!
#elif defined (BIND_VERSION_9_9)
# error Bind 9.9 is not supported!
#elif defined (BIND_VERSION_9_10)
# define DLZ_DLOPEN_VERSION 3
# define DNS_CLIENTINFO_VERSION 1
# define ISC_BOOLEAN_AS_BOOL 0
#elif defined (BIND_VERSION_9_11)
# define DLZ_DLOPEN_VERSION 3
# define DNS_CLIENTINFO_VERSION 2
# define ISC_BOOLEAN_AS_BOOL 0
#elif defined (BIND_VERSION_9_12)
# define DLZ_DLOPEN_VERSION 3
# define DNS_CLIENTINFO_VERSION 2
# define ISC_BOOLEAN_AS_BOOL 0
#elif defined (BIND_VERSION_9_14)
# define DLZ_DLOPEN_VERSION 3
# define DNS_CLIENTINFO_VERSION 2
#elif defined (BIND_VERSION_9_16)
# define DLZ_DLOPEN_VERSION 3
# define DNS_CLIENTINFO_VERSION 2
#elif defined (BIND_VERSION_9_18)
# define DLZ_DLOPEN_VERSION 3
# define DNS_CLIENTINFO_VERSION 2
#else
# error Unsupported BIND version
#endif

#ifndef ISC_BOOLEAN_AS_BOOL
#define ISC_BOOLEAN_AS_BOOL 1
#endif

# define DLZ_DLOPEN_AGE 0

typedef unsigned int isc_result_t;
#if ISC_BOOLEAN_AS_BOOL == 1
typedef bool isc_boolean_t;
#else
typedef int isc_boolean_t;
#endif
typedef uint32_t dns_ttl_t;

/* return these in flags from dlz_version() */
#define DNS_SDLZFLAG_THREADSAFE		0x00000001U
#define DNS_SDLZFLAG_RELATIVEOWNER	0x00000002U
#define DNS_SDLZFLAG_RELATIVERDATA	0x00000004U

/* result codes */
#define ISC_R_SUCCESS			0
#define ISC_R_NOMEMORY			1
#define ISC_R_NOPERM			6
#define ISC_R_NOSPACE			19
#define ISC_R_NOTFOUND			23
#define ISC_R_FAILURE			25
#define ISC_R_NOTIMPLEMENTED		27
#define ISC_R_NOMORE			29
#define ISC_R_INVALIDFILE		30
#define ISC_R_UNEXPECTED		34
#define ISC_R_FILENOTFOUND		38

/* boolean values */
#if ISC_BOOLEAN_AS_BOOL == 1
#define ISC_TRUE	true
#define ISC_FALSE	false
#else
#define ISC_TRUE	1
#define ISC_FALSE	0
#endif

/* log levels */
#define ISC_LOG_INFO		(-1)
#define ISC_LOG_NOTICE		(-2)
#define ISC_LOG_WARNING 	(-3)
#define ISC_LOG_ERROR		(-4)
#define ISC_LOG_CRITICAL	(-5)
#define ISC_LOG_DEBUG(level)	(level)

/* opaque structures */
typedef void *dns_sdlzlookup_t;
typedef void *dns_sdlzallnodes_t;
typedef void *dns_view_t;
typedef void *dns_dlzdb_t;

/*
 * Method and type definitions needed for retrieval of client info
 * from the caller.
 */
typedef struct isc_sockaddr {
	union {
		struct sockaddr         sa;
		struct sockaddr_in      sin;
		struct sockaddr_in6     sin6;
		struct sockaddr_un      sunix;
	}                               type;
	unsigned int                    length;
	void *                          link;
} isc_sockaddr_t;

#if DNS_CLIENTINFO_VERSION == 1

typedef struct dns_clientinfo {
	uint16_t version;
	void *data;
} dns_clientinfo_t;

typedef isc_result_t (*dns_clientinfo_sourceip_t)(dns_clientinfo_t *client,
						  isc_sockaddr_t **addrp);

#define DNS_CLIENTINFOMETHODS_VERSION 1
#define DNS_CLIENTINFOMETHODS_AGE 0

typedef struct dns_clientinfomethods {
	uint16_t version;
	uint16_t age;
	dns_clientinfo_sourceip_t sourceip;
} dns_clientinfomethods_t;

#elif DNS_CLIENTINFO_VERSION == 2

typedef struct dns_clientinfo {
	uint16_t version;
	void *data;
	void *dbversion;
} dns_clientinfo_t;

typedef isc_result_t (*dns_clientinfo_sourceip_t)(dns_clientinfo_t *client,
						  isc_sockaddr_t **addrp);

typedef isc_result_t (*dns_clientinfo_version_t)(dns_clientinfo_t *client,
						 void **addrp);

#define DNS_CLIENTINFOMETHODS_VERSION 2
#define DNS_CLIENTINFOMETHODS_AGE 1

typedef struct dns_clientinfomethods {
	uint16_t version;
	uint16_t age;
	dns_clientinfo_sourceip_t sourceip;
	dns_clientinfo_version_t dbversion;
} dns_clientinfomethods_t;

#endif /* DNS_CLIENTINFO_VERSION */


/*
 * Method definitions for callbacks provided by the dlopen driver
 */

typedef void log_t(int level, const char *fmt, ...);

typedef isc_result_t dns_sdlz_putrr_t(dns_sdlzlookup_t *lookup,
				      const char *type,
				      dns_ttl_t ttl,
				      const char *data);

typedef isc_result_t dns_sdlz_putnamedrr_t(dns_sdlzallnodes_t *allnodes,
					   const char *name,
					   const char *type,
					   dns_ttl_t ttl,
					   const char *data);

typedef isc_result_t dns_dlz_writeablezone_t(dns_view_t *view,
					     dns_dlzdb_t *dlzdb,
					     const char *zone_name);


/*
 * prototypes for the functions you can include in your module
 */

/*
 * dlz_version() is required for all DLZ external drivers. It should
 * return DLZ_DLOPEN_VERSION.  'flags' is updated to indicate capabilities
 * of the module.  In particular, if the module is thread-safe then it
 * sets 'flags' to include DNS_SDLZFLAG_THREADSAFE.  Other capability
 * flags may be added in the future.
 */
int
dlz_version(unsigned int *flags);

/*
 * dlz_create() is required for all DLZ external drivers.
 */
isc_result_t
dlz_create(const char *dlzname, unsigned int argc, const char *argv[],
	   void **dbdata, ...);

/*
 * dlz_destroy() is optional, and will be called when the driver is
 * unloaded if supplied
 */
void
dlz_destroy(void *dbdata);

/*
 * dlz_findzonedb is required for all DLZ external drivers
 */
isc_result_t
dlz_findzonedb(void *dbdata, const char *name,
	       dns_clientinfomethods_t *methods,
	       dns_clientinfo_t *clientinfo);

/*
 * dlz_lookup is required for all DLZ external drivers
 */
isc_result_t
dlz_lookup(const char *zone, const char *name, void *dbdata,
	   dns_sdlzlookup_t *lookup,
	   dns_clientinfomethods_t *methods,
	   dns_clientinfo_t *clientinfo);

/*
 * dlz_authority() is optional if dlz_lookup() supplies
 * authority information (i.e., SOA, NS) for the dns record
 */
isc_result_t
dlz_authority(const char *zone, void *dbdata, dns_sdlzlookup_t *lookup);

/*
 * dlz_allowzonexfr() is optional, and should be supplied if you want to
 * support zone transfers
 */
isc_result_t
dlz_allowzonexfr(void *dbdata, const char *name, const char *client);

/*
 * dlz_allnodes() is optional, but must be supplied if supply a
 * dlz_allowzonexfr() function
 */
isc_result_t
dlz_allnodes(const char *zone, void *dbdata, dns_sdlzallnodes_t *allnodes);

/*
 * dlz_newversion() is optional. It should be supplied if you want to
 * support dynamic updates.
 */
isc_result_t
dlz_newversion(const char *zone, void *dbdata, void **versionp);

/* 
 * dlz_closeversion() is optional, but must be supplied if you supply a
 * dlz_newversion() function
 */
void
dlz_closeversion(const char *zone, isc_boolean_t commit, void *dbdata,
		 void **versionp);

/*
 * dlz_configure() is optional, but must be supplied if you want to support
 * dynamic updates
 */
isc_result_t
dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb, void *dbdata);

/*
 * dlz_ssumatch() is optional, but must be supplied if you want to support
 * dynamic updates
 */
isc_boolean_t
dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,
	     const char *type, const char *key, uint32_t keydatalen,
	     uint8_t *keydata, void *dbdata);

/*
 * dlz_addrdataset() is optional, but must be supplied if you want to
 * support dynamic updates
 */
isc_result_t
dlz_addrdataset(const char *name, const char *rdatastr, void *dbdata,
		void *version);

/*
 * dlz_subrdataset() is optional, but must be supplied if you want to
 * support dynamic updates
 */
isc_result_t
dlz_subrdataset(const char *name, const char *rdatastr, void *dbdata,
		void *version);

/*
 * dlz_delrdataset() is optional, but must be supplied if you want to
 * support dynamic updates
 */
isc_result_t
dlz_delrdataset(const char *name, const char *type, void *dbdata,
		void *version);

#endif /* DLZ_MINIMAL_H */