pub struct Ipv4PacketMut<'a> { /* private fields */ }Expand description
A structurally validated mutable RFC 791 packet view.
Implementations§
Source§impl<'a> Ipv4PacketMut<'a>
impl<'a> Ipv4PacketMut<'a>
Sourcepub fn icmpv4_mut(&mut self) -> Result<Option<Icmpv4MessageMut<'_>>, ParseError>
pub fn icmpv4_mut(&mut self) -> Result<Option<Icmpv4MessageMut<'_>>, ParseError>
Parses mutable ICMPv4 only when this is an unfragmented ICMP packet.
Sourcepub fn udp_mut(&mut self) -> Result<Option<UdpDatagramMut<'_>>, ParseError>
pub fn udp_mut(&mut self) -> Result<Option<UdpDatagramMut<'_>>, ParseError>
Parses mutable UDP only when this is an unfragmented UDP packet.
Sourcepub fn tcp_mut(&mut self) -> Result<Option<TcpSegmentMut<'_>>, ParseError>
pub fn tcp_mut(&mut self) -> Result<Option<TcpSegmentMut<'_>>, ParseError>
Parses mutable TCP only when this is an unfragmented TCP packet.
Source§impl<'a> Ipv4PacketMut<'a>
impl<'a> Ipv4PacketMut<'a>
Sourcepub fn parse(bytes: &'a mut [u8]) -> Result<Self, ParseError>
pub fn parse(bytes: &'a mut [u8]) -> Result<Self, ParseError>
Validates RFC 791 structural bounds and excludes trailing bytes.
Sourcepub fn total_length(&self) -> u16
pub fn total_length(&self) -> u16
Returns the RFC 791 total-length field.
Sourcepub fn identification(&self) -> u16
pub fn identification(&self) -> u16
Returns the identification field.
Sourcepub fn flags_fragment_offset(&self) -> u16
pub fn flags_fragment_offset(&self) -> u16
Returns raw flags and fragment offset.
Sourcepub fn protocol(&self) -> Ipv4Protocol
pub fn protocol(&self) -> Ipv4Protocol
Returns the protocol value, including unknown values.
Sourcepub fn header_checksum(&self) -> u16
pub fn header_checksum(&self) -> u16
Returns the encoded header checksum.
Sourcepub fn source(&self) -> Ipv4Address
pub fn source(&self) -> Ipv4Address
Returns the source address.
Sourcepub fn destination(&self) -> Ipv4Address
pub fn destination(&self) -> Ipv4Address
Returns the destination address.
Sourcepub fn options_mut(&mut self) -> &mut [u8] ⓘ
pub fn options_mut(&mut self) -> &mut [u8] ⓘ
Returns mutable options; this does not update the header checksum.
Sourcepub fn payload_mut(&mut self) -> &mut [u8] ⓘ
pub fn payload_mut(&mut self) -> &mut [u8] ⓘ
Returns mutable payload bytes, which are not header-checksum covered.
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Returns all represented bytes mutably.
Sourcepub fn set_dscp_ecn(&mut self, v: u8)
pub fn set_dscp_ecn(&mut self, v: u8)
Replaces DSCP/ECN without updating the checksum.
Sourcepub fn set_identification(&mut self, v: u16)
pub fn set_identification(&mut self, v: u16)
Replaces identification without updating the checksum.
Sourcepub fn set_flags_fragment_offset(&mut self, v: u16)
pub fn set_flags_fragment_offset(&mut self, v: u16)
Replaces raw flags and fragment offset without updating the checksum.
Sourcepub fn set_protocol(&mut self, v: Ipv4Protocol)
pub fn set_protocol(&mut self, v: Ipv4Protocol)
Replaces protocol without updating the checksum.
Sourcepub fn set_header_checksum(&mut self, v: u16)
pub fn set_header_checksum(&mut self, v: u16)
Replaces the encoded checksum directly.
Sourcepub fn set_source(&mut self, v: Ipv4Address)
pub fn set_source(&mut self, v: Ipv4Address)
Replaces source without updating the checksum.
Sourcepub fn set_destination(&mut self, v: Ipv4Address)
pub fn set_destination(&mut self, v: Ipv4Address)
Replaces destination without updating the checksum.
Sourcepub fn update_header_checksum(&mut self)
pub fn update_header_checksum(&mut self)
Recomputes and writes the checksum across the full IHL, including options.
Sourcepub fn checksum_is_valid(&self) -> bool
pub fn checksum_is_valid(&self) -> bool
Checks the current checksum across the full IHL.