Struct etherparse::Ipv6FragmentHeaderSlice
source · pub struct Ipv6FragmentHeaderSlice<'a> { /* private fields */ }
Expand description
Slice containing an IPv6 fragment header.
Implementations§
source§impl<'a> Ipv6FragmentHeaderSlice<'a>
impl<'a> Ipv6FragmentHeaderSlice<'a>
sourcepub fn from_slice(
slice: &'a [u8]
) -> Result<Ipv6FragmentHeaderSlice<'a>, LenError>
pub fn from_slice( slice: &'a [u8] ) -> Result<Ipv6FragmentHeaderSlice<'a>, LenError>
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 next_header(&self) -> IpNumber
pub fn next_header(&self) -> IpNumber
sourcepub fn fragment_offset(&self) -> IpFragOffset
pub fn fragment_offset(&self) -> IpFragOffset
Fragment offset
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 identification(&self) -> u32
pub fn identification(&self) -> u32
Identifcation value generated by the source
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 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§
source§impl<'a> Clone for Ipv6FragmentHeaderSlice<'a>
impl<'a> Clone for Ipv6FragmentHeaderSlice<'a>
source§fn clone(&self) -> Ipv6FragmentHeaderSlice<'a>
fn clone(&self) -> Ipv6FragmentHeaderSlice<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for Ipv6FragmentHeaderSlice<'a>
impl<'a> Debug for Ipv6FragmentHeaderSlice<'a>
source§impl<'a> PartialEq for Ipv6FragmentHeaderSlice<'a>
impl<'a> PartialEq for Ipv6FragmentHeaderSlice<'a>
source§fn eq(&self, other: &Ipv6FragmentHeaderSlice<'a>) -> bool
fn eq(&self, other: &Ipv6FragmentHeaderSlice<'a>) -> bool
self
and other
values to be equal, and is used
by ==
.