Bruno Jesus : iphlpapi: Stub more IP_ADAPTER_UNICAST_ADDRESS fields in GetAdaptersAddresses.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Apr 16 07:56:27 CDT 2015
Module: wine
Branch: master
Commit: 9c20f9bca6996acc2ee1ddd4eece36123da498cb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9c20f9bca6996acc2ee1ddd4eece36123da498cb
Author: Bruno Jesus <00cpxxx at gmail.com>
Date: Thu Apr 16 01:25:44 2015 -0300
iphlpapi: Stub more IP_ADAPTER_UNICAST_ADDRESS fields in GetAdaptersAddresses.
---
dlls/iphlpapi/iphlpapi_main.c | 40 ++++++++++++++++++++++++++++++++++------
dlls/iphlpapi/tests/iphlpapi.c | 3 ---
2 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index 513cbce..3eaefab 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -784,6 +784,31 @@ static PMIB_IPFORWARDROW findIPv4Gateway(DWORD index,
return row;
}
+static void fill_unicast_addr_data(IP_ADAPTER_ADDRESSES *aa, IP_ADAPTER_UNICAST_ADDRESS *ua)
+{
+ /* Actually this information should be read somewhere from the system
+ * but it doesn't matter much for the bugs found so far.
+ * This information is required for DirectPlay8 games. */
+ if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK)
+ {
+ ua->PrefixOrigin = IpPrefixOriginDhcp;
+ ua->SuffixOrigin = IpSuffixOriginDhcp;
+ }
+ else
+ {
+ ua->PrefixOrigin = IpPrefixOriginManual;
+ ua->SuffixOrigin = IpSuffixOriginManual;
+ }
+
+ /* The address is not duplicated in the network */
+ ua->DadState = IpDadStatePreferred;
+
+ /* Some address life time values, required even for non-dhcp addresses */
+ ua->ValidLifetime = 60000;
+ ua->PreferredLifetime = 60000;
+ ua->LeaseLifetime = 60000;
+}
+
static ULONG adapterAddressesFromIndex(ULONG family, ULONG flags, IF_INDEX index,
IP_ADAPTER_ADDRESSES *aa, ULONG *size)
{
@@ -884,6 +909,13 @@ static ULONG adapterAddressesFromIndex(ULONG family, ULONG flags, IF_INDEX index
TRACE("%s: %d IPv4 addresses, %d IPv6 addresses:\n", name, num_v4addrs,
num_v6addrs);
+
+ buflen = MAX_INTERFACE_PHYSADDR;
+ getInterfacePhysicalByIndex(index, &buflen, aa->PhysicalAddress, &type);
+ aa->PhysicalAddressLength = buflen;
+ aa->IfType = typeFromMibType(type);
+ aa->ConnectionType = connectionTypeFromMibType(type);
+
if (num_v4_gateways)
{
PMIB_IPFORWARDROW adapterRow;
@@ -930,6 +962,7 @@ static ULONG adapterAddressesFromIndex(ULONG family, ULONG flags, IF_INDEX index
sa->sin_port = 0;
TRACE("IPv4 %d/%d: %s\n", i + 1, num_v4addrs,
debugstr_ipv4(&sa->sin_addr.S_un.S_addr, addr_buf));
+ fill_unicast_addr_data(aa, ua);
ptr += ua->u.s.Length + ua->Address.iSockaddrLength;
if (i < num_v4addrs - 1)
@@ -967,6 +1000,7 @@ static ULONG adapterAddressesFromIndex(ULONG family, ULONG flags, IF_INDEX index
memcpy(sa, v6addrs[i].lpSockaddr, sizeof(*sa));
TRACE("IPv6 %d/%d: %s\n", i + 1, num_v6addrs,
debugstr_ipv6(sa, addr_buf));
+ fill_unicast_addr_data(aa, ua);
ptr += ua->u.s.Length + ua->Address.iSockaddrLength;
if (i < num_v6addrs - 1)
@@ -1071,12 +1105,6 @@ static ULONG adapterAddressesFromIndex(ULONG family, ULONG flags, IF_INDEX index
}
}
- buflen = MAX_INTERFACE_PHYSADDR;
- getInterfacePhysicalByIndex(index, &buflen, aa->PhysicalAddress, &type);
- aa->PhysicalAddressLength = buflen;
- aa->IfType = typeFromMibType(type);
- aa->ConnectionType = connectionTypeFromMibType(type);
-
getInterfaceMtuByName(name, &aa->Mtu);
getInterfaceStatusByName(name, &status);
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c
index 377aadf..58fb843 100644
--- a/dlls/iphlpapi/tests/iphlpapi.c
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -1360,10 +1360,8 @@ static void test_GetAdaptersAddresses(void)
ua = aa->FirstUnicastAddress;
while (ua)
{
-todo_wine
ok(ua->PrefixOrigin != IpPrefixOriginOther,
"bad address config value %d\n", ua->PrefixOrigin);
-todo_wine
ok(ua->SuffixOrigin != IpSuffixOriginOther,
"bad address config value %d\n", ua->PrefixOrigin);
/* Address configured manually or from DHCP server? */
@@ -1375,7 +1373,6 @@ todo_wine
ok(ua->LeaseLifetime, "expected non-zero\n");
}
/* Is the address ok in the network (not duplicated)? */
-todo_wine
ok(ua->DadState != IpDadStateInvalid && ua->DadState != IpDadStateDuplicate,
"bad address duplication value %d\n", ua->DadState);
trace("\tLength: %u\n", S(U(*ua)).Length);
More information about the wine-cvs
mailing list