pinger

package
v0.0.0-...-3733eb8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorAlreadyExists

type ErrorAlreadyExists struct{}

ErrorAlreadyExists is returned if a callback already exists. Used to detect icmp ID conflicts

func (*ErrorAlreadyExists) Error

func (e *ErrorAlreadyExists) Error() string

type Pinger

type Pinger struct {
	Conn *icmp.PacketConn
	// contains filtered or unexported fields
}

Pinger is a protocol specific pinger, either ipv4 or ipv6

func New

func New(v int) *Pinger

New returns a new pinger

func (*Pinger) AddCallBack

func (pp *Pinger) AddCallBack(ip net.IP, id int, cb func(*packet.Packet)) error

AddCallBack adds an OnRecieve callback for a given IP and icmp id This implicitly starts the listening for these packets

func (*Pinger) DelCallBack

func (pp *Pinger) DelCallBack(ip net.IP, id int) error

DelCallBack deletes a callback for a given IP and icmp id This stops listening for these packets

func (*Pinger) GetCallback

func (pp *Pinger) GetCallback(ip net.IP, id int) (func(*packet.Packet), bool)

GetCallback returns the OnRecieve callback for for a given IP and icmp id

func (*Pinger) Network

func (pp *Pinger) Network() string

Network returns the name of the network

func (*Pinger) Send

func (pp *Pinger) Send(dst *net.IPAddr, sp *packet.Packet) error

Send sends a packet. This also sets the sent time on the packet nolint: interfacer I want only an IPAddr not net.Addr others will throw erros

func (*Pinger) SendType

func (pp *Pinger) SendType() icmp.Type

SendType returns the icmp.Type for the given protocol

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL