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#ifndef OPENVPN_TUN_BUILDER_BASE_H
13#define OPENVPN_TUN_BUILDER_BASE_H
14
15#include <string>
16
17#ifdef ENABLE_OVPNDCO
18#include <openvpn/dco/key.hpp>
19#endif
20
21#include <openvpn/addr/ip.hpp>
23
24namespace openvpn {
25
42{
43 public:
50 virtual bool tun_builder_new()
51 {
52 return false;
53 }
54
67 virtual bool tun_builder_set_layer(int layer)
68 {
69 return true;
70 }
71
83 virtual bool tun_builder_set_remote_address(const std::string &address, bool ipv6)
84 {
85 return false;
86 }
87
101 virtual bool tun_builder_add_address(const std::string &address,
102 int prefix_length,
103 const std::string &gateway, // optional
104 bool ipv6,
105 bool net30)
106 {
107 return false;
108 }
109
123 {
124 return true;
125 }
126
139 virtual bool tun_builder_reroute_gw(bool ipv4,
140 bool ipv6,
141 unsigned int flags)
142 {
143 return false;
144 }
145
158 virtual bool tun_builder_add_route(const std::string &address,
159 int prefix_length,
160 int metric,
161 bool ipv6)
162 {
163 return false;
164 }
165
178 virtual bool tun_builder_exclude_route(const std::string &address,
179 int prefix_length,
180 int metric,
181 bool ipv6)
182 {
183 return false;
184 }
185
196 {
197 return false;
198 }
199
211 virtual bool tun_builder_set_mtu(int mtu)
212 {
213 return false;
214 }
215
226 virtual bool tun_builder_set_session_name(const std::string &name)
227 {
228 return false;
229 }
230
240 virtual bool tun_builder_add_proxy_bypass(const std::string &bypass_host)
241 {
242 return false;
243 }
244
255 virtual bool tun_builder_set_proxy_auto_config_url(const std::string &url)
256 {
257 return false;
258 }
259
271 virtual bool tun_builder_set_proxy_http(const std::string &host, int port)
272 {
273 return false;
274 }
275
287 virtual bool tun_builder_set_proxy_https(const std::string &host, int port)
288 {
289 return false;
290 }
291
305 virtual bool tun_builder_add_wins_server(const std::string &address)
306 {
307 return false;
308 }
309
329 virtual bool tun_builder_set_allow_family(int af, bool allow)
330 {
331 return true;
332 }
333
347 virtual bool tun_builder_set_allow_local_dns(bool allow)
348 {
349 return true;
350 }
351
362 {
363 return -1;
364 }
365
379 virtual bool tun_builder_persist()
380 {
381 return true;
382 }
383
395 virtual std::vector<std::string> tun_builder_get_local_networks(bool ipv6)
396 {
397 return {};
398 }
399
407 {
408 }
409
417 virtual void tun_builder_teardown(bool disconnect)
418 {
419 }
425 virtual ~TunBuilderBase() = default;
426
427#ifdef ENABLE_OVPNDCO
433 virtual bool tun_builder_dco_available()
434 {
435 return false;
436 }
437
444 virtual int tun_builder_dco_enable(const std::string &dev_name)
445 {
446 return -1;
447 }
448
459 virtual void tun_builder_dco_new_peer(uint32_t peer_id,
460 uint32_t transport_fd,
461 struct sockaddr *sa,
462 socklen_t salen,
463 IPv4::Addr &vpn4,
464 IPv6::Addr &vpn6)
465 {
466 }
467
475 virtual void tun_builder_dco_set_peer(uint32_t peer_id, int keepalive_interval, int keepalive_timeout)
476 {
477 }
478
485 virtual void tun_builder_dco_del_peer(uint32_t peer_id)
486 {
487 }
488
496 virtual void tun_builder_dco_get_peer(uint32_t peer_id, bool sync)
497 {
498 }
499
506 virtual void tun_builder_dco_new_key(unsigned int key_slot, const KoRekey::KeyConfig *kc)
507 {
508 }
509
516 virtual void tun_builder_dco_swap_keys(uint32_t peer_id)
517 {
518 }
519
526 virtual void tun_builder_dco_del_key(uint32_t peer_id, unsigned int key_slot)
527 {
528 }
529
535 virtual void tun_builder_dco_establish()
536 {
537 }
538#endif // ENABLE_OVPNDCO
539};
540} // namespace openvpn
541
542#endif
TunBuilder methods, loosely based on the Android VpnService.Builder abstraction.
Definition base.hpp:42
virtual bool tun_builder_set_dns_options(const DnsOptions &dns)
Callback to set DNS related options to VPN interface.
Definition base.hpp:195
virtual bool tun_builder_add_address(const std::string &address, int prefix_length, const std::string &gateway, bool ipv6, bool net30)
Callback to add a network address to the VPN interface.
Definition base.hpp:101
virtual bool tun_builder_add_route(const std::string &address, int prefix_length, int metric, bool ipv6)
Callback to add a route to the VPN interface.
Definition base.hpp:158
virtual ~TunBuilderBase()=default
Virtual destructor for the TunBuilderBase class.
virtual bool tun_builder_set_route_metric_default(int metric)
Optional callback to set default value for route metric.
Definition base.hpp:122
virtual void tun_builder_establish_lite()
Indicates a reconnection with persisted TUN state.
Definition base.hpp:406
virtual bool tun_builder_persist()
Determines if the TUN interface can be persisted.
Definition base.hpp:379
virtual void tun_builder_teardown(bool disconnect)
Indicates that tunnel is being torn down.
Definition base.hpp:417
virtual bool tun_builder_set_proxy_http(const std::string &host, int port)
Callback to set the HTTP proxy.
Definition base.hpp:271
virtual bool tun_builder_reroute_gw(bool ipv4, bool ipv6, unsigned int flags)
Callback to reroute the default gateway to the VPN interface.
Definition base.hpp:139
virtual int tun_builder_establish()
Callback to establish the VPN tunnel.
Definition base.hpp:361
virtual bool tun_builder_add_wins_server(const std::string &address)
Callback to add a Windows WINS server to the VPN interface.
Definition base.hpp:305
virtual bool tun_builder_set_layer(int layer)
Optional callback that indicates OSI layer to be used.
Definition base.hpp:67
virtual std::vector< std::string > tun_builder_get_local_networks(bool ipv6)
Retrieves a list of local networks to exclude from the VPN network.
Definition base.hpp:395
virtual bool tun_builder_add_proxy_bypass(const std::string &bypass_host)
Callback to add a host which should bypass the proxy.
Definition base.hpp:240
virtual bool tun_builder_set_allow_family(int af, bool allow)
Indicates whether traffic of a certain address family (AF_INET or AF_INET6) should be blocked or allo...
Definition base.hpp:329
virtual bool tun_builder_set_proxy_https(const std::string &host, int port)
Set the HTTPS proxy for the TunBuilder session.
Definition base.hpp:287
virtual bool tun_builder_exclude_route(const std::string &address, int prefix_length, int metric, bool ipv6)
Callback to exclude route from VPN interface.
Definition base.hpp:178
virtual bool tun_builder_set_allow_local_dns(bool allow)
Optional callback that indicates whether local DNS traffic should be blocked or allowed to prevent DN...
Definition base.hpp:347
virtual bool tun_builder_set_mtu(int mtu)
Callback to set the MTU of the VPN interface.
Definition base.hpp:211
virtual bool tun_builder_set_remote_address(const std::string &address, bool ipv6)
Callback to set the address of the remote server.
Definition base.hpp:83
virtual bool tun_builder_set_proxy_auto_config_url(const std::string &url)
Callback to set the proxy "Auto Config URL".
Definition base.hpp:255
virtual bool tun_builder_set_session_name(const std::string &name)
Sets the session name for the TunBuilder.
Definition base.hpp:226
virtual bool tun_builder_new()
Callback to construct a new TunBuilder. This function should be called first.
Definition base.hpp:50
Support deferred server-side state creation when client connects.
Definition ovpncli.cpp:95
All DNS options set with the –dns or –dhcp-option directive.
reroute_gw flags
proxy_host_port port
proxy_autoconfig_url url
remote_address ipv6
proxy_bypass bypass_host
proxy_host_port host
remote_address address
reroute_gw ipv4