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
pub fn source_addr(&self) -> IpAddr
Return the source address as an core::net::Ipvddr
Sourcepub fn destination_addr(&self) -> IpAddr
pub fn destination_addr(&self) -> IpAddr
Return the destination address as an core::net::IpAddr
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.