packet

package
v0.0.0-...-9d436b2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPProtocolIPv6HopByHop    IPProtocol = 0
	IPProtocolICMPv4          IPProtocol = 1
	IPProtocolIGMP            IPProtocol = 2
	IPProtocolIPv4            IPProtocol = 4
	IPProtocolTCP             IPProtocol = 6
	IPProtocolUDP             IPProtocol = 17
	IPProtocolRUDP            IPProtocol = 27
	IPProtocolIPv6            IPProtocol = 41
	IPProtocolIPv6Routing     IPProtocol = 43
	IPProtocolIPv6Fragment    IPProtocol = 44
	IPProtocolGRE             IPProtocol = 47
	IPProtocolESP             IPProtocol = 50
	IPProtocolAH              IPProtocol = 51
	IPProtocolICMPv6          IPProtocol = 58
	IPProtocolNoNextHeader    IPProtocol = 59
	IPProtocolIPv6Destination IPProtocol = 60
	IPProtocolIPIP            IPProtocol = 94
	IPProtocolEtherIP         IPProtocol = 97
	IPProtocolSCTP            IPProtocol = 132
	IPProtocolUDPLite         IPProtocol = 136
	IPProtocolMPLSInIP        IPProtocol = 137

	IPv4_PSEUDO_LENGTH int = 12
)

Variables

This section is empty.

Functions

func Checksum

func Checksum(fields ...[]byte) uint16

func IPID

func IPID() uint16

func ParseICMPv4

func ParseICMPv4(pkt []byte, icmp4 *ICMPv4) error

func ParseIPv4

func ParseIPv4(pkt []byte, ip4 *IPv4) error

func ReleaseICMPv4

func ReleaseICMPv4(icmp4 *ICMPv4)

func ReleaseIPv4

func ReleaseIPv4(ip4 *IPv4)

Types

type ICMPv4

type ICMPv4 struct {
	Type     uint8
	Code     uint8
	Checksum uint16
	Payload  []byte
}

func NewICMPv4

func NewICMPv4() *ICMPv4

func (*ICMPv4) Serialize

func (icmp4 *ICMPv4) Serialize(hdr []byte, ckFields ...[]byte) error

type IPProtocol

type IPProtocol uint8

IPProtocol is an enumeration of IP protocol values, and acts as a decoder for any type it supports.

type IPv4

type IPv4 struct {
	Version    uint8
	IHL        uint8
	TOS        uint8
	Length     uint16
	Id         uint16
	Flags      uint8
	FragOffset uint16
	TTL        uint8
	Protocol   IPProtocol
	Checksum   uint16
	SrcIP      net.IP
	DstIP      net.IP
	Options    []IPv4Option
	Padding    []byte
	Payload    []byte
	// contains filtered or unexported fields
}

func NewIPv4

func NewIPv4() *IPv4

func (*IPv4) HeaderLength

func (ip *IPv4) HeaderLength() int

func (*IPv4) PseudoHeader

func (ip *IPv4) PseudoHeader(buf []byte, proto IPProtocol, dataLen int) error

func (*IPv4) Serialize

func (ip *IPv4) Serialize(hdr []byte, dataLen int) error

type IPv4Option

type IPv4Option struct {
	OptionType   uint8
	OptionLength uint8
	OptionData   []byte
}

Jump to

Keyboard shortcuts

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