CVS: winex/dlls/iphlpapi ifenum.c, 1.4, 1.5 ifenum.h, 1.1.2.1, 1.3 iphlpapi.spec, 1.4, 1.5 iphlpapi_main.c, 1.8, 1.9 ipstats.c, 1.3, 1.4 ipstats.h, 1.1.2.1, 1.3 Makefile.in, 1.4, 1.5

[email protected]
Newsgroups gmane.comp.emulators.winex.cvs
Message-ID <[email protected]>
Subject: winex/dlls/iphlpapi ifenum.c,1.4,1.5 ifenum.h,1.1.2.1,1.3 iphlpapi.spec,1.4,1.5 iphlpapi_main.c,1.8,1.9 ipstats.c,1.3,1.4 ipstats.h,1.1.2.1,1.3 Makefile.in,1.4,1.5Update of /var/lib/cvsd/cvsroot/winex/dlls/iphlpapi
In directory agravaine:/tmp/cvs-serv13642/dlls/iphlpapi

Modified Files:
	ifenum.c ifenum.h iphlpapi.spec iphlpapi_main.c ipstats.c 
	ipstats.h Makefile.in 
Log Message:

- refresh our iphlpapi from WineHQ's, updating the license accordingly
- implement SIO_ROUTING_INTERFACE_QUERY



Index: ifenum.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/iphlpapi/ifenum.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ifenum.c	28 Mar 2007 18:36:48 -0000	1.4
+++ ifenum.c	30 Mar 2007 20:11:02 -0000	1.5
@@ -1,41 +1,24 @@
-/* Copyright (C) 2003 Juan Lang
+/* Copyright (C) 2003,2006 Juan Lang
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
[...980 lines suppressed...]
+        ret = ERROR_OUTOFMEMORY;
+      HeapFree(GetProcessHeap(), 0, ifc.ifc_buf);
+    }
+  }
+  return ret;
+}
+
 char *toIPAddressString(unsigned int addr, char string[16])
 {
   if (string) {
@@ -893,8 +788,7 @@
 
     iAddr.s_addr = addr;
     /* extra-anal, just to make auditors happy */
-    strncpy(string, inet_ntoa(iAddr), 16);
-    string[16] = '\0';
+    lstrcpynA(string, inet_ntoa(iAddr), 16);
   }
   return string;
 }

Index: ifenum.h
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/iphlpapi/ifenum.h,v
retrieving revision 1.1.2.1
retrieving revision 1.3
diff -u -d -r1.1.2.1 -r1.3
--- ifenum.h	21 Jan 2005 19:17:34 -0000	1.1.2.1
+++ ifenum.h	30 Mar 2007 20:11:02 -0000	1.3
@@ -1,11 +1,23 @@
 /* ifenum.h
- * Copyright (C) 2003 Juan Lang
+ * Copyright (C) 2003,2006 Juan Lang
  *
- * This module implements functions shared by DLLs that need to enumerate
- * network interfaces and addresses.  It's meant to hide some problematic
- * defines like socket(), as well as provide only one file
- * that needs to be ported to implement these functions on different platforms,
- * since the Windows API provides multiple ways to get at this info.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ * This module implements network interface and address enumeration.  It's
+ * meant to hide some problematic defines like socket(), and make iphlpapi
+ * more portable.
  *
  * Like Windows, it uses a numeric index to identify an interface uniquely.
  * As implemented, an interface represents a UNIX network interface, virtual
@@ -13,10 +25,7 @@
  * only supports IPv4.)
  * The indexes returned are not guaranteed to be contiguous, so don't call
  * getNumInterfaces() and assume the values [0,getNumInterfaces() - 1] will be
- * valid indexes; use getInterfaceIndexTable() instead.  Non-loopback
- * interfaces have lower index values than loopback interfaces, in order to
- * make the indexes somewhat reusable as Netbios LANA numbers.  See ifenum.c
- * for more detail on this.
+ * valid indexes; use getInterfaceIndexTable() instead.
  *
  * See also the companion file, ipstats.h, for functions related to getting
  * statistics.
@@ -24,7 +33,10 @@
 #ifndef WINE_IFENUM_H_
 #define WINE_IFENUM_H_
 
+#include <stdarg.h>
+
 #include "windef.h"
+#include "winbase.h"
 #include "iprtrmib.h"
 
 #define MAX_INTERFACE_PHYSADDR    8
@@ -33,17 +45,14 @@
 DWORD getNumInterfaces(void);
 DWORD getNumNonLoopbackInterfaces(void);
 
-/* A table of interface indexes, see get*InterfaceTable().  Ignore numAllocated,
- * it's used during the creation of the table.
- */
+/* A table of interface indexes, see get*InterfaceTable(). */
 typedef struct _InterfaceIndexTable {
   DWORD numIndexes;
-  DWORD numAllocated;
   DWORD indexes[1];
 } InterfaceIndexTable;
 
 /* Returns a table with all known interface indexes, or NULL if one could not
- * be allocated.  free() the returned table.
+ * be allocated.  HeapFree() the returned table.
  */
 InterfaceIndexTable *getInterfaceIndexTable(void);
 
@@ -53,10 +62,10 @@
 /* ByName/ByIndex versions of various getter functions. */
 
 /* can be used as quick check to see if you've got a valid index, returns NULL
- * if not.  The buffer's only valid till the next call, so copy it right away
- * if you care.
+ * if not.  Overwrites your buffer, which should be at least of size
+ * MAX_ADAPTER_NAME.
  */
-const char *getInterfaceNameByIndex(DWORD index);
+char *getInterfaceNameByIndex(DWORD index, char *name);
 
 /* Fills index with the index of name, if found.  Returns
  * ERROR_INVALID_PARAMETER if name or index is NULL, ERROR_INVALID_DATA if name
@@ -64,16 +73,6 @@
  */
 DWORD getInterfaceIndexByName(const char *name, PDWORD index);
 
