Skip to contentSkip to conversation

syshead: cleanups

PATCH New Alon Bar-Lev 1 participant 17 messages May 12, 2012

lore
Share & tools
lore
#0 lore raw

cover syshead: cleanups

Hello,

This series include some minor syshead.h cleanups, most moved to build system.

I think these are simple enough to go into 2.3, the risk is minimal but I don't care if we truly freeze 2.3 and switch master to 2.4 and apply this for 2.4.

This series is on top of my build branch[1], about to merge it too.

[1] https://github.com/alonbl/openvpn/compare/build

Alon Bar-Lev (16):
cleanup: syshead: remove OS_SPECIFIC_DIRSEP in favor of autoconf
PATH_SEPARATOR
cleanup: syshead: move O_BINARY detection to autoconf
cleanup: syshead: remove useless WIN32_0_1
cleanup: syshead: remove useless constant USE_64_BIT_COUNTERS
cleanup: syshead: move apple specific CPPFLAGS out of syshead
clenaup: syshead: remove wait macros wrappers
cleanup: syshead: move likely,unlikely to basic.h
cleanup: syshead: move sleep,random,syshead.h emulation to compat
cleanup: syshead: rename S_ERROR->S_ERRORS to avoid conflict with
stropts.h
cleanup: syshead: split pedantic into pedantic, lint
cleanup: syshead: move _P1003_1B_VISIBLE to autoconf
cleanup: syshead: move socket compat into basic.h
cleanup: syshead: remove dead code
cleanup: syshead: move SOL_IP emulation to autoconf
cleanup: syshead: move ENABLE_MEMSTATS to autoconf
clenaup: syshead: reworder/cleanup includes

 configure.ac             |   63 ++++++++++-
 src/compat/compat.h      |    6 +
 src/openvpn/basic.h      |   40 +++++++
 src/openvpn/common.h     |   13 +--
 src/openvpn/error.h      |    2 +-
 src/openvpn/misc.c       |    6 +-
 src/openvpn/openvpn.c    |    2 +-
 src/openvpn/ssl.c        |   16 ++--
 src/openvpn/ssl_common.h |    2 +-
 src/openvpn/ssl_verify.c |    2 +-
 src/openvpn/syshead.h    |  270 ++++++----------------------------------------
 src/openvpn/tun.c        |   12 --
 12 files changed, 157 insertions(+), 277 deletions(-)
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 1/16 cleanup: syshead: remove OS_SPECIFIC_DIRSEP in favor of autoconf PATH_SEPARATOR

---
 src/openvpn/misc.c       |    6 +-----
 src/openvpn/ssl_verify.c |    2 +-
 src/openvpn/syshead.h    |    9 ---------
 3 files changed, 2 insertions(+), 15 deletions(-)
src/openvpn/misc.c +1 -5
index 2ded9bf..3dd2aa2 100644
@@ -1070,13 +1070,9 @@ gen_path (const char *directory, const char *filename, struct gc_arena *gc)
     {
       const size_t outsize = strlen(safe_filename) + (directory ? strlen (directory) : 0) + 16;
       struct buffer out = alloc_buf_gc (outsize, gc);
-      char dirsep[2];
-
-      dirsep[0] = OS_SPECIFIC_DIRSEP;
-      dirsep[1] = '\0';
 
       if (directory)
-	buf_printf (&out, "%s%s", directory, dirsep);
+	buf_printf (&out, "%s%c", directory, PATH_SEPARATOR);
       buf_printf (&out, "%s", safe_filename);
 
       return BSTR (&out);
src/openvpn/ssl_verify.c +1 -1
index 30fb05d..ad46c13 100644
@@ -545,7 +545,7 @@ verify_check_crl_dir(const char *crl_dir, openvpn_x509_cert_t *cert)
 
   char *serial = x509_get_serial(cert, &gc);
 
-  if (!openvpn_snprintf(fn, sizeof(fn), "%s%c%s", crl_dir, OS_SPECIFIC_DIRSEP, serial))
+  if (!openvpn_snprintf(fn, sizeof(fn), "%s%c%s", crl_dir, PATH_SEPARATOR, serial))
     {
       msg (D_HANDSHAKE, "VERIFY CRL: filename overflow");
       goto cleanup;
src/openvpn/syshead.h +0 -9
index 3337764..c5dbac6 100644
@@ -446,15 +446,6 @@
 #endif
 
 /*
- * Directory separation char
- */
-#ifdef WIN32
-#define OS_SPECIFIC_DIRSEP '\\'
-#else
-#define OS_SPECIFIC_DIRSEP '/'
-#endif
-
-/*
  * Define a boolean value based
  * on Win32 status.
  */
Signature · 1 line
1.7.3.4
#2 lore raw

PATCH 2/16 cleanup: syshead: move O_BINARY detection to autoconf

In reply to Alon Bar-Lev
---
 configure.ac          |   11 +++++++++++
 src/openvpn/syshead.h |    7 -------
 2 files changed, 11 insertions(+), 7 deletions(-)
configure.ac +11 -0
index 4592727..6f6a1f4 100644
@@ -519,6 +519,17 @@ AC_CHECK_DECLS(
 	]]
 )
 
