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-2023 Arne Schwabe <arne@rfc2549.org>
9  * Copyright (C) 2021-2023 Antonio Quartulli <a@unstable.cc>
10  * Copyright (C) 2021-2023 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, write to the Free Software Foundation, Inc.,
24  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  */
26 #ifndef DCO_H
27 #define DCO_H
28 
29 #include "buffer.h"
30 #include "error.h"
31 #include "dco_internal.h"
32 #include "networking.h"
33 
34 /* forward declarations (including other headers leads to nasty include
35  * order problems)
36  */
37 struct event_set;
38 struct key2;
39 struct key_state;
40 struct multi_context;
41 struct multi_instance;
42 struct mroute_addr;
43 struct options;
44 struct tls_multi;
45 struct tuntap;
46 
47 #define DCO_IROUTE_METRIC 100
48 #define DCO_DEFAULT_METRIC 200
49 
50 #if defined(ENABLE_DCO)
51 
59 bool dco_available(int msglevel);
60 
61 
68 const char *dco_version_string(struct gc_arena *gc);
69 
79 bool dco_check_option(int msglevel, const struct options *o);
80 
91 bool dco_check_startup_option(int msglevel, const struct options *o);
92 
102 bool dco_check_pull_options(int msglevel, const struct options *o);
103 
111 bool ovpn_dco_init(int mode, dco_context_t *dco);
112 
121 int open_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx, const char *dev);
122 
129 void close_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx);
130 
138 
142 void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg);
143 
158 int init_key_dco_bi(struct tls_multi *multi, struct key_state *ks,
159  const struct key2 *key2, int key_direction,
160  const char *ciphername, bool server);
161 
171 bool dco_update_keys(dco_context_t *dco, struct tls_multi *multi);
178 int dco_p2p_add_new_peer(struct context *c);
179 
192 int dco_set_peer(dco_context_t *dco, unsigned int peerid,
193  int keepalive_interval, int keepalive_timeout, int mss);
194 
200 void dco_remove_peer(struct context *c);
201 
209 int dco_multi_add_new_peer(struct multi_context *m, struct multi_instance *mi);
210 
219 void dco_install_iroute(struct multi_context *m, struct multi_instance *mi,
220  struct mroute_addr *addr);
221 
228 void dco_delete_iroutes(struct multi_context *m, struct multi_instance *mi);
229 
237 
243 int dco_get_peer_stats(struct context *c);
244 
250 const char *dco_get_supported_ciphers();
251 
252 #else /* if defined(ENABLE_DCO) */
253 
254 typedef void *dco_context_t;
255 
256 static inline bool
257 dco_available(int msglevel)
258 {
259  return false;
260 }
261 
262 static inline const char *
264 {
265  return "not-compiled";
266 }
267 
268 static inline bool
269 dco_check_option(int msglevel, const struct options *o)
270 {
271  return false;
272 }
273 
274 static inline bool
275 dco_check_startup_option(int msglevel, const struct options *o)
276 {
277  return false;
278 }
279 
280 static inline bool
281 dco_check_pull_options(int msglevel, const struct options *o)
282 {
283  return false;
284 }
285 
286 static inline bool
288 {
289  return true;
290 }
291 
292 static inline int
293 open_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx, const char *dev)
294 {
295  return 0;
296 }
297 
298 static inline void
300 {
301 }
302 
303 static inline int
305 {
306  ASSERT(false);
307  return 0;
308 }
309 
310 static inline void
312 {
313 }
314 
315 static inline int
316 init_key_dco_bi(struct tls_multi *multi, struct key_state *ks,
317  const struct key2 *key2, int key_direction,
318  const char *ciphername, bool server)
319 {
320  return 0;
321 }
322 
323 static inline bool
325 {
326  ASSERT(false);
327  return false;
328 }
329 
330 static inline int
332 {
333  return 0;
334 }
335 
336 static inline int
337 dco_set_peer(dco_context_t *dco, unsigned int peerid,
338  int keepalive_interval, int keepalive_timeout, int mss)
339 {
340  return 0;
341 }
342 
343 static inline void
345 {
346 }
347 
348 static inline int
350 {
351  return 0;
352 }
353 
354 static inline void
356  struct mroute_addr *addr)
357 {
358 }
359 
360 static inline void
362 {
363 }
364 
365 static inline int
367 {
368  return 0;
369 }
370 
371 static inline int
373 {
374  return 0;
375 }
376 
377 static inline const char *
379 {
380  return "";
381 }
382 
383 #endif /* defined(ENABLE_DCO) */
384 #endif /* ifndef DCO_H */
dco_check_option
static bool dco_check_option(int msglevel, const struct options *o)
Definition: dco.h:269
multi_instance
Server-mode state structure for one single VPN tunnel.
Definition: multi.h:101
error.h
networking.h
dco_do_read
static int dco_do_read(dco_context_t *dco)
Definition: dco.h:304
dco_available
static bool dco_available(int msglevel)
Definition: dco.h:257
context
Contains all state information for one tunnel.
Definition: openvpn.h:476
es
struct env_set * es
Definition: test_pkcs11.c:133
dco_internal.h
close_tun_dco
static void close_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx)
Definition: dco.h:299
openvpn_net_ctx_t
void * openvpn_net_ctx_t
Definition: networking.h:28
tls_multi
Security parameter state for a single VPN tunnel.
Definition: ssl_common.h:587
key_state
Security parameter state of one TLS and data channel key session.
Definition: ssl_common.h:195
ASSERT
#define ASSERT(x)
Definition: error.h:201
open_tun_dco
static int open_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx, const char *dev)
Definition: dco.h:293
options
Definition: options.h:236
dco_context_t
void * dco_context_t
Definition: dco.h:254
dco_p2p_add_new_peer
static int dco_p2p_add_new_peer(struct context *c)
Definition: dco.h:331
dco_remove_peer
static void dco_remove_peer(struct context *c)
Definition: dco.h:344
dco_delete_iroutes
static void dco_delete_iroutes(struct multi_context *m, struct multi_instance *mi)
Definition: dco.h:361
buffer.h
mroute_addr
Definition: mroute.h:75
dco_check_startup_option
static bool dco_check_startup_option(int msglevel, const struct options *o)
Definition: dco.h:275
gc_arena
Garbage collection arena used to keep track of dynamically allocated memory.
Definition: buffer.h:116
multi_context
Main OpenVPN server state structure.
Definition: multi.h:155
dco_event_set
static void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg)
Definition: dco.h:311
event_set
Definition: event.h:124
dco_update_keys
static bool dco_update_keys(dco_context_t *dco, struct tls_multi *multi)
Definition: dco.h:324
dco_version_string
static const char * dco_version_string(struct gc_arena *gc)
Definition: dco.h:263
tuntap::dco
dco_context_t dco
Definition: tun.h:234
tuntap
Definition: tun.h:171
dco_set_peer
static int dco_set_peer(dco_context_t *dco, unsigned int peerid, int keepalive_interval, int keepalive_timeout, int mss)
Definition: dco.h:337
dco_get_peer_stats_multi
static int dco_get_peer_stats_multi(dco_context_t *dco, struct multi_context *m)
Definition: dco.h:366
init_key_dco_bi
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:316
key2
Container for bidirectional cipher and HMAC key material.
Definition: crypto.h:179
dco_get_supported_ciphers
static const char * dco_get_supported_ciphers()
Definition: dco.h:378
dco_multi_add_new_peer
static int dco_multi_add_new_peer(struct multi_context *m, struct multi_instance *mi)
Definition: dco.h:349
ovpn_dco_init
static bool ovpn_dco_init(int mode, dco_context_t *dco)
Definition: dco.h:287
dco_get_peer_stats
static int dco_get_peer_stats(struct context *c)
Definition: dco.h:372
dco_install_iroute
static void dco_install_iroute(struct multi_context *m, struct multi_instance *mi, struct mroute_addr *addr)
Definition: dco.h:355
dco_check_pull_options
static bool dco_check_pull_options(int msglevel, const struct options *o)
Definition: dco.h:281