2
* OpenVPN -- An application to securely tunnel IP networks
3
* over a single UDP port, with support for SSL/TLS-based
4
* session authentication and key exchange,
5
* packet encryption, packet authentication, and
8
* Copyright (C) 2002-2004 James Yonan <jim@yonan.net>
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program (see the file COPYING included with this
22
* distribution); if not, write to the Free Software Foundation, Inc.,
23
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35
* Use LZO compress routine lzo1x_1_15_compress which is described
36
* as faster but needs a bit more memory than the standard routine.
37
* Use safe decompress (i.e. check for buffer overflows).
38
* You may want to use the non-safe version
39
* of decompress if speed is essential and if you know
40
* that you will always be using a MAC to verify the
41
* integrity of incoming packets.
43
#define LZO_COMPRESS lzo1x_1_15_compress
44
#define LZO_WORKSPACE LZO1X_1_15_MEM_COMPRESS
45
#define LZO_DECOMPRESS lzo1x_decompress_safe
47
#define LZO_EXTRA_BUFFER(len) ((len)/64 + 16 + 3) /* LZO worst case size expansion. */
50
* Don't try to compress any packet smaller than this.
52
#define COMPRESS_THRESHOLD 100
55
* Adaptive compress parameters
57
#define AC_SAMP_SEC 2 /* number of seconds in sample period */
58
#define AC_MIN_BYTES 1000 /* sample period must have at least n bytes
59
to be valid for testing */
60
#define AC_SAVE_PCT 5 /* turn off compress if we didn't save at
61
least this % during sample period */
62
#define AC_OFF_SEC 60 /* if we turn off compression, don't do sample
63
retest for n seconds */
65
struct lzo_adaptive_compress {
74
* Compress and Uncompress routines.
77
struct lzo_compress_workspace
81
struct lzo_adaptive_compress ac;
84
counter_type pre_decompress;
85
counter_type post_decompress;
86
counter_type pre_compress;
87
counter_type post_compress;
90
void lzo_adjust_frame_parameters(struct frame *frame);
92
void lzo_compress_init (struct lzo_compress_workspace *lzowork, bool adaptive);
94
void lzo_compress_uninit (struct lzo_compress_workspace *lzowork);
96
void lzo_compress (struct buffer *buf, struct buffer work,
97
struct lzo_compress_workspace *lzowork,
98
const struct frame* frame,
99
const time_t current);
101
void lzo_decompress (struct buffer *buf, struct buffer work,
102
struct lzo_compress_workspace *lzowork,
103
const struct frame* frame);
105
void lzo_print_stats (struct lzo_compress_workspace *lzo_compwork);