OpenVPN 3 Core Library
Loading...
Searching...
No Matches
base.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// multi-protocol acceptor classes that handle the protocol-specific
13// details of accepting client connections.
14
15#pragma once
16
17#include <vector>
18#include <utility>
19
20#include <openvpn/io/io.hpp>
21
24#include <openvpn/common/rc.hpp>
27
28#ifndef OPENVPN_ACCEPTOR_LISTENER_BASE_RC
29#define OPENVPN_ACCEPTOR_LISTENER_BASE_RC RC<thread_unsafe_refcount>
30#endif
31
33
35{
37
38 virtual void handle_accept(AsioPolySock::Base::Ptr sock, const openvpn_io::error_code &error) = 0;
39};
40
41struct Base : public RC<thread_unsafe_refcount>
42{
44
45 virtual void async_accept(ListenerBase *listener,
46 const size_t acceptor_index,
47 openvpn_io::io_context &io_context) = 0;
48 virtual void close() = 0;
49};
50
51struct Item
52{
54 {
57#ifdef OPENVPN_POLYSOCK_SUPPORTS_ALT_ROUTING
58 AltRouting,
59#endif
60 };
61
62 Item(Base::Ptr acceptor_arg,
63 const SSLMode ssl_mode_arg)
64 : acceptor(std::move(acceptor_arg)),
65 ssl_mode(ssl_mode_arg)
66 {
67 }
68
71};
72
73struct Set : public std::vector<Item>
74{
75 void close()
76 {
77 for (auto &i : *this)
78 i.acceptor->close();
79 }
80};
81
82} // namespace openvpn::Acceptor
#define OPENVPN_ACCEPTOR_LISTENER_BASE_RC
Definition base.hpp:29
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 void close()=0
RCPtr< Base > Ptr
Definition base.hpp:43
virtual void async_accept(ListenerBase *listener, const size_t acceptor_index, openvpn_io::io_context &io_context)=0
Item(Base::Ptr acceptor_arg, const SSLMode ssl_mode_arg)
Definition base.hpp:62
virtual void handle_accept(AsioPolySock::Base::Ptr sock, const openvpn_io::error_code &error)=0
RCPtr< ListenerBase > Ptr
Definition base.hpp:36