Struct packet_formats::icmp::IcmpPacket
source · pub struct IcmpPacket<I: IcmpIpExt, B: ByteSlice, 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: ByteSlice, M: IcmpMessage<I>> IcmpPacket<I, B, M>
impl<I: IcmpIpExt, B: ByteSlice, 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: ByteSlice, M: IcmpMessage<I, Body<B> = OriginalPacket<B>>> IcmpPacket<I, B, M>
impl<I: IcmpIpExt, B: ByteSlice, 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: ByteSlice, M: IcmpMessage<Ipv4, Body<B> = OriginalPacket<B>>> IcmpPacket<Ipv4, B, M>
impl<B: ByteSlice, 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: ByteSlice, M: IcmpMessage<Ipv6, Body<B> = OriginalPacket<B>>> IcmpPacket<Ipv6, B, M>
impl<B: ByteSlice, 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: ByteSlice, M: IcmpMessage<I, Body<B> = Options<B>>> IcmpPacket<I, B, M>
impl<I: IcmpIpExt, B: ByteSlice, 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 + ByteSlice, M: Debug + IcmpMessage<I>> Debug for IcmpPacket<I, B, M>
impl<I: Debug + IcmpIpExt, B: Debug + ByteSlice, M: Debug + IcmpMessage<I>> Debug for IcmpPacket<I, B, M>
source§impl<B: ByteSlice, I: IcmpIpExt, M: IcmpMessage<I>> FromRaw<IcmpPacketRaw<I, B, M>, IcmpParseArgs<<I as Ip>::Addr>> for IcmpPacket<I, B, M>
impl<B: ByteSlice, I: IcmpIpExt, M: IcmpMessage<I>> FromRaw<IcmpPacketRaw<I, B, M>, IcmpParseArgs<<I as Ip>::Addr>> for IcmpPacket<I, B, M>
§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: ByteSlice, I: IcmpIpExt, M: IcmpMessage<I>> ParsablePacket<B, IcmpParseArgs<<I as Ip>::Addr>> for IcmpPacket<I, B, M>
impl<B: ByteSlice, I: IcmpIpExt, M: IcmpMessage<I>> ParsablePacket<B, IcmpParseArgs<<I as Ip>::Addr>> for IcmpPacket<I, B, M>
§type Error = ParseError
type Error = ParseError
source§fn parse_metadata(&self) -> ParseMetadata
fn parse_metadata(&self) -> ParseMetadata
GrowBuffer::undo_parse
]. Read more