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-2026 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
49#ifdef ENABLE_DEBUG
50static const char *
51pract(int action)
52{
53 switch (action)
54 {
55 case TA_UNDEF:
56 return "TA_UNDEF";
57
58 case TA_SOCKET_READ:
59 return "TA_SOCKET_READ";
60
62 return "TA_SOCKET_READ_RESIDUAL";
63
64 case TA_SOCKET_WRITE:
65 return "TA_SOCKET_WRITE";
66
68 return "TA_SOCKET_WRITE_READY";
69
71 return "TA_SOCKET_WRITE_DEFERRED";
72
73 case TA_TUN_READ:
74 return "TA_TUN_READ";
75
76 case TA_TUN_WRITE:
77 return "TA_TUN_WRITE";
78
79 case TA_INITIAL:
80 return "TA_INITIAL";
81
82 case TA_TIMEOUT:
83 return "TA_TIMEOUT";
84
86 return "TA_TUN_WRITE_TIMEOUT";
87
88 default:
89 return "?";
90 }
91}
92#endif /* ENABLE_DEBUG */
93
94static inline struct context *
96{
97 if (mi)
98 {
99 return &mi->context;
100 }
101 else
102 {
103 return &m->top;
104 }
105}
106
107struct multi_io *
108multi_io_init(const int maxclients)
109{
110 struct multi_io *multi_io;
111
112 ASSERT(maxclients >= 1);
113
115 multi_io->maxevents = maxclients + BASE_N_EVENTS;
119 msg(D_MULTI_LOW, "MULTI IO: MULTI_IO INIT maxclients=%d maxevents=%d", maxclients,
121 return multi_io;
122}
123
124void
126{
127 if (!mi)
128 {
129 return;
130 }
131
132 mi->socket_set_called = true;
134 {
136 &mi->context.c2.link_sockets[0]->ev_arg, NULL);
137 }
138 else
139 {
142 &mi->tcp_rwflags);
143 }
144}
145
146void
148{
149 if (multi_io)
150 {
152 free(multi_io->esr);
153 free(multi_io);
154 }
155}
156
157int
159{
160 int status, i;
161 unsigned int *persistent = &m->multi_io->tun_rwflags;
162
164 {
165 for (i = 0; i < m->top.c1.link_sockets_num; i++)
166 {
168 &m->top.c2.link_sockets[i]->ev_arg);
169 }
170 }
171
173 {
175 }
176
177 tun_set(m->top.c1.tuntap, m->multi_io->es, EVENT_READ, MULTI_IO_TUN, persistent);
178#if defined(ENABLE_DCO)
180#endif
181
182#ifdef ENABLE_MANAGEMENT
183 if (management)
184 {
187 }
188#endif
189
190#ifdef ENABLE_ASYNC_PUSH
191 /* arm inotify watcher */
193#endif
194
195 status =
197 update_time();
198 m->multi_io->n_esr = 0;
199 if (status > 0)
200 {
201 m->multi_io->n_esr = status;
202 }
203 return status;
204}
205
206static int
207multi_io_wait_lite(struct multi_context *m, struct multi_instance *mi, const int action,
208 bool *tun_input_pending)
209{
210 struct context *c = multi_get_context(m, mi);
211 unsigned int looking_for = 0;
212
213 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_wait_lite a=%s mi=" ptr_format, pract(action),
214 (ptr_type)mi);
215
216 tv_clear(&c->c2.timeval); /* ZERO-TIMEOUT */
217
218 switch (action)
219 {
220 case TA_TUN_READ:
221 looking_for = TUN_READ;
222 tun_input_pending = NULL;
224 break;
225
226 case TA_SOCKET_READ:
227 looking_for = SOCKET_READ;
228 tun_input_pending = NULL;
230 break;
231
232 case TA_TUN_WRITE:
233 looking_for = TUN_WRITE;
234 tun_input_pending = NULL;
235 /* For some reason, the Linux 2.2 TUN/TAP driver hits this timeout */
236 c->c2.timeval.tv_sec = 1;
238 break;
239
240 case TA_SOCKET_WRITE:
241 looking_for = SOCKET_WRITE;
243 break;
244
245 default:
246 msg(M_FATAL, "MULTI IO: multi_io_wait_lite, unhandled action=%d", action);
247 }
248
249 if (tun_input_pending && (c->c2.event_set_status & TUN_READ))
250 {
251 *tun_input_pending = true;
252 }
253
254 if (c->c2.event_set_status & looking_for)
255 {
256 return action;
257 }
258 else
259 {
260 switch (action)
261 {
262 /* MULTI PROTOCOL socket output buffer is full */
263 case TA_SOCKET_WRITE:
265
266 /* TUN device timed out on accepting write */
267 case TA_TUN_WRITE:
269 }
270
271 return TA_UNDEF;
272 }
273}
274
275static struct multi_instance *
276multi_io_dispatch(struct multi_context *m, struct multi_instance *mi, const int action)
277{
278 const unsigned int mpp_flags = MPP_PRE_SELECT | MPP_RECORD_TOUCH;
279 struct multi_instance *touched = mi;
280 m->mpp_touched = &touched;
281
282 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_dispatch a=%s mi=" ptr_format, pract(action),
283 (ptr_type)mi);
284
285 switch (action)
286 {
287 case TA_TUN_READ:
289 if (!IS_SIG(&m->top))
290 {
291 multi_process_incoming_tun(m, mpp_flags);
292 }
293 break;
294
295 case TA_SOCKET_READ:
297 ASSERT(mi);
300 set_prefix(mi);
302 clear_prefix();
303 if (!IS_SIG(&mi->context))
304 {
305 multi_process_incoming_link(m, mi, mpp_flags, mi->context.c2.link_sockets[0]);
306 if (!IS_SIG(&mi->context))
307 {
309 }
310 }
311 break;
312
313 case TA_TIMEOUT:
314 multi_process_timeout(m, mpp_flags);
315 break;
316
317 case TA_TUN_WRITE:
318 multi_process_outgoing_tun(m, mpp_flags);
319 break;
320
323 break;
324
326 ASSERT(mi);
328 break;
329
330 case TA_SOCKET_WRITE:
331 multi_tcp_process_outgoing_link(m, false, mpp_flags);
332 break;
333
335 multi_tcp_process_outgoing_link(m, true, mpp_flags);
336 break;
337
338 case TA_INITIAL:
339 ASSERT(mi);
341 multi_process_post(m, mi, mpp_flags);
342 break;
343
344 default:
345 msg(M_FATAL, "MULTI IO: multi_io_dispatch, unhandled action=%d", action);
346 }
347
348 m->mpp_touched = NULL;
349 return touched;
350}
351
352static int
353multi_io_post(struct multi_context *m, struct multi_instance *mi, const int action)
354{
355 struct context *c = multi_get_context(m, mi);
356 int newaction = TA_UNDEF;
357
358#define MTP_NONE 0
359#define MTP_TUN_OUT (1 << 0)
360#define MTP_LINK_OUT (1 << 1)
361 unsigned int flags = MTP_NONE;
362
363 if (TUN_OUT(c))
364 {
365 flags |= MTP_TUN_OUT;
366 }
367 if (LINK_OUT(c))
368 {
369 flags |= MTP_LINK_OUT;
370 }
371
372 switch (flags)
373 {
375 case MTP_TUN_OUT:
376 newaction = TA_TUN_WRITE;
377 break;
378
379 case MTP_LINK_OUT:
380 newaction = TA_SOCKET_WRITE;
381 break;
382
383 case MTP_NONE:
384 if (mi && sockets_read_residual(c))
385 {
386 newaction = TA_SOCKET_READ_RESIDUAL;
387 }
388 else
389 {
391 }
392 break;
393
394 default:
395 {
396 struct gc_arena gc = gc_new();
397 msg(M_FATAL, "MULTI IO: multi_io_post bad state, mi=%s flags=%d",
398 multi_instance_string(mi, false, &gc), flags);
399 gc_free(&gc);
400 break;
401 }
402 }
403
404 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_post %s -> %s", pract(action), pract(newaction));
405
406 return newaction;
407}
408
409void
411{
412 struct multi_io *multi_io = m->multi_io;
413 int i;
414
415 for (i = 0; i < multi_io->n_esr; ++i)
416 {
417 struct event_set_return *e = &multi_io->esr[i];
418 struct event_arg *ev_arg = (struct event_arg *)e->arg;
419
420 /* incoming data for instance or listening socket? */
421 if (e->arg >= MULTI_N)
422 {
423 switch (ev_arg->type)
424 {
425 struct multi_instance *mi;
426
427 /* react to event on child instance */
429 if (!ev_arg->u.mi)
430 {
431 msg(D_MULTI_ERRORS, "MULTI IO: multi_io_proc_io: null minstance");
432 break;
433 }
434
435 mi = ev_arg->u.mi;
436 if (e->rwflags & EVENT_WRITE)
437 {
439 }
440 else if (e->rwflags & EVENT_READ)
441 {
442 multi_io_action(m, mi, TA_SOCKET_READ, false);
443 }
444 break;
445
447 if (!ev_arg->u.sock)
448 {
449 msg(D_MULTI_ERRORS, "MULTI IO: multi_io_proc_io: null socket");
450 break;
451 }
452 /* new incoming TCP client attempting to connect? */
454 {
457 }
458 else
459 {
461 mi = m->pending;
462 }
463 /* monitor and/or handle events that are
464 * triggered in succession by the first one
465 * before returning to the main loop. */
466 if (mi)
467 {
468 multi_io_action(m, mi, TA_INITIAL, false);
469 }
470 break;
471 }
472 }
473 else
474 {
475#ifdef ENABLE_MANAGEMENT
476 if (e->arg == MULTI_IO_MANAGEMENT)
477 {
480 }
481 else
482#endif
483 /* incoming data on TUN? */
484 if (e->arg == MULTI_IO_TUN)
485 {
486 if (e->rwflags & EVENT_WRITE)
487 {
488 multi_io_action(m, NULL, TA_TUN_WRITE, false);
489 }
490 else if (e->rwflags & EVENT_READ)
491 {
492 multi_io_action(m, NULL, TA_TUN_READ, false);
493 }
494 }
495
496#if defined(ENABLE_DCO)
497 /* incoming data on DCO? */
498 else if (e->arg == MULTI_IO_DCO)
499 {
501 }
502#endif
503 /* signal received? */
504 else if (e->arg == MULTI_IO_SIG)
505 {
507 }
508#ifdef ENABLE_ASYNC_PUSH
509 else if (e->arg == MULTI_IO_FILE_CLOSE_WRITE)
510 {
511 multi_process_file_closed(m, MPP_PRE_SELECT | MPP_RECORD_TOUCH);
512 }
513#endif
514 }
515 if (IS_SIG(&m->top))
516 {
517 break;
518 }
519 }
520 multi_io->n_esr = 0;
521
522 /*
523 * Process queued mbuf packets destined for TCP socket
524 */
525 {
526 struct multi_instance *mi;
527 while (!IS_SIG(&m->top) && (mi = mbuf_peek(m->mbuf)) != NULL)
528 {
529 multi_io_action(m, mi, TA_SOCKET_WRITE, true);
530 }
531 }
532}
533
534void
535multi_io_action(struct multi_context *m, struct multi_instance *mi, int action, bool poll)
536{
537 bool tun_input_pending = false;
538
539 do
540 {
541 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_action a=%s p=%d", pract(action), poll);
542
543 /*
544 * If TA_SOCKET_READ_RESIDUAL, it means we still have pending
545 * input packets which were read by a prior recv.
546 *
547 * Otherwise do a "lite" wait, which means we wait with 0 timeout
548 * on I/O events only related to the current instance, not
549 * the big list of events.
550 *
551 * On our first pass, poll will be false because we already know
552 * that input is available, and to call io_wait would be redundant.
553 */
554 if (poll && action != TA_SOCKET_READ_RESIDUAL)
555 {
556 const int orig_action = action;
557 action = multi_io_wait_lite(m, mi, action, &tun_input_pending);
558 if (action == TA_UNDEF)
559 {
560 msg(M_FATAL, "MULTI IO: I/O wait required blocking in multi_io_action, action=%d",
561 orig_action);
562 }
563 }
564
565 /*
566 * Dispatch the action
567 */
568 struct multi_instance *touched = multi_io_dispatch(m, mi, action);
569
570 /*
571 * Signal received or connection
572 * reset by peer?
573 */
574 if (touched && IS_SIG(&touched->context))
575 {
576 if (mi == touched)
577 {
578 mi = NULL;
579 }
581 }
582
583
584 /*
585 * If dispatch produced any pending output
586 * for a particular instance, point to
587 * that instance.
588 */
589 if (m->pending)
590 {
591 mi = m->pending;
592 }
593
594 /*
595 * Based on the effects of the action,
596 * such as generating pending output,
597 * possibly transition to a new action state.
598 */
599 action = multi_io_post(m, mi, action);
600
601 /*
602 * If we are finished processing the original action,
603 * check if we have any TUN input. If so, transition
604 * our action state to processing this input.
605 */
606 if (tun_input_pending && action == TA_UNDEF)
607 {
608 action = TA_TUN_READ;
609 mi = NULL;
610 tun_input_pending = false;
611 poll = false;
612 }
613 else
614 {
615 poll = true;
616 }
617
618 } while (action != TA_UNDEF);
619}
620
621void
623{
624 if (multi_io && multi_io->es)
625 {
626 event_del(multi_io->es, event);
627 }
628}
static void gc_free(struct gc_arena *a)
Definition buffer.h:1049
#define ALLOC_OBJ_CLEAR(dptr, type)
Definition buffer.h:1088
#define ALLOC_ARRAY(dptr, type, n)
Definition buffer.h:1094
static struct gc_arena gc_new(void)
Definition buffer.h:1041
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:316
static int dco_read_and_process(dco_context_t *dco)
Definition dco.h:309
#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:1187
#define TUN_WRITE
Definition event.h:64
static void event_free(struct event_set *es)
Definition event.h:159
static void event_del(struct event_set *es, event_t event)
Definition event.h:174
#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:186
#define SOCKET_WRITE
Definition event.h:61
#define EVENT_WRITE
Definition event.h:38
#define MULTI_N
Definition event.h:85
#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:203
@ EVENT_ARG_LINK_SOCKET
Definition event.h:135
@ EVENT_ARG_MULTI_INSTANCE
Definition event.h:134
static void event_ctl(struct event_set *es, event_t event, unsigned int rwflags, void *arg)
Definition event.h:180
void get_io_flags_udp(struct context *c, struct multi_io *multi_io, const unsigned int flags)
Definition forward.c:2151
void io_wait(struct context *c, const unsigned int flags)
Definition forward.c:2164
Interface functions to the internal and external multiplexers.
#define IOW_READ_TUN
Definition forward.h:56
#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:3306
void read_incoming_link(struct context *c, struct link_socket *sock)
Read a packet from the external network interface.
Definition forward.c:926
void read_incoming_tun(struct context *c)
Read a packet from the virtual tun/tap network interface.
Definition forward.c:1300
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:639
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:3504
#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:3247
void management_io(struct management *man)
Definition manage.c:3285
static struct multi_instance * mbuf_peek(struct mbuf_set *ms)
Definition mbuf.h:101
static bool mbuf_defined(const struct mbuf_set *ms)
Definition mbuf.h:81
struct multi_instance * multi_create_instance_tcp(struct multi_context *m, struct link_socket *sock)
Definition mtcp.c:41
bool multi_tcp_process_outgoing_link(struct multi_context *m, bool defer, const unsigned int mpp_flags)
Definition mtcp.c:164
bool multi_tcp_process_outgoing_link_ready(struct multi_context *m, struct multi_instance *mi, const unsigned int mpp_flags)
Definition mtcp.c:143
unsigned int p2mp_iow_flags(const struct multi_context *m)
Definition mudp.c:367
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:3177
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:2981
bool multi_process_timeout(struct multi_context *m, const unsigned int mpp_flags)
Definition multi.c:3632
const char * multi_instance_string(const struct multi_instance *mi, bool null, struct gc_arena *gc)
Definition multi.c:418
void multi_process_drop_outgoing_tun(struct multi_context *m, const unsigned int mpp_flags)
Definition multi.c:3664
Header file for server-mode related structures and functions.
static void set_prefix(struct multi_instance *mi)
Definition multi.h:523
static void clear_prefix(void)
Definition multi.h:535
#define MPP_RECORD_TOUCH
Definition multi.h:275
#define MPP_PRE_SELECT
Definition multi.h:273
struct multi_io * multi_io_init(const int maxclients)
Definition multi_io.c:108
#define MULTI_IO_SIG
Definition multi_io.c:44
void multi_io_process_io(struct multi_context *m)
Definition multi_io.c:410
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:207
#define MULTI_IO_TUN
Definition multi_io.c:43
void multi_io_free(struct multi_io *multi_io)
Definition multi_io.c:147
#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:125
int multi_io_wait(struct multi_context *m)
Definition multi_io.c:158
#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:276
void multi_io_delete_event(struct multi_io *multi_io, event_t event)
Definition multi_io.c:622
static struct context * multi_get_context(struct multi_context *m, struct multi_instance *mi)
Definition multi_io.c:95
static int multi_io_post(struct multi_context *m, struct multi_instance *mi, const int action)
Definition multi_io.c:353
void multi_io_action(struct multi_context *m, struct multi_instance *mi, int action, bool poll)
Definition multi_io.c:535
#define MULTI_IO_MANAGEMENT
Definition multi_io.c:45
#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:9310
static void update_time(void)
Definition otime.h:84
static void tv_clear(struct timeval *tv)
Definition otime.h:108
#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:2946
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:811
static bool stream_buf_read_setup(struct link_socket *sock)
Definition socket.h:562
static void socket_reset_listen_persistent(struct link_socket *sock)
Definition socket.h:821
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:471
struct signal_info * sig
Internal error signaling object.
Definition openvpn.h:500
struct context_2 c2
Level 2 context.
Definition openvpn.h:514
struct options options
Options loaded from command line or configuration file.
Definition openvpn.h:472
struct context_1 c1
Level 1 context.
Definition openvpn.h:513
struct link_socket * sock
Definition event.h:145
struct multi_instance * mi
Definition event.h:144
union event_arg::@1 u
event_arg_t type
Definition event.h:141
unsigned int rwflags
Definition event.h:123
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:116
Main OpenVPN server state structure.
Definition multi.h:162
struct mbuf_set * mbuf
Set of buffers for passing data channel packets between VPN tunnel instances.
Definition multi.h:174
struct multi_io * multi_io
I/O state and events tracker.
Definition multi.h:177
struct context top
Storage structure for process-wide configuration.
Definition multi.h:201
struct multi_instance * pending
Definition multi.h:195
struct multi_instance ** mpp_touched
Definition multi.h:197
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:142
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
dco_context_t dco
Definition tun.h:247
struct gc_arena gc
Definition test_ssl.c:133
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