+AC_CHECK_DECLS(
+	[O_BINARY],
+	,
+	[AC_DEFINE([O_BINARY], [0], [O_BINARY replacement])],
+	[[
+		#ifdef HAVE_FCNTL_H
+		#include <fcntl.h>
+		#endif
+	]]
+)
+
 AC_FUNC_FORK
 
 AC_CHECK_FUNCS([ \
src/openvpn/syshead.h +0 -7
index c5dbac6..91a23d3 100644
@@ -439,13 +439,6 @@
 #endif
 
 /*
- * Does this OS draw a distinction between binary and ascii files?
- */
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-/*
  * Define a boolean value based
  * on Win32 status.
  */
Signature · 1 line
1.7.3.4
#3 lore raw

PATCH 3/16 cleanup: syshead: remove useless WIN32_0_1

In reply to Alon Bar-Lev
---
 src/openvpn/syshead.h |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)
src/openvpn/syshead.h +0 -10
index 91a23d3..99a6674 100644
@@ -439,16 +439,6 @@
 #endif
 
 /*
- * Define a boolean value based
- * on Win32 status.
- */
-#ifdef WIN32
-#define WIN32_0_1 1
-#else
-#define WIN32_0_1 0
-#endif
-
-/*
  * Our socket descriptor type.
  */
 #ifdef WIN32
Signature · 1 line
1.7.3.4
#4 lore raw

PATCH 4/16 cleanup: syshead: remove useless constant USE_64_BIT_COUNTERS

In reply to Alon Bar-Lev
---
 src/openvpn/common.h  |   13 ++++---------
 src/openvpn/syshead.h |    5 -----
 2 files changed, 4 insertions(+), 14 deletions(-)
src/openvpn/common.h +4 -9
index de2d609..845faee 100644
@@ -28,16 +28,11 @@
 /*
  * Statistics counters and associated printf formats.
  */
-#ifdef USE_64_BIT_COUNTERS
-  typedef unsigned long long int counter_type;
-# ifdef WIN32
-#  define counter_format  "%I64u"
-# else
-#  define counter_format  "%llu"
-# endif
+typedef unsigned long long int counter_type;
+#ifdef WIN32
+# define counter_format  "%I64u"
 #else
-  typedef unsigned int counter_type;
-# define counter_format   "%u"
+# define counter_format  "%llu"
 #endif
 
 /*
src/openvpn/syshead.h +0 -5
index 99a6674..ccd78af 100644
@@ -456,11 +456,6 @@ socket_defined (const socket_descriptor_t sd)
 }
 
 /*
- * Should statistics counters be 64 bits?
- */
-#define USE_64_BIT_COUNTERS
-
-/*
  * Should we enable the use of execve() for calling subprocesses,
  * instead of system()?
  */
Signature · 1 line
1.7.3.4
#5 lore raw

PATCH 5/16 cleanup: syshead: move apple specific CPPFLAGS out of syshead

In reply to Alon Bar-Lev
---
 configure.ac          |   18 ++++++++++++++++++
 src/openvpn/syshead.h |    6 ------
 2 files changed, 18 insertions(+), 6 deletions(-)
configure.ac +18 -0
index 6f6a1f4..9fcd7fe 100644
@@ -357,6 +357,24 @@ AC_TYPE_UINT16_T
 AC_TYPE_UINT32_T
 AC_TYPE_UINT64_T
 AC_TYPE_SIGNAL
+
+AC_MSG_CHECKING([Apple specific settings])
+AC_EGREP_CPP(
+	[true],
+	[
+#if defined(__APPLE__)
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1070
+true
+#endif
+#endif
+	],
+	[
+		AC_MSG_RESULT([required])
+		CPPFLAGS="${CPPFLAGS} -D__APPLE_USE_RFC_3542=1"
+	],
+	[AC_MSG_RESULT([not required])]
+)
+
 AX_CPP_VARARG_MACRO_ISO
 AX_CPP_VARARG_MACRO_GCC
 AX_TYPE_SOCKLEN_T
src/openvpn/syshead.h +0 -6
index ccd78af..c5bf4a8 100644
@@ -45,12 +45,6 @@
 #define srandom srand
 #endif
 
-#if defined(__APPLE__)
-#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1070
-#define __APPLE_USE_RFC_3542  1
-#endif
-#endif
-
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
Signature · 1 line
1.7.3.4
#6 lore raw

PATCH 6/16 clenaup: syshead: remove wait macros wrappers

In reply to Alon Bar-Lev

WEXITSTATUS is POSIX, show me the platform that does not support this.

WIFEXITED is not used at Windows code.

---
 src/openvpn/syshead.h |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)
