34#if defined(ENABLE_LZO)
44lzo_compress_init(
struct compress_context *compctx)
48 compctx->wu.lzo.wmem_size = LZO_WORKSPACE;
50 int lzo_status = lzo_init();
51 if (lzo_status != LZO_E_OK)
53 msg(
M_FATAL,
"Cannot initialize LZO compression library (lzo_init() returns %d)",
56 compctx->wu.lzo.wmem = (lzo_voidp)malloc(compctx->wu.lzo.wmem_size);
61lzo_compress_uninit(
struct compress_context *compctx)
63 free(compctx->wu.lzo.wmem);
64 compctx->wu.lzo.wmem = NULL;
68lzo_compress(
struct buffer *buf,
struct buffer work,
struct compress_context *compctx,
72 *header = NO_COMPRESS_BYTE;
76lzo_decompress(
struct buffer *buf,
struct buffer work,
struct compress_context *compctx,
93 if (c == LZO_COMPRESS_BYTE)
96 err = LZO_DECOMPRESS(
BPTR(buf),
BLEN(buf),
BPTR(&work), &zlen, compctx->wu.lzo.wmem);
108 compctx->pre_decompress += buf->
len;
109 compctx->post_decompress += work.
len;
113 else if (c == NO_COMPRESS_BYTE)
124const struct compress_alg lzo_alg = {
"lzo", lzo_compress_init, lzo_compress_uninit, lzo_compress,
static bool buf_safe(const struct buffer *buf, size_t len)
static bool buf_advance(struct buffer *buf, int size)
static uint8_t * buf_prepend(struct buffer *buf, int size)
static void check_malloc_return(void *p)
#define buf_init(buf, offset)
#define COMP_F_SWAP
initial command byte is swapped with last byte in buffer to preserve payload alignment
Wrapper structure for dynamically allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
Packet geometry parameters.
int payload_size
the maximum size that a payload that our buffers can hold from either tun device or network link.
int headroom
the headroom in the buffer, this is choosen to allow all potential header to be added before the pack...