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