windivert

package module
v0.0.0-...-328c566 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: BSD-2-Clause Imports: 6 Imported by: 0

README

go-WinDivert2

Go bindings for WinDivert 2.x

Thanks

Initialization codes are mostly copied from clmul/go-windivert.

Documentation

Rendered for windows/amd64

Index

Constants

View Source
const (
	InvalidHandleValue = -1

	// https://github.com/basil00/Divert/blob/master/include/windivert.h
	PacketFlagSniffed     = 1      /* Packet was sniffed? */
	PacketFlagOutbound    = 1 << 1 /* Packet is outound? */
	PacketFlagLoopback    = 1 << 2 /* Packet is loop? */
	PacketFlagImpostor    = 1 << 3 /* Packet is Impostor? */
	PacketFlagIPv6        = 1 << 4 /* Packet is IPv6? */
	PacketFlagIPChecksum  = 1 << 5 /* Packet has valid IPv4 checksum? */
	PacketFlagTCPChecksum = 1 << 6 /* Packet has valid TCP checksum? */
	PacketFlagUDPChecksum = 1 << 7 /* Packet has valid UDP checksum? */

	// WinDivert events.
	EventNetworkPacket          = 0 /* Network packet. */
	EventNetworkFlowEstablished = 1 /* Flow established. */
	EventNetworkFlowDelete      = 2 /* Flow deleted. */
	EventSocketBind             = 3 /* Socket bind. */
	EventSocketConnect          = 4 /* Socket connect. */
	EventSocketListen           = 5 /* Socket listen. */
	EventSocketAccept           = 6 /* Socket accept. */
	EventSocketClose            = 7 /* Socket close. */
	EventReflectOpen            = 8 /* WinDivert handle opened. */
	EventReflectClose           = 9 /* WinDivert handle closed. */

	LayerNetwork        = 0
	LayerNetworkForward = 1
	LayerFlow           = 2
	LayerSocket         = 3
	LayerReflect        = 4

	FlagSniff     = 1
	FlagDrop      = 2
	FlagRecvOnly  = 4
	FlagReadOnly  = 4
	FlagSendOnly  = 8
	FlagWriteOnly = 8
	FlagNoInstall = 16
	FlagFragment  = 32

	DirectionOutbound = 0
	DirectionInbound  = 1

	ParamQueueLen  = 0
	ParamQueueTime = 1
	ParamQueueSize = 2

	ParamMajorVersion = 3
	ParamMinorVersion = 4
)

Variables

View Source
var (
	DLLVersion string
)

Functions

func CalcChecksums

func CalcChecksums(packet []byte) []byte

func FormatIPAddress

func FormatIPAddress(addr [4]uint32) net.IP

func FormatIPv4Address

func FormatIPv4Address(addr [4]uint32) net.IP

func FormatIPv6Address

func FormatIPv6Address(addr [4]uint32) net.IP

Types

type Address

type Address struct {
	Timestamp int64  /* Packet's timestamp. */
	Layer     uint8  /* Packet's layer. */
	Event     uint8  /* Packet event. */
	Flags     uint8  /* Packet Flags: Sniffed, Outbound, Loopback, Impostor, IPv6, IPChecksum, TCPChecksum, UDPChecksum */
	Reserved1 uint8  /* Reserved1 */
	Reserved2 uint32 /* Reserved2 */
	Data      [64]byte
}

func (Address) IsIPChecksum

func (addr Address) IsIPChecksum() (bool, error)

func (Address) IsIPv6

func (addr Address) IsIPv6() (bool, error)

func (Address) IsImpostor

func (addr Address) IsImpostor() (bool, error)

func (Address) IsLoopback

func (addr Address) IsLoopback() (bool, error)

func (Address) IsOutbound

func (addr Address) IsOutbound() (bool, error)

func (Address) IsSniffed

func (addr Address) IsSniffed() (bool, error)

func (Address) IsTCPChecksum

func (addr Address) IsTCPChecksum() (bool, error)

func (Address) IsUDPChecksum

func (addr Address) IsUDPChecksum() (bool, error)

type DataFlow

type DataFlow struct {
	EndpointId       uint64    /* Endpoint ID. */
	ParentEndpointId uint64    /* Parent Endpoint ID. */
	ProcessId        uint32    /* Process ID. */
	LocalAddr        [4]uint32 /* Local address. */
	RemoteAddr       [4]uint32 /* Remote address. */
	LocalPort        uint16    /* Local port. */
	RemotePort       uint16    /* Remote port. */
	Protocol         uint8     /* Protocol. */
}

type DataNetwork

type DataNetwork struct {
	IfIdx    uint32 /* Packet's interface index. */
	SubIfIdx uint32 /* Packet's sub-interface index. */
}

https://github.com/basil00/Divert/blob/master/include/windivert.h

type DataReflect

type DataReflect struct {
	Timestamp int64  /* Handle open time. */
	ProcessId uint32 /* Handle process ID. */
	Layer     int    /* Handle layer. */
	Flags     uint64 /* Handle flags. */
	Priority  int16  /* Handle priority. */
}

type DataSocket

type DataSocket struct {
	EndpointId       uint64    /* Endpoint ID. */
	ParentEndpointId uint64    /* Parent Endpoint ID. */
	ProcessId        uint32    /* Process ID. */
	LocalAddr        [4]uint32 /* Local address. */
	RemoteAddr       [4]uint32 /* Remote address. */
	LocalPort        uint16    /* Local port. */
	RemotePort       uint16    /* Remote port. */
	Protocol         uint8     /* Protocol. */
}

type Handle

type Handle uintptr

func Open

func Open(filter string, layer, priority, flags int) (Handle, error)

func (Handle) Close

func (h Handle) Close() error

func (Handle) GetParam

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

func (Handle) GetVersion

func (h Handle) GetVersion() (version string, err error)

func (Handle) Recv

func (h Handle) Recv(packet []byte) (n int, addr Address, err error)

func (Handle) Send

func (h Handle) Send(packet []byte, addr Address) (n int, err error)

func (Handle) SetParam

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

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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