Skip to main content

Module ntp

Module ntp 

Source
Expand description

NTPv4 packet codec (RFC 5905) with extension-field iteration (RFC 7822).

Every entry point is a parse-constructor returning Result; nothing here can panic on untrusted bytes (the fuzz targets in fuzz/ hold this line).

Structs§

ExtensionField
One RFC 7822 extension field: type, and its value bytes (header excluded).
ExtensionIter
NtpPacket
The fixed NTPv4 header.
NtpShort
32-bit NTP short format: 16.16 fixed-point seconds (root delay / dispersion).
NtpTimestamp
64-bit NTP timestamp: 32.32 fixed-point seconds since the era epoch.

Enums§

LeapIndicator
Mode
ParseError
Trailer
What follows the fixed header.

Constants§

HEADER_LEN
Length of the fixed NTPv4 header.
UNIX_EPOCH_OFFSET
Seconds between the NTP era-0 epoch (1900-01-01) and the Unix epoch (1970-01-01).

Functions§

extension_fields
Iterate whatever follows the 48-byte header. Malformed input can never panic: anything that does not parse as an extension field is yielded once as Trailer::Opaque and iteration ends.
offset_delay
Offset/delay from the four client-exchange timestamps (RFC 5905 §8), all in seconds on any common timescale. Returns (offset, delay); offset is seconds to ADD to the local clock.