Documentation ¶
Overview ¶
Package icmp provides basic functions for the manipulation of ICMP message.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IPv6PseudoHeader ¶
IPv6PseudoHeader returns an IPv6 pseudo header for checkusm calculation.
Types ¶
type DefaultMessageBody ¶
type DefaultMessageBody struct {
Data []byte // data
}
A DefaultMessageBody represents the default message body.
func (*DefaultMessageBody) Len ¶
func (p *DefaultMessageBody) Len() int
Len implements the Len method of MessageBody interface.
func (*DefaultMessageBody) Marshal ¶
func (p *DefaultMessageBody) Marshal() ([]byte, error)
Marshal implements the Marshal method of MessageBody 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 ¶
ParseMessage parses b as an ICMP message. Proto must be iana.ProtocolICMP or iana.ProtocolIPv6ICMP.
func (*Message) Marshal ¶
Marshal returns the binary enconding of the ICMP message m.
For ICMP for IPv4 message, the returned message always contains the calculated checksum field.
For ICMP for IPv6 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. Len() int // Marshal returns the binary enconding of ICMP message body. Marshal() ([]byte, error) }
A MessageBody represents an ICMP message body.