ethernet

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const MockEthernetInterfaceBufferSize = 1024

Variables

This section is empty.

Functions

This section is empty.

Types

type BPF

type BPF struct {
	// contains filtered or unexported fields
}

BPF represents a Berkeley Packet Filter

func NewBPF

func NewBPF() *BPF

NewBPF creates a new empty BPF

func (*BPF) AddTerm

func (b *BPF) AddTerm(t BPFTerm)

AddTerm adds a term to a BPF

type BPFTerm

type BPFTerm struct {
	Code uint16
	Jt   uint8
	Jf   uint8
	K    uint32
}

BPFTerm is a BPF Term

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn is a wrapper that implements net.Conn and sents packets to a particular destination (write only)

func (*Conn) Close

func (c *Conn) Close() error

Close is here to fulfill the net.Conn interface

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr returns the local address

func (*Conn) Read

func (c *Conn) Read(b []byte) (n int, err error)

Read is there to fulfill the net.Conn interface

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns the remote address

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

SetDeadline is here to fulfill the net.Conn interface

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline is here to fulfill the net.Conn interface

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline is here to fulfill the net.Conn interface

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

Write sends b on the Conn

type EthAddr

type EthAddr struct {
	// contains filtered or unexported fields
}

EthAddr implements net.Addr

func (EthAddr) Network

func (ea EthAddr) Network() string

Network returns "ethernet"

func (EthAddr) String

func (ea EthAddr) String() string

String returns the address

type EthernetInterface added in v0.1.8

type EthernetInterface struct {
	// contains filtered or unexported fields
}

func NewEthernetInterface added in v0.1.8

func NewEthernetInterface(devName string, bpf *BPF, llc LLC) (*EthernetInterface, error)

func (*EthernetInterface) Close added in v0.1.8

func (e *EthernetInterface) Close()

Close closes the handler

func (*EthernetInterface) GetMTU added in v0.1.8

func (e *EthernetInterface) GetMTU() int

GetMTU gets the interfaces MTU

func (*EthernetInterface) MCastJoin added in v0.1.8

func (e *EthernetInterface) MCastJoin(addr MACAddr) error

MCastJoin joins a multicast group

func (*EthernetInterface) NewConn added in v0.1.8

func (e *EthernetInterface) NewConn(dest MACAddr) net.Conn

NewConn creates a new ethernet conn

func (*EthernetInterface) RecvPacket added in v0.1.8

func (e *EthernetInterface) RecvPacket() (pkt []byte, src MACAddr, err error)

func (*EthernetInterface) SendPacket added in v0.1.8

func (e *EthernetInterface) SendPacket(dst MACAddr, pkt []byte) error

SendPacket sends an 802.3 ethernet packet (LLC)

type EthernetInterfaceFactory added in v0.1.8

type EthernetInterfaceFactory struct{}

func NewEthernetInterfaceFactory added in v0.1.8

func NewEthernetInterfaceFactory() *EthernetInterfaceFactory

func (*EthernetInterfaceFactory) New added in v0.1.8

func (eif *EthernetInterfaceFactory) New(name string, bpf *BPF, llc LLC) (EthernetInterfaceI, error)

type EthernetInterfaceFactoryI added in v0.1.8

type EthernetInterfaceFactoryI interface {
	New(name string, bpf *BPF, llc LLC) (EthernetInterfaceI, error)
}

type EthernetInterfaceI added in v0.1.8

type EthernetInterfaceI interface {
	RecvPacket() (pkt []byte, src MACAddr, err error)
	SendPacket(dst MACAddr, pkt []byte) error
	MCastJoin(addr MACAddr) error
	GetMTU() int
	Close()
}

type LLC

type LLC struct {
	DSAP         uint8
	SSAP         uint8
	ControlField uint8
}

LLC is a Logical Link Control header

type MACAddr

type MACAddr [ethALen]byte

MACAddr represens a MAC address

func (MACAddr) String

func (m MACAddr) String() string

type MockEthernetInterface added in v0.1.8

type MockEthernetInterface struct {
	// contains filtered or unexported fields
}

func NewMockEthernetInterface added in v0.1.8

func NewMockEthernetInterface() *MockEthernetInterface

func (*MockEthernetInterface) Close added in v0.1.8

func (mei *MockEthernetInterface) Close()

func (*MockEthernetInterface) DrainBuffer added in v0.1.8

func (mei *MockEthernetInterface) DrainBuffer()

func (*MockEthernetInterface) GetMTU added in v0.1.8

func (mei *MockEthernetInterface) GetMTU() int

func (*MockEthernetInterface) MCastJoin added in v0.1.8

func (mei *MockEthernetInterface) MCastJoin(addr MACAddr) error

func (*MockEthernetInterface) ReceiveAtRemote added in v0.1.8

func (mei *MockEthernetInterface) ReceiveAtRemote() (MACAddr, []byte)

func (*MockEthernetInterface) RecvPacket added in v0.1.8

func (mei *MockEthernetInterface) RecvPacket() (pkt []byte, src MACAddr, err error)

func (*MockEthernetInterface) SendFromRemote added in v0.1.8

func (mei *MockEthernetInterface) SendFromRemote(src MACAddr, pkt []byte)

func (*MockEthernetInterface) SendPacket added in v0.1.8

func (mei *MockEthernetInterface) SendPacket(dst MACAddr, pkt []byte) error

type MockEthernetInterfaceFactory added in v0.1.8

type MockEthernetInterfaceFactory struct{}

func NewMockEthernetInterfaceFactory added in v0.1.8

func NewMockEthernetInterfaceFactory() *MockEthernetInterfaceFactory

func (*MockEthernetInterfaceFactory) New added in v0.1.8

func (meif *MockEthernetInterfaceFactory) New(name string, bpf *BPF, llc LLC) (EthernetInterfaceI, error)

Jump to

Keyboard shortcuts

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