2 * ntp_control.h - definitions related to NTP mode 6 control messages
8 u_char li_vn_mode; /* leap, version, mode */
9 u_char r_m_e_op; /* response, more, error, opcode */
10 u_short sequence; /* sequence number of request */
11 u_short status; /* status word for association */
12 associd_t associd; /* association ID */
13 u_short offset; /* offset of this batch of data */
14 u_short count; /* count of data in this packet */
15 u_char data[(480 + MAX_MAC_LEN)]; /* data + auth */
19 * Length of the control header, in octets
21 #define CTL_HEADER_LEN 12
22 #define CTL_MAX_DATA_LEN 468
28 #define CTL_MAXTRAPS 3 /* maximum number of traps we allow */
29 #define CTL_TRAPTIME (60*60) /* time out traps in 1 hour */
30 #define CTL_MAXAUTHSIZE 64 /* maximum size of an authen'ed req */
33 * Decoding for the r_m_e_op field
35 #define CTL_RESPONSE 0x80
36 #define CTL_ERROR 0x40
38 #define CTL_OP_MASK 0x1f
40 #define CTL_ISRESPONSE(r_m_e_op) (((r_m_e_op) & 0x80) != 0)
41 #define CTL_ISMORE(r_m_e_op) (((r_m_e_op) & 0x20) != 0)
42 #define CTL_ISERROR(r_m_e_op) (((r_m_e_op) & 0x40) != 0)
43 #define CTL_OP(r_m_e_op) ((r_m_e_op) & CTL_OP_MASK)
48 #define CTL_OP_UNSPEC 0
49 #define CTL_OP_READSTAT 1
50 #define CTL_OP_READVAR 2
51 #define CTL_OP_WRITEVAR 3
52 #define CTL_OP_READCLOCK 4
53 #define CTL_OP_WRITECLOCK 5
54 #define CTL_OP_SETTRAP 6
55 #define CTL_OP_ASYNCMSG 7
56 #define CTL_OP_UNSETTRAP 31
59 * {En,De}coding of the system status word
61 #define CTL_SST_TS_UNSPEC 0 /* time source unspecified */
62 #define CTL_SST_TS_ATOM 1 /* time source calibrated atomic */
63 #define CTL_SST_TS_LF 2 /* time source VLF or LF radio */
64 #define CTL_SST_TS_HF 3 /* time source HF radio */
65 #define CTL_SST_TS_UHF 4 /* time source UHF radio */
66 #define CTL_SST_TS_LOCAL 5 /* time source LOCAL */
67 #define CTL_SST_TS_NTP 6 /* time source NTP */
68 #define CTL_SST_TS_UDPTIME 7 /* time source UDP/TIME */
69 #define CTL_SST_TS_WRSTWTCH 8 /* time source is wristwatch */
70 #define CTL_SST_TS_TELEPHONE 9 /* time source is telephone modem */
71 #define CTL_SST_TS_PPS 0x20 /* time source is PPS signal */
73 #define CTL_SYS_MAXEVENTS 15
75 #define CTL_SYS_STATUS(li, source, nevnt, evnt) \
76 (((((unsigned short)(li))<< 14)&0xc000) | \
77 (((source)<<8)&0x3f00) | \
78 (((nevnt)<<4)&0x00f0) | \
81 #define CTL_SYS_LI(status) (((status)>>14) & 0x3)
82 #define CTL_SYS_SOURCE(status) (((status)>>8) & 0x3f)
83 #define CTL_SYS_NEVNT(status) (((status)>>4) & 0xf)
84 #define CTL_SYS_EVENT(status) ((status) & 0xf)
87 * {En,De}coding of the peer status word
89 #define CTL_PST_CONFIG 0x80
90 #define CTL_PST_AUTHENABLE 0x40
91 #define CTL_PST_AUTHENTIC 0x20
92 #define CTL_PST_REACH 0x10
93 #define CTL_PST_UNSPEC 0x08
95 #define CTL_PST_SEL_REJECT 0 /* reject */
96 #define CTL_PST_SEL_SANE 1 /* x falsetick */
97 #define CTL_PST_SEL_CORRECT 2 /* . excess */
98 #define CTL_PST_SEL_SELCAND 3 /* - outlyer */
99 #define CTL_PST_SEL_SYNCCAND 4 /* + candidat */
100 #define CTL_PST_SEL_DISTSYSPEER 5 /* # selected */
101 #define CTL_PST_SEL_SYSPEER 6 /* * sys.peer */
102 #define CTL_PST_SEL_PPS 7 /* o pps.peer */
104 #define CTL_PEER_MAXEVENTS 15
106 #define CTL_PEER_STATUS(status, nevnt, evnt) \
107 ((((status)<<8) & 0xff00) | \
108 (((nevnt)<<4) & 0x00f0) | \
111 #define CTL_PEER_STATVAL(status)(((status)>>8) & 0xff)
112 #define CTL_PEER_NEVNT(status) (((status)>>4) & 0xf)
113 #define CTL_PEER_EVENT(status) ((status) & 0xf)
116 * {En,De}coding of the clock status word
118 #define CTL_CLK_OKAY 0
119 #define CTL_CLK_NOREPLY 1
120 #define CTL_CLK_BADFORMAT 2
121 #define CTL_CLK_FAULT 3
122 #define CTL_CLK_PROPAGATION 4
123 #define CTL_CLK_BADDATE 5
124 #define CTL_CLK_BADTIME 6
126 #define CTL_CLK_STATUS(status, event) \
127 ((((status)<<8) & 0xff00) | \
131 * Error code responses returned when the E bit is set.
133 #define CERR_UNSPEC 0
134 #define CERR_PERMISSION 1
135 #define CERR_BADFMT 2
137 #define CERR_BADASSOC 4
138 #define CERR_UNKNOWNVAR 5
139 #define CERR_BADVALUE 6
140 #define CERR_RESTRICT 7
142 #define CERR_NORESOURCE CERR_PERMISSION /* wish there was a different code */
146 * System variables we understand
150 #define CS_PRECISION 3
151 #define CS_ROOTDELAY 4
152 #define CS_ROOTDISPERSION 5
163 #define CS_PROCESSOR 16
165 #define CS_VERSION 18
167 #define CS_VARLIST 20
173 #define CS_REVTIME 25
174 #define CS_LEAPTAB 26
179 #define CS_MAXCODE CS_REVOKE
181 #define CS_MAXCODE CS_VARLIST
185 * Peer variables we understand
188 #define CP_AUTHENABLE 2
189 #define CP_AUTHENTIC 3
196 #define CP_STRATUM 10
199 #define CP_PRECISION 13
200 #define CP_ROOTDELAY 14
201 #define CP_ROOTDISPERSION 15
203 #define CP_REFTIME 17
208 #define CP_UNREACH 22
213 #define CP_DISPERSION 27
215 #define CP_FILTDELAY 29
216 #define CP_FILTOFFSET 30
218 #define CP_RECEIVED 32
220 #define CP_FILTERROR 34
223 #define CP_VARLIST 37
228 #define CP_INITSEQ 41
229 #define CP_INITKEY 42
230 #define CP_INITTSP 43
233 #define CP_MAXCODE CP_IDENT
235 #define CP_MAXCODE CP_VARLIST
239 * Clock variables we understand
242 #define CC_TIMECODE 2
245 #define CC_BADFORMAT 5
247 #define CC_FUDGETIME1 7
248 #define CC_FUDGETIME2 8
249 #define CC_FUDGEVAL1 9
250 #define CC_FUDGEVAL2 10
253 #define CC_VARLIST 13
255 #define CC_MAXCODE CC_VARLIST
258 * Definition of the structure used internally to hold trap information.
259 * ntp_request.c wants to see this.
262 struct sockaddr_storage tr_addr;/* address of trap recipient */
263 struct interface *tr_localaddr; /* interface to send this through */
264 u_long tr_settime; /* time trap was set */
265 u_long tr_count; /* async messages sent to this guy */
266 u_long tr_origtime; /* time trap was originally set */
267 u_long tr_resets; /* count of resets for this trap */
268 u_short tr_sequence; /* trap sequence id */
269 u_char tr_flags; /* trap flags */
270 u_char tr_version; /* version number of trapper */
272 extern struct ctl_trap ctl_trap[];
277 #define TRAP_INUSE 0x1 /* this trap is active */
278 #define TRAP_NONPRIO 0x2 /* this trap is non-priority */
279 #define TRAP_CONFIGURED 0x4 /* this trap was configured */
282 * Types of things we may deal with
283 * shared between ntpq and library