Hans Leidekker : iphlpapi: Implement GetIfTable2.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Aug 18 09:22:16 CDT 2015


Module: wine
Branch: master
Commit: ad9ba6a029b03e6fd805bd18fe272bb694481a6a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ad9ba6a029b03e6fd805bd18fe272bb694481a6a

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Tue Aug 18 09:41:23 2015 +0200

iphlpapi: Implement GetIfTable2.

---

 dlls/iphlpapi/iphlpapi.spec    |  2 +-
 dlls/iphlpapi/iphlpapi_main.c  | 37 +++++++++++++++++++++++++++++++++++++
 dlls/iphlpapi/tests/iphlpapi.c | 21 +++++++++++++++++++++
 include/netioapi.h             |  6 ++++++
 4 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/dlls/iphlpapi/iphlpapi.spec b/dlls/iphlpapi/iphlpapi.spec
index 50ea35b..4be42fe 100644
--- a/dlls/iphlpapi/iphlpapi.spec
+++ b/dlls/iphlpapi/iphlpapi.spec
@@ -91,7 +91,7 @@
 @ stub GetIfEntryFromStack
 #@ stub GetIfStackTable
 @ stdcall GetIfTable( ptr ptr long )
-#@ stub GetIfTable2
+@ stdcall GetIfTable2( ptr )
 #@ stub GetIfTable2Ex
 @ stub GetIfTableFromStack
 @ stub GetIgmpList
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index cac702c..90dcda3 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -1828,6 +1828,43 @@ DWORD WINAPI GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
   return ret;
 }
 
+/******************************************************************
+ *    GetIfTable2 (IPHLPAPI.@)
+ */
+DWORD WINAPI GetIfTable2( MIB_IF_TABLE2 **table )
+{
+    DWORD i, nb_interfaces, size = sizeof(MIB_IF_TABLE2);
+    InterfaceIndexTable *index_table;
+    MIB_IF_TABLE2 *ret;
+
+    TRACE( "table %p\n", table );
+
+    if (!table) return ERROR_INVALID_PARAMETER;
+
+    if ((nb_interfaces = get_interface_indices( FALSE, NULL )) > 1)
+        size += (nb_interfaces - 1) * sizeof(MIB_IF_ROW2);
+
+    if (!(ret = HeapAlloc( GetProcessHeap(), 0, size ))) return ERROR_OUTOFMEMORY;
+
+    get_interface_indices( FALSE, &index_table );
+    if (!index_table)
+    {
+        HeapFree( GetProcessHeap(), 0, ret );
+        return ERROR_OUTOFMEMORY;
+    }
+
+    ret->NumEntries = 0;
+    for (i = 0; i < index_table->numIndexes; i++)
+    {
+        ret->Table[i].InterfaceIndex = index_table->indexes[i];
+        GetIfEntry2( &ret->Table[i] );
+        ret->NumEntries++;
+    }
+
+    HeapFree( GetProcessHeap(), 0, index_table );
+    *table = ret;
+    return NO_ERROR;
+}
 
 /******************************************************************
  *    GetInterfaceInfo (IPHLPAPI.@)
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c
index 6553581..92653ed5 100644
--- a/dlls/iphlpapi/tests/iphlpapi.c
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -56,6 +56,7 @@ static DWORD (WINAPI *pGetIfEntry)(PMIB_IFROW);
 static DWORD (WINAPI *pGetIfEntry2)(PMIB_IF_ROW2);
 static DWORD (WINAPI *pGetFriendlyIfIndex)(DWORD);
 static DWORD (WINAPI *pGetIfTable)(PMIB_IFTABLE,PULONG,BOOL);
+static DWORD (WINAPI *pGetIfTable2)(PMIB_IF_TABLE2*);
 static DWORD (WINAPI *pGetIpForwardTable)(PMIB_IPFORWARDTABLE,PULONG,BOOL);
 static DWORD (WINAPI *pGetIpNetTable)(PMIB_IPNETTABLE,PULONG,BOOL);
 static DWORD (WINAPI *pGetInterfaceInfo)(PIP_INTERFACE_INFO,PULONG);
@@ -102,6 +103,7 @@ static void loadIPHlpApi(void)
     pGetIfEntry2 = (void *)GetProcAddress(hLibrary, "GetIfEntry2");
     pGetFriendlyIfIndex = (void *)GetProcAddress(hLibrary, "GetFriendlyIfIndex");
     pGetIfTable = (void *)GetProcAddress(hLibrary, "GetIfTable");
+    pGetIfTable2 = (void *)GetProcAddress(hLibrary, "GetIfTable2");
     pGetIpForwardTable = (void *)GetProcAddress(hLibrary, "GetIpForwardTable");
     pGetIpNetTable = (void *)GetProcAddress(hLibrary, "GetIpNetTable");
     pGetInterfaceInfo = (void *)GetProcAddress(hLibrary, "GetInterfaceInfo");
@@ -1868,6 +1870,24 @@ static void test_GetIfEntry2(void)
     ok( row.InterfaceIndex == index, "got %u\n", index );
 }
 
+static void test_GetIfTable2(void)
+{
+    DWORD ret;
+    MIB_IF_TABLE2 *table;
+
+    if (!pGetIfTable2)
+    {
+        win_skip( "GetIfTable2 not available\n" );
+        return;
+    }
+
+    table = NULL;
+    ret = pGetIfTable2( &table );
+    ok( ret == NO_ERROR, "got %u\n", ret );
+    ok( table != NULL, "table not set\n" );
+    pFreeMibTable( table );
+}
+
 START_TEST(iphlpapi)
 {
 
@@ -1890,6 +1910,7 @@ START_TEST(iphlpapi)
     test_CreateSortedAddressPairs();
     test_interface_identifier_conversion();
     test_GetIfEntry2();
+    test_GetIfTable2();
     freeIPHlpApi();
   }
 }
diff --git a/include/netioapi.h b/include/netioapi.h
index 894dbc5..0357431 100644
--- a/include/netioapi.h
+++ b/include/netioapi.h
@@ -76,6 +76,12 @@ typedef struct _MIB_IF_ROW2
     ULONG64 OutQLen;
 } MIB_IF_ROW2, *PMIB_IF_ROW2;
 
+typedef struct _MIB_IF_TABLE2
+{
+    ULONG NumEntries;
+    MIB_IF_ROW2 Table[1];
+} MIB_IF_TABLE2, *PMIB_IF_TABLE2;
+
 DWORD WINAPI ConvertInterfaceGuidToLuid(const GUID*,NET_LUID*);
 DWORD WINAPI ConvertInterfaceIndexToLuid(NET_IFINDEX,NET_LUID*);
 DWORD WINAPI ConvertInterfaceLuidToGuid(const NET_LUID*,GUID*);




More information about the wine-cvs mailing list