Documentation ¶
Index ¶
- Variables
- type Ethertype
- type Frame
- func (f Frame) Destination() net.HardwareAddr
- func (f Frame) Ethertype() Ethertype
- func (f Frame) Payload() []byte
- func (f *Frame) Prepare(dst net.HardwareAddr, src net.HardwareAddr, tagging Tagging, ...)
- func (f *Frame) Resize(payloadSize int)
- func (f Frame) Source() net.HardwareAddr
- func (f Frame) Tagging() Tagging
- func (f Frame) Tags() []byte
- type Tagging
Constants ¶
This section is empty.
Variables ¶
var ( IPv4 = Ethertype{0x08, 0x00} ARP = Ethertype{0x08, 0x06} WakeOnLAN = Ethertype{0x08, 0x42} TRILL = Ethertype{0x22, 0xF3} DECnetPhase4 = Ethertype{0x60, 0x03} RARP = Ethertype{0x80, 0x35} AppleTalk = Ethertype{0x80, 0x9B} AARP = Ethertype{0x80, 0xF3} IPX1 = Ethertype{0x81, 0x37} IPX2 = Ethertype{0x81, 0x38} QNXQnet = Ethertype{0x82, 0x04} IPv6 = Ethertype{0x86, 0xDD} EthernetFlowControl = Ethertype{0x88, 0x08} IEEE802_3 = Ethertype{0x88, 0x09} CobraNet = Ethertype{0x88, 0x19} MPLSUnicast = Ethertype{0x88, 0x47} MPLSMulticast = Ethertype{0x88, 0x48} PPPoEDiscovery = Ethertype{0x88, 0x63} PPPoESession = Ethertype{0x88, 0x64} JumboFrames = Ethertype{0x88, 0x70} HomePlug1_0MME = Ethertype{0x88, 0x7B} IEEE802_1X = Ethertype{0x88, 0x8E} PROFINET = Ethertype{0x88, 0x92} HyperSCSI = Ethertype{0x88, 0x9A} AoE = Ethertype{0x88, 0xA2} EtherCAT = Ethertype{0x88, 0xA4} EthernetPowerlink = Ethertype{0x88, 0xAB} LLDP = Ethertype{0x88, 0xCC} SERCOS3 = Ethertype{0x88, 0xCD} WSMP = Ethertype{0x88, 0xDC} HomePlugAVMME = Ethertype{0x88, 0xE1} MRP = Ethertype{0x88, 0xE3} IEEE802_1AE = Ethertype{0x88, 0xE5} IEEE1588 = Ethertype{0x88, 0xF7} IEEE802_1ag = Ethertype{0x89, 0x02} FCoE = Ethertype{0x89, 0x06} FCoEInit = Ethertype{0x89, 0x14} RoCE = Ethertype{0x89, 0x15} CTP = Ethertype{0x90, 0x00} VeritasLLT = Ethertype{0xCA, 0xFE} )
Common ethertype values
Functions ¶
This section is empty.
Types ¶
type Ethertype ¶
type Ethertype [2]byte
Ethertype is a type used represent the ethertype of an ethernet frame. Defined as a 2-byte array, variables of this type are intended to be used as immutable values.
type Frame ¶
type Frame []byte
Frame represents an ethernet frame. The length of the underlying slice of a Frame should always reflect the ethernet frame length.
func (Frame) Destination ¶
func (f Frame) Destination() net.HardwareAddr
Destination returns the destination address field of the frame. The address references a slice on the frame.
It is not safe to use this method if f is nil or an invalid ethernet frame.
func (Frame) Ethertype ¶
Ethertype returns the ethertype field of the frame.
It is not safe to use this method if f is nil or an invalid ethernet frame.
func (Frame) Payload ¶
Payload returns a slice holding the payload part of the frame. Upper layer should use the returned slice for both reading and writing purposes.
It is not safe to use this method if f is nil or an invalid ethernet frame.
func (*Frame) Prepare ¶
func (f *Frame) Prepare(dst net.HardwareAddr, src net.HardwareAddr, tagging Tagging, ethertype Ethertype, payloadSize int)
Prepare prepares *f to be used, by filling in dst/src address, setting up proper tagging and ethertype, and resizing it to proper length.
It is safe to call Prepare on a pointer to a nil Frame or invalid Frame.
func (*Frame) Resize ¶
Resize re-slices (*f) so that len(*f) holds exactly payloadSize bytes of payload. If cap(*f) is not large enough, a new slice is made and content from old slice is copied to the new one.
If len(*f) is less than 14 bytes, it is assumed to be not tagged.
It is safe to call Resize on a pointer to a nil Frame.
func (Frame) Source ¶
func (f Frame) Source() net.HardwareAddr
Source returns the source address field of the frame. The address references a slice on the frame.
It is not safe to use this method if f is nil or an invalid ethernet frame.
func (Frame) Tagging ¶
Tagging returns whether/how the frame has 802.1Q tag(s).
It is not safe to use this method if f is nil or an invalid ethernet frame.
func (Frame) Tags ¶
Tag returns a slice holding the tag part of the frame, if any. Note that this includes the Tag Protocol Identifier (TPID), e.g. 0x8100 or 0x88a8. Upper layer should use the returned slice for both reading and writing.
It is not safe to use this method if f is nil or an invalid ethernet frame.