Documentation ¶
Index ¶
- Constants
- func PacketAlign(size uint32) uint32
- type Interface
- func (wintun *Interface) DeleteInterface() (rebootRequired bool, err error)
- func (wintun *Interface) GUID() windows.GUID
- func (wintun *Interface) LUID() uint64
- func (wintun *Interface) Name() (string, error)
- func (wintun *Interface) Register(descriptor *RingDescriptor) (windows.Handle, error)
- func (wintun *Interface) SetName(ifname string) error
- func (wintun *Interface) Version() (driverVersion string, ndisVersion string, err error)
- type Packet
- type PacketHeader
- type Pool
- func (pool Pool) CreateInterface(ifname string, requestedGUID *windows.GUID) (wintun *Interface, rebootRequired bool, err error)
- func (pool Pool) DeleteMatchingInterfaces(matches func(wintun *Interface) bool) (deviceInstancesDeleted []uint32, rebootRequired bool, errors []error)
- func (pool Pool) GetInterface(ifname string) (*Interface, error)
- type Ring
- type RingDescriptor
Constants ¶
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 ¶
Types ¶
type Interface ¶
type Interface struct {
// contains filtered or unexported fields
}
func (*Interface) DeleteInterface ¶
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) Register ¶
func (wintun *Interface) Register(descriptor *RingDescriptor) (windows.Handle, error)
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 ¶
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 }
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()