packet

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: Apache-2.0 Imports: 6 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 IPID

func IPID() uint16

func ParseIPv4

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

func ParseTCP

func ParseTCP(pkt []byte, tcp *TCP) error

func ParseUDP

func ParseUDP(pkt []byte, udp *UDP) error

func PutIPv4

func PutIPv4(ip4 *IPv4)

func PutTCP

func PutTCP(tcp *TCP)

func PutUDP

func PutUDP(udp *UDP)

Types

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 GetIPv4

func GetIPv4() *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
}

type TCP

type TCP struct {
	SrcPort                                    uint16
	DstPort                                    uint16
	Seq                                        uint32
	Ack                                        uint32
	DataOffset                                 uint8
	FIN, SYN, RST, PSH, ACK, URG, ECE, CWR, NS bool
	Window                                     uint16
	Checksum                                   uint16
	Urgent                                     uint16
	Options                                    []TCPOption

	Padding []byte
	Payload []byte
	// contains filtered or unexported fields
}

func GetTCP

func GetTCP() *TCP

func (*TCP) HeaderLength

func (tcp *TCP) HeaderLength() int

func (*TCP) Serialize

func (tcp *TCP) Serialize(hdr []byte, ckFields ...[]byte) error

type TCPOption

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

type UDP

type UDP struct {
	SrcPort  uint16
	DstPort  uint16
	Length   uint16
	Checksum uint16
	Payload  []byte
}

func GetUDP

func GetUDP() *UDP

func (*UDP) Serialize

func (udp *UDP) Serialize(hdr []byte, ckFields ...[]byte) error

Jump to

Keyboard shortcuts

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