1*cdfa2a7eSchristos /* $NetBSD: ntp_request.h,v 1.9 2020/05/25 20:47:19 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 742950cc38Schristos * 1 - incompatible 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 */ 1212950cc38Schristos union addrun { 122abb0f93cSkardel struct in6_addr addr6; 123abb0f93cSkardel struct in_addr addr; 124abb0f93cSkardel }; 125abb0f93cSkardel 1262950cc38Schristos #define MODE7_PAYLOAD_LIM 176 1272950cc38Schristos 1282950cc38Schristos typedef union req_data_u_tag { 1292950cc38Schristos u_int32 u32[MODE7_PAYLOAD_LIM / sizeof(u_int32)]; 1302950cc38Schristos char data[MODE7_PAYLOAD_LIM]; /* data area (176 byte max) */ 1312950cc38Schristos } req_data_u; /* struct conf_peer must fit */ 1322950cc38Schristos 133abb0f93cSkardel /* 1347fdb569fSchristos * Structure for carrying system flags. 1357fdb569fSchristos */ 1367fdb569fSchristos struct conf_sys_flags { 1377fdb569fSchristos u_int32 flags; 1387fdb569fSchristos }; 1397fdb569fSchristos 1407fdb569fSchristos /* 1417fdb569fSchristos * System flags we can set/clear 1427fdb569fSchristos */ 1437fdb569fSchristos #define SYS_FLAG_BCLIENT 0x01 1447fdb569fSchristos #define SYS_FLAG_PPS 0x02 1457fdb569fSchristos #define SYS_FLAG_NTP 0x04 1467fdb569fSchristos #define SYS_FLAG_KERNEL 0x08 1477fdb569fSchristos #define SYS_FLAG_MONITOR 0x10 1487fdb569fSchristos #define SYS_FLAG_FILEGEN 0x20 1497fdb569fSchristos #define SYS_FLAG_AUTH 0x40 1507fdb569fSchristos #define SYS_FLAG_CAL 0x80 1517fdb569fSchristos 1527fdb569fSchristos /* 153abb0f93cSkardel * A request packet. These are almost a fixed length. 154abb0f93cSkardel */ 155abb0f93cSkardel struct req_pkt { 156abb0f93cSkardel u_char rm_vn_mode; /* response, more, version, mode */ 157abb0f93cSkardel u_char auth_seq; /* key, sequence number */ 158abb0f93cSkardel u_char implementation; /* implementation number */ 159abb0f93cSkardel u_char request; /* request number */ 160abb0f93cSkardel u_short err_nitems; /* error code/number of data items */ 161abb0f93cSkardel u_short mbz_itemsize; /* item size */ 1622950cc38Schristos req_data_u u; /* data area */ 163abb0f93cSkardel l_fp tstamp; /* time stamp, for authentication */ 164abb0f93cSkardel keyid_t keyid; /* (optional) encryption key */ 1654eea345dSchristos char mac[MAX_MDG_LEN]; /* (optional) auth code */ 166abb0f93cSkardel }; 167abb0f93cSkardel 168abb0f93cSkardel /* 169abb0f93cSkardel * The req_pkt_tail structure is used by ntpd to adjust for different 170abb0f93cSkardel * packet sizes that may arrive. 171abb0f93cSkardel */ 172abb0f93cSkardel struct req_pkt_tail { 173abb0f93cSkardel l_fp tstamp; /* time stamp, for authentication */ 174abb0f93cSkardel keyid_t keyid; /* (optional) encryption key */ 1754eea345dSchristos char mac[MAX_MDG_LEN]; /* (optional) auth code */ 176abb0f93cSkardel }; 177abb0f93cSkardel 178abb0f93cSkardel /* MODE_PRIVATE request packet header length before optional items. */ 1792950cc38Schristos #define REQ_LEN_HDR (offsetof(struct req_pkt, u)) 180abb0f93cSkardel /* MODE_PRIVATE request packet fixed length without MAC. */ 181abb0f93cSkardel #define REQ_LEN_NOMAC (offsetof(struct req_pkt, keyid)) 182abb0f93cSkardel /* MODE_PRIVATE req_pkt_tail minimum size (16 octet digest) */ 183abb0f93cSkardel #define REQ_TAIL_MIN \ 184abb0f93cSkardel (sizeof(struct req_pkt_tail) - (MAX_MAC_LEN - MAX_MD5_LEN)) 185abb0f93cSkardel 186abb0f93cSkardel /* 187abb0f93cSkardel * A MODE_PRIVATE response packet. The length here is variable, this 188abb0f93cSkardel * is a maximally sized one. Note that this implementation doesn't 189abb0f93cSkardel * authenticate responses. 190abb0f93cSkardel */ 1912950cc38Schristos #define RESP_HEADER_SIZE (offsetof(struct resp_pkt, u)) 1922950cc38Schristos #define RESP_DATA_SIZE 500 1932950cc38Schristos 1942950cc38Schristos typedef union resp_pkt_u_tag { 1952950cc38Schristos char data[RESP_DATA_SIZE]; 1962950cc38Schristos u_int32 u32[RESP_DATA_SIZE / sizeof(u_int32)]; 1972950cc38Schristos } resp_pkt_u; 198abb0f93cSkardel 199abb0f93cSkardel struct resp_pkt { 200abb0f93cSkardel u_char rm_vn_mode; /* response, more, version, mode */ 201abb0f93cSkardel u_char auth_seq; /* key, sequence number */ 202abb0f93cSkardel u_char implementation; /* implementation number */ 203abb0f93cSkardel u_char request; /* request number */ 204abb0f93cSkardel u_short err_nitems; /* error code/number of data items */ 205abb0f93cSkardel u_short mbz_itemsize; /* item size */ 2062950cc38Schristos resp_pkt_u u; /* data area */ 207abb0f93cSkardel }; 208abb0f93cSkardel 209abb0f93cSkardel 210abb0f93cSkardel /* 211abb0f93cSkardel * Information error codes 212abb0f93cSkardel */ 213abb0f93cSkardel #define INFO_OKAY 0 2142950cc38Schristos #define INFO_ERR_IMPL 1 /* incompatible implementation */ 215abb0f93cSkardel #define INFO_ERR_REQ 2 /* unknown request code */ 216abb0f93cSkardel #define INFO_ERR_FMT 3 /* format error */ 217abb0f93cSkardel #define INFO_ERR_NODATA 4 /* no data for this request */ 218abb0f93cSkardel #define INFO_ERR_AUTH 7 /* authentication failure */ 2192950cc38Schristos #define MAX_INFO_ERR INFO_ERR_AUTH 220abb0f93cSkardel 221abb0f93cSkardel /* 222abb0f93cSkardel * Maximum sequence number. 223abb0f93cSkardel */ 224abb0f93cSkardel #define MAXSEQ 127 225abb0f93cSkardel 226abb0f93cSkardel 227abb0f93cSkardel /* 228abb0f93cSkardel * Bit setting macros for multifield items. 229abb0f93cSkardel */ 230abb0f93cSkardel #define RESP_BIT 0x80 231abb0f93cSkardel #define MORE_BIT 0x40 232abb0f93cSkardel 233abb0f93cSkardel #define ISRESPONSE(rm_vn_mode) (((rm_vn_mode)&RESP_BIT)!=0) 234abb0f93cSkardel #define ISMORE(rm_vn_mode) (((rm_vn_mode)&MORE_BIT)!=0) 235abb0f93cSkardel #define INFO_VERSION(rm_vn_mode) ((u_char)(((rm_vn_mode)>>3)&0x7)) 236abb0f93cSkardel #define INFO_MODE(rm_vn_mode) ((rm_vn_mode)&0x7) 237abb0f93cSkardel 238abb0f93cSkardel #define RM_VN_MODE(resp, more, version) \ 239abb0f93cSkardel ((u_char)(((resp)?RESP_BIT:0)\ 240abb0f93cSkardel |((more)?MORE_BIT:0)\ 241abb0f93cSkardel |((version?version:(NTP_OLDVERSION+1))<<3)\ 242abb0f93cSkardel |(MODE_PRIVATE))) 243abb0f93cSkardel 244abb0f93cSkardel #define INFO_IS_AUTH(auth_seq) (((auth_seq) & 0x80) != 0) 245abb0f93cSkardel #define INFO_SEQ(auth_seq) ((auth_seq)&0x7f) 246abb0f93cSkardel #define AUTH_SEQ(auth, seq) ((u_char)((((auth)!=0)?0x80:0)|((seq)&0x7f))) 247abb0f93cSkardel 248abb0f93cSkardel #define INFO_ERR(err_nitems) ((u_short)((ntohs(err_nitems)>>12)&0xf)) 249abb0f93cSkardel #define INFO_NITEMS(err_nitems) ((u_short)(ntohs(err_nitems)&0xfff)) 2507fdb569fSchristos #define _ERR_EN(err) ((u_short)(((err)&0xf)<<12)) 2517fdb569fSchristos #define ERR_NITEMS(err, nitems) ((u_short)htons(_ERR_EN(err)|(nitems&0xfff))) 252abb0f93cSkardel 253abb0f93cSkardel #define INFO_MBZ(mbz_itemsize) ((ntohs(mbz_itemsize)>>12)&0xf) 254abb0f93cSkardel #define INFO_ITEMSIZE(mbz_itemsize) ((u_short)(ntohs(mbz_itemsize)&0xfff)) 255abb0f93cSkardel #define MBZ_ITEMSIZE(itemsize) (htons((u_short)(itemsize))) 256abb0f93cSkardel 257abb0f93cSkardel 258abb0f93cSkardel /* 259abb0f93cSkardel * Implementation numbers. One for universal use and one for ntpd. 260abb0f93cSkardel */ 261abb0f93cSkardel #define IMPL_UNIV 0 262abb0f93cSkardel #define IMPL_XNTPD_OLD 2 /* Used by pre ipv6 ntpdc */ 263abb0f93cSkardel #define IMPL_XNTPD 3 /* Used by post ipv6 ntpdc */ 264abb0f93cSkardel 265abb0f93cSkardel /* 266abb0f93cSkardel * Some limits related to authentication. Frames which are 267abb0f93cSkardel * authenticated must include a time stamp which differs from 268abb0f93cSkardel * the receive time stamp by no more than 10 seconds. 269abb0f93cSkardel */ 270abb0f93cSkardel #define INFO_TS_MAXSKEW 10. 271abb0f93cSkardel 272abb0f93cSkardel /* 273abb0f93cSkardel * Universal request codes go here. There aren't any. 274abb0f93cSkardel */ 275abb0f93cSkardel 276abb0f93cSkardel /* 2772950cc38Schristos * ntpdc -> ntpd request codes go here. 278abb0f93cSkardel */ 279abb0f93cSkardel #define REQ_PEER_LIST 0 /* return list of peers */ 280abb0f93cSkardel #define REQ_PEER_LIST_SUM 1 /* return summary info for all peers */ 281abb0f93cSkardel #define REQ_PEER_INFO 2 /* get standard information on peer */ 282abb0f93cSkardel #define REQ_PEER_STATS 3 /* get statistics for peer */ 283abb0f93cSkardel #define REQ_SYS_INFO 4 /* get system information */ 284abb0f93cSkardel #define REQ_SYS_STATS 5 /* get system stats */ 285abb0f93cSkardel #define REQ_IO_STATS 6 /* get I/O stats */ 286abb0f93cSkardel #define REQ_MEM_STATS 7 /* stats related to peer list maint */ 287abb0f93cSkardel #define REQ_LOOP_INFO 8 /* info from the loop filter */ 288abb0f93cSkardel #define REQ_TIMER_STATS 9 /* get timer stats */ 289abb0f93cSkardel #define REQ_CONFIG 10 /* configure a new peer */ 290abb0f93cSkardel #define REQ_UNCONFIG 11 /* unconfigure an existing peer */ 291abb0f93cSkardel #define REQ_SET_SYS_FLAG 12 /* set system flags */ 292abb0f93cSkardel #define REQ_CLR_SYS_FLAG 13 /* clear system flags */ 293abb0f93cSkardel #define REQ_MONITOR 14 /* (not used) */ 294abb0f93cSkardel #define REQ_NOMONITOR 15 /* (not used) */ 295abb0f93cSkardel #define REQ_GET_RESTRICT 16 /* return restrict list */ 296abb0f93cSkardel #define REQ_RESADDFLAGS 17 /* add flags to restrict list */ 297abb0f93cSkardel #define REQ_RESSUBFLAGS 18 /* remove flags from restrict list */ 298abb0f93cSkardel #define REQ_UNRESTRICT 19 /* remove entry from restrict list */ 299abb0f93cSkardel #define REQ_MON_GETLIST 20 /* return data collected by monitor */ 300abb0f93cSkardel #define REQ_RESET_STATS 21 /* reset stat counters */ 301abb0f93cSkardel #define REQ_RESET_PEER 22 /* reset peer stat counters */ 302abb0f93cSkardel #define REQ_REREAD_KEYS 23 /* reread the encryption key file */ 303abb0f93cSkardel #define REQ_DO_DIRTY_HACK 24 /* (not used) */ 304abb0f93cSkardel #define REQ_DONT_DIRTY_HACK 25 /* (not used) */ 305abb0f93cSkardel #define REQ_TRUSTKEY 26 /* add a trusted key */ 306abb0f93cSkardel #define REQ_UNTRUSTKEY 27 /* remove a trusted key */ 307abb0f93cSkardel #define REQ_AUTHINFO 28 /* return authentication info */ 308abb0f93cSkardel #define REQ_TRAPS 29 /* return currently set traps */ 309abb0f93cSkardel #define REQ_ADD_TRAP 30 /* add a trap */ 310abb0f93cSkardel #define REQ_CLR_TRAP 31 /* clear a trap */ 311abb0f93cSkardel #define REQ_REQUEST_KEY 32 /* define a new request keyid */ 312abb0f93cSkardel #define REQ_CONTROL_KEY 33 /* define a new control keyid */ 313abb0f93cSkardel #define REQ_GET_CTLSTATS 34 /* get stats from the control module */ 314abb0f93cSkardel #define REQ_GET_LEAPINFO 35 /* (not used) */ 315abb0f93cSkardel #define REQ_GET_CLOCKINFO 36 /* get clock information */ 316abb0f93cSkardel #define REQ_SET_CLKFUDGE 37 /* set clock fudge factors */ 317abb0f93cSkardel #define REQ_GET_KERNEL 38 /* get kernel pll/pps information */ 318abb0f93cSkardel #define REQ_GET_CLKBUGINFO 39 /* get clock debugging info */ 319abb0f93cSkardel #define REQ_SET_PRECISION 41 /* (not used) */ 320abb0f93cSkardel #define REQ_MON_GETLIST_1 42 /* return collected v1 monitor data */ 321abb0f93cSkardel #define REQ_HOSTNAME_ASSOCID 43 /* Here is a hostname + assoc_id */ 322abb0f93cSkardel #define REQ_IF_STATS 44 /* get interface statistics */ 323abb0f93cSkardel #define REQ_IF_RELOAD 45 /* reload interface list */ 324abb0f93cSkardel 325abb0f93cSkardel /* Determine size of pre-v6 version of structures */ 326abb0f93cSkardel #define v4sizeof(type) offsetof(type, v6_flag) 327abb0f93cSkardel 328abb0f93cSkardel /* 329abb0f93cSkardel * Flags in the peer information returns 330abb0f93cSkardel */ 331abb0f93cSkardel #define INFO_FLAG_CONFIG 0x1 332abb0f93cSkardel #define INFO_FLAG_SYSPEER 0x2 333abb0f93cSkardel #define INFO_FLAG_BURST 0x4 334abb0f93cSkardel #define INFO_FLAG_REFCLOCK 0x8 335abb0f93cSkardel #define INFO_FLAG_PREFER 0x10 336abb0f93cSkardel #define INFO_FLAG_AUTHENABLE 0x20 337abb0f93cSkardel #define INFO_FLAG_SEL_CANDIDATE 0x40 338abb0f93cSkardel #define INFO_FLAG_SHORTLIST 0x80 339abb0f93cSkardel #define INFO_FLAG_IBURST 0x100 340abb0f93cSkardel 341abb0f93cSkardel /* 342abb0f93cSkardel * Flags in the system information returns 343abb0f93cSkardel */ 344abb0f93cSkardel #define INFO_FLAG_BCLIENT 0x1 345abb0f93cSkardel #define INFO_FLAG_AUTHENTICATE 0x2 346abb0f93cSkardel #define INFO_FLAG_NTP 0x4 347abb0f93cSkardel #define INFO_FLAG_KERNEL 0x8 348abb0f93cSkardel #define INFO_FLAG_MONITOR 0x40 349abb0f93cSkardel #define INFO_FLAG_FILEGEN 0x80 350abb0f93cSkardel #define INFO_FLAG_CAL 0x10 351abb0f93cSkardel #define INFO_FLAG_PPS_SYNC 0x20 352abb0f93cSkardel 353abb0f93cSkardel /* 354abb0f93cSkardel * Peer list structure. Used to return raw lists of peers. It goes 355abb0f93cSkardel * without saying that everything returned is in network byte order. 356abb0f93cSkardel * Well, it *would* have gone without saying, but somebody said it. 357abb0f93cSkardel */ 358abb0f93cSkardel struct info_peer_list { 359abb0f93cSkardel u_int32 addr; /* address of peer */ 360abb0f93cSkardel u_short port; /* port number of peer */ 361abb0f93cSkardel u_char hmode; /* mode for this peer */ 362abb0f93cSkardel u_char flags; /* flags (from above) */ 363abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 364abb0f93cSkardel u_int unused1; /* (unused) padding for addr6 */ 365abb0f93cSkardel struct in6_addr addr6; /* v6 address of peer */ 366abb0f93cSkardel }; 367abb0f93cSkardel 368abb0f93cSkardel 369abb0f93cSkardel /* 370abb0f93cSkardel * Peer summary structure. Sort of the info that ntpdc returns by default. 371abb0f93cSkardel */ 372abb0f93cSkardel struct info_peer_summary { 373abb0f93cSkardel u_int32 dstadr; /* local address (zero for undetermined) */ 374abb0f93cSkardel u_int32 srcadr; /* source address */ 375abb0f93cSkardel u_short srcport; /* source port */ 376abb0f93cSkardel u_char stratum; /* stratum of peer */ 377abb0f93cSkardel s_char hpoll; /* host polling interval */ 378abb0f93cSkardel s_char ppoll; /* peer polling interval */ 379abb0f93cSkardel u_char reach; /* reachability register */ 380abb0f93cSkardel u_char flags; /* flags, from above */ 381abb0f93cSkardel u_char hmode; /* peer mode */ 382abb0f93cSkardel s_fp delay; /* peer.estdelay */ 383abb0f93cSkardel l_fp offset; /* peer.estoffset */ 384abb0f93cSkardel u_fp dispersion; /* peer.estdisp */ 385abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 386abb0f93cSkardel u_int unused1; /* (unused) padding for dstadr6 */ 387abb0f93cSkardel struct in6_addr dstadr6; /* local address (v6) */ 388abb0f93cSkardel struct in6_addr srcadr6; /* source address (v6) */ 389abb0f93cSkardel }; 390abb0f93cSkardel 391abb0f93cSkardel 392abb0f93cSkardel /* 393abb0f93cSkardel * Peer information structure. 394abb0f93cSkardel */ 395abb0f93cSkardel struct info_peer { 396abb0f93cSkardel u_int32 dstadr; /* local address */ 397abb0f93cSkardel u_int32 srcadr; /* source address */ 398abb0f93cSkardel u_short srcport; /* remote port */ 399abb0f93cSkardel u_char flags; /* peer flags */ 400abb0f93cSkardel u_char leap; /* peer.leap */ 401abb0f93cSkardel u_char hmode; /* peer.hmode */ 402abb0f93cSkardel u_char pmode; /* peer.pmode */ 403abb0f93cSkardel u_char stratum; /* peer.stratum */ 404abb0f93cSkardel u_char ppoll; /* peer.ppoll */ 405abb0f93cSkardel u_char hpoll; /* peer.hpoll */ 406abb0f93cSkardel s_char precision; /* peer.precision */ 407abb0f93cSkardel u_char version; /* peer.version */ 408abb0f93cSkardel u_char unused8; 409abb0f93cSkardel u_char reach; /* peer.reach */ 410abb0f93cSkardel u_char unreach; /* peer.unreach */ 411abb0f93cSkardel u_char flash; /* old peer.flash */ 412abb0f93cSkardel u_char ttl; /* peer.ttl */ 413abb0f93cSkardel u_short flash2; /* new peer.flash */ 414abb0f93cSkardel associd_t associd; /* association ID */ 415abb0f93cSkardel keyid_t keyid; /* peer.keyid */ 416abb0f93cSkardel u_int32 pkeyid; /* unused */ 417abb0f93cSkardel u_int32 refid; /* peer.refid */ 418abb0f93cSkardel u_int32 timer; /* peer.timer */ 419abb0f93cSkardel s_fp rootdelay; /* peer.delay */ 420abb0f93cSkardel u_fp rootdispersion; /* peer.dispersion */ 421abb0f93cSkardel l_fp reftime; /* peer.reftime */ 422abb0f93cSkardel l_fp org; /* peer.org */ 423abb0f93cSkardel l_fp rec; /* peer.rec */ 424abb0f93cSkardel l_fp xmt; /* peer.xmt */ 425abb0f93cSkardel s_fp filtdelay[NTP_SHIFT]; /* delay shift register */ 426abb0f93cSkardel l_fp filtoffset[NTP_SHIFT]; /* offset shift register */ 427abb0f93cSkardel u_char order[NTP_SHIFT]; /* order of peers from last filter */ 428abb0f93cSkardel s_fp delay; /* peer.estdelay */ 429abb0f93cSkardel u_fp dispersion; /* peer.estdisp */ 430abb0f93cSkardel l_fp offset; /* peer.estoffset */ 431abb0f93cSkardel u_fp selectdisp; /* peer select dispersion */ 432abb0f93cSkardel int32 unused1; /* (obsolete) */ 433abb0f93cSkardel int32 unused2; 434abb0f93cSkardel int32 unused3; 435abb0f93cSkardel int32 unused4; 436abb0f93cSkardel int32 unused5; 437abb0f93cSkardel int32 unused6; 438abb0f93cSkardel int32 unused7; 439abb0f93cSkardel s_fp estbdelay; /* broadcast offset */ 440abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 441abb0f93cSkardel u_int unused9; /* (unused) padding for dstadr6 */ 442abb0f93cSkardel struct in6_addr dstadr6; /* local address (v6-like) */ 443abb0f93cSkardel struct in6_addr srcadr6; /* sources address (v6-like) */ 444abb0f93cSkardel }; 445abb0f93cSkardel 446abb0f93cSkardel 447abb0f93cSkardel /* 448abb0f93cSkardel * Peer statistics structure 449abb0f93cSkardel */ 450abb0f93cSkardel struct info_peer_stats { 451abb0f93cSkardel u_int32 dstadr; /* local address */ 452abb0f93cSkardel u_int32 srcadr; /* remote address */ 453abb0f93cSkardel u_short srcport; /* remote port */ 454abb0f93cSkardel u_short flags; /* peer flags */ 455abb0f93cSkardel u_int32 timereset; /* time counters were reset */ 456abb0f93cSkardel u_int32 timereceived; /* time since a packet received */ 457abb0f93cSkardel u_int32 timetosend; /* time until a packet sent */ 458abb0f93cSkardel u_int32 timereachable; /* time peer has been reachable */ 459abb0f93cSkardel u_int32 sent; /* number sent */ 460abb0f93cSkardel u_int32 unused1; /* (unused) */ 461abb0f93cSkardel u_int32 processed; /* number processed */ 462abb0f93cSkardel u_int32 unused2; /* (unused) */ 463abb0f93cSkardel u_int32 badauth; /* bad authentication */ 464abb0f93cSkardel u_int32 bogusorg; /* bogus origin */ 465abb0f93cSkardel u_int32 oldpkt; /* duplicate */ 466abb0f93cSkardel u_int32 unused3; /* (unused) */ 467abb0f93cSkardel u_int32 unused4; /* (unused) */ 468abb0f93cSkardel u_int32 seldisp; /* bad dispersion */ 469abb0f93cSkardel u_int32 selbroken; /* bad reference time */ 470abb0f93cSkardel u_int32 unused5; /* (unused) */ 471abb0f93cSkardel u_char candidate; /* select order */ 472abb0f93cSkardel u_char unused6; /* (unused) */ 473abb0f93cSkardel u_char unused7; /* (unused) */ 474abb0f93cSkardel u_char unused8; /* (unused) */ 475abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 476abb0f93cSkardel u_int unused9; /* (unused) padding for dstadr6 */ 477abb0f93cSkardel struct in6_addr dstadr6; /* local address */ 478abb0f93cSkardel struct in6_addr srcadr6; /* remote address */ 479abb0f93cSkardel }; 480abb0f93cSkardel 481abb0f93cSkardel 482abb0f93cSkardel /* 483abb0f93cSkardel * Loop filter variables 484abb0f93cSkardel */ 485abb0f93cSkardel struct info_loop { 486abb0f93cSkardel l_fp last_offset; 487abb0f93cSkardel l_fp drift_comp; 488abb0f93cSkardel u_int32 compliance; 489abb0f93cSkardel u_int32 watchdog_timer; 490abb0f93cSkardel }; 491abb0f93cSkardel 492abb0f93cSkardel 493abb0f93cSkardel /* 494abb0f93cSkardel * System info. Mostly the sys.* variables, plus a few unique to 495abb0f93cSkardel * the implementation. 496abb0f93cSkardel */ 497abb0f93cSkardel struct info_sys { 498abb0f93cSkardel u_int32 peer; /* system peer address (v4) */ 499abb0f93cSkardel u_char peer_mode; /* mode we are syncing to peer in */ 500abb0f93cSkardel u_char leap; /* system leap bits */ 501abb0f93cSkardel u_char stratum; /* our stratum */ 502abb0f93cSkardel s_char precision; /* local clock precision */ 503abb0f93cSkardel s_fp rootdelay; /* delay from sync source */ 504abb0f93cSkardel u_fp rootdispersion; /* dispersion from sync source */ 505abb0f93cSkardel u_int32 refid; /* reference ID of sync source */ 506abb0f93cSkardel l_fp reftime; /* system reference time */ 507abb0f93cSkardel u_int32 poll; /* system poll interval */ 508abb0f93cSkardel u_char flags; /* system flags */ 509abb0f93cSkardel u_char unused1; /* unused */ 510abb0f93cSkardel u_char unused2; /* unused */ 511abb0f93cSkardel u_char unused3; /* unused */ 512abb0f93cSkardel s_fp bdelay; /* default broadcast offset */ 513abb0f93cSkardel s_fp frequency; /* frequency residual (scaled ppm) */ 514abb0f93cSkardel l_fp authdelay; /* default authentication delay */ 515abb0f93cSkardel u_fp stability; /* clock stability (scaled ppm) */ 516abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 517abb0f93cSkardel u_int unused4; /* unused, padding for peer6 */ 518abb0f93cSkardel struct in6_addr peer6; /* system peer address (v6) */ 519abb0f93cSkardel }; 520abb0f93cSkardel 521abb0f93cSkardel 522abb0f93cSkardel /* 523abb0f93cSkardel * System stats. These are collected in the protocol module 524abb0f93cSkardel */ 525abb0f93cSkardel struct info_sys_stats { 526abb0f93cSkardel u_int32 timeup; /* time since restart */ 527abb0f93cSkardel u_int32 timereset; /* time since reset */ 528abb0f93cSkardel u_int32 denied; /* access denied */ 529abb0f93cSkardel u_int32 oldversionpkt; /* recent version */ 530abb0f93cSkardel u_int32 newversionpkt; /* current version */ 531abb0f93cSkardel u_int32 unknownversion; /* bad version */ 532abb0f93cSkardel u_int32 badlength; /* bad length or format */ 533abb0f93cSkardel u_int32 processed; /* packets processed */ 534abb0f93cSkardel u_int32 badauth; /* bad authentication */ 535abb0f93cSkardel u_int32 received; /* packets received */ 536abb0f93cSkardel u_int32 limitrejected; /* rate exceeded */ 5374eea345dSchristos u_int32 lamport; /* Lamport violations */ 5384eea345dSchristos u_int32 tsrounding; /* Timestamp rounding errors */ 539abb0f93cSkardel }; 540abb0f93cSkardel 541abb0f93cSkardel 542abb0f93cSkardel /* 543abb0f93cSkardel * System stats - old version 544abb0f93cSkardel */ 545abb0f93cSkardel struct old_info_sys_stats { 546abb0f93cSkardel u_int32 timeup; /* time since restart */ 547abb0f93cSkardel u_int32 timereset; /* time since reset */ 548abb0f93cSkardel u_int32 denied; /* access denied */ 549abb0f93cSkardel u_int32 oldversionpkt; /* recent version */ 550abb0f93cSkardel u_int32 newversionpkt; /* current version */ 551abb0f93cSkardel u_int32 unknownversion; /* bad version */ 552abb0f93cSkardel u_int32 badlength; /* bad length or format */ 553abb0f93cSkardel u_int32 processed; /* packets processed */ 554abb0f93cSkardel u_int32 badauth; /* bad authentication */ 555abb0f93cSkardel u_int32 wanderhold; /* (not used) */ 556abb0f93cSkardel }; 557abb0f93cSkardel 558abb0f93cSkardel 559abb0f93cSkardel /* 560abb0f93cSkardel * Peer memory statistics. Collected in the peer module. 561abb0f93cSkardel */ 562abb0f93cSkardel struct info_mem_stats { 563abb0f93cSkardel u_int32 timereset; /* time since reset */ 564abb0f93cSkardel u_short totalpeermem; 565abb0f93cSkardel u_short freepeermem; 566abb0f93cSkardel u_int32 findpeer_calls; 567abb0f93cSkardel u_int32 allocations; 568abb0f93cSkardel u_int32 demobilizations; 569abb0f93cSkardel u_char hashcount[NTP_HASH_SIZE]; 570abb0f93cSkardel }; 571abb0f93cSkardel 572abb0f93cSkardel 573abb0f93cSkardel /* 574abb0f93cSkardel * I/O statistics. Collected in the I/O module 575abb0f93cSkardel */ 576abb0f93cSkardel struct info_io_stats { 577abb0f93cSkardel u_int32 timereset; /* time since reset */ 578abb0f93cSkardel u_short totalrecvbufs; /* total receive bufs */ 579abb0f93cSkardel u_short freerecvbufs; /* free buffers */ 580abb0f93cSkardel u_short fullrecvbufs; /* full buffers */ 581abb0f93cSkardel u_short lowwater; /* number of times we've added buffers */ 582abb0f93cSkardel u_int32 dropped; /* dropped packets */ 583abb0f93cSkardel u_int32 ignored; /* ignored packets */ 584abb0f93cSkardel u_int32 received; /* received packets */ 585abb0f93cSkardel u_int32 sent; /* packets sent */ 586abb0f93cSkardel u_int32 notsent; /* packets not sent */ 587abb0f93cSkardel u_int32 interrupts; /* interrupts we've handled */ 588abb0f93cSkardel u_int32 int_received; /* received by interrupt handler */ 589abb0f93cSkardel }; 590abb0f93cSkardel 591abb0f93cSkardel 592abb0f93cSkardel /* 593abb0f93cSkardel * Timer stats. Guess where from. 594abb0f93cSkardel */ 595abb0f93cSkardel struct info_timer_stats { 596abb0f93cSkardel u_int32 timereset; /* time since reset */ 597abb0f93cSkardel u_int32 alarms; /* alarms we've handled */ 598abb0f93cSkardel u_int32 overflows; /* timer overflows */ 599abb0f93cSkardel u_int32 xmtcalls; /* calls to xmit */ 600abb0f93cSkardel }; 601abb0f93cSkardel 602abb0f93cSkardel 603abb0f93cSkardel /* 604abb0f93cSkardel * Structure for passing peer configuration information 605abb0f93cSkardel */ 606abb0f93cSkardel struct old_conf_peer { 607abb0f93cSkardel u_int32 peeraddr; /* address to poll */ 608abb0f93cSkardel u_char hmode; /* mode, either broadcast, active or client */ 609abb0f93cSkardel u_char version; /* version number to poll with */ 610abb0f93cSkardel u_char minpoll; /* min host poll interval */ 611abb0f93cSkardel u_char maxpoll; /* max host poll interval */ 612abb0f93cSkardel u_char flags; /* flags for this request */ 613abb0f93cSkardel u_char ttl; /* time to live (multicast) or refclock mode */ 614abb0f93cSkardel u_short unused; /* unused */ 615abb0f93cSkardel keyid_t keyid; /* key to use for this association */ 616abb0f93cSkardel }; 617abb0f93cSkardel 618abb0f93cSkardel struct conf_peer { 619abb0f93cSkardel u_int32 peeraddr; /* address to poll */ 620abb0f93cSkardel u_char hmode; /* mode, either broadcast, active or client */ 621abb0f93cSkardel u_char version; /* version number to poll with */ 622abb0f93cSkardel u_char minpoll; /* min host poll interval */ 623abb0f93cSkardel u_char maxpoll; /* max host poll interval */ 624abb0f93cSkardel u_char flags; /* flags for this request */ 625abb0f93cSkardel u_char ttl; /* time to live (multicast) or refclock mode */ 626abb0f93cSkardel u_short unused1; /* unused */ 627abb0f93cSkardel keyid_t keyid; /* key to use for this association */ 6282950cc38Schristos char keystr[128]; /* public key file name */ 629abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 630abb0f93cSkardel u_int unused2; /* unused, padding for peeraddr6 */ 631abb0f93cSkardel struct in6_addr peeraddr6; /* ipv6 address to poll */ 632abb0f93cSkardel }; 633abb0f93cSkardel 634abb0f93cSkardel #define CONF_FLAG_AUTHENABLE 0x01 635abb0f93cSkardel #define CONF_FLAG_PREFER 0x02 636abb0f93cSkardel #define CONF_FLAG_BURST 0x04 637abb0f93cSkardel #define CONF_FLAG_IBURST 0x08 638abb0f93cSkardel #define CONF_FLAG_NOSELECT 0x10 639abb0f93cSkardel #define CONF_FLAG_SKEY 0x20 640abb0f93cSkardel 641abb0f93cSkardel /* 642abb0f93cSkardel * Structure for passing peer deletion information. Currently 643abb0f93cSkardel * we only pass the address and delete all configured peers with 644abb0f93cSkardel * this addess. 645abb0f93cSkardel */ 646abb0f93cSkardel struct conf_unpeer { 647abb0f93cSkardel u_int32 peeraddr; /* address of peer */ 648abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 649abb0f93cSkardel struct in6_addr peeraddr6; /* address of peer (v6) */ 650abb0f93cSkardel }; 651abb0f93cSkardel 652abb0f93cSkardel /* 653abb0f93cSkardel * Structure used for returning restrict entries 654abb0f93cSkardel */ 655abb0f93cSkardel struct info_restrict { 656abb0f93cSkardel u_int32 addr; /* match address */ 657abb0f93cSkardel u_int32 mask; /* match mask */ 658abb0f93cSkardel u_int32 count; /* number of packets matched */ 6594eea345dSchristos u_short rflags; /* restrict flags */ 660abb0f93cSkardel u_short mflags; /* match flags */ 661abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 662abb0f93cSkardel u_int unused1; /* unused, padding for addr6 */ 663abb0f93cSkardel struct in6_addr addr6; /* match address (v6) */ 664abb0f93cSkardel struct in6_addr mask6; /* match mask (v6) */ 665abb0f93cSkardel }; 666abb0f93cSkardel 667abb0f93cSkardel 668abb0f93cSkardel /* 669abb0f93cSkardel * Structure used for specifying restrict entries 670abb0f93cSkardel */ 671abb0f93cSkardel struct conf_restrict { 672abb0f93cSkardel u_int32 addr; /* match address */ 673abb0f93cSkardel u_int32 mask; /* match mask */ 6744eea345dSchristos short ippeerlimit; /* ip peer limit */ 675*cdfa2a7eSchristos int srvfuzrft; /* server response fuzz reftime: poll */ 676*cdfa2a7eSchristos u_short flags; /* restrict flags XXX: OLD size and name */ 677abb0f93cSkardel u_short mflags; /* match flags */ 678*cdfa2a7eSchristos short unused1; /* (unused) padding for v6_flag */ 679abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 680abb0f93cSkardel struct in6_addr addr6; /* match address (v6) */ 681abb0f93cSkardel struct in6_addr mask6; /* match mask (v6) */ 682abb0f93cSkardel }; 683abb0f93cSkardel 684abb0f93cSkardel 685abb0f93cSkardel /* 686abb0f93cSkardel * Structure used for returning monitor data 687abb0f93cSkardel */ 688abb0f93cSkardel struct info_monitor_1 { 6892950cc38Schristos u_int32 avg_int; /* avg s between packets from this host */ 6902950cc38Schristos u_int32 last_int; /* s since we last received a packet */ 691abb0f93cSkardel u_int32 restr; /* restrict bits (was named lastdrop) */ 692abb0f93cSkardel u_int32 count; /* count of packets received */ 693abb0f93cSkardel u_int32 addr; /* host address V4 style */ 694abb0f93cSkardel u_int32 daddr; /* destination host address */ 695abb0f93cSkardel u_int32 flags; /* flags about destination */ 696abb0f93cSkardel u_short port; /* port number of last reception */ 697abb0f93cSkardel u_char mode; /* mode of last packet */ 698abb0f93cSkardel u_char version; /* version number of last packet */ 699abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 700abb0f93cSkardel u_int unused1; /* unused, padding for addr6 */ 701abb0f93cSkardel struct in6_addr addr6; /* host address V6 style */ 702abb0f93cSkardel struct in6_addr daddr6; /* host address V6 style */ 703abb0f93cSkardel }; 704abb0f93cSkardel 705abb0f93cSkardel 706abb0f93cSkardel /* 707abb0f93cSkardel * Structure used for returning monitor data 708abb0f93cSkardel */ 709abb0f93cSkardel struct info_monitor { 7102950cc38Schristos u_int32 avg_int; /* avg s between packets from this host */ 7112950cc38Schristos u_int32 last_int; /* s since we last received a packet */ 712abb0f93cSkardel u_int32 restr; /* restrict bits (was named lastdrop) */ 713abb0f93cSkardel u_int32 count; /* count of packets received */ 714abb0f93cSkardel u_int32 addr; /* host address */ 715abb0f93cSkardel u_short port; /* port number of last reception */ 716abb0f93cSkardel u_char mode; /* mode of last packet */ 717abb0f93cSkardel u_char version; /* version number of last packet */ 718abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 719abb0f93cSkardel u_int unused1; /* unused, padding for addr6 */ 720abb0f93cSkardel struct in6_addr addr6; /* host v6 address */ 721abb0f93cSkardel }; 722abb0f93cSkardel 723abb0f93cSkardel /* 724abb0f93cSkardel * Structure used for returning monitor data (old format) 725abb0f93cSkardel */ 726abb0f93cSkardel struct old_info_monitor { 727abb0f93cSkardel u_int32 lasttime; /* last packet from this host */ 728abb0f93cSkardel u_int32 firsttime; /* first time we received a packet */ 729abb0f93cSkardel u_int32 count; /* count of packets received */ 730abb0f93cSkardel u_int32 addr; /* host address */ 731abb0f93cSkardel u_short port; /* port number of last reception */ 732abb0f93cSkardel u_char mode; /* mode of last packet */ 733abb0f93cSkardel u_char version; /* version number of last packet */ 734abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 735abb0f93cSkardel struct in6_addr addr6; /* host address (v6)*/ 736abb0f93cSkardel }; 737abb0f93cSkardel 738abb0f93cSkardel /* 7392950cc38Schristos * Structure used for passing indication of flags to clear 7402950cc38Schristos */ 7412950cc38Schristos struct reset_flags { 7422950cc38Schristos u_int32 flags; 7432950cc38Schristos }; 7442950cc38Schristos 7452950cc38Schristos #define RESET_FLAG_ALLPEERS 0x01 7462950cc38Schristos #define RESET_FLAG_IO 0x02 7472950cc38Schristos #define RESET_FLAG_SYS 0x04 7482950cc38Schristos #define RESET_FLAG_MEM 0x08 7492950cc38Schristos #define RESET_FLAG_TIMER 0x10 7502950cc38Schristos #define RESET_FLAG_AUTH 0x20 7512950cc38Schristos #define RESET_FLAG_CTL 0x40 7522950cc38Schristos 7532950cc38Schristos #define RESET_ALLFLAGS ( \ 7542950cc38Schristos RESET_FLAG_ALLPEERS | \ 7552950cc38Schristos RESET_FLAG_IO | \ 7562950cc38Schristos RESET_FLAG_SYS | \ 7572950cc38Schristos RESET_FLAG_MEM | \ 7582950cc38Schristos RESET_FLAG_TIMER | \ 7592950cc38Schristos RESET_FLAG_AUTH | \ 7602950cc38Schristos RESET_FLAG_CTL \ 7612950cc38Schristos ) 7622950cc38Schristos 7632950cc38Schristos /* 764abb0f93cSkardel * Structure used to return information concerning the authentication 765abb0f93cSkardel * module. 766abb0f93cSkardel */ 767abb0f93cSkardel struct info_auth { 768abb0f93cSkardel u_int32 timereset; /* time counters were reset */ 769abb0f93cSkardel u_int32 numkeys; /* number of keys we know */ 770abb0f93cSkardel u_int32 numfreekeys; /* number of free keys */ 771abb0f93cSkardel u_int32 keylookups; /* calls to authhavekey() */ 772abb0f93cSkardel u_int32 keynotfound; /* requested key unknown */ 773abb0f93cSkardel u_int32 encryptions; /* number of encryptions */ 774abb0f93cSkardel u_int32 decryptions; /* number of decryptions */ 775abb0f93cSkardel u_int32 expired; /* number of expired keys */ 776abb0f93cSkardel u_int32 keyuncached; /* calls to encrypt/decrypt with uncached key */ 777abb0f93cSkardel }; 778abb0f93cSkardel 779abb0f93cSkardel 780abb0f93cSkardel /* 781abb0f93cSkardel * Structure used to pass trap information to the client 782abb0f93cSkardel */ 783abb0f93cSkardel struct info_trap { 784abb0f93cSkardel u_int32 local_address; /* local interface addres (v4) */ 785abb0f93cSkardel u_int32 trap_address; /* remote client's addres (v4) */ 786abb0f93cSkardel u_short trap_port; /* remote port number */ 787abb0f93cSkardel u_short sequence; /* sequence number */ 788abb0f93cSkardel u_int32 settime; /* time trap last set */ 789abb0f93cSkardel u_int32 origtime; /* time trap originally set */ 790abb0f93cSkardel u_int32 resets; /* number of resets on this trap */ 791abb0f93cSkardel u_int32 flags; /* trap flags, as defined in ntp_control.h */ 792abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 793abb0f93cSkardel struct in6_addr local_address6; /* local interface address (v6) */ 794abb0f93cSkardel struct in6_addr trap_address6; /* remote client's address (v6) */ 795abb0f93cSkardel }; 796abb0f93cSkardel 797abb0f93cSkardel /* 798abb0f93cSkardel * Structure used to pass add/clear trap information to the client 799abb0f93cSkardel */ 800abb0f93cSkardel struct conf_trap { 801abb0f93cSkardel u_int32 local_address; /* remote client's address */ 802abb0f93cSkardel u_int32 trap_address; /* local interface address */ 803abb0f93cSkardel u_short trap_port; /* remote client's port */ 804abb0f93cSkardel u_short unused; /* (unused) */ 805abb0f93cSkardel u_int v6_flag; /* is this v6 or not */ 806abb0f93cSkardel struct in6_addr local_address6; /* local interface address (v6) */ 807abb0f93cSkardel struct in6_addr trap_address6; /* remote client's address (v6) */ 808abb0f93cSkardel }; 809abb0f93cSkardel 810abb0f93cSkardel 811abb0f93cSkardel /* 812abb0f93cSkardel * Structure used to return statistics from the control module 813abb0f93cSkardel */ 814abb0f93cSkardel struct info_control { 815abb0f93cSkardel u_int32 ctltimereset; 816abb0f93cSkardel u_int32 numctlreq; /* number of requests we've received */ 817abb0f93cSkardel u_int32 numctlbadpkts; /* number of bad control packets */ 818abb0f93cSkardel u_int32 numctlresponses; /* # resp packets sent */ 819abb0f93cSkardel u_int32 numctlfrags; /* # of fragments sent */ 820abb0f93cSkardel u_int32 numctlerrors; /* number of error responses sent */ 821abb0f93cSkardel u_int32 numctltooshort; /* number of too short input packets */ 822abb0f93cSkardel u_int32 numctlinputresp; /* number of responses on input */ 823abb0f93cSkardel u_int32 numctlinputfrag; /* number of fragments on input */ 824abb0f93cSkardel u_int32 numctlinputerr; /* # input pkts with err bit set */ 825abb0f93cSkardel u_int32 numctlbadoffset; /* # input pkts with nonzero offset */ 826abb0f93cSkardel u_int32 numctlbadversion; /* # input pkts with unknown version */ 827abb0f93cSkardel u_int32 numctldatatooshort; /* data too short for count */ 828abb0f93cSkardel u_int32 numctlbadop; /* bad op code found in packet */ 829abb0f93cSkardel u_int32 numasyncmsgs; /* # async messages we've sent */ 830abb0f93cSkardel }; 831abb0f93cSkardel 832abb0f93cSkardel 833abb0f93cSkardel /* 834abb0f93cSkardel * Structure used to return clock information 835abb0f93cSkardel */ 836abb0f93cSkardel struct info_clock { 837abb0f93cSkardel u_int32 clockadr; 838abb0f93cSkardel u_char type; 839abb0f93cSkardel u_char flags; 840abb0f93cSkardel u_char lastevent; 841abb0f93cSkardel u_char currentstatus; 842abb0f93cSkardel u_int32 polls; 843abb0f93cSkardel u_int32 noresponse; 844abb0f93cSkardel u_int32 badformat; 845abb0f93cSkardel u_int32 baddata; 846abb0f93cSkardel u_int32 timestarted; 847abb0f93cSkardel l_fp fudgetime1; 848abb0f93cSkardel l_fp fudgetime2; 849abb0f93cSkardel int32 fudgeval1; 8503123f114Skardel u_int32 fudgeval2; 851abb0f93cSkardel }; 852abb0f93cSkardel 853abb0f93cSkardel 854abb0f93cSkardel /* 855abb0f93cSkardel * Structure used for setting clock fudge factors 856abb0f93cSkardel */ 857abb0f93cSkardel struct conf_fudge { 858abb0f93cSkardel u_int32 clockadr; 859abb0f93cSkardel u_int32 which; 860abb0f93cSkardel l_fp fudgetime; 8613123f114Skardel u_int32 fudgeval_flags; 862abb0f93cSkardel }; 863abb0f93cSkardel 864abb0f93cSkardel #define FUDGE_TIME1 1 865abb0f93cSkardel #define FUDGE_TIME2 2 866abb0f93cSkardel #define FUDGE_VAL1 3 867abb0f93cSkardel #define FUDGE_VAL2 4 868abb0f93cSkardel #define FUDGE_FLAGS 5 869abb0f93cSkardel 870abb0f93cSkardel 871abb0f93cSkardel /* 872abb0f93cSkardel * Structure used for returning clock debugging info 873abb0f93cSkardel */ 874abb0f93cSkardel #define NUMCBUGVALUES 16 875abb0f93cSkardel #define NUMCBUGTIMES 32 876abb0f93cSkardel 877abb0f93cSkardel struct info_clkbug { 878abb0f93cSkardel u_int32 clockadr; 879abb0f93cSkardel u_char nvalues; 880abb0f93cSkardel u_char ntimes; 881abb0f93cSkardel u_short svalues; 882abb0f93cSkardel u_int32 stimes; 883abb0f93cSkardel u_int32 values[NUMCBUGVALUES]; 884abb0f93cSkardel l_fp times[NUMCBUGTIMES]; 885abb0f93cSkardel }; 886abb0f93cSkardel 887abb0f93cSkardel /* 888abb0f93cSkardel * Structure used for returning kernel pll/PPS information 889abb0f93cSkardel */ 890abb0f93cSkardel struct info_kernel { 891abb0f93cSkardel int32 offset; 892abb0f93cSkardel int32 freq; 893abb0f93cSkardel int32 maxerror; 894abb0f93cSkardel int32 esterror; 895abb0f93cSkardel u_short status; 896abb0f93cSkardel u_short shift; 897abb0f93cSkardel int32 constant; 898abb0f93cSkardel int32 precision; 899abb0f93cSkardel int32 tolerance; 900abb0f93cSkardel 901abb0f93cSkardel /* 902abb0f93cSkardel * Variables used only if PPS signal discipline is implemented 903abb0f93cSkardel */ 904abb0f93cSkardel int32 ppsfreq; 905abb0f93cSkardel int32 jitter; 906abb0f93cSkardel int32 stabil; 907abb0f93cSkardel int32 jitcnt; 908abb0f93cSkardel int32 calcnt; 909abb0f93cSkardel int32 errcnt; 910abb0f93cSkardel int32 stbcnt; 911abb0f93cSkardel }; 912abb0f93cSkardel 913abb0f93cSkardel /* 914abb0f93cSkardel * interface statistics 915abb0f93cSkardel */ 916abb0f93cSkardel struct info_if_stats { 917abb0f93cSkardel union addrun unaddr; /* address */ 918abb0f93cSkardel union addrun unbcast; /* broadcast */ 919abb0f93cSkardel union addrun unmask; /* mask */ 920abb0f93cSkardel u_int32 v6_flag; /* is this v6 */ 921abb0f93cSkardel char name[32]; /* name of interface */ 922abb0f93cSkardel int32 flags; /* interface flags */ 923abb0f93cSkardel int32 last_ttl; /* last TTL specified */ 924abb0f93cSkardel int32 num_mcast; /* No. of IP addresses in multicast socket */ 925abb0f93cSkardel int32 received; /* number of incoming packets */ 926abb0f93cSkardel int32 sent; /* number of outgoing packets */ 927abb0f93cSkardel int32 notsent; /* number of send failures */ 928abb0f93cSkardel int32 uptime; /* number of seconds this interface was active */ 929abb0f93cSkardel u_int32 scopeid; /* Scope used for Multicasting */ 930abb0f93cSkardel u_int32 ifindex; /* interface index - from system */ 931abb0f93cSkardel u_int32 ifnum; /* sequential interface number */ 932abb0f93cSkardel u_int32 peercnt; /* number of peers referencinf this interface - informational only */ 933abb0f93cSkardel u_short family; /* Address family */ 934abb0f93cSkardel u_char ignore_packets; /* Specify whether the packet should be ignored */ 935abb0f93cSkardel u_char action; /* reason the item is listed */ 936abb0f93cSkardel int32 _filler0; /* pad to a 64 bit size boundary */ 937abb0f93cSkardel }; 938abb0f93cSkardel 939abb0f93cSkardel #define IFS_EXISTS 1 /* just exists */ 940abb0f93cSkardel #define IFS_CREATED 2 /* was just created */ 941abb0f93cSkardel #define IFS_DELETED 3 /* was just delete */ 942abb0f93cSkardel 943abb0f93cSkardel /* 944abb0f93cSkardel * Info returned with IP -> hostname lookup 945abb0f93cSkardel */ 946abb0f93cSkardel /* 144 might need to become 32, matching data[] member of req_pkt */ 947abb0f93cSkardel #define NTP_MAXHOSTNAME (32 - sizeof(u_int32) - sizeof(u_short)) 948abb0f93cSkardel struct info_dns_assoc { 949abb0f93cSkardel u_int32 peeraddr; /* peer address (HMS: being careful...) */ 950abb0f93cSkardel associd_t associd; /* association ID */ 951abb0f93cSkardel char hostname[NTP_MAXHOSTNAME]; /* hostname */ 952abb0f93cSkardel }; 953abb0f93cSkardel 954abb0f93cSkardel /* 955abb0f93cSkardel * function declarations 956abb0f93cSkardel */ 957abb0f93cSkardel int get_packet_mode(struct recvbuf *rbufp); /* Return packet mode */ 958abb0f93cSkardel 959abb0f93cSkardel #endif /* NTP_REQUEST_H */ 960