-/* This bunch returns IP addresses, and INADDR_ANY or INADDR_NONE if not found,
- * appropriately depending on the f/n.
- */
-DWORD getInterfaceIPAddrByName(const char *name);
-DWORD getInterfaceIPAddrByIndex(DWORD index);
-DWORD getInterfaceMaskByName(const char *name);
-DWORD getInterfaceMaskByIndex(DWORD index);
-DWORD getInterfaceBCastAddrByName(const char *name);
-DWORD getInterfaceBCastAddrByIndex(DWORD index);
-
 /* Gets a few physical charactersistics of a device:  MAC addr len, MAC addr,
  * and type as one of the MIB_IF_TYPEs.
  * len's in-out: on in, needs to say how many bytes are available in addr,
@@ -92,14 +91,6 @@
 DWORD getInterfacePhysicalByIndex(DWORD index, PDWORD len, PBYTE addr,
  PDWORD type);
 
-/* Get the operational status as a (MIB_)IF_OPER_STATUS type.
- */
-DWORD getInterfaceStatusByName(const char *name, PDWORD status);
-DWORD getInterfaceStatusByIndex(DWORD index, PDWORD status);
-
-DWORD getInterfaceMtuByName(const char *name, PDWORD mtu);
-DWORD getInterfaceMtuByIndex(DWORD index, PDWORD mtu);
-
 /* Fills in the MIB_IFROW by name/index.  Doesn't fill in interface statistics,
  * see ipstats.h for that.
  * Returns ERROR_INVALID_PARAMETER if name or entry is NULL, ERROR_INVALID_DATA
@@ -108,6 +99,15 @@
 DWORD getInterfaceEntryByName(const char *name, PMIB_IFROW entry);
 DWORD getInterfaceEntryByIndex(DWORD index, PMIB_IFROW entry);
 
+DWORD getNumIPAddresses(void);
+
+/* Gets the configured IP addresses for the system, and sets *ppIpAddrTable to
+ * a table of them allocated from heap, or NULL if out of memory.  Returns
+ * NO_ERROR on success, something else on failure.  Note there may be more than
+ * one IP address may exist per interface.
+ */
+DWORD getIPAddrTable(PMIB_IPADDRTABLE *ppIpAddrTable, HANDLE heap, DWORD flags);
+
 /* Converts the network-order bytes in addr to a printable string.  Returns
  * string.
  */

Index: iphlpapi.spec
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/iphlpapi/iphlpapi.spec,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- iphlpapi.spec	6 Nov 2006 13:07:46 -0000	1.4
+++ iphlpapi.spec	30 Mar 2007 20:11:02 -0000	1.5
@@ -1,66 +1,66 @@
-name	iphlpapi
-type	win32
-file	iphlpapi.dll
+name   iphlpapi
+type   win32
+file   iphlpapi.dll
 
 import kernel32.dll
 import ntdll.dll
 
 
-@ stdcall AddIPAddress( long long long ptr ptr ) AddIPAddress
+@ stdcall AddIPAddress( long long long ptr ptr )
 @ stub AllocateAndGetArpEntTableFromStack
-@ stub AllocateAndGetIfTableFromStack
-@ stub AllocateAndGetIpAddrTableFromStack
-@ stub AllocateAndGetIpForwardTableFromStack
-@ stub AllocateAndGetIpNetTableFromStack
-@ stub AllocateAndGetTcpTableFromStack
-@ stub AllocateAndGetUdpTableFromStack
-@ stdcall CreateIpForwardEntry( ptr ) CreateIpForwardEntry
-@ stdcall CreateIpNetEntry( ptr ) CreateIpNetEntry
-@ stdcall CreateProxyArpEntry( long long long ) CreateProxyArpEntry
-@ stdcall DeleteIPAddress( long ) DeleteIPAddress
-@ stdcall DeleteIpForwardEntry( ptr ) DeleteIpForwardEntry
-@ stdcall DeleteIpNetEntry( ptr ) DeleteIpNetEntry
-@ stdcall DeleteProxyArpEntry( long long long ) DeleteProxyArpEntry
-@ stdcall EnableRouter( ptr ptr ) EnableRouter
-@ stdcall FlushIpNetTable( long ) FlushIpNetTable
+@ stdcall AllocateAndGetIfTableFromStack( ptr long long long )
+@ stdcall AllocateAndGetIpAddrTableFromStack( ptr long long long )
+@ stdcall AllocateAndGetIpForwardTableFromStack( ptr long long long )
+@ stdcall AllocateAndGetIpNetTableFromStack( ptr long long long )
+@ stdcall AllocateAndGetTcpTableFromStack( ptr long long long )
+@ stdcall AllocateAndGetUdpTableFromStack( ptr long long long )
+@ stdcall CreateIpForwardEntry( ptr )
+@ stdcall CreateIpNetEntry( ptr )
+@ stdcall CreateProxyArpEntry( long long long )
+@ stdcall DeleteIPAddress( long )
+@ stdcall DeleteIpForwardEntry( ptr )
+@ stdcall DeleteIpNetEntry( ptr )
+@ stdcall DeleteProxyArpEntry( long long long )
+@ stdcall EnableRouter( ptr ptr )
+@ stdcall FlushIpNetTable( long )
 @ stub FlushIpNetTableFromStack
-@ stdcall GetAdapterIndex( wstr ptr ) GetAdapterIndex
+@ stdcall GetAdapterIndex( wstr ptr )
 @ stub GetAdapterOrderMap
-@ stdcall GetAdaptersInfo( ptr ptr ) GetAdaptersInfo
-@ stdcall GetBestInterface( long ptr ) GetBestInterface
+@ stdcall GetAdaptersInfo( ptr ptr )
+@ stdcall GetBestInterface( long ptr )
 @ stub GetBestInterfaceFromStack
-@ stdcall GetBestRoute( long long long ) GetBestRoute
+@ stdcall GetBestRoute( long long long )
 @ stub GetBestRouteFromStack
-@ stdcall GetFriendlyIfIndex( long ) GetFriendlyIfIndex
-@ stdcall GetIcmpStatistics( ptr ) GetIcmpStatistics
+@ stdcall GetFriendlyIfIndex( long )
+@ stdcall GetIcmpStatistics( ptr )
 @ stub GetIcmpStatsFromStack
-@ stdcall GetIfEntry( ptr ) GetIfEntry
+@ stdcall GetIfEntry( ptr )
 @ stub GetIfEntryFromStack
-@ stdcall GetIfTable( ptr ptr long ) GetIfTable
+@ stdcall GetIfTable( ptr ptr long )
 @ stub GetIfTableFromStack
 @ stub GetIgmpList
