windivert

package module
v0.0.0-...-4239d0a Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2020 License: MIT Imports: 7 Imported by: 0

README

WinDivert-Go

Go bindings for WinDivert 2.x

Documentation

Index

Constants

View Source
const (
	FlagDefault   = 0x0000
	FlagSniff     = 0x0001
	FlagDrop      = 0x0002
	FlagRecvOnly  = 0x0004
	FlagReadOnly  = FlagRecvOnly
	FlagSendOnly  = 0x0008
	FlagWriteOnly = FlagSendOnly
	FlagNoInstall = 0x0010
	FlagFragments = 0x0020
)

WinDivert flags.

View Source
const (
	PriorityDefault    = 0
	PriorityHighest    = 3000
	PriorityLowest     = -PriorityHighest
	QueueLengthDefault = 4096
	QueueLengthMin     = 32
	QueueLengthMax     = 16384
	QueueTimeDefault   = 2000     /* 2s */
	QueueTimeMin       = 100      /* 100ms */
	QueueTimeMax       = 16000    /* 16s */
	QueueSizeDefault   = 4194304  /* 4MB */
	QueueSizeMin       = 65535    /* 64KB */
	QueueSizeMax       = 33554432 /* 32MB */
	BatchMax           = 0xff     /* 255 */
	MTUMax             = 40 + 0xffff
)

WinDivert constants.

View Source
const (
	ChecksumDefault  = 0
	NoIPChecksum     = 1
	NoICMPChecksum   = 2
	NoICMPV6Checksum = 4
	NoTCPChecksum    = 8
	NoUDPChecksum    = 16
)
View Source
const (
	ErrInsufficientBuffer = Error(windows.ERROR_INSUFFICIENT_BUFFER)
	ErrNoData             = Error(windows.ERROR_NO_DATA)
	ErrIOPending          = Error(windows.ERROR_IO_PENDING)
	ErrHostUnreachable    = Error(windows.ERROR_HOST_UNREACHABLE)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Timestamp int64 /* Packet's timestamp. */

	Flags uint8
	// contains filtered or unexported fields
}

func (*Address) Event

func (a *Address) Event() Event

func (*Address) Flow

func (a *Address) Flow() *Flow

func (*Address) IPChecksum

func (a *Address) IPChecksum() bool

func (*Address) IPv6

func (a *Address) IPv6() bool

func (*Address) Impostor

func (a *Address) Impostor() bool

func (*Address) Layer

func (a *Address) Layer() Layer

func (*Address) Length

func (a *Address) Length() uint32

func (*Address) Loopback

func (a *Address) Loopback() bool

func (*Address) Network

func (a *Address) Network() *Network

func (*Address) Outbound

func (a *Address) Outbound() bool

func (*Address) Reflect

func (a *Address) Reflect() *Reflect

func (*Address) SetEvent

func (a *Address) SetEvent(event Event)

func (*Address) SetIPChecksum

func (a *Address) SetIPChecksum()

func (*Address) SetIPv6

func (a *Address) SetIPv6()

func (*Address) SetImpostor

func (a *Address) SetImpostor()

func (*Address) SetLayer

func (a *Address) SetLayer(layer Layer)

func (*Address) SetLength

func (a *Address) SetLength(n uint32)

func (*Address) SetLoopback

func (a *Address) SetLoopback()

func (*Address) SetOutbound

func (a *Address) SetOutbound()

func (*Address) SetSniffed

func (a *Address) SetSniffed()

func (*Address) SetTCPChecksum

func (a *Address) SetTCPChecksum()

func (*Address) SetUDPChecksum

func (a *Address) SetUDPChecksum()

func (*Address) Sniffed

func (a *Address) Sniffed() bool

func (*Address) Socket

func (a *Address) Socket() *Socket

func (*Address) TCPChecksum

func (a *Address) TCPChecksum() bool

func (*Address) UDPChecksum

func (a *Address) UDPChecksum() bool

func (*Address) UnsetIPChecksum

func (a *Address) UnsetIPChecksum()

func (*Address) UnsetIPv6

func (a *Address) UnsetIPv6()

func (*Address) UnsetImpostor

func (a *Address) UnsetImpostor()

func (*Address) UnsetLoopback

func (a *Address) UnsetLoopback()

func (*Address) UnsetOutbound

func (a *Address) UnsetOutbound()

func (*Address) UnsetSniffed

func (a *Address) UnsetSniffed()

