OpenVPN
Data Structures | Macros | Functions | Variables
win32.h File Reference
#include "mtu.h"
Include dependency graph for win32.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  security_attributes
 
struct  window_title
 
struct  rw_handle
 
struct  net_event_win32
 
struct  win32_signal
 
struct  overlapped_io
 
struct  semaphore
 

Macros

#define SYS_PATH_ENV_VAR_NAME   "SystemRoot" /* environmental variable name that normally contains the system path */
 
#define NETSH_PATH_SUFFIX   "\\system32\\netsh.exe"
 
#define WIN_ROUTE_PATH_SUFFIX   "\\system32\\route.exe"
 
#define WIN_IPCONFIG_PATH_SUFFIX   "\\system32\\ipconfig.exe"
 
#define WIN_NET_PATH_SUFFIX   "\\system32\\net.exe"
 
#define IN6_ARE_ADDR_EQUAL(a, b)   (memcmp((const void *)(a), (const void *)(b), sizeof(struct in6_addr)) == 0)
 
#define HANDLE_DEFINED(h)   ((h) != NULL && (h) != INVALID_HANDLE_VALUE)
 
#define NE32_PERSIST_EVENT   (1<<0)
 
#define NE32_WRITE_EVENT   (1<<1)
 
#define WSO_MODE_UNDEF   0
 
#define WSO_MODE_SERVICE   1
 
#define WSO_MODE_CONSOLE   2
 
#define WSO_NOFORCE   0
 
#define WSO_FORCE_SERVICE   1
 
#define WSO_FORCE_CONSOLE   2
 
#define IOSTATE_INITIAL   0
 
#define IOSTATE_QUEUED   1 /* overlapped I/O has been queued */
 
#define IOSTATE_IMMEDIATE_RETURN   2 /* I/O function returned immediately without queueing */
 
#define WIN_XP   0
 
#define WIN_VISTA   1
 
#define WIN_7   2
 
#define WIN_8   3
 

Functions

void init_win32 (void)
 
void uninit_win32 (void)
 
void set_pause_exit_win32 (void)
 
static bool defined_net_event_win32 (const struct rw_handle *event)
 
void init_net_event_win32 (struct rw_handle *event, long network_events, socket_descriptor_t sd, unsigned int flags)
 
long reset_net_event_win32 (struct rw_handle *event, socket_descriptor_t sd)
 
void close_net_event_win32 (struct rw_handle *event, socket_descriptor_t sd, unsigned int flags)
 
void net_event_win32_init (struct net_event_win32 *ne)
 
void net_event_win32_start (struct net_event_win32 *ne, long network_events, socket_descriptor_t sd)
 
void net_event_win32_reset (struct net_event_win32 *ne)
 
void net_event_win32_reset_write (struct net_event_win32 *ne)
 
void net_event_win32_stop (struct net_event_win32 *ne)
 
void net_event_win32_close (struct net_event_win32 *ne)
 
static bool net_event_win32_defined (const struct net_event_win32 *ne)
 
static struct rw_handlenet_event_win32_get_event (struct net_event_win32 *ne)
 
static long net_event_win32_get_event_mask (const struct net_event_win32 *ne)
 
static void net_event_win32_clear_selected_events (struct net_event_win32 *ne, long selected_events)
 
void win32_signal_clear (struct win32_signal *ws)
 
void win32_signal_open (struct win32_signal *ws, int force, const char *exit_event_name, bool exit_event_initial_state)
 
void win32_signal_close (struct win32_signal *ws)
 
int win32_signal_get (struct win32_signal *ws)
 
void win32_pause (struct win32_signal *ws)
 
bool win32_service_interrupt (struct win32_signal *ws)
 
void window_title_clear (struct window_title *wt)
 
void window_title_save (struct window_title *wt)
 
void window_title_restore (const struct window_title *wt)
 
void window_title_generate (const char *title)
 
void overlapped_io_init (struct overlapped_io *o, const struct frame *frame, BOOL event_state, bool tuntap_buffer)
 
void overlapped_io_close (struct overlapped_io *o)
 
static bool overlapped_io_active (struct overlapped_io *o)
 
char * overlapped_io_state_ascii (const struct overlapped_io *o)
 
void semaphore_clear (struct semaphore *s)
 
void semaphore_open (struct semaphore *s, const char *name)
 
bool semaphore_lock (struct semaphore *s, int timeout_milliseconds)
 
void semaphore_release (struct semaphore *s)
 
void semaphore_close (struct semaphore *s)
 
