Documentation ¶
Index ¶
- Constants
- Variables
- func FreeMibTable(memory PMibIfTable)
- type IfOperStatus
- type InterfaceAndOperStatusFlags
- type MibIfEntryLevel
- type MibIfRow2
- type MibIfTable2
- type NdisMedium
- type NdisPhysicalMedium
- type NetIfAccessType
- type NetIfAdminStatus
- type NetIfConnectionType
- type NetIfDirectionType
- type NetIfIndex
- type NetIfMediaConnectState
- type NetLUID
- type NetworkInterface
- type PMibIfTable
- type TunnelType
- type Ulong
Constants ¶
const ( MibIfEntryNormal = MibIfEntryLevel(0) MibIfEntryNormalWithoutStatistics = MibIfEntryLevel(2) IfMaxStringSize = 256 IfMaxPhysAddressLength = 32 )
Variables ¶
var MibIfRow2Size = unsafe.Sizeof(MibIfRow2{})
Functions ¶
func FreeMibTable ¶
func FreeMibTable(memory PMibIfTable)
Types ¶
type IfOperStatus ¶
type IfOperStatus uint32
type InterfaceAndOperStatusFlags ¶
type InterfaceAndOperStatusFlags [8]byte // this field is padded in the struct and is not just 1 byte
type MibIfEntryLevel ¶
type MibIfEntryLevel uint32
type MibIfRow2 ¶
type MibIfRow2 struct { InterfaceLuid NetLUID InterfaceIndex NetIfIndex InterfaceGuid windows.GUID Alias [IfMaxStringSize + 1]uint16 Description [IfMaxStringSize + 1]uint16 PhysicalAddressLength Ulong PhysicalAddress [IfMaxPhysAddressLength]byte PermanentPhysicalAddress [IfMaxPhysAddressLength]byte Mtu Ulong Type Ulong TunnelType TunnelType MediaType NdisMedium PhysicalMediumType NdisPhysicalMedium AccessType NetIfAccessType DirectionType NetIfDirectionType InterfaceAndOperStatusFlags InterfaceAndOperStatusFlags OperStatus IfOperStatus AdminStatus NetIfAdminStatus MediaConnectState NetIfMediaConnectState NetworkGuid windows.GUID ConnectionType NetIfConnectionType TransmitLinkSpeed uint64 ReceiveLinkSpeed uint64 InOctets uint64 InUcastPkts uint64 InNUcastPkts uint64 InDiscards uint64 InErrors uint64 InUnknownProtos uint64 InUcastOctets uint64 InMulticastOctets uint64 InBroadcastOctets uint64 OutOctets uint64 OutUcastPkts uint64 OutNUcastPkts uint64 OutDiscards uint64 OutErrors uint64 OutUcastOctets uint64 OutMulticastOctets uint64 OutBroadcastOctets uint64 OutQLen uint64 }
MibIfRow2 from https://docs.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_if_row2
Important: This C struct is padded by the C compiler, so 1 byte fields are actually 8 byte Go uses a different padding scheme depending on GOARCH... the windows C compiler does not...
func GetIfEntry2Ex ¶
func GetIfEntry2Ex(index NetIfIndex, stats bool) (*MibIfRow2, error)
func (*MibIfRow2) NetworkInterface ¶
func (r *MibIfRow2) NetworkInterface() *NetworkInterface
type MibIfTable2 ¶
type MibIfTable2 struct { NumEntries Ulong // Table isn't a pointer but a C array value... C doesn't care that the array field length is 1, so in C we // can iterate over this. In Go this is not allowed, so have to calculate the actual memory address. Table [1]MibIfRow2 // contains filtered or unexported fields }
MibIfTable2 from https://docs.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_if_table2
Important: This C struct is padded by the C compiler, so 1 byte fields are actually 8 byte Go uses a different padding scheme depending on GOARCH... the windows C compiler does not...
In this case NumEntires IS a 4 byte value, BUT the C compiler adds 4 bytes for memory alignment... Go would add the memory at the end, so this would break everything.
func GetIfTable2Ex ¶
func GetIfTable2Ex(stats bool) (*MibIfTable2, error)
GetIfTable2Ex generates interface statistics of all interfaces with one syscall. Unfortunatly it uses dynamic memory magic and must be freed with FreeMibTable! The syscall safes a pointer to the magic memory space, so this is why we have to allocate the pointer and call the syscall with a pointer pointer.
func (*MibIfTable2) Close ¶
func (t *MibIfTable2) Close()
func (*MibIfTable2) Get ¶
func (t *MibIfTable2) Get(index Ulong) *MibIfRow2
Get returns a pointer to a value in the C array
func (*MibIfTable2) Slice ¶
func (t *MibIfTable2) Slice() []*MibIfRow2
type NdisMedium ¶
type NdisMedium uint32
type NdisPhysicalMedium ¶
type NdisPhysicalMedium uint32
type NetIfAccessType ¶
type NetIfAccessType uint32
type NetIfAdminStatus ¶
type NetIfAdminStatus uint32
type NetIfConnectionType ¶
type NetIfConnectionType uint32
type NetIfDirectionType ¶
type NetIfDirectionType uint32
type NetIfIndex ¶
type NetIfIndex Ulong
type NetIfMediaConnectState ¶
type NetIfMediaConnectState uint32
type NetworkInterface ¶
type NetworkInterface struct { Name string BytesReceived uint64 //InOctets DropIn uint64 //InDiscards ErrorIn uint64 //InErrors BytesSent uint64 //OutOctets DropOut uint64 //OutDiscards ErrorOut uint64 //OutErrors PacketsSent uint64 //OutUcastPkts+OutNUcastPkts PacketsReceived uint64 //InUcastPkts+InNUcastPkts }
func NetworkInterfaceStatistics ¶
func NetworkInterfaceStatistics() ([]*NetworkInterface, error)
type PMibIfTable ¶
type PMibIfTable *MibIfTable2
type TunnelType ¶
type TunnelType uint32