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
26#[cfg(feature = "nts-pool")]
27mod nts_pool_ke;
28pub mod tls_utils;
29
30pub(crate) mod exitcode {
31    /// An internal software error has been detected.  This
32    /// should be limited to non-operating system related
33    /// errors as possible.
34    #[cfg(not(test))]
35    pub const SOFTWARE: i32 = 70;
36}
37
38mod exports {
39    pub use super::algorithm::{
40        AlgorithmConfig, KalmanClockController, KalmanControllerMessage, KalmanSourceController,
41        KalmanSourceMessage, ObservableSourceTimedata, SourceController, StateUpdate,
42        TimeSyncController, TwoWayKalmanSourceController,
43    };
44    pub use super::clock::NtpClock;
45    pub use super::config::{SourceDefaultsConfig, StepThreshold, SynchronizationConfig};
46    pub use super::identifiers::ReferenceId;
47    #[cfg(feature = "__internal-fuzz")]
48    pub use super::ipfilter::fuzz::fuzz_ipfilter;
49    pub use super::keyset::{DecodedServerCookie, KeySet, KeySetProvider};
50
51    #[cfg(feature = "__internal-fuzz")]
52    pub use super::keyset::test_cookie;
53    #[cfg(feature = "__internal-fuzz")]
54    pub use super::packet::ExtensionField;
55    pub use super::packet::{
56        Cipher, CipherProvider, EncryptResult, ExtensionHeaderVersion, NoCipher,
57        NtpAssociationMode, NtpLeapIndicator, NtpPacket, PacketParsingError,
58    };
59    pub use super::server::{
60        FilterAction, FilterList, IpSubnet, Server, ServerAction, ServerConfig, ServerReason,
61        ServerResponse, ServerStatHandler, SubnetParseError,
62    };
63    #[cfg(feature = "__internal-test")]
64    pub use super::source::source_snapshot;
65    pub use super::source::{
66        AcceptSynchronizationError, Measurement, NtpSource, NtpSourceAction,
67        NtpSourceActionIterator, NtpSourceSnapshot, NtpSourceUpdate, ObservableSourceState,
68        OneWaySource, OneWaySourceSnapshot, OneWaySourceUpdate, ProtocolVersion, Reach,
69        SourceNtsData,
70    };
71    pub use super::system::{
72        System, SystemAction, SystemActionIterator, SystemSnapshot, SystemSourceUpdate,
73        TimeSnapshot,
74    };
75
76    #[cfg(feature = "__internal-fuzz")]
77    pub use super::time_types::fuzz_duration_from_seconds;
78    pub use super::time_types::{
79        FrequencyTolerance, NtpDuration, NtpInstant, NtpTimestamp, PollInterval, PollIntervalLimits,
80    };
81
82    #[cfg(feature = "__internal-fuzz")]
83    pub use super::nts_record::fuzz_key_exchange_result_decoder;
84    #[cfg(feature = "__internal-fuzz")]
85    pub use super::nts_record::fuzz_key_exchange_server_decoder;
86    pub use super::nts_record::{
87        KeyExchangeClient, KeyExchangeError, KeyExchangeResult, KeyExchangeServer, NtpVersion,
88        NtsRecord, NtsRecordDecoder, WriteError,
89    };
90
91    pub use super::cookiestash::MAX_COOKIES;
92
93    #[cfg(feature = "ntpv5")]
94    pub mod v5 {
95        pub use crate::packet::v5::server_reference_id::{BloomFilter, ServerId};
96    }
97
98    #[cfg(feature = "nts-pool")]
99    pub use super::nts_record::AeadAlgorithm;
100
101    #[cfg(feature = "nts-pool")]
102    pub use super::nts_pool_ke::{
103        ClientToPoolData, ClientToPoolDecoder, PoolToServerData, PoolToServerDecoder,
104        SupportedAlgorithmsDecoder,
105    };
106}
107
108#[cfg(feature = "__internal-api")]
109pub use exports::*;
110
111#[cfg(not(feature = "__internal-api"))]
112pub(crate) use exports::*;