|
| 1 | +use crate::datastructures::common::{PortIdentity, TimeInterval}; |
| 2 | + |
| 3 | +/// Type for `[PortDS].port_state`, see also *IEEE1588-2019 section 8.2.15.3.1 |
| 4 | +#[derive(Copy, Clone, Debug, Eq, PartialEq)] |
| 5 | +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] |
| 6 | +#[repr(u8)] |
| 7 | +#[allow(missing_docs)] |
| 8 | +pub enum PortState { |
| 9 | + Initializing = 1, |
| 10 | + Faulty = 2, |
| 11 | + Disabled = 3, |
| 12 | + Listening = 4, |
| 13 | + PreMaster = 5, |
| 14 | + Master = 6, |
| 15 | + Passive = 7, |
| 16 | + Uncalibrated = 8, |
| 17 | + Slave = 9, |
| 18 | +} |
| 19 | + |
| 20 | +#[derive(Copy, Clone, Debug, Eq, PartialEq)] |
| 21 | +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] |
| 22 | +#[repr(u8)] |
| 23 | +#[allow(missing_docs)] |
| 24 | +pub enum DelayMechanism { |
| 25 | + E2E { |
| 26 | + /// See *IEEE1588-2019 section 8.2.15.3.2* |
| 27 | + log_min_delay_req_interval: i8, |
| 28 | + } = 1, |
| 29 | + P2P { |
| 30 | + /// See *IEEE1588-2019 section 8.2.15.4.5* |
| 31 | + log_min_p_delay_req_interval: i8, |
| 32 | + /// See *IEEE1588-2019 section 8.2.15.3.3* |
| 33 | + mean_link_delay: TimeInterval, |
| 34 | + } = 2, |
| 35 | + NoMechanism = 0xfe, |
| 36 | + CommonP2P { |
| 37 | + /// See *IEEE1588-2019 section 8.2.15.3.3* |
| 38 | + mean_link_delay: TimeInterval, |
| 39 | + } = 3, |
| 40 | + Special = 4, |
| 41 | +} |
| 42 | + |
| 43 | +/// A concrete implementation of the PTP Port dataset (IEEE1588-2019 section |
| 44 | +/// 8.2.15) |
| 45 | +/// |
| 46 | +/// meanLinkDelay, logMinDelayReqInterval and logMinPDelayReqInterval are |
| 47 | +/// exposed through the delay mechanism type when the relevant delay mechanism |
| 48 | +/// is in use. |
| 49 | +#[derive(Copy, Clone, Debug, Eq, PartialEq)] |
| 50 | +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] |
| 51 | +pub struct PortDS { |
| 52 | + /// See *IEEE1588-2019 section 8.2.15.2.1* |
| 53 | + pub port_identity: PortIdentity, |
| 54 | + /// See *IEEE1588-2019 section 8.2.15.3.1* |
| 55 | + pub port_state: PortState, |
| 56 | + /// See *IEEE1588-2019 section 8.2.15.4.1* |
| 57 | + pub log_announce_interval: i8, |
| 58 | + /// See *IEEE1588-2019 section 8.2.15.4.2* |
| 59 | + pub announce_receipt_timeout: u8, |
| 60 | + /// See *IEEE1588-2019 section 8.2.15.4.3* |
| 61 | + pub log_sync_interval: i8, |
| 62 | + /// See *IEEE1588-2019 section 8.2.15.4.4* |
| 63 | + pub delay_mechanism: DelayMechanism, |
| 64 | + /// See *IEEE1588-2019 section 8.2.15.4.6* |
| 65 | + pub version_number: u8, |
| 66 | + /// See *IEEE1588-2019 section 8.2.15.4.7* |
| 67 | + pub minor_version_number: u8, |
| 68 | + /// See *IEEE1588-2019 section 8.2.15.4.8* |
| 69 | + pub delay_asymmetry: TimeInterval, |
| 70 | + /// See *IEEE1588-2019 section 8.2.15.5.2* |
| 71 | + pub master_only: bool, |
| 72 | +} |
0 commit comments