ethernet

package
v0.0.0-...-d51fe85 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const MockEthernetInterfaceBufferSize = 1024
View Source
const (
	TYPE_ARP = 0x0806
)

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 EthernetII

type EthernetII struct {
	Destination MACAddr
	Source      MACAddr
	Type        uint16
}

func (*EthernetII) Serialize

func (e *EthernetII) Serialize(buf *bytes.Buffer)

type EthernetInterface

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

func NewEthernetInterface

func NewEthernetInterface(devName string, bpf *BPF, protocol uint16) (*EthernetInterface, error)

func (*EthernetInterface) Close

func (e *EthernetInterface) Close()

Close closes the handler

func (*EthernetInterface) GetIfIndex

func (e *EthernetInterface) GetIfIndex() uint32

func (*EthernetInterface) GetMACAddress

func (e *EthernetInterface) GetMACAddress() MACAddr

func (*EthernetInterface) MCastJoin

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

MCastJoin joins a multicast group

func (*EthernetInterface) NewConn

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

NewConn creates a new ethernet conn

func (*EthernetInterface) RecvPacket

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

func (*EthernetInterface) SendPacket

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

SendPacket sends an 802.3 ethernet packet (LLC)

type EthernetInterfaceFactory

type EthernetInterfaceFactory struct{}

func NewEthernetInterfaceFactory

func NewEthernetInterfaceFactory() *EthernetInterfaceFactory

func (*EthernetInterfaceFactory) New

func (eif *EthernetInterfaceFactory) New(name string, bpf *BPF, protocol uint16) (EthernetInterfaceI, error)

type EthernetInterfaceFactoryI

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

type EthernetInterfaceI

type EthernetInterfaceI interface {
	RecvPacket() (pkt []byte, src MACAddr, err error)
	SendPacket(dst MACAddr, pkt []byte) error
	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

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

func NewMockEthernetInterface

func NewMockEthernetInterface() *MockEthernetInterface

func (*MockEthernetInterface) Close

func (mei *MockEthernetInterface) Close()

func (*MockEthernetInterface) DrainBuffer

func (mei *MockEthernetInterface) DrainBuffer()

func (*MockEthernetInterface) GetMTU

func (mei *MockEthernetInterface) GetMTU() int

func (*MockEthernetInterface) MCastJoin

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

func (*MockEthernetInterface) ReceiveAtRemote

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

func (*MockEthernetInterface) RecvPacket

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

func (*MockEthernetInterface) SendFromRemote

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

func (*MockEthernetInterface) SendPacket

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

type MockEthernetInterfaceFactory

type MockEthernetInterfaceFactory struct{}

func NewMockEthernetInterfaceFactory

func NewMockEthernetInterfaceFactory() *MockEthernetInterfaceFactory

func (*MockEthernetInterfaceFactory) New

Jump to

Keyboard shortcuts

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