pub struct IpDefragPool<Timestamp = (), CustomChannelId = ()>where
Timestamp: Sized + Debug + Clone,
CustomChannelId: Sized + Debug + Clone + Hash + Eq + PartialEq,{ /* private fields */ }std only.Expand description
Pool of buffers to reconstruct multiple fragmented IP packets in parallel (re-uses buffers to minimize allocations).
It differentiates the packets based on their inner & outer vlan as well as source and destination ip address and allows the user to add their own custom “channel id” type to further differentiate different streams. The custom channel id can be used to
§This implementation is NOT safe against “Out of Memory” attacks
If you use the IpDefragPool in an untrusted environment an attacker could
cause an “out of memory error” by opening up multiple parallel TP streams,
never ending them and filling them up with as much data as possible.
Mitigations will hopefully be offered in future versions but if you have
take care right now you can still use IpDefragBuf directly and implement the
connection handling and mitigation yourself.
Implementations§
Source§impl<Timestamp, CustomChannelId> IpDefragPool<Timestamp, CustomChannelId>
impl<Timestamp, CustomChannelId> IpDefragPool<Timestamp, CustomChannelId>
pub fn new() -> IpDefragPool<Timestamp, CustomChannelId>
Sourcepub fn process_sliced_packet(
&mut self,
slice: &SlicedPacket<'_>,
timestamp: Timestamp,
channel_id: CustomChannelId,
) -> Result<Option<IpDefragPayloadVec>, IpDefragError>
pub fn process_sliced_packet( &mut self, slice: &SlicedPacket<'_>, timestamp: Timestamp, channel_id: CustomChannelId, ) -> Result<Option<IpDefragPayloadVec>, IpDefragError>
Add data from a sliced packet.
Sourcepub fn return_buf(&mut self, buf: IpDefragPayloadVec)
pub fn return_buf(&mut self, buf: IpDefragPayloadVec)
Returns a buffer to the pool so it can be re-used.
Trait Implementations§
Source§impl<Timestamp, CustomChannelId> Clone for IpDefragPool<Timestamp, CustomChannelId>
impl<Timestamp, CustomChannelId> Clone for IpDefragPool<Timestamp, CustomChannelId>
Source§fn clone(&self) -> IpDefragPool<Timestamp, CustomChannelId>
fn clone(&self) -> IpDefragPool<Timestamp, CustomChannelId>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more