icmp

package
v0.0.0-...-287083d Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package icmp provides basic functions for the manipulation of messages used in the Internet Control Message Protocols, ICMPv4 and ICMPv6.

ICMPv4 and ICMPv6 are defined in RFC 792 and RFC 4443. Multi-part message support for ICMP is defined in RFC 4884. ICMP extensions for MPLS are defined in RFC 4950. ICMP extensions for interface and next-hop identification are defined in RFC 5837. PROBE: A utility for probing interfaces is defined in RFC 8335.

Index

Examples

Constants

View Source
const (
	ProtocolIP             = 0   // IPv4 encapsulation, pseudo protocol number
	ProtocolHOPOPT         = 0   // IPv6 Hop-by-Hop Option
	ProtocolICMP           = 1   // Internet Control Message
	ProtocolIGMP           = 2   // Internet Group Management
	ProtocolGGP            = 3   // Gateway-to-Gateway
	ProtocolIPv4           = 4   // IPv4 encapsulation
	ProtocolST             = 5   // Stream
	ProtocolTCP            = 6   // Transmission Control
	ProtocolCBT            = 7   // CBT
	ProtocolEGP            = 8   // Exterior Gateway Protocol
	ProtocolIGP            = 9   // any private interior gateway (used by Cisco for their IGRP)
	ProtocolBBNRCCMON      = 10  // BBN RCC Monitoring
	ProtocolNVPII          = 11  // Network Voice Protocol
	ProtocolPUP            = 12  // PUP
	ProtocolEMCON          = 14  // EMCON
	ProtocolXNET           = 15  // Cross Net Debugger
	ProtocolCHAOS          = 16  // Chaos
	ProtocolUDP            = 17  // User Datagram
	ProtocolMUX            = 18  // Multiplexing
	ProtocolDCNMEAS        = 19  // DCN Measurement Subsystems
	ProtocolHMP            = 20  // Host Monitoring
	ProtocolPRM            = 21  // Packet Radio Measurement
	ProtocolXNSIDP         = 22  // XEROX NS IDP
	ProtocolTRUNK1         = 23  // Trunk-1
	ProtocolTRUNK2         = 24  // Trunk-2
	ProtocolLEAF1          = 25  // Leaf-1
	ProtocolLEAF2          = 26  // Leaf-2
	ProtocolRDP            = 27  // Reliable Data Protocol
	ProtocolIRTP           = 28  // Internet Reliable Transaction
	ProtocolISOTP4         = 29  // ISO Transport Protocol Class 4
	ProtocolNETBLT         = 30  // Bulk Data Transfer Protocol
	ProtocolMFENSP         = 31  // MFE Network Services Protocol
	ProtocolMERITINP       = 32  // MERIT Internodal Protocol
	ProtocolDCCP           = 33  // Datagram Congestion Control Protocol
	Protocol3PC            = 34  // Third Party Connect Protocol
	ProtocolIDPR           = 35  // Inter-Domain Policy Routing Protocol
	ProtocolXTP            = 36  // XTP
	ProtocolDDP            = 37  // Datagram Delivery Protocol
	ProtocolIDPRCMTP       = 38  // IDPR Control Message Transport Proto
	ProtocolTPPP           = 39  // TP++ Transport Protocol
	ProtocolIL             = 40  // IL Transport Protocol
	ProtocolIPv6           = 41  // IPv6 encapsulation
	ProtocolSDRP           = 42  // Source Demand Routing Protocol
	ProtocolIPv6Route      = 43  // Routing Header for IPv6
	ProtocolIPv6Frag       = 44  // Fragment Header for IPv6
	ProtocolIDRP           = 45  // Inter-Domain Routing Protocol
	ProtocolRSVP           = 46  // Reservation Protocol
	ProtocolGRE            = 47  // Generic Routing Encapsulation
	ProtocolDSR            = 48  // Dynamic Source Routing Protocol
	ProtocolBNA            = 49  // BNA
	ProtocolESP            = 50  // Encap Security Payload
	ProtocolAH             = 51  // Authentication Header
	ProtocolINLSP          = 52  // Integrated Net Layer Security  TUBA
	ProtocolNARP           = 54  // NBMA Address Resolution Protocol
	ProtocolMOBILE         = 55  // IP Mobility
	ProtocolTLSP           = 56  // Transport Layer Security Protocol using Kryptonet key management
	ProtocolSKIP           = 57  // SKIP
	ProtocolIPv6ICMP       = 58  // ICMP for IPv6
	ProtocolIPv6NoNxt      = 59  // No Next Header for IPv6
	ProtocolIPv6Opts       = 60  // Destination Options for IPv6
	ProtocolCFTP           = 62  // CFTP
	ProtocolSATEXPAK       = 64  // SATNET and Backroom EXPAK
	ProtocolKRYPTOLAN      = 65  // Kryptolan
	ProtocolRVD            = 66  // MIT Remote Virtual Disk Protocol
	ProtocolIPPC           = 67  // Internet Pluribus Packet Core
	ProtocolSATMON         = 69  // SATNET Monitoring
	ProtocolVISA           = 70  // VISA Protocol
	ProtocolIPCV           = 71  // Internet Packet Core Utility
	ProtocolCPNX           = 72  // Computer Protocol Network Executive
	ProtocolCPHB           = 73  // Computer Protocol Heart Beat
	ProtocolWSN            = 74  // Wang Span Network
	ProtocolPVP            = 75  // Packet Video Protocol
	ProtocolBRSATMON       = 76  // Backroom SATNET Monitoring
	ProtocolSUNND          = 77  // SUN ND PROTOCOL-Temporary
	ProtocolWBMON          = 78  // WIDEBAND Monitoring
	ProtocolWBEXPAK        = 79  // WIDEBAND EXPAK
	ProtocolISOIP          = 80  // ISO Internet Protocol
	ProtocolVMTP           = 81  // VMTP
	ProtocolSECUREVMTP     = 82  // SECURE-VMTP
	ProtocolVINES          = 83  // VINES
	ProtocolTTP            = 84  // Transaction Transport Protocol
	ProtocolIPTM           = 84  // Internet Protocol Traffic Manager
	ProtocolNSFNETIGP      = 85  // NSFNET-IGP
	ProtocolDGP            = 86  // Dissimilar Gateway Protocol
	ProtocolTCF            = 87  // TCF
	ProtocolEIGRP          = 88  // EIGRP
	ProtocolOSPFIGP        = 89  // OSPFIGP
	ProtocolSpriteRPC      = 90  // Sprite RPC Protocol
	ProtocolLARP           = 91  // Locus Address Resolution Protocol
	ProtocolMTP            = 92  // Multicast Transport Protocol
	ProtocolAX25           = 93  // AX.25 Frames
	ProtocolIPIP           = 94  // IP-within-IP Encapsulation Protocol
	ProtocolSCCSP          = 96  // Semaphore Communications Sec. Pro.
	ProtocolETHERIP        = 97  // Ethernet-within-IP Encapsulation
	ProtocolENCAP          = 98  // Encapsulation Header
	ProtocolGMTP           = 100 // GMTP
	ProtocolIFMP           = 101 // Ipsilon Flow Management Protocol
	ProtocolPNNI           = 102 // PNNI over IP
	ProtocolPIM            = 103 // Protocol Independent Multicast
	ProtocolARIS           = 104 // ARIS
	ProtocolSCPS           = 105 // SCPS
	ProtocolQNX            = 106 // QNX
	ProtocolAN             = 107 // Active Networks
	ProtocolIPComp         = 108 // IP Payload Compression Protocol
	ProtocolSNP            = 109 // Sitara Networks Protocol
	ProtocolCompaqPeer     = 110 // Compaq Peer Protocol
	ProtocolIPXinIP        = 111 // IPX in IP
	ProtocolVRRP           = 112 // Virtual Router Redundancy Protocol
	ProtocolPGM            = 113 // PGM Reliable Transport Protocol
	ProtocolL2TP           = 115 // Layer Two Tunneling Protocol
	ProtocolDDX            = 116 // D-II Data Exchange (DDX)
	ProtocolIATP           = 117 // Interactive Agent Transfer Protocol
	ProtocolSTP            = 118 // Schedule Transfer Protocol
	ProtocolSRP            = 119 // SpectraLink Radio Protocol
	ProtocolUTI            = 120 // UTI
	ProtocolSMP            = 121 // Simple Message Protocol
	ProtocolPTP            = 123 // Performance Transparency Protocol
	ProtocolISIS           = 124 // ISIS over IPv4
	ProtocolFIRE           = 125 // FIRE
	ProtocolCRTP           = 126 // Combat Radio Transport Protocol
	ProtocolCRUDP          = 127 // Combat Radio User Datagram
	ProtocolSSCOPMCE       = 128 // SSCOPMCE
	ProtocolIPLT           = 129 // IPLT
	ProtocolSPS            = 130 // Secure Packet Shield
	ProtocolPIPE           = 131 // Private IP Encapsulation within IP
	ProtocolSCTP           = 132 // Stream Control Transmission Protocol
	ProtocolFC             = 133 // Fibre Channel
	ProtocolRSVPE2EIGNORE  = 134 // RSVP-E2E-IGNORE
	ProtocolMobilityHeader = 135 // Mobility Header
	ProtocolUDPLite        = 136 // UDPLite
	ProtocolMPLSinIP       = 137 // MPLS-in-IP
	ProtocolMANET          = 138 // MANET Protocols
	ProtocolHIP            = 139 // Host Identity Protocol
	ProtocolShim6          = 140 // Shim6 Protocol
	ProtocolWESP           = 141 // Wrapped Encapsulating Security Payload
	ProtocolROHC           = 142 // Robust Header Compression
	ProtocolReserved       = 255 // Reserved
)
View Source
const (
	AddrFamilyIPv4                          = 1     // IP (IP version 4)
	AddrFamilyIPv6                          = 2     // IP6 (IP version 6)
	AddrFamilyNSAP                          = 3     // NSAP
	AddrFamilyHDLC                          = 4     // HDLC (8-bit multidrop)
	AddrFamilyBBN1822                       = 5     // BBN 1822
	AddrFamily802                           = 6     // 802 (includes all 802 media plus Ethernet "canonical format")
	AddrFamilyE163                          = 7     // E.163
	AddrFamilyE164                          = 8     // E.164 (SMDS, Frame Relay, ATM)
	AddrFamilyF69                           = 9     // F.69 (Telex)
	AddrFamilyX121                          = 10    // X.121 (X.25, Frame Relay)
	AddrFamilyIPX                           = 11    // IPX
	AddrFamilyAppletalk                     = 12    // Appletalk
	AddrFamilyDecnetIV                      = 13    // Decnet IV
	AddrFamilyBanyanVines                   = 14    // Banyan Vines
	AddrFamilyE164withSubaddress            = 15    // E.164 with NSAP format subaddress
	AddrFamilyDNS                           = 16    // DNS (Domain Name System)
	AddrFamilyDistinguishedName             = 17    // Distinguished Name
	AddrFamilyASNumber                      = 18    // AS Number
	AddrFamilyXTPoverIPv4                   = 19    // XTP over IP version 4
	AddrFamilyXTPoverIPv6                   = 20    // XTP over IP version 6
	AddrFamilyXTPnativemodeXTP              = 21    // XTP native mode XTP
	AddrFamilyFibreChannelWorldWidePortName = 22    // Fibre Channel World-Wide Port Name
	AddrFamilyFibreChannelWorldWideNodeName = 23    // Fibre Channel World-Wide Node Name
	AddrFamilyGWID                          = 24    // GWID
	AddrFamilyL2VPN                         = 25    // AFI for L2VPN information
	AddrFamilyMPLSTPSectionEndpointID       = 26    // MPLS-TP Section Endpoint Identifier
	AddrFamilyMPLSTPLSPEndpointID           = 27    // MPLS-TP LSP Endpoint Identifier
	AddrFamilyMPLSTPPseudowireEndpointID    = 28    // MPLS-TP Pseudowire Endpoint Identifier
	AddrFamilyMTIPv4                        = 29    // MT IP: Multi-Topology IP version 4
	AddrFamilyMTIPv6                        = 30    // MT IPv6: Multi-Topology IP version 6
	AddrFamilyEIGRPCommonServiceFamily      = 16384 // EIGRP Common Service Family
	AddrFamilyEIGRPIPv4ServiceFamily        = 16385 // EIGRP IPv4 Service Family
	AddrFamilyEIGRPIPv6ServiceFamily        = 16386 // EIGRP IPv6 Service Family
	AddrFamilyLISPCanonicalAddressFormat    = 16387 // LISP Canonical Address Format (LCAF)
	AddrFamilyBGPLS                         = 16388 // BGP-LS
	AddrFamily48bitMAC                      = 16389 // 48-bit MAC
	AddrFamily64bitMAC                      = 16390 // 64-bit MAC
	AddrFamilyOUI                           = 16391 // OUI
	AddrFamilyMACFinal24bits                = 16392 // MAC/24
	AddrFamilyMACFinal40bits                = 16393 // MAC/40
	AddrFamilyIPv6Initial64bits             = 16394 // IPv6/64
	AddrFamilyRBridgePortID                 = 16395 // RBridge Port ID
	AddrFamilyTRILLNickname                 = 16396 // TRILL Nickname
)

