wintun

package module
v0.0.0-...-c33dd13 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: MIT Imports: 8 Imported by: 0

README

wintun-go

This contains bindings to use Wintun from Go.

import "golang.zx2c4.com/wintun"

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 AdapterNameMax = 128

Variables

This section is empty.

Functions

func RunningVersion

func RunningVersion() (version uint32, err error)

RunningVersion returns the version of the loaded driver.

func Uninstall

func Uninstall() (err error)

Uninstall removes the driver from the system if no drivers are currently in use.

func Version

func Version() string

Version returns the version of the Wintun DLL.

Types

type Adapter

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

func CreateAdapter

func CreateAdapter(name string, tunnelType string, requestedGUID *windows.GUID) (wintun *Adapter, err error)

CreateAdapter creates a Wintun adapter. name is the cosmetic name of the adapter. tunnelType represents the type of adapter and should be "Wintun". 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.

func OpenAdapter

func OpenAdapter(name string) (wintun *Adapter, err error)

OpenAdapter opens an existing Wintun adapter by name.

func (*Adapter) Close

func (wintun *Adapter) Close() (err error)

Close closes a Wintun adapter.

func (*Adapter) LUID

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

LUID returns the LUID of the 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 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)

type TimestampedWriter

type TimestampedWriter interface {
	WriteWithTimestamp(p []byte, ts int64) (n int, err error)
}

Jump to

Keyboard shortcuts

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