OpenVPN
tun.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) 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#ifndef TUN_H
24#define TUN_H
25
26#ifdef _WIN32
27#include <winioctl.h>
28#include <tap-windows.h>
29#include <setupapi.h>
30#include <cfgmgr32.h>
31#endif
32
33#include "buffer.h"
34#include "error.h"
35#include "mtu.h"
36#include "win32.h"
37#include "event.h"
38#include "proto.h"
39#include "misc.h"
40#include "networking.h"
41#include "dco.h"
42
57
58#ifdef _WIN32
59#define DCO_WIN_REFERENCE_STRING "ovpn-dco"
60#endif
61
62#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST)
63
64/* time constants for --ip-win32 adaptive */
65#define IPW32_SET_ADAPTIVE_DELAY_WINDOW 300
66#define IPW32_SET_ADAPTIVE_TRY_NETSH 20
67
68/* bit flags for DHCP options */
69#define DHCP_OPTIONS_DHCP_OPTIONAL (1 << 0)
70#define DHCP_OPTIONS_DHCP_REQUIRED (1 << 1)
71
73{
74 /* --ip-win32 options */
76
77#define IPW32_SET_MANUAL 0 /* "--ip-win32 manual" */
78#define IPW32_SET_NETSH 1 /* "--ip-win32 netsh" */
79#define IPW32_SET_IPAPI 2 /* "--ip-win32 ipapi" */
80#define IPW32_SET_DHCP_MASQ 3 /* "--ip-win32 dynamic" */
81#define IPW32_SET_ADAPTIVE 4 /* "--ip-win32 adaptive" */
82#define IPW32_SET_N 5
84
85#ifdef _WIN32
87#endif
88
89 /* --ip-win32 dynamic options */
93
94 /* --tap-sleep option */
96
97 /* --dhcp-option options */
98
100
101 const char *domain; /* DOMAIN (15) */
102
103 const char *netbios_scope; /* NBS (47) */
104
105 uint8_t netbios_node_type; /* NBT 1,2,4,8 (46) */
106
107/* Max # of addresses allowed for DNS, WINS, etc. */
108#define N_DHCP_ADDR 4
109
110 /* DNS (6) */
112 unsigned int dns_len;
113
114 /* WINS (44) */
116 unsigned int wins_len;
117
118 /* NTP (42) */
120 unsigned int ntp_len;
121
122 /* NBDD (45) */
124 unsigned int nbdd_len;
125
126#define N_SEARCH_LIST_LEN 10 /* Max # of entries in domin-search list */
127
128 /* SEARCH (119), MacOS, Linux, Win10 1809+ */
131
132 /* DISABLE_NBT (43, Vendor option 001) */
134
137
139
140 struct in6_addr dns6[N_DHCP_ADDR];
141 unsigned int dns6_len;
142#if defined(TARGET_ANDROID)
143 const char *http_proxy;
144 int http_proxy_port;
145#endif
146};
147
148#elif defined(TARGET_LINUX)
149
150struct tuntap_options
151{
152 int txqueuelen;
153};
154
155#else /* if defined(_WIN32) || defined(TARGET_ANDROID) */
156
157struct tuntap_options
158{
159 int dummy; /* not used */
160};
161
162#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */
163
164/*
165 * Define a TUN/TAP dev.
166 */
167#ifndef WIN32
172
173#else /* ifndef WIN32 */
174typedef struct
175{
176 int dummy;
178#endif
179
180struct tuntap
181{
182#define TUNNEL_TYPE(tt) ((tt) ? ((tt)->type) : DEV_TYPE_UNDEF)
183 int type; /* DEV_TYPE_x as defined in proto.h */
184
185#define TUNNEL_TOPOLOGY(tt) ((tt) ? ((tt)->topology) : TOP_UNDEF)
186 int topology; /* one of the TOP_x values */
187
192
196
200
201 bool persistent_if; /* if existed before, keep on program end */
202
203 struct tuntap_options options; /* options set on command line */
204
205 char *actual_name; /* actual name of TUN/TAP dev, usually including unit number */
206
207 /* ifconfig parameters */
210
211 struct in6_addr local_ipv6;
212 struct in6_addr remote_ipv6;
214
215#ifdef _WIN32
216 HANDLE hand;
217 /* used for async NEW_PEER dco call, which might wait for TCP connect */
218 OVERLAPPED dco_new_peer_ov;
222
223 /* used for setting interface address via IP Helper API
224 * or DHCP masquerade */
229
230 /* Windows adapter index for TAP-Windows adapter,
231 * TUN_ADAPTER_INDEX_INVALID if undefined */
233
235
236#else /* ifdef _WIN32 */
237 int fd; /* file descriptor for TUN/TAP dev */
238#endif /* ifdef _WIN32 */
239
240#ifdef TARGET_SOLARIS
241 int ip_fd;
242#endif
243
244 /* used for printing status info only */
245 unsigned int rwflags_debug;
246
249};
250
251static inline bool
252tuntap_defined(const struct tuntap *tt)
253{
254#ifdef _WIN32
255 return tt && tt->hand != NULL;
256#else
257 return tt && tt->fd >= 0;
258#endif
259}
260
261/*
262 * Function prototypes
263 */
264
265void open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt,
266 openvpn_net_ctx_t *ctx);
267
268void close_tun(struct tuntap *tt, openvpn_net_ctx_t *ctx);
269
270void tun_open_device(struct tuntap *tt, const char *dev_node, const char **device_guid,
271 struct gc_arena *gc);
272
273void close_tun_handle(struct tuntap *tt);
274
275ssize_t write_tun(struct tuntap *tt, uint8_t *buf, int len);
276
277ssize_t read_tun(struct tuntap *tt, uint8_t *buf, int len);
278
279#ifdef ENABLE_FEATURE_TUN_PERSIST
280void tuncfg(const char *dev, const char *dev_type, const char *dev_node, int persist_mode,
281 const char *username, const char *groupname, const struct tuntap_options *options,
282 openvpn_net_ctx_t *ctx);
283#endif
284
285const char *guess_tuntap_dev(const char *dev, const char *dev_type, const char *dev_node,
286 struct gc_arena *gc);
287
288struct tuntap *init_tun(const char *dev, /* --dev option */
289 const char *dev_type, /* --dev-type option */
290 int topology, /* one of the TOP_x values */
291 const char *ifconfig_local_parm, /* --ifconfig parm 1 */
292 const char *ifconfig_remote_netmask_parm, /* --ifconfig parm 2 */
293 const char *ifconfig_ipv6_local_parm, /* --ifconfig parm 1 / IPv6 */
294 int ifconfig_ipv6_netbits_parm, /* --ifconfig parm 1 / bits */
295 const char *ifconfig_ipv6_remote_parm, /* --ifconfig parm 2 / IPv6 */
296 struct addrinfo *local_public, struct addrinfo *remote_public,
297 const bool strict_warn, struct env_set *es, openvpn_net_ctx_t *ctx,
298 struct tuntap *tt);
299
300void init_tun_post(struct tuntap *tt, const struct frame *frame,
301 const struct tuntap_options *options);
302
303void do_ifconfig_setenv(const struct tuntap *tt, struct env_set *es);
304
314void do_ifconfig(struct tuntap *tt, const char *ifname, int tun_mtu, const struct env_set *es,
315 openvpn_net_ctx_t *ctx);
316
323void undo_ifconfig(struct tuntap *tt, openvpn_net_ctx_t *ctx);
324
325bool is_dev_type(const char *dev, const char *dev_type, const char *match_type);
326
327int dev_type_enum(const char *dev, const char *dev_type);
328
329const char *dev_type_string(const char *dev, const char *dev_type);
330
331const char *ifconfig_options_string(const struct tuntap *tt, bool remote, bool disable,
332 struct gc_arena *gc);
333
334bool is_tun_p2p(const struct tuntap *tt);
335
337
341const char *print_tun_backend_driver(enum tun_driver_type driver);
342
343/*
344 * Should ifconfig be called before or after
345 * tun dev open?
346 */
347
348#define IFCONFIG_BEFORE_TUN_OPEN 0
349#define IFCONFIG_AFTER_TUN_OPEN 1
350
351#define IFCONFIG_DEFAULT IFCONFIG_AFTER_TUN_OPEN
352
353static inline int
355{
356 if (tt->backend_driver == DRIVER_AFUNIX)
357 {
359 }
360#if defined(TARGET_LINUX)
362#elif defined(TARGET_SOLARIS)
364#elif defined(TARGET_OPENBSD)
366#elif defined(TARGET_DARWIN)
368#elif defined(TARGET_NETBSD)
370#elif defined(_WIN32)
372#elif defined(TARGET_ANDROID)
374#else /* if defined(TARGET_LINUX) */
375 return IFCONFIG_DEFAULT;
376#endif
377}
378
379#define ROUTE_BEFORE_TUN 0
380#define ROUTE_AFTER_TUN 1
381#define ROUTE_ORDER_DEFAULT ROUTE_AFTER_TUN
382
383static inline int
385{
386 if (tt->backend_driver == DRIVER_AFUNIX)
387 {
388 return ROUTE_BEFORE_TUN;
389 }
390#if defined(TARGET_ANDROID)
391 return ROUTE_BEFORE_TUN;
392#else
393 return ROUTE_ORDER_DEFAULT;
394#endif
395}
396
397
398#ifdef _WIN32
399
401{
402 const char *guid;
404 struct tap_reg *next;
405};
406
408{
409 const char *name;
410 const char *guid;
412};
413
420
421int ascii2ipset(const char *name);
422
423const char *ipset2ascii(int index);
424
425const char *ipset2ascii_all(struct gc_arena *gc);
426
427void verify_255_255_255_252(in_addr_t local, in_addr_t remote);
428
429const IP_ADAPTER_INFO *get_adapter_info_list(struct gc_arena *gc);
430
431const IP_ADAPTER_INFO *get_tun_adapter(const struct tuntap *tt, const IP_ADAPTER_INFO *list);
432
433const IP_ADAPTER_INFO *get_adapter_info(DWORD index, struct gc_arena *gc);
434
435const IP_PER_ADAPTER_INFO *get_per_adapter_info(const DWORD index, struct gc_arena *gc);
436
437const IP_ADAPTER_INFO *get_adapter(const IP_ADAPTER_INFO *ai, DWORD index);
438
439bool is_adapter_up(const struct tuntap *tt, const IP_ADAPTER_INFO *list);
440
441bool is_ip_in_adapter_subnet(const IP_ADAPTER_INFO *ai, const in_addr_t ip,
442 in_addr_t *highest_netmask);
443
444DWORD adapter_index_of_ip(const IP_ADAPTER_INFO *list, const in_addr_t ip, int *count,
445 in_addr_t *netmask);
446
447void show_tap_win_adapters(msglvl_t msglevel, msglvl_t warnlevel);
448
449void show_adapters(msglvl_t msglevel);
450
451void tap_allow_nonadmin_access(const char *dev_node);
452
454
455const char *tap_win_getinfo(const struct tuntap *tt, struct gc_arena *gc);
456
457void tun_show_debug(struct tuntap *tt);
458
459bool dhcp_release_by_adapter_index(const DWORD adapter_index);
460
461bool dhcp_renew_by_adapter_index(const DWORD adapter_index);
462
463void fork_register_dns_action(struct tuntap *tt);
464
465void ipconfig_register_dns(const struct env_set *es);
466
467void tun_standby_init(struct tuntap *tt);
468
469bool tun_standby(struct tuntap *tt);
470
471int tun_read_queue(struct tuntap *tt, int maxsize);
472
473int tun_write_queue(struct tuntap *tt, struct buffer *buf);
474
475static inline bool
477{
478 /*
479 * This corresponds to the STATUS_NO_SUCH_DEVICE
480 * error in tapdrvr.c.
481 */
482 if (status < 0)
483 {
484 return GetLastError() == ERROR_FILE_NOT_FOUND;
485 }
486 return false;
487}
488
489static inline bool
491{
492 /*
493 * Typically generated when driver is halted.
494 */
495 if (status < 0)
496 {
497 return GetLastError() == ERROR_OPERATION_ABORTED;
498 }
499 return false;
500}
501
502int tun_write_win32(struct tuntap *tt, struct buffer *buf);
503
504static inline bool
505is_ip_packet_valid(const struct buffer *buf)
506{
507 const struct openvpn_iphdr *ih = (const struct openvpn_iphdr *)BPTR(buf);
508
509 if (OPENVPN_IPH_GET_VER(ih->version_len) == 4)
510 {
511 if (BLENZ(buf) < sizeof(struct openvpn_iphdr))
512 {
513 return false;
514 }
515 }
516 else if (OPENVPN_IPH_GET_VER(ih->version_len) == 6)
517 {
518 if (BLENZ(buf) < sizeof(struct openvpn_ipv6hdr))
519 {
520 return false;
521 }
522 }
523 else
524 {
525 return false;
526 }
527
528 return true;
529}
530
531static inline bool
533{
534 return tt && tt->backend_driver == DRIVER_DCO;
535}
536
537static inline bool
539{
540 return tuntap_is_dco_win(tt) && (status < 0) && (openvpn_errno() == ERROR_NETNAME_DELETED);
541}
542
543#else /* ifdef _WIN32 */
544
545static inline bool
547{
548 return false;
549}
550
551static inline bool
553{
554 return false;
555}
556
557static inline void
558tun_standby_init(struct tuntap *tt)
559{
560}
561
562static inline bool
563tun_standby(struct tuntap *tt)
564{
565 return true;
566}
567
568
569static inline bool
570tuntap_is_dco_win(struct tuntap *tt)
571{
572 return false;
573}
574
575static inline bool
577{
578 return false;
579}
580
581#endif /* ifdef _WIN32 */
582
583/*
584 * TUN/TAP I/O wait functions
585 */
586
587static inline event_t
588tun_event_handle(const struct tuntap *tt)
589{
590#ifdef _WIN32
591 return &tt->rw_handle;
592#else
593 return tt->fd;
594#endif
595}
596
597static inline void
598tun_set(struct tuntap *tt, struct event_set *es, unsigned int rwflags, void *arg,
599 unsigned int *persistent)
600{
601 if (!tuntap_defined(tt) || tuntap_is_dco_win(tt))
602 {
603 return;
604 }
605
606 /* if persistent is defined, call event_ctl only if rwflags has changed since last call */
607 if (!persistent || *persistent != rwflags)
608 {
609 event_ctl(es, tun_event_handle(tt), rwflags, arg);
610 if (persistent)
611 {
612 *persistent = rwflags;
613 }
614 }
615#ifdef _WIN32
616 if (tt->backend_driver == WINDOWS_DRIVER_TAP_WINDOWS6 && (rwflags & EVENT_READ))
617 {
618 tun_read_queue(tt, 0);
619 }
620#endif
621 tt->rwflags_debug = rwflags;
622}
623
624const char *tun_stat(const struct tuntap *tt, unsigned int rwflags, struct gc_arena *gc);
625bool tun_name_is_fixed(const char *dev);
626
627static inline bool
628is_tun_type_set(const struct tuntap *tt)
629{
630 return tt && tt->type != DEV_TYPE_UNDEF;
631}
632
633static inline void
635{
636 tt->actual_name = string_alloc("null", NULL);
637}
638#endif /* TUN_H */
char * string_alloc(const char *str, struct gc_arena *gc)
Definition buffer.c:653
#define BPTR(buf)
Definition buffer.h:123
#define BLENZ(buf)
Definition buffer.h:127
void * dco_context_t
Definition dco.h:259
#define EVENT_READ
Definition event.h:37
static void event_ctl(struct event_set *es, event_t event, unsigned int rwflags, void *arg)
Definition event.h:180
static SERVICE_STATUS status
Definition interactive.c:51
void * openvpn_net_ctx_t
Definition networking.h:38
#define openvpn_errno()
Definition error.h:71
unsigned int msglvl_t
Definition error.h:77
#define DEV_TYPE_UNDEF
Definition proto.h:34
#define OPENVPN_IPH_GET_VER(v)
Definition proto.h:91
pid_t childprocess
Definition tun.h:170
Wrapper structure for dynamically allocated memory.
Definition buffer.h:60
const char * device_interface
Definition tun.h:417
struct device_instance_id_interface * next
Definition tun.h:418
Packet geometry parameters.
Definition mtu.h:108
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:116
uint8_t version_len
Definition proto.h:93
struct panel_reg * next
Definition tun.h:411
const char * name
Definition tun.h:409
const char * guid
Definition tun.h:410
Definition tun.h:401
struct tap_reg * next
Definition tun.h:404
enum tun_driver_type windows_driver
Definition tun.h:403
const char * guid
Definition tun.h:402
struct in6_addr dns6[N_DHCP_ADDR]
Definition tun.h:140
in_addr_t nbdd[N_DHCP_ADDR]
Definition tun.h:123
unsigned int dns6_len
Definition tun.h:141
in_addr_t ntp[N_DHCP_ADDR]
Definition tun.h:119
unsigned int ntp_len
Definition tun.h:120
in_addr_t wins[N_DHCP_ADDR]
Definition tun.h:115
int tap_sleep
Definition tun.h:95
uint8_t netbios_node_type
Definition tun.h:105
unsigned int dns_len
Definition tun.h:112
int dhcp_lease_time
Definition tun.h:92
in_addr_t dns[N_DHCP_ADDR]
Definition tun.h:111
const char * netbios_scope
Definition tun.h:103
bool ip_win32_defined
Definition tun.h:75
unsigned int domain_search_list_len
Definition tun.h:130
bool dhcp_masq_custom_offset
Definition tun.h:90
const char * domain
Definition tun.h:101
bool dhcp_renew
Definition tun.h:135
const char * domain_search_list[N_SEARCH_LIST_LEN]
Definition tun.h:129
HANDLE msg_channel
Definition tun.h:86
int dhcp_masq_offset
Definition tun.h:91
int ip_win32_type
Definition tun.h:83
unsigned int nbdd_len
Definition tun.h:124
bool dhcp_pre_release
Definition tun.h:136
bool register_dns
Definition tun.h:138
bool disable_nbt
Definition tun.h:133
unsigned int wins_len
Definition tun.h:116
int dhcp_options
Definition tun.h:99
Definition tun.h:181
unsigned int rwflags_debug
Definition tun.h:245
in_addr_t local
Definition tun.h:208
int type
Definition tun.h:183
ULONG ipapi_instance
Definition tun.h:227
int netbits_ipv6
Definition tun.h:213
DWORD adapter_index
Definition tun.h:232
int standby_iter
Definition tun.h:234
struct rw_handle rw_handle
Definition tun.h:221
enum tun_driver_type backend_driver
The backend driver that used for this tun/tap device.
Definition tun.h:191
OVERLAPPED dco_new_peer_ov
Definition tun.h:218
bool did_ifconfig_ipv6_setup
if the internal variables related to ifconfig-ipv6 of this struct have been set up.
Definition tun.h:199
struct in6_addr remote_ipv6
Definition tun.h:212
bool did_ifconfig_setup
if the internal variables related to ifconfig of this struct have been set up.
Definition tun.h:195
int topology
Definition tun.h:186
struct overlapped_io writes
Definition tun.h:220
in_addr_t adapter_netmask
Definition tun.h:228
HANDLE hand
Definition tun.h:216
struct overlapped_io reads
Definition tun.h:219
struct in6_addr local_ipv6
Definition tun.h:211
ULONG ipapi_context
Definition tun.h:226
dco_context_t dco
Definition tun.h:247
char * actual_name
Definition tun.h:205
in_addr_t remote_netmask
Definition tun.h:209
afunix_context_t afunix
Definition tun.h:248
bool ipapi_context_defined
Definition tun.h:225
bool persistent_if
Definition tun.h:201
uint32_t in_addr_t
Definition syshead.h:52
struct env_set * es
struct gc_arena gc
Definition test_ssl.c:131
void ipconfig_register_dns(const struct env_set *es)
Definition tun.c:4889
ssize_t write_tun(struct tuntap *tt, uint8_t *buf, int len)
void tun_show_debug(struct tuntap *tt)
Definition tun.c:6054
static bool tuntap_abort(int status)
Definition tun.h:490
void open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt, openvpn_net_ctx_t *ctx)
Definition tun.c:5997
int dev_type_enum(const char *dev, const char *dev_type)
Definition tun.c:521
void close_tun_handle(struct tuntap *tt)
Definition tun.c:6117
void fork_register_dns_action(struct tuntap *tt)
Definition tun.c:5386
#define IFCONFIG_AFTER_TUN_OPEN
Definition tun.h:349
#define N_SEARCH_LIST_LEN
Definition tun.h:126
void show_tap_win_adapters(msglvl_t msglevel, msglvl_t warnlevel)
Definition tun.c:3815
#define IFCONFIG_BEFORE_TUN_OPEN
Definition tun.h:348
bool dhcp_renew_by_adapter_index(const DWORD adapter_index)
Definition tun.c:4822
int ascii2ipset(const char *name)
Definition tun.c:6249
const IP_ADAPTER_INFO * get_tun_adapter(const struct tuntap *tt, const IP_ADAPTER_INFO *list)
Definition tun.c:4303
bool is_adapter_up(const struct tuntap *tt, const IP_ADAPTER_INFO *list)
Definition tun.c:4316
const IP_ADAPTER_INFO * get_adapter_info(DWORD index, struct gc_arena *gc)
Definition tun.c:4218
struct tuntap * init_tun(const char *dev, const char *dev_type, int topology, const char *ifconfig_local_parm, const char *ifconfig_remote_netmask_parm, const char *ifconfig_ipv6_local_parm, int ifconfig_ipv6_netbits_parm, const char *ifconfig_ipv6_remote_parm, struct addrinfo *local_public, struct addrinfo *remote_public, const bool strict_warn, struct env_set *es, openvpn_net_ctx_t *ctx, struct tuntap *tt)
Definition tun.c:830
const char * tun_stat(const struct tuntap *tt, unsigned int rwflags, struct gc_arena *gc)
Definition tun.c:731
static bool is_ip_packet_valid(const struct buffer *buf)
Definition tun.h:505
ssize_t read_tun(struct tuntap *tt, uint8_t *buf, int len)
const IP_PER_ADAPTER_INFO * get_per_adapter_info(const DWORD index, struct gc_arena *gc)
Definition tun.c:4116
static bool tuntap_is_dco_win(struct tuntap *tt)
Definition tun.h:532
#define ROUTE_ORDER_DEFAULT
Definition tun.h:381
int tun_write_win32(struct tuntap *tt, struct buffer *buf)
Definition tun.c:3378
bool is_ip_in_adapter_subnet(const IP_ADAPTER_INFO *ai, const in_addr_t ip, in_addr_t *highest_netmask)
Definition tun.c:4360
struct afunix_context afunix_context_t
const char * tap_win_getinfo(const struct tuntap *tt, struct gc_arena *gc)
Definition tun.c:6038
bool is_dev_type(const char *dev, const char *dev_type, const char *match_type)
Definition tun.c:503
int tun_write_queue(struct tuntap *tt, struct buffer *buf)
Definition tun.c:3323
static bool tuntap_defined(const struct tuntap *tt)
Definition tun.h:252
bool dhcp_release_by_adapter_index(const DWORD adapter_index)
Definition tun.c:4781
bool tun_standby(struct tuntap *tt)
Definition tun.c:5310
void do_ifconfig(struct tuntap *tt, const char *ifname, int tun_mtu, const struct env_set *es, openvpn_net_ctx_t *ctx)
do_ifconfig - configure the tunnel interface
Definition tun.c:1566
const char * dev_type_string(const char *dev, const char *dev_type)
Definition tun.c:540
tun_driver_type
Definition tun.h:44
@ DRIVER_NULL
Definition tun.h:52
@ WINDOWS_DRIVER_UNSPECIFIED
Definition tun.h:45
@ DRIVER_UTUN
macOS internal tun driver
Definition tun.h:55
@ DRIVER_GENERIC_TUNTAP
Definition tun.h:47
@ DRIVER_AFUNIX
using an AF_UNIX socket to pass packets from/to an external program.
Definition tun.h:51
@ WINDOWS_DRIVER_TAP_WINDOWS6
Definition tun.h:46
@ DRIVER_DCO
Definition tun.h:53
void close_tun(struct tuntap *tt, openvpn_net_ctx_t *ctx)
Definition tun.c:6148
const IP_ADAPTER_INFO * get_adapter_info_list(struct gc_arena *gc)
Definition tun.c:4091
void tap_allow_nonadmin_access(const char *dev_node)
Definition tun.c:4701
bool tun_name_is_fixed(const char *dev)
Definition tun.c:1804
const IP_ADAPTER_INFO * get_adapter(const IP_ADAPTER_INFO *ai, DWORD index)
Definition tun.c:4199
static void tun_set(struct tuntap *tt, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent)
Definition tun.h:598
#define IFCONFIG_DEFAULT
Definition tun.h:351
void show_adapters(msglvl_t msglevel)
Definition tun.c:4652
void warn_on_use_of_common_subnets(openvpn_net_ctx_t *ctx)
Definition tun.c:670
#define N_DHCP_ADDR
Definition tun.h:108
int tun_read_queue(struct tuntap *tt, int maxsize)
Definition tun.c:3268
static event_t tun_event_handle(const struct tuntap *tt)
Definition tun.h:588
void init_tun_post(struct tuntap *tt, const struct frame *frame, const struct tuntap_options *options)
Definition tun.c:954
static int ifconfig_order(struct tuntap *tt)
Definition tun.h:354
static void open_tun_null(struct tuntap *tt)
Definition tun.h:634
const char * ifconfig_options_string(const struct tuntap *tt, bool remote, bool disable, struct gc_arena *gc)
Definition tun.c:694
const char * guess_tuntap_dev(const char *dev, const char *dev_type, const char *dev_node, struct gc_arena *gc)
Definition tun.c:560
const char * ipset2ascii(int index)
Definition tun.c:6264
void do_ifconfig_setenv(const struct tuntap *tt, struct env_set *es)
Definition tun.c:786
static bool tuntap_is_dco_win_timeout(struct tuntap *tt, int status)
Definition tun.h:538
void undo_ifconfig(struct tuntap *tt, openvpn_net_ctx_t *ctx)
undo_ifconfig - undo configuration of the tunnel interface
Definition tun.c:1655
bool is_tun_p2p(const struct tuntap *tt)
Definition tun.c:762
const char * ipset2ascii_all(struct gc_arena *gc)
Definition tun.c:6278
static int route_order(struct tuntap *tt)
Definition tun.h:384
void tun_standby_init(struct tuntap *tt)
Definition tun.c:5304
void show_valid_win32_tun_subnets(void)
Definition tun.c:3782
static bool tuntap_stop(int status)
Definition tun.h:476
const char * print_tun_backend_driver(enum tun_driver_type driver)
Return a string representation of the tun backed driver type.
Definition tun.c:59
#define ROUTE_BEFORE_TUN
Definition tun.h:379
static bool is_tun_type_set(const struct tuntap *tt)
Definition tun.h:628
DWORD adapter_index_of_ip(const IP_ADAPTER_INFO *list, const in_addr_t ip, int *count, in_addr_t *netmask)
Definition tun.c:4394
void tun_open_device(struct tuntap *tt, const char *dev_node, const char **device_guid, struct gc_arena *gc)
Definition tun.c:5815
void verify_255_255_255_252(in_addr_t local, in_addr_t remote)
Definition tun.c:3746