pub struct MutableIpv4Packet<'a> { /* private fields */ }Expand description
Represents a mutable IPv4 packet.
Implementations§
Source§impl<'a> MutableIpv4Packet<'a>
impl<'a> MutableIpv4Packet<'a>
Sourcepub fn new_unchecked(buffer: &'a mut [u8]) -> Self
pub fn new_unchecked(buffer: &'a mut [u8]) -> Self
Create a mutable packet without validating the header fields.
Sourcepub fn checksum_mode(&self) -> ChecksumMode
pub fn checksum_mode(&self) -> ChecksumMode
Returns the current checksum recalculation mode.
Sourcepub fn set_checksum_mode(&mut self, mode: ChecksumMode)
pub fn set_checksum_mode(&mut self, mode: ChecksumMode)
Updates the checksum recalculation mode.
Sourcepub fn enable_auto_checksum(&mut self)
pub fn enable_auto_checksum(&mut self)
Enables automatic checksum recalculation.
Sourcepub fn disable_auto_checksum(&mut self)
pub fn disable_auto_checksum(&mut self)
Disables automatic checksum recalculation.
Sourcepub fn is_checksum_dirty(&self) -> bool
pub fn is_checksum_dirty(&self) -> bool
Returns true when the checksum must be recomputed before serialization.
Sourcepub fn mark_checksum_dirty(&mut self)
pub fn mark_checksum_dirty(&mut self)
Marks the checksum as stale and triggers recomputation when automatic mode is enabled.
Sourcepub fn recompute_checksum(&mut self) -> Option<u16>
pub fn recompute_checksum(&mut self) -> Option<u16>
Recomputes the IPv4 header checksum using the current buffer contents.
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 based on the total length field.
Sourcepub fn get_version(&self) -> u8
pub fn get_version(&self) -> u8
Retrieve the version field.
Sourcepub fn set_version(&mut self, version: u8)
pub fn set_version(&mut self, version: u8)
Update the version field.
Sourcepub fn get_header_length(&self) -> u8
pub fn get_header_length(&self) -> u8
Retrieve the header length in 32-bit words.
Sourcepub fn set_header_length(&mut self, ihl: u8)
pub fn set_header_length(&mut self, ihl: u8)
Update the header length in 32-bit words.
Sourcepub fn get_total_length(&self) -> u16
pub fn get_total_length(&self) -> u16
Retrieve the total length field.
Sourcepub fn set_total_length(&mut self, len: u16)
pub fn set_total_length(&mut self, len: u16)
Update the total length field.
Sourcepub fn get_identification(&self) -> u16
pub fn get_identification(&self) -> u16
Retrieve the identification field.
Sourcepub fn set_identification(&mut self, id: u16)
pub fn set_identification(&mut self, id: u16)
Update the identification field.
Sourcepub fn get_fragment_offset(&self) -> u16
pub fn get_fragment_offset(&self) -> u16
Retrieve the fragment offset field.
Sourcepub fn set_fragment_offset(&mut self, offset: u16)
pub fn set_fragment_offset(&mut self, offset: u16)
Update the fragment offset field.
Sourcepub fn get_next_level_protocol(&self) -> IpNextProtocol
pub fn get_next_level_protocol(&self) -> IpNextProtocol
Retrieve the next-level protocol field.
Sourcepub fn set_next_level_protocol(&mut self, proto: IpNextProtocol)
pub fn set_next_level_protocol(&mut self, proto: IpNextProtocol)
Update the next-level protocol field.
Sourcepub fn get_checksum(&self) -> u16
pub fn get_checksum(&self) -> u16
Retrieve the checksum field.
Sourcepub fn set_checksum(&mut self, checksum: u16)
pub fn set_checksum(&mut self, checksum: u16)
Update the checksum field.
Sourcepub fn get_source(&self) -> Ipv4Addr
pub fn get_source(&self) -> Ipv4Addr
Retrieve the source address.
Sourcepub fn set_source(&mut self, addr: Ipv4Addr)
pub fn set_source(&mut self, addr: Ipv4Addr)
Update the source address.
Sourcepub fn get_destination(&self) -> Ipv4Addr
pub fn get_destination(&self) -> Ipv4Addr
Retrieve the destination address.
Sourcepub fn set_destination(&mut self, addr: Ipv4Addr)
pub fn set_destination(&mut self, addr: Ipv4Addr)
Update the destination address.