OpenVPN
dco.h
Go to the documentation of this file.
1/*
2 * OpenVPN -- An application to securely tunnel IP networks
3 * over a single TCP/UDP port, with support for SSL/TLS-based
4 * session authentication and key exchange,
5 * packet encryption, packet authentication, and
6 * packet compression.
7 *
8 * Copyright (C) 2021-2025 Arne Schwabe <arne@rfc2549.org>
9 * Copyright (C) 2021-2025 Antonio Quartulli <a@unstable.cc>
10 * Copyright (C) 2021-2025 OpenVPN Inc <sales@openvpn.net>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2
14 * as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program (see the file COPYING included with this
23 * distribution); if not, see <https://www.gnu.org/licenses/>.
24 */
25#ifndef DCO_H
26#define DCO_H
27
28#include "buffer.h"
29#include "error.h"
30#include "dco_internal.h"
31#include "networking.h"
32
33/* forward declarations (including other headers leads to nasty include
34 * order problems)
35 */
36struct event_set;
37struct key2;
38struct key_state;
39struct multi_context;
40struct multi_instance;
41struct mroute_addr;
42struct options;
43struct tls_multi;
44struct tuntap;
45
46#define DCO_IROUTE_METRIC 100
47#define DCO_DEFAULT_METRIC 200
48
49#if defined(ENABLE_DCO)
50
58bool dco_available(int msglevel);
59
60
67const char *dco_version_string(struct gc_arena *gc);
68
78bool dco_check_option(int msglevel, const struct options *o);
79
90bool dco_check_startup_option(int msglevel, const struct options *o);
91
101bool dco_check_pull_options(int msglevel, const struct options *o);
102
109bool ovpn_dco_init(struct context *c);
110
119int open_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx, const char *dev);
120
127void close_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx);
128
136
140void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg);
141
156int init_key_dco_bi(struct tls_multi *multi, struct key_state *ks, const struct key2 *key2,
157 int key_direction, const char *ciphername, bool server);
158
168bool dco_update_keys(dco_context_t *dco, struct tls_multi *multi);
175int dco_p2p_add_new_peer(struct context *c);
176
189int dco_set_peer(dco_context_t *dco, unsigned int peerid, int keepalive_interval,
190 int keepalive_timeout, int mss);
191
197void dco_remove_peer(struct context *c);
198
206int dco_multi_add_new_peer(struct multi_context *m, struct multi_instance *mi);
207
216void dco_install_iroute(struct multi_context *m, struct multi_instance *mi,
217 struct mroute_addr *addr);
218
225void dco_delete_iroutes(struct multi_context *m, struct multi_instance *mi);
226
233int dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err);
234
241int dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err);
242
248const char *dco_get_supported_ciphers(void);
249
254static inline bool
256{
257 return false;
258}
259#else /* if defined(ENABLE_DCO) */
260
261typedef void *dco_context_t;
262
263static inline bool
264dco_available(int msglevel)
265{
266 return false;
267}
268
269static inline const char *
271{
272 return "not-compiled";
273}
274
275static inline bool
276dco_check_option(int msglevel, const struct options *o)
277{
278 return false;
279}
280
281static inline bool
282dco_check_startup_option(int msglevel, const struct options *o)
283{
284 return false;
285}
286
287static inline bool
288dco_check_pull_options(int msglevel, const struct options *o)
289{
290 return false;
291}
292
293static inline bool
295{
296 return true;
297}
298
299static inline int
300open_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx, const char *dev)
301{
302 return 0;
303}
304
305static inline void
307{
308}
309
310static inline int
312{
313 ASSERT(false);
314 return 0;
315}
316
317static inline void
319{
320}
321
322static inline int
323init_key_dco_bi(struct tls_multi *multi, struct key_state *ks, const struct key2 *key2,
324 int key_direction, const char *ciphername, bool server)
325{
326 return 0;
327}
328
329static inline bool
331{
332 ASSERT(false);
333 return false;
334}
335
336static inline int
338{
339 return 0;
340}
341
342static inline int
343dco_set_peer(dco_context_t *dco, unsigned int peerid, int keepalive_interval, int keepalive_timeout,
344 int mss)
345{
346 return 0;
347}
348
349static inline void
351{
352}
353
354static inline int
356{
357 return 0;
358}
359
360static inline void
361dco_install_iroute(struct multi_context *m, struct multi_instance *mi, struct mroute_addr *addr)
362{
363}
364
365static inline void
367{
368}
369
370static inline int
371dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err)
372{
373 return 0;
374}
375
376static inline int
377dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err)
378{
379 return 0;
380}
381
382static inline const char *
384{
385 return "";
386}
387
388static inline bool
390{
391 return false;
392}
393#endif /* defined(ENABLE_DCO) */
394#endif /* ifndef DCO_H */
static bool dco_available(int msglevel)
Definition dco.h:264
static int dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err)
Definition dco.h:371
static int dco_set_peer(dco_context_t *dco, unsigned int peerid, int keepalive_interval, int keepalive_timeout, int mss)
Definition dco.h:343
static const char * dco_get_supported_ciphers(void)
Definition dco.h:383
static bool dco_supports_epoch_data(struct context *c)
Definition dco.h:389
static int dco_do_read(dco_context_t *dco)
Definition dco.h:311
static void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg)
Definition dco.h:318
static void dco_remove_peer(struct context *c)
Definition dco.h:350
static int open_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx, const char *dev)
Definition dco.h:300
static void dco_install_iroute(struct multi_context *m, struct multi_instance *mi, struct mroute_addr *addr)
Definition dco.h:361
static bool ovpn_dco_init(struct context *c)
Definition dco.h:294
static bool dco_check_startup_option(int msglevel, const struct options *o)
Definition dco.h:282
static int dco_p2p_add_new_peer(struct context *c)
Definition dco.h:337
static bool dco_check_option(int msglevel, const struct options *o)
Definition dco.h:276
static bool dco_update_keys(dco_context_t *dco, struct tls_multi *multi)
Definition dco.h:330
void * dco_context_t
Definition dco.h:261
static const char * dco_version_string(struct gc_arena *gc)
Definition dco.h:270
static int dco_multi_add_new_peer(struct multi_context *m, struct multi_instance *mi)
Definition dco.h:355
static void close_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx)
Definition dco.h:306
static void dco_delete_iroutes(struct multi_context *m, struct multi_instance *mi)
Definition dco.h:366
static int dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err)
Definition dco.h:377
static bool dco_check_pull_options(int msglevel, const struct options *o)
Definition dco.h:288
static int init_key_dco_bi(struct tls_multi *multi, struct key_state *ks, const struct key2 *key2, int key_direction, const char *ciphername, bool server)
Definition dco.h:323
void * openvpn_net_ctx_t
Definition networking.h:38
#define ASSERT(x)
Definition error.h:217
Contains all state information for one tunnel.
Definition openvpn.h:474
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:116
Container for bidirectional cipher and HMAC key material.
Definition crypto.h:240
Security parameter state of one TLS and data channel key session.
Definition ssl_common.h:208
Main OpenVPN server state structure.
Definition multi.h:164
Server-mode state structure for one single VPN tunnel.
Definition multi.h:103
Security parameter state for a single VPN tunnel.
Definition ssl_common.h:612
Definition tun.h:183
dco_context_t dco
Definition tun.h:249
struct env_set * es
struct gc_arena gc
Definition test_ssl.c:154