Enum etherparse::IpSlice
source · pub enum IpSlice<'a> {
Ipv4(Ipv4Slice<'a>),
Ipv6(Ipv6Slice<'a>),
}
Expand description
Slice containing the IP header (v4 or v6), extension headers & payload.
Variants§
Ipv4(Ipv4Slice<'a>)
The ipv4 header & the decoded extension headers.
Ipv6(Ipv6Slice<'a>)
The ipv6 header & the decoded extension headers.
Implementations§
source§impl<'a> IpSlice<'a>
impl<'a> IpSlice<'a>
sourcepub fn ipv4(&self) -> Option<&Ipv4Slice<'_>>
pub fn ipv4(&self) -> Option<&Ipv4Slice<'_>>
Returns a reference to the Ipv4Slice
if self
is a IpSlice::Ipv4
.
sourcepub fn ipv6(&self) -> Option<&Ipv6Slice<'_>>
pub fn ipv6(&self) -> Option<&Ipv6Slice<'_>>
Returns a reference to the Ipv6Slice
if self
is a IpSlice::Ipv6
.
sourcepub fn is_fragmenting_payload(&self) -> bool
pub fn is_fragmenting_payload(&self) -> bool
Returns true if the payload is fragmented.
sourcepub fn source_addr(&self) -> IpAddr
Available on crate feature std
only.
pub fn source_addr(&self) -> IpAddr
std
only.Return the source address as an std::net::Ipvddr (requires
crate feature std
).
sourcepub fn destination_addr(&self) -> IpAddr
Available on crate feature std
only.
pub fn destination_addr(&self) -> IpAddr
std
only.Return the destination address as an std::net::IpAddr (requires
crate feature std
).
sourcepub fn payload(&self) -> &IpPayloadSlice<'a>
pub fn payload(&self) -> &IpPayloadSlice<'a>
Returns a slice containing the data after the IP header and IP 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 IP packet.
This function returns the ip number stored in the last IP header or extension header.
sourcepub fn from_slice(slice: &[u8]) -> Result<IpSlice<'_>, SliceError>
pub fn from_slice(slice: &[u8]) -> Result<IpSlice<'_>, SliceError>
Separates and validates IP headers (including extension headers) in the given slice and determine the sub-slice containing the payload of the IP packet.