]> git.ipfire.org Git - thirdparty/chrony.git/blame - candm.h
ntp: fix log message for replaced source
[thirdparty/chrony.git] / candm.h
CommitLineData
88840341 1/*
88840341
RC
2 chronyd/chronyc - Programs for keeping computer clocks accurate.
3
4 **********************************************************************
6672f045 5 * Copyright (C) Richard P. Curnow 1997-2003
88840341
RC
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
8e23110a 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
88840341
RC
19 *
20 **********************************************************************
21
22 =======================================================================
23
24 Definitions for the network protocol used for command and monitoring
25 of the timeserver.
26
27 */
28
29#ifndef GOT_CANDM_H
30#define GOT_CANDM_H
31
32#include "sysincl.h"
8265ff28 33#include "addressing.h"
88840341
RC
34
35/* This is the default port to use for CANDM, if no alternative is
36 defined */
37#define DEFAULT_CANDM_PORT 323
38
39/* Request codes */
40#define REQ_NULL 0
41#define REQ_ONLINE 1
42#define REQ_OFFLINE 2
43#define REQ_BURST 3
44#define REQ_MODIFY_MINPOLL 4
45#define REQ_MODIFY_MAXPOLL 5
46#define REQ_DUMP 6
47#define REQ_MODIFY_MAXDELAY 7
48#define REQ_MODIFY_MAXDELAYRATIO 8
49#define REQ_MODIFY_MAXUPDATESKEW 9
50#define REQ_LOGON 10
51#define REQ_SETTIME 11
52#define REQ_LOCAL 12
53#define REQ_MANUAL 13
54#define REQ_N_SOURCES 14
55#define REQ_SOURCE_DATA 15
56#define REQ_REKEY 16
57#define REQ_ALLOW 17
58#define REQ_ALLOWALL 18
59#define REQ_DENY 19
60#define REQ_DENYALL 20
61#define REQ_CMDALLOW 21
62#define REQ_CMDALLOWALL 22
63#define REQ_CMDDENY 23
64#define REQ_CMDDENYALL 24
65#define REQ_ACCHECK 25
66#define REQ_CMDACCHECK 26
67#define REQ_ADD_SERVER 27
68#define REQ_ADD_PEER 28
69#define REQ_DEL_SOURCE 29
70#define REQ_WRITERTC 30
71#define REQ_DFREQ 31
72#define REQ_DOFFSET 32
73#define REQ_TRACKING 33
74#define REQ_SOURCESTATS 34
75#define REQ_RTCREPORT 35
76#define REQ_TRIMRTC 36
77#define REQ_CYCLELOGS 37
78#define REQ_SUBNETS_ACCESSED 38
79#define REQ_CLIENT_ACCESSES 39
80#define REQ_CLIENT_ACCESSES_BY_INDEX 40
81#define REQ_MANUAL_LIST 41
82#define REQ_MANUAL_DELETE 42
83#define REQ_MAKESTEP 43
84#define REQ_ACTIVITY 44
78300d01 85#define REQ_MODIFY_MINSTRATUM 45
bed5b72c 86#define REQ_MODIFY_POLLTARGET 46
6ed5a650 87#define REQ_MODIFY_MAXDELAYDEVRATIO 47
6e96b4ba 88#define REQ_RESELECT 48
8d3d45ea 89#define REQ_RESELECTDISTANCE 49
513e6590 90#define REQ_MODIFY_MAKESTEP 50
fb9c2c7d 91#define REQ_SMOOTHING 51
273da62a 92#define REQ_SMOOTHTIME 52
3eb43f46 93#define REQ_REFRESH 53
9b019a03 94#define REQ_SERVER_STATS 54
705e32ac 95#define REQ_CLIENT_ACCESSES_BY_INDEX2 55
53b15bd5 96#define REQ_LOCAL2 56
535ca64b 97#define REQ_NTP_DATA 57
65fd30a5
ML
98#define REQ_ADD_SERVER2 58
99#define REQ_ADD_PEER2 59
5ab645e3
ML
100#define REQ_ADD_SERVER3 60
101#define REQ_ADD_PEER3 61
499f513d 102#define REQ_SHUTDOWN 62
34db671b 103#define REQ_ONOFFLINE 63
00fff161 104#define REQ_ADD_SOURCE 64
93f63589 105#define REQ_NTP_SOURCE_NAME 65
e7a25426
ML
106#define REQ_RESET 66
107#define N_REQUEST_TYPES 67
88840341 108
d0dfa1de 109/* Structure used to exchange timespecs independent of time_t size */
a7892a1a
ML
110typedef struct {
111 uint32_t tv_sec_high;
112 uint32_t tv_sec_low;
84f8463f 113 uint32_t tv_nsec;
d0dfa1de 114} Timespec;
a7892a1a
ML
115
116/* This is used in tv_sec_high for 32-bit timestamps */
117#define TV_NOHIGHSEC 0x7fffffff
118
b4947011
ML
119/* 32-bit floating-point format consisting of 7-bit signed exponent
120 and 25-bit signed coefficient without hidden bit.
121 The result is calculated as: 2^(exp - 25) * coef */
122typedef struct {
123 int32_t f;
124} Float;
125
88840341
RC
126/* The EOR (end of record) fields are used by the offsetof operator in
127 pktlength.c, to get the number of bytes that ought to be
128 transmitted for each packet type. */
129
31669f34
ML
130typedef struct {
131 int32_t EOR;
132} REQ_Null;
133
88840341 134typedef struct {
8265ff28
ML
135 IPAddr mask;
136 IPAddr address;
88840341
RC
137 int32_t EOR;
138} REQ_Online;
139
140typedef struct {
8265ff28
ML
141 IPAddr mask;
142 IPAddr address;
88840341
RC
143 int32_t EOR;
144} REQ_Offline;
145
146typedef struct {
8265ff28
ML
147 IPAddr mask;
148 IPAddr address;
88840341
RC
149 int32_t n_good_samples;
150 int32_t n_total_samples;
151 int32_t EOR;
152} REQ_Burst;
153
154typedef struct {
8265ff28 155 IPAddr address;
88840341
RC
156 int32_t new_minpoll;
157 int32_t EOR;
158} REQ_Modify_Minpoll;
159
160typedef struct {
8265ff28 161 IPAddr address;
88840341
RC
162 int32_t new_maxpoll;
163 int32_t EOR;
164} REQ_Modify_Maxpoll;
165
166typedef struct {
167 int32_t pad;
168 int32_t EOR;
169} REQ_Dump;
170
171typedef struct {
8265ff28 172 IPAddr address;
b4947011 173 Float new_max_delay;
88840341
RC
174 int32_t EOR;
175} REQ_Modify_Maxdelay;
176
177typedef struct {
8265ff28 178 IPAddr address;
b4947011 179 Float new_max_delay_ratio;
88840341
RC
180 int32_t EOR;
181} REQ_Modify_Maxdelayratio;
182
6ed5a650
ML
183typedef struct {
184 IPAddr address;
185 Float new_max_delay_dev_ratio;
186 int32_t EOR;
187} REQ_Modify_Maxdelaydevratio;
188
78300d01
ML
189typedef struct {
190 IPAddr address;
191 int32_t new_min_stratum;
192 int32_t EOR;
193} REQ_Modify_Minstratum;
194
bed5b72c
ML
195typedef struct {
196 IPAddr address;
197 int32_t new_poll_target;
198 int32_t EOR;
199} REQ_Modify_Polltarget;
200
88840341 201typedef struct {
b4947011 202 Float new_max_update_skew;
88840341
RC
203 int32_t EOR;
204} REQ_Modify_Maxupdateskew;
205
513e6590
ML
206typedef struct {
207 int32_t limit;
208 Float threshold;
209 int32_t EOR;
210} REQ_Modify_Makestep;
211
88840341 212typedef struct {
d0dfa1de 213 Timespec ts;
88840341
RC
214 int32_t EOR;
215} REQ_Logon;
216
217typedef struct {
d0dfa1de 218 Timespec ts;
88840341
RC
219 int32_t EOR;
220} REQ_Settime;
221
222typedef struct {
223 int32_t on_off;
224 int32_t stratum;
53b15bd5
ML
225 Float distance;
226 int32_t orphan;
88840341
RC
227 int32_t EOR;
228} REQ_Local;
229
230typedef struct {
231 int32_t option;
232 int32_t EOR;
233} REQ_Manual;
234
88840341
RC
235typedef struct {
236 int32_t index;
237 int32_t EOR;
238} REQ_Source_Data;
239
88840341 240typedef struct {
8265ff28 241 IPAddr ip;
88840341
RC
242 int32_t subnet_bits;
243 int32_t EOR;
244} REQ_Allow_Deny;
245
246typedef struct {
8265ff28 247 IPAddr ip;
88840341
RC
248 int32_t EOR;
249} REQ_Ac_Check;
250
00fff161
ML
251/* Source types in NTP source requests */
252#define REQ_ADDSRC_SERVER 1
253#define REQ_ADDSRC_PEER 2
93008544 254#define REQ_ADDSRC_POOL 3
00fff161 255
41580fe5
ML
256/* Flags used in NTP source requests */
257#define REQ_ADDSRC_ONLINE 0x1
258#define REQ_ADDSRC_AUTOOFFLINE 0x2
93b5b08b 259#define REQ_ADDSRC_IBURST 0x4
5b8835f4
ML
260#define REQ_ADDSRC_PREFER 0x8
261#define REQ_ADDSRC_NOSELECT 0x10
936f5cb0 262#define REQ_ADDSRC_TRUST 0x20
e98f76e0 263#define REQ_ADDSRC_REQUIRE 0x40
90b25f5b 264#define REQ_ADDSRC_INTERLEAVED 0x80
d0eb9427 265#define REQ_ADDSRC_BURST 0x100
44aac84f 266#define REQ_ADDSRC_NTS 0x200
41580fe5 267
88840341 268typedef struct {
00fff161 269 uint32_t type;
02914ac6 270 int8_t name[256];
88840341
RC
271 uint32_t port;
272 int32_t minpoll;
273 int32_t maxpoll;
274 int32_t presend_minpoll;
65fd30a5
ML
275 uint32_t min_stratum;
276 uint32_t poll_target;
277 uint32_t version;
278 uint32_t max_sources;
279 int32_t min_samples;
280 int32_t max_samples;
88840341 281 uint32_t authkey;
44aac84f 282 uint32_t nts_port;
b4947011
ML
283 Float max_delay;
284 Float max_delay_ratio;
65fd30a5 285 Float max_delay_dev_ratio;
5ab645e3
ML
286 Float min_delay;
287 Float asymmetry;
65fd30a5 288 Float offset;
41580fe5 289 uint32_t flags;
9931a916
ML
290 int32_t filter_length;
291 uint32_t reserved[3];
88840341
RC
292 int32_t EOR;
293} REQ_NTP_Source;
294
295typedef struct {
8265ff28 296 IPAddr ip_addr;
88840341
RC
297 int32_t EOR;
298} REQ_Del_Source;
299
88840341 300typedef struct {
b4947011 301 Float dfreq;
88840341
RC
302 int32_t EOR;
303} REQ_Dfreq;
304
305typedef struct {
306 int32_t sec;
307 int32_t usec;
308 int32_t EOR;
309} REQ_Doffset;
310
88840341
RC
311typedef struct {
312 uint32_t index;
313 int32_t EOR;
314} REQ_Sourcestats;
315
88840341
RC
316/* This is based on the response size rather than the
317 request size */
8265ff28 318#define MAX_CLIENT_ACCESSES 8
88840341 319
88840341
RC
320typedef struct {
321 uint32_t first_index;
657929f8 322 uint32_t n_clients;
88840341
RC
323 int32_t EOR;
324} REQ_ClientAccessesByIndex;
325
88840341
RC
326typedef struct {
327 int32_t index;
328 int32_t EOR;
329} REQ_ManualDelete;
330
8d3d45ea
ML
331typedef struct {
332 Float distance;
333 int32_t EOR;
334} REQ_ReselectDistance;
335
273da62a
ML
336#define REQ_SMOOTHTIME_RESET 0
337#define REQ_SMOOTHTIME_ACTIVATE 1
338
339typedef struct {
340 int32_t option;
341 int32_t EOR;
342} REQ_SmoothTime;
343
535ca64b
ML
344typedef struct {
345 IPAddr ip_addr;
346 int32_t EOR;
347} REQ_NTPData;
348
93f63589
ML
349typedef struct {
350 IPAddr ip_addr;
351 int32_t EOR;
352} REQ_NTPSourceName;
353
88840341
RC
354/* ================================================== */
355
356#define PKT_TYPE_CMD_REQUEST 1
357#define PKT_TYPE_CMD_REPLY 2
358
359/* This version number needs to be incremented whenever the packet
360 size and/or the format of any of the existing messages is changed.
361 Other changes, e.g. new command types, should be handled cleanly by
362 client.c and cmdmon.c anyway, so the version can stay the same.
363
364 Version 1 : original version with fixed size packets
365
366 Version 2 : both command and reply packet sizes made capable of
367 being variable length.
368
369 Version 3 : NTP_Source message lengthened (auto_offline)
370
1570f97e 371 Version 4 : IPv6 addressing added, 64-bit time values, sourcestats
b4947011 372 and tracking reports extended, added flags to NTP source request,
5b1a8705 373 trimmed source report, replaced fixed-point format with floating-point
20a43409
ML
374 and used also instead of integer microseconds, new commands: modify stratum,
375 modify polltarget, modify maxdelaydevratio, reselect, reselectdistance
8265ff28 376
19b3c5be 377 Version 5 : auth data moved to the end of the packet to allow hashes with
ad58baa1
ML
378 different sizes, extended sources, tracking and activity reports, dropped
379 subnets accessed and client accesses
dba458d5
ML
380
381 Version 6 : added padding to requests to prevent amplification attack,
513e6590 382 changed maximum number of samples in manual list to 16, new commands: modify
e3191e37 383 makestep, smoothing, smoothtime
e5784c1c 384
e3191e37
ML
385 Support for authentication was removed later in version 6 of the protocol
386 and commands that required authentication are allowed only locally over Unix
387 domain socket.
388
389 Version 6 (no authentication) : changed format of client accesses by index
58c29158
ML
390 (using new request/reply types) and manual timestamp, added new fields and
391 flags to NTP source request and report, made length of manual list constant,
392 added new commands: ntpdata, refresh, serverstats, shutdown
88840341
RC
393 */
394
dba458d5
ML
395#define PROTO_VERSION_NUMBER 6
396
397/* The oldest protocol versions that are compatible enough with the current
398 version to report a version mismatch for the server and the client */
399#define PROTO_VERSION_MISMATCH_COMPAT_SERVER 5
400#define PROTO_VERSION_MISMATCH_COMPAT_CLIENT 4
88840341 401
dba458d5
ML
402/* The first protocol version using padding in requests */
403#define PROTO_VERSION_PADDING 6
404
405/* The maximum length of padding in request packet, currently
657929f8 406 defined by MANUAL_LIST */
dba458d5 407#define MAX_PADDING_LENGTH 396
032838b1 408
88840341
RC
409/* ================================================== */
410
411typedef struct {
412 uint8_t version; /* Protocol version */
413 uint8_t pkt_type; /* What sort of packet this is */
414 uint8_t res1;
415 uint8_t res2;
416 uint16_t command; /* Which command is being issued */
417 uint16_t attempt; /* How many resends the client has done
418 (count up from zero for same sequence
419 number) */
420 uint32_t sequence; /* Client's sequence number */
e5784c1c
ML
421 uint32_t pad1;
422 uint32_t pad2;
88840341
RC
423
424 union {
31669f34 425 REQ_Null null;
88840341
RC
426 REQ_Online online;
427 REQ_Offline offline;
428 REQ_Burst burst;
429 REQ_Modify_Minpoll modify_minpoll;
430 REQ_Modify_Maxpoll modify_maxpoll;
431 REQ_Dump dump;
432 REQ_Modify_Maxdelay modify_maxdelay;
433 REQ_Modify_Maxdelayratio modify_maxdelayratio;
6ed5a650 434 REQ_Modify_Maxdelaydevratio modify_maxdelaydevratio;
78300d01 435 REQ_Modify_Minstratum modify_minstratum;
bed5b72c 436 REQ_Modify_Polltarget modify_polltarget;
88840341 437 REQ_Modify_Maxupdateskew modify_maxupdateskew;
513e6590 438 REQ_Modify_Makestep modify_makestep;
88840341
RC
439 REQ_Logon logon;
440 REQ_Settime settime;
441 REQ_Local local;
442 REQ_Manual manual;
88840341 443 REQ_Source_Data source_data;
88840341
RC
444 REQ_Allow_Deny allow_deny;
445 REQ_Ac_Check ac_check;
446 REQ_NTP_Source ntp_source;
447 REQ_Del_Source del_source;
88840341
RC
448 REQ_Dfreq dfreq;
449 REQ_Doffset doffset;
88840341 450 REQ_Sourcestats sourcestats;
88840341 451 REQ_ClientAccessesByIndex client_accesses_by_index;
88840341 452 REQ_ManualDelete manual_delete;
8d3d45ea 453 REQ_ReselectDistance reselect_distance;
273da62a 454 REQ_SmoothTime smoothtime;
535ca64b 455 REQ_NTPData ntp_data;
93f63589 456 REQ_NTPData ntp_source_name;
88840341
RC
457 } data; /* Command specific parameters */
458
e5784c1c
ML
459 /* Padding used to prevent traffic amplification. It only defines the
460 maximum size of the packet, there is no hole after the data field. */
dba458d5
ML
461 uint8_t padding[MAX_PADDING_LENGTH];
462
88840341
RC
463} CMD_Request;
464
465/* ================================================== */
466/* Authority codes for command types */
467
468#define PERMIT_OPEN 0
469#define PERMIT_LOCAL 1
470#define PERMIT_AUTH 2
471
88840341
RC
472/* ================================================== */
473
474/* Reply codes */
475#define RPY_NULL 1
476#define RPY_N_SOURCES 2
477#define RPY_SOURCE_DATA 3
478#define RPY_MANUAL_TIMESTAMP 4
479#define RPY_TRACKING 5
480#define RPY_SOURCESTATS 6
481#define RPY_RTC 7
482#define RPY_SUBNETS_ACCESSED 8
483#define RPY_CLIENT_ACCESSES 9
484#define RPY_CLIENT_ACCESSES_BY_INDEX 10
485#define RPY_MANUAL_LIST 11
486#define RPY_ACTIVITY 12
fb9c2c7d 487#define RPY_SMOOTHING 13
9b019a03 488#define RPY_SERVER_STATS 14
705e32ac 489#define RPY_CLIENT_ACCESSES_BY_INDEX2 15
535ca64b 490#define RPY_NTP_DATA 16
01a29c7a 491#define RPY_MANUAL_TIMESTAMP2 17
eda4b111 492#define RPY_MANUAL_LIST2 18
93f63589
ML
493#define RPY_NTP_SOURCE_NAME 19
494#define N_REPLY_TYPES 20
88840341
RC
495
496/* Status codes */
497#define STT_SUCCESS 0
498#define STT_FAILED 1
499#define STT_UNAUTH 2
500#define STT_INVALID 3
501#define STT_NOSUCHSOURCE 4
502#define STT_INVALIDTS 5
503#define STT_NOTENABLED 6
504#define STT_BADSUBNET 7
505#define STT_ACCESSALLOWED 8
506#define STT_ACCESSDENIED 9
e15ce69d 507/* Deprecated */
88840341
RC
508#define STT_NOHOSTACCESS 10
509#define STT_SOURCEALREADYKNOWN 11
510#define STT_TOOMANYSOURCES 12
511#define STT_NORTC 13
512#define STT_BADRTCFILE 14
513#define STT_INACTIVE 15
514#define STT_BADSAMPLE 16
8265ff28 515#define STT_INVALIDAF 17
032838b1
ML
516#define STT_BADPKTVERSION 18
517#define STT_BADPKTLENGTH 19
02914ac6 518#define STT_INVALIDNAME 21
88840341
RC
519
520typedef struct {
521 int32_t EOR;
522} RPY_Null;
523
524typedef struct {
525 uint32_t n_sources;
526 int32_t EOR;
527} RPY_N_Sources;
528
529#define RPY_SD_MD_CLIENT 0
530#define RPY_SD_MD_PEER 1
531#define RPY_SD_MD_REF 2
532
533#define RPY_SD_ST_SYNC 0
534#define RPY_SD_ST_UNREACH 1
535#define RPY_SD_ST_FALSETICKER 2
536#define RPY_SD_ST_JITTERY 3
a931b2ee 537#define RPY_SD_ST_CANDIDATE 4
8d80ce44 538#define RPY_SD_ST_OUTLIER 5
88840341 539
19b3c5be
ML
540#define RPY_SD_FLAG_NOSELECT 0x1
541#define RPY_SD_FLAG_PREFER 0x2
936f5cb0 542#define RPY_SD_FLAG_TRUST 0x4
e98f76e0 543#define RPY_SD_FLAG_REQUIRE 0x8
19b3c5be 544
88840341 545typedef struct {
8265ff28 546 IPAddr ip_addr;
79ac20c1 547 int16_t poll;
88840341
RC
548 uint16_t stratum;
549 uint16_t state;
550 uint16_t mode;
19b3c5be
ML
551 uint16_t flags;
552 uint16_t reachability;
88840341 553 uint32_t since_sample;
2dd9f337
ML
554 Float orig_latest_meas;
555 Float latest_meas;
556 Float latest_meas_err;
88840341
RC
557 int32_t EOR;
558} RPY_Source_Data;
559
560typedef struct {
561 uint32_t ref_id;
1570f97e 562 IPAddr ip_addr;
824e86a8
ML
563 uint16_t stratum;
564 uint16_t leap_status;
d0dfa1de 565 Timespec ref_time;
2dd9f337 566 Float current_correction;
19b3c5be
ML
567 Float last_offset;
568 Float rms_offset;
b4947011
ML
569 Float freq_ppm;
570 Float resid_freq_ppm;
571 Float skew_ppm;
572 Float root_delay;
573 Float root_dispersion;
19b3c5be 574 Float last_update_interval;
88840341
RC
575 int32_t EOR;
576} RPY_Tracking;
577
578typedef struct {
1570f97e 579 uint32_t ref_id;
8265ff28 580 IPAddr ip_addr;
88840341
RC
581 uint32_t n_samples;
582 uint32_t n_runs;
583 uint32_t span_seconds;
2dd9f337 584 Float sd;
b4947011
ML
585 Float resid_freq_ppm;
586 Float skew_ppm;
b32432c2
ML
587 Float est_offset;
588 Float est_offset_err;
88840341
RC
589 int32_t EOR;
590} RPY_Sourcestats;
591
592typedef struct {
d0dfa1de 593 Timespec ref_time;
88840341
RC
594 uint16_t n_samples;
595 uint16_t n_runs;
596 uint32_t span_seconds;
b4947011
ML
597 Float rtc_seconds_fast;
598 Float rtc_gain_rate_ppm;
88840341
RC
599 int32_t EOR;
600} RPY_Rtc;
601
602typedef struct {
01a29c7a 603 Float offset;
b4947011
ML
604 Float dfreq_ppm;
605 Float new_afreq_ppm;
88840341
RC
606 int32_t EOR;
607} RPY_ManualTimestamp;
608
88840341 609typedef struct {
8265ff28 610 IPAddr ip;
657929f8
ML
611 uint32_t ntp_hits;
612 uint32_t cmd_hits;
861ac013
ML
613 uint32_t ntp_drops;
614 uint32_t cmd_drops;
657929f8
ML
615 int8_t ntp_interval;
616 int8_t cmd_interval;
617 int8_t ntp_timeout_interval;
618 int8_t pad;
88840341
RC
619 uint32_t last_ntp_hit_ago;
620 uint32_t last_cmd_hit_ago;
621} RPY_ClientAccesses_Client;
622
88840341
RC
623typedef struct {
624 uint32_t n_indices; /* how many indices there are in the server's table */
625 uint32_t next_index; /* the index 1 beyond those processed on this call */
626 uint32_t n_clients; /* the number of valid entries in the following array */
627 RPY_ClientAccesses_Client clients[MAX_CLIENT_ACCESSES];
dba458d5 628 int32_t EOR;
88840341
RC
629} RPY_ClientAccessesByIndex;
630
9b019a03
ML
631typedef struct {
632 uint32_t ntp_hits;
633 uint32_t cmd_hits;
634 uint32_t ntp_drops;
635 uint32_t cmd_drops;
636 uint32_t log_drops;
637 int32_t EOR;
638} RPY_ServerStats;
639
3e234309 640#define MAX_MANUAL_LIST_SAMPLES 16
88840341
RC
641
642typedef struct {
d0dfa1de 643 Timespec when;
b4947011
ML
644 Float slewed_offset;
645 Float orig_offset;
646 Float residual;
88840341
RC
647} RPY_ManualListSample;
648
649typedef struct {
650 uint32_t n_samples;
651 RPY_ManualListSample samples[MAX_MANUAL_LIST_SAMPLES];
dba458d5 652 int32_t EOR;
88840341
RC
653} RPY_ManualList;
654
655typedef struct {
656 int32_t online;
657 int32_t offline;
658 int32_t burst_online;
659 int32_t burst_offline;
19b3c5be 660 int32_t unresolved;
88840341
RC
661 int32_t EOR;
662} RPY_Activity;
663
fb9c2c7d
ML
664#define RPY_SMT_FLAG_ACTIVE 0x1
665#define RPY_SMT_FLAG_LEAPONLY 0x2
666
667typedef struct {
668 uint32_t flags;
669 Float offset;
670 Float freq_ppm;
671 Float wander_ppm;
672 Float last_update_ago;
673 Float remaining_time;
674 int32_t EOR;
675} RPY_Smoothing;
676
535ca64b
ML
677#define RPY_NTP_FLAGS_TESTS 0x3ff
678#define RPY_NTP_FLAG_INTERLEAVED 0x4000
679#define RPY_NTP_FLAG_AUTHENTICATED 0x8000
680
681typedef struct {
682 IPAddr remote_addr;
683 IPAddr local_addr;
684 uint16_t remote_port;
685 uint8_t leap;
686 uint8_t version;
687 uint8_t mode;
688 uint8_t stratum;
689 int8_t poll;
690 int8_t precision;
691 Float root_delay;
692 Float root_dispersion;
693 uint32_t ref_id;
694 Timespec ref_time;
695 Float offset;
696 Float peer_delay;
697 Float peer_dispersion;
698 Float response_time;
699 Float jitter_asymmetry;
700 uint16_t flags;
701 uint8_t tx_tss_char;
702 uint8_t rx_tss_char;
703 uint32_t total_tx_count;
704 uint32_t total_rx_count;
705 uint32_t total_valid_count;
fac1093e 706 uint32_t reserved[4];
535ca64b
ML
707 int32_t EOR;
708} RPY_NTPData;
709
93f63589
ML
710typedef struct {
711 int8_t name[256];
712 int32_t EOR;
713} RPY_NTPSourceName;
714
88840341
RC
715typedef struct {
716 uint8_t version;
717 uint8_t pkt_type;
718 uint8_t res1;
719 uint8_t res2;
720 uint16_t command; /* Which command is being replied to */
721 uint16_t reply; /* Which format of reply this is */
722 uint16_t status; /* Status of command processing */
3f507b78
ML
723 uint16_t pad1; /* Padding for compatibility and 4 byte alignment */
724 uint16_t pad2;
725 uint16_t pad3;
88840341 726 uint32_t sequence; /* Echo of client's sequence number */
e5784c1c
ML
727 uint32_t pad4;
728 uint32_t pad5;
729
88840341
RC
730 union {
731 RPY_Null null;
732 RPY_N_Sources n_sources;
733 RPY_Source_Data source_data;
734 RPY_ManualTimestamp manual_timestamp;
735 RPY_Tracking tracking;
736 RPY_Sourcestats sourcestats;
737 RPY_Rtc rtc;
88840341 738 RPY_ClientAccessesByIndex client_accesses_by_index;
9b019a03 739 RPY_ServerStats server_stats;
88840341
RC
740 RPY_ManualList manual_list;
741 RPY_Activity activity;
fb9c2c7d 742 RPY_Smoothing smoothing;
535ca64b 743 RPY_NTPData ntp_data;
93f63589 744 RPY_NTPSourceName ntp_source_name;
88840341
RC
745 } data; /* Reply specific parameters */
746
747} CMD_Reply;
748
749/* ================================================== */
750
751#endif /* GOT_CANDM_H */