server.h 7.87 KB
Newer Older
Bob Halley's avatar
add  
Bob Halley committed
1
/*
Automatic Updater's avatar
Automatic Updater committed
2
 * Copyright (C) 2004-2009  Internet Systems Consortium, Inc. ("ISC")
Mark Andrews's avatar
Mark Andrews committed
3
 * Copyright (C) 1999-2003  Internet Software Consortium.
4
 *
Automatic Updater's avatar
Automatic Updater committed
5
 * Permission to use, copy, modify, and/or distribute this software for any
Bob Halley's avatar
add  
Bob Halley committed
6 7
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
8
 *
Mark Andrews's avatar
Mark Andrews committed
9 10 11 12 13 14 15
 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
Bob Halley's avatar
add  
Bob Halley committed
16 17
 */

18
/* $Id: server.h,v 1.97 2009/03/04 02:42:30 each Exp $ */
David Lawrence's avatar
David Lawrence committed
19

20 21
#ifndef NAMED_SERVER_H
#define NAMED_SERVER_H 1
Bob Halley's avatar
add  
Bob Halley committed
22

23 24
/*! \file */

Bob Halley's avatar
Bob Halley committed
25
#include <isc/log.h>
26
#include <isc/magic.h>
27
#include <isc/quota.h>
28 29 30
#include <isc/sockaddr.h>
#include <isc/types.h>
#include <isc/xml.h>
Bob Halley's avatar
add  
Bob Halley committed
31

32
#include <dns/acl.h>
33
#include <dns/types.h>
34

35
#include <named/types.h>
36

37 38
#define NS_EVENTCLASS		ISC_EVENTCLASS(0x4E43)
#define NS_EVENT_RELOAD		(NS_EVENTCLASS + 0)
39
#define NS_EVENT_CLIENTCONTROL	(NS_EVENTCLASS + 1)
40

41
/*%
42 43 44
 * Name server state.  Better here than in lots of separate global variables.
 */
struct ns_server {
45
	unsigned int		magic;
46 47
	isc_mem_t *		mctx;

48
	isc_task_t *		task;
49

50
	/* Configurable data. */
51 52 53
	isc_quota_t		xfroutquota;
	isc_quota_t		tcpquota;
	isc_quota_t		recursionquota;
54
	dns_acl_t		*blackholeacl;
55 56
	char *			statsfile;	/*%< Statistics file name */
	char *			dumpfile;	/*%< Dump file name */
57
	char *			bindkeysfile;	/*%< bind.keys file name */
58 59 60 61 62 63
	char *			recfile;	/*%< Recursive file name */
	isc_boolean_t		version_set;	/*%< User has set version */
	char *			version;	/*%< User-specified version */
	isc_boolean_t		hostname_set;	/*%< User has set hostname */
	char *			hostname;	/*%< User-specified hostname */
	/*% Use hostname for server id */
64
	isc_boolean_t		server_usehostname;
65
	char *			server_id;	/*%< User-specified server id */
66

Automatic Updater's avatar
Automatic Updater committed
67
	/*%
68 69 70 71
	 * Current ACL environment.  This defines the
	 * current values of the localhost and localnets
	 * ACLs.
	 */
72 73
	dns_aclenv_t		aclenv;

74
	/* Server data structures. */
75
	dns_loadmgr_t *		loadmgr;
76
	dns_zonemgr_t *		zonemgr;
77
	dns_viewlist_t		viewlist;
78
	ns_interfacemgr_t *	interfacemgr;
79
	dns_db_t *		in_roothints;
80
	dns_tkeyctx_t *		tkeyctx;
81

82
	isc_timer_t *		interface_timer;
Mark Andrews's avatar
Mark Andrews committed
83
	isc_timer_t *		heartbeat_timer;
84 85
	isc_timer_t *		pps_timer;

86 87
	isc_uint32_t		interface_interval;
	isc_uint32_t		heartbeat_interval;
88

89 90
	isc_mutex_t		reload_event_lock;
	isc_event_t *		reload_event;
91 92

