Documentation
¶
Overview ¶
Package tun provides a TUN device implementation for noisysockets.
Index ¶
- Constants
- func Create(ctx context.Context, logger *slog.Logger, name string, conf *Configuration) (network.Interface, error)
- type Configuration
- type Interface
- func (nic *Interface) BatchSize() int
- func (nic *Interface) Close() error
- func (nic *Interface) MTU() (int, error)
- func (nic *Interface) Read(ctx context.Context, packets []*network.Packet, offset int) ([]*network.Packet, error)
- func (nic *Interface) Write(ctx context.Context, packets []*network.Packet) error
Constants ¶
View Source
const ( // VirtioNetHdrLen is the length in bytes of virtioNetHdr. This matches the // shape of the C ABI for its kernel counterpart -- sizeof(virtio_net_hdr). VirtioNetHdrLen = int(unsafe.Sizeof(virtioNetHdr{})) )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Configuration ¶ added in v0.18.1
type Configuration struct {
// BatchSize is the number of packets to read in a single syscall.
// This is only used when the TUN device supports IFF_VNET_HDR.
BatchSize *int
// MTU is the maximum transmission unit of the TUN device.
// If not specified, the default is 1500.
MTU *int
// PacketPool is the pool from which packets are borrowed.
// If not specified, an unbounded pool will be created.
PacketPool *network.PacketPool
// Fd is optionally the file descriptor of an existing TUN device.
Fd *int
// Unmanaged is a flag to indicate if the TUN device is unmanaged
// eg. we are not responsible for setting the MTU or bringing the
// link up.
Unmanaged bool
}
Configuration is the configuration for a TUN device.
Click to show internal directories.
Click to hide internal directories.