icmp

package
v0.0.0-...-f5c58d3 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2016 License: BSD-2-Clause Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// EchoReplyType is the ICMP type for an echo reply.
	EchoReplyType = 0
	// EchoRequestType is the ICMP type for an echo request.
	EchoRequestType = 8
)
View Source
const (
	// EchoReplyCode is the ICMP code for an echo reply.
	EchoReplyCode = 0
	// EchoRequestCode is the ICMP code for an echo request.
	EchoRequestCode = 0
)

Variables

View Source
var (
	// ErrUnsupportedICMPPacket is used for unsupported ICMP packet types.
	ErrUnsupportedICMPPacket = errors.New("unsupported ICMP packet")
)

Functions

This section is empty.

Types

type Code

type Code uint8

Code is the code of the ICMP packet.

type Data

type Data interface {
	Write(io.Writer) error
}

Data is an interface to handle ICMP data.

type Echo

type Echo struct {
	Header  EchoHeader
	Payload []byte
}

Echo is the data for echo request/reply packets.

func NewEcho

func NewEcho(r io.Reader) (data Echo, err error)

NewEcho reads echo request/reply data from a reader.

func (Echo) Write

func (d Echo) Write(w io.Writer) error

Write the echo request/reply data to the writer.

type EchoHeader

type EchoHeader struct {
	Identifier     uint16
	SequenceNumber uint16
}

EchoHeader is the header of echo request/reply packets.

type Header struct {
	Type     Type
	Code     Code
	Checksum uint16
}

Header is the common ICMP header.

type Layer

type Layer interface {
	Packets(p Type) <-chan Packet
	Send(p Packet) error
}

Layer is the ICMP layer.

func NewLayer

func NewLayer(ip ipv4.Layer) Layer

NewLayer creates a new instance of the default ICMP layer.

type Packet

type Packet struct {
	Header Header
	Data   Data

	// Address is either the destination or source address.
	Address ipv4.Address
}

Packet is an ICMP packet.

func NewEchoReply

func NewEchoReply(ident, seq uint16, payload []byte) Packet

NewEchoReply creates a new echo reply packet.

func NewEchoRequest

func NewEchoRequest(ident, seq uint16, payload []byte) Packet

NewEchoRequest creates a new echo request packet.

func NewPacket

func NewPacket(r io.Reader) (packet Packet, err error)

NewPacket will read a packet from a reader.

func (Packet) Write

func (p Packet) Write(w io.Writer) error

Write will write a packet to a writer.

type Type

type Type uint8

Type is the type of the ICMP packet.

Jump to

Keyboard shortcuts

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