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-2026 Arne Schwabe <arne@rfc2549.org>
9 * Copyright (C) 2021-2026 Antonio Quartulli <a@unstable.cc>
10 * Copyright (C) 2021-2026 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
137
141void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg);
142
157int init_key_dco_bi(struct tls_multi *multi, struct key_state *ks, const struct key2 *key2,
158 int key_direction, const char *ciphername, bool server);
159
169bool dco_update_keys(dco_context_t *dco, struct tls_multi *multi);
176int dco_p2p_add_new_peer(struct context *c);
177
190int dco_set_peer(dco_context_t *dco, unsigned int peerid, int keepalive_interval,
191 int keepalive_timeout, int mss);
192
198void dco_remove_peer(struct context *c);
199
207int dco_multi_add_new_peer(const struct multi_context *m, struct multi_instance *mi);
208
217void dco_install_iroute(struct multi_context *m, struct multi_instance *mi,
218 const struct mroute_addr *addr);
219
226void dco_delete_iroutes(openvpn_net_ctx_t *net_ctx, const struct context *c);
227
234int dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err);
235
242int dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err);
243
249const char *dco_get_supported_ciphers(void);
250
255bool
256dco_supports_epoch_data(const struct context *c);
257
267unsigned int dco_probe_capabilities(void);
268#else /* if defined(ENABLE_DCO) */
269
270typedef void *dco_context_t;
271
272static inline bool
274{
275 return false;
276}
277
278static inline const char *
280{
281 return "not-compiled";
282}
283
284static inline bool
285dco_check_option(msglvl_t msglevel, const struct options *o)
286{
287 return false;
288}
289
290static inline bool
291dco_check_startup_option(msglvl_t msglevel, const struct options *o)
292{
293 return false;
294}
295
296static inline bool
297dco_check_pull_options(msglvl_t msglevel, const struct options *o)
298{
299 return false;
300}
301
302static inline bool
304{
305 return true;
306}
307
308static inline int
309open_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx, const char *dev)
310{
311 return 0;
312}
313
314static inline void
316{
317}
318
319static inline int
321{
322 ASSERT(false);
323 return 0;
324}
325
326static inline void
327dco_event_set(dco_context_t *dco, struct event_set *es, void *arg)
328{
329}
330
331static inline int
332init_key_dco_bi(struct tls_multi *multi, struct key_state *ks, const struct key2 *key2,
333 int key_direction, const char *ciphername, bool server)
334{
335 return 0;
336}
337
338static inline bool
340{
341 ASSERT(false);
342 return false;
343}
344
345static inline int
347{
348 return 0;
349}
350
351static inline int
352dco_set_peer(dco_context_t *dco, unsigned int peerid, int keepalive_interval, int keepalive_timeout,
353 int mss)
354{
355 return 0;
356}
357
358static inline void
360{
361}
362
363static inline int
365{
366 return 0;
367}
368
369static inline void
370dco_install_iroute(struct multi_context *m, struct multi_instance *mi, struct mroute_addr *addr)
371{
372}
373
374static inline void
376{
377}
378
379static inline int
380dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err)
381{
382 return 0;
383}
384
385static inline int
386dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err)
387{
388 return 0;
389}
390
391static inline const char *
393{
394 return "";
395}
396
397static inline bool
399{
400 return false;
401}
402
403static inline unsigned int
405{
406 return 0;
407}
408#endif /* defined(ENABLE_DCO) */
409#endif /* ifndef DCO_H */
Buffer management functions and garbage collection.
static int dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err)
Definition dco.h:380
static int dco_set_peer(dco_context_t *dco, unsigned int peerid, int keepalive_interval, int keepalive_timeout, int mss)
Definition dco.h:352
static const char * dco_get_supported_ciphers(void)
Definition dco.h:392
static void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg)
Definition dco.h:327
static void dco_remove_peer(struct context *c)
Definition dco.h:359
static int open_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx, const char *dev)
Definition dco.h:309
static void dco_delete_iroutes(openvpn_net_ctx_t *net_ctx, const struct context *c)
Definition dco.h:375
static int dco_read_and_process(dco_context_t *dco)
Definition dco.h:320
static bool dco_check_startup_option(msglvl_t msglevel, const struct options *o)
Definition dco.h:291
static void dco_install_iroute(struct multi_context *m, struct multi_instance *mi, struct mroute_addr *addr)
Definition dco.h:370
static bool dco_supports_epoch_data(const struct context *c)
Definition dco.h:398
static bool dco_check_pull_options(msglvl_t msglevel, const struct options *o)
Definition dco.h:297
static bool dco_available(msglvl_t msglevel)
Definition dco.h:273
static bool ovpn_dco_init(struct context *c)
Definition dco.h:303
static int dco_p2p_add_new_peer(struct context *c)
Definition dco.h:346
static bool dco_check_option(msglvl_t msglevel, const struct options *o)
Definition dco.h:285
static bool dco_update_keys(dco_context_t *dco, struct tls_multi *multi)
Definition dco.h:339
void * dco_context_t
Definition dco.h:270
static const char * dco_version_string(struct gc_arena *gc)
Definition dco.h:279
static void close_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx)
Definition dco.h:315
static int dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err)
Definition dco.h:386
static int dco_multi_add_new_peer(const struct multi_context *m, struct multi_instance *mi)
Definition dco.h:364
static unsigned int dco_probe_capabilities(void)
Definition dco.h:404
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:332
void * openvpn_net_ctx_t
Definition networking.h:41
unsigned int msglvl_t
Definition error.h:77
#define ASSERT(x)
Definition error.h:221
Contains all state information for one tunnel.
Definition openvpn.h:455
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:127
Container for bidirectional cipher and HMAC key material.
Definition crypto.h:233
Security parameter state of one TLS and data channel key session.
Definition ssl_common.h:208
Main OpenVPN server state structure.
Definition multi.h:170
Server-mode state structure for one single VPN tunnel.
Definition multi.h:102
Security parameter state for a single VPN tunnel.
Definition ssl_common.h:618
Definition tun.h:181
dco_context_t dco
Definition tun.h:247
struct gc_arena gc
Definition test_ssl.c:138