1 /*
2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3  *
4  * SPDX-License-Identifier: MPL-2.0
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
9  *
10  * See the COPYRIGHT file distributed with this work for additional
11  * information regarding copyright ownership.
12  */
13 
14 /*! \file dns/dlz_dlopen.h */
15 
16 #ifndef DLZ_DLOPEN_H
17 #define DLZ_DLOPEN_H
18 
19 #include <inttypes.h>
20 #include <stdbool.h>
21 
22 #include <dns/sdlz.h>
23 
24 ISC_LANG_BEGINDECLS
25 
26 /*
27  * This header provides a minimal set of defines and typedefs needed
28  * for the entry points of an external DLZ module for bind9.
29  */
30 
31 #define DLZ_DLOPEN_VERSION 3
32 #define DLZ_DLOPEN_AGE	   0
33 
34 /*
35  * dlz_dlopen_version() is required for all DLZ external drivers. It
36  * should return DLZ_DLOPEN_VERSION
37  */
38 typedef int
39 dlz_dlopen_version_t(unsigned int *flags);
40 
41 /*
42  * dlz_dlopen_create() is required for all DLZ external drivers.
43  */
44 typedef isc_result_t
45 dlz_dlopen_create_t(const char *dlzname, unsigned int argc, char *argv[],
46 		    void **dbdata, ...);
47 
48 /*
49  * dlz_dlopen_destroy() is optional, and will be called when the
50  * driver is unloaded if supplied
51  */
52 typedef void
53 dlz_dlopen_destroy_t(void *dbdata);
54 
55 /*
56  * dlz_dlopen_findzonedb() is required for all DLZ external drivers
57  */
58 typedef isc_result_t
59 dlz_dlopen_findzonedb_t(void *dbdata, const char *name,
60 			dns_clientinfomethods_t *methods,
61 			dns_clientinfo_t	 *clientinfo);
62 
63 /*
64  * dlz_dlopen_lookup() is required for all DLZ external drivers
65  */
66 typedef isc_result_t
67 dlz_dlopen_lookup_t(const char *zone, const char *name, void *dbdata,
68 		    dns_sdlzlookup_t *lookup, dns_clientinfomethods_t *methods,
69 		    dns_clientinfo_t *clientinfo);
70 
71 /*
72  * dlz_dlopen_authority is optional() if dlz_dlopen_lookup()
73  * supplies authority information for the dns record
74  */
75 typedef isc_result_t
76 dlz_dlopen_authority_t(const char *zone, void *dbdata,
77 		       dns_sdlzlookup_t *lookup);
78 
79 /*
80  * dlz_dlopen_allowzonexfr() is optional, and should be supplied if
81  * you want to support zone transfers
82  */
83 typedef isc_result_t
84 dlz_dlopen_allowzonexfr_t(void *dbdata, const char *name, const char *client);
85 
86 /*
87  * dlz_dlopen_allnodes() is optional, but must be supplied if supply a
88  * dlz_dlopen_allowzonexfr() function
89  */
90 typedef isc_result_t
91 dlz_dlopen_allnodes_t(const char *zone, void *dbdata,
92 		      dns_sdlzallnodes_t *allnodes);
93 
94 /*
95  * dlz_dlopen_newversion() is optional. It should be supplied if you
96  * want to support dynamic updates.
97  */
98 typedef isc_result_t
99 dlz_dlopen_newversion_t(const char *zone, void *dbdata, void **versionp);
100 
101 /*
102  * dlz_closeversion() is optional, but must be supplied if you supply
103  * a dlz_newversion() function
104  */
105 typedef void
106 dlz_dlopen_closeversion_t(const char *zone, bool commit, void *dbdata,
107 			  void **versionp);
108 
109 /*
110  * dlz_dlopen_configure() is optional, but must be supplied if you
111  * want to support dynamic updates
112  */
113 typedef isc_result_t
114 dlz_dlopen_configure_t(dns_view_t *view, dns_dlzdb_t *dlzdb, void *dbdata);
115 
116 /*
117  * dlz_dlopen_setclientcallback() is optional, but must be supplied if you
118  * want to retrieve information about the client (e.g., source address)
119  * before sending a replay.
120  */
121 typedef isc_result_t
122 dlz_dlopen_setclientcallback_t(dns_view_t *view, void *dbdata);
123 
124 /*
125  * dlz_dlopen_ssumatch() is optional, but must be supplied if you want
126  * to support dynamic updates
127  */
128 typedef bool
129 dlz_dlopen_ssumatch_t(const char *signer, const char *name, const char *tcpaddr,
130 		      const char *type, const char *key, uint32_t keydatalen,
131 		      unsigned char *keydata, void *dbdata);
132 
133 /*
134  * dlz_dlopen_addrdataset() is optional, but must be supplied if you
135  * want to support dynamic updates
136  */
137 typedef isc_result_t
138 dlz_dlopen_addrdataset_t(const char *name, const char *rdatastr, void *dbdata,
139 			 void *version);
140 
141 /*
142  * dlz_dlopen_subrdataset() is optional, but must be supplied if you
143  * want to support dynamic updates
144  */
145 typedef isc_result_t
146 dlz_dlopen_subrdataset_t(const char *name, const char *rdatastr, void *dbdata,
147 			 void *version);
148 
149 /*
150  * dlz_dlopen_delrdataset() is optional, but must be supplied if you
151  * want to support dynamic updates
152  */
153 typedef isc_result_t
154 dlz_dlopen_delrdataset_t(const char *name, const char *type, void *dbdata,
155 			 void *version);
156 
157 ISC_LANG_ENDDECLS
158 
159 #endif /* ifndef DLZ_DLOPEN_H */
160