icmp

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2024 License: MIT Imports: 11 Imported by: 1

Documentation

Overview

Package icmp sends and receives icmp echo request/reply packets over a UDP socket. Both IPv4 and IPv6 are supported.

A process using this package can only have one Socket instance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Response

type Response struct {
	From     net.IP
	MsgType  icmp.Type
	Body     icmp.MessageBody
	Received time.Time
}

func (Response) LogValue

func (r Response) LogValue() slog.Value

func (Response) SequenceNumber

func (r Response) SequenceNumber() SequenceNumber

type SequenceNumber

type SequenceNumber uint16

type Socket

type Socket struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

func New

func New(tp Transport, l *slog.Logger) *Socket

func (*Socket) Ping

func (s *Socket) Ping(ip net.IP, seq SequenceNumber, ttl uint8, payload []byte) error

func (*Socket) Read

func (s *Socket) Read(ctx context.Context) (Response, error)

func (*Socket) Resolve

func (s *Socket) Resolve(host string) (net.IP, error)

func (*Socket) Serve

func (s *Socket) Serve(ctx context.Context)

type Transport

type Transport int
const (
	IPv4 Transport = 0x01
	IPv6 Transport = 0x02
)

func (Transport) String

func (tp Transport) String() string

Jump to

Keyboard shortcuts

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