1190207Srpaulo/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.8 2004-01-28 14:34:50 hannes Exp $ */
217680Spst
317680Spst/*
417680Spst * Based on ntp.h from the U of MD implementation
517680Spst *	This file is based on Version 2 of the NTP spec (RFC1119).
617680Spst */
717680Spst
817680Spst/*
917680Spst *  Definitions for the masses
1017680Spst */
11127668Sbms#define	JAN_1970	2208988800U	/* 1970 - 1900 in seconds */
1217680Spst
1317680Spst/*
1417680Spst * Structure definitions for NTP fixed point values
1517680Spst *
1617680Spst *    0			  1		      2			  3
1717680Spst *    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
1817680Spst *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1917680Spst *   |			       Integer Part			     |
2017680Spst *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2117680Spst *   |			       Fraction Part			     |
2217680Spst *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2317680Spst *
2417680Spst *    0			  1		      2			  3
2517680Spst *    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
2617680Spst *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2717680Spst *   |		  Integer Part	     |	   Fraction Part	     |
2817680Spst *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2917680Spst*/
3017680Spststruct l_fixedpt {
3117680Spst	u_int32_t int_part;
3217680Spst	u_int32_t fraction;
3317680Spst};
3417680Spst
3517680Spststruct s_fixedpt {
3675115Sfenner	u_int16_t int_part;
3775115Sfenner	u_int16_t fraction;
3817680Spst};
3917680Spst
40146773Ssam/* rfc2030
41146773Ssam *                      1                   2                   3
42146773Ssam *  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
43146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44146773Ssam * |LI | VN  |Mode |    Stratum    |     Poll      |   Precision   |
45146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46146773Ssam * |                          Root Delay                           |
47146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48146773Ssam * |                       Root Dispersion                         |
49146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50146773Ssam * |                     Reference Identifier                      |
51146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52146773Ssam * |                                                               |
53146773Ssam * |                   Reference Timestamp (64)                    |
54146773Ssam * |                                                               |
55146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56146773Ssam * |                                                               |
57146773Ssam * |                   Originate Timestamp (64)                    |
58146773Ssam * |                                                               |
59146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
60146773Ssam * |                                                               |
61146773Ssam * |                    Receive Timestamp (64)                     |
62146773Ssam * |                                                               |
63146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64146773Ssam * |                                                               |
65146773Ssam * |                    Transmit Timestamp (64)                    |
66146773Ssam * |                                                               |
67146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68146773Ssam * |                 Key Identifier (optional) (32)                |
69146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70146773Ssam * |                                                               |
71146773Ssam * |                                                               |
72146773Ssam * |                 Message Digest (optional) (128)               |
73146773Ssam * |                                                               |
74146773Ssam * |                                                               |
75146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
76146773Ssam */
77146773Ssam
7817680Spststruct ntpdata {
7917680Spst	u_char status;		/* status of local clock and leap info */
8017680Spst	u_char stratum;		/* Stratum level */
8117680Spst	u_char ppoll;		/* poll value */
8217680Spst	int precision:8;
83146773Ssam	struct s_fixedpt root_delay;
84146773Ssam	struct s_fixedpt root_dispersion;
8517680Spst	u_int32_t refid;
86146773Ssam	struct l_fixedpt ref_timestamp;
87146773Ssam	struct l_fixedpt org_timestamp;
88146773Ssam	struct l_fixedpt rec_timestamp;
89146773Ssam	struct l_fixedpt xmt_timestamp;
90146773Ssam        u_int32_t key_id;
91146773Ssam        u_int8_t  message_digest[16];
9217680Spst};
9317680Spst/*
9417680Spst *	Leap Second Codes (high order two bits)
9517680Spst */
9617680Spst#define	NO_WARNING	0x00	/* no warning */
9717680Spst#define	PLUS_SEC	0x40	/* add a second (61 seconds) */
9817680Spst#define	MINUS_SEC	0x80	/* minus a second (59 seconds) */
9917680Spst#define	ALARM		0xc0	/* alarm condition (clock unsynchronized) */
10017680Spst
10117680Spst/*
10217680Spst *	Clock Status Bits that Encode Version
10317680Spst */
10417680Spst#define	NTPVERSION_1	0x08
10517680Spst#define	VERSIONMASK	0x38
10617680Spst#define LEAPMASK	0xc0
10717680Spst#define	MODEMASK	0x07
10817680Spst
10917680Spst/*
11017680Spst *	Code values
11117680Spst */
11217680Spst#define	MODE_UNSPEC	0	/* unspecified */
11317680Spst#define	MODE_SYM_ACT	1	/* symmetric active */
11417680Spst#define	MODE_SYM_PAS	2	/* symmetric passive */
11517680Spst#define	MODE_CLIENT	3	/* client */
11617680Spst#define	MODE_SERVER	4	/* server */
11717680Spst#define	MODE_BROADCAST	5	/* broadcast */
11817680Spst#define	MODE_RES1	6	/* reserved */
11917680Spst#define	MODE_RES2	7	/* reserved */
12017680Spst
12117680Spst/*
12217680Spst *	Stratum Definitions
12317680Spst */
12417680Spst#define	UNSPECIFIED	0
12517680Spst#define	PRIM_REF	1	/* radio clock */
12617680Spst#define	INFO_QUERY	62	/* **** THIS implementation dependent **** */
12717680Spst#define	INFO_REPLY	63	/* **** THIS implementation dependent **** */
128