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