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