2004-01-28 22:34:50 +08:00
|
|
|
/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.8 2004-01-28 14:34:50 hannes Exp $ */
|
1999-10-08 07:47:09 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Based on ntp.h from the U of MD implementation
|
|
|
|
* This file is based on Version 2 of the NTP spec (RFC1119).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Definitions for the masses
|
|
|
|
*/
|
2003-08-06 12:58:21 +08:00
|
|
|
#define JAN_1970 2208988800U /* 1970 - 1900 in seconds */
|
1999-10-08 07:47:09 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Structure definitions for NTP fixed point values
|
|
|
|
*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 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
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Integer Part |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Fraction Part |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 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
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Integer Part | Fraction Part |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
|
|
|
struct l_fixedpt {
|
|
|
|
u_int32_t int_part;
|
|
|
|
u_int32_t fraction;
|
2002-12-11 15:13:49 +08:00
|
|
|
};
|
1999-10-08 07:47:09 +08:00
|
|
|
|
|
|
|
struct s_fixedpt {
|
2000-10-03 10:54:54 +08:00
|
|
|
u_int16_t int_part;
|
|
|
|
u_int16_t fraction;
|
2002-12-11 15:13:49 +08:00
|
|
|
};
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2004-01-28 22:34:50 +08:00
|
|
|
/* rfc2030
|
|
|
|
* 1 2 3
|
|
|
|
* 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
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* |LI | VN |Mode | Stratum | Poll | Precision |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Root Delay |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Root Dispersion |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Reference Identifier |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | |
|
|
|
|
* | Reference Timestamp (64) |
|
|
|
|
* | |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | |
|
|
|
|
* | Originate Timestamp (64) |
|
|
|
|
* | |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | |
|
|
|
|
* | Receive Timestamp (64) |
|
|
|
|
* | |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | |
|
|
|
|
* | Transmit Timestamp (64) |
|
|
|
|
* | |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Key Identifier (optional) (32) |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* | Message Digest (optional) (128) |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
|
|
|
|
1999-10-08 07:47:09 +08:00
|
|
|
struct ntpdata {
|
|
|
|
u_char status; /* status of local clock and leap info */
|
|
|
|
u_char stratum; /* Stratum level */
|
|
|
|
u_char ppoll; /* poll value */
|
|
|
|
int precision:8;
|
2004-01-28 22:34:50 +08:00
|
|
|
struct s_fixedpt root_delay;
|
|
|
|
struct s_fixedpt root_dispersion;
|
1999-10-08 07:47:09 +08:00
|
|
|
u_int32_t refid;
|
2004-01-28 22:34:50 +08:00
|
|
|
struct l_fixedpt ref_timestamp;
|
|
|
|
struct l_fixedpt org_timestamp;
|
|
|
|
struct l_fixedpt rec_timestamp;
|
|
|
|
struct l_fixedpt xmt_timestamp;
|
|
|
|
u_int32_t key_id;
|
|
|
|
u_int8_t message_digest[16];
|
2002-12-11 15:13:49 +08:00
|
|
|
};
|
1999-10-08 07:47:09 +08:00
|
|
|
/*
|
|
|
|
* Leap Second Codes (high order two bits)
|
|
|
|
*/
|
|
|
|
#define NO_WARNING 0x00 /* no warning */
|
|
|
|
#define PLUS_SEC 0x40 /* add a second (61 seconds) */
|
|
|
|
#define MINUS_SEC 0x80 /* minus a second (59 seconds) */
|
|
|
|
#define ALARM 0xc0 /* alarm condition (clock unsynchronized) */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clock Status Bits that Encode Version
|
|
|
|
*/
|
|
|
|
#define NTPVERSION_1 0x08
|
|
|
|
#define VERSIONMASK 0x38
|
|
|
|
#define LEAPMASK 0xc0
|
|
|
|
#define MODEMASK 0x07
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Code values
|
|
|
|
*/
|
|
|
|
#define MODE_UNSPEC 0 /* unspecified */
|
|
|
|
#define MODE_SYM_ACT 1 /* symmetric active */
|
|
|
|
#define MODE_SYM_PAS 2 /* symmetric passive */
|
|
|
|
#define MODE_CLIENT 3 /* client */
|
|
|
|
#define MODE_SERVER 4 /* server */
|
|
|
|
#define MODE_BROADCAST 5 /* broadcast */
|
|
|
|
#define MODE_RES1 6 /* reserved */
|
|
|
|
#define MODE_RES2 7 /* reserved */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stratum Definitions
|
|
|
|
*/
|
|
|
|
#define UNSPECIFIED 0
|
|
|
|
#define PRIM_REF 1 /* radio clock */
|
|
|
|
#define INFO_QUERY 62 /* **** THIS implementation dependent **** */
|
|
|
|
#define INFO_REPLY 63 /* **** THIS implementation dependent **** */
|