ethernet

package
v0.0.3-pre7 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 Handler

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

Handler is an Ethernet handler

func NewHandler

func NewHandler(devName string, bpf *BPF, llc LLC) (*Handler, error)

NewHandler creates a new Ethernet handler

func (*Handler) Close

func (e *Handler) Close()

Close closes the handler

func (*Handler) GetMTU

func (e *Handler) GetMTU() int

GetMTU gets the interfaces MTU

func (*Handler) MCastJoin

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

MCastJoin joins a multicast group

func (*Handler) NewConn

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

NewConn creates a new ethernet conn

func (*Handler) RecvPacket

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

RecvPacket receives a packet on the ethernet handler

func (*Handler) SendPacket

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

SendPacket sends an 802.3 ethernet packet (LLC)

type HandlerInterface

type HandlerInterface interface {
	NewConn(dest MACAddr) net.Conn
	RecvPacket() (pkt []byte, src MACAddr, err error)
	SendPacket(dst MACAddr, pkt []byte) error
	MCastJoin(addr MACAddr) error
	GetMTU() int
	Close()
}

HandlerInterface is an handler interface

func NewMockHandler

func NewMockHandler() HandlerInterface

NewMockHandler creates a new mock handler

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 MockConn

type MockConn struct {
	C *btesting.MockConnBidi
	// contains filtered or unexported fields
}

MockConn is a mock of Conn

func (*MockConn) Close

func (c *MockConn) Close() error

Close is here to fulfill the net.Conn interface

func (*MockConn) LocalAddr

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

LocalAddr returns the local address

func (*MockConn) Read

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

Read is there to fulfill the net.Conn interface

func (*MockConn) RemoteAddr

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

RemoteAddr returns the remote address

func (*MockConn) SetDeadline

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

SetDeadline is here to fulfill the net.Conn interface

func (*MockConn) SetReadDeadline

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

SetReadDeadline is here to fulfill the net.Conn interface

func (*MockConn) SetWriteDeadline

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

SetWriteDeadline is here to fulfill the net.Conn interface

func (*MockConn) Write

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

Write sends b on the Conn

type MockHandler

type MockHandler struct {
}

MockHandler mocks an ethernet handler

func (*MockHandler) Close

func (m *MockHandler) Close()

Close is here to fulfill an interface

func (*MockHandler) GetMTU

func (m *MockHandler) GetMTU() int

GetMTU is here to fulfill an interface

func (*MockHandler) MCastJoin

func (m *MockHandler) MCastJoin(addr MACAddr) error

MCastJoin is here to fulfill an interface

func (*MockHandler) NewConn

func (m *MockHandler) NewConn(dest MACAddr) net.Conn

NewConn creates a new mocked ethernet conn

func (*MockHandler) RecvPacket

func (m *MockHandler) RecvPacket() (pkt []byte, src MACAddr, err error)

RecvPacket to be implemented

func (*MockHandler) SendPacket

func (m *MockHandler) SendPacket(dst MACAddr, pkt []byte) error

SendPacket is here to fulfill an interface

Jump to

Keyboard shortcuts

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