protocol

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2015 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ARP

type ARP struct {
	HWType      uint16
	ProtoType   uint16
	HWLength    uint8
	ProtoLength uint8
	Operation   uint16
	SHA         net.HardwareAddr // Sender Hardware Address
	SPA         net.IP           // Sender Protocol Address
	THA         net.HardwareAddr // Target Hardware Address
	TPA         net.IP           // Target Protocol Address
}

func NewARPReply

func NewARPReply(sha, tha net.HardwareAddr, spa, tpa net.IP) *ARP

func NewARPRequest

func NewARPRequest(sha net.HardwareAddr, spa, tpa net.IP) *ARP

func (ARP) MarshalBinary

func (r ARP) MarshalBinary() ([]byte, error)

func (ARP) String added in v0.9.0

func (r ARP) String() string

func (*ARP) UnmarshalBinary

func (r *ARP) UnmarshalBinary(data []byte) error

type Ethernet

type Ethernet struct {
	SrcMAC, DstMAC net.HardwareAddr
	Type           uint16
	Payload        []byte
}

func (Ethernet) MarshalBinary

func (r Ethernet) MarshalBinary() ([]byte, error)

func (*Ethernet) UnmarshalBinary

func (r *Ethernet) UnmarshalBinary(data []byte) error

type ICMP

type ICMP struct {
	Type     uint8
	Code     uint8
	Checksum uint16
}

type ICMPEcho

type ICMPEcho struct {
	ICMP
	ID       uint16
	Sequence uint16
	Payload  []byte
}

func NewICMPEchoReply

func NewICMPEchoReply(id, seq uint16, payload []byte) *ICMPEcho

func NewICMPEchoRequest

func NewICMPEchoRequest(id, seq uint16, payload []byte) *ICMPEcho

func (ICMPEcho) MarshalBinary

func (r ICMPEcho) MarshalBinary() ([]byte, error)

func (*ICMPEcho) UnmarshalBinary

func (r *ICMPEcho) UnmarshalBinary(data []byte) error

type IPv4

type IPv4 struct {
	Version  uint8
	IHL      uint8
	DSCP     uint8
	ECN      uint8
	Length   uint16
	ID       uint16
	Flags    uint8
	Offset   uint16
	TTL      uint8
	Protocol uint8
	Checksum uint16
	SrcIP    net.IP
	DstIP    net.IP
	Payload  []byte
}

func NewIPv4

func NewIPv4(src, dst net.IP, protocol uint8, payload []byte) *IPv4

func (IPv4) MarshalBinary

func (r IPv4) MarshalBinary() ([]byte, error)

func (*IPv4) UnmarshalBinary

func (r *IPv4) UnmarshalBinary(data []byte) error

type LLDP

type LLDP struct {
	ChassisID LLDPChassisID
	PortID    LLDPPortID
	TTL       uint16
}

func (*LLDP) MarshalBinary

func (r *LLDP) MarshalBinary() ([]byte, error)

func (*LLDP) UnmarshalBinary

func (r *LLDP) UnmarshalBinary(data []byte) error

type LLDPChassisID

type LLDPChassisID struct {
	SubType uint8
	Data    []byte
}

type LLDPPortID

type LLDPPortID struct {
	SubType uint8
	Data    []byte
}

type TCP

type TCP struct {
	SrcPort        uint16
	DstPort        uint16
	Sequence       uint32
	Acknowledgment uint32
	// From LSB, FIN, SYN, RST, PSH, ACK, URG, ECE, CWR, and NS.
	Flags      uint16
	WindowSize uint16
	Checksum   uint16
	Urgent     uint16
	Payload    []byte
	// contains filtered or unexported fields
}

func (TCP) MarshalBinary

func (r TCP) MarshalBinary() ([]byte, error)

func (*TCP) SetPseudoHeader

func (r *TCP) SetPseudoHeader(src, dst net.IP)

TCP checksum needs a pseudo header that has src and dst IPv4 addresses.

func (*TCP) UnmarshalBinary

func (r *TCP) UnmarshalBinary(data []byte) error

type UDP

type UDP struct {
	SrcPort  uint16
	DstPort  uint16
	Length   uint16
	Checksum uint16
	Payload  []byte
	// contains filtered or unexported fields
}

func (UDP) MarshalBinary

func (r UDP) MarshalBinary() ([]byte, error)

func (*UDP) SetPseudoHeader

func (r *UDP) SetPseudoHeader(src, dst net.IP)

UDP checksum needs a pseudo header that has src and dst IPv4 addresses.

func (*UDP) UnmarshalBinary

func (r *UDP) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

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