mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-04-24 00:00:05 +08:00
f65d76170b
git-subtree-dir: OpenVPN Adapter/Vendors/openvpn git-subtree-split: da99df69492256d7a18bbea303ae98457782a4bf
92 lines
3.1 KiB
C++
92 lines
3.1 KiB
C++
// OpenVPN -- An application to securely tunnel IP networks
|
|
// over a single port, with support for SSL/TLS-based
|
|
// session authentication and key exchange,
|
|
// packet encryption, packet authentication, and
|
|
// packet compression.
|
|
//
|
|
// Copyright (C) 2012-2017 OpenVPN Technologies, Inc.
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License Version 3
|
|
// as published by the Free Software Foundation.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program in the COPYING file.
|
|
// If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
// Abstract base classes for server tun objects
|
|
|
|
#ifndef OPENVPN_TUN_SERVER_TUNBASE_H
|
|
#define OPENVPN_TUN_SERVER_TUNBASE_H
|
|
|
|
#include <string>
|
|
|
|
#include <openvpn/common/exception.hpp>
|
|
#include <openvpn/common/rc.hpp>
|
|
#include <openvpn/buffer/buffer.hpp>
|
|
#include <openvpn/server/servhalt.hpp>
|
|
#include <openvpn/addr/route.hpp>
|
|
|
|
namespace openvpn {
|
|
|
|
// Base class for the client instance receiver. Note that all
|
|
// client instance receivers (transport, routing, management,
|
|
// etc.) must inherit virtually from RC because the client instance
|
|
// object will inherit from multiple receivers.
|
|
struct TunClientInstanceRecv : public virtual RC<thread_unsafe_refcount>
|
|
{
|
|
typedef RCPtr<TunClientInstanceRecv> Ptr;
|
|
|
|
//virtual bool defined() const = 0;
|
|
virtual void stop() = 0;
|
|
|
|
// Called with IP packets from tun layer.
|
|
virtual void tun_recv(BufferAllocated& buf) = 0;
|
|
|
|
// push a halt or restart message to client
|
|
virtual void push_halt_restart_msg(const HaltRestart::Type type,
|
|
const std::string& reason,
|
|
const bool tell_client) = 0;
|
|
};
|
|
|
|
// Base class for the per-client-instance state of the TunServer.
|
|
// Each client instance uses this class to send data to the tun layer.
|
|
struct TunClientInstanceSend : public virtual RC<thread_unsafe_refcount>
|
|
{
|
|
typedef RCPtr<TunClientInstanceSend> Ptr;
|
|
|
|
//virtual bool defined() const = 0;
|
|
virtual void stop() = 0;
|
|
|
|
virtual bool tun_send_const(const Buffer& buf) = 0;
|
|
virtual bool tun_send(BufferAllocated& buf) = 0;
|
|
|
|
// add routes
|
|
virtual void add_routes(const std::vector<IP::Route>& rtvec) = 0;
|
|
|
|
// set fwmark
|
|
virtual void set_fwmark(const unsigned int fwmark) = 0;
|
|
|
|
// set up relay to target
|
|
virtual void relay(const IP::Addr& target, const int port) = 0;
|
|
|
|
virtual const std::string& tun_info() const = 0;
|
|
};
|
|
|
|
// Factory for server tun object.
|
|
struct TunClientInstanceFactory : public RC<thread_unsafe_refcount>
|
|
{
|
|
typedef RCPtr<TunClientInstanceFactory> Ptr;
|
|
|
|
virtual TunClientInstanceSend::Ptr new_obj(TunClientInstanceRecv* parent) = 0;
|
|
};
|
|
|
|
} // namespace openvpn
|
|
|
|
#endif
|