void netcmd_semaphore_init (void)
 
void netcmd_semaphore_close (void)
 
void netcmd_semaphore_lock (void)
 
void netcmd_semaphore_release (void)
 
bool init_security_attributes_allow_all (struct security_attributes *obj)
 
bool win_safe_filename (const char *fn)
 
void set_win_sys_path (const char *newpath, struct env_set *es)
 
void set_win_sys_path_via_env (struct env_set *es)
 
char * get_win_sys_path (void)
 
void fork_to_self (const char *cmdline)
 
const char * win_get_tempdir (void)
 
WCHAR * wide_string (const char *utf8, struct gc_arena *gc)
 
bool win_wfp_block_dns (const NET_IFINDEX index, const HANDLE msg_channel)
 
bool win_wfp_uninit (const NET_IFINDEX index, const HANDLE msg_channel)
 
int win32_version_info (void)
 
const char * win32_version_string (struct gc_arena *gc, bool add_name)
 

Variables

struct win32_signal win32_signal
 
struct window_title window_title
 
struct semaphore netcmd_semaphore
 

Macro Definition Documentation

◆ HANDLE_DEFINED

#define HANDLE_DEFINED (   h)    ((h) != NULL && (h) != INVALID_HANDLE_VALUE)

◆ IN6_ARE_ADDR_EQUAL

#define IN6_ARE_ADDR_EQUAL (   a,
 
)    (memcmp((const void *)(a), (const void *)(b), sizeof(struct in6_addr)) == 0)

◆ IOSTATE_IMMEDIATE_RETURN

#define IOSTATE_IMMEDIATE_RETURN   2 /* I/O function returned immediately without queueing */

◆ IOSTATE_INITIAL

#define IOSTATE_INITIAL   0

◆ IOSTATE_QUEUED

#define IOSTATE_QUEUED   1 /* overlapped I/O has been queued */

◆ NE32_PERSIST_EVENT

#define NE32_PERSIST_EVENT   (1<<0)

◆ NE32_WRITE_EVENT

#define NE32_WRITE_EVENT   (1<<1)

Definition at line 81 of file win32.h.

Referenced by init_net_event_win32(), and net_event_win32_start().

◆ NETSH_PATH_SUFFIX

#define NETSH_PATH_SUFFIX   "\\system32\\netsh.exe"

◆ SYS_PATH_ENV_VAR_NAME

#define SYS_PATH_ENV_VAR_NAME   "SystemRoot" /* environmental variable name that normally contains the system path */

Definition at line 31 of file win32.h.

Referenced by set_win_sys_path(), and set_win_sys_path_via_env().

◆ WIN_7

#define WIN_7   2

Definition at line 299 of file win32.h.

Referenced by netsh_set_dns6_servers(), win32_version_info(), and win32_version_string().

◆ WIN_8

#define WIN_8   3

Definition at line 300 of file win32.h.

Referenced by win32_version_info(), and win32_version_string().

◆ WIN_IPCONFIG_PATH_SUFFIX

#define WIN_IPCONFIG_PATH_SUFFIX   "\\system32\\ipconfig.exe"

Definition at line 34 of file win32.h.

Referenced by ipconfig_register_dns().

◆ WIN_NET_PATH_SUFFIX

#define WIN_NET_PATH_SUFFIX   "\\system32\\net.exe"

Definition at line 35 of file win32.h.

◆ WIN_ROUTE_PATH_SUFFIX

#define WIN_ROUTE_PATH_SUFFIX   "\\system32\\route.exe"

Definition at line 33 of file win32.h.

Referenced by add_route(), and delete_route().

◆ WIN_VISTA

#define WIN_VISTA   1

Definition at line 298 of file win32.h.

Referenced by win32_version_info(), and win32_version_string().

◆ WIN_XP

#define WIN_XP   0

Definition at line 297 of file win32.h.

Referenced by win32_version_info(), and win32_version_string().

◆ WSO_FORCE_CONSOLE

#define WSO_FORCE_CONSOLE   2

Definition at line 163 of file win32.h.

Referenced by pre_setup(), uninit_win32(), and win32_signal_open().

◆ WSO_FORCE_SERVICE

#define WSO_FORCE_SERVICE   1

Definition at line 162 of file win32.h.

Referenced by pre_setup(), and win32_signal_open().

◆ WSO_MODE_CONSOLE

#define WSO_MODE_CONSOLE   2

◆ WSO_MODE_SERVICE

#define WSO_MODE_SERVICE   1

