Module packet

Module packet 

Source
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§

Icmpv4Packet
An Icmpv4 Packet.
Icmpv6Packet

Enums§

IcmpPacketBuildError
Errors returned by constructors for a given packet.
Icmpv4Message
The various messages for an Icmpv4 packet.
Icmpv6Message
The possible Icmpv6 Message types.
PacketParseError
Error type returned by parsing the ICMP packets.

Traits§

WithEchoReply
Construct a packet for Echo Reply messages. This packet type is really only used for the ICMPv6 protocol.
WithEchoRequest
Construct a packet for the EchoRequest messages.
WithParameterProblem
Construct a packet for Parameter Problem messages.
WithTimeExceeded
Construct a packet for Time Exceeded messages.
WithUnreachable
Construct a packet for Destination Unreachable messages.