2 * from ns.h 4.33 (Berkeley) 8/23/90
3 * $Id: ns_glob.h,v 8.51 1999/10/15 21:53:32 vixie Exp $
8 * The Regents of the University of California. All rights reserved.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
42 * Permission to use, copy, modify, and distribute this software for any
43 * purpose with or without fee is hereby granted, provided that the above
44 * copyright notice and this permission notice appear in all copies, and that
45 * the name of Digital Equipment Corporation not be used in advertising or
46 * publicity pertaining to distribution of the document or software without
47 * specific, written prior permission.
49 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
50 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
51 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
52 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
53 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
54 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
55 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
60 * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
62 * Permission to use, copy, modify, and distribute this software for any
63 * purpose with or without fee is hereby granted, provided that the above
64 * copyright notice and this permission notice appear in all copies.
66 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
67 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
68 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
69 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
70 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
71 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
72 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
77 * Global variables for the name server.
80 /* original argv[] from main() */
81 DECL char **saved_argv;
84 DECL int debug INIT(0);
85 DECL int desired_debug INIT(0);
88 /* global event context */
91 /* global resolver context. */
92 DECL struct __res_state res;
94 /* list of open streams */
95 DECL struct qstream *streamq;
97 /* often set to the current time */
98 DECL struct timeval tt;
100 /* head of allocated queries */
101 DECL struct qinfo *nsqhead;
103 /* datagram socket for sysquery() and ns_forw(). */
104 DECL int ds INIT(-1);
106 /* event ID for reads of "ds". */
107 DECL evFileID ds_evID;
110 /* is query logging turned on? */
114 /* port to which we send queries */
115 DECL u_int16_t ns_port;
117 /* Source addr of our internal resolver. */
118 DECL struct sockaddr_in source_addr; /* INITs to <INADDR_ANY, 0>. */
120 /* Used by ns_stats */
121 DECL time_t boottime;
123 DECL time_t resettime;
125 /* next query to retry */
126 DECL struct qinfo *retryqp;
128 /* default configuration file */
131 /* default debug output file */
132 DECL char *debugfile;
134 /* zone information */
135 DECL struct zoneinfo *zones;
137 /* number of zones allocated */
140 /* free list of unused zones[] elements. */
141 DECL LIST(struct zoneinfo) freezones;
143 /* list of zones that have a reload pending. */
144 DECL LIST(struct zoneinfo) reloadingzones;
146 /* set if we need a priming */
147 DECL int needs_prime_cache;
149 /* is cache being primed */
152 /* ptrs to dnames in msg for dn_comp */
153 DECL u_char *dnptrs[40];
155 /* end pointer for dnptrs */
156 DECL u_char **dnptrs_end
157 INIT(dnptrs + sizeof dnptrs / sizeof(u_char*));
159 /* number of names in addinfo */
162 /* name of cache file */
163 DECL const char *cache_file;
166 /* retry time when a slave */
167 DECL int slave_retry INIT(4);
171 DECL const char * LogSignature INIT(";BIND LOG V8\n");
172 DECL const char * DumpSignature INIT(";BIND DUMP V8\n");
173 DECL const char * DumpSuffix INIT(".dumptmp");
176 DECL const char sendtoStr[] INIT("sendto");
177 DECL const char tcpsendStr[] INIT("tcp_send");
179 /* defined in version.c, can't use DECL/INIT */
180 extern char Version[];
181 extern char ShortVersion[];
183 /* If getnum() has an error, here will be the result. */
184 DECL int getnum_error INIT(0);
186 enum context { domain_ctx, owner_ctx, mailname_ctx, hostname_ctx };
187 DECL const char *context_strings[]
189 = { "domain", "owner", "mail", "host", NULL }
193 DECL const char *transport_strings[]
195 = { "primary", "secondary", "response", NULL }
199 DECL const char *severity_strings[]
201 = { "ignore", "warn", "fail", "not_set", NULL }
205 DECL struct in_addr inaddr_any; /* Inits to 0.0.0.0 */
207 DECL options server_options INIT(NULL);
209 DECL server_info nameserver_info INIT(NULL);
210 DECL key_info_list secretkey_info INIT(NULL);
212 DECL int main_needs_exit INIT(0);
213 DECL ip_match_list bogus_nameservers INIT(NULL);
215 DECL log_context log_ctx;
216 DECL int log_ctx_valid INIT(0);
218 DECL log_channel syslog_channel INIT(NULL);
219 DECL log_channel debug_channel INIT(NULL);
220 DECL log_channel stderr_channel INIT(NULL);
221 DECL log_channel eventlib_channel INIT(NULL);
222 DECL log_channel packet_channel INIT(NULL);
223 DECL log_channel null_channel INIT(NULL);
225 DECL ip_match_list local_addresses INIT(NULL);
226 DECL ip_match_list local_networks INIT(NULL);
228 /* are we running in no-fork mode? */
229 DECL int foreground INIT(0);
231 DECL const struct ns_sym logging_constants[]
234 { log_info, "info" },
235 { log_notice, "notice" },
236 { log_warning, "warning" },
237 { log_error, "error" },
238 { log_critical, "critical" },
244 DECL const struct ns_sym syslog_constants[]
247 { LOG_KERN, "kern" },
248 { LOG_USER, "user" },
249 { LOG_MAIL, "mail" },
250 { LOG_DAEMON, "daemon" },
251 { LOG_AUTH, "auth" },
252 { LOG_SYSLOG, "syslog" },
255 { LOG_NEWS, "news" },
258 { LOG_UUCP, "uucp" },
261 { LOG_CRON, "cron" },
264 { LOG_AUTHPRIV, "authpriv" },
269 { LOG_LOCAL0, "local0"},
270 { LOG_LOCAL1, "local1"},
271 { LOG_LOCAL2, "local2"},
272 { LOG_LOCAL3, "local3"},
273 { LOG_LOCAL4, "local4"},
274 { LOG_LOCAL5, "local5"},
275 { LOG_LOCAL6, "local6"},
276 { LOG_LOCAL7, "local7"},
282 DECL const struct ns_sym category_constants[]
285 { ns_log_default, "default" },
286 { ns_log_config, "config" },
287 { ns_log_parser, "parser" },
288 { ns_log_queries, "queries" },
289 { ns_log_lame_servers, "lame-servers" },
290 { ns_log_statistics, "statistics" },
291 { ns_log_panic, "panic" },
292 { ns_log_update, "update" },
293 { ns_log_ncache, "ncache" },
294 { ns_log_xfer_in, "xfer-in" },
295 { ns_log_xfer_out, "xfer-out" },
297 { ns_log_eventlib, "eventlib" },
298 { ns_log_packet, "packet" },
300 { ns_log_notify, "notify" },
302 { ns_log_cname, "cname" },
303 { ns_log_security, "security" },
305 { ns_log_insist, "insist" },
306 { ns_log_maint, "maintenance" },
307 { ns_log_load, "load" },
308 { ns_log_resp_checks, "response-checks" },
309 { ns_log_control, "control" },
315 DECL const char panic_msg_no_options[]
316 INIT("no server_options in NS_OPTION_P");
318 DECL const char panic_msg_insist_failed[]
319 INIT("%s:%d: insist '%s' failed: %s");
321 DECL const char panic_msg_bad_which[]
322 INIT("%s:%d: INCRSTATS(%s): bad \"which\"");
324 DECL u_long globalStats[nssLast];
326 DECL evTimerID clean_timer;
327 DECL evTimerID interface_timer;
328 DECL evTimerID stats_timer;
329 DECL evTimerID heartbeat_timer;
330 DECL int active_timers INIT(0);
333 DECL char * user_name INIT(NULL);
335 DECL char * group_name INIT(NULL);
336 DECL char * chroot_dir INIT(NULL);
338 DECL int loading INIT(0);
340 DECL int xfers_running INIT(0);
341 DECL int xfers_deferred INIT(0);
342 DECL int qserials_running INIT(0);