4 * ntp_control.h - definitions related to NTP mode 6 control messages
10 u_char li_vn_mode
; /* leap, version, mode */
11 u_char r_m_e_op
; /* response, more, error, opcode */
12 u_short sequence
; /* sequence number of request */
13 u_short status
; /* status word for association */
14 associd_t associd
; /* association ID */
15 u_short offset
; /* offset of this batch of data */
16 u_short count
; /* count of data in this packet */
17 u_char data
[(480 + MAX_MAC_LEN
)]; /* data + auth */
21 * Length of the control header, in octets
23 #define CTL_HEADER_LEN 12
24 #define CTL_MAX_DATA_LEN 468
30 #define CTL_MAXTRAPS 3 /* maximum number of traps we allow */
31 #define CTL_TRAPTIME (60*60) /* time out traps in 1 hour */
32 #define CTL_MAXAUTHSIZE 64 /* maximum size of an authen'ed req */
35 * Decoding for the r_m_e_op field
37 #define CTL_RESPONSE 0x80
38 #define CTL_ERROR 0x40
40 #define CTL_OP_MASK 0x1f
42 #define CTL_ISRESPONSE(r_m_e_op) (((r_m_e_op) & 0x80) != 0)
43 #define CTL_ISMORE(r_m_e_op) (((r_m_e_op) & 0x20) != 0)
44 #define CTL_ISERROR(r_m_e_op) (((r_m_e_op) & 0x40) != 0)
45 #define CTL_OP(r_m_e_op) ((r_m_e_op) & CTL_OP_MASK)
50 #define CTL_OP_UNSPEC 0 /* unspeciffied */
51 #define CTL_OP_READSTAT 1 /* read status */
52 #define CTL_OP_READVAR 2 /* read variables */
53 #define CTL_OP_WRITEVAR 3 /* write variables */
54 #define CTL_OP_READCLOCK 4 /* read clock variables */
55 #define CTL_OP_WRITECLOCK 5 /* write clock variables */
56 #define CTL_OP_SETTRAP 6 /* set trap address */
57 #define CTL_OP_ASYNCMSG 7 /* asynchronous message */
58 #define CTL_OP_CONFIGURE 8 /* runtime configuration */
59 #define CTL_OP_SAVECONFIG 9 /* save config to file */
60 #define CTL_OP_UNSETTRAP 31 /* unset trap */
63 * {En,De}coding of the system status word
65 #define CTL_SST_TS_UNSPEC 0 /* unspec */
66 #define CTL_SST_TS_ATOM 1 /* pps */
67 #define CTL_SST_TS_LF 2 /* lf radio */
68 #define CTL_SST_TS_HF 3 /* hf radio */
69 #define CTL_SST_TS_UHF 4 /* uhf radio */
70 #define CTL_SST_TS_LOCAL 5 /* local */
71 #define CTL_SST_TS_NTP 6 /* ntp */
72 #define CTL_SST_TS_UDPTIME 7 /* other */
73 #define CTL_SST_TS_WRSTWTCH 8 /* wristwatch */
74 #define CTL_SST_TS_TELEPHONE 9 /* telephone */
76 #define CTL_SYS_MAXEVENTS 15
78 #define CTL_SYS_STATUS(li, source, nevnt, evnt) \
79 (((((unsigned short)(li))<< 14)&0xc000) | \
80 (((source)<<8)&0x3f00) | \
81 (((nevnt)<<4)&0x00f0) | \
84 #define CTL_SYS_LI(status) (((status)>>14) & 0x3)
85 #define CTL_SYS_SOURCE(status) (((status)>>8) & 0x3f)
86 #define CTL_SYS_NEVNT(status) (((status)>>4) & 0xf)
87 #define CTL_SYS_EVENT(status) ((status) & 0xf)
90 * {En,De}coding of the peer status word
92 #define CTL_PST_CONFIG 0x80
93 #define CTL_PST_AUTHENABLE 0x40
94 #define CTL_PST_AUTHENTIC 0x20
95 #define CTL_PST_REACH 0x10
96 #define CTL_PST_BCAST 0x08
98 #define CTL_PST_SEL_REJECT 0 /* reject */
99 #define CTL_PST_SEL_SANE 1 /* x falsetick */
100 #define CTL_PST_SEL_CORRECT 2 /* . excess */
101 #define CTL_PST_SEL_SELCAND 3 /* - outlyer */
102 #define CTL_PST_SEL_SYNCCAND 4 /* + candidate */
103 #define CTL_PST_SEL_EXCESS 5 /* # backup */
104 #define CTL_PST_SEL_SYSPEER 6 /* * sys.peer */
105 #define CTL_PST_SEL_PPS 7 /* o pps.peer */
107 #define CTL_PEER_MAXEVENTS 15
109 #define CTL_PEER_STATUS(status, nevnt, evnt) \
110 ((((status)<<8) & 0xff00) | \
111 (((nevnt)<<4) & 0x00f0) | \
114 #define CTL_PEER_STATVAL(status)(((status)>>8) & 0xff)
115 #define CTL_PEER_NEVNT(status) (((status)>>4) & 0xf)
116 #define CTL_PEER_EVENT(status) ((status) & 0xf)
119 * {En,De}coding of the clock status word
121 #define CTL_CLK_OKAY 0
122 #define CTL_CLK_NOREPLY 1
123 #define CTL_CLK_BADFORMAT 2
124 #define CTL_CLK_FAULT 3
125 #define CTL_CLK_PROPAGATION 4
126 #define CTL_CLK_BADDATE 5
127 #define CTL_CLK_BADTIME 6
129 #define CTL_CLK_STATUS(status, event) \
130 ((((status)<<8) & 0xff00) | \
134 * Error code responses returned when the E bit is set.
136 #define CERR_UNSPEC 0
137 #define CERR_PERMISSION 1
138 #define CERR_BADFMT 2
140 #define CERR_BADASSOC 4
141 #define CERR_UNKNOWNVAR 5
142 #define CERR_BADVALUE 6
143 #define CERR_RESTRICT 7
145 #define CERR_NORESOURCE CERR_PERMISSION /* wish there was a different code */
149 * System variables we understand
153 #define CS_PRECISION 3
154 #define CS_ROOTDELAY 4
155 #define CS_ROOTDISPERSION 5
165 #define CS_PROCESSOR 15
167 #define CS_VERSION 17
169 #define CS_VARLIST 19
171 #define CS_LEAPTAB 21
172 #define CS_LEAPEND 22
179 #define CS_SIGNATURE 28
180 #define CS_REVTIME 29
183 #define CS_MAXCODE CS_DIGEST
185 #define CS_MAXCODE CS_RATE
189 * Peer variables we understand
192 #define CP_AUTHENABLE 2
193 #define CP_AUTHENTIC 3
200 #define CP_STRATUM 10
203 #define CP_PRECISION 13
204 #define CP_ROOTDELAY 14
205 #define CP_ROOTDISPERSION 15
207 #define CP_REFTIME 17
212 #define CP_UNREACH 22
217 #define CP_DISPERSION 27
219 #define CP_FILTDELAY 29
220 #define CP_FILTOFFSET 30
222 #define CP_RECEIVED 32
224 #define CP_FILTERROR 34
227 #define CP_VARLIST 37
236 #define CP_INITSEQ 45
237 #define CP_INITKEY 46
238 #define CP_INITTSP 47
239 #define CP_SIGNATURE 48
240 #define CP_MAXCODE CP_SIGNATURE
242 #define CP_MAXCODE CP_BIAS
246 * Clock variables we understand
249 #define CC_TIMECODE 2
252 #define CC_BADFORMAT 5
254 #define CC_FUDGETIME1 7
255 #define CC_FUDGETIME2 8
256 #define CC_FUDGEVAL1 9
257 #define CC_FUDGEVAL2 10
260 #define CC_VARLIST 13
261 #define CC_MAXCODE CC_VARLIST
264 * Definition of the structure used internally to hold trap information.
265 * ntp_request.c wants to see this.
268 sockaddr_u tr_addr
; /* address of trap recipient */
269 struct interface
*tr_localaddr
; /* interface to send this through */
270 u_long tr_settime
; /* time trap was set */
271 u_long tr_count
; /* async messages sent to this guy */
272 u_long tr_origtime
; /* time trap was originally set */
273 u_long tr_resets
; /* count of resets for this trap */
274 u_short tr_sequence
; /* trap sequence id */
275 u_char tr_flags
; /* trap flags */
276 u_char tr_version
; /* version number of trapper */
278 extern struct ctl_trap ctl_trap
[];
283 #define TRAP_INUSE 0x1 /* this trap is active */
284 #define TRAP_NONPRIO 0x2 /* this trap is non-priority */
285 #define TRAP_CONFIGURED 0x4 /* this trap was configured */
288 * Types of things we may deal with
289 * shared between ntpq and library