Skip to content

Commit 9233918

Browse files
committed
Implement CSPTP source functionality.
1 parent 3510543 commit 9233918

9 files changed

Lines changed: 461 additions & 8 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ clock-steering = "0.2.1"
3636
hickory-resolver = { version = "0.26.0", features = ["dnssec-aws-lc-rs"] }
3737
libc = "0.2.154"
3838
pps-time = "0.2.3"
39-
rand = "0.8.0"
39+
rand = { version = "0.8.0", default-features = false }
4040
serde = { version = "1.0.166", features = ["derive"] }
4141
serde_json = "1.0"
4242
timestamped-socket = "0.2.2"

fuzz/fuzz_rand_shim/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ publish = false
77
[workspace]
88
members = ["."]
99

10+
[features]
11+
std = []
12+
std_rng = []
13+
1014
[dependencies]
1115
real_rand = { git = "https://github.com/rust-random/rand.git", tag="0.8.5", package="rand" }

ntp-proto/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ __internal-api = []
2121
[dependencies]
2222
# Note: md5 is needed to calculate ReferenceIDs for IPv6 addresses per RFC5905
2323
md-5.workspace = true
24-
rand.workspace = true
24+
rand = { workspace = true, features = ["std", "std_rng"] }
2525
tracing.workspace = true
2626
tokio = { workspace = true, features = ["io-util", "time"] }
2727
tokio-rustls.workspace = true

statime-csptp/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ std = ["statime-wire/std"]
1717
[dependencies]
1818
statime-wire = { workspace = true }
1919
ntp-proto = { workspace = true }
20+
rand = { workspace = true, default-features = false }

statime-csptp/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,12 @@ mod manager;
142142
mod messages;
143143
mod platform;
144144
mod server;
145+
mod source;
145146

146147
pub use manager::{CsptpConfig, CsptpManager};
147148
pub use platform::{InternalState, StateMutex};
148149
pub use server::{ServerRecvResult, ServerSocket, serve};
150+
pub use source::{ClientRecvResult, ClientSocket, CsptpSource, CsptpSourceConfig};
149151

150152
/// Observable CSPTP state
151153
#[derive(Debug, Copy, Clone)]

statime-csptp/src/messages.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ use statime_wire::{
66
SyncMessage, TimeInterval, Timestamp, TlvSetBuilder, TlvType,
77
};
88

9-
use crate::{
10-
CsptpState,
11-
messages::tlvs::{CsptpRequestTlv, CsptpResponseTlv, CsptpStatusTlv},
12-
};
9+
use crate::CsptpState;
1310

1411
mod tlvs;
1512

13+
pub(crate) use tlvs::{CsptpRequestTlv, CsptpResponseTlv, CsptpStatusTlv};
14+
1615
pub(crate) const MAX_MESSAGE_SIZE: usize = 512;
1716

1817
/// A message with additional restrictions to ensure it is a valid CSPTP Message.
@@ -116,7 +115,6 @@ impl<'a> CsptpMessage<'a> {
116115
}
117116

118117
/// Generate a new request message. The buffer must be at least 8 bytes long
119-
#[expect(unused)]
120118
pub(crate) fn new_request(
121119
buffer: &'a mut [u8],
122120
domain_number: u8,

statime-csptp/src/messages/tlvs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ pub(crate) struct CsptpStatusTlv {
7777
}
7878

7979
impl CsptpStatusTlv {
80-
#[expect(unused)]
8180
pub(crate) fn try_from(tlv: &Tlv<'_>) -> Option<Self> {
8281
(tlv.tlv_type == TlvType::CsptpStatus)
8382
.then(|| {

0 commit comments

Comments
 (0)