Merge from vendor branch LIBARCHIVE:
[dragonfly.git] / contrib / bind-9.2.4rc7 / bin / named / include / named / server.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2001  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.3 2004/03/09 06:09:23 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
53         /*
54          * Current ACL environment.  This defines the
55          * current values of the localhost and localnets
56          * ACLs.
57          */
58         dns_aclenv_t            aclenv;
59
60         /* Server data structures. */
61         dns_loadmgr_t *         loadmgr;
62         dns_zonemgr_t *         zonemgr;
63         dns_viewlist_t          viewlist;
64         ns_interfacemgr_t *     interfacemgr;
65         dns_db_t *              in_roothints;
66         dns_tkeyctx_t *         tkeyctx;
67
68         isc_timer_t *           interface_timer;
69         isc_timer_t *           heartbeat_timer;
70         isc_uint32_t            interface_interval;
71         isc_uint32_t            heartbeat_interval;
72
73         isc_mutex_t             reload_event_lock;
74         isc_event_t *           reload_event;
75
76         isc_boolean_t           flushonshutdown;
77         isc_boolean_t           log_queries;    /* For BIND 8 compatibility */
78
79         char *                  statsfile;      /* Statistics file name */
80         isc_uint64_t *          querystats;     /* Query statistics counters */
81
82         char *                  dumpfile;       /* Dump file name */
83
84         ns_controls_t *         controls;       /* Control channels */
85         unsigned int            dispatchgen;
86         ns_dispatchlist_t       dispatches;
87
88 };
89
90 #define NS_SERVER_MAGIC                 ISC_MAGIC('S','V','E','R')
91 #define NS_SERVER_VALID(s)              ISC_MAGIC_VALID(s, NS_SERVER_MAGIC)
92
93 void
94 ns_server_create(isc_mem_t *mctx, ns_server_t **serverp);
95 /*
96  * Create a server object with default settings.
97  * This function either succeeds or causes the program to exit
98  * with a fatal error.
99  */
100
101 void
102 ns_server_destroy(ns_server_t **serverp);
103 /*
104  * Destroy a server object, freeing its memory.
105  */
106
107 void
108 ns_server_reloadwanted(ns_server_t *server);
109 /*
110  * Inform a server that a reload is wanted.  This function
111  * may be called asynchronously, from outside the server's task.
112  * If a reload is already scheduled or in progress, the call
113  * is ignored.
114  */
115
116 void
117 ns_server_flushonshutdown(ns_server_t *server, isc_boolean_t flush);
118 /*
119  * Inform the server that the zones should be flushed to disk on shutdown.
120  */
121
122 isc_result_t
123 ns_server_reloadcommand(ns_server_t *server, char *args);
124 /*
125  * Act on a "reload" command from the command channel.
126  */
127
128 isc_result_t
129 ns_server_reconfigcommand(ns_server_t *server, char *args);
130 /*
131  * Act on a "reconfig" command from the command channel.
132  */
133
134 isc_result_t
135 ns_server_refreshcommand(ns_server_t *server, char *args);
136 /*
137  * Act on a "refresh" command from the command channel.
138  */
139
140 isc_result_t
141 ns_server_togglequerylog(ns_server_t *server);
142 /*
143  * Toggle logging of queries, as in BIND 8.
144  */
145
146 /*
147  * Dump the current statistics to the statistics file.
148  */
149 isc_result_t
150 ns_server_dumpstats(ns_server_t *server);
151
152 /*
153  * Dump the current cache to the dump file.
154  */
155 isc_result_t
156 ns_server_dumpdb(ns_server_t *server);
157
158 /*
159  * Change or increment the server debug level.
160  */
161 isc_result_t
162 ns_server_setdebuglevel(ns_server_t *server, char *args);
163
164 /*
165  * Flush the server's cache(s)
166  */
167 isc_result_t
168 ns_server_flushcache(ns_server_t *server, char *args);
169
170 /*
171  * Report the server's status.
172  */
173 isc_result_t
174 ns_server_status(ns_server_t *server, isc_buffer_t *text);
175
176 /*
177  * Maintain a list of dispatches that require reserved ports.
178  */
179 void
180 ns_add_reserved_dispatch(ns_server_t *server, isc_sockaddr_t *addr);
181
182 #endif /* NAMED_SERVER_H */