◆ WSO_MODE_UNDEF

#define WSO_MODE_UNDEF   0

Definition at line 146 of file win32.h.

Referenced by uninit_win32(), and win32_signal_open().

◆ WSO_NOFORCE

#define WSO_NOFORCE   0

Definition at line 161 of file win32.h.

Referenced by win32_signal_open().

Function Documentation

◆ close_net_event_win32()

void close_net_event_win32 ( struct rw_handle event,
socket_descriptor_t  sd,
unsigned int  flags 
)

◆ defined_net_event_win32()

static bool defined_net_event_win32 ( const struct rw_handle event)
inlinestatic

◆ fork_to_self()

void fork_to_self ( const char *  cmdline)

Definition at line 1166 of file win32.c.

References CLEAR, M_ERRNO, M_WARN, msg, status, and string_alloc().

Referenced by fork_dhcp_action(), and fork_register_dns_action().

◆ get_win_sys_path()

char* get_win_sys_path ( void  )

◆ init_net_event_win32()

void init_net_event_win32 ( struct rw_handle event,
long  network_events,
socket_descriptor_t  sd,
unsigned int  flags 
)

◆ init_security_attributes_allow_all()

bool init_security_attributes_allow_all ( struct security_attributes obj)

◆ init_win32()

void init_win32 ( void  )

Definition at line 105 of file win32.c.

References M_ERR, msg, win32_signal_clear(), window_title_clear(), and wsa_state.

Referenced by init_static().

◆ net_event_win32_clear_selected_events()

static void net_event_win32_clear_selected_events ( struct net_event_win32 ne,
long  selected_events 
)
inlinestatic

Definition at line 137 of file win32.h.

References net_event_win32::event_mask.

Referenced by management_io().

◆ net_event_win32_close()

void net_event_win32_close ( struct net_event_win32 ne)

◆ net_event_win32_defined()

static bool net_event_win32_defined ( const struct net_event_win32 ne)
inlinestatic

Definition at line 119 of file win32.h.

References defined_net_event_win32(), and net_event_win32::handle.

Referenced by net_event_win32_close(), and net_event_win32_stop().

◆ net_event_win32_get_event()

static struct rw_handle* net_event_win32_get_event ( struct net_event_win32 ne)
static

Definition at line 125 of file win32.h.

References net_event_win32::handle.

Referenced by management_socket_set().

◆ net_event_win32_get_event_mask()

static long net_event_win32_get_event_mask ( const struct net_event_win32 ne)
inlinestatic

Definition at line 131 of file win32.h.

References net_event_win32::event_mask.

Referenced by management_io().

◆ net_event_win32_init()

void net_event_win32_init ( struct net_event_win32 ne)

Definition at line 319 of file win32.c.

References CLEAR, net_event_win32::sd, and SOCKET_UNDEFINED.

Referenced by man_connection_init(), and net_event_win32_close().

◆ net_event_win32_reset()

void net_event_win32_reset ( struct net_event_win32 ne)

◆ net_event_win32_reset_write()

void net_event_win32_reset_write ( struct net_event_win32 ne)

◆ net_event_win32_start()

void net_event_win32_start ( struct net_event_win32 ne,
long  network_events,
socket_descriptor_t  sd 
)

◆ net_event_win32_stop()

void net_event_win32_stop ( struct net_event_win32 ne)

◆ netcmd_semaphore_close()

void netcmd_semaphore_close ( void  )

Definition at line 854 of file win32.c.

References netcmd_semaphore, and semaphore_close().

Referenced by uninit_win32().

◆ netcmd_semaphore_init()

void netcmd_semaphore_init ( void  )

Definition at line 848 of file win32.c.

References netcmd_semaphore, and semaphore_open().

Referenced by netcmd_semaphore_lock().

◆ netcmd_semaphore_lock()

void netcmd_semaphore_lock ( void  )

◆ netcmd_semaphore_release()

void netcmd_semaphore_release ( void  )

◆ overlapped_io_active()

static bool overlapped_io_active ( struct overlapped_io o)
inlinestatic

◆ overlapped_io_close()

void overlapped_io_close ( struct overlapped_io o)

Definition at line 184 of file win32.c.

References overlapped_io::buf_init, free_buf(), M_ERRNO, M_WARN, msg, and overlapped_io::overlapped.

Referenced by close_tun(), and link_socket_close().

◆ overlapped_io_init()

void overlapped_io_init ( struct overlapped_io o,
const struct frame frame,
BOOL  event_state,
bool  tuntap_buffer 
)

