1 /* $NetBSD: dlz_minimal.h,v 1.1.1.3 2014/12/10 03:34:31 christos Exp $ */
4 * Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the
8 * above copyright notice and this permission notice appear in all
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
12 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
14 * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
15 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
16 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
17 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
18 * USE OR PERFORMANCE OF THIS SOFTWARE.
22 * This header provides a minimal set of defines and typedefs needed
23 * for building an external DLZ module for bind9. When creating a new
24 * external DLZ driver, please copy this header into your own source
29 #define DLZ_MINIMAL_H 1
31 #include <sys/types.h>
32 #include <sys/socket.h>
33 #ifdef ISC_PLATFORM_HAVESYSUNH
37 #include <netinet/in.h>
38 #include <arpa/inet.h>
40 typedef unsigned int isc_result_t
;
41 typedef int isc_boolean_t
;
42 typedef uint32_t dns_ttl_t
;
45 * Define DLZ_DLOPEN_VERSION to different values to use older versions
48 #ifndef DLZ_DLOPEN_VERSION
49 #define DLZ_DLOPEN_VERSION 3
50 #define DLZ_DLOPEN_AGE 0
53 /* return these in flags from dlz_version() */
54 #define DNS_SDLZFLAG_THREADSAFE 0x00000001U
55 #define DNS_SDLZFLAG_RELATIVEOWNER 0x00000002U
56 #define DNS_SDLZFLAG_RELATIVERDATA 0x00000004U
59 #define ISC_R_SUCCESS 0
60 #define ISC_R_NOMEMORY 1
61 #define ISC_R_NOPERM 6
62 #define ISC_R_NOSPACE 19
63 #define ISC_R_NOTFOUND 23
64 #define ISC_R_FAILURE 25
65 #define ISC_R_NOTIMPLEMENTED 27
66 #define ISC_R_NOMORE 29
67 #define ISC_R_INVALIDFILE 30
68 #define ISC_R_UNEXPECTED 34
69 #define ISC_R_FILENOTFOUND 38
76 #define ISC_LOG_INFO (-1)
77 #define ISC_LOG_NOTICE (-2)
78 #define ISC_LOG_WARNING (-3)
79 #define ISC_LOG_ERROR (-4)
80 #define ISC_LOG_CRITICAL (-5)
81 #define ISC_LOG_DEBUG(level) (level)
83 /* other useful definitions */
84 #define UNUSED(x) (void)(x)
86 /* opaque structures */
87 typedef void *dns_sdlzlookup_t
;
88 typedef void *dns_sdlzallnodes_t
;
89 typedef void *dns_view_t
;
90 typedef void *dns_dlzdb_t
;
92 #if DLZ_DLOPEN_VERSION > 1
94 * Method and type definitions needed for retrieval of client info
97 typedef struct isc_sockaddr
{
100 struct sockaddr_in sin
;
101 struct sockaddr_in6 sin6
;
102 #ifdef ISC_PLATFORM_HAVESYSUNH
103 struct sockaddr_un sunix
;
110 #define DNS_CLIENTINFO_VERSION 1
111 typedef struct dns_clientinfo
{
116 typedef isc_result_t (*dns_clientinfo_sourceip_t
)(dns_clientinfo_t
*client
,
117 isc_sockaddr_t
**addrp
);
119 #define DNS_CLIENTINFOMETHODS_VERSION 1
120 #define DNS_CLIENTINFOMETHODS_AGE 0
122 typedef struct dns_clientinfomethods
{
125 dns_clientinfo_sourceip_t sourceip
;
126 } dns_clientinfomethods_t
;
127 #endif /* DLZ_DLOPEN_VERSION > 1 */
130 * Method definitions for callbacks provided by the dlopen driver
132 typedef void log_t(int level
, const char *fmt
, ...);
134 typedef isc_result_t
dns_sdlz_putrr_t(dns_sdlzlookup_t
*lookup
,
139 typedef isc_result_t
dns_sdlz_putnamedrr_t(dns_sdlzallnodes_t
*allnodes
,
145 #if DLZ_DLOPEN_VERSION < 3
146 typedef isc_result_t
dns_dlz_writeablezone_t(dns_view_t
*view
,
147 const char *zone_name
);
148 #else /* DLZ_DLOPEN_VERSION >= 3 */
149 typedef isc_result_t
dns_dlz_writeablezone_t(dns_view_t
*view
,
151 const char *zone_name
);
152 #endif /* DLZ_DLOPEN_VERSION */
155 * prototypes for the functions you can include in your module
159 * dlz_version() is required for all DLZ external drivers. It should
160 * return DLZ_DLOPEN_VERSION. 'flags' is updated to indicate capabilities
161 * of the module. In particular, if the module is thread-safe then it
162 * sets 'flags' to include DNS_SDLZFLAG_THREADSAFE. Other capability
163 * flags may be added in the future.
166 dlz_version(unsigned int *flags
);
169 * dlz_create() is required for all DLZ external drivers.
172 dlz_create(const char *dlzname
, unsigned int argc
, char *argv
[],
176 * dlz_destroy() is optional, and will be called when the driver is
177 * unloaded if supplied
180 dlz_destroy(void *dbdata
);
183 * dlz_findzonedb is required for all DLZ external drivers
185 #if DLZ_DLOPEN_VERSION < 3
187 dlz_findzonedb(void *dbdata
, const char *name
);
188 #else /* DLZ_DLOPEN_VERSION >= 3 */
190 dlz_findzonedb(void *dbdata
, const char *name
,
191 dns_clientinfomethods_t
*methods
,
192 dns_clientinfo_t
*clientinfo
);
193 #endif /* DLZ_DLOPEN_VERSION */
196 * dlz_lookup is required for all DLZ external drivers
198 #if DLZ_DLOPEN_VERSION == 1
200 dlz_lookup(const char *zone
, const char *name
, void *dbdata
,
201 dns_sdlzlookup_t
*lookup
);
202 #else /* DLZ_DLOPEN_VERSION > 1 */
204 dlz_lookup(const char *zone
, const char *name
, void *dbdata
,
205 dns_sdlzlookup_t
*lookup
,
206 dns_clientinfomethods_t
*methods
,
207 dns_clientinfo_t
*clientinfo
);
208 #endif /* DLZ_DLOPEN_VERSION */
211 * dlz_authority() is optional if dlz_lookup() supplies
212 * authority information (i.e., SOA, NS) for the dns record
215 dlz_authority(const char *zone
, void *dbdata
, dns_sdlzlookup_t
*lookup
);
218 * dlz_allowzonexfr() is optional, and should be supplied if you want to
219 * support zone transfers
222 dlz_allowzonexfr(void *dbdata
, const char *name
, const char *client
);
225 * dlz_allnodes() is optional, but must be supplied if supply a
226 * dlz_allowzonexfr() function
229 dlz_allnodes(const char *zone
, void *dbdata
, dns_sdlzallnodes_t
*allnodes
);
232 * dlz_newversion() is optional. It should be supplied if you want to
233 * support dynamic updates.
236 dlz_newversion(const char *zone
, void *dbdata
, void **versionp
);
239 * dlz_closeversion() is optional, but must be supplied if you supply a
240 * dlz_newversion() function
243 dlz_closeversion(const char *zone
, isc_boolean_t commit
, void *dbdata
,
247 * dlz_configure() is optional, but must be supplied if you want to support
250 #if DLZ_DLOPEN_VERSION < 3
252 dlz_configure(dns_view_t
*view
, void *dbdata
);
253 #else /* DLZ_DLOPEN_VERSION >= 3 */
255 dlz_configure(dns_view_t
*view
, dns_dlzdb_t
*dlzdb
, void *dbdata
);
256 #endif /* DLZ_DLOPEN_VERSION */
259 * dlz_ssumatch() is optional, but must be supplied if you want to support
263 dlz_ssumatch(const char *signer
, const char *name
, const char *tcpaddr
,
264 const char *type
, const char *key
, uint32_t keydatalen
,
265 uint8_t *keydata
, void *dbdata
);
268 * dlz_addrdataset() is optional, but must be supplied if you want to
269 * support dynamic updates
272 dlz_addrdataset(const char *name
, const char *rdatastr
, void *dbdata
,
276 * dlz_subrdataset() is optional, but must be supplied if you want to
277 * support dynamic updates
280 dlz_subrdataset(const char *name
, const char *rdatastr
, void *dbdata
,
284 * dlz_delrdataset() is optional, but must be supplied if you want to
285 * support dynamic updates
288 dlz_delrdataset(const char *name
, const char *type
, void *dbdata
,
291 #endif /* DLZ_MINIMAL_H */