1
- /* Copyright (c) 2018 Daniel Widdis, All Rights Reserved
1
+ /* Copyright (c) 2018,2020 Daniel Widdis, All Rights Reserved
2
2
*
3
3
* The contents of this file is dual-licensed under 2
4
4
* alternative Open Source/Free licenses: LGPL 2.1 or later and
@@ -51,6 +51,10 @@ public interface IPHlpAPI extends Library {
51
51
int MAX_DOMAIN_NAME_LEN = 128 ;
52
52
int MAX_SCOPE_ID_LEN = 256 ;
53
53
54
+ // Source: Winsock2.h
55
+ int AF_INET = 2 ; // The Internet Protocol version 4 (IPv4) address family.
56
+ int AF_INET6 = 23 ; // The Internet Protocol version 6 (IPv6) address family.
57
+
54
58
/**
55
59
* The MIB_IFROW structure stores information about a particular interface.
56
60
*
@@ -89,8 +93,7 @@ class MIB_IFROW extends Structure {
89
93
}
90
94
91
95
/**
92
- * The MIB_IF_ROW2 structure stores information about a particular
93
- * interface.
96
+ * The MIB_IF_ROW2 structure stores information about a particular interface.
94
97
*
95
98
* @see <A HREF=
96
99
* "https://msdn.microsoft.com/library/windows/hardware/ff559214">MIB_IF_ROW2</A>
@@ -184,8 +187,8 @@ public static class ByReference extends IP_ADDR_STRING implements Structure.ByRe
184
187
}
185
188
186
189
/**
187
- * The FIXED_INFO structure contains information that is the same across all
188
- * the interfaces on a computer.
190
+ * The FIXED_INFO structure contains information that is the same across all the
191
+ * interfaces on a computer.
189
192
*
190
193
* @see <A HREF=
191
194
* "https://docs.microsoft.com/en-us/windows/desktop/api/iptypes/ns-iptypes-fixed_info_w2ksp1">FIXED_INFO</A>
@@ -214,45 +217,90 @@ public FIXED_INFO() {
214
217
}
215
218
216
219
/**
217
- * The GetIfEntry function retrieves information for the specified interface
220
+ * The MIB_TCPSTATS structure contains statistics for the TCP protocol running
218
221
* on the local computer.
219
- *
220
- * The dwIndex member in the MIB_IFROW structure pointed to by the pIfRow
221
- * parameter must be initialized to a valid network interface index
222
- * retrieved by a previous call to the GetIfTable, GetIfTable2, or
223
- * GetIfTable2Ex function. The GetIfEntry function will fail if the dwIndex
224
- * member of the MIB_IFROW pointed to by the pIfRow parameter does not match
225
- * an existing interface index on the local computer.
222
+ * <p>
223
+ * In the Windows SDK, the version of the structure for use on Windows Vista and
224
+ * later is defined as {@code MIB_TCPSTATS_LH}. In the Windows SDK, the version
225
+ * of this structure to be used on earlier systems including Windows 2000 and
226
+ * later is defined as {@code MIB_TCPSTATS_W2K}.
227
+ */
228
+ @ FieldOrder ({ "dwRtoAlgorithm" , "dwRtoMin" , "dwRtoMax" , "dwMaxConn" , "dwActiveOpens" , "dwPassiveOpens" ,
229
+ "dwAttemptFails" , "dwEstabResets" , "dwCurrEstab" , "dwInSegs" , "dwOutSegs" , "dwRetransSegs" , "dwInErrs" ,
230
+ "dwOutRsts" , "dwNumConns" })
231
+ class MIB_TCPSTATS extends Structure {
232
+ public int dwRtoAlgorithm ; // Union for _W2K version, doesn't change mapping
233
+ public int dwRtoMin ;
234
+ public int dwRtoMax ;
235
+ public int dwMaxConn ;
236
+ public int dwActiveOpens ;
237
+ public int dwPassiveOpens ;
238
+ public int dwAttemptFails ;
239
+ public int dwEstabResets ;
240
+ public int dwCurrEstab ;
241
+ public int dwInSegs ;
242
+ public int dwOutSegs ;
243
+ public int dwRetransSegs ;
244
+ public int dwInErrs ;
245
+ public int dwOutRsts ;
246
+ public int dwNumConns ;
247
+ }
248
+
249
+ /**
250
+ * The MIB_UDPSTATS structure contains statistics for the User Datagram Protocol
251
+ * (UDP) running on the local computer.
252
+ */
253
+ @ FieldOrder ({ "dwInDatagrams" , "dwNoPorts" , "dwInErrors" , "dwOutDatagrams" , "dwNumAddrs" })
254
+ class MIB_UDPSTATS extends Structure {
255
+ public int dwInDatagrams ;
256
+ public int dwNoPorts ;
257
+ public int dwInErrors ;
258
+ public int dwOutDatagrams ;
259
+ public int dwNumAddrs ;
260
+ }
261
+
262
+ /**
263
+ * The GetIfEntry function retrieves information for the specified interface on
264
+ * the local computer.
265
+ * <p>
266
+ * The {@code dwIndex} member in the {@link MIB_IFROW} structure pointed to by
267
+ * the pIfRow parameter must be initialized to a valid network interface index
268
+ * retrieved by a previous call to the GetIfTable, GetIfTable2, or GetIfTable2Ex
269
+ * function. The GetIfEntry function will fail if the dwIndex member of the
270
+ * {@link MIB_IFROW} pointed to by the pIfRow parameter does not match an
271
+ * existing interface index on the local computer.
226
272
*
227
273
* @param pIfRow
228
274
* A pointer to a MIB_IFROW structure that, on successful return,
229
- * receives information for an interface on the local computer.
230
- * On input, set the dwIndex member of MIB_IFROW to the index of
275
+ * receives information for an interface on the local computer. On
276
+ * input, set the dwIndex member of {@link MIB_IFROW} to the index of
231
277
* the interface for which to retrieve information.
232
- * @return If the function succeeds, the return value is NO_ERROR.
278
+ * @return If the function succeeds, the return value is
279
+ * {@link WinError#NO_ERROR}.
233
280
*/
234
281
int GetIfEntry (MIB_IFROW pIfRow );
235
282
236
283
/**
237
- * The GetIfEntry2 function retrieves information for the specified
238
- * interface on the local computer.
239
- *
240
- * On input, at least one of the following members in the MIB_IF_ROW2
241
- * structure passed in the Row parameter must be initialized: InterfaceLuid
242
- * or InterfaceIndex. The fields are used in the order listed above. So if
243
- * the InterfaceLuid is specified, then this member is used to determine the
284
+ * The GetIfEntry2 function retrieves information for the specified interface on
285
+ * the local computer.
286
+ * <p>
287
+ * On input, at least one of the following members in the {@link MIB_IF_ROW2}
288
+ * structure passed in the Row parameter must be initialized: InterfaceLuid or
289
+ * InterfaceIndex. The fields are used in the order listed above. So if the
290
+ * InterfaceLuid is specified, then this member is used to determine the
244
291
* interface. If no value was set for the InterfaceLuid member (the value of
245
- * this member was set to zero), then the InterfaceIndex member is next used
246
- * to determine the interface. On output, the remaining fields of the
247
- * MIB_IF_ROW2 structure pointed to by the Row parameter are filled in.
292
+ * this member was set to zero), then the InterfaceIndex member is next used to
293
+ * determine the interface. On output, the remaining fields of the
294
+ * {@link MIB_IF_ROW2} structure pointed to by the Row parameter are filled in.
248
295
*
249
296
* @param pIfRow2
250
- * A pointer to a MIB_IF_ROW2 structure that, on successful
297
+ * A pointer to a {@link MIB_IF_ROW2} structure that, on successful
251
298
* return, receives information for an interface on the local
252
- * computer. On input, the InterfaceLuid or the InterfaceIndex
253
- * member of the MIB_IF_ROW2 must be set to the interface for
254
- * which to retrieve information.
255
- * @return If the function succeeds, the return value is NO_ERROR.
299
+ * computer. On input, the InterfaceLuid or the InterfaceIndex member
300
+ * of the {@link MIB_IF_ROW2} must be set to the interface for which
301
+ * to retrieve information.
302
+ * @return If the function succeeds, the return value is
303
+ * {@link WinError#NO_ERROR}.
256
304
*/
257
305
int GetIfEntry2 (MIB_IF_ROW2 pIfRow2 );
258
306
@@ -261,18 +309,77 @@ public FIXED_INFO() {
261
309
* computer.
262
310
*
263
311
* @param pFixedInfo
264
- * A pointer to a buffer that contains a FIXED_INFO structure
265
- * that receives the network parameters for the local computer,
266
- * if the function was successful. This buffer must be allocated
267
- * by the caller prior to calling the GetNetworkParams function.
312
+ * A pointer to a buffer that contains a {@link FIXED_INFO} structure
313
+ * that receives the network parameters for the local computer, if
314
+ * the function was successful. This buffer must be allocated by the
315
+ * caller prior to calling the GetNetworkParams function.
268
316
* @param pOutBufLen
269
317
* A pointer to a ULONG variable that specifies the size of the
270
- * FIXED_INFO structure. If this size is insufficient to hold the
271
- * information, GetNetworkParams fills in this variable with the
318
+ * {@link FIXED_INFO} structure. If this size is insufficient to hold
319
+ * the information, GetNetworkParams fills in this variable with the
272
320
* required size, and returns an error code of
273
- * ERROR_BUFFER_OVERFLOW.
274
- * @return If the function succeeds, the return value is ERROR_SUCCESS.
321
+ * {@link WinError#ERROR_BUFFER_OVERFLOW}.
322
+ * @return If the function succeeds, the return value is
323
+ * {@link WinError#ERROR_SUCCESS}.
275
324
*/
276
325
int GetNetworkParams (Pointer pFixedInfo , IntByReference pOutBufLen );
277
- }
278
326
327
+ /**
328
+ * The GetTcpStatistics function retrieves the TCP statistics for the local
329
+ * computer.
330
+ *
331
+ * @param Statistics
332
+ * A {@link MIB_TCPSTATS} structure that receives the TCP statistics
333
+ * for the local computer.
334
+ * @return If the function succeeds, the return value is
335
+ * {@link WinError#NO_ERROR}.
336
+ */
337
+ int GetTcpStatistics (MIB_TCPSTATS Statistics );
338
+
339
+ /**
340
+ * The GetTcpStatisticsEx function retrieves the Transmission Control Protocol
341
+ * (TCP) statistics for the current computer. The GetTcpStatisticsEx function
342
+ * differs from the {@link #GetTcpStatistics} function in that
343
+ * GetTcpStatisticsEx also supports the Internet Protocol version 6 (IPv6)
344
+ * protocol family.
345
+ *
346
+ * @param Statistics
347
+ * A {@link MIB_TCPSTATS} structure that receives the TCP statistics
348
+ * for the local computer.
349
+ * @param Family
350
+ * The protocol family for which to retrieve statistics. This
351
+ * parameter must be {@link #AF_INET} or {@link #AF_INET6}.
352
+ * @return If the function succeeds, the return value is
353
+ * {@link WinError#NO_ERROR}.
354
+ */
355
+ int GetTcpStatisticsEx (MIB_TCPSTATS Statistics , int Family );
356
+
357
+ /**
358
+ * The GetUdpStatistics function retrieves the User Datagram Protocol (UDP)
359
+ * statistics for the local computer.
360
+ *
361
+ * @param Statistics
362
+ * A {@link MIB_UDPSTATS} structure that receives the UDP statistics
363
+ * for the local computer.
364
+ * @return If the function succeeds, the return value is
365
+ * {@link WinError#NO_ERROR}.
366
+ */
367
+ int GetUdpStatistics (MIB_UDPSTATS Statistics );
368
+
369
+ /**
370
+ * The GetUdpStatisticsEx function retrieves the User Datagram Protocol (UDP)
371
+ * statistics for the current computer. The GetUdpStatisticsEx function differs
372
+ * from the {@link #GetUdpStatistics} function in that GetUdpStatisticsEx also
373
+ * supports the Internet Protocol version 6 (IPv6) protocol family.
374
+ *
375
+ * @param Statistics
376
+ * A {@link MIB_UDPSTATS} structure that receives the UDP statistics
377
+ * for the local computer.
378
+ * @param Family
379
+ * The protocol family for which to retrieve statistics. This
380
+ * parameter must be {@link #AF_INET} or {@link #AF_INET6}.
381
+ * @return If the function succeeds, the return value is
382
+ * {@link WinError#NO_ERROR}.
383
+ */
384
+ int GetUdpStatisticsEx (MIB_UDPSTATS Statistics , int Family );
385
+ }
0 commit comments