-@ stdcall GetInterfaceInfo( ptr ptr ) GetInterfaceInfo
-@ stdcall GetIpAddrTable( ptr ptr long ) GetIpAddrTable
+@ stdcall GetInterfaceInfo( ptr ptr )
+@ stdcall GetIpAddrTable( ptr ptr long )
 @ stub GetIpAddrTableFromStack
-@ stdcall GetIpForwardTable( ptr ptr long ) GetIpForwardTable
+@ stdcall GetIpForwardTable( ptr ptr long )
 @ stub GetIpForwardTableFromStack
-@ stdcall GetIpNetTable( ptr ptr long ) GetIpNetTable
+@ stdcall GetIpNetTable( ptr ptr long )
 @ stub GetIpNetTableFromStack
-@ stdcall GetIpStatistics( ptr ) GetIpStatistics
+@ stdcall GetIpStatistics( ptr )
 @ stub GetIpStatsFromStack
-@ stdcall GetNetworkParams( ptr ptr ) GetNetworkParams
-@ stdcall GetNumberOfInterfaces( ptr ) GetNumberOfInterfaces
-@ stdcall GetPerAdapterInfo( long ptr ptr ) GetPerAdapterInfo
-@ stdcall GetRTTAndHopCount( long ptr long ptr ) GetRTTAndHopCount
-@ stdcall GetTcpStatistics( ptr ) GetTcpStatistics
+@ stdcall GetNetworkParams( ptr ptr )
+@ stdcall GetNumberOfInterfaces( ptr )
+@ stdcall GetPerAdapterInfo( long ptr ptr )
+@ stdcall GetRTTAndHopCount( long ptr long ptr )
+@ stdcall GetTcpStatistics( ptr )
 @ stub GetTcpStatsFromStack
-@ stdcall GetTcpTable( ptr ptr long ) GetTcpTable
+@ stdcall GetTcpTable( ptr ptr long )
 @ stub GetTcpTableFromStack
-@ stdcall GetUdpStatistics( ptr ) GetUdpStatistics
+@ stdcall GetUdpStatistics( ptr )
 @ stub GetUdpStatsFromStack
-@ stdcall GetUdpTable( ptr ptr long ) GetUdpTable
+@ stdcall GetUdpTable( ptr ptr long )
 @ stub GetUdpTableFromStack
-@ stdcall GetUniDirectionalAdapterInfo( ptr ptr ) GetUniDirectionalAdapterInfo
+@ stdcall GetUniDirectionalAdapterInfo( ptr ptr )
 @ stub InternalCreateIpForwardEntry
 @ stub InternalCreateIpNetEntry
 @ stub InternalDeleteIpForwardEntry
@@ -76,8 +76,8 @@
 @ stub InternalSetIpNetEntry
 @ stub InternalSetIpStats
 @ stub InternalSetTcpEntry
-@ stdcall IpReleaseAddress( ptr ) IpReleaseAddress
-@ stdcall IpRenewAddress( ptr ) IpRenewAddress
+@ stdcall IpReleaseAddress( ptr )
+@ stdcall IpRenewAddress( ptr )
 @ stub IsLocalAddress
 @ stub NTPTimeToNTFileTime
 @ stub NTTimeToNTPTime
@@ -85,8 +85,8 @@
 @ stub NhGetInterfaceNameFromGuid
 @ stub NhpAllocateAndGetInterfaceInfoFromStack
 @ stub NhpGetInterfaceIndexFromStack
-@ stdcall NotifyAddrChange( ptr ptr ) NotifyAddrChange
-@ stdcall NotifyRouteChange( ptr ptr ) NotifyRouteChange
+@ stdcall NotifyAddrChange( ptr ptr )
+@ stdcall NotifyRouteChange( ptr ptr )
 @ stub NotifyRouteChangeEx
 @ stub _PfAddFiltersToInterface@24
 @ stub _PfAddGlobalFilterToInterface@8
@@ -104,22 +104,22 @@
 @ stub _PfSetLogBuffer@28
 @ stub _PfTestPacket@20
 @ stub _PfUnBindInterface@4
-@ stdcall SendARP( long long ptr ptr ) SendARP
+@ stdcall SendARP( long long ptr ptr )
 @ stub SetAdapterIpAddress
 @ stub SetBlockRoutes
-@ stdcall SetIfEntry( ptr ) SetIfEntry
+@ stdcall SetIfEntry( ptr )
 @ stub SetIfEntryToStack
-@ stdcall SetIpForwardEntry( ptr ) SetIpForwardEntry
+@ stdcall SetIpForwardEntry( ptr )
 @ stub SetIpForwardEntryToStack
 @ stub SetIpMultihopRouteEntryToStack
-@ stdcall SetIpNetEntry( ptr ) SetIpNetEntry
+@ stdcall SetIpNetEntry( ptr )
 @ stub SetIpNetEntryToStack
 @ stub SetIpRouteEntryToStack
-@ stdcall SetIpStatistics( ptr ) SetIpStatistics
+@ stdcall SetIpStatistics( ptr )
 @ stub SetIpStatsToStack
-@ stdcall SetIpTTL( long ) SetIpTTL
+@ stdcall SetIpTTL( long )
 @ stub SetProxyArpEntryToStack
 @ stub SetRouteWithRef
-@ stdcall SetTcpEntry( ptr ) SetTcpEntry
+@ stdcall SetTcpEntry( ptr )
 @ stub SetTcpEntryToStack
-@ stdcall UnenableRouter( ptr ptr ) UnenableRouter
+@ stdcall UnenableRouter( ptr ptr )

Index: iphlpapi_main.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/iphlpapi/iphlpapi_main.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- iphlpapi_main.c	28 Mar 2007 18:42:07 -0000	1.8
+++ iphlpapi_main.c	30 Mar 2007 20:11:02 -0000	1.9
@@ -1,16 +1,44 @@
 /*
  * iphlpapi dll implementation
  *
- * Copyright (C) 2003 Juan Lang
+ * Copyright (C) 2003,2006 Juan Lang
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
[...2307 lines suppressed...]
  * RETURNS
+ *  Success: NO_ERROR
+ *  Failure: error code from winerror.h
  *
- *  DWORD
- *
+ * FIXME
+ *  Stub, returns ERROR_NOT_SUPPORTED.
  */
 DWORD WINAPI UnenableRouter(OVERLAPPED * pOverlapped, LPDWORD lpdwEnableCount)
 {
-  FIXME(":stub\n");
+  FIXME("(pOverlapped %p, lpdwEnableCount %p): stub\n", pOverlapped,
+   lpdwEnableCount);
   /* could echo "0" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
      could map EACCESS to ERROR_ACCESS_DENIED, I suppose
-     marking Win2K+ functions not supported */
+   */
   return ERROR_NOT_SUPPORTED;
 }

