pub struct TcpReassembler { /* private fields */ }Expand description
TCP stream reassembly engine using a BTreeMap for out-of-order segment management.
Mirrors Wireshark’s reassemble.c logic: segments are keyed by absolute TCP sequence number. In-order segments are immediately appended to the contiguous reassembled buffer, while out-of-order segments are cached until gaps are filled.
Implementations§
Source§impl TcpReassembler
impl TcpReassembler
Sourcepub fn initialize(&mut self, initial_seq: u32)
pub fn initialize(&mut self, initial_seq: u32)
Initialize with the first observed sequence number (ISN + 1 for data after SYN).
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Whether this reassembler has been initialized.
Sourcepub fn reassembled_data(&self) -> &[u8] ⓘ
pub fn reassembled_data(&self) -> &[u8] ⓘ
Get the contiguous reassembled data if it’s in memory.
Returns None if the data has been spilled to disk.
Use [read_reassembled] for guaranteed access regardless of storage location.
Sourcepub fn read_reassembled(&self) -> Result<Vec<u8>>
pub fn read_reassembled(&self) -> Result<Vec<u8>>
Read the reassembled data regardless of storage location.
Works for both in-memory and spilled-to-disk data.
Sourcepub fn drain_reassembled(&mut self) -> Result<Vec<u8>>
pub fn drain_reassembled(&mut self) -> Result<Vec<u8>>
Drain and return the reassembled data, resetting the buffer.
Sourcepub fn buffered_bytes(&self) -> usize
pub fn buffered_bytes(&self) -> usize
Total bytes in the out-of-order buffer.
Sourcepub fn fragment_count(&self) -> usize
pub fn fragment_count(&self) -> usize
Number of out-of-order fragments.
Sourcepub fn in_memory_bytes(&self) -> usize
pub fn in_memory_bytes(&self) -> usize
Total bytes currently held in memory (reassembled + OOO segments).
Sourcepub fn spill(&mut self, spill_dir: Option<&Path>) -> Result<usize>
pub fn spill(&mut self, spill_dir: Option<&Path>) -> Result<usize>
Spill reassembled data to a temporary file on disk.
Returns the number of bytes freed from memory.
Sourcepub fn is_spilled(&self) -> bool
pub fn is_spilled(&self) -> bool
Whether the reassembled data has been spilled to disk.
Sourcepub fn process_segment(
&mut self,
seq: u32,
payload: &[u8],
config: &FlowConfig,
) -> Result<ReassemblyAction, FlowError>
pub fn process_segment( &mut self, seq: u32, payload: &[u8], config: &FlowConfig, ) -> Result<ReassemblyAction, FlowError>
Process an incoming TCP segment.
Handles in-order, out-of-order, overlapping, and duplicate segments according to the algorithm described in the architectural blueprint.
Trait Implementations§
Source§impl Debug for TcpReassembler
impl Debug for TcpReassembler
Auto Trait Implementations§
impl Freeze for TcpReassembler
impl RefUnwindSafe for TcpReassembler
impl Send for TcpReassembler
impl Sync for TcpReassembler
impl Unpin for TcpReassembler
impl UnsafeUnpin for TcpReassembler
impl UnwindSafe for TcpReassembler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more