mx_remote/types/
network.rs1use std::net::Ipv4Addr;
7
8use crate::wire::UtpLinkSpeed;
9
10#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
12pub struct UtpLinkErrors {
13 pub in_error: bool,
15 pub in_fcs_error: bool,
17 pub in_collision: bool,
19 pub out_deferred: bool,
21 pub out_excessive: bool,
23 pub polarity_error: bool,
25 pub skew_warning: bool,
27 pub length_warning: bool,
29}
30
31impl UtpLinkErrors {
32 pub(crate) const fn from_wire(v: u8) -> Self {
34 Self {
35 in_error: v & (1 << 0) != 0,
36 in_fcs_error: v & (1 << 1) != 0,
37 in_collision: v & (1 << 2) != 0,
38 out_deferred: v & (1 << 3) != 0,
39 out_excessive: v & (1 << 4) != 0,
40 polarity_error: v & (1 << 5) != 0,
41 skew_warning: v & (1 << 6) != 0,
42 length_warning: v & (1 << 7) != 0,
43 }
44 }
45}
46
47#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
49pub struct UtpCableStatus {
50 pub polarity: bool,
52 pub pair: u8,
54 pub skew: u32,
56 pub length: u32,
58}
59
60#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
62pub enum VctStatus {
63 #[default]
65 Healthy,
66 Warning,
68}
69
70#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
72pub struct MacAddress(pub [u8; 6]);
73
74impl core::fmt::Display for MacAddress {
75 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
76 let [a, b, c, d, e, g] = self.0;
77 write!(f, "{a:02X}:{b:02X}:{c:02X}:{d:02X}:{e:02X}:{g:02X}")
78 }
79}
80
81#[derive(Clone, Debug, Default, PartialEq, Eq)]
85pub struct NetworkPortStatus {
86 pub port: u16,
88 pub name: String,
90 pub link_speed: UtpLinkSpeed,
92 pub link_full_duplex: bool,
94 pub ip: Option<Ipv4Addr>,
96 pub querier: Option<Ipv4Addr>,
98 pub mac_address: Option<MacAddress>,
100 pub errors: Option<UtpLinkErrors>,
102 pub vct_status: Option<[VctStatus; 4]>,
104 pub cable_status: Vec<UtpCableStatus>,
106}