2 * $OpenBSD: src/usr.sbin/ntpd/ntp.h,v 1.11 2004/12/13 12:22:52 dtucker Exp $
3 * $DragonFly: src/usr.sbin/dntpd/ntp.h,v 1.1 2005/04/24 02:36:50 dillon Exp $
7 * Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
8 * Copyright (c) 2004 Alexander Guy <alexander.guy@andern.org>
10 * Permission to use, copy, modify, and distribute this software for any
11 * purpose with or without fee is hereby granted, provided that the above
12 * copyright notice and this permission notice appear in all copies.
14 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 /* Style borrowed from NTP ref/tcpdump and updated for SNTPv4 (RFC2030). */
32 * 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
33 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
35 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 * 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
41 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 * | Integer Part | Fraction Part |
43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58 * 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
59 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
60 * |LI | VN | Mode| Stratum | Poll | Precision |
61 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62 * | Synchronizing Distance |
63 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64 * | Synchronizing Dispersion |
65 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66 * | Reference Clock Identifier |
67 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
69 * | Reference Timestamp (64 bits) |
71 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73 * | Originate Timestamp (64 bits) |
75 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77 * | Receive Timestamp (64 bits) |
79 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
81 * | Transmit Timestamp (64 bits) |
83 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
84 * | Key Identifier (optional) (32) |
85 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
88 * | Message Digest (optional) (128) |
91 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95 #define NTP_DIGESTSIZE 16
96 #define NTP_MSGSIZE_NOAUTH 48
97 #define NTP_MSGSIZE (NTP_MSGSIZE_NOAUTH + 4 + NTP_DIGESTSIZE)
100 u_int8_t status; /* status of local clock and leap info */
101 u_int8_t stratum; /* Stratum level */
102 u_int8_t ppoll; /* poll value */
104 struct s_fixedpt rootdelay;
105 struct s_fixedpt dispersion;
107 struct l_fixedpt reftime;
108 struct l_fixedpt orgtime;
109 struct l_fixedpt rectime;
110 struct l_fixedpt xmttime;
112 u_int8_t digest[NTP_DIGESTSIZE];
122 * Leap Second Codes (high order two bits)
124 #define LI_NOWARNING (0 << 6) /* no warning */
125 #define LI_PLUSSEC (1 << 6) /* add a second (61 seconds) */
126 #define LI_MINUSSEC (2 << 6) /* minus a second (59 seconds) */
127 #define LI_ALARM (3 << 6) /* alarm condition */
132 #define MODEMASK (7 << 0)
133 #define VERSIONMASK (7 << 3)
134 #define LIMASK (3 << 6)
139 #define MODE_RES0 0 /* reserved */
140 #define MODE_SYM_ACT 1 /* symmetric active */
141 #define MODE_SYM_PAS 2 /* symmetric passive */
142 #define MODE_CLIENT 3 /* client */
143 #define MODE_SERVER 4 /* server */
144 #define MODE_BROADCAST 5 /* broadcast */
145 #define MODE_RES1 6 /* reserved for NTP control message */
146 #define MODE_RES2 7 /* reserved for private use */
148 #define JAN_1970 2208988800UL /* 1970 - 1900 in seconds */
150 #define NTP_VERSION 4
151 #define NTP_MAXSTRATUM 15