iphlpapi: Implement GetIfTable2.
This commit is contained in:
parent
d5a1e47a45
commit
ad9ba6a029
|
@ -91,7 +91,7 @@
|
||||||
@ stub GetIfEntryFromStack
|
@ stub GetIfEntryFromStack
|
||||||
#@ stub GetIfStackTable
|
#@ stub GetIfStackTable
|
||||||
@ stdcall GetIfTable( ptr ptr long )
|
@ stdcall GetIfTable( ptr ptr long )
|
||||||
#@ stub GetIfTable2
|
@ stdcall GetIfTable2( ptr )
|
||||||
#@ stub GetIfTable2Ex
|
#@ stub GetIfTable2Ex
|
||||||
@ stub GetIfTableFromStack
|
@ stub GetIfTableFromStack
|
||||||
@ stub GetIgmpList
|
@ stub GetIgmpList
|
||||||
|
|
|
@ -1828,6 +1828,43 @@ DWORD WINAPI GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
|
||||||
return ret;
|
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.@)
|
* GetInterfaceInfo (IPHLPAPI.@)
|
||||||
|
|
|
@ -56,6 +56,7 @@ static DWORD (WINAPI *pGetIfEntry)(PMIB_IFROW);
|
||||||
static DWORD (WINAPI *pGetIfEntry2)(PMIB_IF_ROW2);
|
static DWORD (WINAPI *pGetIfEntry2)(PMIB_IF_ROW2);
|
||||||
static DWORD (WINAPI *pGetFriendlyIfIndex)(DWORD);
|
static DWORD (WINAPI *pGetFriendlyIfIndex)(DWORD);
|
||||||
static DWORD (WINAPI *pGetIfTable)(PMIB_IFTABLE,PULONG,BOOL);
|
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 *pGetIpForwardTable)(PMIB_IPFORWARDTABLE,PULONG,BOOL);
|
||||||
static DWORD (WINAPI *pGetIpNetTable)(PMIB_IPNETTABLE,PULONG,BOOL);
|
static DWORD (WINAPI *pGetIpNetTable)(PMIB_IPNETTABLE,PULONG,BOOL);
|
||||||
static DWORD (WINAPI *pGetInterfaceInfo)(PIP_INTERFACE_INFO,PULONG);
|
static DWORD (WINAPI *pGetInterfaceInfo)(PIP_INTERFACE_INFO,PULONG);
|
||||||
|
@ -102,6 +103,7 @@ static void loadIPHlpApi(void)
|
||||||
pGetIfEntry2 = (void *)GetProcAddress(hLibrary, "GetIfEntry2");
|
pGetIfEntry2 = (void *)GetProcAddress(hLibrary, "GetIfEntry2");
|
||||||
pGetFriendlyIfIndex = (void *)GetProcAddress(hLibrary, "GetFriendlyIfIndex");
|
pGetFriendlyIfIndex = (void *)GetProcAddress(hLibrary, "GetFriendlyIfIndex");
|
||||||
pGetIfTable = (void *)GetProcAddress(hLibrary, "GetIfTable");
|
pGetIfTable = (void *)GetProcAddress(hLibrary, "GetIfTable");
|
||||||
|
pGetIfTable2 = (void *)GetProcAddress(hLibrary, "GetIfTable2");
|
||||||
pGetIpForwardTable = (void *)GetProcAddress(hLibrary, "GetIpForwardTable");
|
pGetIpForwardTable = (void *)GetProcAddress(hLibrary, "GetIpForwardTable");
|
||||||
pGetIpNetTable = (void *)GetProcAddress(hLibrary, "GetIpNetTable");
|
pGetIpNetTable = (void *)GetProcAddress(hLibrary, "GetIpNetTable");
|
||||||
pGetInterfaceInfo = (void *)GetProcAddress(hLibrary, "GetInterfaceInfo");
|
pGetInterfaceInfo = (void *)GetProcAddress(hLibrary, "GetInterfaceInfo");
|
||||||
|
@ -1868,6 +1870,24 @@ static void test_GetIfEntry2(void)
|
||||||
ok( row.InterfaceIndex == index, "got %u\n", index );
|
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)
|
START_TEST(iphlpapi)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1890,6 +1910,7 @@ START_TEST(iphlpapi)
|
||||||
test_CreateSortedAddressPairs();
|
test_CreateSortedAddressPairs();
|
||||||
test_interface_identifier_conversion();
|
test_interface_identifier_conversion();
|
||||||
test_GetIfEntry2();
|
test_GetIfEntry2();
|
||||||
|
test_GetIfTable2();
|
||||||
freeIPHlpApi();
|
freeIPHlpApi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,12 @@ typedef struct _MIB_IF_ROW2
|
||||||
ULONG64 OutQLen;
|
ULONG64 OutQLen;
|
||||||
} MIB_IF_ROW2, *PMIB_IF_ROW2;
|
} 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 ConvertInterfaceGuidToLuid(const GUID*,NET_LUID*);
|
||||||
DWORD WINAPI ConvertInterfaceIndexToLuid(NET_IFINDEX,NET_LUID*);
|
DWORD WINAPI ConvertInterfaceIndexToLuid(NET_IFINDEX,NET_LUID*);
|
||||||
DWORD WINAPI ConvertInterfaceLuidToGuid(const NET_LUID*,GUID*);
|
DWORD WINAPI ConvertInterfaceLuidToGuid(const NET_LUID*,GUID*);
|
||||||
|
|
Loading…
Reference in New Issue