Struct zero_packet::network::ipv4::IPv4Builder

source ·
pub struct IPv4Builder<'a> {
    pub data: &'a mut [u8],
}
Expand description

Represents an IPv4 packet.

Fields§

§data: &'a mut [u8]

Implementations§

source§

impl<'a> IPv4Builder<'a>

source

pub fn new(data: &'a mut [u8]) -> Result<Self, &'static str>

Creates a new IPv4Packet from the given data slice. Returns an error if the data Slice is too short to contain an IPv4 header.

source

pub fn header_length(&self) -> usize

Returns the actual header length in bytes.

source

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

Sets the version field.

source

pub fn set_ihl(&mut self, ihl: u8)

Sets the IHL field.

source

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

Sets the DSCP field.

source

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

Sets the ECN field.

source

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

Sets the total length field.

source

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

Sets the identification field.

source

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

Sets the flags field.

source

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

Sets the fragment offset field.

source

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

Sets the TTL field.

source

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

Sets the protocol field.

source

pub fn set_src_ip(&mut self, src_ip: &[u8; 4])

Sets the source IP address field.

source

pub fn set_dest_ip(&mut self, dest_ip: &[u8; 4])

Sets the destination IP address field.

source

pub fn set_checksum(&mut self)

Calculates the checksum field.

Only includes the header.

Auto Trait Implementations§

§

impl<'a> Freeze for IPv4Builder<'a>

§

impl<'a> RefUnwindSafe for IPv4Builder<'a>

§

impl<'a> Send for IPv4Builder<'a>

§

impl<'a> Sync for IPv4Builder<'a>

§

impl<'a> Unpin for IPv4Builder<'a>

§

impl<'a> !UnwindSafe for IPv4Builder<'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>,

§

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>,

§

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.