Documentation
¶
Index ¶
- Variables
- type L2PacketConn
- func (c *L2PacketConn) Close() error
- func (c *L2PacketConn) LocalMAC() tcpip.LinkAddress
- func (c *L2PacketConn) ReadBatchFrames(msgs []batchpc.Message, flags int) (int, error)
- func (c *L2PacketConn) ReadFrame(dst []byte) (int, error)
- func (c *L2PacketConn) WriteBatchFrames(msgs []batchpc.Message, flags int) (int, error)
- func (c *L2PacketConn) WriteFrame(frame []byte) error
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidFrame = errors.New("invalid frame")
Functions ¶
This section is empty.
Types ¶
type L2PacketConn ¶
type L2PacketConn struct {
// contains filtered or unexported fields
}
L2PacketConn adapts a net.PacketConn (UDP) to read/write L2 Ethernet frames.
func NewL2PacketConn ¶
func NewL2PacketConn(pc batchpc.BatchPacketConn) (*L2PacketConn, error)
NewL2PacketConn creates a new L2PacketConn.
func (*L2PacketConn) Close ¶
func (c *L2PacketConn) Close() error
func (*L2PacketConn) LocalMAC ¶
func (c *L2PacketConn) LocalMAC() tcpip.LinkAddress
LocalMAC returns the locally-administered unicast MAC address used by this connection.
func (*L2PacketConn) ReadBatchFrames ¶
ReadBatchFrames reads a batch of UDP payloads and emits fully-formed Ethernet frames into msgs[i].Buf (resizing the slice length to the frame size). msgs[i].Addr will be set to the remote *net.UDPAddr for convenience.
func (*L2PacketConn) ReadFrame ¶
func (c *L2PacketConn) ReadFrame(dst []byte) (int, error)
ReadFrame reads from PacketConn and emits a full Ethernet frame into dst. The Ethernet dst MAC is our random local MAC; the src MAC is a stable random, locally-administered unicast MAC based on the remote IP.
func (*L2PacketConn) WriteBatchFrames ¶
WriteBatchFrames consumes a batch of Ethernet frames (IPv4/IPv6 + UDP) and writes their UDP payloads to destinations extracted from each frame. On return, n is the number of frames successfully queued/written.
func (*L2PacketConn) WriteFrame ¶
func (c *L2PacketConn) WriteFrame(frame []byte) error
WriteFrame consumes an Ethernet frame (IPv4/IPv6 + UDP) and writes the payload to the underlying PacketConn based on the frame’s dst IP:port.