xref: /freebsd/contrib/ntp/include/ntpd.h (revision 397c2693fa66508cb5e6b173650a1f3bc6c4dd4f)
1 /*
2  * ntpd.h - Prototypes and external variables for ntpd.
3  *
4  * Note the first half is primarily function prototypes, type
5  * declarations, and preprocessor macros, with variables declared
6  * primarily in the second half.
7  *
8  * Each half is further divided into sections for each source file.
9  */
10 
11 #include "ntp.h"
12 #include "ntp_stdlib.h"
13 #include "ntp_syslog.h"
14 #include "ntp_debug.h"
15 #include "ntp_syslog.h"
16 #include "ntp_select.h"
17 #include "ntp_malloc.h"
18 #include "ntp_refclock.h"
19 #include "ntp_intres.h"
20 #include "recvbuff.h"
21 
22 /*
23  * First half: ntpd types, functions, macros
24  * -----------------------------------------
25  */
26 
27 /*
28  * macro for debugging output - cut down on #ifdef pollution.
29  *
30  * DPRINTF() is for use by ntpd only, and compiles away to nothing
31  * without DEBUG (configure --disable-debugging).
32  *
33  * TRACE() is similar for libntp and utilities, which retain full
34  * debug capability even when compiled without DEBUG.
35  *
36  * The calling convention is not attractive:
37  *     DPRINTF(debuglevel, (fmt, ...));
38  *     DPRINTF(2, ("shows #ifdef DEBUG and if debug >= %d\n", 2));
39  */
40 #ifdef DEBUG
41 # define DPRINTF(lvl, arg)				\
42 	do { 						\
43 		if (debug >= (lvl))			\
44 			mprintf arg;			\
45 	} while (0)
46 #else
47 # define DPRINTF(lvl, arg)	do {} while (0)
48 #endif
49 
50 /* clear bitflag only on DEBUG builds */
51 #ifdef DEBUG
52 # define CLEAR_BIT_IF_DEBUG(bit, flags)			\
53 	do {						\
54 		(flags) &= ~(bit);			\
55 	} while (FALSE)
56 #else
57 # define CLEAR_BIT_IF_DEBUG(bit, flags)			\
58 	do {} while (FALSE)
59 #endif
60 
61 
62 /* nt_clockstuff.c */
63 #ifdef SYS_WINNT
64 extern	void	win_time_stepped(void);
65 #endif
66 
67 /* ntp_config.c */
68 #define	TAI_1972	10	/* initial TAI offset (s) */
69 extern	char	*keysdir;	/* crypto keys and leaptable directory */
70 extern	char *	saveconfigdir;	/* ntpq saveconfig output directory */
71 
72 extern	void	getconfig	(int, char **);
73 extern	void	ctl_clr_stats	(void);
74 extern	int	ctlclrtrap	(sockaddr_u *, endpt *, int);
75 extern	u_short ctlpeerstatus	(struct peer *);
76 extern	int	ctlsettrap	(sockaddr_u *, endpt *, int, int);
77 extern	u_short ctlsysstatus	(void);
78 extern	void	init_control	(void);
79 extern	void	process_control (struct recvbuf *, int);
80 extern	void	report_event	(int, struct peer *, const char *);
81 extern	int	mprintf_event	(int evcode, struct peer *p,
82 				 const char *fmt, ...) NTP_PRINTF(3, 4);
83 
84 /* ntp_control.c */
85 /*
86  * Structure for translation tables between internal system
87  * variable indices and text format.
88  */
89 struct ctl_var {
90 	u_short code;
91 	u_short flags;
92 	const char *text;
93 };
94 /*
95  * Flag values
96  */
97 #define	CAN_READ	0x01
98 #define	CAN_WRITE	0x02
99 
100 #define DEF		0x20
101 #define	PADDING		0x40
102 #define	EOV		0x80
103 
104 #define	RO	(CAN_READ)
105 #define	WO	(CAN_WRITE)
106 #define	RW	(CAN_READ|CAN_WRITE)
107 
108 extern	char *	add_var (struct ctl_var **, u_long, u_short);
109 extern	void	free_varlist (struct ctl_var *);
110 extern	void	set_var (struct ctl_var **, const char *, u_long, u_short);
111 extern	void	set_sys_var (const char *, u_long, u_short);
112 extern	const char *	get_ext_sys_var(const char *tag);
113 
114 /* ntp_io.c */
115 typedef struct interface_info {
116 	endpt *	ep;
117 	u_char	action;
118 } interface_info_t;
119 
120 typedef void	(*interface_receiver_t)	(void *, interface_info_t *);
121 
122 extern	void	interface_enumerate	(interface_receiver_t, void *);
123 extern	endpt *	getinterface		(sockaddr_u *, u_int32);
124 extern	endpt *	select_peerinterface	(struct peer *, sockaddr_u *,
125 					 endpt *);
126 extern	endpt *	findinterface		(sockaddr_u *);
127 extern	endpt *	findbcastinter		(sockaddr_u *);
128 extern	void	enable_broadcast	(endpt *, sockaddr_u *);
129 extern	void	enable_multicast_if	(endpt *, sockaddr_u *);
130 extern	void	interface_update	(interface_receiver_t, void *);
131 #ifndef HAVE_IO_COMPLETION_PORT
132 extern	void	io_handler		(void);
133 #else
134 extern	void WINAPI ip_interface_changed(ULONG_PTR ctx);
135 #endif
136 extern	void	init_io 	(void);
137 extern	void	io_open_sockets	(void);
138 extern	void	io_clr_stats	(void);
139 extern	void	io_setbclient	(void);
140 extern	void	io_unsetbclient	(void);
141 extern	void	io_multicast_add(sockaddr_u *);
142 extern	void	io_multicast_del(sockaddr_u *);
143 extern	void	sendpkt		(sockaddr_u *dest, endpt * ep, int ttl,
144 				 struct pkt *pkt, int len);
145 extern	isc_boolean_t	is_linklocal(sockaddr_u *psau);
146 #ifdef DEBUG_TIMING
147 extern	void	collect_timing  (struct recvbuf *, const char *, int, l_fp *);
148 #endif
149 #ifdef HAVE_SIGNALED_IO
150 extern	void	wait_for_signal		(void);
151 extern	void	unblock_io_and_alarm	(void);
152 extern	void	block_io_and_alarm	(void);
153 # define	UNBLOCK_IO_AND_ALARM()	unblock_io_and_alarm()
154 # define	BLOCK_IO_AND_ALARM()	block_io_and_alarm()
155 #else
156 # define	UNBLOCK_IO_AND_ALARM()	do {} while (0)
157 # define	BLOCK_IO_AND_ALARM()	do {} while (0)
158 #endif
159 #define		eptoa(pif)	localaddrtoa(pif)
160 #define		latoa(pif)	eptoa(pif)
161 extern const char * localaddrtoa(endpt *);
162 #ifdef DEBUG
163 extern const char * iflags_str(u_int32 iflags);
164 #endif
165 
166 
167 /* ntp_loopfilter.c */
168 extern	void	init_loopfilter(void);
169 extern	int 	local_clock(struct peer *, double);
170 extern	void	adj_host_clock(void);
171 extern	void	loop_config(int, double);
172 extern	void	select_loop(int);
173 extern	void	huffpuff(void);
174 extern	u_long	sys_clocktime;
175 extern	u_int	sys_tai;
176 extern 	int	freq_cnt;
177 
178 /* ntp_monitor.c */
179 #define MON_HASH_SIZE		((size_t)1U << mon_hash_bits)
180 #define MON_HASH_MASK		(MON_HASH_SIZE - 1)
181 #define	MON_HASH(addr)		(sock_hash(addr) & MON_HASH_MASK)
182 extern	void	init_mon	(void);
183 extern	void	mon_start	(int);
184 extern	void	mon_stop	(int);
185 extern	u_short	ntp_monitor	(struct recvbuf *, u_short);
186 extern	void	mon_clearinterface(endpt *interface);
187 
188 /* ntp_peer.c */
189 extern	void	init_peer	(void);
190 extern	struct peer *findexistingpeer(sockaddr_u *, const char *,
191 				      struct peer *, int, u_char, int *);
192 extern	struct peer *findpeer	(struct recvbuf *, int, int *);
193 extern	struct peer *findpeerbyassoc(associd_t);
194 extern  void	set_peerdstadr	(struct peer *, endpt *);
195 extern	struct peer *newpeer	(sockaddr_u *, const char *, endpt *,
196 				 int, u_char, u_char, u_char, u_char,
197 				 u_int, u_char, u_int32,
198 				 keyid_t, const char *);
199 extern	void	peer_all_reset	(void);
200 extern	void	peer_clr_stats	(void);
201 extern	struct peer *peer_config(sockaddr_u *, const char *, endpt *,
202 				 int, u_char, u_char, u_char, u_char,
203 				 u_int, u_int32,
204 				 keyid_t, const char *);
205 extern	void	peer_reset	(struct peer *);
206 extern	void	refresh_all_peerinterfaces(void);
207 extern	void	unpeer		(struct peer *);
208 extern	void	clear_all	(void);
209 extern	int	score_all	(struct peer *);
210 extern	struct peer *findmanycastpeer(struct recvbuf *);
211 extern	void	peer_cleanup	(void);
212 
213 /* ntp_crypto.c */
214 #ifdef AUTOKEY
215 extern	int	crypto_recv	(struct peer *, struct recvbuf *);
216 extern	int	crypto_xmit	(struct peer *, struct pkt *,
217 				    struct recvbuf *, int,
218 				    struct exten *, keyid_t);
219 extern	keyid_t	session_key	(sockaddr_u *, sockaddr_u *, keyid_t,
220 				    keyid_t, u_long);
221 extern	int	make_keylist	(struct peer *, endpt *);
222 extern	void	key_expire	(struct peer *);
223 extern	void	crypto_update	(void);
224 extern	void	crypto_update_taichange(void);
225 extern	void	crypto_config	(int, char *);
226 extern	void	crypto_setup	(void);
227 extern	u_int	crypto_ident	(struct peer *);
228 extern	struct exten *crypto_args (struct peer *, u_int, associd_t, char *);
229 extern	int	crypto_public	(struct peer *, u_char *, u_int);
230 extern	void	value_free	(struct value *);
231 extern	char	*iffpar_file;
232 extern	EVP_PKEY *iffpar_pkey;
233 extern	char	*gqpar_file;
234 extern	EVP_PKEY *gqpar_pkey;
235 extern	char	*mvpar_file;
236 extern	EVP_PKEY *mvpar_pkey;
237 extern struct value tai_leap;
238 #endif	/* AUTOKEY */
239 
240 /* ntp_proto.c */
241 extern	void	transmit	(struct peer *);
242 extern	void	receive 	(struct recvbuf *);
243 extern	void	peer_clear	(struct peer *, const char *);
244 extern	void 	process_packet	(struct peer *, struct pkt *, u_int);
245 extern	void	clock_select	(void);
246 extern	void	set_sys_leap	(u_char);
247 
248 extern	u_long	leapsec;	/* seconds to next leap (proximity class) */
249 extern  int	leapdif;	/* TAI difference step at next leap second */
250 extern	int	sys_orphan;
251 extern	double	sys_mindisp;
252 extern	double	sys_maxdist;
253 
254 extern	char	*sys_ident;	/* identity scheme */
255 extern	void	poll_update	(struct peer *, u_char, u_char);
256 
257 extern	void	clear		(struct peer *);
258 extern	void	clock_filter	(struct peer *, double, double, double);
259 extern	void	init_proto	(void);
260 extern	void	set_sys_tick_precision(double);
261 extern	void	proto_config	(int, u_long, double, sockaddr_u *);
262 extern	void	proto_clr_stats (void);
263 
264 /* ntp_refclock.c */
265 #ifdef	REFCLOCK
266 extern	int	refclock_newpeer (struct peer *);
267 extern	void	refclock_unpeer (struct peer *);
268 extern	void	refclock_receive (struct peer *);
269 extern	void	refclock_transmit (struct peer *);
270 extern	void	init_refclock	(void);
271 #endif	/* REFCLOCK */
272 
273 /* ntp_request.c */
274 extern	void	init_request	(void);
275 extern	void	process_private (struct recvbuf *, int);
276 extern	void	reset_auth_stats(void);
277 
278 /* ntp_restrict.c */
279 extern	void	init_restrict	(void);
280 extern	void	restrictions	(sockaddr_u *, r4addr *);
281 extern	int/*BOOL*/hack_restrict(restrict_op op, sockaddr_u *resaddr,
282 				 sockaddr_u *resmask, short ippeerlimit,
283 				 u_short mflags, u_short rflags,
284 				 u_int32 expire);
285 extern	void	restrict_source	(sockaddr_u *addr, int/*BOOL*/ remove,
286 				 u_int32 lifetime);
287 #ifdef DEBUG
288 extern	void	dump_restricts	(void);
289 extern	const char *resop_str	(restrict_op op);
290 extern	const char *rflags_str	(u_short rflags);
291 extern	const char *mflags_str	(u_short mflags);
292 #endif
293 
294 
295 /* ntp_timer.c */
296 extern	void	init_timer	(void);
297 extern	void	reinit_timer	(void);
298 extern	void	timer		(void);
299 extern	void	timer_clr_stats (void);
300 extern	int	endpt_scan_period;	/* -U option default 301s */
301 extern	u_long	endpt_scan_timer;	/* next scan current_time */
302 extern	u_long	orphwait;		/* orphan wait time */
303 #ifdef AUTOKEY
304 extern	char	*sys_hostname;	/* host name */
305 extern	char	*sys_groupname;	/* group name */
306 extern	char	*group_name;	/* group name */
307 extern	u_char	sys_revoke;	/* keys revoke timeout */
308 extern	u_char	sys_automax;	/* session key timeout */
309 #endif	/* AUTOKEY */
310 
311 /* ntp_util.c */
312 extern	void	init_util	(void);
313 extern	void	write_stats	(void);
314 extern	void	stats_config	(int, const char *, int optflag);
315 extern	void	record_peer_stats (sockaddr_u *, int, double, double, double, double);
316 extern	void	record_proto_stats (char *);
317 extern	void	record_loop_stats (double, double, double, double, int);
318 extern	void	record_clock_stats (sockaddr_u *, const char *);
319 extern	int	mprintf_clock_stats(sockaddr_u *, const char *, ...)
320 					NTP_PRINTF(2, 3);
321 extern	void	record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr,
322 				  l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4,
323 				  int leap, int version, int mode,
324 				  int stratum, int ppoll, int precision,
325 				  double root_delay, double root_dispersion,
326 				  u_int32 refid, int len, u_char *extra);
327 extern	void	check_leap_file	(int is_daily_check, u_int32 ntptime, const time_t * systime);
328 extern	void	record_crypto_stats (sockaddr_u *, const char *);
329 #ifdef DEBUG
330 extern	void	record_timing_stats (const char *);
331 extern	void	append_flagstr(char *flagstr, size_t sz, const char *text);
332 #endif
333 extern	char *	fstostr(time_t);	/* NTP timescale seconds */
334 
335 /* ntpd.c */
336 extern	void	parse_cmdline_opts(int *, char ***);
337 
338 /* ntservice.c */
339 #ifndef SYS_WINNT
340 # define	ntservice_isup()	do {} while (FALSE)
341 #endif
342 
343 /*
344  * Signals we catch for debugging.
345  */
346 #define MOREDEBUGSIG	SIGUSR1
347 #define LESSDEBUGSIG	SIGUSR2
348 /*
349  * Signals which terminate us gracefully.
350  */
351 #ifndef SYS_WINNT
352 # define SIGDIE1	SIGHUP
353 # define SIGDIE2	SIGINT
354 # define SIGDIE3	SIGQUIT
355 # define SIGDIE4	SIGTERM
356 #endif /* SYS_WINNT */
357 
358 
359 /*
360  * Last half: ntpd variables
361  * -------------------------
362  */
363 
364 /* ntp_config.c */
365 extern char const *	progname;
366 extern int saved_argc;
367 extern char **saved_argv;
368 extern char	*sys_phone[];		/* ACTS phone numbers */
369 #if defined(HAVE_SCHED_SETSCHEDULER)
370 extern int	config_priority_override;
371 extern int	config_priority;
372 #endif
373 extern char *ntp_signd_socket;
374 extern struct config_tree_tag *cfg_tree_history;
375 
376 #ifdef BC_LIST_FRAMEWORK_NOT_YET_USED
377 /*
378  * backwards compatibility flags
379  */
380 typedef struct bc_entry_tag {
381 	int	token;
382 	int	enabled;
383 } bc_entry;
384 
385 extern bc_entry bc_list[];
386 #endif
387 
388 /* ntp_control.c */
389 extern int	num_ctl_traps;
390 extern keyid_t	ctl_auth_keyid;		/* keyid used for authenticating write requests */
391 
392 /*
393  * Statistic counters to keep track of requests and responses.
394  */
395 extern u_long	ctltimereset;		/* time stats reset */
396 extern u_long	numctlreq;		/* number of requests we've received */
397 extern u_long	numctlbadpkts;		/* number of bad control packets */
398 extern u_long	numctlresponses; 	/* number of resp packets sent with data */
399 extern u_long	numctlfrags; 		/* number of fragments sent */
400 extern u_long	numctlerrors;		/* number of error responses sent */
401 extern u_long	numctltooshort;		/* number of too short input packets */
402 extern u_long	numctlinputresp; 	/* number of responses on input */
403 extern u_long	numctlinputfrag; 	/* number of fragments on input */
404 extern u_long	numctlinputerr;		/* number of input pkts with err bit set */
405 extern u_long	numctlbadoffset; 	/* number of input pkts with nonzero offset */
406 extern u_long	numctlbadversion;	/* number of input pkts with unknown version */
407 extern u_long	numctldatatooshort;	/* data too short for count */
408 extern u_long	numctlbadop; 		/* bad op code found in packet */
409 extern u_long	numasyncmsgs;		/* number of async messages we've sent */
410 
411 /*
412  * Other statistics of possible interest
413  */
414 extern volatile u_long packets_dropped;	/* total number of packets dropped on reception */
415 extern volatile u_long packets_ignored;	/* packets received on wild card interface */
416 extern volatile u_long packets_received;/* total number of packets received */
417 extern u_long	packets_sent;		/* total number of packets sent */
418 extern u_long	packets_notsent; 	/* total number of packets which couldn't be sent */
419 
420 extern volatile u_long handler_calls;	/* number of calls to interrupt handler */
421 extern volatile u_long handler_pkts;	/* number of pkts received by handler */
422 extern u_long	io_timereset;		/* time counters were reset */
423 
424 /* ntp_io.c */
425 extern int	no_periodic_scan;	/* no periodic net addr scans */
426 extern int	scan_addrs_once;	/* no net addr rescans */
427 extern int	nonlocal_v4_addr_up;	/* should we try IPv4 pool? */
428 extern int	nonlocal_v6_addr_up;	/* should we try IPv6 pool? */
429 extern u_int	sys_ifnum;		/* next .ifnum to assign */
430 extern endpt *	any_interface;		/* IPv4 wildcard */
431 extern endpt *	any6_interface;		/* IPv6 wildcard */
432 extern endpt *	loopback_interface;	/* IPv4 loopback for refclocks */
433 extern endpt *	ep_list;		/* linked list */
434 
435 /* ntp_loopfilter.c */
436 extern double	drift_comp;		/* clock frequency (s/s) */
437 extern double	clock_stability;	/* clock stability (s/s) */
438 extern double	clock_max_back;		/* max backward offset before step (s) */
439 extern double	clock_max_fwd;		/* max forward offset before step (s) */
440 extern double	clock_panic;		/* max offset before panic (s) */
441 extern double	clock_phi;		/* dispersion rate (s/s) */
442 extern double	clock_minstep;		/* step timeout (s) */
443 extern double	clock_codec;		/* codec frequency */
444 #ifdef KERNEL_PLL
445 extern int	pll_status;		/* status bits for kernel pll */
446 #endif /* KERNEL_PLL */
447 
448 /*
449  * Clock state machine control flags
450  */
451 extern int	ntp_enable;		/* clock discipline enabled */
452 extern int	pll_control;		/* kernel support available */
453 extern int	kern_enable;		/* kernel support enabled */
454 extern int	hardpps_enable;		/* kernel PPS discipline enabled */
455 extern int	ext_enable;		/* external clock enabled */
456 extern int	cal_enable;		/* refclock calibrate enable */
457 extern int	allow_panic;		/* allow panic correction (-g) */
458 extern int	enable_panic_check;	/* Can we check allow_panic's state? */
459 extern int	force_step_once;	/* always step time once at startup (-G) */
460 extern int	mode_ntpdate;		/* exit on first clock set (-q) */
461 extern int	peer_ntpdate;		/* count of ntpdate peers */
462 
463 /*
464  * Clock state machine variables
465  */
466 extern u_char	sys_poll;		/* system poll interval (log2 s) */
467 extern int	state;			/* clock discipline state */
468 extern int	tc_counter;		/* poll-adjust counter */
469 extern u_long	last_time;		/* time of last clock update (s) */
470 extern double	last_offset;		/* last clock offset (s) */
471 extern u_char	allan_xpt;		/* Allan intercept (log2 s) */
472 extern double	clock_jitter;		/* clock jitter (s) */
473 extern double	sys_offset;		/* system offset (s) */
474 extern double	sys_jitter;		/* system jitter (s) */
475 
476 /* ntp_monitor.c */
477 extern u_char	mon_hash_bits;		/* log2 size of hash table */
478 extern mon_entry ** mon_hash;		/* MRU hash table */
479 extern mon_entry mon_mru_list;		/* mru listhead */
480 extern u_int	mon_enabled;		/* MON_OFF (0) or other MON_* */
481 extern u_int	mru_alloc;		/* mru list + free list count */
482 extern u_int	mru_entries;		/* mru list count */
483 extern u_int	mru_peakentries;	/* highest mru_entries */
484 extern u_int	mru_initalloc;		/* entries to preallocate */
485 extern u_int	mru_incalloc;		/* allocation batch factor */
486 extern u_int	mru_mindepth;		/* preempt above this */
487 extern int	mru_maxage;		/* for entries older than */
488 extern u_int	mru_maxdepth; 		/* MRU size hard limit */
489 extern int	mon_age;		/* preemption limit */
490 
491 /* ntp_peer.c */
492 extern struct peer *peer_hash[NTP_HASH_SIZE];	/* peer hash table */
493 extern int	peer_hash_count[NTP_HASH_SIZE];	/* count of in each bucket */
494 extern struct peer *assoc_hash[NTP_HASH_SIZE];	/* association ID hash table */
495 extern int	assoc_hash_count[NTP_HASH_SIZE];/* count of in each bucket */
496 extern struct peer *peer_list;		/* peer structures list */
497 extern int	peer_count;		/* count in peer_list */
498 extern int	peer_free_count;	/* count in peer_free */
499 
500 /*
501  * Miscellaneous statistic counters which may be queried.
502  */
503 extern u_long	peer_timereset;		/* time stat counters were zeroed */
504 extern u_long	findpeer_calls;		/* number of calls to findpeer */
505 extern u_long	assocpeer_calls;	/* number of calls to findpeerbyassoc */
506 extern u_long	peer_allocations;	/* number of allocations from the free list */
507 extern u_long	peer_demobilizations;	/* number of structs freed to free list */
508 extern int	total_peer_structs;	/* number of peer structs in circulation */
509 extern int	peer_associations;	/* mobilized associations */
510 extern int	peer_preempt;		/* preemptable associations */
511 
512 /* ntp_proto.c */
513 /*
514  * System variables are declared here.	See Section 3.2 of the
515  * specification.
516  */
517 extern u_char	sys_leap;		/* system leap indicator */
518 extern u_char	sys_stratum;		/* system stratum */
519 extern s_char	sys_precision;		/* local clock precision */
520 extern double	sys_rootdelay;		/* roundtrip delay to primary source */
521 extern double	sys_rootdisp;		/* dispersion to primary source */
522 extern u_int32	sys_refid;		/* reference id */
523 extern l_fp	sys_reftime;		/* last update time */
524 extern struct peer *sys_peer;		/* current peer */
525 
526 /*
527  * Nonspecified system state variables.
528  */
529 extern int	sys_bclient;		/* we set our time to broadcasts */
530 extern int	sys_mclient;		/* we set our time to manycasts */
531 extern double	sys_bdelay; 		/* broadcast client default delay */
532 extern int	sys_authenticate;	/* requre authentication for config */
533 extern l_fp	sys_authdelay;		/* authentication delay */
534 extern u_char	sys_bcpollbstep;	/* broadcast poll backstep gate */
535 extern u_long 	sys_epoch;		/* last clock update time */
536 extern keyid_t	sys_private;		/* private value for session seed */
537 extern int	sys_manycastserver;	/* respond to manycast client pkts */
538 extern int	sys_maxclock;		/* maximum survivors */
539 extern int	sys_minclock;		/* minimum survivors */
540 extern int	sys_minsane;		/* minimum candidates */
541 extern int	sys_floor;		/* cluster stratum floor */
542 extern int	sys_ceiling;		/* cluster stratum ceiling */
543 extern u_char	sys_ttl[MAX_TTL];	/* ttl mapping vector */
544 extern u_int	sys_ttlmax;		/* max ttl mapping vector index */
545 
546 /*
547  * Statistics counters
548  */
549 extern u_long	sys_badauth;		/* bad authentication */
550 extern u_long	sys_badlength;		/* bad length or format */
551 extern u_long	sys_declined;		/* declined */
552 extern u_long	sys_kodsent;		/* KoD sent */
553 extern u_long	sys_lamport;		/* Lamport violation */
554 extern u_long	sys_limitrejected;	/* rate exceeded */
555 extern u_long	sys_newversion;		/* current version  */
556 extern u_long	sys_oldversion;		/* old version */
557 extern u_long	sys_processed;		/* packets for this host */
558 extern u_long	sys_received;		/* packets received */
559 extern u_long	sys_restricted;		/* access denied */
560 extern u_long	sys_stattime;		/* time since reset */
561 extern u_long	sys_tsrounding;		/* timestamp rounding errors */
562 
563 /* ntp_request.c */
564 extern keyid_t	info_auth_keyid;	/* keyid used to authenticate requests */
565 extern u_long	auth_timereset;
566 
567 /* ntp_restrict.c */
568 extern restrict_u *	restrictlist4;	/* IPv4 restriction list */
569 extern restrict_u *	restrictlist6;	/* IPv6 restriction list */
570 extern int		ntp_minpkt;
571 extern u_char		ntp_minpoll;
572 
573 /* ntp_scanner.c */
574 extern u_int32		conf_file_sum;	/* Simple sum of characters */
575 
576 /* ntp_signd.c */
577 #ifdef HAVE_NTP_SIGND
578 extern void send_via_ntp_signd(struct recvbuf *, int, keyid_t, int,
579 			       struct pkt *);
580 #endif
581 
582 /* ntp_timer.c */
583 extern volatile int alarm_flag;		/* alarm flag */
584 extern volatile u_long alarm_overflow;
585 extern u_long	current_time;		/* seconds since startup */
586 extern u_long	timer_timereset;
587 extern u_long	timer_overflows;
588 extern u_long	timer_xmtcalls;
589 extern int	leap_sec_in_progress;
590 #ifdef LEAP_SMEAR
591 extern struct leap_smear_info leap_smear;
592 extern int	leap_smear_intv;
593 #endif
594 #ifdef SYS_WINNT
595 HANDLE WaitableTimerHandle;
596 #endif
597 
598 /* ntp_util.c */
599 extern	char	statsdir[MAXFILENAME];
600 extern	int	stats_control;		/* write stats to fileset? */
601 extern	int	stats_write_period;	/* # of seconds between writes. */
602 extern	double	stats_write_tolerance;
603 extern	double	wander_threshold;
604 
605 /* ntpd.c */
606 extern	int	nofork;		/* no-fork flag */
607 extern	int	initializing;	/* initializing flag */
608 #ifdef HAVE_DROPROOT
609 extern	int	droproot;	/* flag: try to drop root privileges after startup */
610 extern	int	root_dropped;	/* root has been dropped */
611 extern char *user;		/* user to switch to */
612 extern char *group;		/* group to switch to */
613 extern const char *chrootdir;	/* directory to chroot() to */
614 #endif
615 #ifdef HAVE_WORKING_FORK
616 extern	int	daemon_pipe[2];	/* startup monitoring */
617 #endif
618 
619 /* ntservice.c */
620 #ifdef SYS_WINNT
621 extern int accept_wildcard_if_for_winnt;
622 #endif
623 
624 /* refclock_conf.c */
625 #ifdef REFCLOCK
626 /* refclock configuration table */
627 extern struct refclock * const refclock_conf[];
628 extern u_char	num_refclock_conf;
629 #endif
630 
631