97eb2efce341c470c41c0bc51520335edfb5bc46
[dragonfly.git] / contrib / bind-9.3 / bin / named / include / named / server.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2003  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and 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.58.2.1.10.11 2004/03/08 04:04:21 marka Exp $ */
19
20 #ifndef NAMED_SERVER_H
21 #define NAMED_SERVER_H 1
22
23 #include <isc/log.h>
24 #include <isc/sockaddr.h>
25 #include <isc/magic.h>
26 #include <isc/types.h>
27 #include <isc/quota.h>
28
29 #include <dns/types.h>
30 #include <dns/acl.h>
31
32 #include <named/types.h>
33
34 #define NS_EVENTCLASS           ISC_EVENTCLASS(0x4E43)
35 #define NS_EVENT_RELOAD         (NS_EVENTCLASS + 0)
36 #define NS_EVENT_CLIENTCONTROL  (NS_EVENTCLASS + 1)
37
38 /*
39  * Name server state.  Better here than in lots of separate global variables.
40  */
41 struct ns_server {
42         unsigned int            magic;
43         isc_mem_t *             mctx;
44
45         isc_task_t *            task;
46
47         /* Configurable data. */
48         isc_quota_t             xfroutquota;
49         isc_quota_t             tcpquota;
50         isc_quota_t             recursionquota;
51         dns_acl_t               *blackholeacl;
52         char *                  statsfile;      /* Statistics file name */
53         char *                  dumpfile;       /* Dump file name */
54         char *                  recfile;        /* Recursive file name */
55         isc_boolean_t           version_set;    /* User has set version */
56         char *                  version;        /* User-specified version */
57         isc_boolean_t           hostname_set;   /* User has set hostname */
58         char *                  hostname;       /* User-specified hostname */
59         /* Use hostname for server id */
60         isc_boolean_t           server_usehostname;
61         char *                  server_id;      /* User-specified server id */
62
63         /*
64          * Current ACL environment.  This defines the
65          * current values of the localhost and localnets
66          * ACLs.
67          */
68         dns_aclenv_t            aclenv;
69
70         /* Server data structures. */
71         dns_loadmgr_t *         loadmgr;
72         dns_zonemgr_t *         zonemgr;
73         dns_viewlist_t          viewlist;
74         ns_interfacemgr_t *     interfacemgr;
75         dns_db_t *              in_roothints;
76         dns_tkeyctx_t *         tkeyctx;
77
78         isc_timer_t *           interface_timer;
79         isc_timer_t *           heartbeat_timer;
80         isc_uint32_t            interface_interval;
81         isc_uint32_t            heartbeat_interval;
82
83         isc_mutex_t             reload_event_lock;
84         isc_event_t *           reload_event;
85
86         isc_boolean_t           flushonshutdown;
87         isc_boolean_t           log_queries;    /* For BIND 8 compatibility */
88
89         isc_uint64_t *          querystats;     /* Query statistics counters */
90
91         ns_controls_t *         controls;       /* Control channels */
92         unsigned int            dispatchgen;
93         ns_dispatchlist_t       dispatches;
94                                                 
95 };
96
97 #define NS_SERVER_MAGIC                 ISC_MAGIC('S','V','E','R')
98 #define NS_SERVER_VALID(s)              ISC_MAGIC_VALID(s, NS_SERVER_MAGIC)
99
100 void
101 ns_server_create(isc_mem_t *mctx, ns_server_t **serverp);
102 /*
103  * Create a server object with default settings.
104  * This function either succeeds or causes the program to exit
105  * with a fatal error.
106  */
107
108 void
109 ns_server_destroy(ns_server_t **serverp);
110 /*
111  * Destroy a server object, freeing its memory.
112  */
113
114 void
115 ns_server_reloadwanted(ns_server_t *server);
116 /*
117  * Inform a server that a reload is wanted.  This function
118  * may be called asynchronously, from outside the server's task.
119  * If a reload is already scheduled or in progress, the call
120  * is ignored.
121  */
122
123 void
124 ns_server_flushonshutdown(ns_server_t *server, isc_boolean_t flush);
125 /*
126  * Inform the server that the zones should be flushed to disk on shutdown.
127  */
128
129 isc_result_t
130 ns_server_reloadcommand(ns_server_t *server, char *args, isc_buffer_t *text);
131 /*
132  * Act on a "reload" command from the command channel.
133  */
134
135 isc_result_t
136 ns_server_reconfigcommand(ns_server_t *server, char *args);
137 /*
138  * Act on a "reconfig" command from the command channel.
139  */
140
141 isc_result_t
142 ns_server_refreshcommand(ns_server_t *server, char *args, isc_buffer_t *text);
143 /*
144  * Act on a "refresh" command from the command channel.
145  */
146
147 isc_result_t
148 ns_server_retransfercommand(ns_server_t *server, char *args);
149 /*
150  * Act on a "retransfer" command from the command channel.
151  */
152
153 isc_result_t
154 ns_server_togglequerylog(ns_server_t *server);
155 /*
156  * Toggle logging of queries, as in BIND 8.
157  */
158
159 /*
160  * Dump the current statistics to the statistics file.
161  */
162 isc_result_t
163 ns_server_dumpstats(ns_server_t *server);
164
165 /*
166  * Dump the current cache to the dump file.
167  */
168 isc_result_t
169 ns_server_dumpdb(ns_server_t *server, char *args);
170
171 /*
172  * Change or increment the server debug level.
173  */
174 isc_result_t
175 ns_server_setdebuglevel(ns_server_t *server, char *args);
176
177 /*
178  * Flush the server's cache(s)
179  */
180 isc_result_t
181 ns_server_flushcache(ns_server_t *server, char *args);
182
183 /*
184  * Flush a particular name from the server's cache(s)
185  */
186 isc_result_t
187 ns_server_flushname(ns_server_t *server, char *args);
188
189 /*
190  * Report the server's status.
191  */
192 isc_result_t
193 ns_server_status(ns_server_t *server, isc_buffer_t *text);
194
195 /*
196  * Enable or disable updates for a zone.
197  */
198 isc_result_t
199 ns_server_freeze(ns_server_t *server, isc_boolean_t freeze, char *args);
200
201 /*
202  * Dump the current recursive queries.
203  */
204 isc_result_t
205 ns_server_dumprecursing(ns_server_t *server);
206
207 /*
208  * Maintain a list of dispatches that require reserved ports.
209  */
210 void
211 ns_add_reserved_dispatch(ns_server_t *server, isc_sockaddr_t *addr);
212
213 #endif /* NAMED_SERVER_H */