Move tcpdump-3.9/ to tcpdump/. No need for a versioned dir.
[dragonfly.git] / contrib / tcpdump / ntp.h
1 /* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.8 2004/01/28 14:34:50 hannes 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        2208988800U     /* 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 /* rfc2030
41  *                      1                   2                   3
42  *  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
43  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44  * |LI | VN  |Mode |    Stratum    |     Poll      |   Precision   |
45  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46  * |                          Root Delay                           |
47  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48  * |                       Root Dispersion                         |
49  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50  * |                     Reference Identifier                      |
51  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52  * |                                                               |
53  * |                   Reference Timestamp (64)                    |
54  * |                                                               |
55  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56  * |                                                               |
57  * |                   Originate Timestamp (64)                    |
58  * |                                                               |
59  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
60  * |                                                               |
61  * |                    Receive Timestamp (64)                     |
62  * |                                                               |
63  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64  * |                                                               |
65  * |                    Transmit Timestamp (64)                    |
66  * |                                                               |
67  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68  * |                 Key Identifier (optional) (32)                |
69  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70  * |                                                               |
71  * |                                                               |
72  * |                 Message Digest (optional) (128)               |
73  * |                                                               |
74  * |                                                               |
75  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
76  */
77
78 struct ntpdata {
79         u_char status;          /* status of local clock and leap info */
80         u_char stratum;         /* Stratum level */
81         u_char ppoll;           /* poll value */
82         int precision:8;
83         struct s_fixedpt root_delay;
84         struct s_fixedpt root_dispersion;
85         u_int32_t refid;
86         struct l_fixedpt ref_timestamp;
87         struct l_fixedpt org_timestamp;
88         struct l_fixedpt rec_timestamp;
89         struct l_fixedpt xmt_timestamp;
90         u_int32_t key_id;
91         u_int8_t  message_digest[16];
92 };
93 /*
94  *      Leap Second Codes (high order two bits)
95  */
96 #define NO_WARNING      0x00    /* no warning */
97 #define PLUS_SEC        0x40    /* add a second (61 seconds) */
98 #define MINUS_SEC       0x80    /* minus a second (59 seconds) */
99 #define ALARM           0xc0    /* alarm condition (clock unsynchronized) */
100
101 /*
102  *      Clock Status Bits that Encode Version
103  */
104 #define NTPVERSION_1    0x08
105 #define VERSIONMASK     0x38
106 #define LEAPMASK        0xc0
107 #define MODEMASK        0x07
108
109 /*
110  *      Code values
111  */
112 #define MODE_UNSPEC     0       /* unspecified */
113 #define MODE_SYM_ACT    1       /* symmetric active */
114 #define MODE_SYM_PAS    2       /* symmetric passive */
115 #define MODE_CLIENT     3       /* client */
116 #define MODE_SERVER     4       /* server */
117 #define MODE_BROADCAST  5       /* broadcast */
118 #define MODE_RES1       6       /* reserved */
119 #define MODE_RES2       7       /* reserved */
120
121 /*
122  *      Stratum Definitions
123  */
124 #define UNSPECIFIED     0
125 #define PRIM_REF        1       /* radio clock */
126 #define INFO_QUERY      62      /* **** THIS implementation dependent **** */
127 #define INFO_REPLY      63      /* **** THIS implementation dependent **** */