Documentation
¶
Index ¶
- Constants
- func PacketOffset() int
- type IZSocket
- type ZSocket
- func (zs *ZSocket) Close() error
- func (zs *ZSocket) CopyToBuffer(buf []byte, l uint16, copyFx func(dst, src []byte, l uint16) uint16) (int32, error)
- func (zs *ZSocket) FlushFrames() (uint, error, []error)
- func (zs *ZSocket) Listen(fx func(*nettypes.Frame, uint16, uint16)) error
- func (zs *ZSocket) MaxPacketSize() uint16
- func (zs *ZSocket) MaxPackets() int32
- func (zs *ZSocket) WriteToBuffer(buf []byte, l uint16) (int32, error)
- func (zs *ZSocket) WrittenPackets() int32
Constants ¶
const ( TPacketAlignment = 16 MinimumFrameSize = TPacketAlignment << 7 MaximumFrameSize = TPacketAlignment << 11 EnableRX = 1 << 0 EnableTX = 1 << 1 DisableTXLoss = 1 << 2 )
Variables ¶
This section is empty.
Functions ¶
func PacketOffset ¶
func PacketOffset() int
Types ¶
type IZSocket ¶
type IZSocket interface { MaxPackets() int32 MaxPacketSize() uint16 WrittenPackets() int32 Listen(fx func(*nettypes.Frame, uint16, uint16)) WriteToBuffer(buf []byte, l uint16) (int32, error) CopyToBuffer(buf []byte, l uint16, copyFx func(dst, src []byte, l uint16)) (int32, error) FlushFrames() (uint, error, []error) Close() error }
IZSocket is an interface for interacting with eth-iface like objects in the ZSocket code-base. This has basically simply enabled the FakeInterface code to work.
type ZSocket ¶
type ZSocket struct {
// contains filtered or unexported fields
}
ZSocket opens a zero copy ring-buffer to the specified interface. Do not manually initialize ZSocket. Use `NewZSocket`.
func NewZSocket ¶
func NewZSocket(ethIndex, options int, maxFrameSize, maxTotalFrames uint, ethType nettypes.EthType) (*ZSocket, error)
NewZSocket opens a "ZSocket" on the specificed interface (by interfaceIndex). Whether the TX ring, RX ring, or both are enabled are options that can be passed. Additionally, an option can be passed that will tell the kernel to pay attention to packet faults, called DisableTXLoss.
func (*ZSocket) CopyToBuffer ¶
func (zs *ZSocket) CopyToBuffer(buf []byte, l uint16, copyFx func(dst, src []byte, l uint16) uint16) (int32, error)
CopyToBuffer is like WriteToBuffer, it writes a frame to the TX ring buffer. However, it can take a function argument, that will be passed the raw TX byes so that custom logic can be applied to copying the frame (for example, encrypting the frame).
func (*ZSocket) FlushFrames ¶
FlushFrames tells the kernel to flush all packets written to the TX ring buffer.n
func (*ZSocket) MaxPacketSize ¶
Returns the frame size in bytes
func (*ZSocket) MaxPackets ¶
Returns the maximum amount of frame packets that can be written
func (*ZSocket) WriteToBuffer ¶
WriteToBuffer writes a raw frame in bytes to the TX ring buffer. The length of the frame must be specified.
func (*ZSocket) WrittenPackets ¶
Returns the amount of packets, written to the tx ring, that haven't been flushed.