reactos/dll/win32/iphlpapi/ipstats.h
Joachim Henze 8898f92574 [0.4.10][IPHLPAPI][TCPIP][IP][LWIP][SDK][PSDK] Port back groundworks for netstat
This fixes:
CORE-15363 'netstat TCP foreign address port is wrong'
CORE-5401 'Netstat returns ERROR_NO_DATA Pipe being closed'
CORE-5126 'UNIMPLEMENTED: iphlpapi: GetExtendedUdpTable'
even without touching the netstat binary yet.
And is mostly based on work done by Pierre Schweitzer during 0.4.11-dev'ing.

by porting back:
0.4.15-dev-6231-g a5360f542f [IPHLPAPI] Formatting only, no functional change
partially 0.4.14-dev-1425-g f540b2b20c [IPHLPAPI] GetAdaptersAddresses(): Add 1 free() in ERROR_NO_DATA case (#2526) (but leave out adding the comments in .h)
0.4.12-dev-686-g 22f60faf43 [IPHLPAPI] Remove dead code to fix CID 513306, 1442673, 1442697
0.4.11-dev-880-g bf052e120b [IPHLPAPI] Reduce code duplication and use a single function for TCP and UDP enumerations + fix corruption
0.4.11-dev-867-g 159f5b676a [IPHLPAPI] Fix broken size computation leading to buffer overrun
0.4.11-dev-861-g 05657bfcfd [SDK] Add a non documenter TOIID used to query modules information
0.4.11-dev-827-g ce7f9211a0 [TCPIP] In InfoTdiQueryGetConnectionTcpTable(), only return if there's a connection
0.4.11-dev-823-g 0ec92100bc [TCPIP] Properly display local information for established connections
0.4.11-dev-819-g fbdfe7bd40 [SDK] Add GetExtendedUdpTable()
0.4.11-dev-818-g 370b03b523 [IPHLPAPI] Reimplement GetUdpTable() using GetExtendedUdpTable()
0.4.11-dev-817-g 58cef01422 [IPHLPAPI] Implement GetExtendedUdpTable() CORE-5126
0.4.11-dev-816-g 6fb6c7b50b [IPHLPAPI] Implement getOwnerUdoTable(), to get UDP connections with owner PID
0.4.11-dev-815-g 13de7f08af [TCPIP] Implement enumerating UDP connections with owner PID
0.4.11-dev-813-g 73c87d5c14 [IPHLPAPI] Reimplement GetTcpTable() using GetExtendedTcpTable()
0.4.11-dev-812-g d76ac645e8 [IPHLPAPI] Don't leak memory
0.4.11-dev-811-g c949a12506 [IPHLPAPI] Implement the IPv4 TCP_TABLE_OWNER_PID_* cases in GetExtendedTcpTable()
0.4.11-dev-810-g dca7e5689f [IPHLPAPI] Implement getOwnerTcpTable(), to get TCP connections with owner PID
0.4.11-dev-809-g 411504b5f4 [TCPIP] Implement enumerating TCP connections with owner PID
0.4.11-dev-808-g 935978ee57 [TCPIP] Store creator PID in ADDRESS_FILE
0.4.11-dev-807-g 702d44c683 [IPHLPAPI] Implement the IPv4 TCP_TABLE_BASIC_* cases in GetExtendedTcpTable()
0.4.11-dev-804-g 91b013d387 [TCPIP] When enumerating sockets, retrieve their state and return it
0.4.11-dev-803-g 738f327668 [IP] Add a TCPGetSocketStatus() wrapper around LibTCPGetSocketStatus()
0.4.11-dev-802-g 29c1510423 [LWIP] Implement a LibTCPGetSocketStatus() function in our LwIP glue
0.4.11-dev-792-g 8a98c85c1f [IPHLPAPI] Fix checking entity when enumerating TCP/UDP connections
0.4.11-dev-784-g f29016dabe [TCPIP] Properly handle listening sockets
0.4.11-dev-782-g 007f43dd56 [TCPIP] Implement returning UDP connections CORE-5401
0.4.11-dev-781-g 77d5f04f22 [TCPIP] Implement returning TCP connections CORE-5401
0.4.11-dev-799-g 500a5151ea [TCPIP] Fix returned IP address when querying TCP connections CORE-15363
0.4.11-dev-783-g d18b1fe24b [IPHLPAPI] Properly count UDP entries CORE-5401
0.4.11-dev-780-g e3cb9697a4 [IPHLPAPI] Implement getNumUdpEntries() and getUdpTable() CORE-5401
0.4.11-dev-779-g 678204790c [IPHLPAPI] Implement getNumTcpEntries() and getTcpTable() CORE-5401
----------------
Strip some DPRINTs entirely in IPHLPAPI/TCPIP in releases/0.4.7 - 0.4.10 (instead of fixing them like we did on master). Many of them had x64 issues:
This was partially *inspired* by watching the following commits:
0.4.13-dev-14-g f9a967b2ae [IPHLPAPI] Fix misc 64 bit issues (only the parts in iphlpapi_main.c with the format strings)
0.4.10-dev-409-g 0f8439aa71 [IPHLPAPI] Fix 64 bit issue, just the one within [IPHLPAPI] ifenum_reactos.c
0.4.9-dev-856-g 6c9359221c [IPHLPAPI] ipstats_reactos: Review all TRACE/WARN calls
This does not only fix the x64 incompatibilities by superseding those 3 commits but also will keep the file-sizes under control for the backports.
2023-07-03 01:47:10 +02:00

115 lines
3.5 KiB
C

/* ipstats.h
* Copyright (C) 2003 Juan Lang
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* This module implements functions shared by DLLs that need to get network-
* related statistics. It's meant to hide some platform-specificisms, and
* share code that was previously duplicated.
*/
#ifndef WINE_IPSTATS_H_
#define WINE_IPSTATS_H_
//#include <stdarg.h>
//#include "windef.h"
//#include "winbase.h"
//#include "iprtrmib.h"
/* Fills in entry's interface stats, using name to find them.
* Returns ERROR_INVALID_PARAMETER if name or entry is NULL, NO_ERROR otherwise.
*/
DWORD getInterfaceStatsByName(const char *name, PMIB_IFROW entry);
/* Ditto above by index. */
DWORD getInterfaceStatsByIndex(DWORD index, PMIB_IFROW entry);
/* Gets ICMP statistics into stats. Returns ERROR_INVALID_PARAMETER if stats is
* NULL, NO_ERROR otherwise.
*/
DWORD getICMPStats(MIB_ICMP *stats);
/* Gets IP statistics into stats. Returns ERROR_INVALID_PARAMETER if stats is
* NULL, NO_ERROR otherwise.
*/
DWORD getIPStats(PMIB_IPSTATS stats, DWORD family);
/* Gets TCP statistics into stats. Returns ERROR_INVALID_PARAMETER if stats is
* NULL, NO_ERROR otherwise.
*/
DWORD getTCPStats(MIB_TCPSTATS *stats, DWORD family);
/* Gets UDP statistics into stats. Returns ERROR_INVALID_PARAMETER if stats is
* NULL, NO_ERROR otherwise.
*/
DWORD getUDPStats(MIB_UDPSTATS *stats, DWORD family);
/* Route table functions */
DWORD getNumRoutes(void);
/* Minimalist route entry, only has the fields I can actually fill in. How
* these map to the different windows route data structures is up to you.
*/
typedef struct _RouteEntry {
DWORD dest;
DWORD mask;
DWORD gateway;
DWORD ifIndex;
DWORD metric;
} RouteEntry;
typedef struct _RouteTable {
DWORD numRoutes;
RouteEntry routes[1];
} RouteTable;
typedef enum _CLASS_TABLE {
ClassBasic,
ClassModulePid,
ClassModule
} CLASS_TABLE;
/* Allocates and returns to you the route table, or NULL if it can't allocate
* enough memory. free() the returned table.
*/
RouteTable *getRouteTable(void);
/* Returns the number of entries in the arp table. */
DWORD getNumArpEntries(void);
/* Allocates and returns to you the arp table, or NULL if it can't allocate
* enough memory. free() the returned table.
*/
PMIB_IPNETTABLE getArpTable(void);
/* Returns the number of entries in the UDP state table. */
DWORD getNumUdpEntries(void);
/* Allocates and returns to you the UDP state table, or NULL if it can't
* allocate enough memory. free() the returned table.
*/
PVOID getUdpTable(CLASS_TABLE Class);
/* Returns the number of entries in the TCP state table. */
DWORD getNumTcpEntries(void);
/* Allocates and returns to you the TCP state table, or NULL if it can't
* allocate enough memory. free() the returned table.
*/
PVOID getTcpTable(CLASS_TABLE Class);
#endif /* ndef WINE_IPSTATS_H_ */