Variables

View Source
var (
	// NativeEndian is the machine native endian implementation of
	// ByteOrder.
	NativeEndian binary.ByteOrder
)

Functions

func IPv6PseudoHeader

func IPv6PseudoHeader(src, dst net.IP) []byte

IPv6PseudoHeader returns an IPv6 pseudo header for checksum calculation.

func ParseIPv4Header

func ParseIPv4Header(b []byte) (*ipv4.Header, error)

ParseIPv4Header returns the IPv4 header of the IPv4 packet that triggered an ICMP error message. This is found in the Data field of the ICMP error message body.

The provided b must be in the format used by a raw ICMP socket on the local system. This may differ from the wire format, and the format used by a raw IP socket, depending on the system.

To parse an IPv6 header, use ipv6.ParseHeader.

Types

type DefaultMessageBody deprecated

type DefaultMessageBody = RawBody

A DefaultMessageBody represents the default message body.

Deprecated: Use RawBody instead.

type DstUnreach

type DstUnreach struct {
	Data       []byte      // data, known as original datagram field
	Extensions []Extension // extensions
}

A DstUnreach represents an ICMP destination unreachable message body.

func (*DstUnreach) Len

func (p *DstUnreach) Len(proto int) int

Len implements the Len method of MessageBody interface.

func (*DstUnreach) Marshal

