Add resident.conf(5) and varsym.conf(5) manual pages.
[dragonfly/vkernel-mp.git] / contrib / ntpd / ntp.h
blob47c92617a53d25353bdda05d29d60a0bd34a00fd
1 /* $OpenBSD: src/usr.sbin/ntpd/ntp.h,v 1.11 2004/12/13 12:22:52 dtucker Exp $ */
3 /*
4 * Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
5 * Copyright (c) 2004 Alexander Guy <alexander.guy@andern.org>
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #ifndef _NTP_H_
21 #define _NTP_H_
23 /* Style borrowed from NTP ref/tcpdump and updated for SNTPv4 (RFC2030). */
26 * RFC Section 3
28 * 0 1 2 3
29 * 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
30 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31 * | Integer Part |
32 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
33 * | Fraction Part |
34 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 * 0 1 2 3
37 * 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
38 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 * | Integer Part | Fraction Part |
40 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 struct l_fixedpt {
43 u_int32_t int_partl;
44 u_int32_t fractionl;
47 struct s_fixedpt {
48 u_int16_t int_parts;
49 u_int16_t fractions;
52 /* RFC Section 4
54 * 0 1 2 3
55 * 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
56 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57 * |LI | VN | Mode| Stratum | Poll | Precision |
58 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
59 * | Synchronizing Distance |
60 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61 * | Synchronizing Dispersion |
62 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
63 * | Reference Clock Identifier |
64 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
65 * | |
66 * | Reference Timestamp (64 bits) |
67 * | |
68 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
69 * | |
70 * | Originate Timestamp (64 bits) |
71 * | |
72 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73 * | |
74 * | Receive Timestamp (64 bits) |
75 * | |
76 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77 * | |
78 * | Transmit Timestamp (64 bits) |
79 * | |
80 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
81 * | Key Identifier (optional) (32) |
82 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
83 * | |
84 * | |
85 * | Message Digest (optional) (128) |
86 * | |
87 * | |
88 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
92 #define NTP_DIGESTSIZE 16
93 #define NTP_MSGSIZE_NOAUTH 48
94 #define NTP_MSGSIZE (NTP_MSGSIZE_NOAUTH + 4 + NTP_DIGESTSIZE)
96 struct ntp_msg {
97 u_int8_t status; /* status of local clock and leap info */
98 u_int8_t stratum; /* Stratum level */
99 u_int8_t ppoll; /* poll value */
100 int8_t precision;
101 struct s_fixedpt rootdelay;
102 struct s_fixedpt dispersion;
103 u_int32_t refid;
104 struct l_fixedpt reftime;
105 struct l_fixedpt orgtime;
106 struct l_fixedpt rectime;
107 struct l_fixedpt xmttime;
108 u_int32_t keyid;
109 u_int8_t digest[NTP_DIGESTSIZE];
112 struct ntp_query {
113 int fd;
114 struct ntp_msg msg;
115 double xmttime;
119 * Leap Second Codes (high order two bits)
121 #define LI_NOWARNING (0 << 6) /* no warning */
122 #define LI_PLUSSEC (1 << 6) /* add a second (61 seconds) */
123 #define LI_MINUSSEC (2 << 6) /* minus a second (59 seconds) */
124 #define LI_ALARM (3 << 6) /* alarm condition */
127 * Status Masks
129 #define MODEMASK (7 << 0)
130 #define VERSIONMASK (7 << 3)
131 #define LIMASK (3 << 6)
134 * Mode values
136 #define MODE_RES0 0 /* reserved */
137 #define MODE_SYM_ACT 1 /* symmetric active */
138 #define MODE_SYM_PAS 2 /* symmetric passive */
139 #define MODE_CLIENT 3 /* client */
140 #define MODE_SERVER 4 /* server */
141 #define MODE_BROADCAST 5 /* broadcast */
142 #define MODE_RES1 6 /* reserved for NTP control message */
143 #define MODE_RES2 7 /* reserved for private use */
145 #define JAN_1970 2208988800UL /* 1970 - 1900 in seconds */
147 #define NTP_VERSION 4
148 #define NTP_MAXSTRATUM 15
150 #endif /* _NTP_H_ */