Skip to main content

ReferenceIdentifier

Enum ReferenceIdentifier 

Source
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

Source

pub fn as_bytes(&self) -> [u8; 4]

Returns the raw 4-byte representation of the reference identifier.

Source

pub fn is_kiss_of_death(&self) -> bool

Returns true if this is a Kiss-o’-Death reference identifier.

Source§

impl ReferenceIdentifier

Source

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

Source§

fn clone(&self) -> ReferenceIdentifier

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConstPackedSizeBytes for ReferenceIdentifier

Source§

const PACKED_SIZE_BYTES: usize = 4

The constant size in bytes when this type is packed for network transmission.
Source§

impl Debug for ReferenceIdentifier

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for ReferenceIdentifier

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ReferenceIdentifier

Source§

fn eq(&self, other: &ReferenceIdentifier) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToBytes for ReferenceIdentifier

Source§

fn to_bytes(&self, buf: &mut [u8]) -> Result<usize, ParseError>

Write this value into the given byte slice. Returns the number of bytes written. Fails with ParseError::BufferTooShort if buf is too short.
Source§

impl WriteToBytes for ReferenceIdentifier

Available on crate feature std only.
Source§

fn write_to_bytes<W: WriteBytesExt>(&self, writer: W) -> Result<()>

Write the command to bytes.
Source§

impl Copy for ReferenceIdentifier

Source§

impl Eq for ReferenceIdentifier

Source§

impl StructuralPartialEq for ReferenceIdentifier

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.