func (p *DstUnreach) Marshal(proto int) ([]byte, error)

Marshal implements the Marshal method of MessageBody interface.

type Echo

type Echo struct {
	ID   int    // identifier
	Seq  int    // sequence number
	Data []byte // data
}

An Echo represents an ICMP echo request or reply message body.

func (*Echo) Len

func (p *Echo) Len(proto int) int

Len implements the Len method of MessageBody interface.

func (*Echo) Marshal

func (p *Echo) Marshal(proto int) ([]byte, error)

Marshal implements the Marshal method of MessageBody interface.

type ExtendedEchoReply

type ExtendedEchoReply struct {
	ID     int  // identifier
	Seq    int  // sequence number
	State  int  // 3-bit state working together with Message.Code
	Active bool // probed interface is active
	IPv4   bool // probed interface runs IPv4
	IPv6   bool // probed interface runs IPv6
}

An ExtendedEchoReply represents an ICMP extended echo reply message body.

func (*ExtendedEchoReply) Len

func (p *ExtendedEchoReply) Len(proto int) int

Len implements the Len method of MessageBody interface.

func (*ExtendedEchoReply) Marshal

func (p *ExtendedEchoReply) Marshal(proto int) ([]byte, error)

Marshal implements the Marshal method of MessageBody interface.

