OpenVPN
multi_io.c
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) 2002-2025 OpenVPN Inc <sales@openvpn.net>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include "syshead.h"
28
29#include "memdbg.h"
30
31#include "multi.h"
32#include "forward.h"
33#include "multi_io.h"
34
35#ifdef HAVE_SYS_INOTIFY_H
36#include <sys/inotify.h>
37#endif
38
39/*
40 * Special tags passed to event.[ch] functions
41 */
42#define MULTI_IO_SOCKET ((void *)1)
43#define MULTI_IO_TUN ((void *)2)
44#define MULTI_IO_SIG ((void *)3) /* Only on Windows */
45#define MULTI_IO_MANAGEMENT ((void *)4)
46#define MULTI_IO_FILE_CLOSE_WRITE ((void *)5)
47#define MULTI_IO_DCO ((void *)6)
48
49struct ta_iow_flags
50{
51 unsigned int flags;
52 unsigned int ret;
53 unsigned int tun;
54 unsigned int sock;
55};
56
57#ifdef ENABLE_DEBUG
58static const char *
59pract(int action)
60{
61 switch (action)
62 {
63 case TA_UNDEF:
64 return "TA_UNDEF";
65
66 case TA_SOCKET_READ:
67 return "TA_SOCKET_READ";
68
70 return "TA_SOCKET_READ_RESIDUAL";
71
72 case TA_SOCKET_WRITE:
73 return "TA_SOCKET_WRITE";
74
76 return "TA_SOCKET_WRITE_READY";
77
79 return "TA_SOCKET_WRITE_DEFERRED";
80
81 case TA_TUN_READ:
82 return "TA_TUN_READ";
83
84 case TA_TUN_WRITE:
85 return "TA_TUN_WRITE";
86
87 case TA_INITIAL:
88 return "TA_INITIAL";
89
90 case TA_TIMEOUT:
91 return "TA_TIMEOUT";
92
94 return "TA_TUN_WRITE_TIMEOUT";
95
96 default:
97 return "?";
98 }
99}
100#endif /* ENABLE_DEBUG */
101
102static inline struct context *
104{
105 if (mi)
106 {
107 return &mi->context;
108 }
109 else
110 {
111 return &m->top;
112 }
113}
114
115struct multi_io *
116multi_io_init(const int maxclients)
117{
118 struct multi_io *multi_io;
119
120 ASSERT(maxclients >= 1);
121
123 multi_io->maxevents = maxclients + BASE_N_EVENTS;
127 msg(D_MULTI_LOW, "MULTI IO: MULTI_IO INIT maxclients=%d maxevents=%d", maxclients,
129 return multi_io;
130}
131
132void
134{
135 if (!mi)
136 {
137 return;
138 }
139
140 mi->socket_set_called = true;
142 {
144 &mi->context.c2.link_sockets[0]->ev_arg, NULL);
145 }
146 else
147 {
150 &mi->tcp_rwflags);
151 }
152}
153
154void
156{
157 if (multi_io)
158 {
160 free(multi_io->esr);
161 free(multi_io);
162 }
163}
164
165int
167{
168 int status, i;
169 unsigned int *persistent = &m->multi_io->tun_rwflags;
170
172 {
173 for (i = 0; i < m->top.c1.link_sockets_num; i++)
174 {
176 &m->top.c2.link_sockets[i]->ev_arg);
177 }
178 }
179
181 {
183 }
184
185 tun_set(m->top.c1.tuntap, m->multi_io->es, EVENT_READ, MULTI_IO_TUN, persistent);
186#if defined(ENABLE_DCO)
188#endif
189
190#ifdef ENABLE_MANAGEMENT
191 if (management)
192 {
195 }
196#endif
197
198#ifdef ENABLE_ASYNC_PUSH
199 /* arm inotify watcher */
201#endif
202
203 status =
205 update_time();
206 m->multi_io->n_esr = 0;
207 if (status > 0)
208 {
209 m->multi_io->n_esr = status;
210 }
211 return status;
212}
213
214static int
215multi_io_wait_lite(struct multi_context *m, struct multi_instance *mi, const int action,
216 bool *tun_input_pending)
217{
218 struct context *c = multi_get_context(m, mi);
219 unsigned int looking_for = 0;
220
221 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_wait_lite a=%s mi=" ptr_format, pract(action),
222 (ptr_type)mi);
223
224 tv_clear(&c->c2.timeval); /* ZERO-TIMEOUT */
225
226 switch (action)
227 {
228 case TA_TUN_READ:
229 looking_for = TUN_READ;
230 tun_input_pending = NULL;
232 break;
233
234 case TA_SOCKET_READ:
235 looking_for = SOCKET_READ;
236 tun_input_pending = NULL;
238 break;
239
240 case TA_TUN_WRITE:
241 looking_for = TUN_WRITE;
242 tun_input_pending = NULL;
243 /* For some reason, the Linux 2.2 TUN/TAP driver hits this timeout */
244 c->c2.timeval.tv_sec = 1;
246 break;
247
248 case TA_SOCKET_WRITE:
249 looking_for = SOCKET_WRITE;
251 break;
252
253 default:
254 msg(M_FATAL, "MULTI IO: multi_io_wait_lite, unhandled action=%d", action);
255 }
256
257 if (tun_input_pending && (c->c2.event_set_status & TUN_READ))
258 {
259 *tun_input_pending = true;
260 }
261
262 if (c->c2.event_set_status & looking_for)
263 {
264 return action;
265 }
266 else
267 {
268 switch (action)
269 {
270 /* MULTI PROTOCOL socket output buffer is full */
271 case TA_SOCKET_WRITE:
273
274 /* TUN device timed out on accepting write */
275 case TA_TUN_WRITE:
277 }
278
279 return TA_UNDEF;
280 }
281}
282
283static struct multi_instance *
284multi_io_dispatch(struct multi_context *m, struct multi_instance *mi, const int action)
285{
286 const unsigned int mpp_flags = MPP_PRE_SELECT | MPP_RECORD_TOUCH;
287 struct multi_instance *touched = mi;
288 m->mpp_touched = &touched;
289
290 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_dispatch a=%s mi=" ptr_format, pract(action),
291 (ptr_type)mi);
292
293 switch (action)
294 {
295 case TA_TUN_READ:
297 if (!IS_SIG(&m->top))
298 {
299 multi_process_incoming_tun(m, mpp_flags);
300 }
301 break;
302
303 case TA_SOCKET_READ:
305 ASSERT(mi);
308 set_prefix(mi);
310 clear_prefix();
311 if (!IS_SIG(&mi->context))
312 {
313 multi_process_incoming_link(m, mi, mpp_flags, mi->context.c2.link_sockets[0]);
314 if (!IS_SIG(&mi->context))
315 {
317 }
318 }
319 break;
320
321 case TA_TIMEOUT:
322 multi_process_timeout(m, mpp_flags);
323 break;
324
325 case TA_TUN_WRITE:
326 multi_process_outgoing_tun(m, mpp_flags);
327 break;
328
331 break;
332
334 ASSERT(mi);
336 break;
337
338 case TA_SOCKET_WRITE:
339 multi_tcp_process_outgoing_link(m, false, mpp_flags);
340 break;
341
343 multi_tcp_process_outgoing_link(m, true, mpp_flags);
344 break;
345
346 case TA_INITIAL:
347 ASSERT(mi);
349 multi_process_post(m, mi, mpp_flags);
350 break;
351
352 default:
353 msg(M_FATAL, "MULTI IO: multi_io_dispatch, unhandled action=%d", action);
354 }
355
356 m->mpp_touched = NULL;
357 return touched;
358}
359
360static int
361multi_io_post(struct multi_context *m, struct multi_instance *mi, const int action)
362{
363 struct context *c = multi_get_context(m, mi);
364 int newaction = TA_UNDEF;
365
366#define MTP_NONE 0
367#define MTP_TUN_OUT (1 << 0)
368#define MTP_LINK_OUT (1 << 1)
369 unsigned int flags = MTP_NONE;
370
371 if (TUN_OUT(c))
372 {
373 flags |= MTP_TUN_OUT;
374 }
375 if (LINK_OUT(c))
376 {
377 flags |= MTP_LINK_OUT;
378 }
379
380 switch (flags)
381 {
383 case MTP_TUN_OUT:
384 newaction = TA_TUN_WRITE;
385 break;
386
387 case MTP_LINK_OUT:
388 newaction = TA_SOCKET_WRITE;
389 break;
390
391 case MTP_NONE:
392 if (mi && sockets_read_residual(c))
393 {
394 newaction = TA_SOCKET_READ_RESIDUAL;
395 }
396 else
397 {
399 }
400 break;
401
402 default:
403 {
404 struct gc_arena gc = gc_new();
405 msg(M_FATAL, "MULTI IO: multi_io_post bad state, mi=%s flags=%d",
406 multi_instance_string(mi, false, &gc), flags);
407 gc_free(&gc);
408 break;
409 }
410 }
411
412 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_post %s -> %s", pract(action), pract(newaction));
413
414 return newaction;
415}
416
417void
419{
420 struct multi_io *multi_io = m->multi_io;
421 int i;
422
423 for (i = 0; i < multi_io->n_esr; ++i)
424 {
425 struct event_set_return *e = &multi_io->esr[i];
426 struct event_arg *ev_arg = (struct event_arg *)e->arg;
427
428 /* incoming data for instance or listening socket? */
429 if (e->arg >= MULTI_N)
430 {
431 switch (ev_arg->type)
432 {
433 struct multi_instance *mi;
434
435 /* react to event on child instance */
437 if (!ev_arg->u.mi)
438 {
439 msg(D_MULTI_ERRORS, "MULTI IO: multi_io_proc_io: null minstance");
440 break;
441 }
442
443 mi = ev_arg->u.mi;
444 if (e->rwflags & EVENT_WRITE)
445 {
447 }
448 else if (e->rwflags & EVENT_READ)
449 {
450 multi_io_action(m, mi, TA_SOCKET_READ, false);
451 }
452 break;
453
455 if (!ev_arg->u.sock)
456 {
457 msg(D_MULTI_ERRORS, "MULTI IO: multi_io_proc_io: null socket");
458 break;
459 }
460 /* new incoming TCP client attempting to connect? */
462 {
465 }
466 else
467 {
469 mi = m->pending;
470 }
471 /* monitor and/or handle events that are
472 * triggered in succession by the first one
473 * before returning to the main loop. */
474 if (mi)
475 {
476 multi_io_action(m, mi, TA_INITIAL, false);
477 }
478 break;
479 }
480 }
481 else
482 {
483#ifdef ENABLE_MANAGEMENT
484 if (e->arg == MULTI_IO_MANAGEMENT)
485 {
488 }
489 else
490#endif
491 /* incoming data on TUN? */
492 if (e->arg == MULTI_IO_TUN)
493 {
494 if (e->rwflags & EVENT_WRITE)
495 {
496 multi_io_action(m, NULL, TA_TUN_WRITE, false);
497 }
498 else if (e->rwflags & EVENT_READ)
499 {
500 multi_io_action(m, NULL, TA_TUN_READ, false);
501 }
502 }
503 /* new incoming TCP client attempting to connect? */
504 else if (e->arg == MULTI_IO_SOCKET)
505 {
506 struct multi_instance *mi;
507 ASSERT(m->top.c2.link_sockets[0]);
510 if (mi)
511 {
512 multi_io_action(m, mi, TA_INITIAL, false);
513 }
514 }
515#if defined(ENABLE_DCO)
516 /* incoming data on DCO? */
517 else if (e->arg == MULTI_IO_DCO)
518 {
520 }
521#endif
522 /* signal received? */
523 else if (e->arg == MULTI_IO_SIG)
524 {
526 }
527#ifdef ENABLE_ASYNC_PUSH
528 else if (e->arg == MULTI_IO_FILE_CLOSE_WRITE)
529 {
530 multi_process_file_closed(m, MPP_PRE_SELECT | MPP_RECORD_TOUCH);
531 }
532#endif
533 }
534 if (IS_SIG(&m->top))
535 {
536 break;
537 }
538 }
539 multi_io->n_esr = 0;
540
541 /*
542 * Process queued mbuf packets destined for TCP socket
543 */
544 {
545 struct multi_instance *mi;
546 while (!IS_SIG(&m->top) && (mi = mbuf_peek(m->mbuf)) != NULL)
547 {
548 multi_io_action(m, mi, TA_SOCKET_WRITE, true);
549 }
550 }
551}
552
553void
554multi_io_action(struct multi_context *m, struct multi_instance *mi, int action, bool poll)
555{
556 bool tun_input_pending = false;
557
558 do
559 {
560 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_action a=%s p=%d", pract(action), poll);
561
562 /*
563 * If TA_SOCKET_READ_RESIDUAL, it means we still have pending
564 * input packets which were read by a prior recv.
565 *
566 * Otherwise do a "lite" wait, which means we wait with 0 timeout
567 * on I/O events only related to the current instance, not
568 * the big list of events.
569 *
570 * On our first pass, poll will be false because we already know
571 * that input is available, and to call io_wait would be redundant.
572 */
573 if (poll && action != TA_SOCKET_READ_RESIDUAL)
574 {
575 const int orig_action = action;
576 action = multi_io_wait_lite(m, mi, action, &tun_input_pending);
577 if (action == TA_UNDEF)
578 {
579 msg(M_FATAL, "MULTI IO: I/O wait required blocking in multi_io_action, action=%d",
580 orig_action);
581 }
582 }
583
584 /*
585 * Dispatch the action
586 */
587 struct multi_instance *touched = multi_io_dispatch(m, mi, action);
588
589 /*
590 * Signal received or connection
591 * reset by peer?
592 */
593 if (touched && IS_SIG(&touched->context))
594 {
595 if (mi == touched)
596 {
597 mi = NULL;
598 }
600 }
601
602
603 /*
604 * If dispatch produced any pending output
605 * for a particular instance, point to
606 * that instance.
607 */
608 if (m->pending)
609 {
610 mi = m->pending;
611 }
612
613 /*
614 * Based on the effects of the action,
615 * such as generating pending output,
616 * possibly transition to a new action state.
617 */
618 action = multi_io_post(m, mi, action);
619
620 /*
621 * If we are finished processing the original action,
622 * check if we have any TUN input. If so, transition
623 * our action state to processing this input.
624 */
625 if (tun_input_pending && action == TA_UNDEF)
626 {
627 action = TA_TUN_READ;
628 mi = NULL;
629 tun_input_pending = false;
630 poll = false;
631 }
632 else
633 {
634 poll = true;
635 }
636
637 } while (action != TA_UNDEF);
638}
639
640void
642{
643 if (multi_io && multi_io->es)
644 {
645 event_del(multi_io->es, event);
646 }
647}
static void gc_free(struct gc_arena *a)
Definition buffer.h:1025
#define ALLOC_OBJ_CLEAR(dptr, type)
Definition buffer.h:1052
#define ALLOC_ARRAY(dptr, type, n)
Definition buffer.h:1058
static struct gc_arena gc_new(void)
Definition buffer.h:1017
unsigned long ptr_type
Definition common.h:59
#define ptr_format
Definition common.h:50
static void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg)
Definition dco.h:315
#define D_MULTI_ERRORS
Definition errlevel.h:64
#define D_MULTI_DEBUG
Definition errlevel.h:126
#define D_MULTI_LOW
Definition errlevel.h:85
struct event_set * event_set_init(int *maxevents, unsigned int flags)
Definition event.c:1177
#define TUN_WRITE
Definition event.h:64
static void event_free(struct event_set *es)
Definition event.h:161
static void event_del(struct event_set *es, event_t event)
Definition event.h:176
#define SOCKET_READ
Definition event.h:60
static int event_wait(struct event_set *es, const struct timeval *tv, struct event_set_return *out, int outlen)
Definition event.h:188
#define SOCKET_WRITE
Definition event.h:61
#define EVENT_WRITE
Definition event.h:38
#define MULTI_N
Definition event.h:87
#define EVENT_READ
Definition event.h:37
#define TUN_READ
Definition event.h:63
static void wait_signal(struct event_set *es, void *arg)
Definition event.h:205
@ EVENT_ARG_LINK_SOCKET
Definition event.h:137
@ EVENT_ARG_MULTI_INSTANCE
Definition event.h:136
static void event_ctl(struct event_set *es, event_t event, unsigned int rwflags, void *arg)
Definition event.h:182
void get_io_flags_udp(struct context *c, struct multi_io *multi_io, const unsigned int flags)
Definition forward.c:2161
Interface functions to the internal and external multiplexers.
#define IOW_READ_TUN
Definition forward.h:56
static void io_wait(struct context *c, const unsigned int flags)
Definition forward.h:383
#define IOW_READ_LINK
Definition forward.h:57
#define LINK_OUT(c)
Definition forward.h:38
#define TUN_OUT(c)
Definition forward.h:37
#define IOW_TO_TUN
Definition forward.h:54
#define IOW_READ_TUN_FORCE
Definition forward.h:62
#define IOW_TO_LINK
Definition forward.h:55
bool multi_process_incoming_link(struct multi_context *m, struct multi_instance *instance, const unsigned int mpp_flags, struct link_socket *sock)
Demultiplex and process a packet received over the external network interface.
Definition multi.c:3341
void read_incoming_link(struct context *c, struct link_socket *sock)
Read a packet from the external network interface.
Definition forward.c:923
void read_incoming_tun(struct context *c)
Read a packet from the virtual tun/tap network interface.
Definition forward.c:1305
static bool multi_process_outgoing_tun(struct multi_context *m, const unsigned int mpp_flags)
Send a packet over the virtual tun/tap network interface to its locally reachable destination.
Definition multi.h:636
bool multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flags)
Determine the destination VPN tunnel of a packet received over the virtual tun/tap network interface ...
Definition multi.c:3539
#define BASE_N_EVENTS
Definition init.h:32
static SERVICE_STATUS status
Definition interactive.c:51
void management_socket_set(struct management *man, struct event_set *es, void *arg, unsigned int *persistent)
Definition manage.c:3152
void management_io(struct management *man)
Definition manage.c:3190
static struct multi_instance * mbuf_peek(struct mbuf_set *ms)
Definition mbuf.h:99
static bool mbuf_defined(const struct mbuf_set *ms)
Definition mbuf.h:79
struct multi_instance * multi_create_instance_tcp(struct multi_context *m, struct link_socket *sock)
Definition mtcp.c:49
bool multi_tcp_process_outgoing_link(struct multi_context *m, bool defer, const unsigned int mpp_flags)
Definition mtcp.c:176
bool multi_tcp_process_outgoing_link_ready(struct multi_context *m, struct multi_instance *mi, const unsigned int mpp_flags)
Definition mtcp.c:151
unsigned int p2mp_iow_flags(const struct multi_context *m)
Definition mudp.c:437
void multi_process_io_udp(struct multi_context *m, struct link_socket *sock)
Definition mudp.c:339
void multi_close_instance_on_signal(struct multi_context *m, struct multi_instance *mi)
Definition multi.c:3205
bool multi_process_post(struct multi_context *m, struct multi_instance *mi, const unsigned int flags)
Perform postprocessing of a VPN tunnel instance.
Definition multi.c:3006
bool multi_process_timeout(struct multi_context *m, const unsigned int mpp_flags)
Definition multi.c:3667
const char * multi_instance_string(const struct multi_instance *mi, bool null, struct gc_arena *gc)
Definition multi.c:430
void multi_process_drop_outgoing_tun(struct multi_context *m, const unsigned int mpp_flags)
Definition multi.c:3699
Header file for server-mode related structures and functions.
bool multi_process_incoming_dco(struct multi_context *m)
Process an incoming DCO message (from kernel space).
static void set_prefix(struct multi_instance *mi)
Definition multi.h:520
static void clear_prefix(void)
Definition multi.h:532
#define MPP_RECORD_TOUCH
Definition multi.h:277
#define MPP_PRE_SELECT
Definition multi.h:274
struct multi_io * multi_io_init(const int maxclients)
Definition multi_io.c:116
#define MULTI_IO_SIG
Definition multi_io.c:44
void multi_io_process_io(struct multi_context *m)
Definition multi_io.c:418
static int multi_io_wait_lite(struct multi_context *m, struct multi_instance *mi, const int action, bool *tun_input_pending)
Definition multi_io.c:215
#define MULTI_IO_TUN
Definition multi_io.c:43
void multi_io_free(struct multi_io *multi_io)
Definition multi_io.c:155
#define MTP_NONE
#define MTP_TUN_OUT
#define MULTI_IO_DCO
Definition multi_io.c:47
#define MTP_LINK_OUT
void multi_io_set_global_rw_flags(struct multi_context *m, struct multi_instance *mi)
Definition multi_io.c:133
int multi_io_wait(struct multi_context *m)
Definition multi_io.c:166
#define MULTI_IO_FILE_CLOSE_WRITE
Definition multi_io.c:46
static struct multi_instance * multi_io_dispatch(struct multi_context *m, struct multi_instance *mi, const int action)
Definition multi_io.c:284
void multi_io_delete_event(struct multi_io *multi_io, event_t event)
Definition multi_io.c:641
static struct context * multi_get_context(struct multi_context *m, struct multi_instance *mi)
Definition multi_io.c:103
static int multi_io_post(struct multi_context *m, struct multi_instance *mi, const int action)
Definition multi_io.c:361
void multi_io_action(struct multi_context *m, struct multi_instance *mi, int action, bool poll)
Definition multi_io.c:554
#define MULTI_IO_MANAGEMENT
Definition multi_io.c:45
#define MULTI_IO_SOCKET
Definition multi_io.c:42
#define TA_UNDEF
Definition multi_io.h:36
#define TA_SOCKET_WRITE_READY
Definition multi_io.h:40
#define TA_SOCKET_READ_RESIDUAL
Definition multi_io.h:38
#define TA_SOCKET_READ
Definition multi_io.h:37
#define TA_INITIAL
Definition multi_io.h:44
#define TA_TUN_WRITE
Definition multi_io.h:43
#define TA_TIMEOUT
Definition multi_io.h:45
#define TA_SOCKET_WRITE_DEFERRED
Definition multi_io.h:41
#define TA_TUN_WRITE_TIMEOUT
Definition multi_io.h:46
#define TA_TUN_READ
Definition multi_io.h:42
#define TA_SOCKET_WRITE
Definition multi_io.h:39
#define M_FATAL
Definition error.h:90
#define dmsg(flags,...)
Definition error.h:172
#define msg(flags,...)
Definition error.h:152
#define ASSERT(x)
Definition error.h:219
bool has_udp_in_local_list(const struct options *options)
Definition options.c:9325
static void update_time(void)
Definition otime.h:81
static void tv_clear(struct timeval *tv)
Definition otime.h:105
#define IS_SIG(c)
Definition sig.h:47
static void get_signal(volatile int *sig)
Copy the global signal_received (if non-zero) to the passed-in argument sig.
Definition sig.h:109
unsigned int socket_set(struct link_socket *s, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent)
Definition socket.c:2953
bool sockets_read_residual(const struct context *c)
Definition socket.c:45
static void socket_set_listen_persistent(struct link_socket *sock, struct event_set *es, void *arg)
Definition socket.h:782
static bool stream_buf_read_setup(struct link_socket *sock)
Definition socket.h:533
static void socket_reset_listen_persistent(struct link_socket *sock)
Definition socket.h:792
static bool proto_is_dgram(int proto)
Return if the protocol is datagram (UDP)
int link_sockets_num
Definition openvpn.h:158
struct tuntap * tuntap
Tun/tap virtual network interface.
Definition openvpn.h:172
unsigned int event_set_status
Definition openvpn.h:235
struct link_socket ** link_sockets
Definition openvpn.h:237
struct timeval timeval
Time to next event of timers and similar.
Definition openvpn.h:396
Contains all state information for one tunnel.
Definition openvpn.h:474
struct signal_info * sig
Internal error signaling object.
Definition openvpn.h:503
struct context_2 c2
Level 2 context.
Definition openvpn.h:517
struct options options
Options loaded from command line or configuration file.
Definition openvpn.h:475
struct context_1 c1
Level 1 context.
Definition openvpn.h:516
struct link_socket * sock
Definition event.h:147
struct multi_instance * mi
Definition event.h:146
union event_arg::@1 u
event_arg_t type
Definition event.h:143
unsigned int rwflags
Definition event.h:125
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:116
Main OpenVPN server state structure.
Definition multi.h:163
struct mbuf_set * mbuf
Set of buffers for passing data channel packets between VPN tunnel instances.
Definition multi.h:175
struct multi_io * multi_io
I/O state and events tracker.
Definition multi.h:178
struct context top
Storage structure for process-wide configuration.
Definition multi.h:202
struct multi_instance * pending
Definition multi.h:196
struct multi_instance ** mpp_touched
Definition multi.h:198
Server-mode state structure for one single VPN tunnel.
Definition multi.h:102
struct mbuf_set * tcp_link_out_deferred
Definition multi.h:128
unsigned int tcp_rwflags
Definition multi.h:127
bool socket_set_called
Definition multi.h:129
struct event_arg ev_arg
this struct will store a pointer to either mi or link_socket, depending on the event type,...
Definition multi.h:107
struct context context
The context structure storing state for this VPN tunnel.
Definition multi.h:143
struct event_set * es
Definition multi_io.h:53
int n_esr
Definition multi_io.h:55
struct event_set_return * esr
Definition multi_io.h:54
unsigned int tun_rwflags
Definition multi_io.h:57
int maxevents
Definition multi_io.h:56
unsigned int management_persist_flags
Definition multi_io.h:60
volatile int signal_received
Definition sig.h:42
unsigned int flags
Definition mtcp.c:42
unsigned int ret
Definition mtcp.c:43
unsigned int tun
Definition mtcp.c:44
unsigned int sock
Definition mtcp.c:45
dco_context_t dco
Definition tun.h:249
struct gc_arena gc
Definition test_ssl.c:131
static bool tuntap_is_dco_win(struct tuntap *tt)
Definition tun.h:532
static void tun_set(struct tuntap *tt, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent)
Definition tun.h:598