14#ifndef OPENVPN_TRANSPORT_UDPLINK_H
15#define OPENVPN_TRANSPORT_UDPLINK_H
30#if defined(OPENVPN_DEBUG_UDPLINK) && OPENVPN_DEBUG_UDPLINK >= 1
31#define OPENVPN_LOG_UDPLINK_ERROR(x) OPENVPN_LOG(x)
33#define OPENVPN_LOG_UDPLINK_ERROR(x)
36#if defined(OPENVPN_DEBUG_UDPLINK) && OPENVPN_DEBUG_UDPLINK >= 3
37#define OPENVPN_LOG_UDPLINK_VERBOSE(x) OPENVPN_LOG(x)
39#define OPENVPN_LOG_UDPLINK_VERBOSE(x)
54 typedef std::unique_ptr<PacketFrom>
SPtr;
59template <
typename ReadHandler>
66 openvpn_io::ip::udp::socket &socket_arg,
92 gremlin_send(buf, endpoint);
104 for (
int i = 0; i < n_parallel; i++)
112#ifdef OPENVPN_GREMLIN
137 [self =
Ptr(
this), udpfrom =
PacketFrom::SPtr(udpfrom)](
const openvpn_io::error_code &error,
const size_t bytes_recvd)
mutable
140 self->handle_read(std::move(udpfrom), error, bytes_recvd);
154 pfp->buf.set_size(bytes_recvd);
157#ifdef OPENVPN_GREMLIN
181 const size_t wrote = endpoint
186 if (wrote == buf.
size())
195 catch (openvpn_io::system_error &e)
199 return e.code().value();
206#ifdef OPENVPN_GREMLIN
209 std::unique_ptr<AsioEndpoint> ep;
212 gremlin->send_queue([self =
Ptr(
this), buf =
BufferAllocated(buf), ep = std::move(ep)]()
mutable
215 self->do_send(buf, ep.get()); });
220 gremlin->recv_queue([self =
Ptr(
this), pfp = std::move(pfp)]()
mutable
223 self->read_handler->udp_read_handler(pfp); });
233#ifdef OPENVPN_GREMLIN
234 std::unique_ptr<Gremlin::SendRecvQueue> gremlin;
#define OPENVPN_ASYNC_HANDLER
openvpn_io::const_buffer const_buffer() const
Return an openvpn_io::const_buffer object used by asio write methods.
size_t size() const
Returns the size of the buffer in T objects.
size_t prepare(Buffer &buf) const
void reset_align_adjust(const size_t align_adjust)
openvpn_io::mutable_buffer mutable_buffer(Buffer &buf) const
void reset() noexcept
Points this RCPtr<T> to nullptr safely.
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)
void inc_stat(const size_t type, const count_t value)
int do_send(const Buffer &buf, const AsioEndpoint *endpoint)
UDPLink(ReadHandler read_handler_arg, openvpn_io::ip::udp::socket &socket_arg, const Frame::Context &frame_context_arg, const SessionStats::Ptr &stats_arg)
void handle_read(PacketFrom::SPtr pfp, const openvpn_io::error_code &error, const size_t bytes_recvd)
void reset_align_adjust(const size_t align_adjust)
Frame::Context frame_context
void start(const int n_parallel)
int send(const Buffer &buf, const AsioEndpoint *endpoint)
void queue_read(PacketFrom *udpfrom)
openvpn_io::ip::udp::socket & socket
openvpn_io::ip::udp::endpoint AsioEndpoint
BufferAllocatedType< unsigned char > BufferAllocated
AsioEndpoint sender_endpoint
std::unique_ptr< PacketFrom > SPtr
static const char config[]
#define OPENVPN_LOG_UDPLINK_VERBOSE(x)
#define OPENVPN_LOG_UDPLINK_ERROR(x)