func (*Address) UnsetTCPChecksum

func (a *Address) UnsetTCPChecksum()

func (*Address) UnsetUDPChecksum

func (a *Address) UnsetUDPChecksum()

type Error

type Error syscall.Errno

func (Error) Error

func (e Error) Error() string

type Event

type Event int

WinDivert events.

const (
	EventNetworkPacket   Event = iota /* Network packet. */
	EventFlowEstablished              /* Flow established. */
	EventFlowDeleted                  /* Flow deleted. */
	EventSocketBind                   /* Socket bind. */
	EventSocketConnect                /* Socket connect. */
	EventSocketListen                 /* Socket listen. */
	EventSocketAccept                 /* Socket accept. */
	EventSocketClose                  /* Socket close. */
	EventReflectOpen                  /* WinDivert handle opened. */
	EventReflectClose                 /* WinDivert handle closed. */
)

func (Event) String

func (e Event) String() string

type Flow

type Flow struct {
	EndpointID       uint64    /* Endpoint ID. */
	ParentEndpointID uint64    /* Parent endpoint ID. */
	ProcessID        uint32    /* Process ID. */
	LocalAddress     [16]uint8 /* Local address. */
	RemoteAddress    [16]uint8 /* Remote address. */
	LocalPort        uint16    /* Local port. */
	RemotePort       uint16    /* Remote port. */
	Protocol         uint8     /* Protocol. */
	// contains filtered or unexported fields
}

type Handle

type Handle uintptr

func Open

func Open(filter string, layer Layer, priority int16, flags uint64) (Handle, error)

Open returns windivert Handle if succeed.

func (Handle) Close

func (h Handle) Close() error

func (Handle) GetParam

func (h Handle) GetParam(param Param) (uint64, error)

func (Handle) Recv

func (h Handle) Recv(packet []byte, address *Address) (int, error)

func (Handle) RecvEx

func (h Handle) RecvEx(_ []byte, _ *Address, _ uint64) (int, error)

func (Handle) Send

func (h Handle) Send(packet []byte, address *Address) (int, error)

func (Handle) SendEx

func (h Handle) SendEx(_ []byte, _ *Address, _ uint64) (int, error)

func (Handle) SetParam

func (h Handle) SetParam(param Param, value uint64) error

func (Handle) Shutdown

func (h Handle) Shutdown(how Shutdown) error

type Layer

type Layer int

WinDivert layers.

const (
	LayerNetwork        Layer = iota /* Network layer. */
	LayerNetworkForward              /* Network layer (forwarded packets) */
	LayerFlow                        /* Flow layer. */
	LayerSocket                      /* Socket layer. */
	LayerReflect                     /* Reflect layer. */
)

func (Layer) String

func (l Layer) String() string

type Network

type Network struct {
	InterfaceIndex    uint32 /* Packet's interface index. */
	SubInterfaceIndex uint32 /* Packet's sub-interface index. */
	// contains filtered or unexported fields
}

type Param

type Param int

WinDivert parameters.

const (
	QueueLength  Param = iota /* Packet queue length. */
	QueueTime                 /* Packet queue time. */
	QueueSize                 /* Packet queue size. */
	VersionMajor              /* Driver version (major). */
	VersionMinor              /* Driver version (minor). */
)

func (Param) String

func (p Param) String() string

type Reflect

type Reflect struct {
	TimeStamp int64  /* Handle open time. */
	ProcessID uint32 /* Handle process ID. */

	Flags    uint64 /* Handle flags. */
	Priority int16  /* Handle priority. */
	// contains filtered or unexported fields
}

func (*Reflect) Layer

func (r *Reflect) Layer() Layer

type Shutdown

type Shutdown int

WinDivert shutdown parameter.

const (
	ShutdownRecv Shutdown = iota /* Shutdown recv. */
	ShutdownSend                 /* Shutdown send. */
	ShutdownBoth                 /* Shutdown recv and send. */
)

func (Shutdown) String

func (h Shutdown) String() string

type Socket

type Socket struct {
	EndpointID       uint64    /* Endpoint ID. */
	ParentEndpointID uint64    /* Parent endpoint ID. */
	ProcessID        uint32    /* Process ID. */
	LocalAddress     [16]uint8 /* Local address. */
	RemoteAddress    [16]uint8 /* Remote address. */
	LocalPort        uint16    /* Local port. */
	RemotePort       uint16    /* Remote port. */
	Protocol         uint8     /* Protocol. */
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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