protocol

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: GPL-2.0 Imports: 8 Imported by: 5

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, tha net.HardwareAddr, spa, tpa net.IP) *ARP

func (ARP) MarshalBinary

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

func (ARP) String

func (r ARP) String() string

func (*ARP) UnmarshalBinary

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

type DHCP

type DHCP struct {
	Op      DHCPOpcode // Message op code / message type.
	Hops    uint8
	XID     uint32        // Transaction ID.
	Elapsed time.Duration // Elapsed since client began address acquisition or renewal process.
	Flags   uint16
	CIAddr  net.IP           // Client IP address.
	YIAddr  net.IP           // Your (client) IP address.
	SIAddr  net.IP           // IP address of next server to use in bootstrap.
	GIAddr  net.IP           // Relay agent IP address, used in booting via a relay agent.
	CHAddr  net.HardwareAddr // Client hardware address.
	SName   string           // Optional server host name.
	File    string           // Boot file name.
	Options []DHCPOption     // Optional parameters field.
	// contains filtered or unexported fields
}

See RFC 2131: Dynamic Host Configuration Protocol.

func (*DHCP) MarshalBinary

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

func (*DHCP) Option

func (r *DHCP) Option(code uint8) (opt DHCPOption, ok bool)

func (*DHCP) UnmarshalBinary

func (r *DHCP) UnmarshalBinary(data []byte) (err error)

type DHCPOpcode

type DHCPOpcode uint8
const (
	DHCPOpcodeRequest DHCPOpcode = 1
	DHCPOpcodeReply   DHCPOpcode = 2
)

type DHCPOption

type DHCPOption struct {
	Code  uint8
	Value []byte
}

See RFC 2132: DHCP Options and BOOTP Vendor Extensions.

func (*DHCPOption) MarshalBinary

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

func (*DHCPOption) UnmarshalBinary

func (r *DHCPOption) 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