Documentation
¶
Overview ¶
Package icmpx provides low-level ICMPv4 (IPPROTO_ICMP) and ICMPv6 (IPPROTO_ICMPV6) raw socket support for Linux.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn interface { // Close closes the underlying socket. io.Closer // ReadFrom reads an ICMP message and returns the sender's IP address. ReadFrom(ctx context.Context) (*icmp.Message, netip.Addr, error) // WriteTo writes an ICMP message to a destination IP address. WriteTo(ctx context.Context, msg *icmp.Message, dst netip.Addr) error }
A Conn allows reading and writing ICMPv4/6 messages, depending on the concrete type of Conn.
type IPv4Config ¶
type IPv4Config struct { // Filter applies an optional ICMPv4 filter to an IPv4Conn's underlying // socket before bind(2) is called, ensuring that no packets will be // received which do not match the filter. // // If nil, no ICMPv4 filter is applied. Filter *IPv4Filter }
An IPv4Config configures an IPv4Conn.
type IPv4Conn ¶
type IPv4Conn struct { // IP is the chosen IPv4 bind address for ICMPv4 communication. IP netip.Addr // contains filtered or unexported fields }
An IPv4Conn allows reading and writing ICMPv4 data on a network interface.
func ListenIPv4 ¶
func ListenIPv4(ifi *net.Interface, cfg IPv4Config) (*IPv4Conn, error)
ListenIPv4 binds an ICMPv4 socket on the specified network interface.
type IPv4Filter ¶
type IPv4Filter struct {
// contains filtered or unexported fields
}
An IPv4Filter creates an ICMPv4 filter which may be attached to an IPv4Conn.
func IPv4AllowOnly ¶
func IPv4AllowOnly(types ...ipv4.ICMPType) *IPv4Filter
IPv4AllowOnly constructs an IPv4Filter which only permits the specified ICMPv4 types. All other ICMPv4 traffic is filtered out.
func (*IPv4Filter) Accept ¶
func (f *IPv4Filter) Accept(typ ipv4.ICMPType)
Accept accepts an ICMPv4 type using the filter.
func (*IPv4Filter) Block ¶
func (f *IPv4Filter) Block(typ ipv4.ICMPType)
Block blocks an ICMPv4 type using the filter.
func (*IPv4Filter) SetAll ¶
func (f *IPv4Filter) SetAll(block bool)
SetAll either blocks or allows all ICMPv4 types on the filter depending on the input value.
type IPv6Config ¶
type IPv6Config struct { // Filter applies an optional ICMPv6 filter to an IPv6Conn's underlying // socket before bind(2) is called, ensuring that no packets will be // received which do not match the filter. // // If nil, no ICMPv6 filter is applied. Filter *IPv6Filter }
An IPv6Config configures an IPv6Conn.
type IPv6Conn ¶
type IPv6Conn struct { // IP is the chosen IPv6 bind address for ICMPv6 communication. IP netip.Addr // contains filtered or unexported fields }
An IPv6Conn allows reading and writing ICMPv6 data on a network interface.
func ListenIPv6 ¶
func ListenIPv6(ifi *net.Interface, cfg IPv6Config) (*IPv6Conn, error)
ListenIPv6 binds an ICMPv6 socket on the specified network interface.
func (*IPv6Conn) SetTrafficClass ¶
SetTrafficClass sets the IPv6 Traffic Class field for outgoing packets.
type IPv6Filter ¶
type IPv6Filter struct {
// contains filtered or unexported fields
}
An IPv6Filter creates an ICMPv6 filter which may be attached to an IPv6Conn.
func IPv6AllowOnly ¶
func IPv6AllowOnly(types ...ipv6.ICMPType) *IPv6Filter
IPv6AllowOnly constructs an IPv6Filter which only permits the specified ICMPv6 types. All other ICMPv6 traffic is filtered out.
func (*IPv6Filter) Accept ¶
func (f *IPv6Filter) Accept(typ ipv6.ICMPType)
Accept accepts an ICMPv6 type using the filter.
func (*IPv6Filter) Block ¶
func (f *IPv6Filter) Block(typ ipv6.ICMPType)
Block blocks an ICMPv6 type using the filter.
func (*IPv6Filter) SetAll ¶
func (f *IPv6Filter) SetAll(block bool)
SetAll either blocks or allows all ICMPv6 types on the filter depending on the input value.