Expand description
Packet parsing and construction.
Where possible we use traits to support a common API for constructing the ICMPv4 and ICMPv6 versions of the packets.
Both packet types can be constructed from a slice: &[u8] via the TryFrom trait.
§Examples
Constructing an ICMPv4 echo request.
let packet = Icmpv4Packet::with_echo_request(
42, // An identifier so you can recognize responses to your own packets.
0, // the first echo request packet in our sequence.
"a payload big enough to matter".as_bytes().to_vec()
).unwrap();Parsing an ICMPv4 packet from a byte buffer.
use std::convert::TryFrom;
let parsed_packet = Icmpv4Packet::try_from(byte_buffer.as_slice()).unwrap();Structs§
- Icmpv4
Packet - An Icmpv4 Packet.
- Icmpv6
Packet
Enums§
- Icmp
Packet Build Error - Errors returned by constructors for a given packet.
- Icmpv4
Message - The various messages for an Icmpv4 packet.
- Icmpv6
Message - The possible Icmpv6 Message types.
- Packet
Parse Error - Error type returned by parsing the ICMP packets.
Traits§
- With
Echo Reply - Construct a packet for Echo Reply messages. This packet type is really only used for the ICMPv6 protocol.
- With
Echo Request - Construct a packet for the EchoRequest messages.
- With
Parameter Problem - Construct a packet for Parameter Problem messages.
- With
Time Exceeded - Construct a packet for Time Exceeded messages.
- With
Unreachable - Construct a packet for Destination Unreachable messages.