15#ifndef OPENVPN_COMPRESS_COMPRESS_H
16#define OPENVPN_COMPRESS_COMPRESS_H
30#if !defined(OPENVPN_DEBUG_COMPRESS)
31#define OPENVPN_DEBUG_COMPRESS 1
41 virtual const char *
name()
const = 0;
97 const unsigned char first = buf.
pop_back();
106 unsigned char uc = buf[0];
119 unsigned char uc = buf[0];
175 throw compressor_unavailable();
233 throw compressor_unavailable();
288 return "IV_LZO_SWAP=1\n";
296 return "IV_LZ4v2=1\n";
300 return "IV_SNAPPY=1\n";
305 return "IV_LZO_STUB=1\n"
307 "IV_COMP_STUBv2=1\n";
324 "IV_COMP_STUBv2=1\n";
334 "IV_COMP_STUBv2=1\n";
350 return "IV_LZO_SWAP=1\n";
358 return "IV_SNAPPY=1\n";
362 return "IV_LZO_STUB=1\n"
432 return "COMP_STUBv2";
471 if (method ==
"stub-v2")
473 else if (method ==
"lz4-v2")
475 else if (method ==
"lz4")
477 else if (method ==
"lzo")
479 else if (method ==
"lzo-swap")
481 else if (method ==
"lzo-stub")
483 else if (method ==
"snappy")
485 else if (method ==
"stub")
static Type parse_method(const std::string &method)
const char * options_string() const
unsigned int extra_payload_bytes() const
static Type stub(const Type t)
const char * method_to_string() const
Compress::Ptr new_compressor(const Frame::Ptr &frame, const SessionStats::Ptr &stats)
const char * peer_info_string() const
static bool is_any_stub(const Type t)
OPENVPN_SIMPLE_EXCEPTION(compressor_unavailable)
const char * peer_info_string_v1() const
static void init_static()
static bool compressor_available(const Type t)
CompressContext(const Type t, const bool asym)
static void init_static()
void do_swap(Buffer &buf, unsigned char op)
virtual void decompress(BufferAllocated &buf)=0
void error(BufferAllocated &buf)
virtual const char * name() const =0
void do_unswap(Buffer &buf)
void v2_push(Buffer &buf, unsigned char value)
virtual void compress(BufferAllocated &buf, const bool hint)=0
Compress(const Frame::Ptr &frame_arg, const SessionStats::Ptr &stats_arg)
T * prepend_alloc(const size_t size)
Allocate space for prepending data to the buffer.
void push_back(const T &value)
Append a T object to the end of the array, resizing the array if necessary.
size_t size() const
Returns the size of the buffer in T objects.
T pop_back()
Removes and returns the last element from the buffer.
void advance(const size_t delta)
Advances the buffer by the specified delta.
void push_front(const T &value)
Append a T object to the array, with possible resize.
void reset_size()
Resets the size of the buffer to zero.
Reference count base class for objects tracked by RCPtr. Disallows copying and assignment.
virtual void error(const size_t type, const std::string *text=nullptr)