#include "syshead.h"
-#ifdef USE_COMP
-
#include "comp.h"
#include "error.h"
+
+#ifdef USE_COMP
+
#include "otime.h"
#include "memdbg.h"
buf_printf(out, "IV_COMP_STUB=1\n");
buf_printf(out, "IV_COMP_STUBv2=1\n");
}
+#endif /* USE_COMP */
bool
check_compression_settings_valid(struct compress_options *info, int msglevel)
if (info->alg != COMP_ALGV2_UNCOMPRESSED && info->alg != COMP_ALG_UNDEF
&& (info->flags & COMP_F_ALLOW_NOCOMP_ONLY))
{
+#ifdef USE_COMP
msg(msglevel, "Compression or compression stub framing is not allowed "
"since data-channel offloading is enabled.");
+#else
+ msg(msglevel, "Compression or compression stub framing is not allowed "
+ "since OpenVPN was built without compression support.");
+#endif
return false;
}
#endif
return true;
}
-
-
-#endif /* USE_COMP */
#ifndef OPENVPN_COMP_H
#define OPENVPN_COMP_H
-#ifdef USE_COMP
+/* We always parse all compression options, so we include these defines/struct
+ * outside of the USE_COMP define */
-#include "buffer.h"
-#include "mtu.h"
-#include "common.h"
-#include "status.h"
+/* Compression flags */
+#define COMP_F_ADAPTIVE (1<<0) /* COMP_ALG_LZO only */
+#define COMP_F_ALLOW_COMPRESS (1<<1) /* not only downlink is compressed but also uplink */
+#define COMP_F_SWAP (1<<2) /* initial command byte is swapped with last byte in buffer to preserve payload alignment */
+#define COMP_F_ADVERTISE_STUBS_ONLY (1<<3) /* tell server that we only support compression stubs */
+#define COMP_F_ALLOW_STUB_ONLY (1<<4) /* Only accept stub compression, even with COMP_F_ADVERTISE_STUBS_ONLY
+ * we still accept other compressions to be pushed */
+#define COMP_F_MIGRATE (1<<5) /* push stub-v2 or comp-lzo no when we see a client with comp-lzo in occ */
+#define COMP_F_ALLOW_ASYM (1<<6) /* Compression was explicitly set to allow asymetric compression */
+#define COMP_F_ALLOW_NOCOMP_ONLY (1<<7) /* Do not allow compression framing (breaks DCO) */
/* algorithms */
#define COMP_ALG_UNDEF 0
#define COMP_ALGV2_SNAPPY 13
*/
-/* Compression flags */
-#define COMP_F_ADAPTIVE (1<<0) /* COMP_ALG_LZO only */
-#define COMP_F_ALLOW_COMPRESS (1<<1) /* not only downlink is compressed but also uplink */
-#define COMP_F_SWAP (1<<2) /* initial command byte is swapped with last byte in buffer to preserve payload alignment */
-#define COMP_F_ADVERTISE_STUBS_ONLY (1<<3) /* tell server that we only support compression stubs */
-#define COMP_F_ALLOW_STUB_ONLY (1<<4) /* Only accept stub compression, even with COMP_F_ADVERTISE_STUBS_ONLY
- * we still accept other compressions to be pushed */
-#define COMP_F_MIGRATE (1<<5) /* push stub-v2 or comp-lzo no when we see a client with comp-lzo in occ */
-#define COMP_F_ALLOW_ASYM (1<<6) /* Compression was explicitly set to allow asymetric compression */
-#define COMP_F_ALLOW_NOCOMP_ONLY (1<<7) /* Do not allow compression framing (breaks DCO) */
+/*
+ * Information that basically identifies a compression
+ * algorithm and related flags.
+ */
+struct compress_options
+{
+ int alg;
+ unsigned int flags;
+};
+
+static inline bool
+comp_non_stub_enabled(const struct compress_options *info)
+{
+ return info->alg != COMP_ALGV2_UNCOMPRESSED
+ && info->alg != COMP_ALG_STUB
+ && info->alg != COMP_ALG_UNDEF;
+}
+
+/**
+ * Checks if the compression settings are valid. Takes into account the
+ * flags of allow-compression and also the whether algorithms are compiled
+ * in
+ */
+bool
+check_compression_settings_valid(struct compress_options *info, int msglevel);
+
+#ifdef USE_COMP
+#include "buffer.h"
+#include "mtu.h"
+#include "common.h"
+#include "status.h"
/*
* Length of prepended prefix on compressed packets
#include "comp-lz4.h"
#endif
-/*
- * Information that basically identifies a compression
- * algorithm and related flags.
- */
-struct compress_options
-{
- int alg;
- unsigned int flags;
-};
-
/*
* Workspace union of all supported compression algorithms
*/
{
return info->alg != COMP_ALG_UNDEF;
}
-
-static inline bool
-comp_non_stub_enabled(const struct compress_options *info)
-{
- return info->alg != COMP_ALGV2_UNCOMPRESSED
- && info->alg != COMP_ALG_STUB
- && info->alg != COMP_ALG_UNDEF;
-}
-
-/**
- * Checks if the compression settings are valid. Takes into account the
- * flags of allow-compression and also the whether algorithms are compiled
- * in
- */
-bool
-check_compression_settings_valid(struct compress_options *info, int msglevel);
-
#endif /* USE_COMP */
#endif /* ifndef OPENVPN_COMP_H */
SHOW_BOOL(fast_io);
-#ifdef USE_COMP
SHOW_INT(comp.alg);
SHOW_INT(comp.flags);
-#endif
SHOW_STR(route_script);
SHOW_STR(route_default_gateway);
o->pre_connect->ping_send_timeout = o->ping_send_timeout;
/* Miscellaneous Options */
-#ifdef USE_COMP
o->pre_connect->comp = o->comp;
-#endif
}
void
o->ping_send_timeout = pp->ping_send_timeout;
/* Miscellaneous Options */
-#ifdef USE_COMP
o->comp = pp->comp;
-#endif
}
o->push_continuation = 0;
o->comp.flags = COMP_F_ALLOW_STUB_ONLY | COMP_F_ADVERTISE_STUBS_ONLY;
}
}
+#else /* ifdef USE_COMP */
+ o->comp.flags = COMP_F_ALLOW_NOCOMP_ONLY;
#endif
}
#endif
}
-#ifdef USE_COMP
static void
show_compression_warning(struct compress_options *info)
{
}
}
}
-#endif
bool
key_is_external(const struct options *options)
options->passtos = true;
}
#endif
-#if defined(USE_COMP)
else if (streq(p[0], "allow-compression") && p[1] && !p[2])
{
VERIFY_PERMISSION(OPT_P_GENERAL);
show_compression_warning(&options->comp);
}
-#endif /* USE_COMP */
else if (streq(p[0], "show-ciphers") && !p[1])
{
VERIFY_PERMISSION(OPT_P_GENERAL);