Struct etherparse::Ipv6FragmentHeader
source · pub struct Ipv6FragmentHeader {
pub next_header: IpNumber,
pub fragment_offset: IpFragOffset,
pub more_fragments: bool,
pub identification: u32,
}
Expand description
IPv6 fragment header.
Fields§
§next_header: IpNumber
IP protocol number specifying the next header or transport layer protocol.
See IpNumber or ip_number for a definition of the known values.
fragment_offset: IpFragOffset
Offset of the current IP payload relative to the start of the fragmented packet payload.
more_fragments: bool
True if more fragment packets will follow. False if this is the last packet.
identification: u32
Identifcation value generated by the source.
Implementations§
source§impl Ipv6FragmentHeader
impl Ipv6FragmentHeader
sourcepub const fn new(
next_header: IpNumber,
fragment_offset: IpFragOffset,
more_fragments: bool,
identification: u32,
) -> Ipv6FragmentHeader
pub const fn new( next_header: IpNumber, fragment_offset: IpFragOffset, more_fragments: bool, identification: u32, ) -> Ipv6FragmentHeader
Create a new fragmentation header with the given parameters.
Note that the fragment_offset
can only support values between 0 and 0x1fff (inclusive).
sourcepub fn from_slice(slice: &[u8]) -> Result<(Ipv6FragmentHeader, &[u8]), LenError>
pub fn from_slice(slice: &[u8]) -> Result<(Ipv6FragmentHeader, &[u8]), LenError>
Read an Ipv6FragmentHeader from a slice and return the header & unused parts of the slice.
sourcepub fn read<T: Read + Seek + Sized>(
reader: &mut T,
) -> Result<Ipv6FragmentHeader, Error>
Available on crate feature std
only.
pub fn read<T: Read + Seek + Sized>( reader: &mut T, ) -> Result<Ipv6FragmentHeader, Error>
std
only.Read an fragment header from the current reader position.
sourcepub fn read_limited<T: Read + Seek + Sized>(
reader: &mut LimitedReader<T>,
) -> Result<Ipv6FragmentHeader, LimitedReadError>
Available on crate feature std
only.
pub fn read_limited<T: Read + Seek + Sized>( reader: &mut LimitedReader<T>, ) -> Result<Ipv6FragmentHeader, LimitedReadError>
std
only.Read an fragment header from the current reader position.
sourcepub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), Error>
Available on crate feature std
only.
pub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), Error>
std
only.Writes a given IPv6 fragment header to the current position.
sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Length of the header in bytes.
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::{Ipv6FragmentHeader, ip_number::UDP};
// offset 0 & no more fragments result in an unfragmented payload
{
let header = Ipv6FragmentHeader::new(UDP, 0.try_into().unwrap(), false, 123);
assert!(false == header.is_fragmenting_payload());
}
// offset 0 & but more fragments will come -> fragmented
{
let header = Ipv6FragmentHeader::new(UDP, 0.try_into().unwrap(), true, 123);
assert!(header.is_fragmenting_payload());
}
// offset non zero & no more fragments will come -> fragmented
{
let header = Ipv6FragmentHeader::new(UDP, 1.try_into().unwrap(), false, 123);
assert!(header.is_fragmenting_payload());
}
Trait Implementations§
source§impl Clone for Ipv6FragmentHeader
impl Clone for Ipv6FragmentHeader
source§fn clone(&self) -> Ipv6FragmentHeader
fn clone(&self) -> Ipv6FragmentHeader
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Ipv6FragmentHeader
impl Debug for Ipv6FragmentHeader
source§impl PartialEq for Ipv6FragmentHeader
impl PartialEq for Ipv6FragmentHeader
impl Eq for Ipv6FragmentHeader
impl StructuralPartialEq for Ipv6FragmentHeader
Auto Trait Implementations§
impl Freeze for Ipv6FragmentHeader
impl RefUnwindSafe for Ipv6FragmentHeader
impl Send for Ipv6FragmentHeader
impl Sync for Ipv6FragmentHeader
impl Unpin for Ipv6FragmentHeader
impl UnwindSafe for Ipv6FragmentHeader
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)