Commit bfd7b9bc authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

iphlpapi: Sort by adapter index first in GetIpNetTable().

parent fae847ad
......@@ -2282,6 +2282,9 @@ err:
static int ipnetrow_cmp( const void *a, const void *b )
{
const MIB_IPNETROW *rowA = a, *rowB = b;
if (rowA->dwIndex != rowB->dwIndex) return DWORD_cmp( rowA->dwIndex, rowB->dwIndex );
return DWORD_cmp(RtlUlongByteSwap( rowA->dwAddr ), RtlUlongByteSwap( rowB->dwAddr ));
}
......
......@@ -371,6 +371,7 @@ static void testGetIpNetTable(void)
{
DWORD apiReturn;
ULONG dwSize = 0;
unsigned int i;
apiReturn = GetIpNetTable(NULL, NULL, FALSE);
if (apiReturn == ERROR_NOT_SUPPORTED) {
......@@ -390,11 +391,23 @@ static void testGetIpNetTable(void)
PMIB_IPNETTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
memset(buf, 0xcc, dwSize);
apiReturn = GetIpNetTable(buf, &dwSize, FALSE);
apiReturn = GetIpNetTable(buf, &dwSize, TRUE);
ok((apiReturn == NO_ERROR && buf->dwNumEntries) || (apiReturn == ERROR_NO_DATA && !buf->dwNumEntries),
"got apiReturn %lu, dwSize %lu, buf->dwNumEntries %lu.\n",
apiReturn, dwSize, buf->dwNumEntries);
if (apiReturn == NO_ERROR)
{
for (i = 0; i < buf->dwNumEntries - 1; ++i)
{
ok( buf->table[i].dwIndex <= buf->table[i + 1].dwIndex,
"Entries are not sorted by index, i %u.\n", i );
if (buf->table[i].dwIndex == buf->table[i + 1].dwIndex)
ok(ntohl(buf->table[i].dwAddr) <= ntohl(buf->table[i + 1].dwAddr),
"Entries are not sorted by address, i %u.\n", i );
}
}
if (apiReturn == NO_ERROR && winetest_debug > 1)
{
DWORD i, j;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment