tun

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ND6_INFINITE_LIFETIME = 0xffffffff
View Source
const SIOCAIFADDR_IN6 = (unix.SIOCAIFADDR & 0xe000ffff) | (uint(unsafe.Sizeof(addrIfReq6{})) << 16)

SIOCAIFADDR_IN6 is the same ioctlHandle identifier as unix.SIOCAIFADDR adjusted with size of addrIfReq6

View Source
const SIOCDIFADDR_IN6 = (unix.SIOCDIFADDR & 0xe000ffff) | (uint(unsafe.Sizeof(addrIfReq6{})) << 16)

SIOCDIFADDR_IN6 is the same ioctlHandle identifier as unix.SIOCDIFADDR adjusted with size of addrIfReq6

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	*os.File
	// contains filtered or unexported fields
}

func OpenTun

func OpenTun() (*Device, error)

OpenTun creates a new TUN device and ensures that it is up and running.

func (*Device) AddSubnet

func (t *Device) AddSubnet(ctx context.Context, subnet *net.IPNet) error

AddSubnet adds a subnet to this TUN device and creates a route for that subnet which is associated with the device (removing the device will automatically remove the route).

func (*Device) Name

func (t *Device) Name() string

Name returns the name of this device, e.g. "tun0"

func (*Device) ReadPacket

func (t *Device) ReadPacket(into *buffer.Data) (int, error)

ReadPacket reads as many bytes as possible into the given buffer.Data and returns the number of bytes actually read

func (*Device) RemoveSubnet

func (t *Device) RemoveSubnet(ctx context.Context, subnet *net.IPNet) error

RemoveSubnet removes a subnet from this TUN device and also removes the route for that subnet which is associated with the device.

func (*Device) SetMTU

func (t *Device) SetMTU(mtu int) error

func (*Device) WritePacket

func (t *Device) WritePacket(from *buffer.Data) (int, error)

WritePacket writes bytes from the given buffer.Data and returns the number of bytes actually written.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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