Author: spetreolle
Date: Mon Nov  2 23:56:46 2015
New Revision: 69791
URL: 
http://svn.reactos.org/svn/reactos?rev=69791&view=rev
Log:
[IPHLPAPI]
Fix GetAdaptersAdresses operational status.
ReactOS is now seen online.
CORE-9178 #resolve
Please retest apps with connectivity problems.
Modified:
    trunk/reactos/dll/win32/iphlpapi/CMakeLists.txt
    trunk/reactos/dll/win32/iphlpapi/address.c
    trunk/reactos/dll/win32/iphlpapi/iphlpapi_main.c
Modified: trunk/reactos/dll/win32/iphlpapi/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/iphlpapi/CMakeLi…
==============================================================================
--- trunk/reactos/dll/win32/iphlpapi/CMakeLists.txt     [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/iphlpapi/CMakeLists.txt     [iso-8859-1] Mon Nov  2 23:56:46
2015
@@ -6,6 +6,7 @@
 spec2def(iphlpapi.dll iphlpapi.spec ADD_IMPORTLIB)
+add_definitions(-DGetAdaptersAddressesV2)
 list(APPEND SOURCE
     address.c
     dhcp_reactos.c
Modified: trunk/reactos/dll/win32/iphlpapi/address.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/iphlpapi/address…
==============================================================================
--- trunk/reactos/dll/win32/iphlpapi/address.c  [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/iphlpapi/address.c  [iso-8859-1] Mon Nov  2 23:56:46 2015
@@ -9,7 +9,7 @@
 #include "iphlpapi_private.h"
 WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
-#if 1
+#ifdef GetAdaptersAddressesV2
 /* Helper for GetAdaptersAddresses:
  * Retrieves the list of network adapters from tcpip.sys */
 static
@@ -422,7 +422,11 @@
                 CurrentAA->Flags = 0; // FIXME!
                 CurrentAA->Mtu = Entry->if_mtu;
                 CurrentAA->IfType = Entry->if_type;
-                CurrentAA->OperStatus = Entry->if_operstatus;
+                if(Entry->if_operstatus >= IF_OPER_STATUS_CONNECTING)
+                    CurrentAA->OperStatus = IfOperStatusUp;
+                else
+                    CurrentAA->OperStatus = IfOperStatusDown;
+
                 /* Next items */
                 Ptr = (BYTE*)(CurrentAA + 1);
Modified: trunk/reactos/dll/win32/iphlpapi/iphlpapi_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/iphlpapi/iphlpap…
==============================================================================
--- trunk/reactos/dll/win32/iphlpapi/iphlpapi_main.c    [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/iphlpapi/iphlpapi_main.c    [iso-8859-1] Mon Nov  2 23:56:46
2015
@@ -1517,22 +1517,6 @@
        return ret;
 }
-
-/******************************************************************
- *    GetPerAdapterInfo (IPHLPAPI.@)
- *
- *
- * PARAMS
- *
- *  IfIndex [In]
- *  pPerAdapterInfo [In/Out]
- *  pOutBufLen [In/Out]
- *
- * RETURNS
- *
- *  DWORD
- *
- */
 static void CreateNameServerListEnumNamesFunc( PWCHAR Interface, PWCHAR Server, PVOID
Data)
 {
   IP_ADDR_STRING *pNext;
@@ -1563,6 +1547,21 @@
   Context->NumServers++;
 }
+/******************************************************************
+ *    GetPerAdapterInfo (IPHLPAPI.@)
+ *
+ *
+ * PARAMS
+ *
+ *  IfIndex [In]
+ *  pPerAdapterInfo [In/Out]
+ *  pOutBufLen [In/Out]
+ *
+ * RETURNS
+ *
+ *  DWORD
+ *
+ */
 DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo,
PULONG pOutBufLen)
 {
   HKEY hkey;
@@ -2294,7 +2293,7 @@
 /*
  * @implemented
  */
-#if 0
+#ifdef GetAdaptersAddressesV1
 DWORD WINAPI DECLSPEC_HOTPATCH GetAdaptersAddresses(ULONG Family,ULONG Flags,PVOID
Reserved,PIP_ADAPTER_ADDRESSES pAdapterAddresses,PULONG pOutBufLen)
 {
     InterfaceIndexTable *indexTable;
@@ -2308,7 +2307,7 @@
     if (!pOutBufLen) return ERROR_INVALID_PARAMETER;
     if (Reserved) return ERROR_INVALID_PARAMETER;
-    indexTable = getNonLoopbackInterfaceIndexTable(); //I think we want non-loopback here
+    indexTable = getInterfaceIndexTable();
     if (!indexTable)
         return ERROR_NOT_ENOUGH_MEMORY;
@@ -2345,8 +2344,8 @@
             /* We're only going to implement what's required for XP SP0 */
         }
     }
-
-    if (*pOutBufLen < requiredSize)
+    TRACE("size: %d, requiredSize: %d\n", *pOutBufLen, requiredSize);
+    if (!pAdapterAddresses || *pOutBufLen < requiredSize)
     {
         *pOutBufLen = requiredSize;
         closeTcpFile(tcpFile);
@@ -2397,16 +2396,15 @@
             currentLocation += sizeof(WCHAR);
             currentAddress->Next = (PVOID)currentLocation;
+            /* Terminate the last address correctly */
+            if(i==0)
+                currentAddress->Next = NULL;
             /* We're only going to implement what's required for XP SP0 */
             currentAddress = currentAddress->Next;
         }
     }
-
-    /* Terminate the last address correctly */
-    if (currentAddress)
-        currentAddress->Next = NULL;
     /* Now again, for real this time */
@@ -2470,7 +2468,10 @@
             currentAddress->IfType = ifInfo.if_info.ent.if_type;
             /* Operational status */
-            currentAddress->OperStatus = ifInfo.if_info.ent.if_operstatus;
+            if(ifInfo.if_info.ent.if_operstatus >= IF_OPER_STATUS_CONNECTING)
+                currentAddress->OperStatus = IfOperStatusUp;
+            else
+                currentAddress->OperStatus = IfOperStatusDown;
             /* We're only going to implement what's required for XP SP0 */