Struct etherparse::Ipv4Slice
source · pub struct Ipv4Slice<'a> { /* private fields */ }
Expand description
Slice containing the IPv4 headers & payload.
Implementations§
source§impl<'a> Ipv4Slice<'a>
impl<'a> Ipv4Slice<'a>
sourcepub fn from_slice(slice: &[u8]) -> Result<Ipv4Slice<'_>, SliceError>
pub fn from_slice(slice: &[u8]) -> Result<Ipv4Slice<'_>, SliceError>
Separates and validates IPv4 headers (including extension headers) in the given slice and determine the sub-slice containing the payload of the IPv4 packet.
Note that his function returns an crate::err::LenError
if the given slice
contains less data then the total_len
field in the IPv4 header indicates
should be present.
If you want to ignore these kind of length errors based on the length
fields in the IP headers use crate::LaxIpv4Slice::from_slice
instead.
sourcepub fn header(&self) -> Ipv4HeaderSlice<'_>
pub fn header(&self) -> Ipv4HeaderSlice<'_>
Returns a slice containing the IPv4 header.
sourcepub fn extensions(&self) -> Ipv4ExtensionsSlice<'_>
pub fn extensions(&self) -> Ipv4ExtensionsSlice<'_>
Returns a slice containing the IPv4 extension headers.
sourcepub fn payload(&self) -> &IpPayloadSlice<'a>
pub fn payload(&self) -> &IpPayloadSlice<'a>
Returns a slice containing the data after the IPv4 header and IPv4 extensions headers.
sourcepub fn payload_ip_number(&self) -> IpNumber
pub fn payload_ip_number(&self) -> IpNumber
Returns the ip number the type of payload of the IPv4 packet.
This function returns the ip number stored in the last IPv4 header or extension header.
sourcepub fn is_payload_fragmented(&self) -> bool
pub fn is_payload_fragmented(&self) -> bool
Returns true if the payload is flagged as being fragmented.