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;
247 perf_pop();
248 break;
249
250 case TA_SOCKET_WRITE:
251 looking_for = SOCKET_WRITE;
253 break;
254
255 default:
256 msg(M_FATAL, "MULTI IO: multi_io_wait_lite, unhandled action=%d", action);
257 }
258
259 if (tun_input_pending && (c->c2.event_set_status & TUN_READ))
260 {
261 *tun_input_pending = true;
262 }
263
264 if (c->c2.event_set_status & looking_for)
265 {
266 return action;
267 }
268 else
269 {
270 switch (action)
271 {
272 /* MULTI PROTOCOL socket output buffer is full */
273 case TA_SOCKET_WRITE:
275
276 /* TUN device timed out on accepting write */
277 case TA_TUN_WRITE:
279 }
280
281 return TA_UNDEF;
282 }
283}
284
285static struct multi_instance *
286multi_io_dispatch(struct multi_context *m, struct multi_instance *mi, const int action)
287{
288 const unsigned int mpp_flags = MPP_PRE_SELECT | MPP_RECORD_TOUCH;
289 struct multi_instance *touched = mi;
290 m->mpp_touched = &touched;
291
292 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_dispatch a=%s mi=" ptr_format, pract(action),
293 (ptr_type)mi);
294
295 switch (action)
296 {
297 case TA_TUN_READ:
299 if (!IS_SIG(&m->top))
300 {
301 multi_process_incoming_tun(m, mpp_flags);
302 }
303 break;
304
305 case TA_SOCKET_READ:
307 ASSERT(mi);
310 set_prefix(mi);
312 clear_prefix();
313 if (!IS_SIG(&mi->context))
314 {
315 multi_process_incoming_link(m, mi, mpp_flags, mi->context.c2.link_sockets[0]);
316 if (!IS_SIG(&mi->context))
317 {
319 }
320 }
321 break;
322
323 case TA_TIMEOUT:
324 multi_process_timeout(m, mpp_flags);
325 break;
326
327 case TA_TUN_WRITE:
328 multi_process_outgoing_tun(m, mpp_flags);
329 break;
330
333 break;
334
336 ASSERT(mi);
338 break;
339
340 case TA_SOCKET_WRITE:
341 multi_tcp_process_outgoing_link(m, false, mpp_flags);
342 break;
343
345 multi_tcp_process_outgoing_link(m, true, mpp_flags);
346 break;
347
348 case TA_INITIAL:
349 ASSERT(mi);
351 multi_process_post(m, mi, mpp_flags);
352 break;
353
354 default:
355 msg(M_FATAL, "MULTI IO: multi_io_dispatch, unhandled action=%d", action);
356 }
357
358 m->mpp_touched = NULL;
359 return touched;
360}
361
362static int
363multi_io_post(struct multi_context *m, struct multi_instance *mi, const int action)
364{
365 struct context *c = multi_get_context(m, mi);
366 int newaction = TA_UNDEF;
367
368#define MTP_NONE 0
369#define MTP_TUN_OUT (1 << 0)
370#define MTP_LINK_OUT (1 << 1)
371 unsigned int flags = MTP_NONE;
372
373 if (TUN_OUT(c))
374 {
375 flags |= MTP_TUN_OUT;
376 }
377 if (LINK_OUT(c))
378 {
379 flags |= MTP_LINK_OUT;
380 }
381
382 switch (flags)
383 {
385 case MTP_TUN_OUT:
386 newaction = TA_TUN_WRITE;
387 break;
388
389 case MTP_LINK_OUT:
390 newaction = TA_SOCKET_WRITE;
391 break;
392
393 case MTP_NONE:
394 if (mi && sockets_read_residual(c))
395 {
396 newaction = TA_SOCKET_READ_RESIDUAL;
397 }
398 else
399 {
401 }
402 break;
403
404 default:
405 {
406 struct gc_arena gc = gc_new();
407 msg(M_FATAL, "MULTI IO: multi_io_post bad state, mi=%s flags=%d",
408 multi_instance_string(mi, false, &gc), flags);
409 gc_free(&gc);
410 break;
411 }
412 }
413
414 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_post %s -> %s", pract(action), pract(newaction));
415
416 return newaction;
417}
418
419void
421{
422 struct multi_io *multi_io = m->multi_io;
423 int i;
424
425 for (i = 0; i < multi_io->n_esr; ++i)
426 {
427 struct event_set_return *e = &multi_io->esr[i];
428 struct event_arg *ev_arg = (struct event_arg *)e->arg;
429
430 /* incoming data for instance or listening socket? */
431 if (e->arg >= MULTI_N)
432 {
433 switch (ev_arg->type)
434 {
435 struct multi_instance *mi;
436
437 /* react to event on child instance */
439 if (!ev_arg->u.mi)
440 {
441 msg(D_MULTI_ERRORS, "MULTI IO: multi_io_proc_io: null minstance");
442 break;
443 }
444
445 mi = ev_arg->u.mi;
446 if (e->rwflags & EVENT_WRITE)
447 {
449 }
450 else if (e->rwflags & EVENT_READ)
451 {
452 multi_io_action(m, mi, TA_SOCKET_READ, false);
453 }
454 break;
455
457 if (!ev_arg->u.sock)
458 {
459 msg(D_MULTI_ERRORS, "MULTI IO: multi_io_proc_io: null socket");
460 break;
461 }
462 /* new incoming TCP client attempting to connect? */
464 {
467 }
468 else
469 {
471 mi = m->pending;
472 }
473 /* monitor and/or handle events that are
474 * triggered in succession by the first one
475 * before returning to the main loop. */
476 if (mi)
477 {
478 multi_io_action(m, mi, TA_INITIAL, false);
479 }
480 break;
481 }
482 }
483 else
484 {
485#ifdef ENABLE_MANAGEMENT
486 if (e->arg == MULTI_IO_MANAGEMENT)
487 {
490 }
491 else
492#endif
493 /* incoming data on TUN? */
494 if (e->arg == MULTI_IO_TUN)
495 {
496 if (e->rwflags & EVENT_WRITE)
497 {
498 multi_io_action(m, NULL, TA_TUN_WRITE, false);
499 }
500 else if (e->rwflags & EVENT_READ)
501 {
502 multi_io_action(m, NULL, TA_TUN_READ, false);
503 }
504 }
505 /* new incoming TCP client attempting to connect? */
506 else if (e->arg == MULTI_IO_SOCKET)
507 {
508 struct multi_instance *mi;
509 ASSERT(m->top.c2.link_sockets[0]);
512 if (mi)
513 {
514 multi_io_action(m, mi, TA_INITIAL, false);
515 }
516 }
517#if defined(ENABLE_DCO)
518 /* incoming data on DCO? */
519 else if (e->arg == MULTI_IO_DCO)
520 {
522 }
523#endif
524 /* signal received? */
525 else if (e->arg == MULTI_IO_SIG)
526 {
528 }
529#ifdef ENABLE_ASYNC_PUSH
530 else if (e->arg == MULTI_IO_FILE_CLOSE_WRITE)
531 {
532 multi_process_file_closed(m, MPP_PRE_SELECT | MPP_RECORD_TOUCH);
533 }
534#endif
535 }
536 if (IS_SIG(&m->top))
537 {
538 break;
539 }
540 }
541 multi_io->n_esr = 0;
542
543 /*
544 * Process queued mbuf packets destined for TCP socket
545 */
546 {
547 struct multi_instance *mi;
548 while (!IS_SIG(&m->top) && (mi = mbuf_peek(m->mbuf)) != NULL)
549 {
550 multi_io_action(m, mi, TA_SOCKET_WRITE, true);
551 }
552 }
553}
554
555void
556multi_io_action(struct multi_context *m, struct multi_instance *mi, int action, bool poll)
557{
558 bool tun_input_pending = false;
559
560 do
561 {
562 dmsg(D_MULTI_DEBUG, "MULTI IO: multi_io_action a=%s p=%d", pract(action), poll);
563
564 /*
565 * If TA_SOCKET_READ_RESIDUAL, it means we still have pending
566 * input packets which were read by a prior recv.
567 *
568 * Otherwise do a "lite" wait, which means we wait with 0 timeout
569 * on I/O events only related to the current instance, not
570 * the big list of events.
571 *
572 * On our first pass, poll will be false because we already know
573 * that input is available, and to call io_wait would be redundant.
574 */
575 if (poll && action != TA_SOCKET_READ_RESIDUAL)
576 {
577 const int orig_action = action;
578 action = multi_io_wait_lite(m, mi, action, &tun_input_pending);
579 if (action == TA_UNDEF)
580 {
581 msg(M_FATAL, "MULTI IO: I/O wait required blocking in multi_io_action, action=%d",
582 orig_action);
583 }
584 }
585
586 /*
587 * Dispatch the action
588 */
589 struct multi_instance *touched = multi_io_dispatch(m, mi, action);
590
591 /*
592 * Signal received or connection
593 * reset by peer?
594 */
595 if (touched && IS_SIG(&touched->context))
596 {
597 if (mi == touched)
598 {
599 mi = NULL;
600 }
602 }
603
604
605 /*
606 * If dispatch produced any pending output
607 * for a particular instance, point to
608 * that instance.
609 */
610 if (m->pending)
611 {
612 mi = m->pending;
613 }
614
615 /*
616 * Based on the effects of the action,
617 * such as generating pending output,
618 * possibly transition to a new action state.
619 */
620 action = multi_io_post(m, mi, action);
621
622 /*
623 * If we are finished processing the original action,
624 * check if we have any TUN input. If so, transition
625 * our action state to processing this input.
626 */
627 if (tun_input_pending && action == TA_UNDEF)
628 {
629 action = TA_TUN_READ;
630 mi = NULL;
631 tun_input_pending = false;
632 poll = false;
633 }
634 else
635 {
636 poll = true;
637 }
638
639 } while (action != TA_UNDEF);
640}
641
642void
644{
645 if (multi_io && multi_io->es)
646 {
647 event_del(multi_io->es, event);
648 }
649}
static void gc_free(struct gc_arena *a)
Definition buffer.h:1015
#define ALLOC_OBJ_CLEAR(dptr, type)
Definition buffer.h:1042
#define ALLOC_ARRAY(dptr, type, n)
Definition buffer.h:1048
static struct gc_arena gc_new(void)
Definition buffer.h:1007
unsigned long ptr_type
Definition common.h:57
#define ptr_format
Definition common.h:48
static void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg)
Definition dco.h:318
#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:65
static void event_free(struct event_set *es)
Definition event.h:162
static void event_del(struct event_set *es, event_t event)
Definition event.h:177
#define SOCKET_READ
Definition event.h:61
static int event_wait(struct event_set *es, const struct timeval *tv, struct event_set_return *out, int outlen)
Definition event.h:189
#define SOCKET_WRITE
Definition event.h:62
#define EVENT_WRITE
Definition event.h:39
#define MULTI_N
Definition event.h:88
#define EVENT_READ
Definition event.h:38
#define TUN_READ
Definition event.h:64
static void wait_signal(struct event_set *es, void *arg)
Definition event.h:208
@ EVENT_ARG_LINK_SOCKET
Definition event.h:138
@ EVENT_ARG_MULTI_INSTANCE
Definition event.h:137
static void event_ctl(struct event_set *es, event_t event, unsigned int rwflags, void *arg)
Definition event.h:183
void get_io_flags_udp(struct context *c, struct multi_io *multi_io, const unsigned int flags)
Definition forward.c:2174
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:3351
void read_incoming_link(struct context *c, struct link_socket *sock)
Read a packet from the external network interface.
Definition forward.c:925
void read_incoming_tun(struct context *c)
Read a packet from the virtual tun/tap network interface.
Definition forward.c:1322
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:3551
#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:3159
void management_io(struct management *man)
Definition manage.c:3197
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:54
bool multi_tcp_process_outgoing_link(struct multi_context *m, bool defer, const unsigned int mpp_flags)
Definition mtcp.c:185
bool multi_tcp_process_outgoing_link_ready(struct multi_context *m, struct multi_instance *mi, const unsigned int mpp_flags)
Definition mtcp.c:160
unsigned int p2mp_iow_flags(const struct multi_context *m)
Definition mudp.c:446
void multi_process_io_udp(struct multi_context *m, struct link_socket *sock)
Definition mudp.c:348
void multi_close_instance_on_signal(struct multi_context *m, struct multi_instance *mi)
Definition multi.c:3211
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:3012
bool multi_process_timeout(struct multi_context *m, const unsigned int mpp_flags)
Definition multi.c:3679
const char * multi_instance_string(const struct multi_instance *mi, bool null, struct gc_arena *gc)
Definition multi.c:441
void multi_process_drop_outgoing_tun(struct multi_context *m, const unsigned int mpp_flags)
Definition multi.c:3711
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:521
static void clear_prefix(void)
Definition multi.h:533
#define MPP_RECORD_TOUCH
Definition multi.h:278
#define MPP_PRE_SELECT
Definition multi.h:275
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:420
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:286
void multi_io_delete_event(struct multi_io *multi_io, event_t event)
Definition multi_io.c:643
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:363
void multi_io_action(struct multi_context *m, struct multi_instance *mi, int action, bool poll)
Definition multi_io.c:556
#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:9939
static void update_time(void)
Definition otime.h:81
static void tv_clear(struct timeval *tv)
Definition otime.h:105
static void perf_push(int type)
Definition perf.h:77
#define PERF_PROC_OUT_TUN_MTCP
Definition perf.h:56
static void perf_pop(void)
Definition perf.h:81
#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:2944
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:753
static bool stream_buf_read_setup(struct link_socket *sock)
Definition socket.h:504
static void socket_reset_listen_persistent(struct link_socket *sock)
Definition socket.h:763
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:148
struct multi_instance * mi
Definition event.h:147
union event_arg::@1 u
event_arg_t type
Definition event.h:144
unsigned int rwflags
Definition event.h:126
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:116
Main OpenVPN server state structure.
Definition multi.h:164
struct mbuf_set * mbuf
Set of buffers for passing data channel packets between VPN tunnel instances.
Definition multi.h:176
struct multi_io * multi_io
I/O state and events tracker.
Definition multi.h:179
struct context top
Storage structure for process-wide configuration.
Definition multi.h:203
struct multi_instance * pending
Definition multi.h:197
struct multi_instance ** mpp_touched
Definition multi.h:199
Server-mode state structure for one single VPN tunnel.
Definition multi.h:103
struct mbuf_set * tcp_link_out_deferred
Definition multi.h:129
unsigned int tcp_rwflags
Definition multi.h:128
bool socket_set_called
Definition multi.h:130
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:108
struct context context
The context structure storing state for this VPN tunnel.
Definition multi.h:144
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