Struct etherparse::Ipv6FragmentHeaderSlice
source · [−]pub struct Ipv6FragmentHeaderSlice<'a> { /* private fields */ }
Expand description
Slice containing an IPv6 fragment header.
Implementations
sourceimpl<'a> Ipv6FragmentHeaderSlice<'a>
impl<'a> Ipv6FragmentHeaderSlice<'a>
sourcepub fn from_slice(
slice: &'a [u8]
) -> Result<Ipv6FragmentHeaderSlice<'a>, ReadError>
pub fn from_slice(
slice: &'a [u8]
) -> Result<Ipv6FragmentHeaderSlice<'a>, ReadError>
Creates a hop by hop header slice from a slice.
sourcepub unsafe fn from_slice_unchecked(
slice: &'a [u8]
) -> Ipv6FragmentHeaderSlice<'a>
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.
sourcepub fn slice(&self) -> &'a [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn slice(&self) -> &'a [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
Returns the slice containing the ipv6 fragment header.
sourcepub fn next_header(&self) -> u8
pub fn next_header(&self) -> u8
sourcepub fn fragment_offset(&self) -> u16
pub fn fragment_offset(&self) -> u16
Fragment offset in 8 octets.
Note: In the header only 13 bits are used, so the allowed range of the value is between 0 and 0x1FFF (inclusive).
sourcepub fn more_fragments(&self) -> bool
pub fn more_fragments(&self) -> bool
True if more fragment packets will follow. False if this is the last packet.
sourcepub fn is_fragmenting_payload(&self) -> bool
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());
}
sourcepub fn identification(&self) -> u32
pub fn identification(&self) -> u32
Identifcation value generated by the source
sourcepub fn to_header(&self) -> Ipv6FragmentHeader
pub fn to_header(&self) -> Ipv6FragmentHeader
Decode some of the fields and copy the results to a Ipv6FragmentHeader struct.
Trait Implementations
sourceimpl<'a> Clone for Ipv6FragmentHeaderSlice<'a>
impl<'a> Clone for Ipv6FragmentHeaderSlice<'a>
sourcefn clone(&self) -> Ipv6FragmentHeaderSlice<'a>
fn clone(&self) -> Ipv6FragmentHeaderSlice<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'a> Debug for Ipv6FragmentHeaderSlice<'a>
impl<'a> Debug for Ipv6FragmentHeaderSlice<'a>
sourceimpl<'a> PartialEq<Ipv6FragmentHeaderSlice<'a>> for Ipv6FragmentHeaderSlice<'a>
impl<'a> PartialEq<Ipv6FragmentHeaderSlice<'a>> for Ipv6FragmentHeaderSlice<'a>
sourcefn eq(&self, other: &Ipv6FragmentHeaderSlice<'a>) -> bool
fn eq(&self, other: &Ipv6FragmentHeaderSlice<'a>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Ipv6FragmentHeaderSlice<'a>) -> bool
fn ne(&self, other: &Ipv6FragmentHeaderSlice<'a>) -> bool
This method tests for !=
.
impl<'a> Eq for Ipv6FragmentHeaderSlice<'a>
impl<'a> StructuralEq for Ipv6FragmentHeaderSlice<'a>
impl<'a> StructuralPartialEq for Ipv6FragmentHeaderSlice<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for Ipv6FragmentHeaderSlice<'a>
impl<'a> Send for Ipv6FragmentHeaderSlice<'a>
impl<'a> Sync for Ipv6FragmentHeaderSlice<'a>
impl<'a> Unpin for Ipv6FragmentHeaderSlice<'a>
impl<'a> UnwindSafe for Ipv6FragmentHeaderSlice<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more