Branch data Line data Source code
1 : : // $Id: NTP.h 6219 2008-10-01 05:39:07Z vern $
2 : : //
3 : : // See the file "COPYING" in the main distribution directory for copyright.
4 : :
5 : : #ifndef ntp_h
6 : : #define ntp_h
7 : :
8 : : #include "UDP.h"
9 : :
10 : :
11 : : // The following are from the tcpdump distribution, credited there
12 : : // to the U of MD implementation.
13 : :
14 : : #define JAN_1970 2208988800.0 /* 1970 - 1900 in seconds */
15 : :
16 : : struct l_fixedpt {
17 : : unsigned int int_part;
18 : : unsigned int fraction;
19 : : };
20 : :
21 : : struct s_fixedpt {
22 : : unsigned short int_part;
23 : : unsigned short fraction;
24 : : };
25 : :
26 : : struct ntpdata {
27 : : unsigned char status; /* status of local clock and leap info */
28 : : unsigned char stratum; /* Stratum level */
29 : : unsigned char ppoll; /* poll value */
30 : : int precision:8;
31 : : struct s_fixedpt distance;
32 : : struct s_fixedpt dispersion;
33 : : unsigned int refid;
34 : : struct l_fixedpt reftime;
35 : : struct l_fixedpt org;
36 : : struct l_fixedpt rec;
37 : : struct l_fixedpt xmt;
38 : : };
39 : :
40 [ # # ][ # # ]: 0 : class NTP_Analyzer : public Analyzer {
41 : : public:
42 : : NTP_Analyzer(Connection* conn);
43 : :
44 : 0 : static Analyzer* InstantiateAnalyzer(Connection* conn)
45 : 0 : { return new NTP_Analyzer(conn); }
46 : :
47 : 1 : static bool Available() { return ntp_message; }
48 : :
49 : : protected:
50 : : virtual void Done();
51 : : virtual void DeliverPacket(int len, const u_char* data, bool orig,
52 : : int seq, const IP_Hdr* ip, int caplen);
53 : :
54 : : int Request(const u_char* data, int len);
55 : : int Reply(const u_char* data, int len);
56 : :
57 : : // NTP is a unidirectional protocol, so no notion of "requests"
58 : : // as separate from "replies".
59 : : void Message(const u_char* data, int len);
60 : :
61 : : double ShortFloat(struct s_fixedpt fp);
62 : : double LongFloat(struct l_fixedpt fp);
63 : : double ConvertToDouble(unsigned int int_part, unsigned int fraction,
64 : : double frac_base);
65 : :
66 : : friend class ConnectionTimer;
67 : : void ExpireTimer(double t);
68 : : };
69 : :
70 : : #endif
|