-
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.
split key data used for first fragment and data filter against this f…
…irst fragment
- Loading branch information
1 parent
0a444f8
commit 7366d8d
Showing
7 changed files
with
146 additions
and
69 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
31 changes: 31 additions & 0 deletions
31
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use libpcap_tools::FiveTuple; | ||
|
||
use crate::filters::fragmentation::two_tuple_proto_ipid::TwoTupleProtoIpid; | ||
|
||
/// Contains either FiveTuple or TwoTupleProtoIpid. | ||
/// 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 { | ||
/// Packet is either not a fragment, or the first one. | ||
NotFragmentOrFirstFragment(FiveTuple), | ||
/// Packet is a fragment, but not the first one. | ||
FragmentAfterFirst(TwoTupleProtoIpid), | ||
} | ||
|
||
impl KeyFragmentationMatching { | ||
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<&FiveTuple> { | ||
match self { | ||
KeyFragmentationMatching::FragmentAfterFirst(_) => None, | ||
KeyFragmentationMatching::NotFragmentOrFirstFragment(five_tuple) => Some(five_tuple), | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.