Low-level socket operations for ICMP using Erlang's :socket API.
This module handles opening raw ICMP sockets, sending packets, and receiving replies with proper timeout handling.
Summary
Functions
Close an ICMP socket.
Open a raw ICMP socket.
Receive an ICMP reply with timeout.
Send an ICMP packet to a destination IP.
Functions
@spec close(:socket.socket()) :: :ok | {:error, term()}
Close an ICMP socket.
@spec open() :: {:ok, :socket.socket()} | {:error, term()}
Open a raw ICMP socket.
Returns {:ok, socket} or {:error, reason}.
Requires elevated privileges (root or CAP_NET_RAW).
@spec recv(:socket.socket(), non_neg_integer()) :: {:ok, binary()} | {:error, term()}
Receive an ICMP reply with timeout.
Returns {:ok, data} or {:error, :timeout} / {:error, reason}.
@spec send(:socket.socket(), binary(), :inet.ip_address()) :: :ok | {:error, term()}
Send an ICMP packet to a destination IP.