◆ overlapped_io_state_ascii()

char* overlapped_io_state_ascii ( const struct overlapped_io o)

◆ reset_net_event_win32()

long reset_net_event_win32 ( struct rw_handle event,
socket_descriptor_t  sd 
)

◆ semaphore_clear()

void semaphore_clear ( struct semaphore s)

Definition at line 748 of file win32.c.

References CLEAR.

◆ semaphore_close()

void semaphore_close ( struct semaphore s)

◆ semaphore_lock()

bool semaphore_lock ( struct semaphore s,
int  timeout_milliseconds 
)

◆ semaphore_open()

void semaphore_open ( struct semaphore s,
const char *  name 
)

◆ semaphore_release()

void semaphore_release ( struct semaphore s)

◆ set_pause_exit_win32()

void set_pause_exit_win32 ( void  )

Definition at line 140 of file win32.c.

References pause_exit_enabled.

Referenced by add_option().

◆ set_win_sys_path()

void set_win_sys_path ( const char *  newpath,
struct env_set es 
)

Definition at line 1213 of file win32.c.

References setenv_str(), string_alloc(), SYS_PATH_ENV_VAR_NAME, and win_sys_path.

Referenced by add_option(), and set_win_sys_path_via_env().

◆ set_win_sys_path_via_env()

void set_win_sys_path_via_env ( struct env_set es)

Definition at line 1221 of file win32.c.

References M_ERR, M_FATAL, msg, set_win_sys_path(), status, and SYS_PATH_ENV_VAR_NAME.

Referenced by openvpn_main().

◆ uninit_win32()

void uninit_win32 ( void  )

◆ wide_string()

WCHAR* wide_string ( const char *  utf8,
struct gc_arena gc 
)

◆ win32_pause()

void win32_pause ( struct win32_signal ws)

◆ win32_service_interrupt()

bool win32_service_interrupt ( struct win32_signal ws)

◆ win32_signal_clear()

void win32_signal_clear ( struct win32_signal ws)

Definition at line 442 of file win32.c.

References CLEAR.

Referenced by init_win32().

◆ win32_signal_close()

void win32_signal_close ( struct win32_signal ws)

◆ win32_signal_get()

int win32_signal_get ( struct win32_signal ws)

◆ win32_signal_open()

void win32_signal_open ( struct win32_signal ws,
int  force,
const char *  exit_event_name,
bool  exit_event_initial_state 
)

◆ win32_version_info()

int win32_version_info ( void  )

Definition at line 1401 of file win32.c.

References M_FATAL, msg, WIN_7, WIN_8, WIN_VISTA, and WIN_XP.

Referenced by netsh_set_dns6_servers(), and win32_version_string().

◆ win32_version_string()

const char* win32_version_string ( struct gc_arena gc,
bool  add_name 
)

◆ win_get_tempdir()

const char* win_get_tempdir ( void  )

Definition at line 1238 of file win32.c.

References M_WARN, and msg.

Referenced by init_options().

◆ win_safe_filename()

bool win_safe_filename ( const char *  fn)

Definition at line 936 of file win32.c.

References cmp_prefix().

Referenced by gen_path().

◆ win_wfp_block_dns()

bool win_wfp_block_dns ( const NET_IFINDEX  index,
const HANDLE  msg_channel 
)

◆ win_wfp_uninit()

bool win_wfp_uninit ( const NET_IFINDEX  index,
const HANDLE  msg_channel 
)

◆ window_title_clear()

void window_title_clear ( struct window_title wt)

Definition at line 700 of file win32.c.

References CLEAR.

Referenced by init_win32().

◆ window_title_generate()

void window_title_generate ( const char *  title)

Definition at line 732 of file win32.c.

References alloc_buf_gc(), BSTR, buf_printf(), gc_free(), and gc_new().

Referenced by pre_setup().

◆ window_title_restore()

void window_title_restore ( const struct window_title wt)

Definition at line 723 of file win32.c.

References window_title::old_window_title, and window_title::saved.

Referenced by uninit_win32().

◆ window_title_save()

void window_title_save ( struct window_title wt)

Definition at line 706 of file win32.c.

References window_title::old_window_title, and window_title::saved.

Referenced by pre_setup().

Variable Documentation

◆ netcmd_semaphore

struct semaphore netcmd_semaphore

◆ win32_signal

Definition at line 84 of file win32.c.

◆ window_title

Definition at line 90 of file win32.c.