OpenVPN 3 Core Library
Loading...
Searching...
No Matches
tcplink.hpp
Go to the documentation of this file.
1
// OpenVPN -- An application to securely tunnel IP networks
2
// over a single port, with support for SSL/TLS-based
3
// session authentication and key exchange,
4
// packet encryption, packet authentication, and
5
// packet compression.
6
//
7
// Copyright (C) 2012- OpenVPN Inc.
8
//
9
// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10
//
11
12
// Low-level TCP transport object.
13
14
#ifndef OPENVPN_TRANSPORT_TCPLINK_H
15
#define OPENVPN_TRANSPORT_TCPLINK_H
16
17
#include <deque>
18
#include <utility>
// for std::move
19
#include <memory>
20
21
#include <
openvpn/io/io.hpp
>
22
23
#include <
openvpn/common/bigmutex.hpp
>
24
#include <
openvpn/common/size.hpp
>
25
#include <
openvpn/common/rc.hpp
>
26
#include <
openvpn/common/socktypes.hpp
>
27
#include <
openvpn/frame/frame.hpp
>
28
#include <
openvpn/log/sessionstats.hpp
>
29
#include <
openvpn/transport/pktstream.hpp
>
30
#include <
openvpn/transport/mutate.hpp
>
31
#include <
openvpn/transport/tcplinkcommon.hpp
>
32
33
#ifdef OPENVPN_GREMLIN
34
#include <
openvpn/transport/gremlin.hpp
>
35
#endif
36
37
namespace
openvpn::TCPTransport
{
38
39
template
<
typename
Protocol,
typename
ReadHandler,
bool
RAW_MODE_ONLY>
40
class
TCPLink
:
public
LinkCommon
<Protocol,
41
ReadHandler,
42
RAW_MODE_ONLY>
43
{
44
using
Queue
= std::deque<BufferPtr>;
45
46
public
:
47
using
Base
=
LinkCommon
<
Protocol
,
48
ReadHandler,
49
RAW_MODE_ONLY>;
50
using
Ptr
=
RCPtr<TCPLink>
;
51
52
using
protocol
=
Protocol
;
53
54
friend
Base
;
55
56
TCPLink
(ReadHandler read_handler_arg,
57
typename
Protocol::socket &socket_arg,
58
const
size_t
send_queue_max_size_arg,
// 0 to disable
59
const
size_t
free_list_max_size_arg,
60
const
Frame::Context
&frame_context_arg,
61
const
SessionStats::Ptr
&stats_arg)
62
:
Base
(read_handler_arg,
63
socket_arg,
64
send_queue_max_size_arg,
65
free_list_max_size_arg,
66
frame_context_arg,
67
stats_arg)
68
{
69
}
70
71
private
:
72
// Called by LinkCommon
73
void
from_app_send_buffer
(
BufferPtr
&buf)
override
74
{
75
Base::queue_send_buffer
(buf);
76
}
77
78
void
recv_buffer
(
PacketFrom::SPtr
&pfp,
const
size_t
bytes_recvd)
override
79
{
80
bool
requeue =
true
;
81
OPENVPN_LOG_TCPLINK_VERBOSE
(
"TCP recv raw="
82
<<
Base::raw_mode_read
<<
" size="
<< bytes_recvd);
83
84
pfp->buf.set_size(bytes_recvd);
85
requeue =
Base::process_recv_buffer
(pfp->buf);
86
if
(!
Base::halt
&& requeue)
87
Base::queue_recv
(pfp.release());
// reuse PacketFrom object
88
}
89
};
90
}
// namespace openvpn::TCPTransport
91
92
#endif
bigmutex.hpp
openvpn::Frame::Context
Definition
frame.hpp:58
openvpn::Protocol
Definition
protocol.hpp:26
openvpn::RCPtr
The smart pointer class.
Definition
rc.hpp:119
openvpn::TCPTransport::LinkCommon
Definition
tcplinkcommon.hpp:48
openvpn::TCPTransport::LinkCommon::raw_mode_read
bool raw_mode_read
Definition
tcplinkcommon.hpp:466
openvpn::TCPTransport::LinkCommon::queue_recv
void queue_recv(PacketFrom *tcpfrom)
Definition
tcplinkcommon.hpp:182
openvpn::TCPTransport::LinkCommon::halt
bool halt
Definition
tcplinkcommon.hpp:468
openvpn::TCPTransport::LinkCommon::process_recv_buffer
bool process_recv_buffer(BufferAllocated &buf)
Definition
tcplinkcommon.hpp:334
openvpn::TCPTransport::LinkCommon::queue_send_buffer
void queue_send_buffer(BufferPtr &buf)
Definition
tcplinkcommon.hpp:271
openvpn::TCPTransport::TCPLink
Definition
tcplink.hpp:43
openvpn::TCPTransport::TCPLink::TCPLink
TCPLink(ReadHandler read_handler_arg, typename Protocol::socket &socket_arg, const size_t send_queue_max_size_arg, const size_t free_list_max_size_arg, const Frame::Context &frame_context_arg, const SessionStats::Ptr &stats_arg)
Definition
tcplink.hpp:56
openvpn::TCPTransport::TCPLink::Base
friend Base
Definition
tcplink.hpp:54
openvpn::TCPTransport::TCPLink::from_app_send_buffer
void from_app_send_buffer(BufferPtr &buf) override
Definition
tcplink.hpp:73
openvpn::TCPTransport::TCPLink::recv_buffer
void recv_buffer(PacketFrom::SPtr &pfp, const size_t bytes_recvd) override
Definition
tcplink.hpp:78
openvpn::TCPTransport::TCPLink::Queue
std::deque< BufferPtr > Queue
Definition
tcplink.hpp:44
frame.hpp
gremlin.hpp
io.hpp
mutate.hpp
openvpn::TCPTransport
Definition
tcpcli.hpp:29
pktstream.hpp
rc.hpp
sessionstats.hpp
size.hpp
socktypes.hpp
openvpn::TCPTransport::PacketFrom::SPtr
std::unique_ptr< PacketFrom > SPtr
Definition
tcplinkbase.hpp:15
tcplinkcommon.hpp
OPENVPN_LOG_TCPLINK_VERBOSE
#define OPENVPN_LOG_TCPLINK_VERBOSE(x)
Definition
tcplinkcommon.hpp:39
openvpn
transport
tcplink.hpp
Generated by
1.9.8