⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

NtpPacket

Struct NtpPacket 

Source
pub struct NtpPacket {
Show 13 fields pub leap: LeapIndicator, pub version: u8, pub mode: u8, pub stratum: u8, pub poll: i8, pub precision: i8, pub root_delay: u32, pub root_dispersion: u32, pub reference_id: [u8; 4], pub reference_ts: NtpTimestamp, pub origin_ts: NtpTimestamp, pub receive_ts: NtpTimestamp, pub transmit_ts: NtpTimestamp,
}
Expand description

NTPv4 packet (48 bytes, RFC 5905).

Fields§

§leap: LeapIndicator

Leap indicator (2 bits)

§version: u8

Version number (3 bits)

§mode: u8

Mode (3 bits)

§stratum: u8

Stratum level (0 = unspecified, 1 = primary, 2-15 = secondary)

§poll: i8

Maximum interval between successive messages (log2 seconds)

§precision: i8

Precision of the system clock (log2 seconds)

§root_delay: u32

Total round-trip delay to the reference source (NTP short format, 16.16)

§root_dispersion: u32

Maximum error relative to the reference source (NTP short format, 16.16)

§reference_id: [u8; 4]

Reference identifier (stratum 1: 4-char ASCII, else: IP address)

§reference_ts: NtpTimestamp

Time when the system clock was last set

§origin_ts: NtpTimestamp

Time at the client when the request departed

§receive_ts: NtpTimestamp

Time at the server when the request arrived

§transmit_ts: NtpTimestamp

Time at the server when the response departed

Implementations§

Source§

impl NtpPacket

Source

pub fn new_request(transmit_ts: NtpTimestamp) -> Self

Create a new client request packet.

Source

pub fn to_bytes(&self) -> [u8; 48]

Serialize to a 48-byte array.

Source

pub fn from_bytes(buf: &[u8]) -> Option<Self>

Deserialize from a 48-byte slice.

Source

pub fn is_kod(&self) -> bool

Check if this is a Kiss-o’-Death (KoD) packet.

KoD packets have stratum == 0 and a 4-char ASCII code in reference_id.

Source

pub fn kod_code(&self) -> Option<[u8; 4]>

Get the KoD code (e.g., “DENY”, “RATE”, “RSTR”) if this is a KoD packet.

Trait Implementations§

Source§

impl Clone for NtpPacket

Source§

fn clone(&self) -> NtpPacket

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for NtpPacket

Source§

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

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

impl PartialEq for NtpPacket

Source§

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

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

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 Eq for NtpPacket

Source§

impl StructuralPartialEq for NtpPacket

Auto Trait Implementations§

§

impl Freeze for NtpPacket

§

impl RefUnwindSafe for NtpPacket

§

impl Send for NtpPacket

§

impl Sync for NtpPacket

§

impl Unpin for NtpPacket

§

impl UnwindSafe for NtpPacket

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.