Trait IcmpVersion

Source
pub trait IcmpVersion:
    Sealed
    + Debug
    + Send
    + Sync
    + 'static {
    type Address: Into<IpAddr> + Copy + Send + Sync;
    type SocketAddr: Into<SocketAddr> + PartialEq + Eq + Debug + Copy;

    const DOMAIN: Domain;
    const PROTOCOL: Protocol;
    const DEFAULT_BIND: Self::SocketAddr;

    // Required methods
    fn extract_icmp_from_recv_packet(
        packet: &[u8],
    ) -> Result<(&[u8], Range<usize>)>;
    fn checksum_required() -> bool;
}
Expand description

Trait abstracting over ICMPv4 and ICMPv6 behavior

Required Associated Constants§

Source

const DOMAIN: Domain

The socket domain to use when opening a socket

Source

const PROTOCOL: Protocol

The socket protocol to use when opening a socket

Source

const DEFAULT_BIND: Self::SocketAddr

The sockaddr to bind to if none is specified in socket::SocketConfig.

This should be 0.0.0.0 or :: with a 0 port so that the kernel chooses a free port.

There must always be some sockaddr bound during socket init, otherwise the local port is not set until the first packet is sent.

Required Associated Types§

Source

type Address: Into<IpAddr> + Copy + Send + Sync

The type of IP address used with this version

Source

type SocketAddr: Into<SocketAddr> + PartialEq + Eq + Debug + Copy

The type of sockaddr used with this version

Required Methods§

Source

fn extract_icmp_from_recv_packet(packet: &[u8]) -> Result<(&[u8], Range<usize>)>

Extract the portion of the packet that comprises the ICMP message

Source

fn checksum_required() -> bool

Whether the ICMP checksum should be calculated when sending a message.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl IcmpVersion for Icmpv4

Source§

const DOMAIN: Domain = socket2::Domain::IPV4

Source§

const PROTOCOL: Protocol = socket2::Protocol::ICMPV4

Source§

const DEFAULT_BIND: Self::SocketAddr

Source§

type Address = Ipv4Addr

Source§

type SocketAddr = SocketAddrV4

Source§

impl IcmpVersion for Icmpv6

Source§

const DOMAIN: Domain = socket2::Domain::IPV6

Source§

const PROTOCOL: Protocol = socket2::Protocol::ICMPV6

Source§

const DEFAULT_BIND: Self::SocketAddr

Source§

type Address = Ipv6Addr

Source§

type SocketAddr = SocketAddrV6