	isc_boolean_t		flushonshutdown;
93
	isc_boolean_t		log_queries;	/*%< For BIND 8 compatibility */
Michael Sawyer's avatar
Michael Sawyer committed
94

95
	ns_cachelist_t		cachelist;	/*%< Possibly shared caches */
96 97 98 99 100 101
	isc_stats_t *		nsstats;	/*%< Server stats */
	dns_stats_t *		rcvquerystats;	/*% Incoming query stats */
	dns_stats_t *		opcodestats;	/*%< Incoming message stats */
	isc_stats_t *		zonestats;	/*% Zone management stats */
	isc_stats_t  *		resolverstats;	/*% Resolver stats */
	isc_stats_t *		sockstats;	/*%< Socket stats */
102

103
	ns_controls_t *		controls;	/*%< Control channels */
104 105
	unsigned int		dispatchgen;
	ns_dispatchlist_t	dispatches;
106 107

	dns_acache_t		*acache;
108

109
	ns_statschannellist_t	statschannels;
110 111
};

112 113
#define NS_SERVER_MAGIC			ISC_MAGIC('S','V','E','R')
#define NS_SERVER_VALID(s)		ISC_MAGIC_VALID(s, NS_SERVER_MAGIC)
114

115
/*%
116
 * Server statistics counters.  Used as isc_statscounter_t values.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
 */
enum {
	dns_nsstatscounter_requestv4 = 0,
	dns_nsstatscounter_requestv6 = 1,
	dns_nsstatscounter_edns0in = 2,
	dns_nsstatscounter_badednsver = 3,
	dns_nsstatscounter_tsigin = 4,
	dns_nsstatscounter_sig0in = 5,
	dns_nsstatscounter_invalidsig = 6,
	dns_nsstatscounter_tcp = 7,

	dns_nsstatscounter_authrej = 8,
	dns_nsstatscounter_recurserej = 9,
	dns_nsstatscounter_xfrrej = 10,
	dns_nsstatscounter_updaterej = 11,

	dns_nsstatscounter_response = 12,
	dns_nsstatscounter_truncatedresp = 13,
	dns_nsstatscounter_edns0out = 14,
	dns_nsstatscounter_tsigout = 15,
	dns_nsstatscounter_sig0out = 16,

	dns_nsstatscounter_success = 17,
	dns_nsstatscounter_authans = 18,
	dns_nsstatscounter_nonauthans = 19,
	dns_nsstatscounter_referral = 20,
	dns_nsstatscounter_nxrrset = 21,
	dns_nsstatscounter_servfail = 22,
	dns_nsstatscounter_formerr = 23,
	dns_nsstatscounter_nxdomain = 24,
	dns_nsstatscounter_recursion = 25,
	dns_nsstatscounter_duplicate = 26,
	dns_nsstatscounter_dropped = 27,
	dns_nsstatscounter_failure = 28,

	dns_nsstatscounter_xfrdone = 29,

	dns_nsstatscounter_updatereqfwd = 30,
	dns_nsstatscounter_updaterespfwd = 31,
	dns_nsstatscounter_updatefwdfail = 32,
	dns_nsstatscounter_updatedone = 33,
	dns_nsstatscounter_updatefail = 34,
	dns_nsstatscounter_updatebadprereq = 35,

	dns_nsstatscounter_max = 36
};

164
void
165
ns_server_create(isc_mem_t *mctx, ns_server_t **serverp);
166
/*%<
167
 * Create a server object with default settings.
168 169
 * This function either succeeds or causes the program to exit
 * with a fatal error.
170 171 172 173
 */

void
ns_server_destroy(ns_server_t **serverp);
174
/*%<
175 176
 * Destroy a server object, freeing its memory.
 */
Bob Halley's avatar
Bob Halley committed
177 178

