Struct etherparse::LaxIpv6Slice
source · pub struct LaxIpv6Slice<'a> { /* private fields */ }
Expand description
Slice containing laxly separated IPv6 headers & payload.
Compared to the normal Ipv6Slice
this slice allows the
payload to incomplete/cut off and errors to be present in
the IpPayload.
The main usecases for “laxly” parsed slices are are:
- Parsing packets that have been cut off. This is, for example, useful to parse packets returned via ICMP as these usually only contain the start.
- Parsing packets where the
total_len
(for IPv4) have not yet been set. This can be useful when parsing packets which have been recorded in a layer before the length field was set (e.g. before the operating system set the length fields).
Implementations§
source§impl<'a> LaxIpv6Slice<'a>
impl<'a> LaxIpv6Slice<'a>
sourcepub fn from_slice(
slice: &'a [u8]
) -> Result<(LaxIpv6Slice<'a>, Option<(HeaderSliceError, Layer)>), HeaderSliceError>
pub fn from_slice( slice: &'a [u8] ) -> Result<(LaxIpv6Slice<'a>, Option<(HeaderSliceError, Layer)>), HeaderSliceError>
Seperate an IPv6 header (+ extensions) & the payload from the given slice with less strict length checks (useful for cut off packet or for packets with unset length fields).
If you want to only receive correct IpPayloads use crate::Ipv4Slice::from_slice
instead.
The main usecases for this functions are:
- Parsing packets that have been cut off. This is, for example, useful to parse packets returned via ICMP as these usually only contain the start.
- Parsing packets where the
payload_length
(in the IPv6 header) has not yet been set. This can be useful when parsing packets which have been recorded in a layer before the length field was set (e.g. before the operating system set the length fields).
§Differences to from_slice
:
There are two main differences:
- Errors in the expansion headers will only stop the parsing and return an
Ok
with the successfully parsed parts and the error as optional. Only if an unrecoverable error is encountered in the IP header itself anErr
is returned. In the normalIpv4Slice::from_slice
function anErr
is returned if an error is encountered in an exteions header. LaxIpv4Slice::from_slice
ignores inconsistentpayload_length
values. When thepayload_length
value in the IPv6 header is inconsistant the length of the given slice is used as a substitute.
You can check if the slice length was used as a substitude by checking
if the len_source
value in the returned IpPayloadSlice
is set to
LenSource::Slice
. If a substitution was not needed len_source
is set to LenSource::Ipv6HeaderPayloadLen
.
§When is the slice length used as a fallback?
The slice length is used as a fallback/substitude if the payload_length
field in the IPv6 header is
- Bigger then the given slice (payload cannot fully be seperated).
- The value
0
.
sourcepub fn header(&self) -> Ipv6HeaderSlice<'a>
pub fn header(&self) -> Ipv6HeaderSlice<'a>
Returns a slice containing the IPv6 header.
sourcepub fn extensions(&self) -> &Ipv6ExtensionsSlice<'a>
pub fn extensions(&self) -> &Ipv6ExtensionsSlice<'a>
Returns a slice containing the IPv6 extension headers.
sourcepub fn payload(&self) -> &LaxIpPayloadSlice<'a>
pub fn payload(&self) -> &LaxIpPayloadSlice<'a>
Returns a slice containing the data after the IPv6 header and IPv6 extensions headers.
sourcepub fn is_payload_fragmented(&self) -> bool
pub fn is_payload_fragmented(&self) -> bool
Returns true if the payload is flagged as being fragmented.
Trait Implementations§
source§impl<'a> Clone for LaxIpv6Slice<'a>
impl<'a> Clone for LaxIpv6Slice<'a>
source§fn clone(&self) -> LaxIpv6Slice<'a>
fn clone(&self) -> LaxIpv6Slice<'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 LaxIpv6Slice<'a>
impl<'a> Debug for LaxIpv6Slice<'a>
source§impl<'a> From<LaxIpv6Slice<'a>> for LaxIpSlice<'a>
impl<'a> From<LaxIpv6Slice<'a>> for LaxIpSlice<'a>
source§fn from(value: LaxIpv6Slice<'a>) -> Self
fn from(value: LaxIpv6Slice<'a>) -> Self
source§impl<'a> From<LaxIpv6Slice<'a>> for LaxNetSlice<'a>
impl<'a> From<LaxIpv6Slice<'a>> for LaxNetSlice<'a>
source§fn from(value: LaxIpv6Slice<'a>) -> LaxNetSlice<'a>
fn from(value: LaxIpv6Slice<'a>) -> LaxNetSlice<'a>
source§impl<'a> PartialEq for LaxIpv6Slice<'a>
impl<'a> PartialEq for LaxIpv6Slice<'a>
source§fn eq(&self, other: &LaxIpv6Slice<'a>) -> bool
fn eq(&self, other: &LaxIpv6Slice<'a>) -> bool
self
and other
values to be equal, and is used
by ==
.