silence some warnings.
[reactos.git] / reactos / lib / iphlpapi / iphlpapi_main.c
index 8a93ef0..c0a2bfe 100644 (file)
@@ -18,9 +18,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
+#include "iphlpapi_private.h"
 
 #include <stdarg.h>
 #include <stdlib.h>
 # include <resolv.h>
 #endif
 
-#ifdef __REACTOS__
-# include <windows.h>
-# include <windef.h>
-# include <winbase.h>
-# include <net/miniport.h>
-# include <winsock2.h>
-# include <nspapi.h>
-# include <iptypes.h>
-# include "iphlpapiextra.h"
-# include "wine/debug.h"
-#else
-# include "windef.h"
-# include "winbase.h"
-# include "winreg.h"
-# include "debug.h"
-#endif
 
-#include <stdio.h>
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
 #include "iphlpapi.h"
 #include "ifenum.h"
 #include "ipstats.h"
-#include "iphlp_res.h"
+#include "resinfo.h"
+#include "route.h"
+#include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
 
@@ -95,11 +82,9 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  *  DWORD
  *
  */
-DWORD WINAPI AddIPAddress(IPAddr Address, IPMask IpMask, DWORD IfIndex, PULONG NTEContext, PULONG NTEInstance)
+DWORD WINAPI AddIPAddress(IPAddr Address, IPMask Netmask, DWORD IfIndex, PULONG NteContext, PULONG NteInstance)
 {
-  FIXME(":stub\n");
-  /* marking Win2K+ functions not supported */
-  return ERROR_NOT_SUPPORTED;
+    return addIPAddress( Address, Netmask, IfIndex, NteContext, NteInstance );
 }
 
 
@@ -350,10 +335,7 @@ DWORD WINAPI AllocateAndGetUdpTableFromStack(PMIB_UDPTABLE *ppUdpTable,
  */
 DWORD WINAPI CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute)
 {
-  TRACE("pRoute %p\n", pRoute);
-  /* could use SIOCADDRT, not sure I want to */
-  FIXME(":stub\n");
-  return (DWORD) 0;
+    return createIpForwardEntry( pRoute );
 }
 
 
@@ -420,9 +402,7 @@ DWORD WINAPI CreateProxyArpEntry(DWORD dwAddress, DWORD dwMask, DWORD dwIfIndex)
 DWORD WINAPI DeleteIPAddress(ULONG NTEContext)
 {
   TRACE("NTEContext %ld\n", NTEContext);
-  FIXME(":stub\n");
-  /* marking Win2K+ functions not supported */
-  return ERROR_NOT_SUPPORTED;
+  return deleteIpAddress( NTEContext );
 }
 
 
@@ -441,10 +421,7 @@ DWORD WINAPI DeleteIPAddress(ULONG NTEContext)
  */
 DWORD WINAPI DeleteIpForwardEntry(PMIB_IPFORWARDROW pRoute)
 {
-  TRACE("pRoute %p\n", pRoute);
-  /* could use SIOCDELRT, not sure I want to */
-  FIXME(":stub\n");
-  return (DWORD) 0;
+    return deleteIpForwardEntry( pRoute );
 }
 
 
@@ -636,16 +613,17 @@ DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
                 winsEnabled = TRUE;
               RegCloseKey(hKey);
             }
