Expand description
rusty_rtos_sntp — coreSNTP remade in Rust.
What is here: core_sntp_serializer.c — the SNTPv4 packet codec, the
response validation, the clock-offset arithmetic across the 2036 era wrap,
the poll-interval calculation and the UNIX time conversion. Every one of
them diffed against the C, call for call.
What is not: core_sntp_client.c, the state machine that drives a UDP
transport and an authentication interface. It needs a seam this package does
not have yet, and this crate does not pretend otherwise.
Integer arithmetic throughout, because coreSNTP targets parts with no
floating-point unit. Zero allocation, no_std, forbid(unsafe).
This is the facade: it re-exports the no_std core. Depend on this crate;
reach into the sub-crates only when you are building a port or a backend.
Part of Kairos (Remade With Rust). Plan: docs/plans/rusty_rtos_sntp.md.
Modules§
- client
core_sntp_client.c: the polling client over a UDP transport.core_sntp_client.cremade: the polling client over a UDP transport.- prelude
- The names a firmware wants in scope.
- rtos_
core rusty_rtos_core— the shared vocabulary of the Kairos family.- serializer
core_sntp_serializer.c: the SNTPv4 packet codec and its arithmetic.core_sntp_serializer.cremade: the SNTPv4 packet codec and its arithmetic.- types
- The types that cross the SNTP surface. The types that cross the SNTP surface.
Structs§
- Accepted
- A server response that carried a usable time.
- Client
- A long-running SNTP client: one server at a time, rotating on refusal.
- Network
Error - Something went wrong in the transport itself.
- NoAuth
- No authentication, which is what most SNTP deployments use.
- Rejected
- A Kiss-o’-Death: the server answered, and the answer was no.
- Server
Info - A time server: a name to resolve, and a port to reach it on.
- Timestamp
- An SNTP timestamp: seconds and fractions since 1 January 1900 UTC.
Enums§
- Auth
Error - Why an authentication callback refused.
- Deserialize
Error - Why a response could not be read.
- Init
Error - Why a client could not be built.
- Leap
Second SntpLeapSecondInfo_t: what the server says about the coming month.- Poll
Interval Error - Why a poll interval could not be calculated.
- Receive
Error - Why a response could not be used.
- Reception
- What happened while waiting for a response.
- Rejection
- Why a server refused to give the time.
- Send
Error - Why a time request could not be sent.
- Serialize
Error - Why a request could not be serialized.
- Verdict
- What a well-formed response turned out to say.
Constants§
- FRACTION_
VALUE_ PER_ MICROSECOND SNTP_FRACTION_VALUE_PER_MICROSECOND. The fractions field is 32 bits over one second, so one tick is about 232 picoseconds and a microsecond is 4,295 of them.- KISS_
OF_ DEATH_ CODE_ LENGTH SNTP_KISS_OF_DEATH_CODE_LENGTH: a kiss code is four ASCII characters.- PACKET_
BASE_ SIZE SNTP_PACKET_BASE_SIZE: a packet without authentication data.- TIME_
AT_ UNIX_ EPOCH_ SECS SNTP_TIME_AT_UNIX_EPOCH_SECS: 70 years, in seconds, between the SNTP epoch (1 Jan 1900) and the UNIX epoch (1 Jan 1970).- UNIX_
TIME_ SECS_ AT_ SNTP_ ERA_ 1_ SMALLEST_ TIME UNIX_TIME_SECS_AT_SNTP_ERA_1_SMALLEST_TIME: the UNIX time at the moment SNTP’s seconds field wraps, 7 Feb 2036 06:28:16 UTC.- VERSION
- Crate version, for manifests and logs.
Traits§
- Authenticator
- Symmetric-key or NTS-style authentication, if the deployment uses it.
- Sntp
Host - Everything the client needs from the system it runs on.
Functions§
- calculate_
poll_ interval Sntp_CalculatePollInterval: how often to ask, for a wanted accuracy.- convert_
to_ unix_ time Sntp_ConvertToUnixTime: an SNTP timestamp as UNIX seconds and microseconds.- deserialize_
response Sntp_DeserializeResponse: validate a server response and time the clock.- serialize_
request Sntp_SerializeRequest: build an SNTP request packet.