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

iphlpapi: Partially fill Ipv4 / Ipv6 metric in GetAdaptersAddresses().

parent ee069253
......@@ -993,6 +993,7 @@ static DWORD gateway_and_prefix_addresses_alloc( IP_ADAPTER_ADDRESSES *aa, ULONG
{
struct nsi_ipv4_forward_key *key4;
struct nsi_ipv6_forward_key *key6;
struct nsi_ip_forward_rw *rw;
IP_ADAPTER_GATEWAY_ADDRESS *gw, **gw_next;
IP_ADAPTER_PREFIX *prefix, **prefix_next;
DWORD err, count, i, prefix_len, key_size = (family == AF_INET) ? sizeof(*key4) : sizeof(*key6);
......@@ -1002,11 +1003,14 @@ static DWORD gateway_and_prefix_addresses_alloc( IP_ADAPTER_ADDRESSES *aa, ULONG
void *key;
err = NsiAllocateAndGetTable( 1, ip_module_id( family ), NSI_IP_FORWARD_TABLE, &key, key_size,
NULL, 0, NULL, 0, NULL, 0, &count, 0 );
(void **)&rw, sizeof(*rw), NULL, 0, NULL, 0, &count, 0 );
if (err) return err;
while (aa)
{
if (family == AF_INET) aa->Ipv4Metric = ~0u;
else aa->Ipv6Metric = ~0u;
for (gw_next = &aa->FirstGatewayAddress; *gw_next; gw_next = &(*gw_next)->Next)
;
for (prefix_next = &aa->FirstPrefix; *prefix_next; prefix_next = &(*prefix_next)->Next)
......@@ -1019,6 +1023,12 @@ static DWORD gateway_and_prefix_addresses_alloc( IP_ADAPTER_ADDRESSES *aa, ULONG
luid = (family == AF_INET) ? &key4->luid : &key6->luid;
if (luid->Value != aa->Luid.Value) continue;
if (rw[i].metric)
{
if (family == AF_INET) aa->Ipv4Metric = min( aa->Ipv4Metric, rw[i].metric );
else aa->Ipv6Metric = min( aa->Ipv6Metric, rw[i].metric );
}
if (flags & GAA_FLAG_INCLUDE_GATEWAYS)
{
memset( &sockaddr, 0, sizeof(sockaddr) );
......@@ -1103,7 +1113,7 @@ static DWORD gateway_and_prefix_addresses_alloc( IP_ADAPTER_ADDRESSES *aa, ULONG
}
err:
NsiFreeTable( key, NULL, NULL, NULL );
NsiFreeTable( key, rw, NULL, NULL );
return err;
}
......@@ -1269,11 +1279,8 @@ static DWORD adapters_addresses_alloc( ULONG family, ULONG flags, IP_ADAPTER_ADD
if (err) goto err;
}
if (flags & (GAA_FLAG_INCLUDE_GATEWAYS | GAA_FLAG_INCLUDE_PREFIX))
{
err = call_families( gateway_and_prefix_addresses_alloc, aa, family, flags );
if (err) goto err;
}
err = call_families( gateway_and_prefix_addresses_alloc, aa, family, flags );
if (err) goto err;
err = dns_info_alloc( aa, family, flags );
if (err) goto err;
......
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