Commit 60354102 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

iphlpapi: Only return gateway addresses if GAA_FLAG_INCLUDE_ALL_GATEWAYS is specified.

parent 8d3318a8
...@@ -716,7 +716,8 @@ static PMIB_IPFORWARDROW findIPv4Gateway(DWORD index, ...@@ -716,7 +716,8 @@ static PMIB_IPFORWARDROW findIPv4Gateway(DWORD index,
return row; return row;
} }
static ULONG adapterAddressesFromIndex(ULONG family, DWORD index, IP_ADAPTER_ADDRESSES *aa, ULONG *size) static ULONG adapterAddressesFromIndex(ULONG family, ULONG flags, DWORD index,
IP_ADAPTER_ADDRESSES *aa, ULONG *size)
{ {
ULONG ret, i, num_v4addrs = 0, num_v4_gateways = 0, num_v6addrs = 0, total_size; ULONG ret, i, num_v4addrs = 0, num_v4_gateways = 0, num_v6addrs = 0, total_size;
DWORD *v4addrs = NULL; DWORD *v4addrs = NULL;
...@@ -725,26 +726,29 @@ static ULONG adapterAddressesFromIndex(ULONG family, DWORD index, IP_ADAPTER_ADD ...@@ -725,26 +726,29 @@ static ULONG adapterAddressesFromIndex(ULONG family, DWORD index, IP_ADAPTER_ADD
if (family == WS_AF_INET) if (family == WS_AF_INET)
{ {
ret = AllocateAndGetIpForwardTableFromStack(&routeTable, FALSE, ret = v4addressesFromIndex(index, &v4addrs, &num_v4addrs);
GetProcessHeap(), 0); if (!ret && flags & GAA_FLAG_INCLUDE_ALL_GATEWAYS)
if (!ret)
{ {
ret = v4addressesFromIndex(index, &v4addrs, &num_v4addrs); ret = AllocateAndGetIpForwardTableFromStack(&routeTable, FALSE,
num_v4_gateways = count_v4_gateways(index, routeTable); GetProcessHeap(), 0);
if (!ret)
num_v4_gateways = count_v4_gateways(index, routeTable);
} }
} }
else if (family == WS_AF_INET6) else if (family == WS_AF_INET6)
ret = v6addressesFromIndex(index, &v6addrs, &num_v6addrs); ret = v6addressesFromIndex(index, &v6addrs, &num_v6addrs);
else if (family == WS_AF_UNSPEC) else if (family == WS_AF_UNSPEC)
{ {
ret = AllocateAndGetIpForwardTableFromStack(&routeTable, FALSE, ret = v4addressesFromIndex(index, &v4addrs, &num_v4addrs);
GetProcessHeap(), 0); if (!ret && flags & GAA_FLAG_INCLUDE_ALL_GATEWAYS)
if (!ret)
{ {
ret = v4addressesFromIndex(index, &v4addrs, &num_v4addrs); ret = AllocateAndGetIpForwardTableFromStack(&routeTable, FALSE,
num_v4_gateways = count_v4_gateways(index, routeTable); GetProcessHeap(), 0);
if (!ret) if (!ret)
{
num_v4_gateways = count_v4_gateways(index, routeTable);
ret = v6addressesFromIndex(index, &v6addrs, &num_v6addrs); ret = v6addressesFromIndex(index, &v6addrs, &num_v6addrs);
}
} }
} }
else else
...@@ -929,7 +933,7 @@ ULONG WINAPI GetAdaptersAddresses(ULONG family, ULONG flags, PVOID reserved, ...@@ -929,7 +933,7 @@ ULONG WINAPI GetAdaptersAddresses(ULONG family, ULONG flags, PVOID reserved,
for (i = 0; i < table->numIndexes; i++) for (i = 0; i < table->numIndexes; i++)
{ {
size = 0; size = 0;
if ((ret = adapterAddressesFromIndex(family, table->indexes[i], NULL, &size))) if ((ret = adapterAddressesFromIndex(family, flags, table->indexes[i], NULL, &size)))
{ {
HeapFree(GetProcessHeap(), 0, table); HeapFree(GetProcessHeap(), 0, table);
return ret; return ret;
...@@ -941,7 +945,7 @@ ULONG WINAPI GetAdaptersAddresses(ULONG family, ULONG flags, PVOID reserved, ...@@ -941,7 +945,7 @@ ULONG WINAPI GetAdaptersAddresses(ULONG family, ULONG flags, PVOID reserved,
ULONG bytes_left = size = total_size; ULONG bytes_left = size = total_size;
for (i = 0; i < table->numIndexes; i++) for (i = 0; i < table->numIndexes; i++)
{ {
if ((ret = adapterAddressesFromIndex(family, table->indexes[i], aa, &size))) if ((ret = adapterAddressesFromIndex(family, flags, table->indexes[i], aa, &size)))
{ {
HeapFree(GetProcessHeap(), 0, table); HeapFree(GetProcessHeap(), 0, table);
return ret; return ret;
......
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