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#include <algorithm>
20
21#include <openvpn/io/io.hpp>
22
25#include <openvpn/common/rc.hpp>
28
29#ifndef OPENVPN_ACCEPTOR_LISTENER_BASE_RC
30#define OPENVPN_ACCEPTOR_LISTENER_BASE_RC RC<thread_unsafe_refcount>
31#endif
32
34
36{
38
39 virtual void handle_accept(AsioPolySock::Base::Ptr sock, const openvpn_io::error_code &error) = 0;
40};
41
42struct Base : RC<thread_unsafe_refcount>
43{
45
46 virtual void async_accept(ListenerBase *listener,
47 const size_t acceptor_index,
48 openvpn_io::io_context &io_context) = 0;
49 virtual void close() = 0;
50};
51
52struct Item
53{
55 {
58#ifdef OPENVPN_POLYSOCK_SUPPORTS_ALT_ROUTING
59 AltRouting,
60#endif
61 };
62
63 Item(Base::Ptr acceptor_arg,
64 const SSLMode ssl_mode_arg)
65 : acceptor(std::move(acceptor_arg)),
66 ssl_mode(ssl_mode_arg)
67 {
68 }
69
72};
73
74struct Set : std::vector<Item>
75{
76 void close()
77 {
78 std::ranges::for_each(*this, [](const auto &i)
79 { i.acceptor->close(); });
80 }
81};
82
83} // namespace openvpn::Acceptor
#define OPENVPN_ACCEPTOR_LISTENER_BASE_RC
Definition base.hpp:30
The smart pointer class.
Definition rc.hpp:119
Reference count base class for objects tracked by RCPtr. Disallows copying and assignment.
Definition rc.hpp:908
virtual void close()=0
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:63
virtual void handle_accept(AsioPolySock::Base::Ptr sock, const openvpn_io::error_code &error)=0