/*
* ntpd.h - Prototypes and external variables for ntpd.
*
* Note the first half is primarily function prototypes, type
* declarations, and preprocessor macros, with variables declared
* primarily in the second half.
*
* Each half is further divided into sections for each source file.
*/
/*
* macro for debugging output - cut down on #ifdef pollution.
*
* DPRINTF() is for use by ntpd only, and compiles away to nothing
* without DEBUG (configure --disable-debugging).
*
* TRACE() is similar for libntp and utilities, which retain full
* debug capability even when compiled without DEBUG.
*
* The calling convention is not attractive:
* DPRINTF(debuglevel, (fmt, ...));
* DPRINTF(2, ("shows #ifdef DEBUG and if debug >= %d\n", 2));
*/
#ifdef DEBUG
# define DPRINTF(lvl, arg) \
do { \
if (debug >= (lvl)) \
mprintf arg; \
} while (0)
#else
# define DPRINTF(lvl, arg) do {} while (0)
#endif
/* clear bitflag only on DEBUG builds */
#ifdef DEBUG
# define CLEAR_BIT_IF_DEBUG(bit, flags) \
do { \
(flags) &= ~(bit); \
} while (FALSE)
#else
# define CLEAR_BIT_IF_DEBUG(bit, flags) \
do {} while (FALSE)
#endif
extern u_long leapsec; /* seconds to next leap (proximity class) */
extern int leapdif; /* TAI difference step at next leap second */
extern int sys_orphan;
extern double sys_mindisp;
extern double sys_maxdist;
#ifdef BC_LIST_FRAMEWORK_NOT_YET_USED
/*
* backwards compatibility flags
*/
typedef struct bc_entry_tag {
int token;
int enabled;
} bc_entry;
extern bc_entry bc_list[];
#endif
/* ntp_control.c */
extern int num_ctl_traps;
extern keyid_t ctl_auth_keyid; /* keyid used for authenticating write requests */
/*
* Statistic counters to keep track of requests and responses.
*/
extern u_long ctltimereset; /* time stats reset */
extern u_long numctlreq; /* number of requests we've received */
extern u_long numctlbadpkts; /* number of bad control packets */
extern u_long numctlresponses; /* number of resp packets sent with data */
extern u_long numctlfrags; /* number of fragments sent */
extern u_long numctlerrors; /* number of error responses sent */
extern u_long numctltooshort; /* number of too short input packets */
extern u_long numctlinputresp; /* number of responses on input */
extern u_long numctlinputfrag; /* number of fragments on input */
extern u_long numctlinputerr; /* number of input pkts with err bit set */
extern u_long numctlbadoffset; /* number of input pkts with nonzero offset */
extern u_long numctlbadversion; /* number of input pkts with unknown version */
extern u_long numctldatatooshort; /* data too short for count */
extern u_long numctlbadop; /* bad op code found in packet */
extern u_long numasyncmsgs; /* number of async messages we've sent */
/*
* Other statistics of possible interest
*/
extern volatile u_long packets_dropped; /* total number of packets dropped on reception */
extern volatile u_long packets_ignored; /* packets received on wild card interface */
extern volatile u_long packets_received;/* total number of packets received */
extern u_long packets_sent; /* total number of packets sent */
extern u_long packets_notsent; /* total number of packets which couldn't be sent */
extern volatile u_long handler_calls; /* number of calls to interrupt handler */
extern volatile u_long handler_pkts; /* number of pkts received by handler */
extern u_long io_timereset; /* time counters were reset */
/* ntp_io.c */
extern int no_periodic_scan; /* no periodic net addr scans */
extern int scan_addrs_once; /* no net addr rescans */
extern int nonlocal_v4_addr_up; /* should we try IPv4 pool? */
extern int nonlocal_v6_addr_up; /* should we try IPv6 pool? */
extern u_int sys_ifnum; /* next .ifnum to assign */
extern endpt * any_interface; /* IPv4 wildcard */
extern endpt * any6_interface; /* IPv6 wildcard */
extern endpt * loopback_interface; /* IPv4 loopback for refclocks */
extern endpt * ep_list; /* linked list */
/* ntp_loopfilter.c */
extern double drift_comp; /* clock frequency (s/s) */
extern double clock_stability; /* clock stability (s/s) */
extern double clock_max_back; /* max backward offset before step (s) */
extern double clock_max_fwd; /* max forward offset before step (s) */
extern double clock_panic; /* max offset before panic (s) */
extern double clock_phi; /* dispersion rate (s/s) */
extern double clock_minstep; /* step timeout (s) */
extern double clock_codec; /* codec frequency */
#ifdef KERNEL_PLL
extern int pll_status; /* status bits for kernel pll */
#endif /* KERNEL_PLL */
/*
* Clock state machine control flags
*/
extern int ntp_enable; /* clock discipline enabled */
extern int pll_control; /* kernel support available */
extern int kern_enable; /* kernel support enabled */
extern int hardpps_enable; /* kernel PPS discipline enabled */
extern int ext_enable; /* external clock enabled */
extern int cal_enable; /* refclock calibrate enable */
extern int allow_panic; /* allow panic correction (-g) */
extern int enable_panic_check; /* Can we check allow_panic's state? */
extern int force_step_once; /* always step time once at startup (-G) */
extern int mode_ntpdate; /* exit on first clock set (-q) */
extern int peer_ntpdate; /* count of ntpdate peers */
/*
* Clock state machine variables
*/
extern u_char sys_poll; /* system poll interval (log2 s) */
extern int state; /* clock discipline state */
extern int tc_counter; /* poll-adjust counter */
extern u_long last_time; /* time of last clock update (s) */
extern double last_offset; /* last clock offset (s) */
extern u_char allan_xpt; /* Allan intercept (log2 s) */
extern double clock_jitter; /* clock jitter (s) */
extern double sys_offset; /* system offset (s) */
extern double sys_jitter; /* system jitter (s) */
/* ntp_monitor.c */
extern u_char mon_hash_bits; /* log2 size of hash table */
extern mon_entry ** mon_hash; /* MRU hash table */
extern mon_entry mon_mru_list; /* mru listhead */
extern u_int mon_enabled; /* MON_OFF (0) or other MON_* */
extern u_int mru_alloc; /* mru list + free list count */
extern u_int mru_entries; /* mru list count */
extern u_int mru_peakentries; /* highest mru_entries */
extern u_int mru_initalloc; /* entries to preallocate */
extern u_int mru_incalloc; /* allocation batch factor */
extern u_int mru_mindepth; /* preempt above this */
extern int mru_maxage; /* for entries older than */
extern u_int mru_maxdepth; /* MRU size hard limit */
extern int mon_age; /* preemption limit */
/* ntp_peer.c */
extern struct peer *peer_hash[NTP_HASH_SIZE]; /* peer hash table */
extern int peer_hash_count[NTP_HASH_SIZE]; /* count of in each bucket */
extern struct peer *assoc_hash[NTP_HASH_SIZE]; /* association ID hash table */
extern int assoc_hash_count[NTP_HASH_SIZE];/* count of in each bucket */
extern struct peer *peer_list; /* peer structures list */
extern int peer_count; /* count in peer_list */
extern int peer_free_count; /* count in peer_free */
/*
* Miscellaneous statistic counters which may be queried.
*/
extern u_long peer_timereset; /* time stat counters were zeroed */
extern u_long findpeer_calls; /* number of calls to findpeer */
extern u_long assocpeer_calls; /* number of calls to findpeerbyassoc */
extern u_long peer_allocations; /* number of allocations from the free list */
extern u_long peer_demobilizations; /* number of structs freed to free list */
extern int total_peer_structs; /* number of peer structs in circulation */
extern int peer_associations; /* mobilized associations */
extern int peer_preempt; /* preemptable associations */
/* ntp_proto.c */
/*
* System variables are declared here. See Section 3.2 of the
* specification.
*/
extern u_char sys_leap; /* system leap indicator */
extern u_char sys_stratum; /* system stratum */
extern s_char sys_precision; /* local clock precision */
extern double sys_rootdelay; /* roundtrip delay to primary source */
extern double sys_rootdisp; /* dispersion to primary source */
extern u_int32 sys_refid; /* reference id */
extern l_fp sys_reftime; /* last update time */
extern struct peer *sys_peer; /* current peer */
/*
* Nonspecified system state variables.
*/
extern int sys_bclient; /* we set our time to broadcasts */
extern int sys_mclient; /* we set our time to manycasts */
extern double sys_bdelay; /* broadcast client default delay */
extern int sys_authenticate; /* requre authentication for config */
extern l_fp sys_authdelay; /* authentication delay */
extern u_char sys_bcpollbstep; /* broadcast poll backstep gate */
extern u_long sys_epoch; /* last clock update time */
extern keyid_t sys_private; /* private value for session seed */
extern int sys_manycastserver; /* respond to manycast client pkts */
extern int sys_maxclock; /* maximum survivors */
extern int sys_minclock; /* minimum survivors */
extern int sys_minsane; /* minimum candidates */
extern int sys_floor; /* cluster stratum floor */
extern int sys_ceiling; /* cluster stratum ceiling */
extern u_char sys_ttl[MAX_TTL]; /* ttl mapping vector */
extern u_int sys_ttlmax; /* max ttl mapping vector index */
/*
* Statistics counters
*/
extern u_long sys_badauth; /* bad authentication */
extern u_long sys_badlength; /* bad length or format */
extern u_long sys_declined; /* declined */
extern u_long sys_kodsent; /* KoD sent */
extern u_long sys_lamport; /* Lamport violation */
extern u_long sys_limitrejected; /* rate exceeded */
extern u_long sys_newversion; /* current version */
extern u_long sys_oldversion; /* old version */
extern u_long sys_processed; /* packets for this host */
extern u_long sys_received; /* packets received */
extern u_long sys_restricted; /* access denied */
extern u_long sys_stattime; /* time since reset */
extern u_long sys_tsrounding; /* timestamp rounding errors */
/* ntp_request.c */
extern keyid_t info_auth_keyid; /* keyid used to authenticate requests */
extern u_long auth_timereset;
/* ntp_restrict.c */
extern struct restrict_4 * restrictlist4; /* IPv4 restriction list */
extern struct restrict_6 * restrictlist6; /* IPv6 restriction list */
extern int ntp_minpkt;
extern u_char ntp_minpoll;
/* ntp_scanner.c */
extern u_int32 conf_file_sum; /* Simple sum of characters */
/* ntp_timer.c */
extern volatile int alarm_flag; /* alarm flag */
extern volatile u_long alarm_overflow;
extern u_long current_time; /* seconds since startup */
extern u_long timer_timereset;
extern u_long timer_overflows;
extern u_long timer_xmtcalls;
extern int leap_sec_in_progress;
#ifdef LEAP_SMEAR
extern struct leap_smear_info leap_smear;
extern int leap_smear_intv;
#endif
#ifdef SYS_WINNT
HANDLE WaitableTimerHandle;
#endif
/* ntp_util.c */
extern char statsdir[MAXFILENAME];
extern int stats_control; /* write stats to fileset? */
extern int stats_write_period; /* # of seconds between writes. */
extern double stats_write_tolerance;
extern double wander_threshold;
/* ntpd.c */
extern int nofork; /* no-fork flag */
extern int initializing; /* initializing flag */
#ifdef HAVE_DROPROOT
extern int droproot; /* flag: try to drop root privileges after startup */
extern int root_dropped; /* root has been dropped */
extern char *user; /* user to switch to */
extern char *group; /* group to switch to */
extern const char *chrootdir; /* directory to chroot() to */
#endif
#ifdef HAVE_WORKING_FORK
extern int daemon_pipe[2]; /* startup monitoring */
#endif
/* ntservice.c */
#ifdef SYS_WINNT
extern int accept_wildcard_if_for_winnt;
#endif