Struct IPv4Writer

Source
pub struct IPv4Writer<'a> {
    pub bytes: &'a mut [u8],
}
Expand description

Writes IPv4 header fields.

Fields§

§bytes: &'a mut [u8]

Implementations§

Source§

impl<'a> IPv4Writer<'a>

Source

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

Creates a new IPv4Writer from the given slice.

Source

pub fn header_len(&self) -> usize

Returns the actual header length in bytes.

Source

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

Sets the version field.

Indicates the IP version number. Should be set to 4.

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.

Should include the entire packet (header and payload).

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 IPv4Writer<'a>

§

impl<'a> RefUnwindSafe for IPv4Writer<'a>

§

impl<'a> Send for IPv4Writer<'a>

§

impl<'a> Sync for IPv4Writer<'a>

§

impl<'a> Unpin for IPv4Writer<'a>

§

impl<'a> !UnwindSafe for IPv4Writer<'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.