wintun

package module
v0.0.0-...-1b380c4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: MIT Imports: 11 Imported by: 0

README

wintun-go

https://www.wintun.net/ sdk for golang

The project was extracted from https://github.com/WireGuard/wireguard-go/. Thanks for all the contributors of that project.

Documentation

Rendered for windows/amd64

Index

Constants

View Source
const (
	PacketSizeMax   = 0xffff    // Maximum packet size
	RingCapacityMin = 0x20000   // Minimum ring capacity (128 kiB)
	RingCapacityMax = 0x4000000 // Maximum ring capacity (64 MiB)
)
View Source
const (
	PoolNameMax    = 256
	AdapterNameMax = 128
)

Variables

View Source
var DisableLog = false

Functions

func RunningVersion

func RunningVersion() (version uint32, err error)

RunningVersion returns the version of the running Wintun driver.

Types

type Adapter

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

func (*Adapter) Delete

func (wintun *Adapter) Delete(forceCloseSessions bool) (rebootRequired bool, err error)

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

func (*Adapter) LUID

func (wintun *Adapter) LUID() (luid uint64)

LUID returns the LUID of the adapter.

func (*Adapter) Name

func (wintun *Adapter) Name() (ifname string, err error)

Name returns the name of the Wintun adapter.

func (*Adapter) SetName

func (wintun *Adapter) SetName(ifname string) (err error)

SetName sets name of the Wintun adapter.

func (*Adapter) StartSession

func (wintun *Adapter) StartSession(capacity uint32) (session Session, err error)

type Packet

type Packet struct {
	Next *Packet              // Pointer to next packet in queue
	Size uint32               // Size of packet (max WINTUN_MAX_IP_PACKET_SIZE)
	Data *[PacketSizeMax]byte // Pointer to layer 3 IPv4 or IPv6 packet
}

Packet with data

type Pool

type Pool [PoolNameMax]uint16

func MakePool

func MakePool(poolName string) (pool *Pool, err error)

func (*Pool) CreateAdapter

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

CreateAdapter creates a Wintun adapter. ifname is the requested name of the adapter, while requestedGUID is the GUID of the created network adapter, 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 adapter. 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 adapter ID and a flag if reboot is required.

func (*Pool) DeleteDriver

func (pool *Pool) DeleteDriver() (rebootRequired bool, err error)

DeleteDriver deletes all Wintun adapters in a pool and if there are no more adapters in any other pools, also removes Wintun from the driver store, usually called by uninstallers.

func (*Pool) DeleteMatchingAdapters

func (pool *Pool) DeleteMatchingAdapters(matches func(adapter *Adapter) bool, forceCloseSessions bool) (rebootRequired bool, errors []error)

DeleteMatchingAdapters deletes all Wintun adapters, 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) OpenAdapter

func (pool *Pool) OpenAdapter(ifname string) (wintun *Adapter, err error)

OpenAdapter finds a Wintun adapter by its name. This function returns the adapter if found, or windows.ERROR_FILE_NOT_FOUND otherwise. If the adapter is found but not a Wintun-class or a member of the pool, this function returns windows.ERROR_ALREADY_EXISTS. The adapter must be released after use.

func (*Pool) String

func (pool *Pool) String() string

type Session

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

func (Session) AllocateSendPacket

func (session Session) AllocateSendPacket(packetSize int) (packet []byte, err error)

func (Session) End

func (session Session) End()

func (Session) ReadWaitEvent

func (session Session) ReadWaitEvent() (handle windows.Handle)

func (Session) ReceivePacket

func (session Session) ReceivePacket() (packet []byte, err error)

func (Session) ReleaseReceivePacket

func (session Session) ReleaseReceivePacket(packet []byte)

func (Session) SendPacket

func (session Session) SendPacket(packet []byte)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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