File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / ntp / include / ntpd.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:08:38 2012 UTC (12 years, 5 months ago) by misho
Branches: ntp, MAIN
CVS tags: v4_2_6p5p0, v4_2_6p5, HEAD
ntp 4.2.6p5

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>