icmp

package
v0.0.0-...-e4d881b Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderMinSize = 8

The minimum size of an ICMP header

Variables

This section is empty.

Functions

func Bind

func Bind(tp Type) (chan *Packet, error)

Bind allows clients to bind to a specific ICMP type

func SendPacket

func SendPacket(writer ipv4.Writer, data *Header) error

SendPacket sends an ICMP packet to on a given writer

func Unbind

func Unbind(tp Type) error

Unbind allows clients to unbind from ICMP type to stop receiving packets on the channel.

Types

type Header struct {
	Tp   Type
	Code uint8
	Opt  uint32
	Data []byte
	// contains filtered or unexported fields
}

Header represents an ICMP header

func (*Header) Marshal

func (h *Header) Marshal() ([]byte, error)

Marshal converts a Header structure into a slice of bytes, ready for transmission.

func (*Header) MarshalGivenSlice

func (h *Header) MarshalGivenSlice(base []byte) error

MarshalGivenSlice populates a given slice of bytes with fields from the Header structure.

type Packet

type Packet struct {
	Header         *Header
	OriginalPacket []byte
	LIP, RIP       *ipv4.Address
}

Packet contains an ICMP header and some information from the internet layer protocol header

type Type

type Type uint8

Type is the ICMP type

const (
	EchoReply   Type = 0
	EchoRequest Type = 8
)

Define common ICMP Types

Jump to

Keyboard shortcuts

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