1 // Licensed under the Apache License, Version 2.0 2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. 4 // All files in the project carrying such notice may not be copied, modified, or distributed 5 // except according to those terms. 6 // #include <winapifamily.h> 7 use shared::basetsd::DWORD64; 8 use shared::in6addr::IN6_ADDR; 9 use shared::minwindef::DWORD; 10 use shared::ntdef::{LARGE_INTEGER, UCHAR, ULONGLONG}; 11 const ANY_SIZE: usize = 1; 12 pub const TCPIP_OWNING_MODULE_SIZE: usize = 16; 13 ENUM!{enum MIB_TCP_STATE { 14 MIB_TCP_STATE_CLOSED = 1, 15 MIB_TCP_STATE_LISTEN = 2, 16 MIB_TCP_STATE_SYN_SENT = 3, 17 MIB_TCP_STATE_SYN_RCVD = 4, 18 MIB_TCP_STATE_ESTAB = 5, 19 MIB_TCP_STATE_FIN_WAIT1 = 6, 20 MIB_TCP_STATE_FIN_WAIT2 = 7, 21 MIB_TCP_STATE_CLOSE_WAIT = 8, 22 MIB_TCP_STATE_CLOSING = 9, 23 MIB_TCP_STATE_LAST_ACK = 10, 24 MIB_TCP_STATE_TIME_WAIT = 11, 25 MIB_TCP_STATE_DELETE_TCB = 12, 26 MIB_TCP_STATE_RESERVED = 100, 27 }} 28 ENUM!{enum TCP_CONNECTION_OFFLOAD_STATE { 29 TcpConnectionOffloadStateInHost = 0, 30 TcpConnectionOffloadStateOffloading = 1, 31 TcpConnectionOffloadStateOffloaded = 2, 32 TcpConnectionOffloadStateUploading = 3, 33 TcpConnectionOffloadStateMax = 4, 34 }} 35 pub type PTCP_CONNECTION_OFFLOAD_STATE = *mut TCP_CONNECTION_OFFLOAD_STATE; 36 STRUCT!{struct MIB_TCPROW_LH { 37 State: MIB_TCP_STATE, 38 dwLocalAddr: DWORD, 39 dwLocalPort: DWORD, 40 dwRemoteAddr: DWORD, 41 dwRemotePort: DWORD, 42 }} 43 pub type PMIB_TCPROW_LH = *mut MIB_TCPROW_LH; 44 STRUCT!{struct MIB_TCPROW_W2K { 45 dwState: DWORD, 46 dwLocalAddr: DWORD, 47 dwLocalPort: DWORD, 48 dwRemoteAddr: DWORD, 49 dwRemotePort: DWORD, 50 }} 51 pub type PMIB_TCPROW_W2K = *mut MIB_TCPROW_W2K; 52 pub type MIB_TCPROW = MIB_TCPROW_LH; 53 pub type PMIB_TCPROW = *mut MIB_TCPROW; 54 STRUCT!{struct MIB_TCPTABLE { 55 dwNumEntries: DWORD, 56 table: [MIB_TCPROW; ANY_SIZE], 57 }} 58 pub type PMIB_TCPTABLE = *mut MIB_TCPTABLE; 59 // FIXME: SIZEOF_TCPTABLE(x) 60 STRUCT!{struct MIB_TCPROW2 { 61 dwState: DWORD, 62 dwLocalAddr: DWORD, 63 dwLocalPort: DWORD, 64 dwRemoteAddr: DWORD, 65 dwRemotePort: DWORD, 66 dwOwningPid: DWORD, 67 dwOffloadState: TCP_CONNECTION_OFFLOAD_STATE, 68 }} 69 pub type PMIB_TCPROW2 = *mut MIB_TCPROW2; 70 STRUCT!{struct MIB_TCPTABLE2 { 71 dwNumEntries: DWORD, 72 table: [MIB_TCPROW2; ANY_SIZE], 73 }} 74 pub type PMIB_TCPTABLE2 = *mut MIB_TCPTABLE2; 75 // FIXME: SIZEOF_TCPTABLE2(x) 76 STRUCT!{struct MIB_TCPROW_OWNER_PID { 77 dwState: DWORD, 78 dwLocalAddr: DWORD, 79 dwLocalPort: DWORD, 80 dwRemoteAddr: DWORD, 81 dwRemotePort: DWORD, 82 dwOwningPid: DWORD, 83 }} 84 pub type PMIB_TCPROW_OWNER_PID = *mut MIB_TCPROW_OWNER_PID; 85 STRUCT!{struct MIB_TCPTABLE_OWNER_PID { 86 dwNumEntries: DWORD, 87 table: [MIB_TCPROW_OWNER_PID; ANY_SIZE], 88 }} 89 pub type PMIB_TCPTABLE_OWNER_PID = *mut MIB_TCPTABLE_OWNER_PID; 90 // FIXME: SIZEOF_TCPTABLE_OWNER_PID(x) 91 STRUCT!{struct MIB_TCPROW_OWNER_MODULE { 92 dwState: DWORD, 93 dwLocalAddr: DWORD, 94 dwLocalPort: DWORD, 95 dwRemoteAddr: DWORD, 96 dwRemotePort: DWORD, 97 dwOwningPid: DWORD, 98 liCreateTimestamp: LARGE_INTEGER, 99 OwningModuleInfo: [ULONGLONG; TCPIP_OWNING_MODULE_SIZE], 100 }} 101 pub type PMIB_TCPROW_OWNER_MODULE = *mut MIB_TCPROW_OWNER_MODULE; 102 STRUCT!{struct MIB_TCPTABLE_OWNER_MODULE { 103 dwNumEntries: DWORD, 104 table: [MIB_TCPROW_OWNER_MODULE; ANY_SIZE], 105 }} 106 pub type PMIB_TCPTABLE_OWNER_MODULE = *mut MIB_TCPTABLE_OWNER_MODULE; 107 // FIXME: SIZEOF_TCPTABLE_OWNER_MODULE(x) 108 STRUCT!{struct MIB_TCP6ROW { 109 State: MIB_TCP_STATE, 110 LocalAddr: IN6_ADDR, 111 dwLocalScopeId: DWORD, 112 dwLocalPort: DWORD, 113 RemoteAddr: IN6_ADDR, 114 dwRemoteScopeId: DWORD, 115 dwRemotePort: DWORD, 116 }} 117 pub type PMIB_TCP6ROW = *mut MIB_TCP6ROW; 118 STRUCT!{struct MIB_TCP6TABLE { 119 dwNumEntries: DWORD, 120 table: [MIB_TCP6ROW; ANY_SIZE], 121 }} 122 pub type PMIB_TCP6TABLE = *mut MIB_TCP6TABLE; 123 // FIXME: SIZEOF_TCP6TABLE(x) 124 STRUCT!{struct MIB_TCP6ROW2 { 125 LocalAddr: IN6_ADDR, 126 dwLocalScopeId: DWORD, 127 dwLocalPort: DWORD, 128 RemoteAddr: IN6_ADDR, 129 dwRemoteScopeId: DWORD, 130 dwRemotePort: DWORD, 131 State: MIB_TCP_STATE, 132 dwOwningPid: DWORD, 133 dwOffloadState: TCP_CONNECTION_OFFLOAD_STATE, 134 }} 135 pub type PMIB_TCP6ROW2 = *mut MIB_TCP6ROW2; 136 STRUCT!{struct MIB_TCP6TABLE2 { 137 dwNumEntries: DWORD, 138 table: [MIB_TCP6ROW2; ANY_SIZE], 139 }} 140 pub type PMIB_TCP6TABLE2 = *mut MIB_TCP6TABLE2; 141 // FIXME: SIZEOF_TCP6TABLE2(x) 142 STRUCT!{struct MIB_TCP6ROW_OWNER_PID { 143 ucLocalAddr: [UCHAR; 16], 144 dwLocalScopeId: DWORD, 145 dwLocalPort: DWORD, 146 ucRemoteAddr: [UCHAR; 16], 147 dwRemoteScopeId: DWORD, 148 dwRemotePort: DWORD, 149 dwState: DWORD, 150 dwOwningPid: DWORD, 151 }} 152 pub type PMIB_TCP6ROW_OWNER_PID = *mut MIB_TCP6ROW_OWNER_PID; 153 STRUCT!{struct MIB_TCP6TABLE_OWNER_PID { 154 dwNumEntries: DWORD, 155 table: [MIB_TCP6ROW_OWNER_PID; ANY_SIZE], 156 }} 157 pub type PMIB_TCP6TABLE_OWNER_PID = *mut MIB_TCP6TABLE_OWNER_PID; 158 // FIXME: SIZEOF_TCP6TABLE_OWNER_PID(x) 159 STRUCT!{struct MIB_TCP6ROW_OWNER_MODULE { 160 ucLocalAddr: [UCHAR; 16], 161 dwLocalScopeId: DWORD, 162 dwLocalPort: DWORD, 163 ucRemoteAddr: [UCHAR; 16], 164 dwRemoteScopeId: DWORD, 165 dwRemotePort: DWORD, 166 dwState: DWORD, 167 dwOwningPid: DWORD, 168 liCreateTimestamp: LARGE_INTEGER, 169 OwningModuleInfo: [ULONGLONG; TCPIP_OWNING_MODULE_SIZE], 170 }} 171 pub type PMIB_TCP6ROW_OWNER_MODULE = *mut MIB_TCP6ROW_OWNER_MODULE; 172 STRUCT!{struct MIB_TCP6TABLE_OWNER_MODULE { 173 dwNumEntries: DWORD, 174 table: [MIB_TCP6ROW_OWNER_MODULE; ANY_SIZE], 175 }} 176 pub type PMIB_TCP6TABLE_OWNER_MODULE = *mut MIB_TCP6TABLE_OWNER_MODULE; 177 // FIXME: SIZEOF_TCP6TABLE_OWNER_MODULE(x) 178 ENUM!{enum TCP_RTO_ALGORITHM { 179 TcpRtoAlgorithmOther = 1, 180 TcpRtoAlgorithmConstant = 2, 181 TcpRtoAlgorithmRsre = 3, 182 TcpRtoAlgorithmVanj = 4, 183 MIB_TCP_RTO_OTHER = 1, 184 MIB_TCP_RTO_CONSTANT = 2, 185 MIB_TCP_RTO_RSRE = 3, 186 MIB_TCP_RTO_VANJ = 4, 187 }} 188 pub type PTCP_RTO_ALGORITHM = *mut TCP_RTO_ALGORITHM; 189 STRUCT!{struct MIB_TCPSTATS_LH { 190 RtoAlgorithm: TCP_RTO_ALGORITHM, 191 dwRtoMin: DWORD, 192 dwRtoMax: DWORD, 193 dwMaxConn: DWORD, 194 dwActiveOpens: DWORD, 195 dwPassiveOpens: DWORD, 196 dwAttemptFails: DWORD, 197 dwEstabResets: DWORD, 198 dwCurrEstab: DWORD, 199 dwInSegs: DWORD, 200 dwOutSegs: DWORD, 201 dwRetransSegs: DWORD, 202 dwInErrs: DWORD, 203 dwOutRsts: DWORD, 204 dwNumConns: DWORD, 205 }} 206 pub type PMIB_TCPSTATS_LH = *mut MIB_TCPSTATS_LH; 207 STRUCT!{struct MIB_TCPSTATS_W2K { 208 dwRtoAlgorithm: DWORD, 209 dwRtoMin: DWORD, 210 dwRtoMax: DWORD, 211 dwMaxConn: DWORD, 212 dwActiveOpens: DWORD, 213 dwPassiveOpens: DWORD, 214 dwAttemptFails: DWORD, 215 dwEstabResets: DWORD, 216 dwCurrEstab: DWORD, 217 dwInSegs: DWORD, 218 dwOutSegs: DWORD, 219 dwRetransSegs: DWORD, 220 dwInErrs: DWORD, 221 dwOutRsts: DWORD, 222 dwNumConns: DWORD, 223 }} 224 pub type PMIB_TCPSTATS_W2K = *mut MIB_TCPSTATS_W2K; 225 pub type MIB_TCPSTATS = MIB_TCPSTATS_LH; 226 pub type PMIB_TCPSTATS = *mut MIB_TCPSTATS; 227 STRUCT!{struct MIB_TCPSTATS2 { 228 RtoAlgorithm: TCP_RTO_ALGORITHM, 229 dwRtoMin: DWORD, 230 dwRtoMax: DWORD, 231 dwMaxConn: DWORD, 232 dwActiveOpens: DWORD, 233 dwPassiveOpens: DWORD, 234 dwAttemptFails: DWORD, 235 dwEstabResets: DWORD, 236 dwCurrEstab: DWORD, 237 dw64InSegs: DWORD64, 238 dw64OutSegs: DWORD64, 239 dwRetransSegs: DWORD, 240 dwInErrs: DWORD, 241 dwOutRsts: DWORD, 242 dwNumConns: DWORD, 243 }} 244 pub type PMIB_TCPSTATS2 = *mut MIB_TCPSTATS2; 245