PATCH: dlls/iphlpapi/ipstats.c -- fix build breakage

Gerald Pfeifer pfeifer at dbai.tuwien.ac.at
Fri Jun 13 15:23:11 CDT 2003


On Sat, 7 Jun 2003, Juan Lang wrote:
> Good thinking.  Haven't patched yet, but I wanted to mention:  there is
> an equivalent under Solaris and the BSDs, where TCP_FIN_WAIT is replaced
> by TCPS_FIN_WAIT, TCP_SYN_SENT by TCPS_SYN_SENT and so on.

The patch below implements that; it was tested on SuSE 8.2 and FreeBSD 4.8.

Juan, when having a look off-list, correctly noticed that we could keep
the #ifdefs in the function, but for now I'd prefer to go this route
which should work on all relevant systems (and avoid making this a noop
as before on Linux, where the relevant constants are enums, not defines).

Gerald

ChangeLog:
Unbreak getTcpTable() on Linux-based systems and make it work on BSD
and Solaris as well.

Index: ipstats.c
===================================================================
RCS file: /home/wine/wine/dlls/iphlpapi/ipstats.c,v
retrieving revision 1.3
diff -u -3 -p -r1.3 ipstats.c
--- ipstats.c	15 May 2003 22:55:04 -0000	1.3
+++ ipstats.c	10 Jun 2003 23:17:18 -0000
@@ -42,6 +42,40 @@
 #include "ifenum.h"
 #include "ipstats.h"

+#if ! defined(TCPS_ESTABLISHED)  &&  TCP_ESTABLISHED >= 0
+# define TCPS_ESTABLISHED TCP_ESTABLISHED
+#endif
+#if ! defined(TCPS_SYN_SENT)  &&  TCP_SYN_SENT >= 0
+# define TCPS_SYN_SENT TCP_SYN_SENT
+#endif
+#if ! defined(TCPS_SYN_RECEIVED)  &&  TCP_SYS_RECV >= 0
+# define TCPS_SYN_RECEIVED TCP_SYN_RECV
+#endif
+#if ! defined(TCPS_FIN_WAIT_1)  &&  TCP_FIN_WAIT1 >= 0
+# define TCPS_FIN_WAIT_1 TCP_FIN_WAIT1
+#endif
+#if ! defined(TCPS_FIN_WAIT_2)  &&  TCP_FIN_WAIT2 >= 0
+# define TCPS_FIN_WAIT_2 TCP_FIN_WAIT2
+#endif
+#if ! defined(TCPS_TIME_WAIT)  &&  TCP_TIME_WAIT >= 0
+# define TCPS_TIME_WAIT TCP_TIME_WAIT
+#endif
+#if ! defined(TCPS_CLOSED)  &&  TCP_CLOSE >= 0
+# define TCPS_CLOSED TCP_CLOSE
+#endif
+#if ! defined(TCPS_CLOSE_WAIT)  &&  TCP_CLOSE_WAIT >= 0
+# define TCPS_CLOSE_WAIT TCP_CLOSE_WAIT
+#endif
+#if ! defined(TCPS_LAST_ACK)  &&  TCP_LAST_ACK >= 0
+# define TCPS_LAST_ACK TCP_LAST_ACK
+#endif
+#if ! defined(TCPS_LISTEN)  &&  TCP_LISTEN >= 0
+# define TCPS_LISTEN TCP_LISTEN
+#endif
+#if ! defined(TCPS_CLOSING)  &&  TCP_CLOSING >= 0
+# define TCPS_CLOSING TCP_CLOSING
+#endif
+
 DWORD getInterfaceStatsByName(const char *name, PMIB_IFROW entry)
 {
   FILE *fp;
@@ -778,67 +812,43 @@ PMIB_TCPTABLE getTcpTable(void)
           if (ptr && *ptr) {
             DWORD state = strtoul(ptr, &endPtr, 16);

-#if HAVE_NETINET_TCP_H
             switch (state)
             {
-#ifdef TCP_ESTABLISHED
-              case TCP_ESTABLISHED:
+              case TCPS_ESTABLISHED:
                 ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_ESTAB;
                 break;
-#endif
-#ifdef TCP_SYN_SEND
-              case TCP_SYN_SENT:
+              case TCPS_SYN_SENT:
                 ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_SYN_SENT;
                 break;
-#endif
-#ifdef TCP_SYN_RECV
-              case TCP_SYN_RECV:
+              case TCPS_SYN_RECEIVED:
                 ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_SYN_RCVD;
                 break;
-#endif
-#ifdef TCP_FIN_WAIT1
-              case TCP_FIN_WAIT1:
+              case TCPS_FIN_WAIT_1:
                 ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_FIN_WAIT1;
                 break;
-#endif
-#ifdef TCP_FIN_WAIT2
-              case TCP_FIN_WAIT2:
+              case TCPS_FIN_WAIT_2:
                 ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_FIN_WAIT2;
                 break;
-#endif
-#ifdef TCP_TIME_WAIT
-              case TCP_TIME_WAIT:
+              case TCPS_TIME_WAIT:
                 ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_TIME_WAIT;
                 break;
-#endif
-#ifdef TCP_CLOSE
-              case TCP_CLOSE:
+              case TCPS_CLOSED:
                 ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_CLOSED;
                 break;
-#endif
-#ifdef TCP_CLOSE_WAIT
-              case TCP_CLOSE_WAIT:
+              case TCPS_CLOSE_WAIT:
                 ret->table[ret->dwNumEntries].dwState =
                  MIB_TCP_STATE_CLOSE_WAIT;
                 break;
-#endif
-#ifdef TCP_LAST_ACK
-              case TCP_LAST_ACK:
+              case TCPS_LAST_ACK:
                 ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_LAST_ACK;
                 break;
-#endif
-#ifdef TCP_LISTEN
-              case TCP_LISTEN:
+              case TCPS_LISTEN:
                 ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_LISTEN;
                 break;
-#endif
-#ifdef TCP_CLOSING
-              case TCP_CLOSING:
+              case TCPS_CLOSING:
                 ret->table[ret->dwNumEntries].dwState = MIB_TCP_STATE_CLOSING;
                 break;
-#endif
             }
-#endif
             ptr = endPtr;
           }
           ret->dwNumEntries++;



More information about the wine-patches mailing list