Skip to main content

Ipv4PacketMut

Struct Ipv4PacketMut 

Source
pub struct Ipv4PacketMut<'a> { /* private fields */ }
Expand description

A structurally validated mutable RFC 791 packet view.

Implementations§

Source§

impl<'a> Ipv4PacketMut<'a>

Source

pub fn icmpv4_mut(&mut self) -> Result<Option<Icmpv4MessageMut<'_>>, ParseError>

Parses mutable ICMPv4 only when this is an unfragmented ICMP packet.

Source

pub fn udp_mut(&mut self) -> Result<Option<UdpDatagramMut<'_>>, ParseError>

Parses mutable UDP only when this is an unfragmented UDP packet.

Source

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>

Source

pub fn parse(bytes: &'a mut [u8]) -> Result<Self, ParseError>

Validates RFC 791 structural bounds and excludes trailing bytes.

Source

pub fn dscp_ecn(&self) -> u8

Returns the combined DSCP/ECN octet.

Source

pub fn total_length(&self) -> u16

Returns the RFC 791 total-length field.

Source

pub fn identification(&self) -> u16

Returns the identification field.

Source

pub fn flags_fragment_offset(&self) -> u16

Returns raw flags and fragment offset.

Source

pub fn ttl(&self) -> u8

Returns the time-to-live field.

Source

pub fn protocol(&self) -> Ipv4Protocol

Returns the protocol value, including unknown values.

Source

pub fn header_checksum(&self) -> u16

Returns the encoded header checksum.

Source

pub fn source(&self) -> Ipv4Address

Returns the source address.

Source

pub fn destination(&self) -> Ipv4Address

Returns the destination address.

Source

pub fn options(&self) -> &[u8]

Returns option bytes included by IHL.

Source

pub fn payload(&self) -> &[u8]

Returns payload bytes, which are not header-checksum covered.

Source

pub fn options_mut(&mut self) -> &mut [u8] ⓘ

Returns mutable options; this does not update the header checksum.

Source

pub fn payload_mut(&mut self) -> &mut [u8] ⓘ

Returns mutable payload bytes, which are not header-checksum covered.

Source

pub fn as_bytes(&self) -> &[u8]

Returns the represented packet bytes.

Source

pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ

Returns all represented bytes mutably.

Source

pub fn set_dscp_ecn(&mut self, v: u8)

Replaces DSCP/ECN without updating the checksum.

Source

pub fn set_identification(&mut self, v: u16)

Replaces identification without updating the checksum.

Source

pub fn set_flags_fragment_offset(&mut self, v: u16)

Replaces raw flags and fragment offset without updating the checksum.

Source

pub fn set_ttl(&mut self, v: u8)

Replaces TTL without updating the checksum.

Source

pub fn set_protocol(&mut self, v: Ipv4Protocol)

Replaces protocol without updating the checksum.

Source

pub fn set_header_checksum(&mut self, v: u16)

Replaces the encoded checksum directly.

Source

pub fn set_source(&mut self, v: Ipv4Address)

Replaces source without updating the checksum.

Source

pub fn set_destination(&mut self, v: Ipv4Address)

Replaces destination without updating the checksum.

Source

pub fn update_header_checksum(&mut self)

Recomputes and writes the checksum across the full IHL, including options.

Source

pub fn checksum_is_valid(&self) -> bool

Checks the current checksum across the full IHL.

Trait Implementations§

Source§

impl<'a> Debug for Ipv4PacketMut<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for Ipv4PacketMut<'a>

Source§

impl<'a> PartialEq for Ipv4PacketMut<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Ipv4PacketMut<'a>

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for Ipv4PacketMut<'a>

§

impl<'a> Freeze for Ipv4PacketMut<'a>

§

impl<'a> RefUnwindSafe for Ipv4PacketMut<'a>

§

impl<'a> Send for Ipv4PacketMut<'a>

§

impl<'a> Sync for Ipv4PacketMut<'a>

§

impl<'a> Unpin for Ipv4PacketMut<'a>

§

impl<'a> UnsafeUnpin for Ipv4PacketMut<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.