src/openvpn/syshead.h +0 -9
index c5bf4a8..3e64936 100644
@@ -53,15 +53,6 @@
 # include <sys/wait.h>
 #endif
 
-#ifndef WIN32
-#ifndef WEXITSTATUS
-# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
-#endif
-#ifndef WIFEXITED
-# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
-#endif
-#endif
-
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
Signature · 1 line
1.7.3.4
#7 lore raw

PATCH 7/16 cleanup: syshead: move likely, unlikely to basic.h

In reply to Alon Bar-Lev
---
 src/openvpn/basic.h   |    9 +++++++++
 src/openvpn/syshead.h |    9 ---------
 2 files changed, 9 insertions(+), 9 deletions(-)
src/openvpn/basic.h +9 -0
index 298cf10..f2d5041 100644
@@ -35,4 +35,13 @@
 
 #define IPV4_NETMASK_HOST 0xffffffffU
 
+/* branch prediction hints */
+#if defined(__GNUC__)
+# define likely(x)       __builtin_expect((x),1)
+# define unlikely(x)     __builtin_expect((x),0)
+#else
+# define likely(x)      (x)
+# define unlikely(x)    (x)
+#endif
+
 #endif
src/openvpn/syshead.h +0 -9
index 3e64936..98d6023 100644
@@ -28,15 +28,6 @@
 #include "compat.h"
 #include "compat-stdbool.h"
 
-/* branch prediction hints */
-#if defined(__GNUC__)
-# define likely(x)       __builtin_expect((x),1)
-# define unlikely(x)     __builtin_expect((x),0)
-#else
-# define likely(x)      (x)
-# define unlikely(x)    (x)
-#endif
-
 #ifdef WIN32
 #include <windows.h>
 #include <winsock2.h>
Signature · 1 line
1.7.3.4
#8 lore raw

PATCH 8/16 cleanup: syshead: move sleep, random, syshead.h emulation to compat

In reply to Alon Bar-Lev
---
 src/compat/compat.h   |    6 ++++++
 src/openvpn/syshead.h |    3 ---
 2 files changed, 6 insertions(+), 3 deletions(-)
src/compat/compat.h +6 -0
index 021573e..7d91277 100644
@@ -41,6 +41,12 @@
 #include <sys/socket.h>
 #endif
 
+#ifdef WIN32
+#define sleep(x) Sleep((x)*1000)
+#define random rand
+#define srandom srand
+#endif
+
 #ifndef HAVE_DIRNAME
 char * dirname(char *str);
 #endif /* HAVE_DIRNAME */
src/openvpn/syshead.h +0 -3
index 98d6023..db39625 100644
@@ -31,9 +31,6 @@
 #ifdef WIN32
 #include <windows.h>
 #include <winsock2.h>
-#define sleep(x) Sleep((x)*1000)
-#define random rand
-#define srandom srand
 #endif
 
 #ifdef HAVE_SYS_TYPES_H
Signature · 1 line
1.7.3.4
#9 lore raw

PATCH 9/16 cleanup: syshead: rename S_ERROR->S_ERRORS to avoid conflict with stropts.h

