28 #ifndef OPENVPN_COMP_H
29 #define OPENVPN_COMP_H
39 #define COMP_F_SWAP (1<<2)
40 #define COMP_F_ADVERTISE_STUBS_ONLY (1<<3)
41 #define COMP_F_ALLOW_STUB_ONLY (1<<4)
43 #define COMP_F_MIGRATE (1<<5)
44 #define COMP_F_ALLOW_ASYM (1<<6)
45 #define COMP_F_ALLOW_NOCOMP_ONLY (1<<7)
48 #define COMP_ALG_UNDEF 0
49 #define COMP_ALG_STUB 1
50 #define COMP_ALG_LZO 2
51 #define COMP_ALG_SNAPPY 3
52 #define COMP_ALG_LZ4 4
56 #define COMP_ALGV2_UNCOMPRESSED 10
57 #define COMP_ALGV2_LZ4 11
98 #define COMP_PREFIX_LEN 1
106 #define LZO_COMPRESS_BYTE 0x66
107 #define LZ4_COMPRESS_BYTE 0x69
108 #define NO_COMPRESS_BYTE 0xFA
109 #define NO_COMPRESS_BYTE_SWAP 0xFB
112 #define COMP_ALGV2_INDICATOR_BYTE 0x50
113 #define COMP_ALGV2_UNCOMPRESSED_BYTE 0
114 #define COMP_ALGV2_LZ4_BYTE 1
115 #define COMP_ALGV2_LZO_BYTE 2
116 #define COMP_ALGV2_SNAPPY_BYTE 3
125 #define COMP_EXTRA_BUFFER(len) ((len)/6 + 128 + 3 + COMP_PREFIX_LEN)
130 #define COMPRESS_THRESHOLD 100
133 struct compress_context;
141 void (*compress_init)(
struct compress_context *compctx);
142 void (*compress_uninit)(
struct compress_context *compctx);
143 void (*compress)(
struct buffer *buf,
struct buffer work,
144 struct compress_context *compctx,
147 void (*decompress)(
struct buffer *buf,
struct buffer work,
148 struct compress_context *compctx,
166 union compress_workspace_union
169 struct lzo_compress_workspace lzo;
172 struct lz4_workspace lz4;
179 struct compress_context
182 struct compress_alg alg;
183 union compress_workspace_union wu;
192 extern const struct compress_alg comp_stub_alg;
193 extern const struct compress_alg compv2_stub_alg;
197 void comp_uninit(
struct compress_context *compctx);
199 void comp_print_stats(
const struct compress_context *compctx,
struct status_output *so);
203 void compv2_escape_data_ifneeded(
struct buffer *buf);