From 49857dbdd04e8970e0388d892d99c3bce2901fcf Mon Sep 17 00:00:00 2001 From: WAKAYAMA Shirou Date: Fri, 16 May 2014 12:21:17 +0900 Subject: [PATCH] add NetConnection placeholder on windows. --- net_windows.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/net_windows.go b/net_windows.go index c32f956..74ce1b3 100644 --- a/net_windows.go +++ b/net_windows.go @@ -3,12 +3,31 @@ package gopsutil import ( + "errors" "net" "os" "syscall" "unsafe" ) +var ( + modiphlpapi = NewLazyDLL("iphlpapi.dll") + procGetExtendedTcpTable = modiphlpapi.NewProc("GetExtendedTcpTable") + procGetExtendedUdpTable = modiphlpapi.NewProc("GetExtendedUdpTable") +) + +const ( + TCP_TABLE_BASIC_LISTENER = iota + TCP_TABLE_BASIC_CONNECTIONS + TCP_TABLE_BASIC_ALL + TCP_TABLE_OWNER_PID_LISTENER + TCP_TABLE_OWNER_PID_CONNECTIONS + TCP_TABLE_OWNER_PID_ALL + TCP_TABLE_OWNER_MODULE_LISTENER + TCP_TABLE_OWNER_MODULE_CONNECTIONS + TCP_TABLE_OWNER_MODULE_ALL +) + func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) { ifs, err := net.Interfaces() if err != nil { @@ -49,6 +68,13 @@ func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) { return ret, nil } +// Return a list of network connections opened by a process +func NetConnections(kind string) ([]NetConnectionStat, error) { + var ret []NetConnectionStat + + return ret, erros.New("not implemented yet") +} + // borrowed from src/pkg/net/interface_windows.go func getAdapterList() (*syscall.IpAdapterInfo, error) { b := make([]byte, 1000)