+
             for (ndx = 0; ndx < table->numIndexes; ndx++) {
               PIP_ADAPTER_INFO ptr = &pAdapterInfo[ndx];
               DWORD addrLen = sizeof(ptr->Address), type;
-             const char *ifname = 
-                 getInterfaceNameByIndex(table->indexes[ndx]);
+              const char *ifname = 
+                  getInterfaceNameByIndex(table->indexes[ndx]);
 
               /* on Win98 this is left empty, but whatever */
-             
+              
               strncpy(ptr->AdapterName,ifname,sizeof(ptr->AdapterName));
-             consumeInterfaceName(ifname);
+              consumeInterfaceName(ifname);
               ptr->AdapterName[MAX_ADAPTER_NAME_LENGTH] = '\0';
               getInterfacePhysicalByIndex(table->indexes[ndx], &addrLen,
                ptr->Address, &type);
@@ -847,7 +825,7 @@ DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
   if (name) {
     ret = getInterfaceEntryByIndex(pIfRow->dwIndex, pIfRow);
     if (ret == NO_ERROR)
-      ret = getInterfaceStatsByIndex(pIfRow->dwIndex, pIfRow);
+      ret = getInterfaceStatsByName(name, pIfRow);
     consumeInterfaceName(name);
   }
   else
@@ -958,8 +936,9 @@ DWORD WINAPI GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG dwOutBufLen)
   if (!dwOutBufLen)
     ret = ERROR_INVALID_PARAMETER;
   else {
-    DWORD numInterfaces = getNumInterfaces();
-    ULONG size = sizeof(IP_INTERFACE_INFO) + (numInterfaces - 1) *
+    DWORD numNonLoopbackInterfaces = getNumNonLoopbackInterfaces();
+    DPRINT("numNonLoopbackInterfaces == 0x%x\n", numNonLoopbackInterfaces);
+    ULONG size = sizeof(IP_INTERFACE_INFO) + (numNonLoopbackInterfaces) *
      sizeof(IP_ADAPTER_INDEX_MAP);
 
     if (!pIfTable || *dwOutBufLen < size) {
@@ -967,10 +946,11 @@ DWORD WINAPI GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG dwOutBufLen)
       ret = ERROR_INSUFFICIENT_BUFFER;
     }
     else {
-      InterfaceIndexTable *table = getInterfaceIndexTable();
+      InterfaceIndexTable *table = getNonLoopbackInterfaceIndexTable();
+      DPRINT("table->numIndexes == 0x%x\n", table->numIndexes);
 
       if (table) {
-        size = sizeof(IP_INTERFACE_INFO) + (table->numIndexes - 1) *
+        size = sizeof(IP_INTERFACE_INFO) + (table->numIndexes) *
          sizeof(IP_ADAPTER_INDEX_MAP);
         if (*dwOutBufLen < size) {
           *dwOutBufLen = size;
@@ -992,7 +972,7 @@ DWORD WINAPI GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG dwOutBufLen)
              walker++, assigner++)
               *assigner = *walker;
             *assigner = 0;
-           consumeInterfaceName(name);
+            consumeInterfaceName(name);
             pIfTable->NumAdapters++;
           }
           ret = NO_ERROR;
