31#if defined(ENABLE_LZ4)
41lz4_compress_init(
struct compress_context *compctx)
48lz4v2_compress_init(
struct compress_context *compctx)
54lz4_compress_uninit(
struct compress_context *compctx)
61 struct compress_context *compctx,
69 uint8_t comp_head_byte = NO_COMPRESS_BYTE_SWAP;
70 uint8_t *head =
BPTR(buf);
71 uint8_t *tail =
BEND(buf);
77 *head = comp_head_byte;
83 struct compress_context *compctx,
91 compv2_escape_data_ifneeded(buf);
95do_lz4_decompress(
size_t zlen_max,
98 struct compress_context *compctx)
102 uncomp_len = LZ4_decompress_safe((
const char *)
BPTR(buf), (
char *)
BPTR(work), (
size_t)
BLEN(buf), zlen_max);
111 work->
len = uncomp_len;
114 compctx->pre_decompress += buf->
len;
115 compctx->post_decompress += work->
len;
122 struct compress_context *compctx,
137 uint8_t *head =
BPTR(buf);
143 if (c == LZ4_COMPRESS_BYTE)
145 do_lz4_decompress(zlen_max, &work, buf, compctx);
147 else if (c == NO_COMPRESS_BYTE_SWAP)
160 struct compress_context *compctx,
174 uint8_t *head =
BPTR(buf);
178 if (c != COMP_ALGV2_INDICATOR_BYTE)
191 if (c == COMP_ALGV2_LZ4_BYTE)
194 do_lz4_decompress(zlen_max, &work, buf, compctx);
196 else if (c == COMP_ALGV2_UNCOMPRESSED_BYTE)
207const struct compress_alg lz4_alg = {
215const struct compress_alg lz4v2_alg = {
static bool buf_safe(const struct buffer *buf, size_t len)
static bool buf_advance(struct buffer *buf, int size)
#define buf_init(buf, offset)
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...