15#ifndef OPENVPN_COMPRESS_COMPRESS_H
16#define OPENVPN_COMPRESS_COMPRESS_H
30#ifndef 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];
173 throw compressor_unavailable();
231 throw compressor_unavailable();
286 return "IV_LZO_SWAP=1\n";
294 return "IV_LZ4v2=1\n";
298 return "IV_SNAPPY=1\n";
303 return "IV_LZO_STUB=1\n"
305 "IV_COMP_STUBv2=1\n";
322 "IV_COMP_STUBv2=1\n";
332 "IV_COMP_STUBv2=1\n";
348 return "IV_LZO_SWAP=1\n";
356 return "IV_SNAPPY=1\n";
360 return "IV_LZO_STUB=1\n"
430 return "COMP_STUBv2";
469 if (method ==
"stub-v2")
471 if (method ==
"lz4-v2")
477 if (method ==
"lzo-swap")
479 if (method ==
"lzo-stub")
481 if (method ==
"snappy")
483 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)
CompressContext()=default
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.
bool empty() const
Returns true if the buffer is empty.
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)