API Documentation
Loading...
Searching...
No Matches
NtpPacket.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QtGlobal>
4
5#include <NDEVR/NtpTimestamp.h>
6namespace NDEVR
7{
8 /**
9 * NtpPacket flags (first byte of the packet).
10 */
12 /** Mode. */
13 unsigned char mode : 3;
14
15 /** Version number of the protocol (3 or 4). */
16 unsigned char versionNumber : 3;
17
18 /** Warns of an impending leap second to be inserted/deleted in the last minute
19 * of the current day. */
20 unsigned char leapIndicator : 2;
21 };
22 static_assert(sizeof(NtpPacketFlags) == 1);
23
24#pragma pack(push, 1)
25 /**
26 * Mandatory part of an NTP packet
27 */
28 struct NtpPacket {
29 /** Flags. */
31
32 /** Stratum of the clock. */
33 quint8 stratum;
34
35 /** Maximum interval between successive messages, in log2 seconds. Note that the value is signed. */
36 qint8 poll;
37
38 /** Precision of the clock, in log2 seconds. Note that the value is signed. */
39 qint8 precision;
40
41 /** Round trip time to the primary reference source, in NTP short format. */
42 qint32 rootDelay;
43
44 /** Nominal error relative to the primary reference source. */
46
47 /** Reference identifier (either a 4 character string or an IP address). */
48 qint8 referenceID[4];
49
50 /** The time at which the clock was last set or corrected. */
52
53 /** The time at which the request departed the client for the server. */
55
56 /** The time at which the request arrived at the server. */
58
59 /** The time at which the reply departed the server for client. */
61 };
62 static_assert(sizeof(NtpPacket) == 48);
63
64 /**
65 * Optional part of an NTP packet.
66 */
68 /** Key identifier. */
69 quint32 keyId;
70
71 /** Message Digest. */
72 quint8 messageDigest[16];
73 };
74 static_assert(sizeof(NtpAuthenticationInfo) == 20);
75
76 /**
77 * Full NTP packet.
78 */
83 static_assert(sizeof(NtpFullPacket) == 68);
84
85#pragma pack(pop)
86}
Definition ACIColor.h:37
Definition NtpPacket.h:67
quint8 messageDigest[16]
Definition NtpPacket.h:72
quint32 keyId
Definition NtpPacket.h:69
Definition NtpPacket.h:79
NtpPacket basic
Definition NtpPacket.h:80
NtpAuthenticationInfo auth
Definition NtpPacket.h:81
Definition NtpPacket.h:11
unsigned char leapIndicator
Definition NtpPacket.h:20
unsigned char versionNumber
Definition NtpPacket.h:16
unsigned char mode
Definition NtpPacket.h:13
Definition NtpPacket.h:28
qint32 rootDispersion
Definition NtpPacket.h:45
qint8 poll
Definition NtpPacket.h:36
qint32 rootDelay
Definition NtpPacket.h:42
qint8 precision
Definition NtpPacket.h:39
NtpTimestamp receiveTimestamp
Definition NtpPacket.h:57
NtpTimestamp transmitTimestamp
Definition NtpPacket.h:60
NtpPacketFlags flags
Definition NtpPacket.h:30
NtpTimestamp referenceTimestamp
Definition NtpPacket.h:51
NtpTimestamp originateTimestamp
Definition NtpPacket.h:54
quint8 stratum
Definition NtpPacket.h:33
qint8 referenceID[4]
Definition NtpPacket.h:48
Definition NtpTimestamp.h:13