diff options
| author | luwenpeng <[email protected]> | 2023-09-27 17:54:40 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2023-09-27 17:54:50 +0800 |
| commit | e0c7dfa5bd9d424249b87ec07d377e94d49d139a (patch) | |
| tree | 1d9bab0ed3b366ce3ff9ef0d9190162546521e7f /src/protocol/mpls.rs | |
| parent | 521fbe5464652d509e3290fd336c87ba28fa24c0 (diff) | |
[optimize] Packet Decode
1. Add a macro to obtain Packet’s encapsulation information (the returned data is an immutable reference to Packet)
* get_innermost_special_encapsulation!()
* get_outermost_special_encapsulation!()
Example: let icmp_encapsulation : Option<&Encapsulation> = get_innermost_special_encapsulation!(&Packet, ICMP);
Example: let l4_encapsulation : Option<&Encapsulation> = get_innermost_special_encapsulation!(&Packet, TCP | UDP);
2. Clean up the Clone/Copy Trait of PacketDecode to avoid memory copies caused by improper use by users.
Diffstat (limited to 'src/protocol/mpls.rs')
| -rw-r--r-- | src/protocol/mpls.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/protocol/mpls.rs b/src/protocol/mpls.rs index add686d..2f441f9 100644 --- a/src/protocol/mpls.rs +++ b/src/protocol/mpls.rs @@ -9,7 +9,7 @@ use nom::IResult; * Struct ******************************************************************************/ -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq)] pub struct MPLSHeader { pub label: u32, pub experimental: u8, @@ -17,8 +17,8 @@ pub struct MPLSHeader { pub ttl: u8, } -#[derive(Clone, Debug, PartialEq, Eq)] // Ethernet pseudowire (PW) https://tools.ietf.org/html/rfc4448#section-3.1 +#[derive(Debug, PartialEq)] pub struct PWEthHeader { pub control_word: u32, } |
