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

Slice containing an IPv6 fragment header.

Implementations§

source§

impl<'a> Ipv6FragmentHeaderSlice<'a>

source

pub fn from_slice( slice: &'a [u8] ) -> Result<Ipv6FragmentHeaderSlice<'a>, LenError>

Creates a hop by hop header slice from a slice.

source

pub unsafe fn from_slice_unchecked( slice: &'a [u8] ) -> Ipv6FragmentHeaderSlice<'a>

Creates a hop by hop header slice from a slice (assumes slice size & content was validated before).

§Safety

This function assumes that the passed slice has at least the length of 8. If a slice with length less then 8 is passed to this function the behavior will be undefined.

source

pub fn slice(&self) -> &'a [u8]

Returns the slice containing the ipv6 fragment header.

source

pub fn next_header(&self) -> IpNumber

Returns the IP protocol number of the next header.

See IpNumber or ip_number for a definition of the known values.

source

pub fn fragment_offset(&self) -> IpFragOffset

Fragment offset

source

pub fn more_fragments(&self) -> bool

True if more fragment packets will follow. False if this is the last packet.

source

pub fn identification(&self) -> u32

Identifcation value generated by the source

source

pub fn is_fragmenting_payload(&self) -> bool

Checks if the fragment header actually fragments the packet.

Returns false if the fragment offset is 0 and the more flag is not set. Otherwise returns true.

RFC8200 explicitly states that fragment headers that don’t fragment the packet payload are allowed. See the following quote from RFC8200 page 32:

Revised the text to handle the case of fragments that are whole datagrams (i.e., both the Fragment Offset field and the M flag are zero). If received, they should be processed as a reassembled packet. Any other fragments that match should be processed independently. The Fragment creation process was modified to not create whole datagram fragments (Fragment Offset field and the M flag are zero). See RFC6946 and RFC8021 for more information.“

use etherparse::Ipv6FragmentHeaderSlice;

{
    let slice = Ipv6FragmentHeaderSlice::from_slice(&[
        0, 0, 0, 0, // offset 0 & more_fragments not set
        1, 2, 3, 4,
    ]).unwrap();
    assert!(false == slice.is_fragmenting_payload());
}

{
    let slice = Ipv6FragmentHeaderSlice::from_slice(&[
        0, 0, 0, 0b1000_0000u8, // more_fragments set
        1, 2, 3, 4,
    ]).unwrap();
    assert!(slice.is_fragmenting_payload());
}

{
    let slice = Ipv6FragmentHeaderSlice::from_slice(&[
        0, 0, 1, 0, // non zero offset
        1, 2, 3, 4,
    ]).unwrap();
    assert!(slice.is_fragmenting_payload());
}
source

pub fn to_header(&self) -> Ipv6FragmentHeader

Decode some of the fields and copy the results to a Ipv6FragmentHeader struct.

Trait Implementations§

source§

impl<'a> Clone for Ipv6FragmentHeaderSlice<'a>

source§

fn clone(&self) -> Ipv6FragmentHeaderSlice<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for Ipv6FragmentHeaderSlice<'a>

source§

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

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

impl<'a> PartialEq for Ipv6FragmentHeaderSlice<'a>

source§

fn eq(&self, other: &Ipv6FragmentHeaderSlice<'a>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> Eq for Ipv6FragmentHeaderSlice<'a>

source§

impl<'a> StructuralPartialEq for Ipv6FragmentHeaderSlice<'a>

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.