Index: ipstats.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/iphlpapi/ipstats.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ipstats.c	27 Mar 2007 22:09:32 -0000	1.3
+++ ipstats.c	30 Mar 2007 20:11:02 -0000	1.4
@@ -1,36 +1,76 @@
-/* Copyright (C) 2003 Juan Lang
+/* Copyright (C) 2003,2006 Juan Lang
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  *
  * This file implements statistics getting using the /proc filesystem exported
  * by Linux, and maybe other OSes.
  */
 
 #include "config.h"
+#include "wine/port.h"
 
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
+#include <sys/types.h>
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
-
-#if HAVE_NET_IF_H
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#ifdef HAVE_NET_IF_H
 #include <net/if.h>
 #endif
-
-#if HAVE_NETINET_TCP_H
+#ifdef HAVE_NET_ROUTE_H
+#include <net/route.h>
+#endif
+#ifdef HAVE_NET_IF_ARP_H
+#include <net/if_arp.h>
+#endif
+#ifdef HAVE_NETINET_TCP_H
 #include <netinet/tcp.h>
 #endif
-
-#if HAVE_NETINET_TCP_FSM_H
+#ifdef HAVE_NETINET_TCP_FSM_H
 #include <netinet/tcp_fsm.h>
 #endif
 
+#include "windef.h"
 #include "winbase.h"
 #include "iprtrmib.h"
 #include "ifenum.h"
 #include "ipstats.h"
 