void
179
ns_server_reloadwanted(ns_server_t *server);
180
/*%<
181 182 183 184 185
 * Inform a server that a reload is wanted.  This function
 * may be called asynchronously, from outside the server's task.
 * If a reload is already scheduled or in progress, the call
 * is ignored.
 */
Bob Halley's avatar
add  
Bob Halley committed
186

187
void
188
ns_server_flushonshutdown(ns_server_t *server, isc_boolean_t flush);
189
/*%<
190 191
 * Inform the server that the zones should be flushed to disk on shutdown.
 */
192

193
isc_result_t
194
ns_server_reloadcommand(ns_server_t *server, char *args, isc_buffer_t *text);
195
/*%<
196 197
 * Act on a "reload" command from the command channel.
 */
198

199 200
isc_result_t
ns_server_reconfigcommand(ns_server_t *server, char *args);
201
/*%<
202 203 204
 * Act on a "reconfig" command from the command channel.
 */

205 206
isc_result_t
ns_server_notifycommand(ns_server_t *server, char *args, isc_buffer_t *text);
207
/*%<
208 209 210
 * Act on a "notify" command from the command channel.
 */

211
isc_result_t
212
ns_server_refreshcommand(ns_server_t *server, char *args, isc_buffer_t *text);
213
/*%<
214 215
 * Act on a "refresh" command from the command channel.
 */
216

217 218
isc_result_t
ns_server_retransfercommand(ns_server_t *server, char *args);
219
/*%<
220 221 222
 * Act on a "retransfer" command from the command channel.
 */

223 224
isc_result_t
ns_server_togglequerylog(ns_server_t *server);
225
/*%<
226 227 228
 * Toggle logging of queries, as in BIND 8.
 */

229
/*%
230
 * Dump the current statistics to the statistics file.
231
 */
232 233 234
isc_result_t
ns_server_dumpstats(ns_server_t *server);

235
/*%
236 237 238
 * Dump the current cache to the dump file.
 */
isc_result_t
239
ns_server_dumpdb(ns_server_t *server, char *args);
240

241
/*%
242 243 244 245 246
 * Change or increment the server debug level.
 */
isc_result_t
ns_server_setdebuglevel(ns_server_t *server, char *args);

247
/*%
248 249 250
 * Flush the server's cache(s)
 */
isc_result_t
251
ns_server_flushcache(ns_server_t *server, char *args);
252

253
/*%
254 255 256 257 258
 * Flush a particular name from the server's cache(s)
 */
isc_result_t
ns_server_flushname(ns_server_t *server, char *args);

259
/*%
260 261 262 263 264
 * Report the server's status.
 */
isc_result_t
ns_server_status(ns_server_t *server, isc_buffer_t *text);

265 266 267 268 269 270 271 272 273 274 275 276
/*%
 * Report a list of dynamic and static tsig keys, per view.
 */
isc_result_t
ns_server_tsiglist(ns_server_t *server, isc_buffer_t *text);

/*%
 * Delete a specific key (with optional view).
 */
isc_result_t
ns_server_tsigdelete(ns_server_t *server, char *command, isc_buffer_t *text);

277
/*%
278 279 280 281 282
 * Enable or disable updates for a zone.
 */
isc_result_t
ns_server_freeze(ns_server_t *server, isc_boolean_t freeze, char *args);

283
/*%
284 285 286 287 288
 * Dump the current recursive queries.
 */
isc_result_t
ns_server_dumprecursing(ns_server_t *server);

289
/*%
290 291 292
 * Maintain a list of dispatches that require reserved ports.
 */
void
293
ns_add_reserved_dispatch(ns_server_t *server, const isc_sockaddr_t *addr);
294

295 296 297 298 299 300
/*%
 * Enable or disable dnssec validation.
 */
isc_result_t
ns_server_validation(ns_server_t *server, char *args);

301
#endif /* NAMED_SERVER_H */