PageRenderTime 47ms CodeModel.GetById 14ms app.highlight 29ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/ntp/include/ntpd.h

https://bitbucket.org/freebsd/freebsd-head/
C++ Header | 472 lines | 332 code | 54 blank | 86 comment | 0 complexity | e8560f109e2550b393004e59b4e24dd6 MD5 | raw file
  1/*
  2 * ntpd.h - Prototypes for ntpd.
  3 */
  4
  5#include "ntp_syslog.h"
  6#include "ntp_fp.h"
  7#include "ntp.h"
  8#include "ntp_debug.h"
  9#include "ntp_select.h"
 10#include "ntp_malloc.h"
 11#include "ntp_refclock.h"
 12#include "recvbuff.h"
 13
 14
 15/* ntp_config.c */
 16extern	void	getconfig	P((int, char **));
 17
 18/* ntp_config.c */
 19extern	void	ctl_clr_stats	P((void));
 20extern	int	ctlclrtrap	P((struct sockaddr_storage *, struct interface *, int));
 21extern	u_short ctlpeerstatus	P((struct peer *));
 22extern	int	ctlsettrap	P((struct sockaddr_storage *, struct interface *, int, int));
 23extern	u_short ctlsysstatus	P((void));
 24extern	void	init_control	P((void));
 25extern	void	process_control P((struct recvbuf *, int));
 26extern	void	report_event	P((int, struct peer *));
 27
 28extern	double	fabs		P((double));
 29extern	double	sqrt		P((double));
 30
 31/* ntp_control.c */
 32/*
 33 * Structure for translation tables between internal system
 34 * variable indices and text format.
 35 */
 36struct ctl_var {
 37	u_short code;
 38	u_short flags;
 39	char *text;
 40};
 41/*
 42 * Flag values
 43 */
 44#define	CAN_READ	0x01
 45#define	CAN_WRITE	0x02
 46
 47#define DEF		0x20
 48#define	PADDING		0x40
 49#define	EOV		0x80
 50
 51#define	RO	(CAN_READ)
 52#define	WO	(CAN_WRITE)
 53#define	RW	(CAN_READ|CAN_WRITE)
 54
 55extern  char *  add_var P((struct ctl_var **, u_long, u_short));
 56extern  void    free_varlist P((struct ctl_var *));
 57extern  void    set_var P((struct ctl_var **, const char *, u_long, u_short));
 58extern  void    set_sys_var P((const char *, u_long, u_short));
 59
 60/* ntp_intres.c */
 61extern	void	ntp_res_name	P((struct sockaddr_storage, u_short));
 62extern	void	ntp_res_recv	P((void));
 63extern	void	ntp_intres	P((void));
 64
 65/* ntp_io.c */
 66typedef struct interface_info {
 67	struct interface *interface;
 68	u_char       action;
 69} interface_info_t;
 70
 71typedef void (*interface_receiver_t)(void *, interface_info_t *);
 72
 73extern  volatile int disable_dynamic_updates;
 74
 75extern  void    interface_enumerate P((interface_receiver_t, void *));
 76extern	struct interface *findinterface P((struct sockaddr_storage *));
 77extern  struct interface *findbcastinter P((struct sockaddr_storage *));
 78extern  void	enable_broadcast P((struct interface *, struct sockaddr_storage *));
 79extern  void	enable_multicast_if P((struct interface *, struct sockaddr_storage *));
 80extern	void	interface_dump	 P((struct interface *));
 81
 82extern  void    interface_update P((interface_receiver_t, void *));
 83extern	void	init_io 	P((void));
 84extern	void	input_handler	P((l_fp *));
 85extern	void	io_clr_stats	P((void));
 86extern	void	io_setbclient	P((void));
 87extern	void	io_unsetbclient P((void));
 88extern	void	io_multicast_add P((struct sockaddr_storage));
 89extern	void	io_multicast_del P((struct sockaddr_storage));
 90extern	void	kill_asyncio	 P((int));
 91extern	void	sendpkt 	P((struct sockaddr_storage *, struct interface *, int, struct pkt *, int));
 92#ifdef DEBUG
 93extern  void    collect_timing  P((struct recvbuf *, const char *, int, l_fp *));
 94#endif
 95#ifdef HAVE_SIGNALED_IO
 96extern	void	wait_for_signal P((void));
 97extern	void	unblock_io_and_alarm P((void));
 98extern	void	block_io_and_alarm P((void));
 99#define UNBLOCK_IO_AND_ALARM() unblock_io_and_alarm()
