OpenVPN
|
#include <winioctl.h>
#include <tap-windows.h>
#include <setupapi.h>
#include <cfgmgr32.h>
#include "buffer.h"
#include "error.h"
#include "mtu.h"
#include "win32.h"
#include "event.h"
#include "proto.h"
#include "misc.h"
#include "networking.h"
#include "ring_buffer.h"
Go to the source code of this file.
Data Structures | |
struct | tuntap_options |
struct | tuntap |
struct | tap_reg |
struct | panel_reg |
struct | device_instance_id_interface |
Macros | |
#define | WINTUN_COMPONENT_ID "wintun" |
#define | TUN_ADAPTER_INDEX_INVALID ((DWORD)-1) |
#define | IPW32_SET_ADAPTIVE_DELAY_WINDOW 300 |
#define | IPW32_SET_ADAPTIVE_TRY_NETSH 20 |
#define | IPW32_SET_MANUAL 0 /* "--ip-win32 manual" */ |
#define | IPW32_SET_NETSH 1 /* "--ip-win32 netsh" */ |
#define | IPW32_SET_IPAPI 2 /* "--ip-win32 ipapi" */ |
#define | IPW32_SET_DHCP_MASQ 3 /* "--ip-win32 dynamic" */ |
#define | IPW32_SET_ADAPTIVE 4 /* "--ip-win32 adaptive" */ |
#define | IPW32_SET_N 5 |
#define | N_DHCP_ADDR |
#define | N_SEARCH_LIST_LEN 10 /* Max # of entries in domin-search list */ |
#define | TUNNEL_TYPE(tt) ((tt) ? ((tt)->type) : DEV_TYPE_UNDEF) |
#define | TUNNEL_TOPOLOGY(tt) ((tt) ? ((tt)->topology) : TOP_UNDEF) |
#define | IFCONFIG_BEFORE_TUN_OPEN 0 |
#define | IFCONFIG_AFTER_TUN_OPEN 1 |
#define | IFCONFIG_DEFAULT IFCONFIG_AFTER_TUN_OPEN |
#define | ROUTE_BEFORE_TUN 0 |
#define | ROUTE_AFTER_TUN 1 |
#define | ROUTE_ORDER_DEFAULT ROUTE_AFTER_TUN |
Enumerations | |
enum | windows_driver_type { WINDOWS_DRIVER_UNSPECIFIED, WINDOWS_DRIVER_TAP_WINDOWS6, WINDOWS_DRIVER_WINTUN } |
Functions | |
static bool | tuntap_defined (const struct tuntap *tt) |
static bool | tuntap_is_wintun (struct tuntap *tt) |
static bool | tuntap_ring_empty (struct tuntap *tt) |
void | open_tun (const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt) |
void | close_tun (struct tuntap *tt, openvpn_net_ctx_t *ctx) |
int | write_tun (struct tuntap *tt, uint8_t *buf, int len) |
int | read_tun (struct tuntap *tt, uint8_t *buf, int len) |
void | tuncfg (const char *dev, const char *dev_type, const char *dev_node, int persist_mode, const char *username, const char *groupname, const struct tuntap_options *options, openvpn_net_ctx_t *ctx) |
const char * | guess_tuntap_dev (const char *dev, const char *dev_type, const char *dev_node, struct gc_arena *gc) |
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) |
void | init_tun_post (struct tuntap *tt, const struct frame *frame, const struct tuntap_options *options) |
void | do_ifconfig_setenv (const struct tuntap *tt, struct env_set *es) |
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 More... | |
bool | is_dev_type (const char *dev, const char *dev_type, const char *match_type) |
int | dev_type_enum (const char *dev, const char *dev_type) |
const char * | dev_type_string (const char *dev, const char *dev_type) |
const char * | ifconfig_options_string (const struct tuntap *tt, bool remote, bool disable, struct gc_arena *gc) |
bool | is_tun_p2p (const struct tuntap *tt) |
void | check_subnet_conflict (const in_addr_t ip, const in_addr_t netmask, const char *prefix) |
void | warn_on_use_of_common_subnets (openvpn_net_ctx_t *ctx) |
static int | ifconfig_order (void) |
static int | route_order (void) |
int | ascii2ipset (const char *name) |
const char * | ipset2ascii (int index) |
const char * | ipset2ascii_all (struct gc_arena *gc) |
void | verify_255_255_255_252 (in_addr_t local, in_addr_t remote) |
const IP_ADAPTER_INFO * | get_adapter_info_list (struct gc_arena *gc) |
const IP_ADAPTER_INFO * | get_tun_adapter (const struct tuntap *tt, const IP_ADAPTER_INFO *list) |
const IP_ADAPTER_INFO * | get_adapter_info (DWORD index, struct gc_arena *gc) |
const IP_PER_ADAPTER_INFO * | get_per_adapter_info (const DWORD index, struct gc_arena *gc) |
const IP_ADAPTER_INFO * | get_adapter (const IP_ADAPTER_INFO *ai, DWORD index) |
bool | is_adapter_up (const struct tuntap *tt, const IP_ADAPTER_INFO *list) |
bool | is_ip_in_adapter_subnet (const IP_ADAPTER_INFO *ai, const in_addr_t ip, in_addr_t *highest_netmask) |
DWORD | adapter_index_of_ip (const IP_ADAPTER_INFO *list, const in_addr_t ip, int *count, in_addr_t *netmask) |
void | show_tap_win_adapters (int msglev, int warnlev) |
void | show_adapters (int msglev) |
void | tap_allow_nonadmin_access (const char *dev_node) |
void | show_valid_win32_tun_subnets (void) |
const char * | tap_win_getinfo (const struct tuntap *tt, struct gc_arena *gc) |
void | tun_show_debug (struct tuntap *tt) |
bool | dhcp_release_by_adapter_index (const DWORD adapter_index) |
bool | dhcp_renew_by_adapter_index (const DWORD adapter_index) |
void | fork_register_dns_action (struct tuntap *tt) |
void | ipconfig_register_dns (const struct env_set *es) |
void | tun_standby_init (struct tuntap *tt) |
bool | tun_standby (struct tuntap *tt) |
int | tun_read_queue (struct tuntap *tt, int maxsize) |
int | tun_write_queue (struct tuntap *tt, struct buffer *buf) |
int | tun_finalize (HANDLE h, struct overlapped_io *io, struct buffer *buf) |
static bool | tuntap_stop (int status) |
static bool | tuntap_abort (int status) |
static int | tun_write_win32 (struct tuntap *tt, struct buffer *buf) |
static int | read_tun_buffered (struct tuntap *tt, struct buffer *buf) |
static ULONG | wintun_ring_packet_align (ULONG size) |
static ULONG | wintun_ring_wrap (ULONG value) |
static void | read_wintun (struct tuntap *tt, struct buffer *buf) |
static bool | is_ip_packet_valid (const struct buffer *buf) |
static int | write_wintun (struct tuntap *tt, struct buffer *buf) |
static int | write_tun_buffered (struct tuntap *tt, struct buffer *buf) |
static event_t | tun_event_handle (const struct tuntap *tt) |
static void | tun_set (struct tuntap *tt, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent) |
const char * | tun_stat (const struct tuntap *tt, unsigned int rwflags, struct gc_arena *gc) |
#define IFCONFIG_AFTER_TUN_OPEN 1 |
Definition at line 325 of file tun.h.
Referenced by do_open_tun(), and ifconfig_order().
#define IFCONFIG_BEFORE_TUN_OPEN 0 |
Definition at line 324 of file tun.h.
Referenced by do_open_tun(), and ifconfig_order().
#define IFCONFIG_DEFAULT IFCONFIG_AFTER_TUN_OPEN |
Definition at line 327 of file tun.h.
Referenced by ifconfig_order().
#define IPW32_SET_ADAPTIVE 4 /* "--ip-win32 adaptive" */ |
Definition at line 70 of file tun.h.
Referenced by add_option(), close_tun(), do_ifconfig_ipv4(), init_options(), options_postprocess_mutate_invariant(), options_postprocess_verify_ce(), tun_standby(), and tuntap_set_ip_props().
#define IPW32_SET_ADAPTIVE_DELAY_WINDOW 300 |
Definition at line 59 of file tun.h.
Referenced by add_option().
#define IPW32_SET_ADAPTIVE_TRY_NETSH 20 |
Definition at line 60 of file tun.h.
Referenced by tun_standby().
#define IPW32_SET_DHCP_MASQ 3 /* "--ip-win32 dynamic" */ |
Definition at line 69 of file tun.h.
Referenced by add_option(), close_tun(), dhcp_release(), dhcp_renew(), do_ifconfig_ipv4(), init_options(), options_postprocess_mutate_invariant(), options_postprocess_verify_ce(), and tuntap_set_ip_props().
#define IPW32_SET_IPAPI 2 /* "--ip-win32 ipapi" */ |
Definition at line 68 of file tun.h.
Referenced by tuntap_set_ip_addr().
#define IPW32_SET_MANUAL 0 /* "--ip-win32 manual" */ |
Definition at line 66 of file tun.h.
Referenced by close_tun(), do_ifconfig_ipv4(), do_ifconfig_ipv6(), and options_postprocess_mutate_invariant().
#define IPW32_SET_N 5 |
Definition at line 71 of file tun.h.
Referenced by ascii2ipset(), ipset2ascii(), and ipset2ascii_all().
#define IPW32_SET_NETSH 1 /* "--ip-win32 netsh" */ |
Definition at line 67 of file tun.h.
Referenced by close_tun(), do_ifconfig_ipv4(), and options_postprocess_mutate_invariant().
#define N_DHCP_ADDR |
Definition at line 96 of file tun.h.
Referenced by dhcp_option_address_parse(), and dhcp_option_dns6_parse().
#define N_SEARCH_LIST_LEN 10 /* Max # of entries in domin-search list */ |
Definition at line 115 of file tun.h.
Referenced by add_option().
#define ROUTE_AFTER_TUN 1 |
Definition at line 352 of file tun.h.
Referenced by do_open_tun(), and do_up().
#define ROUTE_BEFORE_TUN 0 |
Definition at line 351 of file tun.h.
Referenced by do_open_tun(), and route_order().
#define ROUTE_ORDER_DEFAULT ROUTE_AFTER_TUN |
Definition at line 353 of file tun.h.
Referenced by route_order().
#define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1) |
Definition at line 56 of file tun.h.
Referenced by adapter_index_of_ip(), add_route(), add_route_ipapi(), del_route_ipapi(), dhcp_release(), dhcp_renew(), dhcp_status(), do_address_service(), do_route_ipv6_service(), get_adapter(), get_adapter_index(), get_adapter_index_method_1(), get_adapter_index_method_2(), get_default_gateway(), get_per_adapter_info(), init_tun_post(), tuntap_set_ip_addr(), and windows_route_find_if_index().
#define TUNNEL_TOPOLOGY | ( | tt | ) | ((tt) ? ((tt)->topology) : TOP_UNDEF) |
Definition at line 160 of file tun.h.
Referenced by multi_select_virtual_addr(), and multi_set_virtual_addr_env().
#define TUNNEL_TYPE | ( | tt | ) | ((tt) ? ((tt)->type) : DEV_TYPE_UNDEF) |
Definition at line 157 of file tun.h.
Referenced by drop_if_recursive_routing(), ipv6_send_icmp_unreachable(), multi_add_iroutes(), multi_client_connect_late_setup(), multi_del_iroutes(), multi_process_incoming_link(), multi_process_incoming_tun(), multi_select_virtual_addr(), multi_set_virtual_addr_env(), process_incoming_link_part2(), process_incoming_tun(), process_ip_header(), process_outgoing_tun(), and read_incoming_tun().
#define WINTUN_COMPONENT_ID "wintun" |
Definition at line 45 of file tun.h.
Referenced by get_tap_reg().
enum windows_driver_type |
DWORD adapter_index_of_ip | ( | const IP_ADAPTER_INFO * | list, |
const in_addr_t | ip, | ||
int * | count, | ||
in_addr_t * | netmask | ||
) |
Definition at line 4677 of file tun.c.
References D_ROUTE_DEBUG, dmsg, gc_free(), gc_new(), get_interface_metric(), in_addr_t, is_ip_in_adapter_subnet(), print_in_addr_t(), and TUN_ADAPTER_INDEX_INVALID.
Referenced by get_default_gateway(), and test_route().
int ascii2ipset | ( | const char * | name | ) |
Definition at line 6908 of file tun.c.
References ASSERT, IPW32_SET_N, ipset_names::short_form, and SIZE.
Referenced by add_option().
Definition at line 536 of file tun.c.
References gc_free(), gc_new(), get_default_gateway(), in_addr_t, M_WARN, msg, and print_in_addr_t().
Referenced by add_routes(), init_tun(), and tuntap_ring_empty().
void close_tun | ( | struct tuntap * | tt, |
openvpn_net_ctx_t * | ctx | ||
) |
Definition at line 6780 of file tun.c.
References tuntap::actual_name, ASSERT, clear_tuntap(), D_WIN32_IO_LOW, delete_route_connected_v6_net(), dhcp_release(), tuntap::did_ifconfig_ipv6_setup, tuntap::did_ifconfig_setup, dmsg, tuntap_options::dns6_len, do_address_service(), do_dns_domain_service(), do_dns_service(), free, gc_free(), gc_new(), tuntap::hand, tuntap_options::ip_win32_type, tuntap::ipapi_context, tuntap::ipapi_context_defined, IPW32_SET_ADAPTIVE, IPW32_SET_DHCP_MASQ, IPW32_SET_MANUAL, IPW32_SET_NETSH, M_ERRNO, M_WARN, msg, tuntap_options::msg_channel, netsh_delete_address_dns(), tuntap::options, overlapped_io_close(), rw_handle::read, tuntap::reads, tuntap::rw_handle, status, strerror_win32(), tuntap::windows_driver, WINDOWS_DRIVER_WINTUN, tuntap::wintun_receive_ring, tuntap::wintun_receive_ring_handle, tuntap::wintun_send_ring, tuntap::wintun_send_ring_handle, rw_handle::write, and tuntap::writes.
Referenced by do_close_tun_simple(), ipset2ascii_all(), open_null(), and tuntap_ring_empty().
int dev_type_enum | ( | const char * | dev, |
const char * | dev_type | ||
) |
Definition at line 361 of file tun.c.
References DEV_TYPE_NULL, DEV_TYPE_TAP, DEV_TYPE_TUN, DEV_TYPE_UNDEF, and is_dev_type().
Referenced by dev_type_string(), do_init_route_list(), guess_tuntap_dev(), helper_client_server(), init_tun(), multi_init(), open_null(), options_postprocess_mutate_ce(), options_postprocess_mutate_invariant(), options_postprocess_verify_ce(), and tuntap_ring_empty().
const char* dev_type_string | ( | const char * | dev, |
const char * | dev_type | ||
) |
Definition at line 382 of file tun.c.
References dev_type_enum(), DEV_TYPE_NULL, DEV_TYPE_TAP, and DEV_TYPE_TUN.
Referenced by do_open_tun(), open_null(), options_string(), and tuntap_ring_empty().
bool dhcp_release_by_adapter_index | ( | const DWORD | adapter_index | ) |
Definition at line 5095 of file tun.c.
References D_TUNTAP_INFO, gc_free(), gc_new(), get_interface_info(), M_WARN, msg, status, and strerror_win32().
Referenced by add_option(), and dhcp_release().
bool dhcp_renew_by_adapter_index | ( | const DWORD | adapter_index | ) |
Definition at line 5135 of file tun.c.
References D_TUNTAP_INFO, gc_free(), gc_new(), get_interface_info(), M_WARN, msg, status, and strerror_win32().
Referenced by add_option(), and dhcp_renew().
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
tt | the tuntap interface context |
ifname | the human readable interface name |
mtu | the MTU value to set the interface to |
es | the environment to be used when executing the commands |
ctx | the networking API opaque context |
Definition at line 1575 of file tun.c.
References D_LOW, tuntap::did_ifconfig_ipv6_setup, tuntap::did_ifconfig_setup, do_ifconfig_ipv4(), do_ifconfig_ipv6(), tuntap::local, tuntap::local_ipv6, management_set_state(), msg, net_ctx_free(), and OPENVPN_STATE_ASSIGN_IP.
Referenced by do_open_tun(), and tuntap_ring_empty().
Definition at line 689 of file tun.c.
References tuntap::did_ifconfig_ipv6_setup, tuntap::did_ifconfig_setup, gc_free(), gc_new(), is_tun_p2p(), tuntap::local, tuntap::local_ipv6, tuntap::netbits_ipv6, print_in6_addr(), print_in_addr_t(), tuntap::remote_ipv6, tuntap::remote_netmask, setenv_int(), and setenv_str().
Referenced by do_open_tun(), init_tun(), and tuntap_ring_empty().
void fork_register_dns_action | ( | struct tuntap * | tt | ) |
Definition at line 5977 of file tun.c.
References alloc_buf_gc(), BSTR, buf_printf(), fork_to_self(), gc_free(), gc_new(), tuntap_options::msg_channel, tuntap::options, tuntap_options::register_dns, and register_dns_service().
Referenced by initialization_sequence_completed().
const IP_ADAPTER_INFO* get_adapter | ( | const IP_ADAPTER_INFO * | ai, |
DWORD | index | ||
) |
Definition at line 4482 of file tun.c.
References TUN_ADAPTER_INDEX_INVALID.
Referenced by get_adapter_info(), get_default_gateway(), get_tun_adapter(), and netsh_ifconfig().
const IP_ADAPTER_INFO* get_adapter_info | ( | DWORD | index, |
struct gc_arena * | gc | ||
) |
Definition at line 4501 of file tun.c.
References get_adapter(), and get_adapter_info_list().
Referenced by delete_temp_addresses(), dhcp_status(), and get_bypass_addresses().
const IP_ADAPTER_INFO* get_adapter_info_list | ( | struct gc_arena * | gc | ) |
Definition at line 4368 of file tun.c.
References gc_malloc(), M_INFO, msg, status, and strerror_win32().
Referenced by get_adapter_index_method_2(), get_adapter_info(), get_default_gateway(), netsh_ifconfig(), show_adapters(), test_routes(), and windows_route_find_if_index().
const IP_PER_ADAPTER_INFO* get_per_adapter_info | ( | const DWORD | index, |
struct gc_arena * | gc | ||
) |
Definition at line 4395 of file tun.c.
References gc_malloc(), M_INFO, msg, status, strerror_win32(), and TUN_ADAPTER_INDEX_INVALID.
Referenced by get_bypass_addresses(), netsh_ifconfig(), and show_adapter().
const IP_ADAPTER_INFO* get_tun_adapter | ( | const struct tuntap * | tt, |
const IP_ADAPTER_INFO * | list | ||
) |
Definition at line 4586 of file tun.c.
References tuntap::adapter_index, and get_adapter().
Referenced by is_adapter_up(), and windows_route_find_if_index().
const char* guess_tuntap_dev | ( | const char * | dev, |
const char * | dev_type, | ||
const char * | dev_node, | ||
struct gc_arena * | gc | ||
) |
Definition at line 405 of file tun.c.
References dev_type_enum(), DEV_TYPE_TAP, DEV_TYPE_TUN, and netsh_get_id().
Referenced by do_open_tun(), and tuntap_ring_empty().
const char* ifconfig_options_string | ( | const struct tuntap * | tt, |
bool | remote, | ||
bool | disable, | ||
struct gc_arena * | gc | ||
) |
Definition at line 590 of file tun.c.
References alloc_buf_gc(), BSTR, buf_printf(), DEV_TYPE_TAP, DEV_TYPE_TUN, tuntap::did_ifconfig_setup, tuntap::local, print_in_addr_t(), tuntap::remote_netmask, TOP_SUBNET, tuntap::topology, and tuntap::type.
Referenced by options_string(), and tuntap_ring_empty().
|
inlinestatic |
Definition at line 330 of file tun.h.
References IFCONFIG_AFTER_TUN_OPEN, IFCONFIG_BEFORE_TUN_OPEN, and IFCONFIG_DEFAULT.
Referenced by do_open_tun().
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 | ||
) |
Definition at line 733 of file tun.c.
References tuntap::adapter_netmask, ALLOC_OBJ, check_addr_clash(), check_subnet_conflict(), clear_tuntap(), dev_type_enum(), DEV_TYPE_TAP, DEV_TYPE_TUN, tuntap::did_ifconfig_ipv6_setup, tuntap::did_ifconfig_setup, do_ifconfig_setenv(), gc_free(), gc_new(), getaddr(), GETADDR_FATAL, GETADDR_FATAL_ON_SIGNAL, GETADDR_HOST_ORDER, GETADDR_RESOLVE, ifconfig_sanity_check(), IPV4_NETMASK_HOST, is_tun_p2p(), tuntap::local, tuntap::local_ipv6, M_FATAL, msg, tuntap::netbits_ipv6, tuntap::remote_ipv6, tuntap::remote_netmask, TOP_SUBNET, tuntap::topology, tuntap::type, and verify_255_255_255_252().
Referenced by do_init_tun(), options_string(), and tuntap_ring_empty().
void init_tun_post | ( | struct tuntap * | tt, |
const struct frame * | frame, | ||
const struct tuntap_options * | options | ||
) |
Definition at line 888 of file tun.c.
References tuntap::adapter_index, M_FATAL, msg, tuntap::options, overlapped_io::overlapped, overlapped_io_init(), rw_handle::read, tuntap::reads, tuntap::rw_handle, TUN_ADAPTER_INDEX_INVALID, tuntap::windows_driver, WINDOWS_DRIVER_WINTUN, tuntap::wintun_receive_ring_handle, tuntap::wintun_send_ring_handle, rw_handle::write, and tuntap::writes.
Referenced by do_init_tun(), and tuntap_ring_empty().
void ipconfig_register_dns | ( | const struct env_set * | es | ) |
Definition at line 5199 of file tun.c.
References argv_free(), argv_msg(), argv_new(), argv_printf(), D_TUNTAP_INFO, get_win_sys_path(), msg, netcmd_semaphore_lock(), netcmd_semaphore_release(), openvpn_execve_check(), and WIN_IPCONFIG_PATH_SUFFIX.
Referenced by add_option().
const char* ipset2ascii | ( | int | index | ) |
Definition at line 6923 of file tun.c.
References ASSERT, IPW32_SET_N, ipset_names::short_form, and SIZE.
Referenced by ipset2ascii_all().
const char* ipset2ascii_all | ( | struct gc_arena * | gc | ) |
Definition at line 6937 of file tun.c.
References alloc_buf_gc(), ASSERT, BSTR, buf_printf(), close_tun(), free, ipset2ascii(), IPW32_SET_N, buffer::len, open_tun(), read, read_tun(), SIZE, write, and write_tun().
Referenced by add_option().
bool is_adapter_up | ( | const struct tuntap * | tt, |
const IP_ADAPTER_INFO * | list | ||
) |
Definition at line 4599 of file tun.c.
References tuntap::adapter_netmask, get_adapter_ip_netmask(), get_adapter_n_ip_netmask(), get_tun_adapter(), in_addr_t, and tuntap::local.
Referenced by test_routes().
bool is_dev_type | ( | const char * | dev, |
const char * | dev_type, | ||
const char * | match_type | ||
) |
Definition at line 343 of file tun.c.
References ASSERT.
Referenced by dev_type_enum(), and tuntap_ring_empty().
bool is_ip_in_adapter_subnet | ( | const IP_ADAPTER_INFO * | ai, |
const in_addr_t | ip, | ||
in_addr_t * | highest_netmask | ||
) |
Definition at line 4644 of file tun.c.
References get_adapter_ip_netmask(), get_adapter_n_ip_netmask(), and in_addr_t.
Referenced by adapter_index_of_ip(), and windows_route_find_if_index().
|
inlinestatic |
Definition at line 573 of file tun.h.
References BLEN, BPTR, OPENVPN_IPH_GET_VER, and openvpn_iphdr::version_len.
Referenced by write_wintun().
bool is_tun_p2p | ( | const struct tuntap * | tt | ) |
Definition at line 663 of file tun.c.
References DEV_TYPE_NULL, DEV_TYPE_TAP, DEV_TYPE_TUN, M_FATAL, msg, TOP_SUBNET, tuntap::topology, and tuntap::type.
Referenced by do_ifconfig_ipv4(), do_ifconfig_setenv(), init_tun(), open_null(), and tuntap_ring_empty().
void open_tun | ( | const char * | dev, |
const char * | dev_type, | ||
const char * | dev_node, | ||
struct tuntap * | tt | ||
) |
Definition at line 6656 of file tun.c.
References DEV_TYPE_NULL, DEV_TYPE_TAP, DEV_TYPE_TUN, gc_free(), gc_new(), M_FATAL, M_INFO, M_NOPREFIX, msg, open_null(), tun_open_device(), tuntap_post_open(), and tuntap::type.
Referenced by do_open_tun(), ipset2ascii_all(), open_null(), and tuntap_ring_empty().
int read_tun | ( | struct tuntap * | tt, |
uint8_t * | buf, | ||
int | len | ||
) |
Referenced by ipset2ascii_all(), open_null(), read_incoming_tun(), and tuntap_ring_empty().
Definition at line 499 of file tun.h.
References tuntap::hand, tuntap::reads, and tun_finalize().
Referenced by read_incoming_tun().
Definition at line 517 of file tun.h.
References overlapped_io::buf_init, buf_write(), tun_ring::data, TUN_PACKET::data, tun_ring::head, buffer::len, M_INFO, msg, tuntap::reads, TUN_PACKET::size, tun_ring::tail, WINTUN_MAX_PACKET_SIZE, WINTUN_RING_CAPACITY, wintun_ring_packet_align(), wintun_ring_wrap(), and tuntap::wintun_send_ring.
Referenced by read_incoming_tun().
|
inlinestatic |
Definition at line 356 of file tun.h.
References ROUTE_BEFORE_TUN, and ROUTE_ORDER_DEFAULT.
Referenced by do_open_tun(), and do_up().
void show_adapters | ( | int | msglev | ) |
Definition at line 4944 of file tun.c.
References gc_free(), gc_new(), get_adapter_info_list(), msg, and show_adapter().
Referenced by add_option(), check_add_routes(), do_route(), initialization_sequence_completed(), and management_show_net_callback().
void show_tap_win_adapters | ( | int | msglev, |
int | warnlev | ||
) |
Definition at line 4090 of file tun.c.
References gc_free(), gc_new(), get_panel_reg(), get_tap_reg(), tap_reg::guid, panel_reg::guid, msg, panel_reg::name, tap_reg::next, panel_reg::next, print_windows_driver(), and tap_reg::windows_driver.
Referenced by add_option().
void show_valid_win32_tun_subnets | ( | void | ) |
Definition at line 4057 of file tun.c.
Referenced by add_option().
void tap_allow_nonadmin_access | ( | const char * | dev_node | ) |
Definition at line 4993 of file tun.c.
References at_least_one_tap_win(), gc_free(), gc_new(), get_device_guid(), get_panel_reg(), get_tap_reg(), get_unspecified_device_guid(), M_ERR, M_FATAL, M_WARN, msg, openvpn_snprintf(), and tap_allow_nonadmin_access_handle().
Referenced by add_option().
Definition at line 6685 of file tun.c.
References alloc_buf_gc(), BCAP, BSTR, tuntap::hand, buffer::len, tuntap::windows_driver, and WINDOWS_DRIVER_TAP_WINDOWS6.
Referenced by print_status(), and x_check_status().
int tun_finalize | ( | HANDLE | h, |
struct overlapped_io * | io, | ||
struct buffer * | buf | ||
) |
Definition at line 3564 of file tun.c.
References ASSERT, overlapped_io::buf, D_WIN32_IO, dmsg, overlapped_io::iostate, IOSTATE_IMMEDIATE_RETURN, IOSTATE_INITIAL, IOSTATE_QUEUED, buffer::len, M_ERRNO, msg, overlapped_io::overlapped, overlapped_io::size, status, and overlapped_io::status.
Referenced by read_tun_buffered(), and tun_write_win32().
int tun_read_queue | ( | struct tuntap * | tt, |
int | maxsize | ||
) |
Definition at line 3437 of file tun.c.
References ASSERT, BLEN, BPTR, overlapped_io::buf, overlapped_io::buf_init, D_WIN32_IO, dmsg, gc_free(), gc_new(), tuntap::hand, overlapped_io::iostate, IOSTATE_IMMEDIATE_RETURN, IOSTATE_INITIAL, IOSTATE_QUEUED, overlapped_io::overlapped, tuntap::reads, overlapped_io::size, status, overlapped_io::status, and strerror_win32().
Referenced by tun_set().
|
inlinestatic |
Definition at line 700 of file tun.h.
References event_ctl(), EVENT_READ, tuntap::rwflags_debug, tun_event_handle(), tun_read_queue(), tun_stat(), tuntap_defined(), tuntap::windows_driver, and WINDOWS_DRIVER_TAP_WINDOWS6.
Referenced by io_wait_dowork(), and multi_tcp_wait().
void tun_show_debug | ( | struct tuntap * | tt | ) |
Definition at line 6703 of file tun.c.
References alloc_buf(), BCAP, BSTR, D_TAP_WIN_DEBUG, free_buf(), tuntap::hand, buffer::len, msg, tuntap::windows_driver, and WINDOWS_DRIVER_TAP_WINDOWS6.
Referenced by pre_select().
bool tun_standby | ( | struct tuntap * | tt | ) |
Definition at line 5670 of file tun.c.
References tuntap::adapter_index, tuntap::adapter_netmask, tuntap_options::ip_win32_type, IPW32_SET_ADAPTIVE, IPW32_SET_ADAPTIVE_TRY_NETSH, tuntap::local, M_INFO, msg, netsh_ifconfig(), NI_IP_NETMASK, NI_OPTIONS, NI_TEST_FIRST, tuntap::options, and tuntap::standby_iter.
Referenced by check_add_routes(), and write_tun_buffered().
void tun_standby_init | ( | struct tuntap * | tt | ) |
Definition at line 5664 of file tun.c.
References tuntap::standby_iter.
Referenced by do_up(), and write_tun_buffered().
Definition at line 628 of file tun.c.
References alloc_buf_gc(), BSTR, buf_printf(), EVENT_READ, EVENT_WRITE, overlapped_io_state_ascii(), tuntap::reads, tuntap::rwflags_debug, and tuntap::writes.
Referenced by tun_set().
Definition at line 3501 of file tun.c.
References ASSERT, BLEN, BPTR, overlapped_io::buf, buf_copy(), overlapped_io::buf_init, D_WIN32_IO, dmsg, gc_free(), gc_new(), tuntap::hand, overlapped_io::iostate, IOSTATE_IMMEDIATE_RETURN, IOSTATE_INITIAL, IOSTATE_QUEUED, buffer::len, overlapped_io::overlapped, overlapped_io::size, status, overlapped_io::status, strerror_win32(), and tuntap::writes.
Referenced by tun_write_win32().
Definition at line 474 of file tun.h.
References BLEN, tuntap::hand, overlapped_io_active(), status, tun_finalize(), tun_write_queue(), and tuntap::writes.
Referenced by write_tun_buffered().
void tuncfg | ( | const char * | dev, |
const char * | dev_type, | ||
const char * | dev_node, | ||
int | persist_mode, | ||
const char * | username, | ||
const char * | groupname, | ||
const struct tuntap_options * | options, | ||
openvpn_net_ctx_t * | ctx | ||
) |
Referenced by do_persist_tuntap(), open_null(), and tuntap_ring_empty().
|
inlinestatic |
Definition at line 461 of file tun.h.
References openvpn_errno.
Referenced by read_incoming_tun(), and write_tun_buffered().
|
inlinestatic |
Definition at line 224 of file tun.h.
References tuntap::hand.
Referenced by pre_select(), print_status(), process_incoming_link_part2(), tun_set(), and x_check_status().
|
inlinestatic |
Definition at line 235 of file tun.h.
References tuntap::windows_driver, and WINDOWS_DRIVER_WINTUN.
Referenced by io_wait(), io_wait_dowork(), multi_tcp_wait(), and tuntap_ring_empty().
|
inlinestatic |
Definition at line 241 of file tun.h.
References check_subnet_conflict(), close_tun(), dev_type_enum(), dev_type_string(), do_ifconfig(), do_ifconfig_setenv(), guess_tuntap_dev(), tun_ring::head, ifconfig_options_string(), in_addr_t, init_tun(), init_tun_post(), is_dev_type(), is_tun_p2p(), open_tun(), read_tun(), tun_ring::tail, tuntap::topology, tuncfg(), tuntap_is_wintun(), warn_on_use_of_common_subnets(), tuntap::wintun_send_ring, and write_tun().
Referenced by multi_tcp_wait(), p2mp_iow_flags(), and p2p_iow_flags().
|
inlinestatic |
Definition at line 447 of file tun.h.
References openvpn_errno.
Referenced by read_incoming_tun(), and write_tun_buffered().
Definition at line 4020 of file tun.c.
References gc_free(), gc_new(), M_FATAL, msg, PACKAGE, and print_in_addr_t().
Referenced by init_tun().
void warn_on_use_of_common_subnets | ( | openvpn_net_ctx_t * | ctx | ) |
Definition at line 567 of file tun.c.
References route_gateway_address::addr, route_gateway_info::flags, route_gateway_info::gateway, gc_free(), gc_new(), get_default_gateway(), in_addr_t, M_WARN, msg, route_gateway_address::netmask, RGI_ADDR_DEFINED, and RGI_NETMASK_DEFINED.
Referenced by do_option_warnings(), and tuntap_ring_empty().
|
inlinestatic |
Definition at line 505 of file tun.h.
References WINTUN_PACKET_ALIGN.
Referenced by read_wintun(), and write_wintun().
|
inlinestatic |
Definition at line 511 of file tun.h.
References WINTUN_RING_CAPACITY.
Referenced by read_wintun(), and write_wintun().
int write_tun | ( | struct tuntap * | tt, |
uint8_t * | buf, | ||
int | len | ||
) |
Referenced by ipset2ascii_all(), open_null(), process_outgoing_tun(), and tuntap_ring_empty().
Definition at line 646 of file tun.h.
References status, tun_standby(), tun_standby_init(), tun_write_win32(), tuntap_abort(), tuntap_stop(), tuntap::windows_driver, WINDOWS_DRIVER_WINTUN, and write_wintun().
Referenced by process_outgoing_tun().
Definition at line 600 of file tun.h.
References tun_ring::alertable, BLEN, BPTR, D_LOW, tun_ring::data, TUN_PACKET::data, tun_ring::head, is_ip_packet_valid(), M_INFO, msg, tuntap::rw_handle, TUN_PACKET::size, tun_ring::tail, WINTUN_PACKET_ALIGN, tuntap::wintun_receive_ring, WINTUN_RING_CAPACITY, wintun_ring_packet_align(), wintun_ring_wrap(), and rw_handle::write.
Referenced by write_tun_buffered().