In reply to Alon Bar-Lev
---
 src/openvpn/ssl.c        |   16 ++++++++--------
 src/openvpn/ssl_common.h |    2 +-
 src/openvpn/syshead.h    |    1 -
 3 files changed, 9 insertions(+), 10 deletions(-)
src/openvpn/ssl.c +8 -8
index 19512c0..3178ff4 100644
@@ -429,8 +429,8 @@ state_name (int state)
       return "S_ACTIVE";
     case S_NORMAL_OP:
       return "S_NORMAL_OP";
-    case S_ERROR:
-      return "S_ERROR";
+    case S_ERRORS:
+      return "S_ERRORS";
     default:
       return "S_???";
     }
@@ -858,7 +858,7 @@ lame_duck_must_die (const struct tls_session* session, interval_t *wakeup)
       else
 	return true;
     }
-  else if (lame->state == S_ERROR)
+  else if (lame->state == S_ERRORS)
     return true;
   else
     return false;
@@ -2020,7 +2020,7 @@ tls_process (struct tls_multi *multi,
 
   /* Make sure we were initialized and that we're not in an error state */
   ASSERT (ks->state != S_UNDEF);
-  ASSERT (ks->state != S_ERROR);
+  ASSERT (ks->state != S_ERRORS);
   ASSERT (session_id_defined (&session->session_id));
 
   /* Should we trigger a soft reset? -- new key, keeps old key for a while */
@@ -2386,7 +2386,7 @@ tls_process (struct tls_multi *multi,
 
 error:
   tls_clear_error();
-  ks->state = S_ERROR;
+  ks->state = S_ERRORS;
   msg (D_TLS_ERRORS, "TLS Error: TLS handshake failed");
   INCR_ERROR;
   gc_free (&gc);
@@ -2468,7 +2468,7 @@ tls_multi_process (struct tls_multi *multi,
 	   * (2) Reinitialize the session.
 	   * (3) Increment soft error count
 	   */
-	  if (ks->state == S_ERROR)
+	  if (ks->state == S_ERRORS)
 	    {
 	      ++multi->n_soft_errors;
 
@@ -2513,7 +2513,7 @@ tls_multi_process (struct tls_multi *multi,
   }
 
   /*
-   * A hard error means that TM_ACTIVE hit an S_ERROR state and that no
+   * A hard error means that TM_ACTIVE hit an S_ERRORS state and that no
    * other key state objects are S_ACTIVE or higher.
    */
   if (error)
@@ -2921,7 +2921,7 @@ tls_pre_decrypt (struct tls_multi *multi,
 
 	    /* Make sure we were initialized and that we're not in an error state */
 	    ASSERT (ks->state != S_UNDEF);
-	    ASSERT (ks->state != S_ERROR);
+	    ASSERT (ks->state != S_ERRORS);
 	    ASSERT (session_id_defined (&session->session_id));
 
 	    /* Let our caller know we processed a control channel packet */
src/openvpn/ssl_common.h +1 -1
index f3f43be..6cf8552 100644
@@ -75,7 +75,7 @@
  *
  * @{
  */
-#define S_ERROR          -1     /**< Error state.  */
+#define S_ERRORS         -1     /**< Error state.  */
 #define S_UNDEF           0     /**< Undefined state, used after a \c
                                  *   key_state is cleaned up. */
 #define S_INITIAL         1     /**< Initial \c key_state state after
src/openvpn/syshead.h +0 -1
index db39625..d095799 100644
@@ -221,7 +221,6 @@
 
 #ifdef HAVE_STROPTS_H
 #include <stropts.h>
-#undef S_ERROR
 #endif
 
 #ifdef HAVE_NET_IF_TUN_H
Signature · 1 line
1.7.3.4
#10 lore raw

PATCH 10/16 cleanup: syshead: split pedantic into pedantic, lint

In reply to Alon Bar-Lev

Split pedantic into two: pedantic (compiler only), lint (functional). Move settings into basic.h.
Remove lint stub in tun.c.

---
 configure.ac          |   18 ++++++++++++++++--
 src/openvpn/basic.h   |   14 ++++++++++++++
 src/openvpn/error.h   |    2 +-
 src/openvpn/openvpn.c |    2 +-
 src/openvpn/syshead.h |   16 ----------------
 src/openvpn/tun.c     |   12 ------------
 6 files changed, 32 insertions(+), 32 deletions(-)
configure.ac +16 -2
index 9fcd7fe..078e46f 100644
@@ -202,12 +202,19 @@ AC_ARG_ENABLE(
 
 AC_ARG_ENABLE(
 	[pedantic],
-	[AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings, will not generate a working executable (debugging option) @<:@default=no@:>@])],
+	[AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings (debugging option) @<:@default=no@:>@])],
 	,
 	[enable_pedantic="no"]
 )
 
 AC_ARG_ENABLE(
+	[lint],
+	[AS_HELP_STRING([--enable-lint], [enable lint friendly build, will not generate a working executable (debugging option) @<:@default=no@:>@])],
+	,
+	[enable_lint="no"]
+)
+
+AC_ARG_ENABLE(
 	[strict-options],
 	[AS_HELP_STRING([--enable-strict-options], [enable strict options check between peers (debugging option) @<:@default=no@:>@])],
 	,
@@ -342,7 +349,6 @@ ifdef(
 )
 
 AC_C_CONST
-AC_C_INLINE
 AC_C_VOLATILE
 AC_TYPE_OFF_T
 AC_TYPE_PID_T
@@ -938,6 +944,10 @@ if test "${enable_pkcs11}" = "yes"; then
 	AC_DEFINE([ENABLE_PKCS11], [1], [Enable PKCS11])
 fi
 
+if test "${enable_lint}" = "yes"; then
+	enable_pedantic="yes"
+	AC_DEFINE([ENABLE_LINT], [1], [Enable lint build])
+fi
 if test "${enable_pedantic}" = "yes"; then
 	enable_strict="yes"
 	CFLAGS="${CFLAGS} -pedantic"
@@ -947,6 +957,10 @@ if test "${enable_strict}" = "yes"; then
 	CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function"
 fi
 
+# check inline after pedantic/lint CFLAGS as it may produce
+# different result
+AC_C_INLINE
+
 if test "${WIN32}" = "yes"; then
 	test -z "${MAN2HTML}" && AC_MSG_ERROR([man2html is required for win32])
 fi
src/openvpn/basic.h +14 -0
index f2d5041..9746315 100644
@@ -44,4 +44,18 @@
 # define unlikely(x)    (x)
 #endif
 
+/*
+ * Lint mode is meant to accomplish lint-style program checking,
+ * not to build a working executable.
+ */
+#ifdef ENABLE_LINT
+# undef HAVE_CPP_VARARG_MACRO_GCC
+# undef HAVE_CPP_VARARG_MACRO_ISO
+# undef EMPTY_ARRAY_SIZE
+# define EMPTY_ARRAY_SIZE 1
+# ifdef inline
+#  undef inline
+# endif
+#endif
+
 #endif
src/openvpn/error.h +1 -1
index ed8f903..fb7fad7 100644
@@ -165,7 +165,7 @@ bool dont_mute (unsigned int flags); /* check muting filter */
 #  define dmsg(flags, args...)
 # endif
 #else
-# if !PEDANTIC
+# ifndef ENABLE_LINT
 #  ifdef _MSC_VER
 #   pragma message("this compiler appears to lack vararg macros which will cause a significant degradation in efficiency")
 #  else
src/openvpn/openvpn.c +1 -1
index 75c751d..acba8e9 100644
@@ -132,7 +132,7 @@ main (int argc, char *argv[])
 {
   struct context c;
 
-#if PEDANTIC
+#ifdef ENABLE_LINT
   fprintf (stderr, "Sorry, I was built with --enable-pedantic and I am incapable of doing any real work!\n");
   return 1;
 #endif
src/openvpn/syshead.h +0 -16
index d095799..e522876 100644
@@ -335,22 +335,6 @@
 #endif
 
 /*
- * Pedantic mode is meant to accomplish lint-style program checking,
- * not to build a working executable.
- */
-#ifdef __STRICT_ANSI__
-# define PEDANTIC 1
-# undef HAVE_CPP_VARARG_MACRO_GCC
-# undef HAVE_CPP_VARARG_MACRO_ISO
-# undef EMPTY_ARRAY_SIZE
-# define EMPTY_ARRAY_SIZE 1
-# undef inline
-# define inline
-#else
-# define PEDANTIC 0
-#endif
-
-/*
  * Do we have the capability to support the --passtos option?
  */
 #if defined(IPPROTO_IP) && defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
src/openvpn/tun.c +0 -12
index 633150f..71abbf3 100644
@@ -1373,8 +1373,6 @@ close_tun_generic (struct tuntap *tt)
 #error header file linux/sockios.h required
 #endif
 
-#if !PEDANTIC
-
 void
 open_tun (const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt)
 {
@@ -1487,16 +1485,6 @@ open_tun (const char *dev, const char *dev_type, const char *dev_node, struct tu
 void
 open_tun (const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt)
 {
-  ASSERT (0);
-}
-
-#endif
-
-#else
-
-void
-open_tun (const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt)
-{
   open_tun_generic (dev, dev_type, dev_node, false, true, tt);
 }
 
Signature · 1 line
1.7.3.4
#11 lore raw

PATCH 11/16 cleanup: syshead: move _P1003_1B_VISIBLE to autoconf

In reply to Alon Bar-Lev
---
 configure.ac          |    2 +-
 src/openvpn/syshead.h |    3 ---
 2 files changed, 1 insertions(+), 4 deletions(-)
configure.ac +1 -1
index 078e46f..2c80ef4 100644
@@ -291,7 +291,7 @@ case "$host" in
 		AC_DEFINE([TARGET_DARWIN], [1], [Are we running on Mac OS X?])
 		AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["M"], [Target prefix])
 		dnl some Mac OS X tendering (we use vararg macros...)
-		CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
+		CPPFLAGS="$CPPFLAGS -no-cpp-precomp -D_P1003_1B_VISIBLE"
 		;;
 	*-mingw*)
 		AC_DEFINE([TARGET_WIN32], [1], [Are we running WIN32?])
src/openvpn/syshead.h +0 -3
index e522876..3fd955d 100644
@@ -328,9 +328,6 @@
 #endif
 
 #ifdef HAVE_SYS_MMAN_H
-#ifdef TARGET_DARWIN
-#define _P1003_1B_VISIBLE
-#endif /* TARGET_DARWIN */
 #include <sys/mman.h>
 #endif
 
Signature · 1 line
1.7.3.4
#12 lore raw

PATCH 12/16 cleanup: syshead: move socket compat into basic.h

In reply to Alon Bar-Lev

Probably not the best place, however, better than syshead.

---
 src/openvpn/basic.h   |   17 +++++++++++++++++
 src/openvpn/syshead.h |   17 -----------------
 2 files changed, 17 insertions(+), 17 deletions(-)
src/openvpn/basic.h +17 -0
index 9746315..ac325e1 100644
@@ -58,4 +58,21 @@
 # endif
 #endif
 
+/*
+ * Our socket descriptor type.
+ */
+#ifdef WIN32
+#define SOCKET_UNDEFINED (INVALID_SOCKET)
+typedef SOCKET socket_descriptor_t;
+#else
+#define SOCKET_UNDEFINED (-1)
+typedef int socket_descriptor_t;
+#endif
+
+static inline int
+socket_defined (const socket_descriptor_t sd)
+{
+  return sd != SOCKET_UNDEFINED;
+}
+
 #endif
src/openvpn/syshead.h +0 -17
index 3fd955d..657c884 100644
@@ -392,23 +392,6 @@
 #endif
 
 /*
- * Our socket descriptor type.
- */
-#ifdef WIN32
-#define SOCKET_UNDEFINED (INVALID_SOCKET)
-typedef SOCKET socket_descriptor_t;
-#else
-#define SOCKET_UNDEFINED (-1)
-typedef int socket_descriptor_t;
-#endif
-
-static inline int
-socket_defined (const socket_descriptor_t sd)
-{
-  return sd != SOCKET_UNDEFINED;
-}
-
-/*
  * Should we enable the use of execve() for calling subprocesses,
  * instead of system()?
  */
Signature · 1 line
1.7.3.4
#13 lore raw

PATCH 13/16 cleanup: syshead: remove dead code

In reply to Alon Bar-Lev
---
 src/openvpn/syshead.h |   14 --------------
 1 files changed, 0 insertions(+), 14 deletions(-)
src/openvpn/syshead.h +0 -14
index 657c884..f908752 100644
@@ -375,14 +375,6 @@
 #endif
 
 /*
- * Disable ESEC
- */
-#if 0
-#undef EXTENDED_SOCKET_ERROR_CAPABILITY
-#define EXTENDED_SOCKET_ERROR_CAPABILITY 0
-#endif
-
-/*
  * Do we have a syslog capability?
  */
 #if defined(HAVE_OPENLOG) && defined(HAVE_SYSLOG)
@@ -548,12 +540,6 @@
 #define EPOLL 0
 #endif
 
-/* Disable EPOLL */
-#if 0
-#undef EPOLL
-#define EPOLL 0
-#endif
-
 /*
  * Should we allow ca/cert/key files to be
  * included inline, in the configuration file?
Signature · 1 line
1.7.3.4
#14 lore raw

PATCH 14/16 cleanup: syshead: move SOL_IP emulation to autoconf

In reply to Alon Bar-Lev
---
 configure.ac          |   11 +++++++++++
 src/openvpn/syshead.h |    8 --------
 2 files changed, 11 insertions(+), 8 deletions(-)
configure.ac +11 -0
index 2c80ef4..193d287 100644
@@ -490,6 +490,17 @@ AC_CHECK_DECLS(
 	,
 	[[${SOCKET_INCLUDES}]]
 )
+AC_CHECK_DECLS(
+	[SOL_IP],
+	,
+	[AC_CHECK_DECLS(
+		[IPPROTO_IP],
+		[AC_DEFINE_UNQUOTED([SOL_IP], [IPPROTO_IP], [SOL_IP emulation])],
+		[AC_MSG_ERROR([cannot find SOL_IP or IPPROTO_IP])],
+		[[${SOCKET_INCLUDES}]]
+	)],
+	[[${SOCKET_INCLUDES}]]
+)
 
 dnl We emulate signals in Windows
 AC_CHECK_DECLS(
src/openvpn/syshead.h +0 -8
index f908752..c4dfd0b 100644
@@ -367,14 +367,6 @@
 #endif
 
 /*
- * Does this platform define SOL_IP
- * or only bsd-style IPPROTO_IP ?
- */
-#ifndef SOL_IP
-#define SOL_IP IPPROTO_IP
-#endif
-
-/*
  * Do we have a syslog capability?
  */
 #if defined(HAVE_OPENLOG) && defined(HAVE_SYSLOG)
Signature · 1 line
1.7.3.4
#15 lore raw

PATCH 15/16 cleanup: syshead: move ENABLE_MEMSTATS to autoconf

In reply to Alon Bar-Lev
---
 configure.ac          |    1 +
 src/openvpn/syshead.h |    7 -------
 2 files changed, 1 insertions(+), 7 deletions(-)
configure.ac +1 -0
index 193d287..cca9508 100644
@@ -270,6 +270,7 @@ case "$host" in
 	*-*-linux*)
 		AC_DEFINE([TARGET_LINUX], [1], [Are we running on Linux?])
 		AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["L"], [Target prefix])
+		AC_DEFINE([ENABLE_MEMSTATS], [1], [Enable --memstats option])
 		;;
 	*-*-solaris*)
 		AC_DEFINE([TARGET_SOLARIS], [1], [Are we running on Solaris?])
src/openvpn/syshead.h +0 -7
index c4dfd0b..d5a9af1 100644
@@ -613,11 +613,4 @@
  */
 #define ENABLE_CLIENT_NAT
 
-/*
- * Enable --memstats option
- */
-#ifdef TARGET_LINUX
-#define ENABLE_MEMSTATS
-#endif
-
 #endif
Signature · 1 line
1.7.3.4
#16 lore raw

PATCH 16/16 clenaup: syshead: reworder/cleanup includes

In reply to Alon Bar-Lev
---
 configure.ac          |    2 +-
 src/openvpn/syshead.h |  146 ++++++++++++-------------------------------------
 2 files changed, 36 insertions(+), 112 deletions(-)
configure.ac +1 -1
index cca9508..97eb5f0 100644
@@ -643,7 +643,7 @@ old_CFLAGS="${CFLAGS}"
 CFLAGS="${CFLAGS} ${TAP_CFLAGS}"
 AC_CHECK_HEADERS(
 	[ \
-		net/if_tun.h net/tun/if_tun.h \
+		net/if_tun.h net/tun/if_tun.h net/if_tap.h \
 		linux/if_tun.h \
 		tap-windows.h \
 	],
src/openvpn/syshead.h +35 -111

222 lines not on this page · raw message

Signature · 1 line
1.7.3.4