type ExtendedEchoRequest

type ExtendedEchoRequest struct {
	ID         int         // identifier
	Seq        int         // sequence number
	Local      bool        // must be true when identifying by name or index
	Extensions []Extension // extensions
}

An ExtendedEchoRequest represents an ICMP extended echo request message body.

func (*ExtendedEchoRequest) Len

func (p *ExtendedEchoRequest) Len(proto int) int

Len implements the Len method of MessageBody interface.

func (*ExtendedEchoRequest) Marshal

func (p *ExtendedEchoRequest) Marshal(proto int) ([]byte, error)

Marshal implements the Marshal method of MessageBody interface.

type Extension

type Extension interface {
	// Len returns the length of ICMP extension.
	// The provided proto must be either the ICMPv4 or ICMPv6
	// protocol number.
	Len(proto int) int

	// Marshal returns the binary encoding of ICMP extension.
	// The provided proto must be either the ICMPv4 or ICMPv6
	// protocol number.
	Marshal(proto int) ([]byte, error)
}

An Extension represents an ICMP extension.

type InterfaceIdent

type InterfaceIdent struct {
	Class int    // extension object class number
	Type  int    // extension object sub-type
	Name  string // interface name
	Index int    // interface index
	AFI   int    // address family identifier; see address family numbers in IANA registry
	Addr  []byte // address
}

