]> git.saurik.com Git - apple/network_cmds.git/blob - tcpdump.tproj/ntp.h
dd69af9f45fb70752c013e3f8a29e515070abb6d
[apple/network_cmds.git] / tcpdump.tproj / ntp.h
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
12 * this file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
20 * under the License."
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24 /* $Header: /cvs/Darwin/Commands/NeXT/network_cmds/tcpdump.tproj/ntp.h,v 1.1.1.1 1999/05/02 03:58:32 wsanchez Exp $ */
25
26 /*
27 * Based on ntp.h from the U of MD implementation
28 * This file is based on Version 2 of the NTP spec (RFC1119).
29 */
30
31 /*
32 * Definitions for the masses
33 */
34 #define JAN_1970 2208988800 /* 1970 - 1900 in seconds */
35
36 /*
37 * Structure definitions for NTP fixed point values
38 *
39 * 0 1 2 3
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 |
43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 * | Fraction Part |
45 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 *
47 * 0 1 2 3
48 * 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
49 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 * | Integer Part | Fraction Part |
51 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 */
53 struct l_fixedpt {
54 u_int32_t int_part;
55 u_int32_t fraction;
56 };
57
58 struct s_fixedpt {
59 u_short int_part;
60 u_short fraction;
61 };
62
63 /* ================= Table 3.3. Packet Variables ================= */
64 /*
65 * 0 1 2 3
66 * 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
67 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68 * |LI | VN | Mode| Stratum | Poll | Precision |
69 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70 * | Synchronizing Distance |
71 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72 * | Synchronizing Dispersion |
73 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
74 * | Reference Clock Identifier |
75 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
76 * | |
77 * | Reference Timestamp (64 bits) |
78 * | |
79 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
80 * | |
81 * | Originate Timestamp (64 bits) |
82 * | |
83 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
84 * | |
85 * | Receive Timestamp (64 bits) |
86 * | |
87 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
88 * | |
89 * | Transmit Timestamp (64 bits) |
90 * | |
91 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
92 */
93 struct ntpdata {
94 u_char status; /* status of local clock and leap info */
95 u_char stratum; /* Stratum level */
96 u_char ppoll; /* poll value */
97 int precision:8;
98 struct s_fixedpt distance;
99 struct s_fixedpt dispersion;
100 u_int32_t refid;
101 struct l_fixedpt reftime;
102 struct l_fixedpt org;
103 struct l_fixedpt rec;
104 struct l_fixedpt xmt;
105 };
106 /*
107 * Leap Second Codes (high order two bits)
108 */
109 #define NO_WARNING 0x00 /* no warning */
110 #define PLUS_SEC 0x40 /* add a second (61 seconds) */
111 #define MINUS_SEC 0x80 /* minus a second (59 seconds) */
112 #define ALARM 0xc0 /* alarm condition (clock unsynchronized) */
113
114 /*
115 * Clock Status Bits that Encode Version
116 */
117 #define NTPVERSION_1 0x08
118 #define VERSIONMASK 0x38
119 #define LEAPMASK 0xc0
120 #define MODEMASK 0x07
121
122 /*
123 * Code values
124 */
125 #define MODE_UNSPEC 0 /* unspecified */
126 #define MODE_SYM_ACT 1 /* symmetric active */
127 #define MODE_SYM_PAS 2 /* symmetric passive */
128 #define MODE_CLIENT 3 /* client */
129 #define MODE_SERVER 4 /* server */
130 #define MODE_BROADCAST 5 /* broadcast */
131 #define MODE_RES1 6 /* reserved */
132 #define MODE_RES2 7 /* reserved */
133
134 /*
135 * Stratum Definitions
136 */
137 #define UNSPECIFIED 0
138 #define PRIM_REF 1 /* radio clock */
139 #define INFO_QUERY 62 /* **** THIS implementation dependent **** */
140 #define INFO_REPLY 63 /* **** THIS implementation dependent **** */