freebsd-nq/contrib/ntp/include/ntpd.h

473 lines
17 KiB
C
Raw Normal View History

1999-12-09 13:01:21 +00:00
/*
* ntpd.h - Prototypes for ntpd.
*/
#include "ntp_syslog.h"
#include "ntp_fp.h"
#include "ntp.h"
#include "ntp_debug.h"
1999-12-09 13:01:21 +00:00
#include "ntp_select.h"
#include "ntp_malloc.h"
#include "ntp_refclock.h"
#include "recvbuff.h"
/* ntp_config.c */
extern void getconfig P((int, char **));
/* ntp_config.c */
extern void ctl_clr_stats P((void));
2004-07-20 15:01:56 +00:00
extern int ctlclrtrap P((struct sockaddr_storage *, struct interface *, int));
1999-12-09 13:01:21 +00:00
extern u_short ctlpeerstatus P((struct peer *));
2004-07-20 15:01:56 +00:00
extern int ctlsettrap P((struct sockaddr_storage *, struct interface *, int, int));
1999-12-09 13:01:21 +00:00
extern u_short ctlsysstatus P((void));
extern void init_control P((void));
extern void process_control P((struct recvbuf *, int));
extern void report_event P((int, struct peer *));
extern double fabs P((double));
extern double sqrt P((double));
/* ntp_control.c */
/*
* Structure for translation tables between internal system
* variable indices and text format.
*/
struct ctl_var {
u_short code;
u_short flags;
char *text;
};
/*
* 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)
2004-07-20 15:01:56 +00:00
extern char * add_var P((struct ctl_var **, u_long, u_short));
1999-12-09 13:01:21 +00:00
extern void free_varlist P((struct ctl_var *));
2004-07-20 15:01:56 +00:00
extern void set_var P((struct ctl_var **, const char *, u_long, u_short));
extern void set_sys_var P((const char *, u_long, u_short));
1999-12-09 13:01:21 +00:00
/* ntp_intres.c */
2004-07-20 15:01:56 +00:00
extern void ntp_res_name P((struct sockaddr_storage, u_short));
2001-08-29 14:35:15 +00:00
extern void ntp_res_recv P((void));
1999-12-09 13:01:21 +00:00
extern void ntp_intres P((void));
/* ntp_io.c */
typedef struct interface_info {
struct interface *interface;
u_char action;
} interface_info_t;
typedef void (*interface_receiver_t)(void *, interface_info_t *);
extern volatile int disable_dynamic_updates;
extern void interface_enumerate P((interface_receiver_t, void *));
2004-07-20 15:01:56 +00:00
extern struct interface *findinterface P((struct sockaddr_storage *));
extern struct interface *findbcastinter P((struct sockaddr_storage *));
extern void enable_broadcast P((struct interface *, struct sockaddr_storage *));
extern void enable_multicast_if P((struct interface *, struct sockaddr_storage *));
extern void interface_dump P((struct interface *));
1999-12-09 13:01:21 +00:00
extern void interface_update P((interface_receiver_t, void *));
1999-12-09 13:01:21 +00:00
extern void init_io P((void));
extern void input_handler P((l_fp *));
extern void io_clr_stats P((void));
extern void io_setbclient P((void));
extern void io_unsetbclient P((void));
2004-07-20 15:01:56 +00:00
extern void io_multicast_add P((struct sockaddr_storage));
extern void io_multicast_del P((struct sockaddr_storage));
extern void kill_asyncio P((int));
extern void sendpkt P((struct sockaddr_storage *, struct interface *, int, struct pkt *, int));
#ifdef DEBUG
extern void collect_timing P((struct recvbuf *, const char *, int, l_fp *));
#endif
1999-12-09 13:01:21 +00:00
#ifdef HAVE_SIGNALED_IO
extern void wait_for_signal P((void));
extern void unblock_io_and_alarm P((void));
extern void block_io_and_alarm P((void));
#define UNBLOCK_IO_AND_ALARM() unblock_io_and_alarm()
#define BLOCK_IO_AND_ALARM() block_io_and_alarm()
#else
#define UNBLOCK_IO_AND_ALARM()
#define BLOCK_IO_AND_ALARM()
1999-12-09 13:01:21 +00:00
#endif
/* ntp_leap.c */
extern void init_leap P((void));
extern void leap_process P((void));
extern int leap_setleap P((int, int));
/*
* there seems to be a bug in the IRIX 4 compiler which prevents
* u_char from beeing used in prototyped functions.
* This is also true AIX compiler.
* So give up and define it to be int. WLJ
*/
extern int leap_actual P((int));
/* ntp_loopfilter.c */
extern void init_loopfilter P((void));
extern int local_clock P((struct peer *, double));
1999-12-09 13:01:21 +00:00
extern void adj_host_clock P((void));
extern void loop_config P((int, double));
2001-08-29 14:35:15 +00:00
extern void huffpuff P((void));
extern u_long sys_clocktime;
extern u_long sys_tai;
1999-12-09 13:01:21 +00:00
/* ntp_monitor.c */
extern void init_mon P((void));
extern void mon_start P((int));
extern void mon_stop P((int));
extern int ntp_monitor P((struct recvbuf *));
extern void ntp_monclearinterface P((struct interface *interface));
1999-12-09 13:01:21 +00:00
/* ntp_peer.c */
extern void init_peer P((void));
2004-07-20 15:01:56 +00:00
extern struct peer *findexistingpeer P((struct sockaddr_storage *, struct peer *, int));
extern struct peer *findpeer P((struct sockaddr_storage *, struct interface *, int, int *));
2001-08-29 14:35:15 +00:00
extern struct peer *findpeerbyassoc P((u_int));
extern void set_peerdstadr P((struct peer *peer, struct interface *interface));
2004-07-20 15:01:56 +00:00
extern struct peer *newpeer P((struct sockaddr_storage *, struct interface *, int, int, int, int, u_int, u_char, int, keyid_t));
1999-12-09 13:01:21 +00:00
extern void peer_all_reset P((void));
extern void peer_clr_stats P((void));
2004-07-20 15:01:56 +00:00
extern struct peer *peer_config P((struct sockaddr_storage *, struct interface *, int, int, int, int, u_int, int, keyid_t, u_char *));
1999-12-09 13:01:21 +00:00
extern void peer_reset P((struct peer *));
2004-07-20 15:01:56 +00:00
extern int peer_unconfig P((struct sockaddr_storage *, struct interface *, int));
extern void refresh_all_peerinterfaces P((void));
1999-12-09 13:01:21 +00:00
extern void unpeer P((struct peer *));
2001-08-29 14:35:15 +00:00
extern void clear_all P((void));
2004-07-20 15:01:56 +00:00
#ifdef OPENSSL
2001-08-29 14:35:15 +00:00
extern void expire_all P((void));
2004-07-20 15:01:56 +00:00
#endif /* OPENSSL */
2001-08-29 14:35:15 +00:00
extern struct peer *findmanycastpeer P((struct recvbuf *));
1999-12-09 13:01:21 +00:00
2004-07-20 15:01:56 +00:00
/* ntp_crypto.c */
#ifdef OPENSSL
extern int crypto_recv P((struct peer *, struct recvbuf *));
extern int crypto_xmit P((struct pkt *, struct sockaddr_storage *, int, struct exten *, keyid_t));
extern keyid_t session_key P((struct sockaddr_storage *, struct sockaddr_storage *, keyid_t, keyid_t, u_long));
extern int make_keylist P((struct peer *, struct interface *));
2004-07-20 15:01:56 +00:00
extern void key_expire P((struct peer *));
extern void crypto_update P((void));
extern void crypto_config P((int, char *));
extern void crypto_setup P((void));
extern u_int crypto_ident P((struct peer *));
extern struct exten *crypto_args P((struct peer *, u_int, char *));
extern int crypto_public P((struct peer *, u_char *, u_int));
extern void value_free P((struct value *));
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;
2004-07-20 15:01:56 +00:00
#endif /* OPENSSL */
1999-12-09 13:01:21 +00:00
/* ntp_proto.c */
extern void transmit P((struct peer *));
extern void receive P((struct recvbuf *));
extern void peer_crypto_clear P((struct peer *peer));
2004-07-20 15:01:56 +00:00
extern void peer_clear P((struct peer *, char *));
extern void process_packet P((struct peer *, struct pkt *));
1999-12-09 13:01:21 +00:00
extern void clock_select P((void));
2004-07-20 15:01:56 +00:00
extern void kod_proto P((void));
1999-12-09 13:01:21 +00:00
/*
* there seems to be a bug in the IRIX 4 compiler which prevents
* u_char from beeing used in prototyped functions.
* This is also true AIX compiler.
* So give up and define it to be int. WLJ
*/
extern void poll_update P((struct peer *, int));
extern void clear P((struct peer *));
extern void clock_filter P((struct peer *, double, double, double));
extern void init_proto P((void));
2004-07-20 15:01:56 +00:00
extern void proto_config P((int, u_long, double, struct sockaddr_storage*));
1999-12-09 13:01:21 +00:00
extern void proto_clr_stats P((void));
#ifdef REFCLOCK
/* ntp_refclock.c */
extern int refclock_newpeer P((struct peer *));
extern void refclock_unpeer P((struct peer *));
extern void refclock_receive P((struct peer *));
extern void refclock_transmit P((struct peer *));
extern void init_refclock P((void));
#endif /* REFCLOCK */
/* ntp_request.c */
extern void init_request P((void));
extern void process_private P((struct recvbuf *, int));
/* ntp_restrict.c */
extern void init_restrict P((void));
extern int restrictions P((struct sockaddr_storage *, int));
2004-07-20 15:01:56 +00:00
extern void hack_restrict P((int, struct sockaddr_storage *, struct sockaddr_storage *, int, int));
1999-12-09 13:01:21 +00:00
/* ntp_timer.c */
extern void init_timer P((void));
2004-07-20 15:01:56 +00:00
extern void reinit_timer P((void));
1999-12-09 13:01:21 +00:00
extern void timer P((void));
extern void timer_clr_stats P((void));
extern void timer_interfacetimeout P((u_long));
extern volatile int interface_interval;
2004-07-20 15:01:56 +00:00
#ifdef OPENSSL
2001-08-29 14:35:15 +00:00
extern char *sys_hostname;
extern l_fp sys_revoketime;
2004-07-20 15:01:56 +00:00
#endif /* OPENSSL */
1999-12-09 13:01:21 +00:00
/* ntp_util.c */
extern void init_util P((void));
extern void write_stats P((void));
extern void stats_config P((int, const char *));
2004-07-20 15:01:56 +00:00
extern void record_peer_stats P((struct sockaddr_storage *, int, double, double, double, double));
2001-08-29 14:35:15 +00:00
extern void record_loop_stats P((double, double, double, double, int));
2004-07-20 15:01:56 +00:00
extern void record_clock_stats P((struct sockaddr_storage *, const char *));
extern void record_raw_stats P((struct sockaddr_storage *, struct sockaddr_storage *, l_fp *, l_fp *, l_fp *, l_fp *));
extern void record_sys_stats P((void));
extern void record_crypto_stats P((struct sockaddr_storage *, const char *));
#ifdef DEBUG
extern void record_timing_stats P((const char *));
#endif
2004-07-20 15:01:56 +00:00
extern int sock_hash P((struct sockaddr_storage *));
extern double old_drift;
1999-12-09 13:01:21 +00:00
/*
* Variable declarations for ntpd.
*/
/* ntp_config.c */
extern char const * progname;
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
/* 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 */
/* ntp_intres.c */
2001-08-29 14:35:15 +00:00
extern keyid_t req_keyid; /* request keyid */
1999-12-09 13:01:21 +00:00
extern char * req_file; /* name of the file with configuration info */
#ifdef SYS_WINNT
extern HANDLE ResolverEventHandle;
#else
extern int resolver_pipe_fd[2]; /* used to let the resolver process alert the parent process */
#endif /* SYS_WINNT */
1999-12-09 13:01:21 +00:00
/*
* 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 */
/*
* Interface stuff
*/
2004-07-20 15:01:56 +00:00
extern struct interface *any_interface; /* default ipv4 interface */
extern struct interface *any6_interface;/* default ipv6 interface */
2001-08-29 14:35:15 +00:00
extern struct interface *loopback_interface; /* loopback interface */
1999-12-09 13:01:21 +00:00
/*
* File descriptor masks etc. for call to select
*/
extern fd_set activefds;
extern int maxactivefd;
/* 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) */
extern double clock_max; /* max 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) */
1999-12-09 13:01:21 +00:00
extern u_long pps_control; /* last pps sample time */
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 */
2001-08-29 14:35:15 +00:00
extern int pps_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 */
extern int allow_panic; /* allow panic correction */
extern int mode_ntpdate; /* exit on first clock set */
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) */
2004-07-20 15:01:56 +00:00
extern double allan_xpt; /* Allan intercept (s) */
extern double clock_jitter; /* clock jitter (s) */
extern double sys_jitter; /* system jitter (s) */
1999-12-09 13:01:21 +00:00
/* ntp_monitor.c */
extern struct mon_data mon_mru_list;
extern struct mon_data mon_fifo_list;
extern int mon_enabled;
/* ntp_peer.c */
extern struct peer *peer_hash[]; /* peer hash table */
extern int peer_hash_count[]; /* count of peers in each bucket */
extern struct peer *assoc_hash[]; /* association ID hash table */
extern int assoc_hash_count[];
extern int peer_free_count;
/*
* 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 */
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 */
extern u_char sys_stratum; /* stratum of system */
extern s_char sys_precision; /* local clock precision */
extern double sys_rootdelay; /* distance to current sync source */
extern double sys_rootdispersion; /* dispersion of system clock */
extern u_int32 sys_refid; /* reference source for local clock */
extern l_fp sys_reftime; /* time we were last updated */
extern struct peer *sys_peer; /* our current peer */
extern struct peer *sys_pps; /* our current PPS peer */
2001-08-29 14:35:15 +00:00
extern struct peer *sys_prefer; /* our cherished peer */
1999-12-09 13:01:21 +00:00
extern u_long sys_automax; /* maximum session key lifetime */
/*
* 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 */
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 */
extern u_char sys_ttl[]; /* ttl mapping vector */
extern int sys_ttlmax; /* max ttl mapping vector index */
extern int leap_next; /* leap consensus */
1999-12-09 13:01:21 +00:00
/*
* Statistics counters
*/
extern u_long sys_stattime; /* time when we started recording */
2004-07-20 15:01:56 +00:00
extern u_long sys_restricted; /* restricted packets */
extern u_long sys_oldversionpkt; /* old version packets */
extern u_long sys_newversionpkt; /* new version packets */
1999-12-09 13:01:21 +00:00
extern u_long sys_unknownversion; /* don't know version packets */
2004-07-20 15:01:56 +00:00
extern u_long sys_badlength; /* bad length or format */
1999-12-09 13:01:21 +00:00
extern u_long sys_processed; /* packets processed */
2004-07-20 15:01:56 +00:00
extern u_long sys_badauth; /* bad authentication */
extern u_long sys_limitrejected; /* rate limit exceeded */
extern u_long sys_received; /* packets received */
1999-12-09 13:01:21 +00:00
/* ntp_refclock.c */
#ifdef REFCLOCK
#ifdef PPS
1999-12-09 13:01:21 +00:00
extern int fdpps; /* pps file descriptor */
#endif /* PPS */
#endif
/* ntp_request.c */
2001-08-29 14:35:15 +00:00
extern keyid_t info_auth_keyid; /* keyid used to authenticate requests */
1999-12-09 13:01:21 +00:00
/* ntp_restrict.c */
2004-07-20 15:01:56 +00:00
extern struct restrictlist *restrictlist; /* the ipv4 restriction list */
extern struct restrictlist6 *restrictlist6; /* the ipv6 restriction list */
extern u_long res_min_interval;
extern u_long res_avg_interval;
extern u_long mon_age; /* monitor preempt age */
1999-12-09 13:01:21 +00:00
/* ntp_timer.c */
extern volatile int alarm_flag; /* alarm flag */
2004-07-20 15:01:56 +00:00
extern u_char sys_revoke; /* keys revoke timeout (log2 s) */
1999-12-09 13:01:21 +00:00
extern volatile u_long alarm_overflow;
extern u_long current_time; /* current time (s) */
extern u_long timer_timereset;
extern u_long timer_overflows;
extern u_long timer_xmtcalls;
/* ntp_util.c */
extern int stats_control; /* write stats to fileset? */
extern int stats_write_period; /* # of seconds between writes. */
extern double stats_write_tolerance;
1999-12-09 13:01:21 +00:00
/* ntpd.c */
extern volatile int debug; /* debugging flag */
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 */
2004-07-20 15:01:56 +00:00
extern char *user; /* user to switch to */
extern char *group; /* group to switch to */
extern char *chrootdir; /* directory to chroot to */
#endif
1999-12-09 13:01:21 +00:00
/* refclock_conf.c */
#ifdef REFCLOCK
extern struct refclock *refclock_conf[]; /* refclock configuration table */
extern u_char num_refclock_conf;
#endif