5 #ifndef __NTPCLIENT_H__
\r
7 #define __NTPCLIENT_H__
\r
11 typedef uint32_t quint32;
\r
12 typedef int32_t qint32;
\r
13 typedef uint8_t quint8;
\r
14 typedef int8_t qint8;
\r
16 typedef union _SNtpFlags SNtpFlags;
\r
19 * 64-bit NTP timestamp.
\r
21 struct __attribute__ ((__packed__)) _SNtpTimestamp {
\r
22 /** Number of seconds passed since Jan 1 1900, in big-endian format. */
\r
25 /** Fractional time part, in <tt>1/0xFFFFFFFF</tt>s of a second. */
\r
29 typedef struct _SNtpTimestamp SNtpTimestamp;
\r
31 * Mandatory part of an NTP packet
\r
35 unsigned char flags; // value 0xDB : mode 3 (client), version 3, leap indicator unknown 3
\r
37 /** Stratum of the clock. */
\r
38 quint8 stratum; // value 0 : unspecified
\r
40 /** Maximum interval between successive messages, in log2 seconds. Note that the value is signed. */
\r
41 qint8 poll; // 10 means 1 << 10 = 1024 seconds
\r
43 /** Precision of the clock, in log2 seconds. Note that the value is signed. */
\r
44 qint8 precision; // 0xFA = 250 = 0.015625 seconds
\r
46 /** Round trip time to the primary reference source, in NTP short format. */
\r
47 qint32 rootDelay; // 0x5D2E = 23854 or (23854/65535)= 0.3640 sec
\r
49 /** Nominal error relative to the primary reference source. */
\r
50 qint32 rootDispersion; // 0x0008 CAC8 = 8.7912 seconds
\r
52 /** Reference identifier (either a 4 character string or an IP address). */
\r
53 qint8 referenceID[4]; // or just 0000
\r
55 /** The time at which the clock was last set or corrected. */
\r
56 SNtpTimestamp referenceTimestamp; // Current time
\r
58 /** The time at which the request departed the client for the server. */
\r
59 SNtpTimestamp originateTimestamp; // Keep 0
\r
61 /** The time at which the request arrived at the server. */
\r
62 SNtpTimestamp receiveTimestamp; // Keep 0
\r
64 /** The time at which the reply departed the server for client. */
\r
65 SNtpTimestamp transmitTimestamp;
\r
68 /* Add this number to get secs since 1-1-1900 */
\r
69 #define TIME1970 2208988800UL
\r
71 #endif // __NTPCLIENT_H__
\r