pub struct IcmpPacket<I: IcmpIpExt, B: SplitByteSlice, M: IcmpMessage<I>> { /* private fields */ }
Expand description
An ICMP packet.
An IcmpPacket
shares its underlying memory with the byte slice it was
parsed from, meaning that no copying or extra allocation is necessary.
Implementations§
Source§impl<I: IcmpIpExt, B: SplitByteSlice, M: IcmpMessage<I>> IcmpPacket<I, B, M>
impl<I: IcmpIpExt, B: SplitByteSlice, M: IcmpMessage<I>> IcmpPacket<I, B, M>
Sourcepub fn code(&self) -> M::Code
pub fn code(&self) -> M::Code
Get the ICMP message code.
The code provides extra details about the message. Each message type has its own set of codes that are allowed.
Sourcepub fn builder(
&self,
src_ip: I::Addr,
dst_ip: I::Addr,
) -> IcmpPacketBuilder<I, M>
pub fn builder( &self, src_ip: I::Addr, dst_ip: I::Addr, ) -> IcmpPacketBuilder<I, M>
Construct a builder with the same contents as this packet.
Source§impl<I: IcmpIpExt, B: SplitByteSlice, M: IcmpMessage<I, Body<B> = OriginalPacket<B>>> IcmpPacket<I, B, M>
impl<I: IcmpIpExt, B: SplitByteSlice, M: IcmpMessage<I, Body<B> = OriginalPacket<B>>> IcmpPacket<I, B, M>
Sourcepub fn original_packet_body(&self) -> &[u8] ⓘ
pub fn original_packet_body(&self) -> &[u8] ⓘ
Get the body of the packet that caused this ICMP message.
This ICMP message contains some of the bytes of the packet that caused
this message to be emitted. original_packet_body
returns as much of
the body of that packet as is contained in this message. For IPv4, this
is guaranteed to be 8 bytes. For IPv6, there are no guarantees about the
length.
Sourcepub fn original_packet(&self) -> &OriginalPacket<B>
pub fn original_packet(&self) -> &OriginalPacket<B>
Returns the original packt that caused this ICMP message.
This ICMP message contains some of the bytes of the packet that caused
this message to be emitted. original_packet
returns as much of the
body of that packet as is contained in this message. For IPv4, this is
guaranteed to be 8 bytes. For IPv6, there are no guarantees about the
length.
Source§impl<B: SplitByteSlice, M: IcmpMessage<Ipv4, Body<B> = OriginalPacket<B>>> IcmpPacket<Ipv4, B, M>
impl<B: SplitByteSlice, M: IcmpMessage<Ipv4, Body<B> = OriginalPacket<B>>> IcmpPacket<Ipv4, B, M>
Sourcepub fn with_original_packet<O, F: FnOnce(Result<Ipv4PacketRaw<&[u8]>, &[u8]>) -> O>(
&self,
f: F,
) -> O
pub fn with_original_packet<O, F: FnOnce(Result<Ipv4PacketRaw<&[u8]>, &[u8]>) -> O>( &self, f: F, ) -> O
Attempt to partially parse the original packet as an IPv4 packet.
f
will be invoked on the result of calling Ipv4PacketRaw::parse
on
the original packet.
Source§impl<B: SplitByteSlice, M: IcmpMessage<Ipv6, Body<B> = OriginalPacket<B>>> IcmpPacket<Ipv6, B, M>
impl<B: SplitByteSlice, M: IcmpMessage<Ipv6, Body<B> = OriginalPacket<B>>> IcmpPacket<Ipv6, B, M>
Sourcepub fn with_original_packet<O, F: FnOnce(Result<Ipv6PacketRaw<&[u8]>, &[u8]>) -> O>(
&self,
f: F,
) -> O
pub fn with_original_packet<O, F: FnOnce(Result<Ipv6PacketRaw<&[u8]>, &[u8]>) -> O>( &self, f: F, ) -> O
Attempt to partially parse the original packet as an IPv6 packet.
f
will be invoked on the result of calling Ipv6PacketRaw::parse
on
the original packet.
Source§impl<I: IcmpIpExt, B: SplitByteSlice, M: IcmpMessage<I, Body<B> = Options<B>>> IcmpPacket<I, B, M>
impl<I: IcmpIpExt, B: SplitByteSlice, M: IcmpMessage<I, Body<B> = Options<B>>> IcmpPacket<I, B, M>
Sourcepub fn ndp_options(&self) -> &Options<B>
pub fn ndp_options(&self) -> &Options<B>
Get the pared list of NDP options from the ICMP message.
Trait Implementations§
Source§impl<I: Debug + IcmpIpExt, B: Debug + SplitByteSlice, M: Debug + IcmpMessage<I>> Debug for IcmpPacket<I, B, M>
impl<I: Debug + IcmpIpExt, B: Debug + SplitByteSlice, M: Debug + IcmpMessage<I>> Debug for IcmpPacket<I, B, M>
Source§impl<B: SplitByteSlice, I: IcmpIpExt, M: IcmpMessage<I>> FromRaw<IcmpPacketRaw<I, B, M>, IcmpParseArgs<<I as Ip>::Addr>> for IcmpPacket<I, B, M>
impl<B: SplitByteSlice, I: IcmpIpExt, M: IcmpMessage<I>> FromRaw<IcmpPacketRaw<I, B, M>, IcmpParseArgs<<I as Ip>::Addr>> for IcmpPacket<I, B, M>
Source§type Error = ParseError
type Error = ParseError
Source§fn try_from_raw_with(
raw: IcmpPacketRaw<I, B, M>,
args: IcmpParseArgs<I::Addr>,
) -> ParseResult<Self>
fn try_from_raw_with( raw: IcmpPacketRaw<I, B, M>, args: IcmpParseArgs<I::Addr>, ) -> ParseResult<Self>
Self
from the raw form in raw
with args
.Source§impl<B: SplitByteSlice, I: IcmpIpExt, M: IcmpMessage<I>> ParsablePacket<B, IcmpParseArgs<<I as Ip>::Addr>> for IcmpPacket<I, B, M>
impl<B: SplitByteSlice, I: IcmpIpExt, M: IcmpMessage<I>> ParsablePacket<B, IcmpParseArgs<<I as Ip>::Addr>> for IcmpPacket<I, B, M>
Source§fn parse_metadata(&self) -> ParseMetadata
fn parse_metadata(&self) -> ParseMetadata
GrowBuffer::undo_parse
]. Read more