iphelper

package
v0.36.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Rendered for windows/amd64

Index

Constants

View Source
const (
	MAX_INTERFACE_NAME_LEN = 256
	MAXLEN_PHYSADDR        = 8
	MAXLEN_IFDESCR         = 256
)
View Source
const (
	TCP_TABLE_BASIC_LISTENER           = uint32(0)
	TCP_TABLE_BASIC_CONNECTIONS        = uint32(1)
	TCP_TABLE_BASIC_ALL                = uint32(2)
	TCP_TABLE_OWNER_PID_LISTENER       = uint32(3)
	TCP_TABLE_OWNER_PID_CONNECTIONS    = uint32(4)
	TCP_TABLE_OWNER_PID_ALL            = uint32(5)
	TCP_TABLE_OWNER_MODULE_LISTENER    = uint32(6)
	TCP_TABLE_OWNER_MODULE_CONNECTIONS = uint32(7)
	TCP_TABLE_OWNER_MODULE_ALL         = uint32(8)
)

Variables

This section is empty.

Functions

func GetAdaptersAddresses

func GetAdaptersAddresses() (table map[uint32]IpAdapterAddressesLh, err error)

GetAdaptersAddresses returns a map of all of the adapters, indexed by interface index

func GetExtendedTcpV4Table

func GetExtendedTcpV4Table() (table map[uint32][]MIB_TCPROW_OWNER_PID, err error)

GetExtendedTcpV4Table returns a list of ipv4 tcp connections indexed by owning PID

func GetIFTable

func GetIFTable() (table map[uint32]MIB_IFROW, err error)

GetIFTable returns a table of interfaces, indexed by the interface index

func Htonl

func Htonl(i uint32) uint32

Htonl converts a host byte order 32 bit int to network byte order

func Ntohl

func Ntohl(i uint32) uint32

Ntohl converts a network byte order 32 bit int to host byte order

func Ntohs

func Ntohs(i uint16) uint16

Ntohs converts a network byte order 16 bit int to host byte order

Types

type IPAdapterUnicastAddress

type IPAdapterUnicastAddress struct {
	Flags   uint32
	Address net.IP
}

type IpAdapterAddressesLh

type IpAdapterAddressesLh struct {
	Index            uint32
	AdapterName      string
	UnicastAddresses []IPAdapterUnicastAddress
}

IpAdapterAddressesLh is a go adaptation of the C structure IP_ADAPTER_ADDRESSES_LH it is a go adaptation, rather than a matching structure, because the real structure is difficult to approximate in Go.

type MIB_IFROW

type MIB_IFROW struct {
	WszName           [MAX_INTERFACE_NAME_LEN]uint16
	DwIndex           uint32
	DwType            uint32
	DwMtu             uint32
	DwSpeed           uint32
	DwPhysAddrLen     uint32
	BPhysAddr         [MAXLEN_PHYSADDR]byte
	DwAdminStatus     uint32
	DwOperStatus      uint32
	DwLastChange      uint32
	DwInOctets        uint32
	DwInUcastPkts     uint32
	DwInNUcastPkts    uint32
	DwInDiscards      uint32
	DwInErrors        uint32
	DwInUnknownProtos uint32
	DwOutOctets       uint32
	DwOutUcastPkts    uint32
	DwOutNUcastPkts   uint32
	DwOutDiscards     uint32
	DwOutErrors       uint32
	DwOutQLen         uint32
	DwDescrLen        uint32
	BDescr            [MAXLEN_IFDESCR]byte
}

MIB_IFROW is the matching structure for the IPHelper structure of the same name, it defines a physical interface https://docs.microsoft.com/en-us/windows/win32/api/ifmib/ns-ifmib-mib_ifrow

type MIB_IPFORWARDROW

type MIB_IPFORWARDROW struct {
	DwForwardDest      uint32 // destination IP address.  0.0.0.0 is default route
	DwForwardMask      uint32
	DwForwardPolicy    uint32
	DwForwardNextHop   uint32
	DwForwardIfIndex   uint32
	DwForwardType      uint32
	DwForwardProto     uint32
	DwForwardAge       uint32
	DwForwardNextHopAS uint32
	DwForwardMetric1   uint32
	DwForwardMetric2   uint32
	DwForwardMetric3   uint32
	DwForwardMetric4   uint32
	DwForwardMetric5   uint32
}

MIB_IPFORWARDROW is the matching structure for the IPHelper structure of the same name; it defines a route entry https://docs.microsoft.com/en-us/windows/win32/api/ipmib/ns-ipmib-mib_ipforwardrow

func GetIPv4RouteTable

func GetIPv4RouteTable() (table []MIB_IPFORWARDROW, err error)

GetIPv4RouteTable returns a list of the current ipv4 routes.

type MIB_TCPROW_OWNER_PID

type MIB_TCPROW_OWNER_PID struct {
	/*  C declaration
	DWORD       dwState;
	DWORD       dwLocalAddr;
	DWORD       dwLocalPort;
	DWORD       dwRemoteAddr;
	DWORD       dwRemotePort;
	DWORD       dwOwningPid; */
	DwState      uint32
	DwLocalAddr  uint32 // network byte order
	DwLocalPort  uint32 // network byte order
	DwRemoteAddr uint32 // network byte order
	DwRemotePort uint32 // network byte order
	DwOwningPid  uint32
}

MIB_TCPROW_OWNER_PID is the matching structure for the IPHelper structure of the same name. Fields documented https://docs.microsoft.com/en-us/windows/win32/api/tcpmib/ns-tcpmib-mib_tcprow_owner_pid

Jump to

Keyboard shortcuts

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