const modifies on primitive return types (int, bool, etc.) do not
do anything and Clang complains about these.
Zero initialisation in C++ is done by = {} or class().
Signed-off-by: Arne Schwabe <arne@openvpn.net>
* Put all methods in the LZ4 namespace.
* Throw errors instead of returning null BufferPtr().
* For decompress(), make sure that max_decompressed_size
doesn't exceed LZ4_MAX_INPUT_SIZE.
This commit only affects the standalone LZ4 helper functions,
not the LZ4 module that is part of the OpenVPN protocol.
Signed-off-by: James Yonan <james@openvpn.net>
It probably makes more sense for debug logging to be handled
by the caller.
Also removed OPENVPN_GZIP_VERBOSE.
Signed-off-by: James Yonan <james@openvpn.net>
compress_lz4() and decompress_lz4() are intended for users
that want to do simple LZ4 compression/decompression on
a Buffer without involving the OpenVPN protocol compression
modules.
Signed-off-by: James Yonan <james@openvpn.net>
Fixed regression in:
template <typename T_>
BufferAllocatedType(const BufferType<T_>& other, const unsigned int flags)
That was introduced by commit b48a1682a7e9c666e1b6605747d3d561f2fbb5c4
BufferAllocated: improve movability
Added BufferAllocated move constructor for foreign
BufferAllocated template classes.
Basically the source of the memcpy was not taking into account
the offset.
Signed-off-by: James Yonan <james@openvpn.net>
Added BufferAllocated move constructor for foreign
BufferAllocated template classes.
In order to make this work, we need to:
(a) generally friend BufferType and BufferAllocatedType
to all BufferAllocatedType template classes, and
(b) require typename R (thread_unsafe_refcount or
thread_safe_refcount) to be specified for
BufferAllocatedType (previously it was optional
and defaulted to thread_unsafe_refcount).
Signed-off-by: James Yonan <james@openvpn.net>
std::strerror() doesn't claim to be thread-safe, so
add openvpn::strerror_str() which is thread-safe by
virtue of the fact that it backs to strerror_r().
Signed-off-by: James Yonan <james@openvpn.net>
Created a lightweight abstraction layer so that another i/o
reactor can be dropped in place of asio.
The basic approach is to rename all references to asio::xxx
types to openvpn_io::xxx and then make openvpn_io a
preprocessor variable that points to the top-level namespace
of the i/o reactor implementation.
All of the source files that currently include <asio.hpp> now
include <openvpn/io/io.hpp> instead:
This gives us a lightweight abstraction layer that allows us
to define openvpn_io to be something other than asio.
Other changes:
* Inclusion of asio by scripts/build is now optional, and is
enabled by passing ASIO=1 or ASIO_DIR=<dir>.
* Refactored openvpn/common/socktypes.hpp to no longer
require asio.
* Refactored openvpn/log/logthread.hpp to no longer require
asio.
* Added openvpn::get_hostname() method as alternative to
calling asio directly.
* openvpn/openssl/util/init.hpp will now #error
if USE_ASIO is undefined.
Signed-off-by: James Yonan <james@openvpn.net>
mutable_buffers_1 -> mutable_buffer
const_buffers_1 -> const_buffer
This patch is a granularization of a patch by David Sommerseth
<davids@openvpn.net> where only the above renames are included.
receive path to reassemble messages fragmented by the
SSL layer up to a max message size of 64 KB.
Ramifications:
* Peer info data and pushed options can be significantly
larger (i.e. approaching 64 KB).
* Less need for the options continuation feature.
Limitations:
* While this patch doesn't change the underlying OpenVPN
protocol, it can result in messages being sent that are
fragmented by the receiving SSL implementation into
multiple buffers. Implementations that lack reassembly
capabilities (such as OpenVPN 2.x at this point in time)
would see each buffer fragment as a separate message.
* This patch running on the server will break negotiation
with pre-peer-info clients. Basically this means it will
interoperate with any OpenVPN 3 version or OpenVPN 2.x
version that includes the June 2010 commit "Implemented a
key/value auth channel from client to server.
Version 2.1.1i".
* added const_buffers_1_limit() method that is like
const_buffers_1_clamp() but includes an upper-bound size
constraint.
* realign() should be a no-op if headroom == offset_
* added additional reset() convenience method that also calls
init_headroom()