Documentation
¶
Index ¶
- func IsIPv4(address string) bool
- func IsIPv6(address string) bool
- type Dispatcher
- type DispatcherOption
- type Handler
- type IPProtocol
- type IPv4Socket
- type IPv6Socket
- type PingHandler
- func (ph *PingHandler) Allocate(handler Handler, timeout time.Duration) (uint16, error)
- func (ph *PingHandler) Close() error
- func (ph *PingHandler) Dispatch(addr net.Addr, im *icmp.Message) error
- func (ph *PingHandler) Run() error
- func (ph *PingHandler) Send(payload []byte, destination *net.IPAddr, handler Handler, ...) error
- func (ph *PingHandler) SendAndWait(payload []byte, destination *net.IPAddr, timeout time.Duration) (net.Addr, *icmp.Message, error)
- type Socket
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dispatcher ¶
type Dispatcher struct { Socket []Socket Defaultv4 *IPv4Socket Defaultv6 *IPv6Socket DefaultHandler Handler // contains filtered or unexported fields }
func NewDispatcher ¶
func NewDispatcher(options ...DispatcherOption) (*Dispatcher, error)
func (*Dispatcher) Register ¶
func (pr *Dispatcher) Register(handler Handler, types ...icmp.Type) error
func (*Dispatcher) Run ¶
func (pr *Dispatcher) Run()
func (*Dispatcher) Unregister ¶
func (pr *Dispatcher) Unregister(types ...icmp.Type) error
type DispatcherOption ¶
type DispatcherOption func(*Dispatcher) error
func AddSocket ¶
func AddSocket(socket Socket) DispatcherOption
func ListenOn ¶
func ListenOn(bindto string) DispatcherOption
func SetDefaultHandler ¶
func SetDefaultHandler(handler Handler) DispatcherOption
type IPProtocol ¶
type IPProtocol int
const ( // Protocol numbers assigned by IANA to ICMPv4 and ICMPv6. // https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers ProtocolICMPv4 IPProtocol = 1 ProtocolICMPv6 IPProtocol = 58 )
type IPv4Socket ¶
type IPv4Socket struct {
// contains filtered or unexported fields
}
func NewIPv4Socket ¶
func NewIPv4Socket(bindto string) (*IPv4Socket, error)
func (*IPv4Socket) Run ¶
func (im *IPv4Socket) Run(dispatcher Handler) error
type IPv6Socket ¶
type IPv6Socket struct {
// contains filtered or unexported fields
}
func NewIPv6Socket ¶
func NewIPv6Socket(bindto string) (*IPv6Socket, error)
func (*IPv6Socket) Run ¶
func (im *IPv6Socket) Run(dispatcher Handler) error
type PingHandler ¶
type PingHandler struct { Id uint16 Sequence uint16 Dispatcher *Dispatcher // contains filtered or unexported fields }
func NewPingHandler ¶
func NewPingHandler(dispatcher *Dispatcher) (*PingHandler, error)
func (*PingHandler) Close ¶
func (ph *PingHandler) Close() error
func (*PingHandler) Run ¶
func (ph *PingHandler) Run() error
Click to show internal directories.
Click to hide internal directories.