100#define BLOCK_IO_AND_ALARM() block_io_and_alarm()
101#else
102#define UNBLOCK_IO_AND_ALARM()
103#define BLOCK_IO_AND_ALARM()
104#endif
105
106/* ntp_leap.c */
107extern	void	init_leap	P((void));
108extern	void	leap_process	P((void));
109extern	int 	leap_setleap	P((int, int));
110/*
111 * there seems to be a bug in the IRIX 4 compiler which prevents
112 * u_char from beeing used in prototyped functions.
113 * This is also true AIX compiler.
114 * So give up and define it to be int. WLJ
115 */
116extern	int	leap_actual P((int));
117
118/* ntp_loopfilter.c */
119extern	void	init_loopfilter P((void));
120extern	int 	local_clock P((struct peer *, double));
121extern	void	adj_host_clock	P((void));
122extern	void	loop_config P((int, double));
123extern	void	huffpuff	P((void));
124extern	u_long	sys_clocktime;
125extern	u_long	sys_tai;
126
127/* ntp_monitor.c */
128extern	void	init_mon	P((void));
129extern	void	mon_start	P((int));
130extern	void	mon_stop	P((int));
131extern	int	ntp_monitor     P((struct recvbuf *));
132extern  void    ntp_monclearinterface P((struct interface *interface));
133
134/* ntp_peer.c */
135extern	void	init_peer	P((void));
136extern	struct peer *findexistingpeer P((struct sockaddr_storage *, struct peer *, int));
137extern	struct peer *findpeer	P((struct sockaddr_storage *, struct interface *, int, int *));
138extern	struct peer *findpeerbyassoc P((u_int));
139extern  void         set_peerdstadr       P((struct peer *peer, struct interface *interface));
140extern	struct peer *newpeer	P((struct sockaddr_storage *, struct interface *, int, int, int, int, u_int, u_char, int, keyid_t));
141extern	void	peer_all_reset	P((void));
142extern	void	peer_clr_stats	P((void));
143extern	struct peer *peer_config P((struct sockaddr_storage *, struct interface *, int, int, int, int, u_int, int, keyid_t, u_char *));
144extern	void	peer_reset	P((struct peer *));
145extern	int 	peer_unconfig	P((struct sockaddr_storage *, struct interface *, int));
146extern  void    refresh_all_peerinterfaces P((void));
147extern	void	unpeer		P((struct peer *));
148extern	void	clear_all	P((void));
149
150#ifdef OPENSSL
151extern	void	expire_all	P((void));
152#endif /* OPENSSL */
153extern	struct	peer *findmanycastpeer	P((struct recvbuf *));
154
155/* ntp_crypto.c */
156#ifdef OPENSSL
157extern	int	crypto_recv	P((struct peer *, struct recvbuf *));
158extern	int	crypto_xmit	P((struct pkt *, struct sockaddr_storage *, int, struct exten *, keyid_t));
159extern	keyid_t	session_key	P((struct sockaddr_storage *, struct sockaddr_storage *, keyid_t, keyid_t, u_long));
160extern	int	make_keylist	P((struct peer *, struct interface *));
161extern	void	key_expire	P((struct peer *));
162extern	void	crypto_update	P((void));
163extern	void	crypto_config	P((int, char *));
164extern	void	crypto_setup	P((void));
165extern	u_int	crypto_ident	P((struct peer *));
166extern	struct exten *crypto_args P((struct peer *, u_int, char *));
167extern	int	crypto_public	P((struct peer *, u_char *, u_int));
168extern	void	value_free	P((struct value *));
169extern	char	*iffpar_file;
170extern	EVP_PKEY *iffpar_pkey;
171extern	char	*gqpar_file;
172extern	EVP_PKEY *gqpar_pkey;
173extern	char	*mvpar_file;
174extern	EVP_PKEY *mvpar_pkey;
175extern struct value tai_leap;
176#endif /* OPENSSL */
177
178/* ntp_proto.c */
179extern	void	transmit	P((struct peer *));
180extern	void	receive 	P((struct recvbuf *));
181extern  void    peer_crypto_clear P((struct peer *peer));
182extern	void	peer_clear	P((struct peer *, char *));
183extern	void 	process_packet	P((struct peer *, struct pkt *));
184extern	void	clock_select	P((void));
185extern	void	kod_proto	P((void));
186
187/*
188 * there seems to be a bug in the IRIX 4 compiler which prevents
189 * u_char from beeing used in prototyped functions.
190 * This is also true AIX compiler.
191 * So give up and define it to be int. WLJ
192 */
193extern	void	poll_update P((struct peer *, int));
194
195extern	void	clear		P((struct peer *));
196extern	void	clock_filter	P((struct peer *, double, double, double));
197extern	void	init_proto	P((void));
198extern	void	proto_config	P((int, u_long, double, struct sockaddr_storage*));
199extern	void	proto_clr_stats P((void));
200
201#ifdef	REFCLOCK
202/* ntp_refclock.c */
203extern	int	refclock_newpeer P((struct peer *));
204extern	void	refclock_unpeer P((struct peer *));
205extern	void	refclock_receive P((struct peer *));
206extern	void	refclock_transmit P((struct peer *));
207extern	void	init_refclock	P((void));
208#endif	/* REFCLOCK */
209
210/* ntp_request.c */
211extern	void	init_request	P((void));
212extern	void	process_private P((struct recvbuf *, int));
213
214/* ntp_restrict.c */
215extern	void	init_restrict	P((void));
216extern	int 	restrictions	P((struct sockaddr_storage *, int));
217extern	void	hack_restrict	P((int, struct sockaddr_storage *, struct sockaddr_storage *, int, int));
218
219/* ntp_timer.c */
220extern	void	init_timer	P((void));
221extern	void	reinit_timer	P((void));
222extern	void	timer		P((void));
223extern	void	timer_clr_stats P((void));
224extern  void    timer_interfacetimeout P((u_long));
225extern  volatile int interface_interval;
226
227#ifdef OPENSSL
228extern	char	*sys_hostname;
229extern	l_fp	sys_revoketime;
230#endif /* OPENSSL */
231
232/* ntp_util.c */
233extern	void	init_util	P((void));
234extern	void	write_stats	P((void));
235extern	void	stats_config	P((int, const char *));
236extern	void	record_peer_stats P((struct sockaddr_storage *, int, double, double, double, double));
237extern	void	record_loop_stats P((double, double, double, double, int));
238extern	void	record_clock_stats P((struct sockaddr_storage *, const char *));
239extern	void	record_raw_stats P((struct sockaddr_storage *, struct sockaddr_storage *, l_fp *, l_fp *, l_fp *, l_fp *));
240extern	void	record_sys_stats P((void));
241extern	void	record_crypto_stats P((struct sockaddr_storage *, const char *));
242#ifdef DEBUG
243extern	void	record_timing_stats P((const char *));
244#endif
245extern  int	sock_hash P((struct sockaddr_storage *));
246extern	double	old_drift;
247
248/*
249 * Variable declarations for ntpd.
250 */
251
252/* ntp_config.c */
253extern char const *	progname;
254extern char	*sys_phone[];		/* ACTS phone numbers */
255#if defined(HAVE_SCHED_SETSCHEDULER)
256extern int	config_priority_override;
257extern int	config_priority;
258#endif
259
260/* ntp_control.c */
261extern int	num_ctl_traps;
262extern keyid_t	ctl_auth_keyid;		/* keyid used for authenticating write requests */
263
264/*
265 * Statistic counters to keep track of requests and responses.
266 */
267extern u_long	ctltimereset;		/* time stats reset */
268extern u_long	numctlreq;		/* number of requests we've received */
269extern u_long	numctlbadpkts;		/* number of bad control packets */
270extern u_long	numctlresponses; 	/* number of resp packets sent with data */
271extern u_long	numctlfrags; 		/* number of fragments sent */
272extern u_long	numctlerrors;		/* number of error responses sent */
273extern u_long	numctltooshort;		/* number of too short input packets */
274extern u_long	numctlinputresp; 	/* number of responses on input */
275extern u_long	numctlinputfrag; 	/* number of fragments on input */
276extern u_long	numctlinputerr;		/* number of input pkts with err bit set */
277extern u_long	numctlbadoffset; 	/* number of input pkts with nonzero offset */
278extern u_long	numctlbadversion;	/* number of input pkts with unknown version */
279extern u_long	numctldatatooshort;	/* data too short for count */
280extern u_long	numctlbadop; 		/* bad op code found in packet */
281extern u_long	numasyncmsgs;		/* number of async messages we've sent */
282
283/* ntp_intres.c */
284extern keyid_t	req_keyid;		/* request keyid */
285extern char *	req_file;		/* name of the file with configuration info */
286#ifdef SYS_WINNT
287extern HANDLE ResolverEventHandle;
288#else
289extern int resolver_pipe_fd[2];  /* used to let the resolver process alert the parent process */
290#endif /* SYS_WINNT */
291
292/*
293 * Other statistics of possible interest
294 */
295extern volatile u_long packets_dropped;	/* total number of packets dropped on reception */
296extern volatile u_long packets_ignored;	/* packets received on wild card interface */
297extern volatile u_long packets_received;/* total number of packets received */
298extern u_long	packets_sent;		/* total number of packets sent */
299extern u_long	packets_notsent; 	/* total number of packets which couldn't be sent */
300
301extern volatile u_long handler_calls;	/* number of calls to interrupt handler */
302extern volatile u_long handler_pkts;	/* number of pkts received by handler */
303extern u_long	io_timereset;		/* time counters were reset */
304
305/*
306 * Interface stuff
307 */
308extern struct interface *any_interface;	/* default ipv4 interface */
309extern struct interface *any6_interface;/* default ipv6 interface */
310extern struct interface *loopback_interface; /* loopback interface */
311
312/*
313 * File descriptor masks etc. for call to select
314 */
315extern fd_set	activefds;
316extern int	maxactivefd;
317
318/* ntp_loopfilter.c */
319extern double	drift_comp;		/* clock frequency (s/s) */
320extern double	clock_stability;	/* clock stability (s/s) */
321extern double	clock_max;		/* max offset before step (s) */
322extern double	clock_panic;		/* max offset before panic (s) */
323extern double	clock_phi;		/* dispersion rate (s/s) */
324extern double	clock_minstep;		/* step timeout (s) */
325extern u_long	pps_control;		/* last pps sample time */
326#ifdef KERNEL_PLL
327extern int	pll_status;		/* status bits for kernel pll */
328#endif /* KERNEL_PLL */
329
330/*
331 * Clock state machine control flags
332 */
333extern int	ntp_enable;		/* clock discipline enabled */
334extern int	pll_control;		/* kernel support available */
335extern int	kern_enable;		/* kernel support enabled */
336extern int	pps_enable;		/* kernel PPS discipline enabled */
337extern int	ext_enable;		/* external clock enabled */
338extern int	cal_enable;		/* refclock calibrate enable */
339extern int	allow_panic;		/* allow panic correction */
340extern int	mode_ntpdate;		/* exit on first clock set */
341extern int	peer_ntpdate;		/* count of ntpdate peers */
342
343/*
344 * Clock state machine variables
345 */
346extern u_char	sys_poll;		/* system poll interval (log2 s) */
347extern int	state;			/* clock discipline state */
348extern int	tc_counter;		/* poll-adjust counter */
349extern u_long	last_time;		/* time of last clock update (s) */
350extern double	last_offset;		/* last clock offset (s) */
351extern double	allan_xpt;		/* Allan intercept (s) */
352extern double	clock_jitter;		/* clock jitter (s) */
353extern double	sys_jitter;		/* system jitter (s) */
354
355/* ntp_monitor.c */
356extern struct mon_data mon_mru_list;
357extern struct mon_data mon_fifo_list;
358extern int	mon_enabled;
359
360/* ntp_peer.c */
361extern struct peer *peer_hash[];	/* peer hash table */
362extern int	peer_hash_count[];	/* count of peers in each bucket */
363extern struct peer *assoc_hash[];	/* association ID hash table */
364extern int	assoc_hash_count[];
365extern int	peer_free_count;
366
367/*
368 * Miscellaneous statistic counters which may be queried.
369 */
370extern u_long	peer_timereset;		/* time stat counters were zeroed */
371extern u_long	findpeer_calls;		/* number of calls to findpeer */
372extern u_long	assocpeer_calls;	/* number of calls to findpeerbyassoc */
373extern u_long	peer_allocations;	/* number of allocations from the free list */
374extern u_long	peer_demobilizations;	/* number of structs freed to free list */
375extern int	total_peer_structs;	/* number of peer structs in circulation */
376extern int	peer_associations;	/* mobilized associations */
377extern int	peer_preempt;		/* preemptable associations */
378/* ntp_proto.c */
379/*
380 * System variables are declared here.	See Section 3.2 of the
381 * specification.
382 */
383extern u_char	sys_leap;		/* system leap indicator */
384extern u_char	sys_stratum;		/* stratum of system */
385extern s_char	sys_precision;		/* local clock precision */
386extern double	sys_rootdelay;		/* distance to current sync source */
387extern double	sys_rootdispersion;	/* dispersion of system clock */
388extern u_int32	sys_refid;		/* reference source for local clock */
389extern l_fp	sys_reftime;		/* time we were last updated */
390extern struct peer *sys_peer;		/* our current peer */
391extern struct peer *sys_pps;		/* our current PPS peer */
392extern struct peer *sys_prefer;		/* our cherished peer */
393extern u_long	sys_automax;		/* maximum session key lifetime */
394
395/*
396 * Nonspecified system state variables.
397 */
398extern int	sys_bclient;		/* we set our time to broadcasts */
399extern double	sys_bdelay; 		/* broadcast client default delay */
400extern int	sys_authenticate;	/* requre authentication for config */
401extern l_fp	sys_authdelay;		/* authentication delay */
402extern keyid_t	sys_private;		/* private value for session seed */
403extern int	sys_manycastserver;	/* respond to manycast client pkts */
404extern int	sys_minclock;		/* minimum survivors */
405extern int	sys_minsane;		/* minimum candidates */
406extern int	sys_floor;		/* cluster stratum floor */
407extern int	sys_ceiling;		/* cluster stratum ceiling */
408extern u_char	sys_ttl[];		/* ttl mapping vector */
409extern int	sys_ttlmax;		/* max ttl mapping vector index */
410extern int	leap_next;		/* leap consensus */
411
412/*
413 * Statistics counters
414 */
415extern u_long	sys_stattime;		/* time when we started recording */
416extern u_long	sys_restricted;	 	/* restricted packets */
417extern u_long	sys_oldversionpkt;	/* old version packets */
418extern u_long	sys_newversionpkt;	/* new version packets  */
419extern u_long	sys_unknownversion;	/* don't know version packets */
420extern u_long	sys_badlength;		/* bad length or format */
421extern u_long	sys_processed;		/* packets processed */
422extern u_long	sys_badauth;		/* bad authentication */
423extern u_long	sys_limitrejected;	/* rate limit exceeded */
424extern u_long	sys_received;		/* packets received */
425
426/* ntp_refclock.c */
427#ifdef REFCLOCK
428#ifdef PPS
429extern int	fdpps;			/* pps file descriptor */
430#endif /* PPS */
431#endif
432
433/* ntp_request.c */
434extern keyid_t	info_auth_keyid;	/* keyid used to authenticate requests */
435
436/* ntp_restrict.c */
437extern struct restrictlist *restrictlist; /* the ipv4 restriction list */
438extern struct restrictlist6 *restrictlist6; /* the ipv6 restriction list */
439extern u_long	res_min_interval;
440extern u_long	res_avg_interval;
441extern u_long	mon_age;		/* monitor preempt age */
442
443/* ntp_timer.c */
444extern volatile int alarm_flag;		/* alarm flag */
445extern u_char	sys_revoke;		/* keys revoke timeout (log2 s) */
446extern volatile u_long alarm_overflow;
447extern u_long	current_time;		/* current time (s) */
448extern u_long	timer_timereset;
449extern u_long	timer_overflows;
450extern u_long	timer_xmtcalls;
451
452/* ntp_util.c */
453extern int	stats_control;		/* write stats to fileset? */
454extern int	stats_write_period;	/* # of seconds between writes. */
455extern double	stats_write_tolerance;
456
457/* ntpd.c */
458extern volatile int debug;		/* debugging flag */
459extern int	nofork;			/* no-fork flag */
460extern int 	initializing;		/* initializing flag */
461#ifdef HAVE_DROPROOT
462extern int droproot;			/* flag: try to drop root privileges after startup */
463extern char *user;			/* user to switch to */
464extern char *group;			/* group to switch to */
465extern char *chrootdir;			/* directory to chroot to */
466#endif
467
468/* refclock_conf.c */
469#ifdef REFCLOCK
470extern struct refclock *refclock_conf[]; /* refclock configuration table */
471extern u_char	num_refclock_conf;
472#endif