pub enum ReferenceIdentifier {
PrimarySource(PrimarySource),
SecondaryOrClient([u8; 4]),
KissOfDeath(KissOfDeath),
Unknown([u8; 4]),
}Expand description
A 32-bit code identifying the particular server or reference clock.
The interpretation depends on the value in the stratum field:
- For packet stratum 0 (unspecified or invalid), this is a four-character ASCII [RFC1345] string, called the “kiss code”, used for debugging and monitoring purposes.
- For stratum 1 (reference clock), this is a four-octet, left-justified, zero-padded ASCII string assigned to the reference clock.
The authoritative list of Reference Identifiers is maintained by IANA; however, any string beginning with the ASCII character “X” is reserved for unregistered experimentation and development.
Variants§
PrimarySource(PrimarySource)
Primary reference source (stratum 1) identifier.
SecondaryOrClient([u8; 4])
The reference identifier of the secondary or client server. Can be used to detect timing loops.
If using the IPv4 address family, the identifier is the four-octet IPv4 address.
If using the IPv6 address family, it is the first four octets of the MD5 hash of the IPv6 address. Note that when using the IPv6 address family on a NTPv4 server with a NTPv3 client, the Reference Identifier field appears to be a random value and a timing loop might not be detected.
KissOfDeath(KissOfDeath)
Kiss-o’-Death packet code (stratum 0).
Unknown([u8; 4])
An unrecognized 4-byte reference identifier.
Used for stratum 0 packets with non-standard kiss codes, stratum 1 packets with unrecognized reference source identifiers, and stratum 16+ (unsynchronized/reserved) packets.
Implementations§
Source§impl ReferenceIdentifier
impl ReferenceIdentifier
Sourcepub fn from_bytes_with_stratum(bytes: [u8; 4], stratum: Stratum) -> Self
pub fn from_bytes_with_stratum(bytes: [u8; 4], stratum: Stratum) -> Self
Parse a reference identifier from 4 bytes, using stratum for disambiguation.
The interpretation of the reference identifier depends on the stratum:
- Stratum 0: Kiss-o’-Death code
- Stratum 1: Primary source identifier
- Stratum 2-15: Secondary/client reference (IPv4 or IPv6 hash)
- Stratum 16+: Unknown
Trait Implementations§
Source§impl Clone for ReferenceIdentifier
impl Clone for ReferenceIdentifier
Source§fn clone(&self) -> ReferenceIdentifier
fn clone(&self) -> ReferenceIdentifier
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConstPackedSizeBytes for ReferenceIdentifier
impl ConstPackedSizeBytes for ReferenceIdentifier
Source§const PACKED_SIZE_BYTES: usize = 4
const PACKED_SIZE_BYTES: usize = 4
Source§impl Debug for ReferenceIdentifier
impl Debug for ReferenceIdentifier
Source§impl Hash for ReferenceIdentifier
impl Hash for ReferenceIdentifier
Source§impl PartialEq for ReferenceIdentifier
impl PartialEq for ReferenceIdentifier
Source§impl ToBytes for ReferenceIdentifier
impl ToBytes for ReferenceIdentifier
Source§fn to_bytes(&self, buf: &mut [u8]) -> Result<usize, ParseError>
fn to_bytes(&self, buf: &mut [u8]) -> Result<usize, ParseError>
ParseError::BufferTooShort if buf is too short.Source§impl WriteToBytes for ReferenceIdentifier
Available on crate feature std only.
impl WriteToBytes for ReferenceIdentifier
std only.