ethernet

package
v0.0.0-...-11c6e6d Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unbind

func Unbind(proto EtherType) error

Unbind allows clients to unbind from specific EtherTypes

func WriteSingle

func WriteSingle(dstMAC *MACAddress, ethertype EtherType, data []byte) (int, error)

WriteSingle is a helper method that is used for one-time sends that do not require a full Writer

Types

type EtherType

type EtherType uint16

EtherType implements the ethernet protocol's EtherType (https://en.wikipedia.org/wiki/EtherType).

const (
	EtherTypeIP  EtherType = 0x0800
	EtherTypeARP EtherType = 0x0806
)

Major EtherTypes as constants

type FrameHeader

type FrameHeader struct {
	//Rmac, Lmac *MAC_Address
	Packet []byte
}

A FrameHeader is used when returning data from Reader.Read() calls

type MACAddress

type MACAddress struct {
	Data []byte
}

The MACAddress type holds a 48-bit MAC Address

var (
	LoopbackMACAddress       *MACAddress
	ExternalMACAddress       *MACAddress
	LoopbackBroadcastAddress *MACAddress
	ExternalBroadcastAddress *MACAddress
)

Static MAC addresses and broadcast addresses

type Reader

type Reader interface {
	Read() (*FrameHeader, error)
	io.Closer
}

Reader allows for reading packets from all interfaces for a specific EtherType

func Bind

func Bind(proto EtherType) (Reader, error)

Bind allows clients to bind to specific EtherTypes

type Writer

type Writer interface {
	Write(data []byte) (n int, err error)
	io.Closer
}

Writer allows for writing packets to a specific MAC address and EtherType

func NewEthernetWriter

func NewEthernetWriter(dstMAC *MACAddress, ethertype EtherType) (Writer, error)

NewEthernetWriter allows for the writing to a given MAC Address and EtherType

Jump to

Keyboard shortcuts

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