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