6fbf66fa |
/*
* OpenVPN -- An application to securely tunnel IP networks
* over a single UDP port, with support for SSL/TLS-based
* session authentication and key exchange,
* packet encryption, packet authentication, and
* packet compression.
* |
49979459 |
* Copyright (C) 2002-2018 OpenVPN Inc <sales@openvpn.net> |
6fbf66fa |
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
* |
caa54ac3 |
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
6fbf66fa |
*/
|
537073fd |
#ifndef OPENVPN_LZO_H
#define OPENVPN_LZO_H
|
f64dfde0 |
/**
* @file
* Data Channel Compression module header file.
*/
|
38d96bd7 |
#if defined(ENABLE_LZO) |
6fbf66fa |
|
f64dfde0 |
/**
* @addtogroup compression
* @{
*/
|
74bbc71b |
#if defined(HAVE_LZO_LZOUTIL_H) |
6fbf66fa |
#include "lzo/lzoutil.h" |
74bbc71b |
#elif defined(HAVE_LZOUTIL_H) |
6fbf66fa |
#include "lzoutil.h" |
74bbc71b |
#endif
#if defined(HAVE_LZO_LZO1X_H)
#include "lzo/lzo1x.h"
#elif defined(HAVE_LZO1X_H) |
6fbf66fa |
#include "lzo1x.h"
#endif
#include "buffer.h"
#include "mtu.h"
#include "common.h"
#include "status.h"
|
38d96bd7 |
extern const struct compress_alg lzo_alg; |
6c34e74f |
|
f64dfde0 |
/**************************************************************************/
/** @name LZO library interface defines *//** @{ *//***********************/ |
6fbf66fa |
#define LZO_COMPRESS lzo1x_1_15_compress |
81d882d5 |
/**< LZO library compression function.
*
* Use \c lzo1x_1_15_compress because it
* is described as faster than the
* standard routine, although it does
* need a bit more memory. */
#define LZO_WORKSPACE LZO1X_1_15_MEM_COMPRESS
/**< The size in bytes of the memory
* %buffer required by the LZO library
* compression algorithm. */ |
6fbf66fa |
#define LZO_DECOMPRESS lzo1x_decompress_safe |
81d882d5 |
/**< LZO library decompression function.
*
* Use safe decompress because it
* includes checks for possible %buffer
* overflows. If speed is essential and
* you will always be using a MAC to
* verify the integrity of incoming
* packets, you might want to consider
* using the non-safe version. */ |
f64dfde0 |
/** @} name LZO library interface *//**************************************/ |
6fbf66fa |
|
f64dfde0 |
/**************************************************************************/
/** @name Adaptive compression defines *//** @{ *//************************/
#define AC_SAMP_SEC 2 /**< Number of seconds in a sample period. */
#define AC_MIN_BYTES 1000 /**< Minimum number of bytes a sample
* period must contain for it to be
* evaluated. */
#define AC_SAVE_PCT 5 /**< Minimum size reduction percentage
* below which compression will be
* turned off. */
#define AC_OFF_SEC 60 /**< Seconds to wait after compression has
* been turned off before retesting. */
/** @} name Adaptive compression defines *//*******************************/
/**
* Adaptive compression state.
*/ |
6fbf66fa |
struct lzo_adaptive_compress { |
81d882d5 |
bool compress_state;
time_t next;
int n_total;
int n_comp; |
6fbf66fa |
};
|
f64dfde0 |
/**
* State for the compression and decompression routines.
*
* This structure contains compression module state, such as whether
* compression is enabled and the status of the adaptive compression
* routines. It also contains an allocated working buffer.
*
* One of these compression workspace structures is maintained for each
* VPN tunnel.
*/ |
6fbf66fa |
struct lzo_compress_workspace
{ |
81d882d5 |
lzo_voidp wmem;
int wmem_size;
struct lzo_adaptive_compress ac; |
6fbf66fa |
};
|
f64dfde0 |
/** @} addtogroup compression */
|
537073fd |
|
38d96bd7 |
#endif /* ENABLE_LZO && USE_COMP */ |
81d882d5 |
#endif /* ifndef OPENVPN_LZO_H */ |