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