+#ifdef linux
+#define TCPS_ESTABLISHED  1
+#define TCPS_SYN_SENT     2
+#define TCPS_SYN_RECEIVED 3
+#define TCPS_FIN_WAIT_1   4
+#define TCPS_FIN_WAIT_2   5
+#define TCPS_TIME_WAIT    6
+#define TCPS_CLOSED       7
+#define TCPS_CLOSE_WAIT   8
+#define TCPS_LAST_ACK     9
+#define TCPS_LISTEN      10
+#define TCPS_CLOSING     11
+#endif
+
 DWORD getInterfaceStatsByName(const char *name, PMIB_IFROW entry)
 {
   FILE *fp;
@@ -126,7 +166,7 @@
   /* get most of these stats from /proc/net/snmp, no error if can't */
   fp = fopen("/proc/net/snmp", "r");
   if (fp) {
-    const char hdr[] = "Icmp:";
+    static const char hdr[] = "Icmp:";
     char buf[512] = { 0 }, *ptr;
 
     do {
@@ -256,7 +296,7 @@
   /* get most of these stats from /proc/net/snmp, no error if can't */
   fp = fopen("/proc/net/snmp", "r");
   if (fp) {
-    const char hdr[] = "Ip:";
+    static const char hdr[] = "Ip:";
     char buf[512] = { 0 }, *ptr;
 
     do {
@@ -365,7 +405,7 @@
   /* get from /proc/net/snmp, no error if can't */
   fp = fopen("/proc/net/snmp", "r");
   if (fp) {
-    const char hdr[] = "Tcp:";
+    static const char hdr[] = "Tcp:";
     char buf[512] = { 0 }, *ptr;
 
 
@@ -455,7 +495,7 @@
   /* get from /proc/net/snmp, no error if can't */
   fp = fopen("/proc/net/snmp", "r");
   if (fp) {
-    const char hdr[] = "Udp:";
+    static const char hdr[] = "Udp:";
     char buf[512] = { 0 }, *ptr;
 
 
@@ -524,70 +564,101 @@
   return getNumWithOneHeader("/proc/net/route");
 }
 
-RouteTable *getRouteTable(void)
+DWORD getRouteTable(PMIB_IPFORWARDTABLE *ppIpForwardTable, HANDLE heap,
+ DWORD flags)
 {
-  DWORD numRoutes = getNumRoutes();
-  RouteTable *ret;
+  DWORD ret;
 
-  ret = (RouteTable *)calloc(1, sizeof(RouteTable) +
-   (numRoutes - 1) * sizeof(RouteEntry));
-  if (ret) {
-    FILE *fp;
+  if (!ppIpForwardTable)
+    ret = ERROR_INVALID_PARAMETER;
+  else {
+    DWORD numRoutes = getNumRoutes();
+    PMIB_IPFORWARDTABLE table = HeapAlloc(heap, flags,
+     sizeof(MIB_IPFORWARDTABLE) + (numRoutes - 1) * sizeof(MIB_IPFORWARDROW));
 
-    /* get from /proc/net/route, no error if can't */
-    fp = fopen("/proc/net/route", "r");
-    if (fp) {
-      char buf[512] = { 0 }, *ptr;
+    if (table) {
+      FILE *fp;
 
-      /* skip header line */
-      ptr = fgets(buf, sizeof(buf), fp);
-      while (ptr && ret->numRoutes < numRoutes) {
+      ret = NO_ERROR;
+      *ppIpForwardTable = table;
+      table->dwNumEntries = 0;
+      /* get from /proc/net/route, no error if can't */
+      fp = fopen("/proc/net/route", "r");
+      if (fp) {
+        char buf[512] = { 0 }, *ptr;
+
+        /* skip header line */
         ptr = fgets(buf, sizeof(buf), fp);
-        if (ptr) {
-          DWORD index;
+        while (ptr && table->dwNumEntries < numRoutes) {
+          memset(&table->table[table->dwNumEntries], 0,
+           sizeof(MIB_IPFORWARDROW));
+          ptr = fgets(buf, sizeof(buf), fp);
+          if (ptr) {
+            DWORD index;
 
-          while (!isspace(*ptr))
+            while (!isspace(*ptr))
+              ptr++;
+            *ptr = '\0';
             ptr++;
-          *ptr = '\0';
-          ptr++;
-          if (getInterfaceIndexByName(buf, &index) == NO_ERROR) {
-            char *endPtr;
+            if (getInterfaceIndexByName(buf, &index) == NO_ERROR) {
+              char *endPtr;
 
-            ret->routes[ret->numRoutes].ifIndex = index;
-            if (*ptr) {
-              ret->routes[ret->numRoutes].dest = strtoul(ptr, &endPtr, 16);
-              ptr = endPtr;
-            }
-            if (ptr && *ptr) {
-              ret->routes[ret->numRoutes].gateway = strtoul(ptr, &endPtr, 16);
-              ptr = endPtr;
-            }
-            if (ptr && *ptr) {
-              strtoul(ptr, &endPtr, 16); /* flags, skip */
-              ptr = endPtr;
-            }
-            if (ptr && *ptr) {
-              strtoul(ptr, &endPtr, 16); /* refcount, skip */
-              ptr = endPtr;
-            }
-            if (ptr && *ptr) {
-              strtoul(ptr, &endPtr, 16); /* use, skip */
-              ptr = endPtr;
-            }
-            if (ptr && *ptr) {
-              ret->routes[ret->numRoutes].metric = strtoul(ptr, &endPtr, 16);
-              ptr = endPtr;
-            }
-            if (ptr && *ptr) {
-              ret->routes[ret->numRoutes].mask = strtoul(ptr, &endPtr, 16);
-              ptr = endPtr;
+              table->table[table->dwNumEntries].dwForwardIfIndex = index;
+              if (*ptr) {
+                table->table[table->dwNumEntries].dwForwardDest =
+                 strtoul(ptr, &endPtr, 16);
+                ptr = endPtr;
+              }
+              if (ptr && *ptr) {
+                table->table[table->dwNumEntries].dwForwardNextHop =
+                 strtoul(ptr, &endPtr, 16);
+                ptr = endPtr;
+              }
+              if (ptr && *ptr) {
+                DWORD flags = strtoul(ptr, &endPtr, 16);
+
+                if (!(flags & RTF_UP))
+                  table->table[table->dwNumEntries].dwForwardType =
+                   MIB_IPROUTE_TYPE_INVALID;
+                else if (flags & RTF_GATEWAY)
+                  table->table[table->dwNumEntries].dwForwardType =
+                   MIB_IPROUTE_TYPE_INDIRECT;
+                else
+                  table->table[table->dwNumEntries].dwForwardType =
+                   MIB_IPROUTE_TYPE_DIRECT;
+                ptr = endPtr;
+              }
+              if (ptr && *ptr) {
+                strtoul(ptr, &endPtr, 16); /* refcount, skip */
+                ptr = endPtr;
+              }
+              if (ptr && *ptr) {
+                strtoul(ptr, &endPtr, 16); /* use, skip */
+                ptr = endPtr;
+              }
+              if (ptr && *ptr) {
+                table->table[table->dwNumEntries].dwForwardMetric1 =
+                 strtoul(ptr, &endPtr, 16);
+                ptr = endPtr;
+              }
+              if (ptr && *ptr) {
+                table->table[table->dwNumEntries].dwForwardMask =
+                 strtoul(ptr, &endPtr, 16);
+                ptr = endPtr;
+              }
+              /* FIXME: other protos might be appropriate, e.g. the default
+               * route is typically set with MIB_IPPROTO_NETMGMT instead */
+              table->table[table->dwNumEntries].dwForwardProto =
+               MIB_IPPROTO_LOCAL;
+              table->dwNumEntries++;
             }
-            ret->numRoutes++;
           }
         }
+        fclose(fp);
       }
-      fclose(fp);
     }
+    else
+      ret = ERROR_OUTOFMEMORY;
   }
   return ret;
 }
@@ -597,64 +668,90 @@
   return getNumWithOneHeader("/proc/net/arp");
 }
 
-PMIB_IPNETTABLE getArpTable(void)
+DWORD getArpTable(PMIB_IPNETTABLE *ppIpNetTable, HANDLE heap, DWORD flags)
 {
-  DWORD numEntries = getNumArpEntries();
-  PMIB_IPNETTABLE ret;
+  DWORD ret;
 
-  ret = (PMIB_IPNETTABLE)calloc(1, sizeof(MIB_IPNETTABLE) +
-   (numEntries - 1) * sizeof(MIB_IPNETROW));
-  if (ret) {
-    FILE *fp;
+  if (!ppIpNetTable)
+    ret = ERROR_INVALID_PARAMETER;
+  else {
+    DWORD numEntries = getNumArpEntries();
+    PMIB_IPNETTABLE table = HeapAlloc(heap, flags,
+     sizeof(MIB_IPNETTABLE) + (numEntries - 1) * sizeof(MIB_IPNETROW));
 
-    /* get from /proc/net/arp, no error if can't */
-    fp = fopen("/proc/net/arp", "r");
-    if (fp) {
-      char buf[512] = { 0 }, *ptr;
+    if (table) {
+      FILE *fp;
 
-      /* skip header line */
-      ptr = fgets(buf, sizeof(buf), fp);
-      while (ptr && ret->dwNumEntries < numEntries) {
+      ret = NO_ERROR;
+      *ppIpNetTable = table;
+      table->dwNumEntries = 0;
+      /* get from /proc/net/arp, no error if can't */
+      fp = fopen("/proc/net/arp", "r");
+      if (fp) {
+        char buf[512] = { 0 }, *ptr;
+
+        /* skip header line */
         ptr = fgets(buf, sizeof(buf), fp);
-        if (ptr) {
-          char *endPtr;
+        while (ptr && table->dwNumEntries < numEntries) {
+          ptr = fgets(buf, sizeof(buf), fp);
+          if (ptr) {
+            char *endPtr;
 
-          if (ptr && *ptr) {
-            ret->table[ret->dwNumEntries].dwAddr = strtoul(ptr, &endPtr, 16);
-            ptr = endPtr;
-          }
-          if (ptr && *ptr) {
-            strtoul(ptr, &endPtr, 16); /* hw type (skip) */
-            ptr = endPtr;
-          }
-          if (ptr && *ptr) {
-            strtoul(ptr, &endPtr, 16); /* flags (skip) */
-            ptr = endPtr;
-          }
-          /* FIXME:  maybe this comes from flags? */
-          ret->table[ret->dwNumEntries].dwType = MIB_IPNET_TYPE_DYNAMIC;
-          while (ptr && *ptr && isspace(*ptr))
-            ptr++;
-          while (ptr && *ptr && !isspace(*ptr)) {
-            DWORD byte = strtoul(ptr, &endPtr, 16);
+            memset(&table->table[table->dwNumEntries], 0, sizeof(MIB_IPNETROW));
+            table->table[table->dwNumEntries].dwAddr = inet_addr(ptr);
+            while (ptr && *ptr && !isspace(*ptr))
+              ptr++;
 
-            if (endPtr && *endPtr) {
-              endPtr++;
-              ret->table[ret->dwNumEntries].bPhysAddr[
-               ret->table[ret->dwNumEntries].dwPhysAddrLen++] = byte & 0x0ff;
+            if (ptr && *ptr) {
+              strtoul(ptr, &endPtr, 16); /* hw type (skip) */
+              ptr = endPtr;
             }
-            ptr = endPtr;
-          }
-          if (ptr && *ptr) {
-            strtoul(ptr, &endPtr, 16); /* mask (skip) */
-            ptr = endPtr;
+            if (ptr && *ptr) {
+              DWORD flags = strtoul(ptr, &endPtr, 16);
+
+#ifdef ATF_COM
+              if (flags & ATF_COM)
+                table->table[table->dwNumEntries].dwType =
+                 MIB_IPNET_TYPE_DYNAMIC;
+              else
+#endif
+#ifdef ATF_PERM
+              if (flags & ATF_PERM)
+                table->table[table->dwNumEntries].dwType =
+                 MIB_IPNET_TYPE_STATIC;
+              else
+#endif
+                table->table[table->dwNumEntries].dwType = MIB_IPNET_TYPE_OTHER;
+
+              ptr = endPtr;
+            }
+            while (ptr && *ptr && isspace(*ptr))
+              ptr++;
+            while (ptr && *ptr && !isspace(*ptr)) {
+              DWORD byte = strtoul(ptr, &endPtr, 16);
+
+              if (endPtr && *endPtr) {
+                endPtr++;
+                table->table[table->dwNumEntries].bPhysAddr[
+                 table->table[table->dwNumEntries].dwPhysAddrLen++] =
+                 byte & 0x0ff;
+              }
+              ptr = endPtr;
+            }
+            if (ptr && *ptr) {
+              strtoul(ptr, &endPtr, 16); /* mask (skip) */
+              ptr = endPtr;
+            }
+            getInterfaceIndexByName(ptr,
+             &table->table[table->dwNumEntries].dwIndex);
+            table->dwNumEntries++;
           }
-          getInterfaceIndexByName(ptr, &ret->table[ret->dwNumEntries].dwIndex);
-          ret->dwNumEntries++;
         }
+        fclose(fp);
       }
-      fclose(fp);
     }
+    else
+      ret = ERROR_OUTOFMEMORY;
   }
   return ret;
 }
@@ -664,49 +761,60 @@
   return getNumWithOneHeader("/proc/net/udp");
 }
 
-PMIB_UDPTABLE getUdpTable(void)
+DWORD getUdpTable(PMIB_UDPTABLE *ppUdpTable, HANDLE heap, DWORD flags)
 {
-  DWORD numEntries = getNumUdpEntries();
-  PMIB_UDPTABLE ret;
+  DWORD ret;
 
-  ret = (PMIB_UDPTABLE)calloc(1, sizeof(MIB_UDPTABLE) +
-   (numEntries - 1) * sizeof(MIB_UDPROW));
-  if (ret) {
-    FILE *fp;
+  if (!ppUdpTable)
+    ret = ERROR_INVALID_PARAMETER;
+  else {
+    DWORD numEntries = getNumUdpEntries();
+    PMIB_UDPTABLE table = HeapAlloc(heap, flags,
+     sizeof(MIB_UDPTABLE) + (numEntries - 1) * sizeof(MIB_UDPROW));
 
-    /* get from /proc/net/udp, no error if can't */
-    fp = fopen("/proc/net/udp", "r");
-    if (fp) {
-      char buf[512] = { 0 }, *ptr;
+    if (table) {
+      FILE *fp;
 
-      /* skip header line */
-      ptr = fgets(buf, sizeof(buf), fp);
-      while (ptr && ret->dwNumEntries < numEntries) {
+      ret = NO_ERROR;
+      *ppUdpTable = table;
+      table->dwNumEntries = 0;
+      /* get from /proc/net/udp, no error if can't */
+      fp = fopen("/proc/net/udp", "r");
+      if (fp) {
+        char buf[512] = { 0 }, *ptr;
+
+        /* skip header line */
         ptr = fgets(buf, sizeof(buf), fp);
-        if (ptr) {
-          char *endPtr;
+        while (ptr && table->dwNumEntries < numEntries) {
+          memset(&table->table[table->dwNumEntries], 0, sizeof(MIB_UDPROW));
+          ptr = fgets(buf, sizeof(buf), fp);
+          if (ptr) {
+            char *endPtr;
 
-          if (ptr && *ptr) {
-            strtoul(ptr, &endPtr, 16); /* skip */
-            ptr = endPtr;
-          }
-          if (ptr && *ptr) {
-            ptr++;
-            ret->table[ret->dwNumEntries].dwLocalAddr = strtoul(ptr, &endPtr,
-             16);
-            ptr = endPtr;
-          }
-          if (ptr && *ptr) {
-            ptr++;
-            ret->table[ret->dwNumEntries].dwLocalPort = strtoul(ptr, &endPtr,
-             16);
-            ptr = endPtr;
+            if (ptr && *ptr) {
+              strtoul(ptr, &endPtr, 16); /* skip */
+              ptr = endPtr;
+            }
+            if (ptr && *ptr) {
+              ptr++;
+              table->table[table->dwNumEntries].dwLocalAddr = strtoul(ptr,
+               &endPtr, 16);
+              ptr = endPtr;
+            }
+            if (ptr && *ptr) {
+              ptr++;
+              table->table[table->dwNumEntries].dwLocalPort = strtoul(ptr,
+               &endPtr, 16);
+              ptr = endPtr;
+            }
+            table->dwNumEntries++;
           }
-          ret->dwNumEntries++;
         }
+        fclose(fp);
       }
-      fclose(fp);
     }
+    else
+      ret = ERROR_OUTOFMEMORY;
   }
   return ret;
 }
@@ -716,109 +824,122 @@
   return getNumWithOneHeader("/proc/net/tcp");
 }
 
-PMIB_TCPTABLE getTcpTable(void)
+DWORD getTcpTable(PMIB_TCPTABLE *ppTcpTable, HANDLE heap, DWORD flags)
 {
-  DWORD numEntries = getNumTcpEntries();
-  PMIB_TCPTABLE ret = NULL;
+  DWORD ret;
 
-#ifndef __APPLE__
-/* The proc filesystem is not available on the Mac */
+  if (!ppTcpTable)
+    ret = ERROR_INVALID_PARAMETER;
+  else {
+    DWORD numEntries = getNumTcpEntries();
+    PMIB_TCPTABLE table = HeapAlloc(heap, flags,
+     sizeof(MIB_TCPTABLE) + (numEntries - 1) * sizeof(MIB_TCPROW));
 
-  ret = (PMIB_TCPTABLE)calloc(1, sizeof(MIB_TCPTABLE) +
-   (numEntries - 1) * sizeof(MIB_TCPROW));
-  if (ret) {
-    FILE *fp;
+    if (table) {
+      FILE *fp;
 
-    /* get from /proc/net/tcp, no error if can't */
-    fp = fopen("/proc/net/tcp", "r");
-    if (fp) {
-      char buf[512] = { 0 }, *ptr;
+      ret = NO_ERROR;
+      *ppTcpTable = table;
+      table->dwNumEntries = 0;
+      /* get from /proc/net/tcp, no error if can't */
+      fp = fopen("/proc/net/tcp", "r");
+      if (fp) {
+        char buf[512] = { 0 }, *ptr;
 
-      /* skip header line */
-      ptr = fgets(buf, sizeof(buf), fp);
-      while (ptr && ret->dwNumEntries < numEntries) {
+        /* skip header line */
         ptr = fgets(buf, sizeof(buf), fp);
-        if (ptr) {
-          char *endPtr;
-
-          while (ptr && *ptr && *ptr != ':')
-            ptr++;
-          if (ptr && *ptr)
-            ptr++;
-          if (ptr && *ptr) {
-            ret->table[ret->dwNumEntries].dwLocalAddr = strtoul(ptr, &endPtr,
-             16);
-            ptr = endPtr;
-          }
-          if (ptr && *ptr) {
-            ptr++;
-            ret->table[ret->dwNumEntries].dwLocalPort = strtoul(ptr, &endPtr,
-             16);
-            ptr = endPtr;
-          }
-          if (ptr && *ptr) {
-            ret->table[ret->dwNumEntries].dwRemoteAddr = strtoul(ptr, &endPtr,
-             16);
-            ptr = endPtr;
-          }
-          if (ptr && *ptr) {
-            ptr++;
-            ret->table[ret->dwNumEntries].dwRemotePort = strtoul(ptr, &endPtr,
-             16);
-            ptr = endPtr;
-          }
-          if (ptr && *ptr) {
-            DWORD state = strtoul(ptr, &endPtr, 16);
+        while (ptr && table->dwNumEntries < numEntries) {
+          memset(&table->table[table->dwNumEntries], 0, sizeof(MIB_TCPROW));
+          ptr = fgets(buf, sizeof(buf), fp);
+          if (ptr) {
+            char *endPtr;
 
-#if HAVE_NETINET_TCP_H
-            switch (state)
-            {
-              case TCP_ESTABLISHED:
-                ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_ESTAB;
-                break;
-              case TCP_SYN_SENT:
-                ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_SYN_SENT;
-                break;
-              case TCP_SYN_RECV:
-                ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_SYN_RCVD;
-                break;
-              case TCP_FIN_WAIT1:
-                ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_FIN_WAIT1;
-                break;
-              case TCP_FIN_WAIT2:
-                ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_FIN_WAIT2;
-                break;
-              case TCP_TIME_WAIT:
-                ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_TIME_WAIT;
-                break;
-              case TCP_CLOSE:
-                ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_CLOSED;
-                break;
-              case TCP_CLOSE_WAIT:
-                ret->table[ret->dwNumEntries].dwState =
-                 MIB_TCP_STATE_CLOSE_WAIT;
-                break;
-              case TCP_LAST_ACK:
-                ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_LAST_ACK;
-                break;
-              case TCP_LISTEN:
-                ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_LISTEN;
-                break;
-              case TCP_CLOSING:
-                ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_CLOSING;
-                break;
+            while (ptr && *ptr && *ptr != ':')
+              ptr++;
+            if (ptr && *ptr)
+              ptr++;
+            if (ptr && *ptr) {
+              table->table[table->dwNumEntries].dwLocalAddr = strtoul(ptr,
+               &endPtr, 16);
+              ptr = endPtr;
+            }
+            if (ptr && *ptr) {
+              ptr++;
+              table->table[table->dwNumEntries].dwLocalPort = strtoul(ptr,
+               &endPtr, 16);
+              ptr = endPtr;
+            }
+            if (ptr && *ptr) {
+              table->table[table->dwNumEntries].dwRemoteAddr = strtoul(ptr,
+               &endPtr, 16);
+              ptr = endPtr;
+            }
+            if (ptr && *ptr) {
+              ptr++;
+              table->table[table->dwNumEntries].dwRemotePort = strtoul(ptr,
+               &endPtr, 16);
+              ptr = endPtr;
+            }
+            if (ptr && *ptr) {
+              DWORD state = strtoul(ptr, &endPtr, 16);
 
+              switch (state)
+              {
+                case TCPS_ESTABLISHED:
+                  table->table[table->dwNumEntries].dwState =
+                   MIB_TCP_STATE_ESTAB;
+                  break;
+                case TCPS_SYN_SENT:
+                  table->table[table->dwNumEntries].dwState =
+                   MIB_TCP_STATE_SYN_SENT;
+                  break;
+                case TCPS_SYN_RECEIVED:
+                  table->table[table->dwNumEntries].dwState =
+                   MIB_TCP_STATE_SYN_RCVD;
+                  break;
+                case TCPS_FIN_WAIT_1:
+                  table->table[table->dwNumEntries].dwState =
+                   MIB_TCP_STATE_FIN_WAIT1;
+                  break;
+                case TCPS_FIN_WAIT_2:
+                  table->table[table->dwNumEntries].dwState =
+                   MIB_TCP_STATE_FIN_WAIT2;
+                  break;
+                case TCPS_TIME_WAIT:
+                  table->table[table->dwNumEntries].dwState =
+                   MIB_TCP_STATE_TIME_WAIT;
+                  break;
+                case TCPS_CLOSED:
+                  table->table[table->dwNumEntries].dwState =
+                   MIB_TCP_STATE_CLOSED;
+                  break;
+                case TCPS_CLOSE_WAIT:
+                  table->table[table->dwNumEntries].dwState =
+                   MIB_TCP_STATE_CLOSE_WAIT;
+                  break;
+                case TCPS_LAST_ACK:
+                  table->table[table->dwNumEntries].dwState =
+                   MIB_TCP_STATE_LAST_ACK;
+                  break;
+                case TCPS_LISTEN:
+                  table->table[table->dwNumEntries].dwState =
+                   MIB_TCP_STATE_LISTEN;
+                  break;
+                case TCPS_CLOSING:
+                  table->table[table->dwNumEntries].dwState =
+                   MIB_TCP_STATE_CLOSING;
+                  break;
+              }
+              ptr = endPtr;
             }
-#endif
-            ptr = endPtr;
+            table->dwNumEntries++;
           }
-          ret->dwNumEntries++;
         }
+        fclose(fp);
       }
-      fclose(fp);
     }
+    else
+      ret = ERROR_OUTOFMEMORY;
   }
-#endif /* __APPLE__ */
-
   return ret;
 }

Index: ipstats.h
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/iphlpapi/ipstats.h,v
retrieving revision 1.1.2.1
retrieving revision 1.3
diff -u -d -r1.1.2.1 -r1.3
--- ipstats.h	21 Jan 2005 19:17:34 -0000	1.1.2.1
+++ ipstats.h	30 Mar 2007 20:11:02 -0000	1.3
@@ -1,14 +1,30 @@
 /* ipstats.h
- * Copyright (C) 2003 Juan Lang
+ * Copyright (C) 2003,2006 Juan Lang
  *
- * This module implements functions shared by DLLs that need to get network-
- * related statistics.  It's meant to hide some platform-specificisms, and
- * share code that was previously duplicated.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ * This module implements functions that get network-related statistics.
+ * It's meant to hide some platform-specificisms.
  */
 #ifndef WINE_IPSTATS_H_
 #define WINE_IPSTATS_H_
 
+#include <stdarg.h>
+
 #include "windef.h"
+#include "winbase.h"
 #include "iprtrmib.h"
 
 /* Fills in entry's interface stats, using name to find them.
@@ -36,53 +52,37 @@
  */
 DWORD getUDPStats(MIB_UDPSTATS *stats);
 
-/* Route table functions */
-
+/* Returns the number of entries in the route table. */
 DWORD getNumRoutes(void);
 
-/* Minimalist route entry, only has the fields I can actually fill in.  How
- * these map to the different windows route data structures is up to you.
- */
-typedef struct _RouteEntry {
-  DWORD dest;
-  DWORD mask;
-  DWORD gateway;
-  DWORD ifIndex;
-  DWORD metric;
-} RouteEntry;
-
-typedef struct _RouteTable {
-  DWORD numRoutes;
-  RouteEntry routes[1];
-} RouteTable;
-
-/* Allocates and returns to you the route table, or NULL if it can't allocate
- * enough memory.  free() the returned table.
+/* Allocates the route table from heap and returns it to you in
+ * *ppIpForwardTable.  Returns NO_ERROR on success, something else on failure.
  */
-RouteTable *getRouteTable(void);
+DWORD getRouteTable(PMIB_IPFORWARDTABLE *ppIpForwardTable, HANDLE heap,
+ DWORD flags);
 
 /* Returns the number of entries in the arp table. */
 DWORD getNumArpEntries(void);
 
-/* Allocates and returns to you the arp table, or NULL if it can't allocate
- * enough memory.  free() the returned table.
+/* Allocates the arp table from heap and returns it to you in *ppIpNetTable.
+ * Returns NO_ERROR on success, something else on failure.
  */
-PMIB_IPNETTABLE getArpTable(void);
+DWORD getArpTable(PMIB_IPNETTABLE *ppIpNetTable, HANDLE heap, DWORD flags);
 
 /* Returns the number of entries in the UDP state table. */
 DWORD getNumUdpEntries(void);
 
-/* Allocates and returns to you the UDP state table, or NULL if it can't
- * allocate enough memory.  free() the returned table.
+/* Allocates the UDP state table from heap and returns it to you in *ppUdpTable.
+ * Returns NO_ERROR on success, something else on failure.
  */
-PMIB_UDPTABLE getUdpTable(void);
+DWORD getUdpTable(PMIB_UDPTABLE *ppUdpTable, HANDLE heap, DWORD flags);
 
 /* Returns the number of entries in the TCP state table. */
 DWORD getNumTcpEntries(void);
 
-/* Allocates and returns to you the TCP state table, or NULL if it can't
- * allocate enough memory.  free() the returned table.
+/* Allocates the TCP state table from heap and returns it to you in *ppTcpTable.
+ * Returns NO_ERROR on success, something else on failure.
  */
-PMIB_TCPTABLE getTcpTable(void);
+DWORD getTcpTable(PMIB_TCPTABLE *ppTcpTable, HANDLE heap, DWORD flags);
 
 #endif /* ndef WINE_IPSTATS_H_ */

Index: Makefile.in
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/iphlpapi/Makefile.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile.in	28 Mar 2007 18:33:47 -0000	1.4
+++ Makefile.in	30 Mar 2007 20:11:02 -0000	1.5
@@ -3,8 +3,8 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = iphlpapi
+IMPORTS   = advapi32 kernel32
 EXTRALIBS = $(LIBRESOLV)
-
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
 
@@ -14,5 +14,3 @@
 	ipstats.c
 
 @MAKE_DLL_RULES@
-
-### Dependencies:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.