package tun
import "gvisor.dev/gvisor/pkg/tcpip/link/tun"
Package tun contains methods to open TAP and TUN devices.
Index ¶
- Constants
- func Open(name string) (int, error)
- func OpenTAP(name string) (int, error)
- type Device
- func (d *Device) Flags() Flags
- func (d *Device) MTU() (uint32, error)
- func (d *Device) Name() string
- func (d *Device) Read() (*buffer.View, error)
- func (d *Device) Readiness(mask waiter.EventMask) waiter.EventMask
- func (d *Device) Release(ctx context.Context)
- func (d *Device) SetIff(ctx context.Context, s *stack.Stack, name string, flags Flags) error
- func (d *Device) SetPersistent(v bool) error
- func (d *Device) Write(data *buffer.View) (int64, error)
- func (d *Device) WriteNotify()
- type Flags
- type PacketInfoFields
- type PacketInfoHeader
Constants ¶
const ( // PacketInfoHeaderSize is the size of the packet information header. PacketInfoHeaderSize = 4 )
Functions ¶
func Open ¶
Open opens the specified TUN device, sets it to non-blocking mode, and returns its file descriptor.
func OpenTAP ¶
OpenTAP opens the specified TAP device, sets it to non-blocking mode, and returns its file descriptor.
Types ¶
type Device ¶
Device is an opened /dev/net/tun device.
+stateify savable
func (*Device) Flags ¶
Flags returns the flags set for d. Zero value if unset.
func (*Device) MTU ¶
MTU returns the tun endpoint MTU (maximum transmission unit).
func (*Device) Name ¶
Name returns the name of the attached network interface. Empty string if unattached.
func (*Device) Read ¶
Read reads one outgoing packet from the network interface.
func (*Device) Readiness ¶
Readiness implements watier.Waitable.Readiness.
func (*Device) Release ¶
Release implements fs.FileOperations.Release.
func (*Device) SetIff ¶
SetIff services TUNSETIFF ioctl(2) request.
func (*Device) SetPersistent ¶
func (*Device) Write ¶
Write inject one inbound packet to the network interface.
func (*Device) WriteNotify ¶
func (d *Device) WriteNotify()
WriteNotify implements channel.Notification.WriteNotify.
type Flags ¶
Flags set properties of a Device
+stateify savable
type PacketInfoFields ¶
type PacketInfoFields struct { Flags uint16 Protocol tcpip.NetworkProtocolNumber }
PacketInfoFields contains fields sent through the wire if IFF_NO_PI flag is not set.
type PacketInfoHeader ¶
type PacketInfoHeader []byte
PacketInfoHeader is the wire representation of the packet information sent if IFF_NO_PI flag is not set.
func (PacketInfoHeader) Encode ¶
func (h PacketInfoHeader) Encode(f *PacketInfoFields)
Encode encodes f into h.
func (PacketInfoHeader) Flags ¶
func (h PacketInfoHeader) Flags() uint16
Flags returns the flag field in h.
func (PacketInfoHeader) Protocol ¶
func (h PacketInfoHeader) Protocol() tcpip.NetworkProtocolNumber
Protocol returns the protocol field in h.
Source Files ¶
device.go protocol.go tun_unsafe.go
- Version
- v0.0.0-20250605235530-a6711d1e1dc6 (latest)
- Published
- Jun 5, 2025
- Platform
- linux/amd64
- Imports
- 14 packages
- Last checked
- 4 hours ago –
Tools for package owners.