bind - Upgraded vendor branch to 9.5.2-P1
[dragonfly.git] / contrib / bind-9.5.2 / bin / named / include / named / server.h
1 /*
2  * Copyright (C) 2004-2009  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2003  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: server.h,v 1.88.10.7 2009/07/11 04:28:14 marka Exp $ */
19
20 #ifndef NAMED_SERVER_H
21 #define NAMED_SERVER_H 1
22
23 /*! \file */
24
25 #include <isc/log.h>
26 #include <isc/magic.h>
27 #include <isc/quota.h>
28 #include <isc/sockaddr.h>
29 #include <isc/types.h>
30 #include <isc/xml.h>
31
32 #include <dns/acl.h>
33 #include <dns/types.h>
34
35 #include <named/types.h>
36
37 #define NS_EVENTCLASS           ISC_EVENTCLASS(0x4E43)
38 #define NS_EVENT_RELOAD         (NS_EVENTCLASS + 0)
39 #define NS_EVENT_CLIENTCONTROL  (NS_EVENTCLASS + 1)
40
41 /*%
42  * Name server state.  Better here than in lots of separate global variables.
43  */
44 struct ns_server {
45         unsigned int            magic;
46         isc_mem_t *             mctx;
47
48         isc_task_t *            task;
49
50         /* Configurable data. */
51         isc_quota_t             xfroutquota;
52         isc_quota_t             tcpquota;
53         isc_quota_t             recursionquota;
54         dns_acl_t               *blackholeacl;
55         char *                  statsfile;      /*%< Statistics file name */
56         char *                  dumpfile;       /*%< Dump file name */
57         char *                  recfile;        /*%< Recursive file name */
58         isc_boolean_t           version_set;    /*%< User has set version */
59         char *                  version;        /*%< User-specified version */
60         isc_boolean_t           hostname_set;   /*%< User has set hostname */
61         char *                  hostname;       /*%< User-specified hostname */
62         /*% Use hostname for server id */
63         isc_boolean_t           server_usehostname;
64         char *                  server_id;      /*%< User-specified server id */
65
66         /*%
67          * Current ACL environment.  This defines the
68          * current values of the localhost and localnets
69          * ACLs.
70          */
71         dns_aclenv_t            aclenv;
72
73         /* Server data structures. */
74         dns_loadmgr_t *         loadmgr;
75         dns_zonemgr_t *         zonemgr;
76         dns_viewlist_t          viewlist;
77         ns_interfacemgr_t *     interfacemgr;
78         dns_db_t *              in_roothints;
79         dns_tkeyctx_t *         tkeyctx;
80
81         isc_timer_t *           interface_timer;
82         isc_timer_t *           heartbeat_timer;
83         isc_timer_t *           pps_timer;
84
85         isc_uint32_t            interface_interval;
86         isc_uint32_t            heartbeat_interval;
87
88         isc_mutex_t             reload_event_lock;
89         isc_event_t *           reload_event;
90
91         isc_boolean_t           flushonshutdown;
92         isc_boolean_t           log_queries;    /*%< For BIND 8 compatibility */
93
94         isc_stats_t *           nsstats;        /*%< Server statistics */
95         dns_stats_t *           rcvquerystats;  /*% Incoming query statistics */
96         dns_stats_t *           opcodestats;    /*%< Incoming message statistics */
97         isc_stats_t *           zonestats;      /*% Zone management statistics */
98         isc_stats_t *           resolverstats;  /*% Resolver statistics */
99
100         isc_stats_t *           sockstats;      /*%< Socket statistics */
101         ns_controls_t *         controls;       /*%< Control channels */
102         unsigned int            dispatchgen;
103         ns_dispatchlist_t       dispatches;
104
105         dns_acache_t            *acache;
106
107         ns_statschannellist_t   statschannels;
108 };
109
110 #define NS_SERVER_MAGIC                 ISC_MAGIC('S','V','E','R')
111 #define NS_SERVER_VALID(s)              ISC_MAGIC_VALID(s, NS_SERVER_MAGIC)
112
113 /*%
114  * Server statistics counters.  Used as isc_statscounter_t values.
115  */
116 enum {
117         dns_nsstatscounter_requestv4 = 0,
118         dns_nsstatscounter_requestv6 = 1,
119         dns_nsstatscounter_edns0in = 2,
120         dns_nsstatscounter_badednsver = 3,
121         dns_nsstatscounter_tsigin = 4,
122         dns_nsstatscounter_sig0in = 5,
123         dns_nsstatscounter_invalidsig = 6,
124         dns_nsstatscounter_tcp = 7,
125
126         dns_nsstatscounter_authrej = 8,
127         dns_nsstatscounter_recurserej = 9,
128         dns_nsstatscounter_xfrrej = 10,
129         dns_nsstatscounter_updaterej = 11,
130
131         dns_nsstatscounter_response = 12,
132         dns_nsstatscounter_truncatedresp = 13,
133         dns_nsstatscounter_edns0out = 14,
134         dns_nsstatscounter_tsigout = 15,
135         dns_nsstatscounter_sig0out = 16,
136
137         dns_nsstatscounter_success = 17,
138         dns_nsstatscounter_authans = 18,
139         dns_nsstatscounter_nonauthans = 19,
140         dns_nsstatscounter_referral = 20,
141         dns_nsstatscounter_nxrrset = 21,
142         dns_nsstatscounter_servfail = 22,
143         dns_nsstatscounter_formerr = 23,
144         dns_nsstatscounter_nxdomain = 24,
145         dns_nsstatscounter_recursion = 25,
146         dns_nsstatscounter_duplicate = 26,
147         dns_nsstatscounter_dropped = 27,
148         dns_nsstatscounter_failure = 28,
149
150         dns_nsstatscounter_xfrdone = 29,
151
152         dns_nsstatscounter_updatereqfwd = 30,
153         dns_nsstatscounter_updaterespfwd = 31,
154         dns_nsstatscounter_updatefwdfail = 32,
155         dns_nsstatscounter_updatedone = 33,
156         dns_nsstatscounter_updatefail = 34,
157         dns_nsstatscounter_updatebadprereq = 35,
158
159         dns_nsstatscounter_max = 36
160 };
161
162 void
163 ns_server_create(isc_mem_t *mctx, ns_server_t **serverp);
164 /*%<
165  * Create a server object with default settings.
166  * This function either succeeds or causes the program to exit
167  * with a fatal error.
168  */
169
170 void
171 ns_server_destroy(ns_server_t **serverp);
172 /*%<
173  * Destroy a server object, freeing its memory.
174  */
175
176 void
177 ns_server_reloadwanted(ns_server_t *server);
178 /*%<
179  * Inform a server that a reload is wanted.  This function
180  * may be called asynchronously, from outside the server's task.
181  * If a reload is already scheduled or in progress, the call
182  * is ignored.
183  */
184
185 void
186 ns_server_flushonshutdown(ns_server_t *server, isc_boolean_t flush);
187 /*%<
188  * Inform the server that the zones should be flushed to disk on shutdown.
189  */
190
191 isc_result_t
192 ns_server_reloadcommand(ns_server_t *server, char *args, isc_buffer_t *text);
193 /*%<
194  * Act on a "reload" command from the command channel.
195  */
196
197 isc_result_t
198 ns_server_reconfigcommand(ns_server_t *server, char *args);
199 /*%<
200  * Act on a "reconfig" command from the command channel.
201  */
202
203 isc_result_t
204 ns_server_notifycommand(ns_server_t *server, char *args, isc_buffer_t *text);
205 /*%<
206  * Act on a "notify" command from the command channel.
207  */
208
209 isc_result_t
210 ns_server_refreshcommand(ns_server_t *server, char *args, isc_buffer_t *text);
211 /*%<
212  * Act on a "refresh" command from the command channel.
213  */
214
215 isc_result_t
216 ns_server_retransfercommand(ns_server_t *server, char *args);
217 /*%<
218  * Act on a "retransfer" command from the command channel.
219  */
220
221 isc_result_t
222 ns_server_togglequerylog(ns_server_t *server);
223 /*%<
224  * Toggle logging of queries, as in BIND 8.
225  */
226
227 /*%
228  * Dump the current statistics to the statistics file.
229  */
230 isc_result_t
231 ns_server_dumpstats(ns_server_t *server);
232
233 /*%
234  * Dump the current cache to the dump file.
235  */
236 isc_result_t
237 ns_server_dumpdb(ns_server_t *server, char *args);
238
239 /*%
240  * Change or increment the server debug level.
241  */
242 isc_result_t
243 ns_server_setdebuglevel(ns_server_t *server, char *args);
244
245 /*%
246  * Flush the server's cache(s)
247  */
248 isc_result_t
249 ns_server_flushcache(ns_server_t *server, char *args);
250
251 /*%
252  * Flush a particular name from the server's cache(s)
253  */
254 isc_result_t
255 ns_server_flushname(ns_server_t *server, char *args);
256
257 /*%
258  * Report the server's status.
259  */
260 isc_result_t
261 ns_server_status(ns_server_t *server, isc_buffer_t *text);
262
263 /*%
264  * Report a list of dynamic and static tsig keys, per view.
265  */
266 isc_result_t
267 ns_server_tsiglist(ns_server_t *server, isc_buffer_t *text);
268
269 /*%
270  * Delete a specific key (with optional view).
271  */
272 isc_result_t
273 ns_server_tsigdelete(ns_server_t *server, char *command, isc_buffer_t *text);
274
275 /*%
276  * Enable or disable updates for a zone.
277  */
278 isc_result_t
279 ns_server_freeze(ns_server_t *server, isc_boolean_t freeze, char *args,
280                  isc_buffer_t *text);
281
282 /*%
283  * Dump the current recursive queries.
284  */
285 isc_result_t
286 ns_server_dumprecursing(ns_server_t *server);
287
288 /*%
289  * Maintain a list of dispatches that require reserved ports.
290  */
291 void
292 ns_add_reserved_dispatch(ns_server_t *server, const isc_sockaddr_t *addr);
293
294 /*%
295  * Enable or disable dnssec validation.
296  */
297 isc_result_t
298 ns_server_validation(ns_server_t *server, char *args);
299
300 #endif /* NAMED_SERVER_H */