Documentation
¶
Index ¶
- Constants
- func RunningVersion() (version uint32, err error)
- type Adapter
- func (wintun *Adapter) Delete(forceCloseSessions bool) (rebootRequired bool, err error)
- func (wintun *Adapter) LUID() (luid uint64)
- func (wintun *Adapter) Name() (ifname string, err error)
- func (wintun *Adapter) SetName(ifname string) (err error)
- func (wintun *Adapter) StartSession(capacity uint32) (session Session, err error)
- type Packet
- type Pool
- func (pool *Pool) CreateAdapter(ifname string, requestedGUID *windows.GUID) (wintun *Adapter, rebootRequired bool, err error)
- func (pool *Pool) DeleteDriver() (rebootRequired bool, err error)
- func (pool *Pool) DeleteMatchingAdapters(matches func(adapter *Adapter) bool, forceCloseSessions bool) (rebootRequired bool, errors []error)
- func (pool *Pool) OpenAdapter(ifname string) (wintun *Adapter, err error)
- func (pool *Pool) String() string
- type Session
- func (session Session) AllocateSendPacket(packetSize int) (packet []byte, err error)
- func (session Session) End()
- func (session Session) ReadWaitEvent() (handle windows.Handle)
- func (session Session) ReceivePacket() (packet []byte, err error)
- func (session Session) ReleaseReceivePacket(packet []byte)
- func (session Session) SendPacket(packet []byte)
Constants ¶
const ( PacketSizeMax = 0xffff // Maximum packet size RingCapacityMin = 0x20000 // Minimum ring capacity (128 kiB) RingCapacityMax = 0x4000000 // Maximum ring capacity (64 MiB) )
const ( PoolNameMax = 256 AdapterNameMax = 128 )
Variables ¶
This section is empty.
Functions ¶
func RunningVersion ¶
RunningVersion returns the version of the running Wintun driver.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
func (*Adapter) Delete ¶
Delete deletes a Wintun adapter. This function succeeds if the adapter was not found. It returns a bool indicating whether a reboot is required.
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 (*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 ¶
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 ¶
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.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}