-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve fragmentation filtering logic
- Loading branch information
1 parent
bd0215f
commit 4b11d7f
Showing
5 changed files
with
117 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 5 additions & 21 deletions
26
pcap-rewrite/src/filters/fragmentation/key_fragmentation_matching.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,13 @@ | ||
use crate::filters::fragmentation::two_tuple_proto_ipid::TwoTupleProtoIpid; | ||
|
||
/// Contains either FiveTuple or TwoTupleProtoIpid. | ||
/// Contains either FiveTuple or TwoTupleProtoIpid or both. | ||
/// It is used to store data that will be matched against the data of the first fragment. | ||
#[derive(Debug, PartialEq, Eq, Hash, Clone)] | ||
pub enum KeyFragmentationMatching<Key> { | ||
/// Packet is either not a fragment, or the first one. | ||
NotFragmentOrFirstFragment(Key), | ||
/// Packet is not a fragment. | ||
NotFragment(Key), | ||
/// Packet is a first fragment. | ||
FirstFragment(TwoTupleProtoIpid, Key), | ||
/// Packet is a fragment, but not the first one. | ||
FragmentAfterFirst(TwoTupleProtoIpid), | ||
} | ||
|
||
impl<Key> KeyFragmentationMatching<Key> { | ||
pub fn get_two_tuple_proto_ipid_option(&self) -> Option<&TwoTupleProtoIpid> { | ||
match self { | ||
KeyFragmentationMatching::FragmentAfterFirst(two_tuple_proto_ipid) => { | ||
Some(two_tuple_proto_ipid) | ||
} | ||
KeyFragmentationMatching::NotFragmentOrFirstFragment(_) => None, | ||
} | ||
} | ||
|
||
pub fn get_five_tuple_option(&self) -> Option<&Key> { | ||
match self { | ||
KeyFragmentationMatching::FragmentAfterFirst(_) => None, | ||
KeyFragmentationMatching::NotFragmentOrFirstFragment(key) => Some(key), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters