-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtypes.go
164 lines (133 loc) · 3.25 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// +build windows
package winnetstat
import (
"syscall"
)
const ANY_SIZE = 1
type MIB_TCP_STATE int32
type TCP_CONNECTION_OFFLOAD_STATE int32
const (
TcpConnectionOffloadStateInHost TCP_CONNECTION_OFFLOAD_STATE = iota
TcpConnectionOffloadStateOffloading
TcpConnectionOffloadStateOffloaded
TcpConnectionOffloadStateUploading
TcpConnectionOffloadStateMax
)
type MIB_TCPROW2 struct {
DwState uint32
DwLocalAddr uint32
DwLocalPort uint32
DwRemoteAddr uint32
DwRemotePort uint32
DwOwningPid uint32
DwOffloadState TCP_CONNECTION_OFFLOAD_STATE
}
type MIB_TCPTABLE2 struct {
DwNumEntries uint32
Table [ANY_SIZE]MIB_TCPROW2
}
type PMIB_TCPTABLE2 *MIB_TCPTABLE2
type PMIB_TCP6TABLE2 *MIB_TCP6TABLE2
func doLoadLibrary(name string) uintptr {
lib, _ := syscall.LoadLibrary(name)
return uintptr(lib)
}
type IN6_ADDR_U struct {
Uchar [16]byte
Ushort [8]uint16
}
type IN6_ADDR struct {
U IN6_ADDR_U
}
func (u *IN6_ADDR_U) GetByte() [16]byte {
var ret [16]byte
for i := 0; i < 16; i++ {
ret[i] = u.Uchar[i]
}
return ret
}
type MIB_TCP6ROW2 struct {
LocalAddr IN6_ADDR
DwLocalScopeId uint32
DwLocalPort uint32
RemoteAddr IN6_ADDR
DwRemoteScopeId uint32
DwRemotePort uint32
State MIB_TCP_STATE
DwOwningPid uint32
DwOffloadState TCP_CONNECTION_OFFLOAD_STATE
}
type MIB_TCP6TABLE2 struct {
DwNumEntries uint32
Table [ANY_SIZE]MIB_TCP6ROW2
}
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365930(v=vs.85).aspx
type MIB_UDPROW_OWNER_PID struct {
DwLocalAddr uint32
DwLocalPort uint32
DwOwningPid uint32
}
type MIB_UDPTABLE_OWNER_PID struct {
DwNumEntries uint32
Table [ANY_SIZE]MIB_UDPROW_OWNER_PID
}
type PMIB_UDPTABLE_OWNER_PID *MIB_UDPTABLE_OWNER_PID
type MIB_UDP6ROW_OWNER_PID struct {
UcLocalAddr [16]byte
DwLocalScopeId uint32
DwLocalPort uint32
DwOwningPid uint32
}
type MIB_UDP6TABLE_OWNER_PID struct {
DwNumEntries uint32
Table [ANY_SIZE]MIB_UDP6ROW_OWNER_PID
}
type UDP_TABLE_CLASS int32
const (
UDP_TABLE_BASIC UDP_TABLE_CLASS = iota
UDP_TABLE_OWNER_PID
UDP_TABLE_OWNER_MODULE
)
type PMIB_UDP6TABLE_OWNER_PID *MIB_UDP6TABLE_OWNER_PID
// GetExtendedTcpTable TCP4 struct
type MIB_TCPROW_OWNER_PID struct {
DwState uint32
DwLocalAddr uint32
DwLocalPort uint32
DwRemoteAddr uint32
DwRemotePort uint32
DwOwningPid uint32
}
type MIB_TCPTABLE_OWNER_PID struct {
DwNumEntries uint32
Table [ANY_SIZE]MIB_TCPROW_OWNER_PID
}
type PMIB_TCPTABLE_OWNER_PID_ALL *MIB_TCPTABLE_OWNER_PID
// GetExtendedTcpTable TCP6 struct
type MIB_TCP6ROW_OWNER_PID struct {
UcLocalAddr [16]byte
DwLocalScopeId uint32
DwLocalPort uint32
UcRemoteAddr [16]byte
DwRemoteScopeId uint32
DwRemotePort uint32
DwState uint32
DwOwningPid uint32
}
type MIB_TCP6TABLE_OWNER_PID struct {
DwNumEntries uint32
Table [ANY_SIZE]MIB_TCP6ROW_OWNER_PID
}
type PMIB_TCP6TABLE_OWNER_PID_ALL *MIB_TCP6TABLE_OWNER_PID
type TCP_TABLE_CLASS int32
const (
TCP_TABLE_BASIC_LISTENER TCP_TABLE_CLASS = 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
)