server.h 6.14 KB
Newer Older
Bob Halley's avatar
add  
Bob Halley committed
1
/*
Automatic Updater's avatar
Automatic Updater committed
2
 * Copyright (C) 2004-2008  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.92 2008/01/24 02:00:44 jinmei 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 57 58 59 60 61 62
	char *			statsfile;	/*%< Statistics file name */
	char *			dumpfile;	/*%< Dump file name */
	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 */
63
	isc_boolean_t		server_usehostname;
64
	char *			server_id;	/*%< User-specified server id */
65

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

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;
Mark Andrews's avatar
Mark Andrews committed
82
	isc_timer_t *		heartbeat_timer;
83 84
	isc_timer_t *		pps_timer;

85 86
	isc_uint32_t		interface_interval;
	isc_uint32_t		heartbeat_interval;
87

88 89
	isc_mutex_t		reload_event_lock;
	isc_event_t *		reload_event;
90 91

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

94
	dns_stats_t *		querystats;	/*%< Query statistics counters */
95

96
	ns_controls_t *		controls;	/*%< Control channels */
97 98
	unsigned int		dispatchgen;
	ns_dispatchlist_t	dispatches;
99 100

	dns_acache_t		*acache;
101

102
	ns_statschannellist_t	statschannels;
103 104
};

105 106
#define NS_SERVER_MAGIC			ISC_MAGIC('S','V','E','R')
#define NS_SERVER_VALID(s)		ISC_MAGIC_VALID(s, NS_SERVER_MAGIC)
107

108
void
109
ns_server_create(isc_mem_t *mctx, ns_server_t **serverp);
110
/*%<
111
 * Create a server object with default settings.
112 113
 * This function either succeeds or causes the program to exit
 * with a fatal error.
114 115 116 117
 */

void
ns_server_destroy(ns_server_t **serverp);
118
/*%<
119 120
 * Destroy a server object, freeing its memory.
 */
Bob Halley's avatar
Bob Halley committed
121 122

void
123
ns_server_reloadwanted(ns_server_t *server);
124
/*%<
125 126 127 128 129
 * 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
130

131
void
132
ns_server_flushonshutdown(ns_server_t *server, isc_boolean_t flush);
133
/*%<
134 135
 * Inform the server that the zones should be flushed to disk on shutdown.
 */
136

137
isc_result_t
138
ns_server_reloadcommand(ns_server_t *server, char *args, isc_buffer_t *text);
139
/*%<
140 141
 * Act on a "reload" command from the command channel.
 */
142

143 144
isc_result_t
ns_server_reconfigcommand(ns_server_t *server, char *args);
145
/*%<
146 147 148
 * Act on a "reconfig" command from the command channel.
 */

149 150
isc_result_t
ns_server_notifycommand(ns_server_t *server, char *args, isc_buffer_t *text);
151
/*%<
152 153 154
 * Act on a "notify" command from the command channel.
 */

155
isc_result_t
156
ns_server_refreshcommand(ns_server_t *server, char *args, isc_buffer_t *text);
157
/*%<
158 159
 * Act on a "refresh" command from the command channel.
 */
160

161 162
isc_result_t
ns_server_retransfercommand(ns_server_t *server, char *args);
163
/*%<
164 165 166
 * Act on a "retransfer" command from the command channel.
 */

167 168
isc_result_t
ns_server_togglequerylog(ns_server_t *server);
169
/*%<
170 171 172
 * Toggle logging of queries, as in BIND 8.
 */

173
/*%
174
 * Dump the current statistics to the statistics file.
175
 */
176 177 178
isc_result_t
ns_server_dumpstats(ns_server_t *server);

179
/*%
180 181 182
 * Dump the current cache to the dump file.
 */
isc_result_t
183
ns_server_dumpdb(ns_server_t *server, char *args);
184

185
/*%
186 187 188 189 190
 * Change or increment the server debug level.
 */
isc_result_t
ns_server_setdebuglevel(ns_server_t *server, char *args);

191
/*%
192 193 194
 * Flush the server's cache(s)
 */
isc_result_t
195
ns_server_flushcache(ns_server_t *server, char *args);
196

197
/*%
198 199 200 201 202
 * Flush a particular name from the server's cache(s)
 */
isc_result_t
ns_server_flushname(ns_server_t *server, char *args);

203
/*%
204 205 206 207 208
 * Report the server's status.
 */
isc_result_t
ns_server_status(ns_server_t *server, isc_buffer_t *text);

209 210 211 212 213 214 215 216 217 218 219 220
/*%
 * 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);

221
/*%
222 223 224 225 226
 * Enable or disable updates for a zone.
 */
isc_result_t
ns_server_freeze(ns_server_t *server, isc_boolean_t freeze, char *args);

227
/*%
228 229 230 231 232
 * Dump the current recursive queries.
 */
isc_result_t
ns_server_dumprecursing(ns_server_t *server);

233
/*%
234 235 236
 * Maintain a list of dispatches that require reserved ports.
 */
void
237
ns_add_reserved_dispatch(ns_server_t *server, const isc_sockaddr_t *addr);
238

239 240 241 242 243 244
/*%
 * Enable or disable dnssec validation.
 */
isc_result_t
ns_server_validation(ns_server_t *server, char *args);

245
#endif /* NAMED_SERVER_H */