An InterfaceIdent represents interface identification.

func (*InterfaceIdent) Len

func (ifi *InterfaceIdent) Len(_ int) int

Len implements the Len method of Extension interface.

func (*InterfaceIdent) Marshal

func (ifi *InterfaceIdent) Marshal(proto int) ([]byte, error)

Marshal implements the Marshal method of Extension interface.

type InterfaceInfo

type InterfaceInfo struct {
	Class     int // extension object class number
	Type      int // extension object sub-type
	Interface *net.Interface
	Addr      *net.IPAddr
}

An InterfaceInfo represents interface and next-hop identification.

func (*InterfaceInfo) Len

func (ifi *InterfaceInfo) Len(proto int) int

Len implements the Len method of Extension interface.

func (*InterfaceInfo) Marshal

func (ifi *InterfaceInfo) Marshal(proto int) ([]byte, error)

Marshal implements the Marshal method of Extension interface.

type MPLSLabel

type MPLSLabel struct {
	Label int  // label value
	TC    int  // traffic class; formerly experimental use
	S     bool // bottom of stack
	TTL   int  // time to live
}

MPLSLabel represents an MPLS label stack entry.

type MPLSLabelStack

type MPLSLabelStack struct {
	Class  int // extension object class number
	Type   int // extension object sub-type
	Labels []MPLSLabel
}

MPLSLabelStack represents an MPLS label stack.

func (*MPLSLabelStack) Len

func (ls *MPLSLabelStack) Len(proto int) int

Len implements the Len method of Extension interface.

func (*MPLSLabelStack) Marshal

func (ls *MPLSLabelStack) Marshal(proto int) ([]byte, error)

Marshal implements the Marshal method of Extension interface.

type Message

type Message struct {
	Type     Type        // type, either ipv4.ICMPType or ipv6.ICMPType
	Code     int         // code
	Checksum int         // checksum
	Body     MessageBody // body
}

A Message represents an ICMP message.

func ParseMessage

func ParseMessage(proto int, b []byte) (*Message, error)

ParseMessage parses b as an ICMP message. The provided proto must be either the ICMPv4 or ICMPv6 protocol number.

func (*Message) Marshal

func (m *Message) Marshal(psh []byte) ([]byte, error)

Marshal returns the binary encoding of the ICMP message m.

For an ICMPv4 message, the returned message always contains the calculated checksum field.

For an ICMPv6 message, the returned message contains the calculated checksum field when psh is not nil, otherwise the kernel will compute the checksum field during the message transmission. When psh is not nil, it must be the pseudo header for IPv6.

