Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrorNotEnoughBytes is returned when the length of the []byte // to be decoded does not exceed the minimum header length. ErrorNotEnoughBytes = errors.New("proto: not enough bytes available to decode") )
Functions ¶
This section is empty.
Types ¶
type EthernetFrame ¶
type EthernetFrame struct { Destination net.HardwareAddr `json:"source"` Source net.HardwareAddr `json:"destination"` VlanTag uint32 `json:"vlanTag"` EtherType uint16 `json:"etherType"` Payload []byte `json:"payload"` }
EthernetFrame represents an Ethernet frame.
func DecodeEthernet ¶
func DecodeEthernet(b []byte) (EthernetFrame, error)
DecodeEthernet decodes an Ethernet frame.
func (EthernetFrame) Bytes ¶
func (f EthernetFrame) Bytes() []byte
Bytes returns an encoded Ethernet frame.
type IPv4Packet ¶
type IPv4Packet struct { Version uint8 `json:"version"` InternetHeaderLength uint8 `json:"internetHeaderLength"` DSCP uint8 `json:"dscp"` ECN uint8 `json:"ecn"` Length uint16 `json:"length"` Identification uint16 `json:"indentification"` Flags uint8 `json:"flags"` FragmentationOffset uint16 `json:"fragmentationOffset"` TimeToLive uint8 `json:"timeToLive"` Protocol uint8 `json:"protocol"` HeaderChecksum uint16 `json:"headerChecksum"` Source net.IP `json:"source"` Destination net.IP `json:"destination"` Options []byte `json:"options"` Payload []byte `json:"payload"` }
IPv4Packet represents an IPv4 packet.
func (IPv4Packet) ComputeChecksum ¶
func (p IPv4Packet) ComputeChecksum() uint16
ComputeChecksum returns the checksum for the IPv4 packet.
type IPv6Packet ¶
type IPv6Packet struct { Version uint8 `json:"version"` TrafficClass uint8 `json:"trafficClass"` FlowLabel uint32 `json:"flowLabel"` Length uint16 `json:"length"` NextHeader uint8 `json:"nextHeader"` HopLimit uint8 `json:"hopLimit"` Source net.IP `json:"source"` Destination net.IP `json:"destination"` Payload []byte `json:"payload"` }
IPv6Packet represents an IPv6 packet.
type TCPPacket ¶
type TCPPacket struct { SourcePort uint16 `json:"sourcePort"` DestinationPort uint16 `json:"destinationPort"` SequenceNumber uint32 `json:"sequenceNumber"` AcknowledgementNumber uint32 `json:"acknowledgementNumber"` DataOffset uint8 `json:"dataOffset"` // We have 9 bits of flags // so we're going to waste a // few bits of space using a // uint16. Flags uint16 `json:"flags"` WindowSize uint16 `json:"windowSize"` Checksum uint16 `json:"checksum"` UrgentPointer uint16 `json:"urgentPointer"` Options []byte `json:"options"` Payload []byte `json:"payload"` }
TCPPacket represents a TCP packet.
Click to show internal directories.
Click to hide internal directories.