1999-12-09 13:01:21 +00:00
|
|
|
/*
|
2014-12-20 22:52:39 +00:00
|
|
|
* 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.
|
1999-12-09 13:01:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ntp.h"
|
2014-12-20 22:52:39 +00:00
|
|
|
#include "ntp_stdlib.h"
|
|
|
|
#include "ntp_syslog.h"
|
2008-08-18 14:26:05 +00:00
|
|
|
#include "ntp_debug.h"
|
2013-12-04 21:33:17 +00:00
|
|
|
#include "ntp_syslog.h"
|
1999-12-09 13:01:21 +00:00
|
|
|
#include "ntp_select.h"
|
|
|
|
#include "ntp_malloc.h"
|
|
|
|
#include "ntp_refclock.h"
|
2014-12-20 22:52:39 +00:00
|
|
|
#include "ntp_intres.h"
|
1999-12-09 13:01:21 +00:00
|
|
|
#include "recvbuff.h"
|
|
|
|
|
2014-12-20 22:52:39 +00:00
|
|
|
/*
|
|
|
|
* First half: ntpd types, functions, macros
|
|
|
|
* -----------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
|
|
|
|
|
|
|
/* nt_clockstuff.c */
|
|
|
|
#ifdef SYS_WINNT
|
|
|
|
extern void win_time_stepped(void);
|
|
|
|
#endif
|
1999-12-09 13:01:21 +00:00
|
|
|
|
2014-12-20 22:52:39 +00:00
|
|
|
/* ntp_config.c */
|
2013-12-04 21:33:17 +00:00
|
|
|
#define TAI_1972 10 /* initial TAI offset (s) */
|
|
|
|
extern char *keysdir; /* crypto keys and leaptable directory */
|
|
|
|
extern char * saveconfigdir; /* ntpq saveconfig output directory */
|
|
|
|
|
|
|
|
extern void getconfig (int, char **);
|
|
|
|
extern void ctl_clr_stats (void);
|
|
|
|
extern int ctlclrtrap (sockaddr_u *, struct interface *, int);
|
|
|
|
extern u_short ctlpeerstatus (struct peer *);
|
|
|
|
extern int ctlsettrap (sockaddr_u *, struct interface *, int, int);
|
|
|
|
extern u_short ctlsysstatus (void);
|
|
|
|
extern void init_control (void);
|
|
|
|
extern void process_control (struct recvbuf *, int);
|
|
|
|
extern void report_event (int, struct peer *, const char *);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern int mprintf_event (int, struct peer *, const char *, ...)
|
|
|
|
NTP_PRINTF(3, 4);
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_control.c */
|
|
|
|
/*
|
|
|
|
* Structure for translation tables between internal system
|
|
|
|
* variable indices and text format.
|
|
|
|
*/
|
|
|
|
struct ctl_var {
|
|
|
|
u_short code;
|
|
|
|
u_short flags;
|
2015-02-05 20:53:33 +00:00
|
|
|
const char *text;
|
1999-12-09 13:01:21 +00:00
|
|
|
};
|
|
|
|
/*
|
|
|
|
* Flag values
|
|
|
|
*/
|
|
|
|
#define CAN_READ 0x01
|
|
|
|
#define CAN_WRITE 0x02
|
|
|
|
|
|
|
|
#define DEF 0x20
|
|
|
|
#define PADDING 0x40
|
|
|
|
#define EOV 0x80
|
|
|
|
|
|
|
|
#define RO (CAN_READ)
|
|
|
|
#define WO (CAN_WRITE)
|
|
|
|
#define RW (CAN_READ|CAN_WRITE)
|
|
|
|
|
2014-12-20 22:52:39 +00:00
|
|
|
extern char * add_var (struct ctl_var **, u_long, u_short);
|
|
|
|
extern void free_varlist (struct ctl_var *);
|
|
|
|
extern void set_var (struct ctl_var **, const char *, u_long, u_short);
|
|
|
|
extern void set_sys_var (const char *, u_long, u_short);
|
|
|
|
extern const char * get_ext_sys_var(const char *tag);
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_io.c */
|
2008-08-18 14:26:05 +00:00
|
|
|
typedef struct interface_info {
|
2013-12-04 21:33:17 +00:00
|
|
|
endpt * ep;
|
|
|
|
u_char action;
|
2008-08-18 14:26:05 +00:00
|
|
|
} interface_info_t;
|
|
|
|
|
2013-12-04 21:33:17 +00:00
|
|
|
typedef void (*interface_receiver_t) (void *, interface_info_t *);
|
|
|
|
|
|
|
|
extern void interface_enumerate (interface_receiver_t, void *);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern endpt * getinterface (sockaddr_u *, u_int32);
|
|
|
|
extern endpt * select_peerinterface (struct peer *, sockaddr_u *,
|
|
|
|
endpt *);
|
2013-12-04 21:33:17 +00:00
|
|
|
extern endpt * findinterface (sockaddr_u *);
|
|
|
|
extern endpt * findbcastinter (sockaddr_u *);
|
|
|
|
extern void enable_broadcast (endpt *, sockaddr_u *);
|
|
|
|
extern void enable_multicast_if (endpt *, sockaddr_u *);
|
|
|
|
extern void interface_update (interface_receiver_t, void *);
|
2014-12-20 22:52:39 +00:00
|
|
|
#ifndef HAVE_IO_COMPLETION_PORT
|
|
|
|
extern void io_handler (void);
|
|
|
|
#endif
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void init_io (void);
|
|
|
|
extern void io_open_sockets (void);
|
|
|
|
extern void io_clr_stats (void);
|
|
|
|
extern void io_setbclient (void);
|
|
|
|
extern void io_unsetbclient (void);
|
|
|
|
extern void io_multicast_add(sockaddr_u *);
|
|
|
|
extern void io_multicast_del(sockaddr_u *);
|
|
|
|
extern void sendpkt (sockaddr_u *, struct interface *, int, struct pkt *, int);
|
2008-08-18 14:26:05 +00:00
|
|
|
#ifdef DEBUG
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void collect_timing (struct recvbuf *, const char *, int, l_fp *);
|
2008-08-18 14:26:05 +00:00
|
|
|
#endif
|
1999-12-09 13:01:21 +00:00
|
|
|
#ifdef HAVE_SIGNALED_IO
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void wait_for_signal (void);
|
|
|
|
extern void unblock_io_and_alarm (void);
|
|
|
|
extern void block_io_and_alarm (void);
|
2014-12-20 22:52:39 +00:00
|
|
|
# define UNBLOCK_IO_AND_ALARM() unblock_io_and_alarm()
|
|
|
|
# define BLOCK_IO_AND_ALARM() block_io_and_alarm()
|
2008-08-18 14:26:05 +00:00
|
|
|
#else
|
2014-12-20 22:52:39 +00:00
|
|
|
# define UNBLOCK_IO_AND_ALARM() do {} while (0)
|
|
|
|
# define BLOCK_IO_AND_ALARM() do {} while (0)
|
1999-12-09 13:01:21 +00:00
|
|
|
#endif
|
2013-12-04 21:33:17 +00:00
|
|
|
#define latoa(pif) localaddrtoa(pif)
|
|
|
|
extern const char * localaddrtoa(endpt *);
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_loopfilter.c */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void init_loopfilter(void);
|
|
|
|
extern int local_clock(struct peer *, double);
|
|
|
|
extern void adj_host_clock(void);
|
|
|
|
extern void loop_config(int, double);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern void select_loop(int);
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void huffpuff(void);
|
2008-08-18 14:26:05 +00:00
|
|
|
extern u_long sys_clocktime;
|
2013-12-04 21:33:17 +00:00
|
|
|
extern u_int sys_tai;
|
2014-12-20 22:52:39 +00:00
|
|
|
extern int freq_cnt;
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_monitor.c */
|
2014-12-20 22:52:39 +00:00
|
|
|
#define MON_HASH_SIZE (1U << mon_hash_bits)
|
|
|
|
#define MON_HASH_MASK (MON_HASH_SIZE - 1)
|
|
|
|
#define MON_HASH(addr) (sock_hash(addr) & MON_HASH_MASK)
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void init_mon (void);
|
|
|
|
extern void mon_start (int);
|
|
|
|
extern void mon_stop (int);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern u_short ntp_monitor (struct recvbuf *, u_short);
|
|
|
|
extern void mon_clearinterface(endpt *interface);
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_peer.c */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void init_peer (void);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern struct peer *findexistingpeer(sockaddr_u *, const char *,
|
|
|
|
struct peer *, int, u_char);
|
2013-12-04 21:33:17 +00:00
|
|
|
extern struct peer *findpeer (struct recvbuf *, int, int *);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern struct peer *findpeerbyassoc(associd_t);
|
|
|
|
extern void set_peerdstadr (struct peer *, endpt *);
|
|
|
|
extern struct peer *newpeer (sockaddr_u *, const char *,
|
|
|
|
endpt *, u_char, u_char,
|
|
|
|
u_char, u_char, u_int, u_char, u_int32,
|
|
|
|
keyid_t, const char *);
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void peer_all_reset (void);
|
|
|
|
extern void peer_clr_stats (void);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern struct peer *peer_config(sockaddr_u *, const char *,
|
|
|
|
endpt *, u_char, u_char,
|
|
|
|
u_char, u_char, u_int, u_int32,
|
|
|
|
keyid_t, const char *);
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void peer_reset (struct peer *);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern void refresh_all_peerinterfaces(void);
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void unpeer (struct peer *);
|
|
|
|
extern void clear_all (void);
|
|
|
|
extern int score_all (struct peer *);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern struct peer *findmanycastpeer(struct recvbuf *);
|
2015-04-10 01:26:02 +00:00
|
|
|
extern void peer_cleanup (void);
|
1999-12-09 13:01:21 +00:00
|
|
|
|
2004-07-20 15:01:56 +00:00
|
|
|
/* ntp_crypto.c */
|
2014-12-20 22:52:39 +00:00
|
|
|
#ifdef AUTOKEY
|
2013-12-04 21:33:17 +00:00
|
|
|
extern int crypto_recv (struct peer *, struct recvbuf *);
|
|
|
|
extern int crypto_xmit (struct peer *, struct pkt *,
|
|
|
|
struct recvbuf *, int,
|
|
|
|
struct exten *, keyid_t);
|
|
|
|
extern keyid_t session_key (sockaddr_u *, sockaddr_u *, keyid_t,
|
|
|
|
keyid_t, u_long);
|
|
|
|
extern int make_keylist (struct peer *, struct interface *);
|
|
|
|
extern void key_expire (struct peer *);
|
|
|
|
extern void crypto_update (void);
|
2015-07-01 03:12:13 +00:00
|
|
|
extern void crypto_update_taichange(void);
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void crypto_config (int, char *);
|
|
|
|
extern void crypto_setup (void);
|
|
|
|
extern u_int crypto_ident (struct peer *);
|
|
|
|
extern struct exten *crypto_args (struct peer *, u_int, associd_t, char *);
|
|
|
|
extern int crypto_public (struct peer *, u_char *, u_int);
|
|
|
|
extern void value_free (struct value *);
|
2008-08-18 14:26:05 +00:00
|
|
|
extern char *iffpar_file;
|
|
|
|
extern EVP_PKEY *iffpar_pkey;
|
|
|
|
extern char *gqpar_file;
|
|
|
|
extern EVP_PKEY *gqpar_pkey;
|
|
|
|
extern char *mvpar_file;
|
|
|
|
extern EVP_PKEY *mvpar_pkey;
|
|
|
|
extern struct value tai_leap;
|
2014-12-20 22:52:39 +00:00
|
|
|
#endif /* AUTOKEY */
|
2004-07-20 15:01:56 +00:00
|
|
|
|
1999-12-09 13:01:21 +00:00
|
|
|
/* ntp_proto.c */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void transmit (struct peer *);
|
|
|
|
extern void receive (struct recvbuf *);
|
2015-02-05 20:53:33 +00:00
|
|
|
extern void peer_clear (struct peer *, const char *);
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void process_packet (struct peer *, struct pkt *, u_int);
|
|
|
|
extern void clock_select (void);
|
2015-07-01 03:12:13 +00:00
|
|
|
extern void set_sys_leap (u_char);
|
2013-12-04 21:33:17 +00:00
|
|
|
|
2014-12-20 22:52:39 +00:00
|
|
|
extern u_long leapsec; /* seconds to next leap (proximity class) */
|
|
|
|
extern int leapdif; /* TAI difference step at next leap second*/
|
2013-12-04 21:33:17 +00:00
|
|
|
extern int sys_orphan;
|
|
|
|
extern double sys_mindisp;
|
|
|
|
extern double sys_maxdist;
|
1999-12-09 13:01:21 +00:00
|
|
|
|
2014-12-20 22:52:39 +00:00
|
|
|
extern char *sys_ident; /* identity scheme */
|
|
|
|
extern void poll_update (struct peer *, u_char);
|
1999-12-09 13:01:21 +00:00
|
|
|
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void clear (struct peer *);
|
|
|
|
extern void clock_filter (struct peer *, double, double, double);
|
|
|
|
extern void init_proto (void);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern void set_sys_tick_precision(double);
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void proto_config (int, u_long, double, sockaddr_u *);
|
|
|
|
extern void proto_clr_stats (void);
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_refclock.c */
|
2014-12-20 22:52:39 +00:00
|
|
|
#ifdef REFCLOCK
|
2013-12-04 21:33:17 +00:00
|
|
|
extern int refclock_newpeer (struct peer *);
|
|
|
|
extern void refclock_unpeer (struct peer *);
|
|
|
|
extern void refclock_receive (struct peer *);
|
|
|
|
extern void refclock_transmit (struct peer *);
|
|
|
|
extern void init_refclock (void);
|
1999-12-09 13:01:21 +00:00
|
|
|
#endif /* REFCLOCK */
|
|
|
|
|
|
|
|
/* ntp_request.c */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void init_request (void);
|
|
|
|
extern void process_private (struct recvbuf *, int);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern void reset_auth_stats(void);
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_restrict.c */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void init_restrict (void);
|
|
|
|
extern u_short restrictions (sockaddr_u *);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern void hack_restrict (int, sockaddr_u *, sockaddr_u *,
|
|
|
|
u_short, u_short, u_long);
|
|
|
|
extern void restrict_source (sockaddr_u *, int, u_long);
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_timer.c */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void init_timer (void);
|
|
|
|
extern void reinit_timer (void);
|
|
|
|
extern void timer (void);
|
|
|
|
extern void timer_clr_stats (void);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern void timer_interfacetimeout (u_long);
|
|
|
|
extern volatile int interface_interval;
|
|
|
|
extern u_long orphwait; /* orphan wait time */
|
|
|
|
#ifdef AUTOKEY
|
2013-12-04 21:33:17 +00:00
|
|
|
extern char *sys_hostname; /* host name */
|
|
|
|
extern char *sys_groupname; /* group name */
|
|
|
|
extern char *group_name; /* group name */
|
2014-12-20 22:52:39 +00:00
|
|
|
extern u_long sys_revoke; /* keys revoke timeout */
|
|
|
|
extern u_long sys_automax; /* session key timeout */
|
|
|
|
#endif /* AUTOKEY */
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_util.c */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void init_util (void);
|
|
|
|
extern void write_stats (void);
|
|
|
|
extern void stats_config (int, const char *);
|
|
|
|
extern void record_peer_stats (sockaddr_u *, int, double, double, double, double);
|
|
|
|
extern void record_proto_stats (char *);
|
|
|
|
extern void record_loop_stats (double, double, double, double, int);
|
|
|
|
extern void record_clock_stats (sockaddr_u *, const char *);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern int mprintf_clock_stats(sockaddr_u *, const char *, ...)
|
|
|
|
NTP_PRINTF(2, 3);
|
2015-02-05 20:53:33 +00:00
|
|
|
extern void record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, int leap, int version, int mode, int stratum, int ppoll, int precision, double root_delay, double root_dispersion, u_int32 refid);
|
2014-12-20 22:52:39 +00:00
|
|
|
extern void check_leap_file (int is_daily_check, u_int32 ntptime, const time_t * systime);
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void record_crypto_stats (sockaddr_u *, const char *);
|
2008-08-18 14:26:05 +00:00
|
|
|
#ifdef DEBUG
|
2013-12-04 21:33:17 +00:00
|
|
|
extern void record_timing_stats (const char *);
|
2008-08-18 14:26:05 +00:00
|
|
|
#endif
|
2013-12-04 21:33:17 +00:00
|
|
|
extern char * fstostr(time_t); /* NTP timescale seconds */
|
2014-12-20 22:52:39 +00:00
|
|
|
|
|
|
|
/* ntpd.c */
|
|
|
|
extern void parse_cmdline_opts(int *, char ***);
|
|
|
|
/*
|
|
|
|
* Signals we catch for debugging.
|
|
|
|
*/
|
|
|
|
#define MOREDEBUGSIG SIGUSR1
|
|
|
|
#define LESSDEBUGSIG SIGUSR2
|
|
|
|
/*
|
|
|
|
* Signals which terminate us gracefully.
|
|
|
|
*/
|
|
|
|
#ifndef SYS_WINNT
|
|
|
|
# define SIGDIE1 SIGHUP
|
|
|
|
# define SIGDIE2 SIGINT
|
|
|
|
# define SIGDIE3 SIGQUIT
|
|
|
|
# define SIGDIE4 SIGTERM
|
|
|
|
#endif /* SYS_WINNT */
|
|
|
|
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/*
|
2014-12-20 22:52:39 +00:00
|
|
|
* Last half: ntpd variables
|
|
|
|
* -------------------------
|
1999-12-09 13:01:21 +00:00
|
|
|
*/
|
2014-12-20 22:52:39 +00:00
|
|
|
|
1999-12-09 13:01:21 +00:00
|
|
|
/* ntp_config.c */
|
|
|
|
extern char const * progname;
|
2008-08-18 14:26:05 +00:00
|
|
|
extern char *sys_phone[]; /* ACTS phone numbers */
|
1999-12-09 13:01:21 +00:00
|
|
|
#if defined(HAVE_SCHED_SETSCHEDULER)
|
|
|
|
extern int config_priority_override;
|
|
|
|
extern int config_priority;
|
|
|
|
#endif
|
2013-12-04 21:33:17 +00:00
|
|
|
extern char *ntp_signd_socket;
|
2014-12-20 22:52:39 +00:00
|
|
|
extern struct config_tree_tag *cfg_tree_history;
|
2013-12-04 21:33:17 +00:00
|
|
|
|
|
|
|
#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
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_control.c */
|
|
|
|
extern int num_ctl_traps;
|
2001-08-29 14:35:15 +00:00
|
|
|
extern keyid_t ctl_auth_keyid; /* keyid used for authenticating write requests */
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 */
|
|
|
|
|
2014-12-20 22:52:39 +00:00
|
|
|
/* ntp_io.c */
|
|
|
|
extern int disable_dynamic_updates;
|
|
|
|
extern u_int sys_ifnum; /* next .ifnum to assign */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern endpt * any_interface; /* IPv4 wildcard */
|
|
|
|
extern endpt * any6_interface; /* IPv6 wildcard */
|
|
|
|
extern endpt * loopback_interface; /* IPv4 loopback for refclocks */
|
2014-12-20 22:52:39 +00:00
|
|
|
extern endpt * ep_list; /* linked list */
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_loopfilter.c */
|
2001-08-29 14:35:15 +00:00
|
|
|
extern double drift_comp; /* clock frequency (s/s) */
|
|
|
|
extern double clock_stability; /* clock stability (s/s) */
|
2015-04-10 01:26:02 +00:00
|
|
|
extern double clock_max_back; /* max backward offset before step (s) */
|
|
|
|
extern double clock_max_fwd; /* max forward offset before step (s) */
|
2001-08-29 14:35:15 +00:00
|
|
|
extern double clock_panic; /* max offset before panic (s) */
|
|
|
|
extern double clock_phi; /* dispersion rate (s/s) */
|
|
|
|
extern double clock_minstep; /* step timeout (s) */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern double clock_codec; /* codec frequency */
|
2001-08-29 14:35:15 +00:00
|
|
|
#ifdef KERNEL_PLL
|
|
|
|
extern int pll_status; /* status bits for kernel pll */
|
|
|
|
#endif /* KERNEL_PLL */
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 */
|
2014-12-20 22:52:39 +00:00
|
|
|
extern int hardpps_enable; /* kernel PPS discipline enabled */
|
1999-12-09 13:01:21 +00:00
|
|
|
extern int ext_enable; /* external clock enabled */
|
2001-08-29 14:35:15 +00:00
|
|
|
extern int cal_enable; /* refclock calibrate enable */
|
2015-04-10 01:26:02 +00:00
|
|
|
extern int allow_panic; /* allow panic correction (-g) */
|
|
|
|
extern int force_step_once; /* always step time once at startup (-G) */
|
|
|
|
extern int mode_ntpdate; /* exit on first clock set (-q) */
|
2001-08-29 14:35:15 +00:00
|
|
|
extern int peer_ntpdate; /* count of ntpdate peers */
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Clock state machine variables
|
|
|
|
*/
|
2001-08-29 14:35:15 +00:00
|
|
|
extern u_char sys_poll; /* system poll interval (log2 s) */
|
1999-12-09 13:01:21 +00:00
|
|
|
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) */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern u_char allan_xpt; /* Allan intercept (log2 s) */
|
2008-08-18 14:26:05 +00:00
|
|
|
extern double clock_jitter; /* clock jitter (s) */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern double sys_offset; /* system offset (s) */
|
2008-08-18 14:26:05 +00:00
|
|
|
extern double sys_jitter; /* system jitter (s) */
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_monitor.c */
|
2014-12-20 22:52:39 +00:00
|
|
|
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 */
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_peer.c */
|
2014-12-20 22:52:39 +00:00
|
|
|
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 */
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 */
|
2008-08-18 14:26:05 +00:00
|
|
|
extern int peer_associations; /* mobilized associations */
|
|
|
|
extern int peer_preempt; /* preemptable associations */
|
2014-12-20 22:52:39 +00:00
|
|
|
|
1999-12-09 13:01:21 +00:00
|
|
|
/* ntp_proto.c */
|
|
|
|
/*
|
|
|
|
* System variables are declared here. See Section 3.2 of the
|
|
|
|
* specification.
|
|
|
|
*/
|
|
|
|
extern u_char sys_leap; /* system leap indicator */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern u_char sys_stratum; /* system stratum */
|
1999-12-09 13:01:21 +00:00
|
|
|
extern s_char sys_precision; /* local clock precision */
|
2013-12-04 21:33:17 +00:00
|
|
|
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 */
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Nonspecified system state variables.
|
|
|
|
*/
|
|
|
|
extern int sys_bclient; /* we set our time to broadcasts */
|
|
|
|
extern double sys_bdelay; /* broadcast client default delay */
|
|
|
|
extern int sys_authenticate; /* requre authentication for config */
|
|
|
|
extern l_fp sys_authdelay; /* authentication delay */
|
2014-12-20 22:52:39 +00:00
|
|
|
extern u_long sys_epoch; /* last clock update time */
|
2001-08-29 14:35:15 +00:00
|
|
|
extern keyid_t sys_private; /* private value for session seed */
|
2004-07-20 15:01:56 +00:00
|
|
|
extern int sys_manycastserver; /* respond to manycast client pkts */
|
|
|
|
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 */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern u_char sys_ttl[MAX_TTL]; /* ttl mapping vector */
|
2004-07-20 15:01:56 +00:00
|
|
|
extern int sys_ttlmax; /* max ttl mapping vector index */
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Statistics counters
|
|
|
|
*/
|
2013-12-04 21:33:17 +00:00
|
|
|
extern u_long sys_stattime; /* time since reset */
|
|
|
|
extern u_long sys_received; /* packets received */
|
|
|
|
extern u_long sys_processed; /* packets for this host */
|
2004-07-20 15:01:56 +00:00
|
|
|
extern u_long sys_restricted; /* restricted packets */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern u_long sys_newversion; /* current version */
|
|
|
|
extern u_long sys_oldversion; /* old version */
|
|
|
|
extern u_long sys_restricted; /* access denied */
|
2004-07-20 15:01:56 +00:00
|
|
|
extern u_long sys_badlength; /* bad length or format */
|
|
|
|
extern u_long sys_badauth; /* bad authentication */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern u_long sys_declined; /* declined */
|
|
|
|
extern u_long sys_limitrejected; /* rate exceeded */
|
|
|
|
extern u_long sys_kodsent; /* KoD sent */
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_request.c */
|
2001-08-29 14:35:15 +00:00
|
|
|
extern keyid_t info_auth_keyid; /* keyid used to authenticate requests */
|
2014-12-20 22:52:39 +00:00
|
|
|
extern u_long auth_timereset;
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_restrict.c */
|
2013-12-04 21:33:17 +00:00
|
|
|
extern restrict_u * restrictlist4; /* IPv4 restriction list */
|
|
|
|
extern restrict_u * restrictlist6; /* IPv6 restriction list */
|
2014-12-20 22:52:39 +00:00
|
|
|
extern int ntp_minpkt;
|
|
|
|
extern u_char ntp_minpoll;
|
|
|
|
|
|
|
|
/* ntp_scanner.c */
|
|
|
|
extern u_int32 conf_file_sum; /* Simple sum of characters */
|
|
|
|
|
|
|
|
/* ntp_signd.c */
|
|
|
|
#ifdef HAVE_NTP_SIGND
|
2015-04-10 01:26:02 +00:00
|
|
|
extern void send_via_ntp_signd(struct recvbuf *, int, keyid_t, int,
|
2014-12-20 22:52:39 +00:00
|
|
|
struct pkt *);
|
|
|
|
#endif
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_timer.c */
|
|
|
|
extern volatile int alarm_flag; /* alarm flag */
|
|
|
|
extern volatile u_long alarm_overflow;
|
2014-12-20 22:52:39 +00:00
|
|
|
extern u_long current_time; /* seconds since startup */
|
1999-12-09 13:01:21 +00:00
|
|
|
extern u_long timer_timereset;
|
|
|
|
extern u_long timer_overflows;
|
|
|
|
extern u_long timer_xmtcalls;
|
2015-07-01 03:12:13 +00:00
|
|
|
extern int leap_sec_in_progress;
|
|
|
|
#ifdef LEAP_SMEAR
|
|
|
|
extern struct leap_smear_info leap_smear;
|
|
|
|
extern int leap_smear_intv;
|
|
|
|
#endif
|
2014-12-20 22:52:39 +00:00
|
|
|
#ifdef SYS_WINNT
|
|
|
|
HANDLE WaitableTimerHandle;
|
|
|
|
#endif
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntp_util.c */
|
2014-12-20 22:52:39 +00:00
|
|
|
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;
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* ntpd.c */
|
2014-12-20 22:52:39 +00:00
|
|
|
extern int nofork; /* no-fork flag */
|
|
|
|
extern int initializing; /* initializing flag */
|
2008-08-18 14:26:05 +00:00
|
|
|
#ifdef HAVE_DROPROOT
|
2014-12-20 22:52:39 +00:00
|
|
|
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 waitsync_fd_to_close; /* -w/--wait-sync */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* ntservice.c */
|
|
|
|
#ifdef SYS_WINNT
|
|
|
|
extern int accept_wildcard_if_for_winnt;
|
2004-07-20 15:01:56 +00:00
|
|
|
#endif
|
1999-12-09 13:01:21 +00:00
|
|
|
|
|
|
|
/* refclock_conf.c */
|
|
|
|
#ifdef REFCLOCK
|
2013-12-04 21:33:17 +00:00
|
|
|
/* refclock configuration table */
|
|
|
|
extern struct refclock * const refclock_conf[];
|
1999-12-09 13:01:21 +00:00
|
|
|
extern u_char num_refclock_conf;
|
|
|
|
#endif
|
2013-12-04 21:33:17 +00:00
|
|
|
|