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(msglvl_t msglevel);
59
60
67const char *dco_version_string(struct gc_arena *gc);
68
78bool dco_check_option(msglvl_t msglevel, const struct options *o);
79
90bool dco_check_startup_option(msglvl_t msglevel, const struct options *o);
91
101bool dco_check_pull_options(msglvl_t 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
254bool
256#else /* if defined(ENABLE_DCO) */
257
258typedef void *dco_context_t;
259
260static inline bool
262{
263 return false;
264}
265
266static inline const char *
268{
269 return "not-compiled";
270}
271
272static inline bool
273dco_check_option(msglvl_t msglevel, const struct options *o)
274{
275 return false;
276}
277
278static inline bool
279dco_check_startup_option(msglvl_t msglevel, const struct options *o)
280{
281 return false;
282}
283
284static inline bool
285dco_check_pull_options(msglvl_t msglevel, const struct options *o)
286{
287 return false;
288}
289
290static inline bool
292{
293 return true;
294}
295
296static inline int
297open_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx, const char *dev)
298{
299 return 0;
300}
301
302static inline void
304{
305}
306
307static inline int
309{
310 ASSERT(false);
311 return 0;
312}
313
314static inline void
316{
317}
318
319static inline int
320init_key_dco_bi(struct tls_multi *multi, struct key_state *ks, const struct key2 *key2,
321 int key_direction, const char *ciphername, bool server)
322{
323 return 0;
324}
325
326static inline bool
328{
329 ASSERT(false);
330 return false;
331}
332
333static inline int
335{
336 return 0;
337}
338
339static inline int
340dco_set_peer(dco_context_t *dco, unsigned int peerid, int keepalive_interval, int keepalive_timeout,
341 int mss)
342{
343 return 0;
344}
345
346static inline void
348{
349}
350
351static inline int
353{
354 return 0;
355}
356
357static inline void
358dco_install_iroute(struct multi_context *m, struct multi_instance *mi, struct mroute_addr *addr)
359{
360}
361
362static inline void
364{
365}
366
367static inline int
368dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err)
369{
370 return 0;
371}
372
373static inline int
374dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err)
375{
376 return 0;
377}
378
379static inline const char *
381{
382 return "";
383}
384
385static inline bool
387{
388 return false;
389}
390#endif /* defined(ENABLE_DCO) */
391#endif /* ifndef DCO_H */
static int dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err)
Definition dco.h:368
static int dco_set_peer(dco_context_t *dco, unsigned int peerid, int keepalive_interval, int keepalive_timeout, int mss)
Definition dco.h:340
static const char * dco_get_supported_ciphers(void)
Definition dco.h:380
static bool dco_supports_epoch_data(struct context *c)
Definition dco.h:386
static int dco_do_read(dco_context_t *dco)
Definition dco.h:308
static void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg)
Definition dco.h:315
static void dco_remove_peer(struct context *c)
Definition dco.h:347
static int open_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx, const char *dev)
Definition dco.h:297
static bool dco_check_startup_option(msglvl_t msglevel, const struct options *o)
Definition dco.h:279
static void dco_install_iroute(struct multi_context *m, struct multi_instance *mi, struct mroute_addr *addr)
Definition dco.h:358
static bool dco_check_pull_options(msglvl_t msglevel, const struct options *o)
Definition dco.h:285
static bool dco_available(msglvl_t msglevel)
Definition dco.h:261
static bool ovpn_dco_init(struct context *c)
Definition dco.h:291
static int dco_p2p_add_new_peer(struct context *c)
Definition dco.h:334
static bool dco_check_option(msglvl_t msglevel, const struct options *o)
Definition dco.h:273
static bool dco_update_keys(dco_context_t *dco, struct tls_multi *multi)
Definition dco.h:327
void * dco_context_t
Definition dco.h:258
static const char * dco_version_string(struct gc_arena *gc)
Definition dco.h:267
static int dco_multi_add_new_peer(struct multi_context *m, struct multi_instance *mi)
Definition dco.h:352
static void close_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx)
Definition dco.h:303
static void dco_delete_iroutes(struct multi_context *m, struct multi_instance *mi)
Definition dco.h:363
static int dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err)
Definition dco.h:374
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:320
void * openvpn_net_ctx_t
Definition networking.h:38
unsigned int msglvl_t
Definition error.h:77
#define ASSERT(x)
Definition error.h:219
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:131