@@ -1144,7 +1124,7 @@ DWORD WINAPI GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSi
   DWORD ret;
   
   TRACE("pIpForwardTable %p, pdwSize %p, bOrder %ld\n", pIpForwardTable,
-       pdwSize, (DWORD)bOrder);
+        pdwSize, (DWORD)bOrder);
   if (!pdwSize)
     ret = ERROR_INVALID_PARAMETER;
   else {
@@ -1255,7 +1235,7 @@ DWORD WINAPI GetIpNetTable(PMIB_IPNETTABLE pIpNetTable, PULONG pdwSize, BOOL bOr
     if (!pIpNetTable || *pdwSize < size) {
       *pdwSize = size;
       ret = ERROR_INSUFFICIENT_BUFFER;
-    }
+    } 
     else {
       PMIB_IPNETTABLE table = getArpTable();
 
@@ -1355,8 +1335,6 @@ DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
   if (!resInfo) 
     return ERROR_OUTOFMEMORY;
 
-  TRACE("resInfo->riCount = %d\n", resInfo->riCount);
-
   size = sizeof(FIXED_INFO) + (resInfo->riCount > 0 ? (resInfo->riCount  - 1) *
    sizeof(IP_ADDR_STRING) : 0);
   if (!pFixedInfo || *pOutBufLen < size) {
@@ -1379,9 +1357,11 @@ DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
 
     for (i = 0, ptr = &pFixedInfo->DnsServerList; i < resInfo->riCount && ptr;
      i++, ptr = ptr->Next) {
-       toIPAddressString
-           (((PSOCKADDR_IN)&resInfo->riAddressList[i])->sin_addr.s_addr,
-            ptr->IpAddress.String);
+        struct sockaddr_in *addr_v4 = 
+            (struct sockaddr_in *)&resInfo->riAddressList[i];
+        toIPAddressString
+            (addr_v4->sin_addr.s_addr,
+             ptr->IpAddress.String);
       if (i == resInfo->riCount - 1)
         ptr->Next = NULL;
       else if (i == 0)
@@ -1916,12 +1896,7 @@ DWORD WINAPI SetIfEntry(PMIB_IFROW pIfRow)
  */
 DWORD WINAPI SetIpForwardEntry(PMIB_IPFORWARDROW pRoute)
 {
-  TRACE("pRoute %p\n", pRoute);
-  /* this is to add a route entry, how's it distinguishable from
-     CreateIpForwardEntry?
-     could use SIOCADDRT, not sure I want to */
-  FIXME(":stub\n");
-  return (DWORD) 0;
+    return setIpForwardEntry( pRoute );
 }
 
 
@@ -2039,9 +2014,9 @@ DWORD WINAPI UnenableRouter(OVERLAPPED * pOverlapped, LPDWORD lpdwEnableCount)
 /*
  * @unimplemented
  */
-DWORD STDCALL GetIpErrorString(IP_STATUS ErrorCode,PWCHAR Buffer,PDWORD Size)
+DWORD WINAPI GetIpErrorString(IP_STATUS ErrorCode,PWCHAR Buffer,PDWORD Size)
 {
-    UNIMPLEMENTED
+    FIXME(":stub\n");
     return 0L;
 }
 
@@ -2049,54 +2024,55 @@ DWORD STDCALL GetIpErrorString(IP_STATUS ErrorCode,PWCHAR Buffer,PDWORD Size)
 /*
  * @unimplemented
  */
-PIP_ADAPTER_ORDER_MAP STDCALL GetAdapterOrderMap(VOID)
+PIP_ADAPTER_ORDER_MAP WINAPI GetAdapterOrderMap(VOID)
 {
-    UNIMPLEMENTED
+    FIXME(":stub\n");
     return 0L;
 }
 
 /*
  * @unimplemented
  */
-DWORD STDCALL GetAdaptersAddresses(ULONG Family,DWORD Flags,PVOID Reserved,PIP_ADAPTER_ADDRESSES pAdapterAddresses,PULONG pOutBufLen)
+DWORD WINAPI GetAdaptersAddresses(ULONG Family,DWORD Flags,PVOID Reserved,PIP_ADAPTER_ADDRESSES pAdapterAddresses,PULONG pOutBufLen)
 {
-    UNIMPLEMENTED
+    FIXME(":stub\n");
     return 0L;
 }
 
 /*
  * @unimplemented
  */
-BOOL STDCALL CancelIPChangeNotify(LPOVERLAPPED notifyOverlapped)
+BOOL WINAPI CancelIPChangeNotify(LPOVERLAPPED notifyOverlapped)
 {
-    UNIMPLEMENTED
+    FIXME(":stub\n");
     return 0L;
 }
 
 /*
  * @unimplemented
  */
-DWORD STDCALL GetBestInterfaceEx(struct sockaddr *pDestAddr,PDWORD pdwBestIfIndex)
+DWORD WINAPI GetBestInterfaceEx(struct sockaddr *pDestAddr,PDWORD pdwBestIfIndex)
 {
-    UNIMPLEMENTED
+    FIXME(":stub\n");
     return 0L;
 }
 
 /*
  * @unimplemented
  */
-DWORD STDCALL NhpAllocateAndGetInterfaceInfoFromStack(IP_INTERFACE_NAME_INFO **ppTable,PDWORD pdwCount,BOOL bOrder,HANDLE hHeap,DWORD dwFlags)
+DWORD WINAPI NhpAllocateAndGetInterfaceInfoFromStack(IP_INTERFACE_NAME_INFO **ppTable,PDWORD pdwCount,BOOL bOrder,HANDLE hHeap,DWORD dwFlags)
 {
-    UNIMPLEMENTED
+    FIXME(":stub\n");
     return 0L;
 }
 
 /*
  * @unimplemented
  */
-DWORD STDCALL GetIcmpStatisticsEx(PMIB_ICMP_EX pStats,DWORD dwFamily)
+DWORD WINAPI GetIcmpStatisticsEx(PMIB_ICMP_EX pStats,DWORD dwFamily)
 {
-    UNIMPLEMENTED
+    FIXME(":stub\n");
     return 0L;
 }
 
+