Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ntp / include / ntp_request.h
blob6016cc8736def6dddd95fac406fd4f1c07c4dbe0
1 /* $NetBSD: ntp_request.h,v 1.4 2007/01/06 19:45:22 kardel Exp $ */
3 /*
4 * ntp_request.h - definitions for the ntpd remote query facility
5 */
7 #ifndef _NTP_REQUEST_H
8 #define _NTP_REQUEST_H
10 #include "ntp_types.h"
13 * A mode 7 packet is used exchanging data between an NTP server
14 * and a client for purposes other than time synchronization, e.g.
15 * monitoring, statistics gathering and configuration. A mode 7
16 * packet has the following format:
18 * 0 1 2 3
19 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
20 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
21 * |R|M| VN | Mode|A| Sequence | Implementation| Req Code |
22 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
23 * | Err | Number of data items | MBZ | Size of data item |
24 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25 * | |
26 * | Data (Minimum 0 octets, maximum 500 octets) |
27 * | |
28 * [...]
29 * | |
30 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31 * | Encryption Keyid (when A bit set) |
32 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
33 * | |
34 * | Message Authentication Code (when A bit set) |
35 * | |
36 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 * where the fields are (note that the client sends requests, the server
39 * responses):
41 * Response Bit: This packet is a response (if clear, packet is a request).
43 * More Bit: Set for all packets but the last in a response which
44 * requires more than one packet.
46 * Version Number: 2 for current version
48 * Mode: Always 7
50 * Authenticated bit: If set, this packet is authenticated.
52 * Sequence number: For a multipacket response, contains the sequence
53 * number of this packet. 0 is the first in the sequence,
54 * 127 (or less) is the last. The More Bit must be set in
55 * all packets but the last.
57 * Implementation number: The number of the implementation this request code
58 * is defined by. An implementation number of zero is used
59 * for requst codes/data formats which all implementations
60 * agree on. Implementation number 255 is reserved (for
61 * extensions, in case we run out).
63 * Request code: An implementation-specific code which specifies the
64 * operation to be (which has been) performed and/or the
65 * format and semantics of the data included in the packet.
67 * Err: Must be 0 for a request. For a response, holds an error
68 * code relating to the request. If nonzero, the operation
69 * requested wasn't performed.
71 * 0 - no error
72 * 1 - incompatable implementation number
73 * 2 - unimplemented request code
74 * 3 - format error (wrong data items, data size, packet size etc.)
75 * 4 - no data available (e.g. request for details on unknown peer)
76 * 5-6 I don't know
77 * 7 - authentication failure (i.e. permission denied)
79 * Number of data items: number of data items in packet. 0 to 500
81 * MBZ: A reserved data field, must be zero in requests and responses.
83 * Size of data item: size of each data item in packet. 0 to 500
85 * Data: Variable sized area containing request/response data. For
86 * requests and responses the size in octets must be greater
87 * than or equal to the product of the number of data items
88 * and the size of a data item. For requests the data area
89 * must be exactly 40 octets in length. For responses the
90 * data area may be any length between 0 and 500 octets
91 * inclusive.
93 * Message Authentication Code: Same as NTP spec, in definition and function.
94 * May optionally be included in requests which require
95 * authentication, is never included in responses.
97 * The version number, mode and keyid have the same function and are
98 * in the same location as a standard NTP packet. The request packet
99 * is the same size as a standard NTP packet to ease receive buffer
100 * management, and to allow the same encryption procedure to be used
101 * both on mode 7 and standard NTP packets. The mac is included when
102 * it is required that a request be authenticated, the keyid should be
103 * zero in requests in which the mac is not included.
105 * The data format depends on the implementation number/request code pair
106 * and whether the packet is a request or a response. The only requirement
107 * is that data items start in the octet immediately following the size
108 * word and that data items be concatenated without padding between (i.e.
109 * if the data area is larger than data_items*size, all padding is at
110 * the end). Padding is ignored, other than for encryption purposes.
111 * Implementations using encryption might want to include a time stamp
112 * or other data in the request packet padding. The key used for requests
113 * is implementation defined, but key 15 is suggested as a default.
117 * union of raw addresses to save space
119 union addrun
121 struct in6_addr addr6;
122 struct in_addr addr;
126 * A request packet. These are almost a fixed length.
128 struct req_pkt {
129 u_char rm_vn_mode; /* response, more, version, mode */
130 u_char auth_seq; /* key, sequence number */
131 u_char implementation; /* implementation number */
132 u_char request; /* request number */
133 u_short err_nitems; /* error code/number of data items */
134 u_short mbz_itemsize; /* item size */
135 char data[MAXFILENAME + 48]; /* data area [32 prev](176 byte max) */
136 /* struct conf_peer must fit */
137 l_fp tstamp; /* time stamp, for authentication */
138 keyid_t keyid; /* encryption key */
139 char mac[MAX_MAC_LEN-sizeof(u_int32)]; /* (optional) 8 byte auth code */
143 * The req_pkt_tail structure is used by ntpd to adjust for different
144 * packet sizes that may arrive.
146 struct req_pkt_tail {
147 l_fp tstamp; /* time stamp, for authentication */
148 keyid_t keyid; /* encryption key */
149 char mac[MAX_MAC_LEN-sizeof(u_int32)]; /* (optional) 8 byte auth code */
153 * Input packet lengths. One with the mac, one without.
155 #define REQ_LEN_HDR 8 /* 4 * u_char + 2 * u_short */
156 #define REQ_LEN_MAC (sizeof(struct req_pkt))
157 #define REQ_LEN_NOMAC (sizeof(struct req_pkt) - MAX_MAC_LEN)
160 * A response packet. The length here is variable, this is a
161 * maximally sized one. Note that this implementation doesn't
162 * authenticate responses.
164 #define RESP_HEADER_SIZE (8)
165 #define RESP_DATA_SIZE (500)
167 struct resp_pkt {
168 u_char rm_vn_mode; /* response, more, version, mode */
169 u_char auth_seq; /* key, sequence number */
170 u_char implementation; /* implementation number */
171 u_char request; /* request number */
172 u_short err_nitems; /* error code/number of data items */
173 u_short mbz_itemsize; /* item size */
174 char data[RESP_DATA_SIZE]; /* data area */
179 * Information error codes
181 #define INFO_OKAY 0
182 #define INFO_ERR_IMPL 1 /* incompatable implementation */
183 #define INFO_ERR_REQ 2 /* unknown request code */
184 #define INFO_ERR_FMT 3 /* format error */
185 #define INFO_ERR_NODATA 4 /* no data for this request */
186 #define INFO_ERR_AUTH 7 /* authentication failure */
189 * Maximum sequence number.
191 #define MAXSEQ 127
195 * Bit setting macros for multifield items.
197 #define RESP_BIT 0x80
198 #define MORE_BIT 0x40
200 #define ISRESPONSE(rm_vn_mode) (((rm_vn_mode)&RESP_BIT)!=0)
201 #define ISMORE(rm_vn_mode) (((rm_vn_mode)&MORE_BIT)!=0)
202 #define INFO_VERSION(rm_vn_mode) ((u_char)(((rm_vn_mode)>>3)&0x7))
203 #define INFO_MODE(rm_vn_mode) ((rm_vn_mode)&0x7)
205 #define RM_VN_MODE(resp, more, version) \
206 ((u_char)(((resp)?RESP_BIT:0)\
207 |((more)?MORE_BIT:0)\
208 |((version?version:(NTP_OLDVERSION+1))<<3)\
209 |(MODE_PRIVATE)))
211 #define INFO_IS_AUTH(auth_seq) (((auth_seq) & 0x80) != 0)
212 #define INFO_SEQ(auth_seq) ((auth_seq)&0x7f)
213 #define AUTH_SEQ(auth, seq) ((u_char)((((auth)!=0)?0x80:0)|((seq)&0x7f)))
215 #define INFO_ERR(err_nitems) ((u_short)((ntohs(err_nitems)>>12)&0xf))
216 #define INFO_NITEMS(err_nitems) ((u_short)(ntohs(err_nitems)&0xfff))
217 #define ERR_NITEMS(err, nitems) (htons((u_short)((((u_short)(err)<<12)&0xf000)\
218 |((u_short)(nitems)&0xfff))))
220 #define INFO_MBZ(mbz_itemsize) ((ntohs(mbz_itemsize)>>12)&0xf)
221 #define INFO_ITEMSIZE(mbz_itemsize) ((u_short)(ntohs(mbz_itemsize)&0xfff))
222 #define MBZ_ITEMSIZE(itemsize) (htons((u_short)(itemsize)))
226 * Implementation numbers. One for universal use and one for ntpd.
228 #define IMPL_UNIV 0
229 #define IMPL_XNTPD_OLD 2 /* Used by pre ipv6 ntpdc */
230 #define IMPL_XNTPD 3 /* Used by post ipv6 ntpdc */
233 * Some limits related to authentication. Frames which are
234 * authenticated must include a time stamp which differs from
235 * the receive time stamp by no more than 10 seconds.
237 #define INFO_TS_MAXSKEW 10.
240 * Universal request codes go here. There aren't any.
244 * NTPD request codes go here.
246 #define REQ_PEER_LIST 0 /* return list of peers */
247 #define REQ_PEER_LIST_SUM 1 /* return summary info for all peers */
248 #define REQ_PEER_INFO 2 /* get standard information on peer */
249 #define REQ_PEER_STATS 3 /* get statistics for peer */
250 #define REQ_SYS_INFO 4 /* get system information */
251 #define REQ_SYS_STATS 5 /* get system stats */
252 #define REQ_IO_STATS 6 /* get I/O stats */
253 #define REQ_MEM_STATS 7 /* stats related to peer list maint */
254 #define REQ_LOOP_INFO 8 /* info from the loop filter */
255 #define REQ_TIMER_STATS 9 /* get timer stats */
256 #define REQ_CONFIG 10 /* configure a new peer */
257 #define REQ_UNCONFIG 11 /* unconfigure an existing peer */
258 #define REQ_SET_SYS_FLAG 12 /* set system flags */
259 #define REQ_CLR_SYS_FLAG 13 /* clear system flags */
260 #define REQ_MONITOR 14 /* (not used) */
261 #define REQ_NOMONITOR 15 /* (not used) */
262 #define REQ_GET_RESTRICT 16 /* return restrict list */
263 #define REQ_RESADDFLAGS 17 /* add flags to restrict list */
264 #define REQ_RESSUBFLAGS 18 /* remove flags from restrict list */
265 #define REQ_UNRESTRICT 19 /* remove entry from restrict list */
266 #define REQ_MON_GETLIST 20 /* return data collected by monitor */
267 #define REQ_RESET_STATS 21 /* reset stat counters */
268 #define REQ_RESET_PEER 22 /* reset peer stat counters */
269 #define REQ_REREAD_KEYS 23 /* reread the encryption key file */
270 #define REQ_DO_DIRTY_HACK 24 /* (not used) */
271 #define REQ_DONT_DIRTY_HACK 25 /* (not used) */
272 #define REQ_TRUSTKEY 26 /* add a trusted key */
273 #define REQ_UNTRUSTKEY 27 /* remove a trusted key */
274 #define REQ_AUTHINFO 28 /* return authentication info */
275 #define REQ_TRAPS 29 /* return currently set traps */
276 #define REQ_ADD_TRAP 30 /* add a trap */
277 #define REQ_CLR_TRAP 31 /* clear a trap */
278 #define REQ_REQUEST_KEY 32 /* define a new request keyid */
279 #define REQ_CONTROL_KEY 33 /* define a new control keyid */
280 #define REQ_GET_CTLSTATS 34 /* get stats from the control module */
281 #define REQ_GET_LEAPINFO 35 /* (not used) */
282 #define REQ_GET_CLOCKINFO 36 /* get clock information */
283 #define REQ_SET_CLKFUDGE 37 /* set clock fudge factors */
284 #define REQ_GET_KERNEL 38 /* get kernel pll/pps information */
285 #define REQ_GET_CLKBUGINFO 39 /* get clock debugging info */
286 #define REQ_SET_PRECISION 41 /* (not used) */
287 #define REQ_MON_GETLIST_1 42 /* return collected v1 monitor data */
288 #define REQ_HOSTNAME_ASSOCID 43 /* Here is a hostname + assoc_id */
289 #define REQ_IF_STATS 44 /* get interface statistics */
290 #define REQ_IF_RELOAD 45 /* reload interface list */
292 /* Determine size of pre-v6 version of structures */
293 #define v4sizeof(type) offsetof(type, v6_flag)
296 * Flags in the peer information returns
298 #define INFO_FLAG_CONFIG 0x1
299 #define INFO_FLAG_SYSPEER 0x2
300 #define INFO_FLAG_BURST 0x4
301 #define INFO_FLAG_REFCLOCK 0x8
302 #define INFO_FLAG_PREFER 0x10
303 #define INFO_FLAG_AUTHENABLE 0x20
304 #define INFO_FLAG_SEL_CANDIDATE 0x40
305 #define INFO_FLAG_SHORTLIST 0x80
306 #define INFO_FLAG_IBURST 0x100
309 * Flags in the system information returns
311 #define INFO_FLAG_BCLIENT 0x1
312 #define INFO_FLAG_AUTHENTICATE 0x2
313 #define INFO_FLAG_NTP 0x4
314 #define INFO_FLAG_KERNEL 0x8
315 #define INFO_FLAG_MONITOR 0x40
316 #define INFO_FLAG_FILEGEN 0x80
317 #define INFO_FLAG_CAL 0x10
318 #define INFO_FLAG_PPS_SYNC 0x20
321 * Peer list structure. Used to return raw lists of peers. It goes
322 * without saying that everything returned is in network byte order.
323 * Well, it *would* have gone without saying, but somebody said it.
325 struct info_peer_list {
326 u_int32 addr; /* address of peer */
327 u_short port; /* port number of peer */
328 u_char hmode; /* mode for this peer */
329 u_char flags; /* flags (from above) */
330 u_int v6_flag; /* is this v6 or not */
331 u_int unused1; /* (unused) padding for addr6 */
332 struct in6_addr addr6; /* v6 address of peer */
337 * Peer summary structure. Sort of the info that ntpdc returns by default.
339 struct info_peer_summary {
340 u_int32 dstadr; /* local address (zero for undetermined) */
341 u_int32 srcadr; /* source address */
342 u_short srcport; /* source port */
343 u_char stratum; /* stratum of peer */
344 s_char hpoll; /* host polling interval */
345 s_char ppoll; /* peer polling interval */
346 u_char reach; /* reachability register */
347 u_char flags; /* flags, from above */
348 u_char hmode; /* peer mode */
349 s_fp delay; /* peer.estdelay */
350 l_fp offset; /* peer.estoffset */
351 u_fp dispersion; /* peer.estdisp */
352 u_int v6_flag; /* is this v6 or not */
353 u_int unused1; /* (unused) padding for dstadr6 */
354 struct in6_addr dstadr6; /* local address (v6) */
355 struct in6_addr srcadr6; /* source address (v6) */
360 * Peer information structure.
362 struct info_peer {
363 u_int32 dstadr; /* local address */
364 u_int32 srcadr; /* source address */
365 u_short srcport; /* remote port */
366 u_char flags; /* peer flags */
367 u_char leap; /* peer.leap */
368 u_char hmode; /* peer.hmode */
369 u_char pmode; /* peer.pmode */
370 u_char stratum; /* peer.stratum */
371 u_char ppoll; /* peer.ppoll */
372 u_char hpoll; /* peer.hpoll */
373 s_char precision; /* peer.precision */
374 u_char version; /* peer.version */
375 u_char unused8;
376 u_char reach; /* peer.reach */
377 u_char unreach; /* peer.unreach */
378 u_char flash; /* old peer.flash */
379 u_char ttl; /* peer.ttl */
380 u_short flash2; /* new peer.flash */
381 associd_t associd; /* association ID */
382 keyid_t keyid; /* peer.keyid */
383 u_int32 pkeyid; /* unused */
384 u_int32 refid; /* peer.refid */
385 u_int32 timer; /* peer.timer */
386 s_fp rootdelay; /* peer.distance */
387 u_fp rootdispersion; /* peer.dispersion */
388 l_fp reftime; /* peer.reftime */
389 l_fp org; /* peer.org */
390 l_fp rec; /* peer.rec */
391 l_fp xmt; /* peer.xmt */
392 s_fp filtdelay[NTP_SHIFT]; /* delay shift register */
393 l_fp filtoffset[NTP_SHIFT]; /* offset shift register */
394 u_char order[NTP_SHIFT]; /* order of peers from last filter */
395 s_fp delay; /* peer.estdelay */
396 u_fp dispersion; /* peer.estdisp */
397 l_fp offset; /* peer.estoffset */
398 u_fp selectdisp; /* peer select dispersion */
399 int32 unused1; /* (obsolete) */
400 int32 unused2;
401 int32 unused3;
402 int32 unused4;
403 int32 unused5;
404 int32 unused6;
405 int32 unused7;
406 s_fp estbdelay; /* broadcast offset */
407 u_int v6_flag; /* is this v6 or not */
408 u_int unused9; /* (unused) padding for dstadr6 */
409 struct in6_addr dstadr6; /* local address (v6-like) */
410 struct in6_addr srcadr6; /* sources address (v6-like) */
415 * Peer statistics structure
417 struct info_peer_stats {
418 u_int32 dstadr; /* local address */
419 u_int32 srcadr; /* remote address */
420 u_short srcport; /* remote port */
421 u_short flags; /* peer flags */
422 u_int32 timereset; /* time counters were reset */
423 u_int32 timereceived; /* time since a packet received */
424 u_int32 timetosend; /* time until a packet sent */
425 u_int32 timereachable; /* time peer has been reachable */
426 u_int32 sent; /* number sent */
427 u_int32 unused1; /* (unused) */
428 u_int32 processed; /* number processed */
429 u_int32 unused2; /* (unused) */
430 u_int32 badauth; /* bad authentication */
431 u_int32 bogusorg; /* bogus origin */
432 u_int32 oldpkt; /* duplicate */
433 u_int32 unused3; /* (unused) */
434 u_int32 unused4; /* (unused) */
435 u_int32 seldisp; /* bad dispersion */
436 u_int32 selbroken; /* bad reference time */
437 u_int32 unused5; /* (unused) */
438 u_char candidate; /* select order */
439 u_char unused6; /* (unused) */
440 u_char unused7; /* (unused) */
441 u_char unused8; /* (unused) */
442 u_int v6_flag; /* is this v6 or not */
443 u_int unused9; /* (unused) padding for dstadr6 */
444 struct in6_addr dstadr6; /* local address */
445 struct in6_addr srcadr6; /* remote address */
450 * Loop filter variables
452 struct info_loop {
453 l_fp last_offset;
454 l_fp drift_comp;
455 u_int32 compliance;
456 u_int32 watchdog_timer;
461 * System info. Mostly the sys.* variables, plus a few unique to
462 * the implementation.
464 struct info_sys {
465 u_int32 peer; /* system peer address (v4) */
466 u_char peer_mode; /* mode we are syncing to peer in */
467 u_char leap; /* system leap bits */
468 u_char stratum; /* our stratum */
469 s_char precision; /* local clock precision */
470 s_fp rootdelay; /* distance from sync source */
471 u_fp rootdispersion; /* dispersion from sync source */
472 u_int32 refid; /* reference ID of sync source */
473 l_fp reftime; /* system reference time */
474 u_int32 poll; /* system poll interval */
475 u_char flags; /* system flags */
476 u_char unused1; /* unused */
477 u_char unused2; /* unused */
478 u_char unused3; /* unused */
479 s_fp bdelay; /* default broadcast offset */
480 s_fp frequency; /* frequency residual (scaled ppm) */
481 l_fp authdelay; /* default authentication delay */
482 u_fp stability; /* clock stability (scaled ppm) */
483 u_int v6_flag; /* is this v6 or not */
484 u_int unused4; /* unused, padding for peer6 */
485 struct in6_addr peer6; /* system peer address (v6) */
490 * System stats. These are collected in the protocol module
492 struct info_sys_stats {
493 u_int32 timeup; /* time since restart */
494 u_int32 timereset; /* time since reset */
495 u_int32 denied; /* access denied */
496 u_int32 oldversionpkt; /* recent version */
497 u_int32 newversionpkt; /* current version */
498 u_int32 unknownversion; /* bad version */
499 u_int32 badlength; /* bad length or format */
500 u_int32 processed; /* packets processed */
501 u_int32 badauth; /* bad authentication */
502 u_int32 received; /* packets received */
503 u_int32 limitrejected; /* rate exceeded */
508 * System stats - old version
510 struct old_info_sys_stats {
511 u_int32 timeup; /* time since restart */
512 u_int32 timereset; /* time since reset */
513 u_int32 denied; /* access denied */
514 u_int32 oldversionpkt; /* recent version */
515 u_int32 newversionpkt; /* current version */
516 u_int32 unknownversion; /* bad version */
517 u_int32 badlength; /* bad length or format */
518 u_int32 processed; /* packets processed */
519 u_int32 badauth; /* bad authentication */
520 u_int32 wanderhold; /* (not used) */
525 * Peer memory statistics. Collected in the peer module.
527 struct info_mem_stats {
528 u_int32 timereset; /* time since reset */
529 u_short totalpeermem;
530 u_short freepeermem;
531 u_int32 findpeer_calls;
532 u_int32 allocations;
533 u_int32 demobilizations;
534 u_char hashcount[NTP_HASH_SIZE];
539 * I/O statistics. Collected in the I/O module
541 struct info_io_stats {
542 u_int32 timereset; /* time since reset */
543 u_short totalrecvbufs; /* total receive bufs */
544 u_short freerecvbufs; /* free buffers */
545 u_short fullrecvbufs; /* full buffers */
546 u_short lowwater; /* number of times we've added buffers */
547 u_int32 dropped; /* dropped packets */
548 u_int32 ignored; /* ignored packets */
549 u_int32 received; /* received packets */
550 u_int32 sent; /* packets sent */
551 u_int32 notsent; /* packets not sent */
552 u_int32 interrupts; /* interrupts we've handled */
553 u_int32 int_received; /* received by interrupt handler */
558 * Timer stats. Guess where from.
560 struct info_timer_stats {
561 u_int32 timereset; /* time since reset */
562 u_int32 alarms; /* alarms we've handled */
563 u_int32 overflows; /* timer overflows */
564 u_int32 xmtcalls; /* calls to xmit */
569 * Structure for passing peer configuration information
571 struct old_conf_peer {
572 u_int32 peeraddr; /* address to poll */
573 u_char hmode; /* mode, either broadcast, active or client */
574 u_char version; /* version number to poll with */
575 u_char minpoll; /* min host poll interval */
576 u_char maxpoll; /* max host poll interval */
577 u_char flags; /* flags for this request */
578 u_char ttl; /* time to live (multicast) or refclock mode */
579 u_short unused; /* unused */
580 keyid_t keyid; /* key to use for this association */
583 struct conf_peer {
584 u_int32 peeraddr; /* address to poll */
585 u_char hmode; /* mode, either broadcast, active or client */
586 u_char version; /* version number to poll with */
587 u_char minpoll; /* min host poll interval */
588 u_char maxpoll; /* max host poll interval */
589 u_char flags; /* flags for this request */
590 u_char ttl; /* time to live (multicast) or refclock mode */
591 u_short unused1; /* unused */
592 keyid_t keyid; /* key to use for this association */
593 char keystr[MAXFILENAME]; /* public key file name*/
594 u_int v6_flag; /* is this v6 or not */
595 u_int unused2; /* unused, padding for peeraddr6 */
596 struct in6_addr peeraddr6; /* ipv6 address to poll */
599 #define CONF_FLAG_AUTHENABLE 0x01
600 #define CONF_FLAG_PREFER 0x02
601 #define CONF_FLAG_BURST 0x04
602 #define CONF_FLAG_IBURST 0x08
603 #define CONF_FLAG_NOSELECT 0x10
604 #define CONF_FLAG_SKEY 0x20
607 * Structure for passing peer deletion information. Currently
608 * we only pass the address and delete all configured peers with
609 * this addess.
611 struct conf_unpeer {
612 u_int32 peeraddr; /* address of peer */
613 u_int v6_flag; /* is this v6 or not */
614 struct in6_addr peeraddr6; /* address of peer (v6) */
618 * Structure for carrying system flags.
620 struct conf_sys_flags {
621 u_int32 flags;
625 * System flags we can set/clear
627 #define SYS_FLAG_BCLIENT 0x01
628 #define SYS_FLAG_PPS 0x02
629 #define SYS_FLAG_NTP 0x04
630 #define SYS_FLAG_KERNEL 0x08
631 #define SYS_FLAG_MONITOR 0x10
632 #define SYS_FLAG_FILEGEN 0x20
633 #define SYS_FLAG_AUTH 0x40
634 #define SYS_FLAG_CAL 0x80
637 * Structure used for returning restrict entries
639 struct info_restrict {
640 u_int32 addr; /* match address */
641 u_int32 mask; /* match mask */
642 u_int32 count; /* number of packets matched */
643 u_short flags; /* restrict flags */
644 u_short mflags; /* match flags */
645 u_int v6_flag; /* is this v6 or not */
646 u_int unused1; /* unused, padding for addr6 */
647 struct in6_addr addr6; /* match address (v6) */
648 struct in6_addr mask6; /* match mask (v6) */
653 * Structure used for specifying restrict entries
655 struct conf_restrict {
656 u_int32 addr; /* match address */
657 u_int32 mask; /* match mask */
658 u_short flags; /* restrict flags */
659 u_short mflags; /* match flags */
660 u_int v6_flag; /* is this v6 or not */
661 struct in6_addr addr6; /* match address (v6) */
662 struct in6_addr mask6; /* match mask (v6) */
667 * Structure used for returning monitor data
669 struct info_monitor_1 {
670 u_int32 lasttime; /* last packet from this host */
671 u_int32 firsttime; /* first time we received a packet */
672 u_int32 lastdrop; /* last time we rejected a packet due to client limitation policy */
673 u_int32 count; /* count of packets received */
674 u_int32 addr; /* host address V4 style */
675 u_int32 daddr; /* destination host address */
676 u_int32 flags; /* flags about destination */
677 u_short port; /* port number of last reception */
678 u_char mode; /* mode of last packet */
679 u_char version; /* version number of last packet */
680 u_int v6_flag; /* is this v6 or not */
681 u_int unused1; /* unused, padding for addr6 */
682 struct in6_addr addr6; /* host address V6 style */
683 struct in6_addr daddr6; /* host address V6 style */
688 * Structure used for returning monitor data
690 struct info_monitor {
691 u_int32 lasttime; /* last packet from this host */
692 u_int32 firsttime; /* first time we received a packet */
693 u_int32 lastdrop; /* last time we rejected a packet due to client limitation policy */
694 u_int32 count; /* count of packets received */
695 u_int32 addr; /* host address */
696 u_short port; /* port number of last reception */
697 u_char mode; /* mode of last packet */
698 u_char version; /* version number of last packet */
699 u_int v6_flag; /* is this v6 or not */
700 u_int unused1; /* unused, padding for addr6 */
701 struct in6_addr addr6; /* host v6 address */
705 * Structure used for returning monitor data (old format
707 struct old_info_monitor {
708 u_int32 lasttime; /* last packet from this host */
709 u_int32 firsttime; /* first time we received a packet */
710 u_int32 count; /* count of packets received */
711 u_int32 addr; /* host address */
712 u_short port; /* port number of last reception */
713 u_char mode; /* mode of last packet */
714 u_char version; /* version number of last packet */
715 u_int v6_flag; /* is this v6 or not */
716 struct in6_addr addr6; /* host address (v6)*/
720 * Structure used for passing indication of flags to clear
722 struct reset_flags {
723 u_int32 flags;
726 #define RESET_FLAG_ALLPEERS 0x01
727 #define RESET_FLAG_IO 0x02
728 #define RESET_FLAG_SYS 0x04
729 #define RESET_FLAG_MEM 0x08
730 #define RESET_FLAG_TIMER 0x10
731 #define RESET_FLAG_AUTH 0x20
732 #define RESET_FLAG_CTL 0x40
734 #define RESET_ALLFLAGS \
735 (RESET_FLAG_ALLPEERS|RESET_FLAG_IO|RESET_FLAG_SYS \
736 |RESET_FLAG_MEM|RESET_FLAG_TIMER|RESET_FLAG_AUTH|RESET_FLAG_CTL)
739 * Structure used to return information concerning the authentication
740 * module.
742 struct info_auth {
743 u_int32 timereset; /* time counters were reset */
744 u_int32 numkeys; /* number of keys we know */
745 u_int32 numfreekeys; /* number of free keys */
746 u_int32 keylookups; /* calls to authhavekey() */
747 u_int32 keynotfound; /* requested key unknown */
748 u_int32 encryptions; /* number of encryptions */
749 u_int32 decryptions; /* number of decryptions */
750 u_int32 expired; /* number of expired keys */
751 u_int32 keyuncached; /* calls to encrypt/decrypt with uncached key */
756 * Structure used to pass trap information to the client
758 struct info_trap {
759 u_int32 local_address; /* local interface addres (v4) */
760 u_int32 trap_address; /* remote client's addres (v4) */
761 u_short trap_port; /* remote port number */
762 u_short sequence; /* sequence number */
763 u_int32 settime; /* time trap last set */
764 u_int32 origtime; /* time trap originally set */
765 u_int32 resets; /* number of resets on this trap */
766 u_int32 flags; /* trap flags, as defined in ntp_control.h */
767 u_int v6_flag; /* is this v6 or not */
768 struct in6_addr local_address6; /* local interface address (v6) */
769 struct in6_addr trap_address6; /* remote client's address (v6) */
773 * Structure used to pass add/clear trap information to the client
775 struct conf_trap {
776 u_int32 local_address; /* remote client's address */
777 u_int32 trap_address; /* local interface address */
778 u_short trap_port; /* remote client's port */
779 u_short unused; /* (unused) */
780 u_int v6_flag; /* is this v6 or not */
781 struct in6_addr local_address6; /* local interface address (v6) */
782 struct in6_addr trap_address6; /* remote client's address (v6) */
787 * Structure used to return statistics from the control module
789 struct info_control {
790 u_int32 ctltimereset;
791 u_int32 numctlreq; /* number of requests we've received */
792 u_int32 numctlbadpkts; /* number of bad control packets */
793 u_int32 numctlresponses; /* # resp packets sent */
794 u_int32 numctlfrags; /* # of fragments sent */
795 u_int32 numctlerrors; /* number of error responses sent */
796 u_int32 numctltooshort; /* number of too short input packets */
797 u_int32 numctlinputresp; /* number of responses on input */
798 u_int32 numctlinputfrag; /* number of fragments on input */
799 u_int32 numctlinputerr; /* # input pkts with err bit set */
800 u_int32 numctlbadoffset; /* # input pkts with nonzero offset */
801 u_int32 numctlbadversion; /* # input pkts with unknown version */
802 u_int32 numctldatatooshort; /* data too short for count */
803 u_int32 numctlbadop; /* bad op code found in packet */
804 u_int32 numasyncmsgs; /* # async messages we've sent */
809 * Structure used to return clock information
811 struct info_clock {
812 u_int32 clockadr;
813 u_char type;
814 u_char flags;
815 u_char lastevent;
816 u_char currentstatus;
817 u_int32 polls;
818 u_int32 noresponse;
819 u_int32 badformat;
820 u_int32 baddata;
821 u_int32 timestarted;
822 l_fp fudgetime1;
823 l_fp fudgetime2;
824 int32 fudgeval1;
825 int32 fudgeval2;
830 * Structure used for setting clock fudge factors
832 struct conf_fudge {
833 u_int32 clockadr;
834 u_int32 which;
835 l_fp fudgetime;
836 int32 fudgeval_flags;
839 #define FUDGE_TIME1 1
840 #define FUDGE_TIME2 2
841 #define FUDGE_VAL1 3
842 #define FUDGE_VAL2 4
843 #define FUDGE_FLAGS 5
847 * Structure used for returning clock debugging info
849 #define NUMCBUGVALUES 16
850 #define NUMCBUGTIMES 32
852 struct info_clkbug {
853 u_int32 clockadr;
854 u_char nvalues;
855 u_char ntimes;
856 u_short svalues;
857 u_int32 stimes;
858 u_int32 values[NUMCBUGVALUES];
859 l_fp times[NUMCBUGTIMES];
863 * Structure used for returning kernel pll/PPS information
865 struct info_kernel {
866 int32 offset;
867 int32 freq;
868 int32 maxerror;
869 int32 esterror;
870 u_short status;
871 u_short shift;
872 int32 constant;
873 int32 precision;
874 int32 tolerance;
877 * Variables used only if PPS signal discipline is implemented
879 int32 ppsfreq;
880 int32 jitter;
881 int32 stabil;
882 int32 jitcnt;
883 int32 calcnt;
884 int32 errcnt;
885 int32 stbcnt;
889 * interface statistics
891 struct info_if_stats {
892 union addrun unaddr; /* address */
893 union addrun unbcast; /* broadcast */
894 union addrun unmask; /* mask */
895 u_int32 v6_flag; /* is this v6 */
896 char name[32]; /* name of interface */
897 int32 flags; /* interface flags */
898 int32 last_ttl; /* last TTL specified */
899 int32 num_mcast; /* No. of IP addresses in multicast socket */
900 int32 received; /* number of incoming packets */
901 int32 sent; /* number of outgoing packets */
902 int32 notsent; /* number of send failures */
903 int32 uptime; /* number of seconds this interface was active */
904 u_int32 scopeid; /* Scope used for Multicasting */
905 u_int32 ifindex; /* interface index - from system */
906 u_int32 ifnum; /* sequential interface number */
907 u_int32 peercnt; /* number of peers referencinf this interface - informational only */
908 u_short family; /* Address family */
909 u_char ignore_packets; /* Specify whether the packet should be ignored */
910 u_char action; /* reason the item is listed */
911 int32 _filler0; /* pad to a 64 bit size boundary */
914 #define IFS_EXISTS 1 /* just exists */
915 #define IFS_CREATED 2 /* was just created */
916 #define IFS_DELETED 3 /* was just delete */
919 * Info returned with IP -> hostname lookup
921 /* 144 might need to become 32, matching data[] member of req_pkt */
922 #define NTP_MAXHOSTNAME (32 - sizeof(u_int32) - sizeof(u_short))
923 struct info_dns_assoc {
924 u_int32 peeraddr; /* peer address (HMS: being careful...) */
925 associd_t associd; /* association ID */
926 char hostname[NTP_MAXHOSTNAME]; /* hostname */
928 #endif /* NTP_REQUEST_H */