net_parser_rs/flow/
info.rs

1pub mod layer2 {
2    use crate::common::{MacAddress, Vlan};
3
4    ///
5    /// Representation of layer 2 types that provide information for `Layer2FlowInfo`
6    ///
7    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
8    pub enum Id {
9        Ethernet,
10    }
11
12    impl Default for Id {
13        fn default() -> Self {
14            Self::Ethernet
15        }
16    }
17
18    ///
19    /// Information from Layer 2 protocols used in stream determination
20    ///
21    #[derive(Clone, Copy, Debug, Default)]
22    pub struct Info {
23        pub id: Id,
24        pub src_mac: MacAddress,
25        pub dst_mac: MacAddress,
26        pub vlan: Vlan,
27    }
28}
29
30pub mod layer3 {
31    use std::net::IpAddr;
32
33    ///
34    /// Representation of Layer3 types that provide information for `Layer3FlowInfo`
35    ///
36    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
37    pub enum Id {
38        Arp,
39        IPv4,
40        IPv6,
41    }
42
43    impl Default for Id {
44        fn default() -> Self {
45            Self::IPv4
46        }
47    }
48
49    ///
50    /// Information from Layer 3 protocols used in flow determination
51    ///
52    #[derive(Clone, Copy, Debug)]
53    pub struct Info {
54        pub id: Id,
55        pub dst_ip: IpAddr,
56        pub src_ip: IpAddr,
57    }
58
59    impl Default for Info {
60        fn default() -> Self {
61            Self {
62                id: Id::default(),
63                dst_ip: std::net::IpAddr::V4(std::net::Ipv4Addr::new(0, 0, 0, 0)),
64                src_ip: std::net::IpAddr::V4(std::net::Ipv4Addr::new(0, 0, 0, 0)),
65            }
66        }
67    }
68}
69
70pub mod layer4 {
71    ///
72    /// Representation of Layer3 types that provide information for `Layer3FlowInfo`
73    ///
74    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
75    pub enum Id {
76        Tcp,
77        Udp,
78        Vxlan
79    }
80
81    impl Default for Id {
82        fn default() -> Self {
83            Self::Udp
84        }
85    }
86
87    ///
88    /// Information from Layer 3 protocols used in flow determination
89    ///
90    #[derive(Clone, Copy, Debug, Default)]
91    pub struct Info {
92        pub id: Id,
93        pub dst_port: u16,
94        pub src_port: u16
95    }
96}