]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Added --enable-lzo-stub configure option to build an OpenVPN client without LZO,...
authorJames Yonan <james@openvpn.net>
Thu, 10 Mar 2011 00:04:39 +0000 (00:04 +0000)
committerDavid Sommerseth <dazo@users.sourceforge.net>
Mon, 25 Apr 2011 20:12:03 +0000 (22:12 +0200)
Modified "push-peer-info" option to push IV_LZO_STUB=1 to server when
client was built with --enable-lzo-stub configure option.  This tells
the server that the client lacks LZO capabilities, so the server
should turn off LZO compression for this client via "lzo no".

Added "setenv PUSH_PEER_INFO" option having the same effect as
"push-peer-info".

Version 2.1.3j

git-svn-id: http://svn.openvpn.net/projects/branches/BETA21@7023 e7ae566f-a301-0410-adde-c780ea21d3b5

configure.ac
lzo.c
lzo.h
options.c
ssl.c
syshead.h
version.m4

index 55757053be68f34145ef2fb1a311351961ec4267..729ce40fa2a489de0ad5717d26ec354a8db9e613 100644 (file)
@@ -69,6 +69,12 @@ AC_ARG_ENABLE(lzo,
    [LZO="yes"]
 )
 
+AC_ARG_ENABLE(lzo-stub,
+   [  --enable-lzo-stub       Don't compile LZO compression support but still allow limited interoperability with LZO-enabled peers],
+   [LZO_STUB="$enableval"],
+   [LZO_STUB="no"]
+)
+
 AC_ARG_ENABLE(crypto,
    [  --disable-crypto        Disable OpenSSL crypto support],
    [CRYPTO="$enableval"],
@@ -657,7 +663,7 @@ dnl
 dnl check for LZO library
 dnl
 
-if test "$LZO" = "yes"; then
+if test "$LZO" = "yes" && test "$LZO_STUB" = "no"; then
    LZO_H=""
    AC_CHECKING([for LZO Library and Header files])
    AC_CHECK_HEADER(lzo/lzo1x.h,
@@ -687,10 +693,15 @@ if test "$LZO" = "yes"; then
    else
      AC_MSG_RESULT([LZO headers were not found])
      AC_MSG_RESULT([LZO library available from http://www.oberhumer.com/opensource/lzo/])
-     AC_MSG_ERROR([Or try ./configure --disable-lzo])
+     AC_MSG_ERROR([Or try ./configure --disable-lzo OR ./configure --enable-lzo-stub])
    fi
 fi
 
+dnl enable multi-client mode
+if test "$LZO_STUB" = "yes"; then
+   AC_DEFINE(LZO_STUB, 1, [Enable LZO stub capability])
+fi
+
 dnl
 dnl check for OpenSSL-crypto library
 dnl
diff --git a/lzo.c b/lzo.c
index 6ea0d03131fbce79cfc25c0bd521dfb1a4419994..7343051227400888bf97e7d7b1b39da67f40e65c 100644 (file)
--- a/lzo.c
+++ b/lzo.c
@@ -32,6 +32,8 @@
 
 #include "memdbg.h"
 
+#ifndef LZO_STUB
+
 static bool
 lzo_adaptive_compress_test (struct lzo_adaptive_compress *ac)
 {
@@ -79,6 +81,8 @@ lzo_adaptive_compress_data (struct lzo_adaptive_compress *ac, int n_total, int n
   ac->n_comp += n_comp;
 }
 
+#endif /* LZO_STUB */
+
 void lzo_adjust_frame_parameters (struct frame *frame)
 {
   /* Leave room for our one-byte compressed/didn't-compress prefix byte. */
@@ -94,14 +98,18 @@ lzo_compress_init (struct lzo_compress_workspace *lzowork, unsigned int flags)
 {
   CLEAR (*lzowork);
 
-  lzowork->wmem_size = LZO_WORKSPACE;
   lzowork->flags = flags;
+#ifndef LZO_STUB
+  lzowork->wmem_size = LZO_WORKSPACE;
 
   if (lzo_init () != LZO_E_OK)
     msg (M_FATAL, "Cannot initialize LZO compression library");
   lzowork->wmem = (lzo_voidp) lzo_malloc (lzowork->wmem_size);
   check_malloc_return (lzowork->wmem);
   msg (M_INFO, "LZO compression initialized");
+#else
+  msg (M_INFO, "LZO stub compression initialized");
+#endif
   lzowork->defined = true;
 }
 
@@ -111,8 +119,10 @@ lzo_compress_uninit (struct lzo_compress_workspace *lzowork)
   if (lzowork)
     {
       ASSERT (lzowork->defined);
+#ifndef LZO_STUB
       lzo_free (lzowork->wmem);
       lzowork->wmem = NULL;
+#endif
       lzowork->defined = false;
     }
 }
@@ -120,6 +130,7 @@ lzo_compress_uninit (struct lzo_compress_workspace *lzowork)
 static inline bool
 lzo_compression_enabled (struct lzo_compress_workspace *lzowork)
 {
+#ifndef LZO_STUB
   if ((lzowork->flags & (LZO_SELECTED|LZO_ON)) == (LZO_SELECTED|LZO_ON))
     {
       if (lzowork->flags & LZO_ADAPTIVE)
@@ -127,6 +138,7 @@ lzo_compression_enabled (struct lzo_compress_workspace *lzowork)
       else
        return true;
     }
+#endif
   return false;
 }
 
@@ -139,15 +151,18 @@ lzo_compress (struct buffer *buf, struct buffer work,
              struct lzo_compress_workspace *lzowork,
              const struct frame* frame)
 {
+#ifndef LZO_STUB
   lzo_uint zlen = 0;
   int err;
   bool compressed = false;
+#endif
 
   ASSERT (lzowork->defined);
 
   if (buf->len <= 0)
     return;
 
+#ifndef LZO_STUB
   /*
    * In order to attempt compression, length must be at least COMPRESS_THRESHOLD,
    * and our adaptive level must give the OK.
@@ -193,6 +208,7 @@ lzo_compress (struct buffer *buf, struct buffer work,
       *buf = work;
     }
   else
+#endif
     {
       uint8_t *header = buf_prepend (buf, 1);
       *header = NO_COMPRESS;
@@ -204,9 +220,11 @@ lzo_decompress (struct buffer *buf, struct buffer work,
                struct lzo_compress_workspace *lzowork,
                const struct frame* frame)
 {
+#ifndef LZO_STUB
   lzo_uint zlen = EXPANDED_SIZE (frame);
-  uint8_t c;           /* flag indicating whether or not our peer compressed */
   int err;
+#endif
+  uint8_t c;           /* flag indicating whether or not our peer compressed */
 
   ASSERT (lzowork->defined);
 
@@ -220,6 +238,7 @@ lzo_decompress (struct buffer *buf, struct buffer work,
 
   if (c == YES_COMPRESS)       /* packet was compressed */
     {
+#ifndef LZO_STUB
       ASSERT (buf_safe (&work, zlen));
       err = LZO_DECOMPRESS (BPTR (buf), BLEN (buf), BPTR (&work), &zlen,
                            lzowork->wmem);
@@ -238,6 +257,11 @@ lzo_decompress (struct buffer *buf, struct buffer work,
       lzowork->post_decompress += work.len;
 
       *buf = work;
+#else
+      dmsg (D_COMP_ERRORS, "LZO decompression error: LZO capability not compiled");
+      buf->len = 0;
+      return;
+#endif
     }
   else if (c == NO_COMPRESS)   /* packet was not compressed */
     {
@@ -264,10 +288,12 @@ void lzo_print_stats (const struct lzo_compress_workspace *lzo_compwork, struct
 {
   ASSERT (lzo_compwork->defined);
 
+#ifndef LZO_STUB
   status_printf (so, "pre-compress bytes," counter_format, lzo_compwork->pre_compress);
   status_printf (so, "post-compress bytes," counter_format, lzo_compwork->post_compress);
   status_printf (so, "pre-decompress bytes," counter_format, lzo_compwork->pre_decompress);
   status_printf (so, "post-decompress bytes," counter_format, lzo_compwork->post_decompress);
+#endif
 }
 
 #else
diff --git a/lzo.h b/lzo.h
index bb15753a2b834f63274834eafd8284060dc66f4c..831f204296943a408d5c19f3548ea3e2e7b32a94 100644 (file)
--- a/lzo.h
+++ b/lzo.h
@@ -27,6 +27,7 @@
 
 #ifdef USE_LZO
 
+#ifndef LZO_STUB
 #ifdef LZO_HEADER_DIR
 #include "lzo/lzoutil.h"
 #include "lzo/lzo1x.h"
@@ -34,6 +35,7 @@
 #include "lzoutil.h"
 #include "lzo1x.h"
 #endif
+#endif
 
 #include "buffer.h"
 #include "mtu.h"
 #define LZO_ON         (1<<1)
 #define LZO_ADAPTIVE   (1<<2)  
 
+/*
+ * Length of prepended prefix on LZO packets
+ */ 
+#define LZO_PREFIX_LEN 1
+
+/*
+ * LZO 2.0 worst case size expansion
+ */
+#define LZO_EXTRA_BUFFER(len) ((len)/8 + 128 + 3)
+
+#ifndef LZO_STUB
+
 /*
  * Use LZO compress routine lzo1x_1_15_compress which is described
  * as faster but needs a bit more memory than the standard routine.
 #define LZO_WORKSPACE  LZO1X_1_15_MEM_COMPRESS
 #define LZO_DECOMPRESS  lzo1x_decompress_safe
 
-#define LZO_EXTRA_BUFFER(len) ((len)/8 + 128 + 3)      /* LZO 2.0 worst case size expansion. */
-
 /*
  * Don't try to compress any packet smaller than this.
  */
 #define COMPRESS_THRESHOLD 100
 
-/*
- * Length of prepended prefix on LZO packets
- */ 
-#define LZO_PREFIX_LEN 1
-
 /*
  * Adaptive compress parameters
  */
@@ -88,23 +95,27 @@ struct lzo_adaptive_compress {
   int n_comp;
 };
 
+#endif /* LZO_STUB */
+
 /*
  * Compress and Uncompress routines.
  */
 
 struct lzo_compress_workspace
 {
+  bool defined;
+  unsigned int flags;
+#ifndef LZO_STUB
   lzo_voidp wmem;
   int wmem_size;
   struct lzo_adaptive_compress ac;
-  unsigned int flags;
-  bool defined;
 
   /* statistics */
   counter_type pre_decompress;
   counter_type post_decompress;
   counter_type pre_compress;
   counter_type post_compress;
+#endif
 };
 
 void lzo_adjust_frame_parameters(struct frame *frame);
index dfba941759df83aa2469e4f3406e323067dcb002..e8e0d7a7a5cb0b6eef0edfeabbdd18b50adc9ab7 100644 (file)
--- a/options.c
+++ b/options.c
@@ -4754,6 +4754,12 @@ add_option (struct options *options,
          msg (msglevel, "this is a generic configuration and cannot directly be used");
          goto err;
        }
+#ifdef ENABLE_PUSH_PEER_INFO
+      else if (streq (p[1], "PUSH_PEER_INFO"))
+       {
+         options->push_peer_info = true;
+       }
+#endif
 #if P2MP
       else if (streq (p[1], "SERVER_POLL_TIMEOUT") && p[2])
        {
diff --git a/ssl.c b/ssl.c
index 16e4c096022562845393555afff5dcfb9e6afa59..dbc65eb16bdaeb6742bed7631f8c1829fb596c6a 100644 (file)
--- a/ssl.c
+++ b/ssl.c
@@ -3809,6 +3809,11 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
        buf_printf (&out, "IV_HWADDR=%s\n", format_hex_ex (macaddr, 6, 0, 1, ":", &gc));
       }
 
+      /* push LZO status */
+#ifdef LZO_STUB
+      buf_printf (&out, "IV_LZO_STUB=1\n");
+#endif
+
       /* push env vars that begin with UV_ */
       for (e=es->list; e != NULL; e=e->next)
        {
index 1c894c91c78a8821f1d8666249e6ade3ddc5982f..0da1fc263454d9195ea440980d0dfb7f68ae8c80 100644 (file)
--- a/syshead.h
+++ b/syshead.h
@@ -697,4 +697,16 @@ socket_defined (const socket_descriptor_t sd)
  */
 #define ENABLE_CLIENT_NAT
 
+/*
+ * Support LZO as a stub in client? (LZO lib not included, but we
+ * we still support LZO protocol changes that allow us to
+ * communicate with an LZO-enabled server)
+ */
+#ifdef LZO_STUB
+#undef USE_LZO
+#undef LZO_VERSION_NUM
+#define USE_LZO 1
+#define LZO_VERSION_NUM "STUB"
+#endif
+
 #endif
index f89b007295c8ed67e089cbc2a6eca6336a2bc5e1..e173442b840f522a6272e78327c0fd14f48c170f 100644 (file)
@@ -1,5 +1,5 @@
 dnl define the OpenVPN version
-define(PRODUCT_VERSION,[2.1.3i])
+define(PRODUCT_VERSION,[2.1.3j])
 dnl define the TAP version
 define(PRODUCT_TAP_ID,[tap0901])
 define(PRODUCT_TAP_WIN32_MIN_MAJOR,[9])