wintun

package
v0.0.0-...-e0a30a8 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Rendered for windows/amd64

Index

Constants

View Source
const (
	PacketAlignment    = 4        // Number of bytes packets are aligned to in rings
	PacketSizeMax      = 0xffff   // Maximum packet size
	PacketCapacity     = 0x800000 // Ring capacity, 8MiB
	PacketTrailingSize = uint32(unsafe.Sizeof(PacketHeader{})) + ((PacketSizeMax + (PacketAlignment - 1)) &^ (PacketAlignment - 1)) - PacketAlignment
)

Variables

This section is empty.

Functions

func PacketAlign

func PacketAlign(size uint32) uint32

Aligns a packet size to PacketAlignment

Types

type Interface

type Interface struct {
	// contains filtered or unexported fields
}

func (*Interface) DeleteInterface

func (wintun *Interface) DeleteInterface() (rebootRequired bool, err error)

DeleteInterface deletes a Wintun interface. This function succeeds if the interface was not found. It returns a bool indicating whether a reboot is required.

func (*Interface) GUID

func (wintun *Interface) GUID() windows.GUID

GUID returns the GUID of the interface.

func (*Interface) LUID

func (wintun *Interface) LUID() uint64

LUID returns the LUID of the interface.

func (*Interface) Name

func (wintun *Interface) Name() (string, error)

Name returns the name of the Wintun interface.

func (*Interface) Register

func (wintun *Interface) Register(descriptor *RingDescriptor) (windows.Handle, error)

func (*Interface) SetName

func (wintun *Interface) SetName(ifname string) error

SetName sets name of the Wintun interface.

func (*Interface) Version

func (wintun *Interface) Version() (driverVersion string, ndisVersion string, err error)

Version returns the version of the Wintun driver and NDIS system currently loaded.

type Packet

type Packet struct {
	PacketHeader
	Data [PacketSizeMax]byte
}

type PacketHeader

type PacketHeader struct {
	Size uint32
}

type Pool

type Pool string

func (Pool) CreateInterface

func (pool Pool) CreateInterface(ifname string, requestedGUID *windows.GUID) (wintun *Interface, rebootRequired bool, err error)

CreateInterface creates a Wintun interface. ifname is the requested name of the interface, while requestedGUID is the GUID of the created network interface, which then influences NLA generation deterministically. If it is set to nil, the GUID is chosen by the system at random, and hence a new NLA entry is created for each new interface. It is called "requested" GUID because the API it uses is completely undocumented, and so there could be minor interesting complications with its usage. This function returns the network interface ID and a flag if reboot is required.

func (Pool) DeleteMatchingInterfaces

func (pool Pool) DeleteMatchingInterfaces(matches func(wintun *Interface) bool) (deviceInstancesDeleted []uint32, rebootRequired bool, errors []error)

DeleteMatchingInterfaces deletes all Wintun interfaces, which match given criteria, and returns which ones it deleted, whether a reboot is required after, and which errors occurred during the process.

func (Pool) GetInterface

func (pool Pool) GetInterface(ifname string) (*Interface, error)

GetInterface finds a Wintun interface by its name. This function returns the interface if found, or windows.ERROR_OBJECT_NOT_FOUND otherwise. If the interface is found but not a Wintun-class or a member of the pool, this function returns windows.ERROR_ALREADY_EXISTS.

type Ring

type Ring struct {
	Head      uint32
	Tail      uint32
	Alertable int32
	Data      [PacketCapacity + PacketTrailingSize]byte
}

func (*Ring) Wrap

func (rb *Ring) Wrap(value uint32) uint32

Wrap returns value modulo ring capacity

type RingDescriptor

type RingDescriptor struct {
	Send, Receive struct {
		Size      uint32
		Ring      *Ring
		TailMoved windows.Handle
	}
}

func NewRingDescriptor

func NewRingDescriptor() (descriptor *RingDescriptor, err error)

func (*RingDescriptor) Close

func (descriptor *RingDescriptor) Close()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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