type MessageBody

type MessageBody interface {
	// Len returns the length of ICMP message body.
	// The provided proto must be either the ICMPv4 or ICMPv6
	// protocol number.
	Len(proto int) int

	// Marshal returns the binary encoding of ICMP message body.
	// The provided proto must be either the ICMPv4 or ICMPv6
	// protocol number.
	Marshal(proto int) ([]byte, error)
}

A MessageBody represents an ICMP message body.

type PacketConn

type PacketConn struct {
	// contains filtered or unexported fields
}

A PacketConn represents a packet network endpoint that uses either ICMPv4 or ICMPv6.

Example (NonPrivilegedPing)
package main

import (
	"log"
	"net"
	"os"
	"runtime"

	"golang.org/x/net/icmp"
	"golang.org/x/net/ipv6"
)

func main() {
	switch runtime.GOOS {
	case "darwin":
	case "linux":
		log.Println("you may need to adjust the net.ipv4.ping_group_range kernel state")
	default:
		log.Println("not supported on", runtime.GOOS)
		return
	}

	c, err := icmp.ListenPacket("udp6", "fe80::1%en0")
	if err != nil {
		log.Fatal(err)
	}
	defer c.Close()

	wm := icmp.Message{
		Type: ipv6.ICMPTypeEchoRequest, Code: 0,
		Body: &icmp.Echo{
			ID: os.Getpid() & 0xffff, Seq: 1,
			Data: []byte("HELLO-R-U-THERE"),
		},
	}
	wb, err := wm.Marshal(nil)
	if err != nil {
		log.Fatal(err)
	}
	if _, err := c.WriteTo(wb, &net.UDPAddr{IP: net.ParseIP("ff02::1"), Zone: "en0"}); err != nil {
		log.Fatal(err)
	}

	rb := make([]byte, 1500)
	n, peer, err := c.ReadFrom(rb)
	if err != nil {
		log.Fatal(err)
	}
	rm, err := icmp.ParseMessage(58, rb[:n])
	if err != nil {
		log.Fatal(err)
	}
	switch rm.Type {
	case ipv6.ICMPTypeEchoReply:
		log.Printf("got reflection from %v", peer)
	default:
		log.Printf("got %+v; want echo reply", rm)
	}
}
Output:

func ListenPacket

func ListenPacket(network, address string) (*PacketConn, error)

ListenPacket listens for incoming ICMP packets addressed to address. See net.Dial for the syntax of address.

For non-privileged datagram-oriented ICMP endpoints, network must be "udp4" or "udp6". The endpoint allows to read, write a few limited ICMP messages such as echo request and echo reply. Currently only Darwin and Linux support this.

Examples:

ListenPacket("udp4", "192.168.0.1")
ListenPacket("udp4", "0.0.0.0")
ListenPacket("udp6", "fe80::1%en0")
ListenPacket("udp6", "::")

For privileged raw ICMP endpoints, network must be "ip4" or "ip6" followed by a colon and an ICMP protocol number or name.

Examples:

ListenPacket("ip4:icmp", "192.168.0.1")
ListenPacket("ip4:1", "0.0.0.0")
ListenPacket("ip6:ipv6-icmp", "fe80::1%en0")
ListenPacket("ip6:58", "::")

func (*PacketConn) Close

func (c *PacketConn) Close() error

Close closes the endpoint.

func (*PacketConn) IPv4PacketConn

func (c *PacketConn) IPv4PacketConn() *ipv4.PacketConn

IPv4PacketConn returns the ipv4.PacketConn of c. It returns nil when c is not created as the endpoint for ICMPv4.

func (*PacketConn) IPv6PacketConn

func (c *PacketConn) IPv6PacketConn() *ipv6.PacketConn

IPv6PacketConn returns the ipv6.PacketConn of c. It returns nil when c is not created as the endpoint for ICMPv6.

func (*PacketConn) LocalAddr

func (c *PacketConn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*PacketConn) ReadFrom

