OpenVPN 3 Core Library
Loading...
Searching...
No Matches
transbase.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// Abstract base classes for client transport objects that implement UDP, TCP,
13// HTTP Proxy, etc.
14
15#ifndef OPENVPN_TRANSPORT_CLIENT_TRANSBASE_H
16#define OPENVPN_TRANSPORT_CLIENT_TRANSBASE_H
17
18#include <string>
19
20#include <openvpn/io/io.hpp>
21
23#include <openvpn/common/rc.hpp>
25#include <openvpn/addr/ip.hpp>
30
31namespace openvpn {
32struct TransportClientParent;
33
34// Base class for client transport object.
35struct TransportClient : public virtual RC<thread_unsafe_refcount>
36{
38
39 virtual void transport_start() = 0;
40 virtual void stop() = 0;
41 virtual bool transport_send_const(const Buffer &buf) = 0;
42 virtual bool transport_send(BufferAllocated &buf) = 0;
43 virtual bool transport_send_queue_empty() = 0;
44 virtual bool transport_has_send_queue() = 0;
45 virtual void transport_stop_requeueing() = 0;
46 virtual size_t transport_send_queue_size() = 0;
47 virtual void reset_align_adjust(const size_t align_adjust) = 0;
48 virtual IP::Addr server_endpoint_addr() const = 0;
49 virtual unsigned short server_endpoint_port() const
50 {
51 return 0;
52 }
53 virtual openvpn_io::detail::socket_type native_handle()
54 {
55 return 0;
56 }
57 // clang-format off
58 virtual void server_endpoint_info(std::string &host,
59 std::string &port,
60 std::string &proto,
61 std::string &ip_addr) const = 0;
62 // clang-format on
63 virtual Protocol transport_protocol() const = 0;
64 virtual void transport_reparent(TransportClientParent *parent) = 0;
65};
66
67// Base class for parent of client transport object, used by client transport
68// objects to communicate received data packets, exceptions, and progress
69// notifications.
71{
72 virtual void transport_recv(BufferAllocated &buf) = 0;
73 virtual void transport_needs_send() = 0; // notification that send queue is empty
74 virtual void transport_error(const Error::Type fatal_err, const std::string &err_text) = 0;
75 virtual void proxy_error(const Error::Type fatal_err, const std::string &err_text) = 0;
76
77 // Return true if we are transporting OpenVPN protocol
79
80 // progress notifications
81 virtual void transport_pre_resolve() = 0;
82 virtual void transport_wait_proxy() = 0;
83 virtual void transport_wait() = 0;
84 virtual void transport_connecting() = 0;
85
86 // Return true if keepalive parameter(s) are enabled.
87 virtual bool is_keepalive_enabled() const = 0;
88
89 // clang-format off
90 // Disable keepalive for rest of session, but fetch
91 // the keepalive parameters (in seconds).
92 virtual void disable_keepalive(unsigned int &keepalive_ping,
93 unsigned int &keepalive_timeout) = 0;
94 // clang-format on
95
96 virtual ~TransportClientParent() = default;
97};
98
99// Factory for client transport object.
100struct TransportClientFactory : public virtual RC<thread_unsafe_refcount>
101{
103
104 // clang-format off
105 virtual TransportClient::Ptr new_transport_client_obj(openvpn_io::io_context &io_context,
106 TransportClientParent *parent) = 0;
107 // clang-format on
108
109 virtual bool is_relay()
110 {
111 return false;
112 }
113 virtual void process_push(const OptionList &)
114 {
115 return;
116 }
117};
118
119} // namespace openvpn
120
121#endif // OPENVPN_TRANSPORT_CLIENT_TRANSBASE_H
The smart pointer class.
Definition rc.hpp:119
Reference count base class for objects tracked by RCPtr. Disallows copying and assignment.
Definition rc.hpp:912
virtual TransportClient::Ptr new_transport_client_obj(openvpn_io::io_context &io_context, TransportClientParent *parent)=0
virtual void process_push(const OptionList &)
RCPtr< TransportClientFactory > Ptr
virtual void transport_connecting()=0
virtual void transport_pre_resolve()=0
virtual void transport_error(const Error::Type fatal_err, const std::string &err_text)=0
virtual void proxy_error(const Error::Type fatal_err, const std::string &err_text)=0
virtual bool transport_is_openvpn_protocol()=0
virtual void transport_wait()=0
virtual bool is_keepalive_enabled() const =0
virtual void disable_keepalive(unsigned int &keepalive_ping, unsigned int &keepalive_timeout)=0
virtual void transport_recv(BufferAllocated &buf)=0
virtual void transport_wait_proxy()=0
virtual void transport_needs_send()=0
virtual ~TransportClientParent()=default
virtual void reset_align_adjust(const size_t align_adjust)=0
virtual void transport_start()=0
virtual bool transport_send_const(const Buffer &buf)=0
virtual void transport_reparent(TransportClientParent *parent)=0
virtual size_t transport_send_queue_size()=0
RCPtr< TransportClient > Ptr
Definition transbase.hpp:37
virtual bool transport_has_send_queue()=0
virtual bool transport_send_queue_empty()=0
virtual IP::Addr server_endpoint_addr() const =0
virtual bool transport_send(BufferAllocated &buf)=0
virtual void server_endpoint_info(std::string &host, std::string &port, std::string &proto, std::string &ip_addr) const =0
virtual void stop()=0
virtual openvpn_io::detail::socket_type native_handle()
Definition transbase.hpp:53
virtual Protocol transport_protocol() const =0
virtual void transport_stop_requeueing()=0
virtual unsigned short server_endpoint_port() const
Definition transbase.hpp:49
proxy_host_port port
proxy_host_port host