ntp_proto/
lib.rs

1//! This crate contains packet parsing and algorithm code for ntpd-rs and is not
2//! intended as a public interface at this time. It follows the same version as the
3//! main ntpd-rs crate, but that version is not intended to give any stability
4//! guarantee. Use at your own risk.
5//!
6//! Please visit the [ntpd-rs](https://github.com/pendulum-project/ntpd-rs) project
7//! for more information.
8#![forbid(unsafe_code)]
9#![cfg_attr(not(feature = "__internal-api"), allow(unused))]
10
11mod algorithm;
12mod clock;
13mod config;
14mod cookiestash;
15mod identifiers;
16mod io;
17mod ipfilter;
18mod keyset;
19mod nts_record;
20mod packet;
21mod server;
22mod source;
23mod system;
24mod time_types;
25
26pub mod tls_utils;
27
28pub(crate) mod exitcode {
29    /// An internal software error has been detected.  This
30    /// should be limited to non-operating system related
31    /// errors as possible.
32    #[cfg(not(test))]
33    pub const SOFTWARE: i32 = 70;
34}
35
36mod exports {
37    pub use super::algorithm::{
38        AlgorithmConfig, KalmanClockController, KalmanControllerMessage, KalmanSourceController,
39        KalmanSourceMessage, ObservableSourceTimedata, SourceController, StateUpdate,
40        TimeSyncController, TwoWayKalmanSourceController,
41    };
42    pub use super::clock::NtpClock;
43    pub use super::config::{SourceConfig, StepThreshold, SynchronizationConfig};
44    pub use super::identifiers::ReferenceId;
45    #[cfg(feature = "__internal-fuzz")]
46    pub use super::ipfilter::fuzz::fuzz_ipfilter;
47    pub use super::keyset::{DecodedServerCookie, KeySet, KeySetProvider};
48
49    #[cfg(feature = "__internal-fuzz")]
50    pub use super::keyset::test_cookie;
51    #[cfg(feature = "__internal-fuzz")]
52    pub use super::packet::ExtensionField;
53    pub use super::packet::{
54        Cipher, CipherProvider, EncryptResult, ExtensionHeaderVersion, NoCipher,
55        NtpAssociationMode, NtpLeapIndicator, NtpPacket, PacketParsingError,
56    };
57    pub use super::server::{
58        FilterAction, FilterList, IpSubnet, Server, ServerAction, ServerConfig, ServerReason,
59        ServerResponse, ServerStatHandler, SubnetParseError,
60    };
61    #[cfg(feature = "__internal-test")]
62    pub use super::source::source_snapshot;
63    pub use super::source::{
64        AcceptSynchronizationError, Measurement, NtpSource, NtpSourceAction,
65        NtpSourceActionIterator, NtpSourceSnapshot, NtpSourceUpdate, ObservableSourceState,
66        OneWaySource, OneWaySourceSnapshot, OneWaySourceUpdate, ProtocolVersion, Reach,
67        SourceNtsData,
68    };
69    pub use super::system::{
70        System, SystemAction, SystemActionIterator, SystemSnapshot, SystemSourceUpdate,
71        TimeSnapshot,
72    };
73
74    #[cfg(feature = "__internal-fuzz")]
75    pub use super::time_types::fuzz_duration_from_seconds;
76    pub use super::time_types::{
77        FrequencyTolerance, NtpDuration, NtpInstant, NtpTimestamp, PollInterval, PollIntervalLimits,
78    };
79
80    #[cfg(feature = "__internal-fuzz")]
81    pub use super::nts_record::fuzz_key_exchange_result_decoder;
82    #[cfg(feature = "__internal-fuzz")]
83    pub use super::nts_record::fuzz_key_exchange_server_decoder;
84    pub use super::nts_record::{
85        KeyExchangeClient, KeyExchangeError, KeyExchangeResult, KeyExchangeServer, NtpVersion,
86        NtsRecord, NtsRecordDecoder, WriteError,
87    };
88
89    pub use super::cookiestash::MAX_COOKIES;
90
91    pub mod v5 {
92        pub use crate::packet::v5::server_reference_id::{BloomFilter, ServerId};
93    }
94}
95
96#[cfg(feature = "__internal-api")]
97pub use exports::*;
98
99#[cfg(not(feature = "__internal-api"))]
100pub(crate) use exports::*;