Skip to main content

ntpsec_rs_core/
lib.rs

1// =============================================================================
2// ntpsec-rs-core — Forensic Rust reconstruction of the NTPsec time-discipline
3// brain.  Deterministic, side-effect-free, court-backed.
4//
5// This crate contains the reimplemented logic of every ntpsec C translation
6// unit that can be reasoned about without touching a real clock, real network
7// sockets, or real filesystem.  Host mutation lives behind trait boundaries in
8// ntpsec-rs-io; the core stays pure.
9//
10// ## Ported-module key
11//
12// Each module is a forensic reconstruction of the corresponding ntpsec C file,
13// developed by:
14//
15//   1. Deep Doxygen index of the ntpsec oracle to extract every function
16//      signature, type definition, constant, and macro.
17//   2. Deterministic-trace replay — captured ntpsec packet receipts are replayed
18//      through the Rust code and outputs are compared byte-for-byte.
19//   3. Protocol-spec cross-check — NTP RFCs (RFC 5905, 5906, 5907, 5908, 7821,
20//      7822, 8573, NTS RFC 8915) and NIST known-answer tests classify where
21//      ntpsec policy differs from generic protocol truth.
22//   4. Court-backed evidence — every admitted behavior links to a reproducible
23//      court in docs/courts/.
24//
25// =============================================================================
26
27// Allow manual is_multiple_of (stable Rust doesn't have the fn, nightly clippy wants it)
28#![allow(clippy::manual_is_multiple_of)]
29
30// ──── Re-exports ────────────────────────────────────────────────────────────
31// The facade crate re-exports the public API.  Here we just define it.
32
33pub mod binio;
34
35// Counting allocator (only available with the `counting-alloc` feature)
36pub mod counting_alloc;
37pub mod daemon_engine;
38pub mod gpstolfp;
39pub mod ieee754io;
40pub mod ntp_assert;
41pub mod ntp_auth;
42pub mod ntp_calendar;
43pub mod ntp_config;
44pub mod ntp_control;
45pub mod ntp_debug;
46pub mod ntp_dns;
47pub mod ntp_endian;
48pub mod ntp_filegen;
49pub mod ntp_fp;
50pub mod ntp_io;
51pub mod ntp_leapsec;
52pub mod ntp_lists;
53pub mod ntp_loopfilter;
54pub mod ntp_malloc;
55pub mod ntp_monitor;
56pub mod ntp_net;
57pub mod ntp_packetstamp;
58pub mod ntp_peer;
59pub mod ntp_proto;
60pub mod ntp_recvbuff;
61pub mod ntp_refclock;
62pub mod ntp_restrict;
63pub mod ntp_sandbox;
64pub mod ntp_scanner;
65pub mod ntp_signd;
66pub mod ntp_stdlib;
67pub mod ntp_syscall;
68pub mod ntp_syslog;
69pub mod ntp_timer;
70pub mod ntp_types;
71pub mod ntp_util;
72pub mod nts;
73pub mod nts_client;
74pub mod nts_cookie;
75pub mod nts_extens;
76pub mod nts_server;
77pub mod parse;
78pub mod refclock_arbiter;
79pub mod refclock_generic;
80pub mod refclock_gpsd;
81pub mod refclock_hpgps;
82pub mod refclock_jjy;
83pub mod refclock_local;
84pub mod refclock_modem;
85pub mod refclock_nmea;
86pub mod refclock_oncore;
87pub mod refclock_pps;
88pub mod refclock_pps_api;
89pub mod refclock_shm;
90pub mod refclock_spectracom;
91pub mod refclock_trimble;
92pub mod refclock_truetime;
93pub mod refclock_zyfer;
94pub mod timespecops;
95
96// ──── Python-client reconstructions ─────────────────────────────────────────
97// The ntpclients/*.py tools are reimplemented as separate crates; the logic
98// they share with the daemon lives here.
99pub mod control_client;
100pub mod leap_query;
101pub mod ntpdig_proto;
102
103// =============================================================================
104// Re-export the top-level preamble types so users see a unified API.
105// =============================================================================
106
107pub use binio::*;
108pub use control_client::*;
109pub use daemon_engine::{
110    parsed_timecode_to_sample, AssocOptions, DaemonEngine, NtsKeInFlight, NtsKeJob, NtsKeJobState,
111    PendingDns, PoolState, RefclockDriver, RefclockInstance, RefclockManager,
112};
113pub use gpstolfp::*;
114pub use ieee754io::*;
115pub use leap_query::*;
116
117pub use ntp_auth::*;
118pub use ntp_calendar::*;
119pub use ntp_config::*;
120pub use ntp_control::*;
121
122pub use ntp_dns::*;
123pub use ntp_endian::*;
124pub use ntp_filegen::*;
125pub use ntp_fp::*;
126pub use ntp_io::*;
127pub use ntp_leapsec::*;
128
129pub use ntp_loopfilter::*;
130pub use ntp_malloc::*;
131pub use ntp_monitor::{MonEntry, MonList, NonceCache, NonceEntry};
132pub use ntp_net::*;
133pub use ntp_packetstamp::*;
134pub use ntp_peer::*;
135pub use ntp_proto::*;
136pub use ntp_recvbuff::*;
137pub use ntp_refclock::*;
138pub use ntp_restrict::*;
139pub use ntp_sandbox::*;
140
141pub use ntp_signd::*;
142pub use ntp_stdlib::*;
143pub use ntp_syscall::*;
144pub use ntp_syslog::*;
145pub use ntp_timer::*;
146pub use ntp_types::*;
147pub use ntp_util::*;
148pub use ntpdig_proto::*;
149pub use nts::*;
150pub use nts_client::*;
151pub use nts_cookie::*;
152pub use nts_extens::{
153    validate_extension_fields_total_size, ExtensionFieldHeader, NtsAuthResult, NtsAuthenticator,
154    EXTENSION_FIELD_NTS_AUTHENTICATOR, EXTENSION_FIELD_NTS_AUTH_RESULT, EXTENSION_FIELD_NTS_COOKIE,
155    EXTENSION_FIELD_NTS_COOKIE_PLACEHOLDER, EXTENSION_FIELD_UNIQUE_IDENTIFIER, MAX_TOTAL_SIZE,
156};
157pub use nts_server::*;
158pub use parse::*;
159pub use refclock_arbiter::*;
160pub use refclock_generic::*;
161pub use refclock_gpsd::*;
162pub use refclock_hpgps::*;
163pub use refclock_jjy::*;
164pub use refclock_local::*;
165pub use refclock_modem::*;
166pub use refclock_nmea::*;
167pub use refclock_oncore::*;
168pub use refclock_pps::*;
169pub use refclock_pps_api::*;
170pub use refclock_shm::*;
171pub use refclock_spectracom::*;
172pub use refclock_trimble::*;
173pub use refclock_truetime::*;
174pub use refclock_zyfer::*;
175pub use timespecops::*;