[4/4] iphlpapi: Improved GetTcpStatisticsEx stub

André Hentschel nerv at dawncrow.de
Wed Sep 19 16:56:12 CDT 2012


I simply didn't found out how to get tcp ipv6 stats on linux, they are not in /proc/net/snmp6 for some reasons

---
 dlls/iphlpapi/iphlpapi.spec    |    2 +-
 dlls/iphlpapi/ipstats.c        |   30 +++++++++++++++++++++++++++---
 dlls/iphlpapi/tests/iphlpapi.c |    6 +++++-
 3 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/dlls/iphlpapi/iphlpapi.spec b/dlls/iphlpapi/iphlpapi.spec
index 368159a..36ba13f 100644
--- a/dlls/iphlpapi/iphlpapi.spec
+++ b/dlls/iphlpapi/iphlpapi.spec
@@ -134,7 +134,7 @@
 #@ stub GetSessionCompartmentId
 @ stdcall GetTcp6Table( ptr ptr long )
 @ stdcall GetTcp6Table2( ptr ptr long )
-#@ stub GetTcpStatisticsEx
+@ stdcall GetTcpStatisticsEx( ptr long )
 @ stdcall GetTcpStatistics( ptr )
 @ stub GetTcpStatsFromStack
 @ stdcall GetTcpTable( ptr ptr long )
diff --git a/dlls/iphlpapi/ipstats.c b/dlls/iphlpapi/ipstats.c
index 4135f72..815740a 100644
--- a/dlls/iphlpapi/ipstats.c
+++ b/dlls/iphlpapi/ipstats.c
@@ -975,24 +975,32 @@ DWORD WINAPI GetIpStatistics(PMIB_IPSTATS stats)
 }
 
 /******************************************************************
- *    GetTcpStatistics (IPHLPAPI.@)
+ *    GetTcpStatisticsEx (IPHLPAPI.@)
  *
- * Get the TCP statistics for the local computer.
+ * Get the IPv4 and IPv6 TCP statistics for the local computer.
  *
  * PARAMS
  *  stats [Out] buffer for TCP statistics
+ *  family [In] specifies wether IPv4 or IPv6 statistics are returned
  *
  * RETURNS
  *  Success: NO_ERROR
  *  Failure: error code from winerror.h
  */
-DWORD WINAPI GetTcpStatistics(PMIB_TCPSTATS stats)
+DWORD WINAPI GetTcpStatisticsEx(PMIB_TCPSTATS stats, DWORD family)
 {
     DWORD ret = ERROR_NOT_SUPPORTED;
 
     if (!stats) return ERROR_INVALID_PARAMETER;
+    if (family != WS_AF_INET && family != WS_AF_INET6) return ERROR_INVALID_PARAMETER;
     memset( stats, 0, sizeof(*stats) );
 
+    if (family == WS_AF_INET6)
+    {
+        FIXME( "unimplemented for IPv6\n" );
+        return ret;
+    }
+
 #ifdef __linux__
     {
         FILE *fp;
@@ -1111,6 +1119,22 @@ DWORD WINAPI GetTcpStatistics(PMIB_TCPSTATS stats)
     return ret;
 }
 
+/******************************************************************
+ *    GetTcpStatistics (IPHLPAPI.@)
+ *
+ * Get the TCP statistics for the local computer.
+ *
+ * PARAMS
+ *  stats [Out] buffer for TCP statistics
+ *
+ * RETURNS
+ *  Success: NO_ERROR
+ *  Failure: error code from winerror.h
+ */
+DWORD WINAPI GetTcpStatistics(PMIB_TCPSTATS stats)
+{
+    return GetTcpStatisticsEx(stats, WS_AF_INET);
+}
 
 /******************************************************************
  *    GetUdpStatistics (IPHLPAPI.@)
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c
index eb96189..c34267e 100644
--- a/dlls/iphlpapi/tests/iphlpapi.c
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -659,7 +659,7 @@ static void testGetTcpStatisticsEx(void)
 
     if (!pGetTcpStatisticsEx)
     {
-        skip( "GetTcpStatisticsEx not available\n" );
+        win_skip( "GetTcpStatisticsEx not available\n" );
         return;
     }
 
@@ -667,6 +667,10 @@ static void testGetTcpStatisticsEx(void)
     ok(apiReturn == ERROR_INVALID_PARAMETER,
        "GetTcpStatisticsEx(NULL, AF_INET); returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn);
 
+    apiReturn = pGetTcpStatisticsEx(&stats, AF_BAN);
+    ok(apiReturn == ERROR_INVALID_PARAMETER || apiReturn == ERROR_NOT_SUPPORTED,
+       "GetTcpStatisticsEx(&stats, AF_BAN) returned %d, expected ERROR_INVALID_PARAMETER\n", apiReturn);
+
     apiReturn = pGetTcpStatisticsEx(&stats, AF_INET);
     ok(apiReturn == NO_ERROR, "GetTcpStatisticsEx returned %d, expected NO_ERROR\n", apiReturn);
     if (apiReturn == NO_ERROR && winetest_debug > 1)
-- 
1.7.4.1


-- 

Best Regards, André Hentschel


More information about the wine-patches mailing list