PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/contrib/ntp/include/ntp_request.h

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