func (c *PacketConn) ReadFrom(b []byte) (int, net.Addr, error)

ReadFrom reads an ICMP message from the connection.

func (*PacketConn) SetDeadline

func (c *PacketConn) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines associated with the endpoint.

func (*PacketConn) SetReadDeadline

func (c *PacketConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline associated with the endpoint.

func (*PacketConn) SetWriteDeadline

func (c *PacketConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the write deadline associated with the endpoint.

func (*PacketConn) WriteTo

func (c *PacketConn) WriteTo(b []byte, dst net.Addr) (int, error)

WriteTo writes the ICMP message b to dst. The provided dst must be net.UDPAddr when c is a non-privileged datagram-oriented ICMP endpoint. Otherwise it must be net.IPAddr.

type PacketTooBig

type PacketTooBig struct {
	MTU  int    // maximum transmission unit of the nexthop link
	Data []byte // data, known as original datagram field
}

A PacketTooBig represents an ICMP packet too big message body.

func (*PacketTooBig) Len

func (p *PacketTooBig) Len(proto int) int

Len implements the Len method of MessageBody interface.

func (*PacketTooBig) Marshal

func (p *PacketTooBig) Marshal(proto int) ([]byte, error)

Marshal implements the Marshal method of MessageBody interface.

type ParamProb

type ParamProb struct {
	Pointer    uintptr     // offset within the data where the error was detected
	Data       []byte      // data, known as original datagram field
	Extensions []Extension // extensions
}

A ParamProb represents an ICMP parameter problem message body.

func (*ParamProb) Len

func (p *ParamProb) Len(proto int) int

Len implements the Len method of MessageBody interface.

func (*ParamProb) Marshal

func (p *ParamProb) Marshal(proto int) ([]byte, error)

Marshal implements the Marshal method of MessageBody interface.

type RawBody

type RawBody struct {
	Data []byte // data
}

A RawBody represents a raw message body.

A raw message body is excluded from message processing and can be used to construct applications such as protocol conformance testing.

func (*RawBody) Len

func (p *RawBody) Len(proto int) int

Len implements the Len method of MessageBody interface.

func (*RawBody) Marshal

func (p *RawBody) Marshal(proto int) ([]byte, error)

Marshal implements the Marshal method of MessageBody interface.

type RawExtension

type RawExtension struct {
	Data []byte // data
}

A RawExtension represents a raw extension.

A raw extension is excluded from message processing and can be used to construct applications such as protocol conformance testing.

func (*RawExtension) Len

func (p *RawExtension) Len(proto int) int

Len implements the Len method of Extension interface.

func (*RawExtension) Marshal

func (p *RawExtension) Marshal(proto int) ([]byte, error)

Marshal implements the Marshal method of Extension interface.

type TimeExceeded

type TimeExceeded struct {
	Data       []byte      // data, known as original datagram field
	Extensions []Extension // extensions
}

A TimeExceeded represents an ICMP time exceeded message body.

func (*TimeExceeded) Len

func (p *TimeExceeded) Len(proto int) int

Len implements the Len method of MessageBody interface.

func (*TimeExceeded) Marshal

func (p *TimeExceeded) Marshal(proto int) ([]byte, error)

Marshal implements the Marshal method of MessageBody interface.

type Timestamp

type Timestamp struct {
	ID        int // identifier
	Seq       int // sequence number
	Originate int
	Receive   int
	Transmit  int
}

An Timestamp represents an ICMP Timestamp request or reply message body.

func (*Timestamp) Len

func (p *Timestamp) Len(proto int) int

Len implements the Len method of MessageBody interface.

func (*Timestamp) Marshal

func (p *Timestamp) Marshal(proto int) ([]byte, error)

Marshal implements the Marshal method of MessageBody interface.

type Type

type Type interface {
	Protocol() int
}

A Type represents an ICMP message type.

Notes

Bugs

  • This package is not implemented on JS, NaCl and Plan 9.

Jump to

Keyboard shortcuts

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