MutIpv4Packet

Struct MutIpv4Packet 

Source
pub struct MutIpv4Packet<'a>(/* private fields */);

Implementations§

Source§

impl<'a> MutIpv4Packet<'a>

Source

pub const MIN_LEN: usize = 20usize

The minimum number of bytes in this type of packet. Usually equal to the header size of the protocol.

Source

pub fn new(data: &'a mut [u8]) -> Option<MutIpv4Packet<'a>>

Creates a new mutable packet based on the given backing slice. Returns None if the buffer is shorter than the minimal length of this packet.

Source

pub unsafe fn new_unchecked(data: &'a mut [u8]) -> MutIpv4Packet<'a>

Creates a new mutable packet based on the given backing slice without checking its length first. If the slice is too short, a subsequent read from a field might result in invalid memory access.

Source

pub fn as_immutable(&'a self) -> Ipv4Packet<'a>

Returns an immutable version of the same packet and backed by the same byte slice. Used to access the getters.

Source

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

Returns a mutable reference to the slice backing this packet.

Source

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

Returns a mutable slice to the part of the backing data that represents the header. This is simply everything up until min_len().

Source

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

Returns a mutable slice to the payload part of the backing data. This is simply everything after the header.

Source§

impl<'a> MutIpv4Packet<'a>

Source

pub fn set_version(&mut self, version: u4)

Source

pub fn set_header_length(&mut self, header_length: u4)

Source

pub fn set_dscp(&mut self, dscp: u6)

Source

pub fn set_ecn(&mut self, ecn: u2)

Source

pub fn set_total_length(&mut self, total_length: u16)

Source

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

Source

pub fn set_flags(&mut self, flags: Flags)

Source

pub fn set_fragment_offset(&mut self, fragment_offset: u13)

Source

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

Source

pub fn set_protocol(&mut self, protocol: Protocol)

Source

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

Source

pub fn set_source(&mut self, source: Ipv4Addr)

Source

pub fn set_destination(&mut self, destination: Ipv4Addr)

Auto Trait Implementations§

§

impl<'a> Freeze for MutIpv4Packet<'a>

§

impl<'a> RefUnwindSafe for MutIpv4Packet<'a>

§

impl<'a> Send for MutIpv4Packet<'a>

§

impl<'a> Sync for MutIpv4Packet<'a>

§

impl<'a> Unpin for MutIpv4Packet<'a>

§

impl<'a> !UnwindSafe for MutIpv4Packet<'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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.