OpenVPN 3 Core Library
Loading...
Searching...
No Matches
setupbase.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
13// Client tun setup base class for Windows
14
15#ifndef OPENVPN_TUN_WIN_CLIENT_SETUPBASE_H
16#define OPENVPN_TUN_WIN_CLIENT_SETUPBASE_H
17
18#include <windows.h> // for HANDLE
19
20#include <functional>
21
22#include <openvpn/io/io.hpp>
23
29
30namespace openvpn::TunWin {
31
33{
35
36 OPENVPN_EXCEPTION(tun_win_setup);
37
38 virtual HANDLE get_handle(std::ostream &os) = 0;
39
40 // clang-format off
41 virtual HANDLE establish(const TunBuilderCapture &pull,
42 const std::wstring &openvpn_app_path,
43 Stop *stop,
44 std::ostream &os,
45 RingBuffer::Ptr rings) = 0;
46 // clang-format on
47
48 virtual bool l2_ready(const TunBuilderCapture &pull) = 0;
49
50 // clang-format off
51 virtual void l2_finish(const TunBuilderCapture &pull,
52 Stop *stop,
53 std::ostream &os) = 0;
54 // clang-format on
55
56 virtual void confirm()
57 {
58 }
59
60 virtual void set_service_fail_handler(std::function<void()> &&handler)
61 {
62 }
63
65
66 virtual void set_adapter_state(const Util::TapNameGuidPair &state) = 0;
67
68 virtual DWORD vpn_interface_index() const
69 {
71 }
72};
73
74struct SetupFactory : public RC<thread_unsafe_refcount>
75{
77
78 // clang-format off
79 virtual SetupBase::Ptr new_setup_obj(openvpn_io::io_context &io_context,
80 const TunWin::Type tun_type,
81 bool allow_local_dns_resolvers) = 0;
82 // clang-format on
83};
84} // namespace openvpn::TunWin
85
86#endif
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
static void handler(int signum)
Definition cli.cpp:961
DNS utilities for Windows.
constexpr std::uint32_t INVALID_ADAPTER_INDEX
Definition tunbase.hpp:29
virtual bool l2_ready(const TunBuilderCapture &pull)=0
virtual void set_adapter_state(const Util::TapNameGuidPair &state)=0
virtual HANDLE establish(const TunBuilderCapture &pull, const std::wstring &openvpn_app_path, Stop *stop, std::ostream &os, RingBuffer::Ptr rings)=0
virtual HANDLE get_handle(std::ostream &os)=0
OPENVPN_EXCEPTION(tun_win_setup)
virtual Util::TapNameGuidPair get_adapter_state()=0
virtual void l2_finish(const TunBuilderCapture &pull, Stop *stop, std::ostream &os)=0
RCPtr< SetupBase > Ptr
Definition setupbase.hpp:34
virtual DWORD vpn_interface_index() const
Definition setupbase.hpp:68
virtual void set_service_fail_handler(std::function< void()> &&handler)
Definition setupbase.hpp:60
virtual SetupBase::Ptr new_setup_obj(openvpn_io::io_context &io_context, const TunWin::Type tun_type, bool allow_local_dns_resolvers)=0
RCPtr< SetupFactory > Ptr
Definition setupbase.hpp:76
std::ostringstream os