]> The Tcpdump Group git mirrors - tcpdump/blob - ntp.h
The "__attribute__((packed))" tag on structures causes some files not to
[tcpdump] / ntp.h
1 /* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.6 2002-12-11 07:13:56 guy Exp $ */
2
3 /*
4 * Based on ntp.h from the U of MD implementation
5 * This file is based on Version 2 of the NTP spec (RFC1119).
6 */
7
8 /*
9 * Definitions for the masses
10 */
11 #define JAN_1970 2208988800 /* 1970 - 1900 in seconds */
12
13 /*
14 * Structure definitions for NTP fixed point values
15 *
16 * 0 1 2 3
17 * 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
18 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
19 * | Integer Part |
20 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
21 * | Fraction Part |
22 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
23 *
24 * 0 1 2 3
25 * 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
26 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27 * | Integer Part | Fraction Part |
28 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29 */
30 struct l_fixedpt {
31 u_int32_t int_part;
32 u_int32_t fraction;
33 };
34
35 struct s_fixedpt {
36 u_int16_t int_part;
37 u_int16_t fraction;
38 };
39
40 /* ================= Table 3.3. Packet Variables ================= */
41 /*
42 * 0 1 2 3
43 * 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
44 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 * |LI | VN | Mode| Stratum | Poll | Precision |
46 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 * | Synchronizing Distance |
48 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 * | Synchronizing Dispersion |
50 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 * | Reference Clock Identifier |
52 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 * | |
54 * | Reference Timestamp (64 bits) |
55 * | |
56 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57 * | |
58 * | Originate Timestamp (64 bits) |
59 * | |
60 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61 * | |
62 * | Receive Timestamp (64 bits) |
63 * | |
64 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
65 * | |
66 * | Transmit Timestamp (64 bits) |
67 * | |
68 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
69 */
70 struct ntpdata {
71 u_char status; /* status of local clock and leap info */
72 u_char stratum; /* Stratum level */
73 u_char ppoll; /* poll value */
74 int precision:8;
75 struct s_fixedpt distance;
76 struct s_fixedpt dispersion;
77 u_int32_t refid;
78 struct l_fixedpt reftime;
79 struct l_fixedpt org;
80 struct l_fixedpt rec;
81 struct l_fixedpt xmt;
82 };
83 /*
84 * Leap Second Codes (high order two bits)
85 */
86 #define NO_WARNING 0x00 /* no warning */
87 #define PLUS_SEC 0x40 /* add a second (61 seconds) */
88 #define MINUS_SEC 0x80 /* minus a second (59 seconds) */
89 #define ALARM 0xc0 /* alarm condition (clock unsynchronized) */
90
91 /*
92 * Clock Status Bits that Encode Version
93 */
94 #define NTPVERSION_1 0x08
95 #define VERSIONMASK 0x38
96 #define LEAPMASK 0xc0
97 #define MODEMASK 0x07
98
99 /*
100 * Code values
101 */
102 #define MODE_UNSPEC 0 /* unspecified */
103 #define MODE_SYM_ACT 1 /* symmetric active */
104 #define MODE_SYM_PAS 2 /* symmetric passive */
105 #define MODE_CLIENT 3 /* client */
106 #define MODE_SERVER 4 /* server */
107 #define MODE_BROADCAST 5 /* broadcast */
108 #define MODE_RES1 6 /* reserved */
109 #define MODE_RES2 7 /* reserved */
110
111 /*
112 * Stratum Definitions
113 */
114 #define UNSPECIFIED 0
115 #define PRIM_REF 1 /* radio clock */
116 #define INFO_QUERY 62 /* **** THIS implementation dependent **** */
117 #define INFO_REPLY 63 /* **** THIS implementation dependent **** */