1 #ifndef PACKETPP_NTP_LAYER 2 #define PACKETPP_NTP_LAYER 79 #if (BYTE_ORDER == LITTLE_ENDIAN) 87 uint8_t leapIndicator:2,
107 uint64_t referenceTimestamp,
117 #pragma pack(push, 1) 127 #pragma pack(push, 1) 128 struct ntp_v4_auth_md5
137 #pragma pack(push, 1) 138 struct ntp_v4_auth_sha1
147 ntp_header *getNtpHeader()
const {
return (ntp_header *)m_Data; }
197 GOES = (
'G') | (
'O' << 8) | (
'E' << 16) | (
'S' << 24),
199 GPS = (
'G') | (
'P' << 8) | (
'S' << 16),
201 GAL = (
'G') | (
'A' << 8) | (
'L' << 16),
203 PPS = (
'P') | (
'P' << 8) | (
'S' << 16),
205 IRIG = (
'I') | (
'R' << 8) | (
'I' << 16) | (
'G' << 24),
207 WWVB = (
'W') | (
'W' << 8) | (
'V' << 16) | (
'B' << 24),
209 DCF = (
'D') | (
'C' << 8) | (
'F' << 16),
211 HBG = (
'H') | (
'B' << 8) | (
'G' << 16),
213 MSF = (
'M') | (
'S' << 8) | (
'F' << 16),
215 JJY = (
'J') | (
'J' << 8) | (
'Y' << 16),
217 LORC = (
'L') | (
'O' << 8) | (
'R' << 16) | (
'C' << 24),
219 TDF = (
'T') | (
'D' << 8) | (
'F' << 16),
221 CHU = (
'C') | (
'H' << 8) | (
'U' << 16),
223 WWV = (
'W') | (
'W' << 8) | (
'V' << 16),
225 WWVH = (
'W') | (
'W' << 8) | (
'V' << 16) | (
'H' << 24),
227 NIST = (
'N') | (
'I' << 8) | (
'S' << 16) | (
'T' << 24),
229 ACTS = (
'A') | (
'C' << 8) | (
'T' << 16) | (
'S' << 24),
231 USNO = (
'U') | (
'S' << 8) | (
'N' << 16) | (
'O' << 24),
233 PTB = (
'P') | (
'T' << 8) | (
'B' << 16),
235 MRS = (
'M') | (
'R' << 8) | (
'S' << 16),
237 XFAC = (
'X') | (
'F' << 8) | (
'A' << 16) | (
'C' << 24),
239 STEP = (
'S') | (
'T' << 8) | (
'E' << 16) | (
'P' << 24),
241 GOOG = (
'G') | (
'O' << 8) | (
'O' << 16) | (
'G' << 24),
243 DCFa = (
'D') | (
'C' << 8) | (
'F' << 16) | (
'a' << 24),
245 DCFp = (
'D') | (
'C' << 8) | (
'F' << 16) | (
'p' << 24),
247 GPSs = (
'G') | (
'P' << 8) | (
'S' << 16) | (
's' << 24),
249 GPSi = (
'G') | (
'P' << 8) | (
'S' << 16) | (
'i' << 24),
251 GLNs = (
'G') | (
'L' << 8) | (
'N' << 16) | (
's' << 24),
253 GLNi = (
'G') | (
'L' << 8) | (
'N' << 16) | (
'i' << 24),
255 LCL = (
'L') | (
'C' << 8) | (
'L' << 16),
257 LOCL = (
'L') | (
'O' << 8) | (
'C' << 16) | (
'L' << 24),
262 DCN = (
'D') | (
'C' << 8) | (
'N' << 16),
264 TSP = (
'T') | (
'S' << 8) | (
'P' << 16),
266 DTS = (
'D') | (
'T' << 8) | (
'S' << 16),
268 ATOM = (
'A') | (
'T' << 8) | (
'O' << 16) | (
'M' << 24),
270 VLF = (
'V') | (
'L' << 8) | (
'F' << 16)
280 ACST = (
'A') | (
'C' << 8) | (
'S' << 16) | (
'T' << 24),
282 AUTH = (
'A') | (
'U' << 8) | (
'T' << 16) | (
'H' << 24),
284 AUTO = (
'A') | (
'U' << 8) | (
'T' << 16) | (
'O' << 24),
286 BCST = (
'B') | (
'C' << 8) | (
'S' << 16) | (
'T' << 24),
288 CRYP = (
'C') | (
'R' << 8) | (
'Y' << 16) | (
'P' << 24),
290 DENY = (
'D') | (
'E' << 8) | (
'N' << 16) | (
'Y' << 24),
292 DROP = (
'D') | (
'R' << 8) | (
'O' << 16) | (
'P' << 24),
294 RSTR = (
'R') | (
'S' << 8) | (
'T' << 16) | (
'R' << 24),
296 INIT = (
'I') | (
'N' << 8) | (
'I' << 16) | (
'T' << 24),
298 MCST = (
'M') | (
'C' << 8) | (
'S' << 16) | (
'T' << 24),
300 NKEY = (
'N') | (
'K' << 8) | (
'E' << 16) | (
'Y' << 24),
302 RATE = (
'R') | (
'A' << 8) | (
'T' << 16) | (
'E' << 24),
304 RMOT = (
'R') | (
'M' << 8) | (
'O' << 16) | (
'T' << 24),
306 STEP = (
'S') | (
'T' << 8) | (
'E' << 16) | (
'P' << 24),
643 static bool isDataValid(
const uint8_t *data,
size_t dataSize);
649 static bool isNTPPort(uint16_t port) {
return port == 123; }
size_t getHeaderLen() const
Definition: NtpLayer.h:659
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:333
int8_t getPollInterval() const
Unknown (clock unsynchronized)
Definition: NtpLayer.h:162
double getPollIntervalInSecs() const
void setOriginTimestampInSecs(double val)
void parseNextLayer()
Parses the next layer. NTP is the always last so does nothing for this layer.
Definition: NtpLayer.h:654
void setReferenceIdentifier(IPv4Address val)
KissODeath
Definition: NtpLayer.h:277
void setRootDispersionInSecs(double val)
Last minute of the day has 59 seconds.
Definition: NtpLayer.h:160
uint8_t getStratum() const
Definition: ProtocolType.h:348
LeapIndicator getLeapIndicator() const
uint32_t getRootDelay() const
double getRootDelayInSecs() const
NTP control messages.
Definition: NtpLayer.h:183
static std::string convertToIsoFormat(const double timestamp)
void setPrecision(int8_t val)
double getRootDispersionInSecs() const
std::string getOriginTimestampAsString()
void setOriginTimestamp(uint64_t val)
NtpLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: NtpLayer.h:316
void setTransmitTimestamp(uint64_t val)
static double convertFromTimestampFormat(const uint64_t val)
The NTP packet consists of an integral number of 32-bit (4 octet) words in network byte order...
Definition: NtpLayer.h:73
static uint32_t convertToShortFormat(const double val)
uint32_t getReferenceIdentifier() const
Broadcasting mode.
Definition: NtpLayer.h:181
uint64_t getOriginTimestamp() const
double getReceiveTimestampInSecs() const
void setPollInterval(int8_t val)
void setLeapIndicator(LeapIndicator val)
Last minute of the day has 61 seconds.
Definition: NtpLayer.h:158
std::string getReferenceIdentifierString() const
std::string getReferenceTimestampAsString()
Mode
Definition: NtpLayer.h:168
void setReferenceTimestamp(uint64_t val)
void setStratum(uint8_t val)
uint64_t getReferenceTimestamp() const
std::string getTransmitTimestampAsString()
std::string getModeString() const
double getReferenceTimestampInSecs() const
Definition: IpAddress.h:42
double getTransmitTimestampInSecs() const
uint64_t getReceiveTimestamp() const
uint32_t getKeyID() const
LeapIndicator
Definition: NtpLayer.h:153
Symmetrically active.
Definition: NtpLayer.h:173
void setVersion(uint8_t val)
void setRootDelayInSecs(double val)
Symmetrically passive.
Definition: NtpLayer.h:175
void setRootDispersion(uint32_t val)
void setReferenceTimestampInSecs(double val)
void setReceiveTimestamp(uint64_t val)
Reserved variable.
Definition: NtpLayer.h:171
std::string getDigest() const
std::string getReceiveTimestampAsString()
uint32_t getRootDispersion() const
void setReceiveTimestampInSecs(double val)
void setRootDelay(uint32_t val)
OsiModelLayer getOsiModelLayer() const
Definition: NtpLayer.h:667
std::string toString() const
double getPrecisionInSecs() const
Server mode.
Definition: NtpLayer.h:179
Reserved for private use.
Definition: NtpLayer.h:185
uint64_t getTransmitTimestamp() const
const ProtocolType NTP
Definition: ProtocolType.h:258
static bool isNTPPort(uint16_t port)
Definition: NtpLayer.h:649
Normal, no leap second.
Definition: NtpLayer.h:156
static double convertFromShortFormat(const uint32_t val)
void computeCalculateFields()
Does nothing for this layer.
Definition: NtpLayer.h:662
static bool isDataValid(const uint8_t *data, size_t dataSize)
Client mode.
Definition: NtpLayer.h:177
static uint64_t convertToTimestampFormat(const double val)
double getOriginTimestampInSecs() const
int8_t getPrecision() const
uint8_t getVersion() const
ClockSource
Definition: NtpLayer.h:192
void setTransmitTimestampInSecs(double val)