pub struct MutableTcpPacket<'a> { /* private fields */ }Expand description
Represents a mutable TCP packet.
Implementations§
Source§impl<'a> MutableTcpPacket<'a>
impl<'a> MutableTcpPacket<'a>
Sourcepub fn new_unchecked(buffer: &'a mut [u8]) -> Self
pub fn new_unchecked(buffer: &'a mut [u8]) -> Self
Create a packet without validating the header fields.
Sourcepub fn checksum_mode(&self) -> ChecksumMode
pub fn checksum_mode(&self) -> ChecksumMode
Returns the checksum recalculation mode for the packet.
Sourcepub fn set_checksum_mode(&mut self, mode: ChecksumMode)
pub fn set_checksum_mode(&mut self, mode: ChecksumMode)
Updates how checksum recalculation should be handled.
Sourcepub fn enable_auto_checksum(&mut self)
pub fn enable_auto_checksum(&mut self)
Enables automatic checksum recomputation after field mutations.
Sourcepub fn disable_auto_checksum(&mut self)
pub fn disable_auto_checksum(&mut self)
Disables automatic checksum recomputation.
Sourcepub fn is_checksum_dirty(&self) -> bool
pub fn is_checksum_dirty(&self) -> bool
Returns true if the checksum needs to be updated before serialization.
Sourcepub fn mark_checksum_dirty(&mut self)
pub fn mark_checksum_dirty(&mut self)
Marks the checksum as dirty and recomputes it when automatic mode is enabled.
Sourcepub fn set_checksum_context(&mut self, context: TransportChecksumContext)
pub fn set_checksum_context(&mut self, context: TransportChecksumContext)
Configures the pseudo-header context required for checksum calculation.
Sourcepub fn set_ipv4_checksum_context(
&mut self,
source: Ipv4Addr,
destination: Ipv4Addr,
)
pub fn set_ipv4_checksum_context( &mut self, source: Ipv4Addr, destination: Ipv4Addr, )
Sets an IPv4 pseudo-header context for checksum calculation.
Sourcepub fn set_ipv6_checksum_context(
&mut self,
source: Ipv6Addr,
destination: Ipv6Addr,
)
pub fn set_ipv6_checksum_context( &mut self, source: Ipv6Addr, destination: Ipv6Addr, )
Sets an IPv6 pseudo-header context for checksum calculation.
Sourcepub fn clear_checksum_context(&mut self)
pub fn clear_checksum_context(&mut self)
Clears the configured pseudo-header context.
Sourcepub fn checksum_context(&self) -> Option<TransportChecksumContext>
pub fn checksum_context(&self) -> Option<TransportChecksumContext>
Returns the currently configured pseudo-header context.
Sourcepub fn recompute_checksum(&mut self) -> Option<u16>
pub fn recompute_checksum(&mut self) -> Option<u16>
Recomputes the checksum using the configured pseudo-header context.
Sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Returns the header length in bytes.
Sourcepub fn payload_len(&self) -> usize
pub fn payload_len(&self) -> usize
Returns the payload length of the packet.