Replace WIN32 by _WIN32
PATCH 1/1 Replace WIN32 by _WIN32
With c99, "WIN32" is no longer automatically defined when (cross-)building for Windows, and proper compilation relies on including <windefs.h>, before checking the macro. "_WIN32" is the official define that is guaranteed to be defined by the compiler itself, no includes are needed.
So, mechanically change all occurrances of "WIN32" to "_WIN32".
While at it, get rid of unused WIN32_0_1 #define in syshead.h
Trac #746
--- doc/doxygen/openvpn.doxyfile | 2 +- include/openvpn-plugin.h.in | 2 +- m4/ax_socklen_t.m4 | 2 +- src/compat/compat-gettimeofday.c | 4 ++-- src/compat/compat-inet_ntop.c | 2 +- src/compat/compat-inet_pton.c | 2 +- src/openvpn/block_dns.c | 2 +- src/openvpn/block_dns.h | 2 +- src/openvpn/common.h | 2 +- src/openvpn/console.c | 4 ++-- src/openvpn/cryptoapi.c | 2 +- src/openvpn/error.c | 10 +++++----- src/openvpn/error.h | 6 +++--- src/openvpn/event.c | 8 ++++---- src/openvpn/event.h | 4 ++-- src/openvpn/fdmisc.c | 4 ++-- src/openvpn/fdmisc.h | 2 +- src/openvpn/forward.c | 4 ++-- src/openvpn/init.c | 36 ++++++++++++++++++------------------ src/openvpn/manage.c | 18 +++++++++--------- src/openvpn/manage.h | 2 +- src/openvpn/misc.c | 16 ++++++++-------- src/openvpn/misc.h | 2 +- src/openvpn/openvpn.c | 8 ++++---- src/openvpn/options.c | 40 ++++++++++++++++++++-------------------- src/openvpn/options.h | 6 +++--- src/openvpn/otime.h | 8 ++++---- src/openvpn/platform.c | 20 ++++++++++---------- src/openvpn/platform.h | 2 +- src/openvpn/plugin.c | 8 ++++---- src/openvpn/plugin.h | 2 +- src/openvpn/route.c | 26 +++++++++++++------------- src/openvpn/route.h | 10 +++++----- src/openvpn/sig.c | 8 ++++---- src/openvpn/sig.h | 2 +- src/openvpn/socket.c | 40 ++++++++++++++++++++-------------------- src/openvpn/socket.h | 18 +++++++++--------- src/openvpn/ssl.c | 4 ++-- src/openvpn/ssl_backend.h | 2 +- src/openvpn/ssl_mbedtls.c | 2 +- src/openvpn/ssl_openssl.c | 2 +- src/openvpn/syshead.h | 26 ++++++++------------------ src/openvpn/tun.c | 24 ++++++++++++------------ src/openvpn/tun.h | 18 +++++++++--------- src/openvpn/win32.c | 2 +- src/openvpn/win32.h | 2 +- 46 files changed, 204 insertions(+), 214 deletions(-)
doc/doxygen/openvpn.doxyfile +1 -1
@@ -235,7 +235,7 @@ EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = -PREDEFINED = WIN32 NTLM USE_LZO ENABLE_FRAGMENT P2MP P2MP_SERVER ENABLE_CRYPTO ENABLE_CRYPTO_OPENSSL ENABLE_PLUGIN ENABLE_MANAGEMENT ENABLE_OCC HAVE_GETTIMEOFDAY +PREDEFINED = _WIN32 NTLM USE_LZO ENABLE_FRAGMENT P2MP P2MP_SERVER ENABLE_CRYPTO ENABLE_CRYPTO_OPENSSL ENABLE_PLUGIN ENABLE_MANAGEMENT ENABLE_OCC HAVE_GETTIMEOFDAY EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #---------------------------------------------------------------------------
include/openvpn-plugin.h.in +1 -1
@@ -154,7 +154,7 @@ typedef void *openvpn_plugin_handle_t; /* * For Windows (needs to be modified for MSVC) */ -#if defined(WIN32) && !defined(OPENVPN_PLUGIN_H) +#if defined(_WIN32) && !defined(OPENVPN_PLUGIN_H) # define OPENVPN_EXPORT __declspec(dllexport) #else # define OPENVPN_EXPORT
m4/ax_socklen_t.m4 +1 -1
@@ -55,7 +55,7 @@ getpeername(0,0,&len); ], [[ #include <sys/types.h> -#ifdef WIN32 +#ifdef _WIN32 #include <ws2tcpip.h> #else #include <sys/socket.h>
src/compat/compat-gettimeofday.c +2 -2
@@ -32,7 +32,7 @@#include "compat.h" -#ifdef WIN32 +#ifdef _WIN32/* * NOTICE: mingw has much faster gettimeofday! * autoconf will set HAVE_GETTIMEOFDAY
@@ -126,6 +126,6 @@ gettimeofday (struct timeval *tv, void *tz)return 0 ; } -#endif /* WIN32 */ +#endif /* _WIN32 */ #endif /* HAVE_GETTIMEOFDAY */
src/compat/compat-inet_ntop.c +1 -1
@@ -32,7 +32,7 @@#include "compat.h" -#ifdef WIN32 +#ifdef _WIN32#include <windows.h>
src/compat/compat-inet_pton.c +1 -1
@@ -32,7 +32,7 @@#include "compat.h" -#ifdef WIN32 +#ifdef _WIN32#include <windows.h> #include <string.h>
src/openvpn/block_dns.c +1 -1
@@ -35,7 +35,7 @@#include "syshead.h" -#ifdef WIN32 +#ifdef _WIN32#include <fwpmu.h> #include <initguid.h>
src/openvpn/block_dns.h +1 -1
@@ -22,7 +22,7 @@* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef WIN32 +#ifdef _WIN32#ifndef OPENVPN_BLOCK_DNS_H #define OPENVPN_BLOCK_DNS_H
src/openvpn/common.h +1 -1
@@ -30,7 +30,7 @@*/ #ifdef USE_64_BIT_COUNTERS typedef unsigned long long int counter_type ; -# ifdef WIN32 +# ifdef _WIN32# define counter_format "%I64u"# else # define counter_format "%llu"
src/openvpn/console.c +2 -2
@@ -38,7 +38,7 @@#include <systemd/sd-daemon.h> #endif -#ifdef WIN32 +#ifdef _WIN32#include "win32.h"
@@ -206,7 +206,7 @@ get_console_input (const char *prompt, const bool echo, char *input, const int creturn get_console_input_systemd (prompt, echo, input, capacity);#endif -#if defined(WIN32 ) +#if defined(_WIN32)return get_console_input_win32 (prompt, echo, input, capacity);#elif defined(HAVE_GETPASS )
src/openvpn/cryptoapi.c +1 -1
@@ -465,4 +465,4 @@ int SSL_CTX_use_CryptoAPI_certificate(SSL_CTX *ssl_ctx, const char *cert_prop)#ifdef _MSC_VER/* Dummy function needed to avoid empty file compiler warning in Microsoft VC */ static void dummy (void ) {}#endif -#endif /* WIN32 */ +#endif /* _WIN32 */
src/openvpn/error.c +5 -5
@@ -453,7 +453,7 @@ close_syslog ()#endif } -#ifdef WIN32 +#ifdef _WIN32static HANDLE orig_stderr;
@@ -471,7 +471,7 @@ get_orig_stderr (void)void redirect_stdout_stderr (const char *file,bool append) { -#if defined(WIN32 ) +#if defined(_WIN32)if (!std_redir) {struct gc_arena gc =gc_new ();
@@ -622,7 +622,7 @@ x_check_status (int status, sock->info.mtu_changed = true; } } -#elif defined(WIN32) +#elif defined(_WIN32)/* get possible driver error from TAP-Windows driver */ extended_msg =tap_win_getinfo (tt, &gc);#endif
@@ -677,7 +677,7 @@ openvpn_exit (const int status)tun_abort (); -#ifdef WIN32 +#ifdef _WIN32uninit_win32 ();#endif
@@ -737,7 +737,7 @@ crash (void) }#endif -#ifdef WIN32 +#ifdef _WIN32const char *strerror_win32 (DWORD errnum,struct gc_arena *gc)
src/openvpn/error.h +3 -3
@@ -66,7 +66,7 @@ struct gc_arena;/* String and Error functions */ -#ifdef WIN32 +#ifdef _WIN32# define openvpn_errno () GetLastError()# define openvpn_strerror (e, gc) strerror_win32(e, gc)const char *strerror_win32 (DWORD errnum,struct gc_arena *gc);
@@ -248,7 +248,7 @@ void close_syslog ();/* log file output */ void redirect_stdout_stderr (const char *file,bool append); -#ifdef WIN32 +#ifdef _WIN32/* get original stderr handle, even if redirected by --log/--log-append */ HANDLE get_orig_stderr (void );#endif
@@ -343,7 +343,7 @@ static inline bool ignore_sys_error (const int err) {/* I/O operation pending */ -#ifdef WIN32 +#ifdef _WIN32if (err ==WSAEWOULDBLOCK || err ==WSAEINVAL )return true;#else
src/openvpn/event.c +4 -4
@@ -49,7 +49,7 @@/* * All non-windows OSes are assumed to have select() */ -#ifdef WIN32 +#ifdef _WIN32#define SELECT 0#else #define SELECT 1
@@ -74,7 +74,7 @@ tv_to_ms_timeout (const struct timeval *tv)return max_int (tv->tv_sec *1000 + (tv->tv_usec +500 ) /1000 ,1 ); } -#ifdef WIN32 +#ifdef _WIN32struct we_set {
@@ -462,7 +462,7 @@ we_init (int *maxevents, unsigned int flags) return (struct event_set *) wes; } -#endif /* WIN32 */ +#endif /* _WIN32 */ #if EPOLL
@@ -1007,7 +1007,7 @@ static struct event_set * event_set_init_simple (int *maxevents, unsigned int flags) {struct event_set *ret =NULL ; -#ifdef WIN32 +#ifdef _WIN32 ret =we_init (maxevents, flags);#elif POLL &&SELECT #if 0 /* Define to 1 if EVENT_METHOD_US_TIMEOUT should cause select to be favored over poll */
src/openvpn/event.h +2 -2
@@ -42,7 +42,7 @@#define EVENT_METHOD_US_TIMEOUT (1<<0)#define EVENT_METHOD_FAST (1<<1) -#ifdef WIN32 +#ifdef _WIN32typedef const struct rw_handle *event_t ;
@@ -137,7 +137,7 @@ event_set_return_init (struct event_set_return *esr) esr->arg =NULL ; } -#ifdef WIN32 +#ifdef _WIN32static inline void wait_signal (struct event_set *es,void *arg)
src/openvpn/fdmisc.c +2 -2
@@ -39,7 +39,7 @@bool set_nonblock_action (int fd) { -#ifdef WIN32 +#ifdef _WIN32u_long arg =1 ;if (ioctlsocket (fd,FIONBIO , &arg))return false;
@@ -54,7 +54,7 @@ set_nonblock_action (int fd)bool set_cloexec_action (int fd) { -#ifndef WIN32 +#ifndef _WIN32if (fcntl (fd,F_SETFD ,FD_CLOEXEC ) <0 )return false;#endif
src/openvpn/fdmisc.h +1 -1
@@ -37,7 +37,7 @@ void set_cloexec (int fd);static inline void openvpn_fd_set (int fd,fd_set *setp) { -#ifndef WIN32 /* The Windows FD_SET() implementation does not overflow */ +#ifndef _WIN32/* The Windows FD_SET() implementation does not overflow */ ASSERT (fd >=0 && fd <FD_SETSIZE );#endif FD_SET (fd, setp);
src/openvpn/forward.c +2 -2
@@ -301,7 +301,7 @@ check_add_routes_dowork (struct context *c) {register_signal (c,SIGHUP ,"ip-fail" ); c->persist.restart_sleep_seconds =10 ; -#ifdef WIN32 +#ifdef _WIN32show_routes (M_INFO |M_NOPREFIX );show_adapters (M_INFO |M_NOPREFIX );#endif
@@ -1348,7 +1348,7 @@ pre_select (struct context *c) c->c2.timeval.tv_sec =BIG_TIMEOUT ; c->c2.timeval.tv_usec =0 ; -#if defined(WIN32 ) +#if defined(_WIN32)if (check_debug_level (D_TAP_WIN_DEBUG )) { c->c2.timeval.tv_sec =1 ;
src/openvpn/init.c +18 -18
@@ -577,7 +577,7 @@ init_static (void)error_reset ();/* initialize error.c */ reset_check_status ();/* initialize status check code in socket.c */ -#ifdef WIN32 +#ifdef _WIN32init_win32 ();#endif
@@ -1024,7 +1024,7 @@ format_common_name (struct context *c, struct gc_arena *gc)void pre_setup (const struct options *options) { -#ifdef WIN32 +#ifdef _WIN32if (options->exit_event_name) { win32_signal_open (&win32_signal,
@@ -1257,7 +1257,7 @@ initialization_sequence_completed (struct context *c, const unsigned int flags)/* Test if errors */ if (flags &ISC_ERRORS ) { -#ifdef WIN32 +#ifdef _WIN32show_routes (M_INFO |M_NOPREFIX );show_adapters (M_INFO |M_NOPREFIX );msg (M_INFO ,"%s With Errors ( see http://openvpn.net/faq.html#dhcpclientserv )" , message);
@@ -1272,7 +1272,7 @@ initialization_sequence_completed (struct context *c, const unsigned int flags)if ((flags & (ISC_ERRORS |ISC_SERVER )) ==0 ) c->options.no_advance=true; -#ifdef WIN32 +#ifdef _WIN32fork_register_dns_action (c->c1.tuntap);#endif
@@ -1367,7 +1367,7 @@ do_route (const struct options *options,argv_reset (&argv); } -#ifdef WIN32 +#ifdef _WIN32if (options->show_net_up) {show_routes (M_INFO |M_NOPREFIX );
@@ -1439,7 +1439,7 @@ do_open_tun (struct context *c)/* initialize (but do not open) tun/tap object */ do_init_tun (c); -#ifdef WIN32 +#ifdef _WIN32/* store (hide) interactive service handle in tuntap_options */ c->c1.tuntap->options.msg_channel = c->options.msg_channel;msg (D_ROUTE ,"interactive service msg_channel=%u" , (unsigned int ) c->options.msg_channel);
@@ -1497,7 +1497,7 @@ do_open_tun (struct context *c) c->plugins,OPENVPN_PLUGIN_UP , c->c1.tuntap->actual_name, -#ifdef WIN32 +#ifdef _WIN32 c->c1.tuntap->adapter_index, #endif dev_type_string (c->options.dev, c->options.dev_type),
@@ -1510,7 +1510,7 @@ do_open_tun (struct context *c)"up" , c->c2.es); -#if defined(WIN32 ) +#if defined(_WIN32)if (c->options.block_outside_dns) {dmsg (D_LOW ,"Blocking outside DNS" );
@@ -1550,7 +1550,7 @@ do_open_tun (struct context *c) c->plugins,OPENVPN_PLUGIN_UP , c->c1.tuntap->actual_name, -#ifdef WIN32 +#ifdef _WIN32 c->c1.tuntap->adapter_index, #endif dev_type_string (c->options.dev, c->options.dev_type),
@@ -1562,7 +1562,7 @@ do_open_tun (struct context *c)NULL ,"up" , c->c2.es); -#if defined(WIN32 ) +#if defined(_WIN32)if (c->options.block_outside_dns) {dmsg (D_LOW ,"Blocking outside DNS" );
@@ -1600,7 +1600,7 @@ do_close_tun (struct context *c, bool force)if (c->c1.tuntap && c->c1.tuntap_owned) {const char *tuntap_actual =string_alloc (c->c1.tuntap->actual_name, &gc); -#ifdef WIN32 +#ifdef _WIN32DWORD adapter_index = c->c1.tuntap->adapter_index;#endif const in_addr_t local = c->c1.tuntap->local;
@@ -1626,7 +1626,7 @@ do_close_tun (struct context *c, bool force) c->plugins,OPENVPN_PLUGIN_ROUTE_PREDOWN , tuntap_actual, -#ifdef WIN32 +#ifdef _WIN32 adapter_index, #endif NULL,
@@ -1654,7 +1654,7 @@ do_close_tun (struct context *c, bool force) c->plugins,OPENVPN_PLUGIN_DOWN , tuntap_actual, -#ifdef WIN32 +#ifdef _WIN32 adapter_index, #endif NULL,
@@ -1668,7 +1668,7 @@ do_close_tun (struct context *c, bool force)"down" , c->c2.es); -#if defined(WIN32 ) +#if defined(_WIN32)if (c->options.block_outside_dns) {if (!win_wfp_uninit (c->options.msg_channel))
@@ -1688,7 +1688,7 @@ do_close_tun (struct context *c, bool force) c->plugins,OPENVPN_PLUGIN_DOWN , tuntap_actual, -#ifdef WIN32 +#ifdef _WIN32 adapter_index, #endif NULL,
@@ -1702,7 +1702,7 @@ do_close_tun (struct context *c, bool force)"down" , c->c2.es); -#if defined(WIN32 ) +#if defined(_WIN32)if (c->options.block_outside_dns) {if (!win_wfp_uninit (c->options.msg_channel))
@@ -3213,7 +3213,7 @@ do_setup_fast_io (struct context *c) {if (c->options.fast_io) { -#ifdef WIN32 +#ifdef _WIN32msg (M_INFO ,"NOTE: --fast-io is disabled since we are running on Windows" );#else if (!proto_is_udp (c->options.ce.proto))
@@ -3326,7 +3326,7 @@ management_callback_status_p2p (void *arg, const int version, struct status_outpvoid management_show_net_callback (void *arg,const int msglevel) { -#ifdef WIN32 +#ifdef _WIN32show_routes (msglevel);show_adapters (msglevel);msg (msglevel,"END" );
src/openvpn/manage.c +9 -9
@@ -270,7 +270,7 @@ man_delete_unix_socket (struct management *man)static void man_close_socket (struct management *man,const socket_descriptor_t sd) { -#ifndef WIN32 +#ifndef _WIN32/* * Windows doesn't need this because the ne32 event is permanently * enabled at struct management scope.
@@ -1413,7 +1413,7 @@ man_dispatch_command (struct management *man, struct status_output *so, const chgc_free (&gc); } -#ifdef WIN32 +#ifdef _WIN32static void man_start_ne32 (struct management *man)
@@ -1503,7 +1503,7 @@ man_new_connection_post (struct management *man, const char *description)man_connection_settings_reset (man); -#ifdef WIN32 +#ifdef _WIN32man_start_ne32 (man);#endif
@@ -1590,7 +1590,7 @@ man_accept (struct management *man)if (socket_defined (man->connection.sd_top)) { -#ifdef WIN32 +#ifdef _WIN32man_stop_ne32 (man);#endif }
@@ -1654,7 +1654,7 @@ man_listen (struct management *man) print_sockaddr (man->settings.local->ai_addr, &gc)); } -#ifdef WIN32 +#ifdef _WIN32man_start_ne32 (man);#endif
@@ -1737,7 +1737,7 @@ man_reset_client_socket (struct management *man, const bool exiting) {if (socket_defined (man->connection.sd_cli)) { -#ifdef WIN32 +#ifdef _WIN32man_stop_ne32 (man);#endif man_close_socket (man, man->connection.sd_cli);
@@ -2254,7 +2254,7 @@ man_connection_init (struct management *man) {if (man->connection.state ==MS_INITIAL ) { -#ifdef WIN32 +#ifdef _WIN32/* * This object is a sort of TCP/IP helper * for Windows.
@@ -2295,7 +2295,7 @@ man_connection_close (struct management *man)if (mc->es)event_free (mc->es); -#ifdef WIN32 +#ifdef _WIN32net_event_win32_close (&mc->ne32);#endif if (socket_defined (mc->sd_top))
@@ -2731,7 +2731,7 @@ man_persist_state (unsigned int *persistent, const int n)return true; } -#ifdef WIN32 +#ifdef _WIN32 void management_socket_set (struct management *man,
src/openvpn/manage.h +1 -1
@@ -257,7 +257,7 @@ struct man_connection {socket_descriptor_t sd_cli;struct openvpn_sockaddr remote; -#ifdef WIN32 +#ifdef _WIN32struct net_event_win32 ne32;#endif
src/openvpn/misc.c +8 -8
@@ -62,7 +62,7 @@ run_up_down (const char *command,const struct plugin_list *plugins, int plugin_type, const char *arg, -#ifdef WIN32 +#ifdef _WIN32 DWORD adapter_index, #endif const char *dev_type,
@@ -85,7 +85,7 @@ run_up_down (const char *command,setenv_str (es,"dev" , arg);if (dev_type)setenv_str (es,"dev_type" , dev_type); -#ifdef WIN32 +#ifdef _WIN32setenv_int (es,"dev_idx" , adapter_index);#endif
@@ -197,7 +197,7 @@ save_inetd_socket_descriptor (void)void warn_if_group_others_accessible (const char * filename) { -#ifndef WIN32 +#ifndef _WIN32 #ifdef HAVE_STAT if (strcmp (filename, INLINE_FILE_TAG)) {
@@ -223,7 +223,7 @@ const char * system_error_message (int stat, struct gc_arena *gc) { struct buffer out = alloc_buf_gc (256, gc); -#ifdef WIN32 +#ifdef _WIN32if (stat ==-1 )buf_printf (&out,"external program did not execute -- " );buf_printf (&out,"returned error code %d" , stat);
@@ -279,7 +279,7 @@ openvpn_execve_allowed (const unsigned int flags) } -#ifndef WIN32 +#ifndef _WIN32/* * Run execve() inside a fork(). Designed to replicate the semantics of system() but * in a safer way that doesn't require the invocation of a shell or the risks
@@ -977,7 +977,7 @@ hostname_randomize(const char *hostname, struct gc_arena *gc)const char *gen_path (const char *directory,const char *filename,struct gc_arena *gc) { -#ifdef WIN32 +#ifdef _WIN32const int CC_PATH_RESERVED =CC_LESS_THAN |CC_GREATER_THAN |CC_COLON |CC_DOUBLE_QUOTE |CC_SLASH |CC_BACKSLASH |CC_PIPE |CC_QUESTION_MARK |CC_ASTERISK ;#else
@@ -988,7 +988,7 @@ gen_path (const char *directory, const char *filename, struct gc_arena *gc)if (safe_filename &&strcmp (safe_filename,"." ) &&strcmp (safe_filename,".." ) -#ifdef WIN32 +#ifdef _WIN32 &&win_safe_filename (safe_filename) #endif )
@@ -1016,7 +1016,7 @@ absolute_pathname (const char *pathname)if (pathname) {const int c = pathname[0 ]; -#ifdef WIN32 +#ifdef _WIN32return c =='\\' || (isalpha (c) && pathname[1 ] ==':' && pathname[2 ] =='\\' );#else return c =='/' ;
src/openvpn/misc.h +1 -1
@@ -63,7 +63,7 @@ void run_up_down (const char *command,const struct plugin_list *plugins, int plugin_type, const char *arg, -#ifdef WIN32 +#ifdef _WIN32 DWORD adapter_index, #endif const char *dev_type,
src/openvpn/openvpn.c +4 -4
@@ -138,7 +138,7 @@ openvpn_main (int argc, char *argv[])return 1 ;#endif -#ifdef WIN32 +#ifdef _WIN32SetConsoleOutputCP (CP_UTF8 );#endif
@@ -172,7 +172,7 @@ openvpn_main (int argc, char *argv[])/* initialize environmental variable store */ c.es =env_set_create (NULL ); -#ifdef WIN32 +#ifdef _WIN32set_win_sys_path_via_env (c.es);#endif
@@ -220,7 +220,7 @@ openvpn_main (int argc, char *argv[])/* print version number */ msg (M_INFO ,"%s" , title_string); -#ifdef WIN32 +#ifdef _WIN32show_windows_version (M_INFO );#endif show_library_versions (M_INFO );
@@ -312,7 +312,7 @@ openvpn_main (int argc, char *argv[])return 0 ;/* NOTREACHED */ } -#ifdef WIN32 +#ifdef _WIN32int wmain (int argc,wchar_t *wargv[]) {char **argv;
src/openvpn/options.c +20 -20
@@ -584,7 +584,7 @@ static const char usage_message[] =" Default is CN in the Subject field.\n" #endif"--verify-hash : Specify SHA1 fingerprint for level-1 cert.\n" -#ifdef WIN32 +#ifdef _WIN32"--cryptoapicert select-string : Load the certificate and private key from the\n" " Windows Certificate System Store.\n"#endif
@@ -662,7 +662,7 @@ static const char usage_message[] ="--show-digests : Show message digest algorithms to use with --auth option.\n" "--show-engines : Show hardware crypto accelerator engines (if available).\n" "--show-tls : Show all TLS ciphers (TLS used only as a control channel).\n" -#ifdef WIN32 +#ifdef _WIN32"\n" "Windows Specific:\n" "--win-sys path : Pathname of Windows system directory. Default is the pathname\n"
@@ -712,7 +712,7 @@ static const char usage_message[] = " optional parameter controls the initial state of ex.\n" "--show-net-up : Show " PACKAGE_NAME "'s view of routing table and net adapter list\n" " after TAP adapter is up and routes have been added.\n" -#ifdef WIN32 +#ifdef _WIN32 "--block-outside-dns : Block DNS on other network adapters to prevent DNS leaks\n" #endif"Windows Standalone Options:\n"
@@ -808,7 +808,7 @@ init_options (struct options *o, const bool init_gc)#ifdef TARGET_LINUX o->tuntap_options.txqueuelen =100 ;#endif -#ifdef WIN32 +#ifdef _WIN32#if 0 o->tuntap_options.ip_win32_type =IPW32_SET_ADAPTIVE ;#else
@@ -868,7 +868,7 @@ init_options (struct options *o, const bool init_gc)/* tmp is only used in P2MP server context */ #if P2MP_SERVER /* Set default --tmp-dir */ -#ifdef WIN32 +#ifdef _WIN32/* On Windows, find temp dir via enviroment variables */ o->tmp_dir =win_get_tempdir ();#else
@@ -877,7 +877,7 @@ init_options (struct options *o, const bool init_gc)if ( !o->tmp_dir ) { o->tmp_dir ="/tmp" ; } -#endif /* WIN32 */ +#endif /* _WIN32 */ #endif /* P2MP_SERVER */ }
@@ -1129,7 +1129,7 @@ parse_hash_fingerprint(const char *str, int nbytes, int msglevel, struct gc_aren }#endif -#ifdef WIN32 +#ifdef _WIN32#ifndef ENABLE_SMALL
@@ -1174,7 +1174,7 @@ show_tuntap_options (const struct tuntap_options *o)#endif #endif -#if defined(WIN32 ) || defined(TARGET_ANDROID ) +#if defined(_WIN32) || defined(TARGET_ANDROID )static void dhcp_option_address_parse (const char *name,const char *parm,in_addr_t *array,int *len,int msglevel) {
@@ -1728,7 +1728,7 @@ show_settings (const struct options *o)show_p2mp_parms (o);#endif -#ifdef WIN32 +#ifdef _WIN32SHOW_BOOL (show_net_up);SHOW_INT (route_method);SHOW_BOOL (block_outside_dns);
@@ -2020,7 +2020,7 @@ options_postprocess_verify_ce (const struct options *options, const struct conne* Windows-specific options. */ -#ifdef WIN32 +#ifdef _WIN32if (dev ==DEV_TYPE_TUN && !(pull || (options->ifconfig_local && options->ifconfig_remote_netmask)))msg (M_USAGE ,"On Windows, --ifconfig is required when --dev tun is used" );
@@ -2495,7 +2495,7 @@ options_postprocess_mutate_ce (struct options *o, struct connection_entry *ce)static void options_postprocess_mutate_invariant (struct options *options) { -#ifdef WIN32 +#ifdef _WIN32const int dev =dev_type_enum (options->dev, options->dev_type);#endif
@@ -2506,7 +2506,7 @@ options_postprocess_mutate_invariant (struct options *options)if (options->inetd ==INETD_NOWAIT ) options->ifconfig_noexec = true; -#ifdef WIN32 +#ifdef _WIN32if ((dev ==DEV_TYPE_TUN || dev ==DEV_TYPE_TAP ) && !options->route_delay_defined) {if (options->mode ==MODE_POINT_TO_POINT )
@@ -2529,7 +2529,7 @@ options_postprocess_mutate_invariant (struct options *options)*/ if (options->mode ==MODE_SERVER ) { -#ifdef WIN32 +#ifdef _WIN32/* * We need to explicitly set --tap-sleep because * we do not schedule event timers in the top-level context.
@@ -3558,7 +3558,7 @@ usage_small (void)openvpn_exit (OPENVPN_EXIT_STATUS_USAGE );/* exit point */ } -#ifdef WIN32 +#ifdef _WIN32void show_windows_version (const unsigned int flags) {struct gc_arena gc =gc_new ();
@@ -3592,7 +3592,7 @@ usage_version (void) {msg (M_INFO |M_NOPREFIX ,"%s" , title_string);show_library_versions (M_INFO |M_NOPREFIX ); -#ifdef WIN32 +#ifdef _WIN32show_windows_version (M_INFO |M_NOPREFIX );#endif msg (M_INFO |M_NOPREFIX ,"Originally developed by James Yonan" );
@@ -3639,7 +3639,7 @@ positive_atoi (const char *str)return i <0 ?0 : i; } -#ifdef WIN32 /* This function is only used when compiling on Windows */ +#ifdef _WIN32/* This function is only used when compiling on Windows */ static unsigned int atou (const char *str) {
@@ -6217,7 +6217,7 @@ add_option (struct options *options,#endif else if (streq (p[0], "msg-channel") && p[1]) { -#ifdef WIN32 +#ifdef _WIN32VERIFY_PERMISSION (OPT_P_GENERAL );HANDLE process =GetCurrentProcess ();HANDLE handle = (HANDLE )atoi (p[1 ]);
@@ -6233,7 +6233,7 @@ add_option (struct options *options, goto err;#endif } -#ifdef WIN32 +#ifdef _WIN32 else if (streq (p[0], "win-sys") && p[1] && !p[2]) {VERIFY_PERMISSION (OPT_P_GENERAL );
@@ -6314,7 +6314,7 @@ add_option (struct options *options, to->ip_win32_defined = true; }#endif -#if defined(WIN32 ) || defined(TARGET_ANDROID ) +#if defined(_WIN32) || defined(TARGET_ANDROID ) else if (streq (p[0], "dhcp-option") && p[1] && !p[3]) {struct tuntap_options *o = &options->tuntap_options;
@@ -6367,7 +6367,7 @@ add_option (struct options *options, o->dhcp_options = true; }#endif -#ifdef WIN32 +#ifdef _WIN32 else if (streq (p[0], "show-adapters") && !p[1]) {VERIFY_PERMISSION (OPT_P_GENERAL );
src/openvpn/options.h +3 -3
@@ -577,7 +577,7 @@ struct options/* special state parms */ int foreign_option_index; -#ifdef WIN32 +#ifdef _WIN32HANDLE msg_channel;const char *exit_event_name;bool exit_event_initial_state;
@@ -650,7 +650,7 @@ struct options#define PUSH_DEFINED (opt) (false)#endif -#ifdef WIN32 +#ifdef _WIN32#define ROUTE_OPTION_FLAGS (o) ((o)->route_method & ROUTE_METHOD_MASK)#else #define ROUTE_OPTION_FLAGS (o) (0)
@@ -688,7 +688,7 @@ void usage_small (void);void show_library_versions (const unsigned int flags); -#ifdef WIN32 +#ifdef _WIN32void show_windows_version (const unsigned int flags);#endif
src/openvpn/otime.h +4 -4
@@ -76,8 +76,8 @@ openvpn_gettimeofday (struct timeval *tv, void *tz)static inline void update_time (void ) { -#ifdef WIN32 -/* on WIN32, gettimeofday is faster than time(NULL) */ +#ifdef _WIN32 +/* on _WIN32, gettimeofday is faster than time(NULL) */ struct timeval tv;openvpn_gettimeofday (&tv,NULL );#else
@@ -90,8 +90,8 @@ update_time (void)static inline void update_time (void ) { -#if defined(WIN32 ) -/* on WIN32, gettimeofday is faster than time(NULL) */ +#if defined(_WIN32) +/* on _WIN32, gettimeofday is faster than time(NULL) */ struct timeval tv;if (!gettimeofday (&tv,NULL )) {
src/openvpn/platform.c +10 -10
@@ -158,7 +158,7 @@ platform_nice (int niceval)unsigned int platform_getpid () { -#ifdef WIN32 +#ifdef _WIN32return (unsigned int )GetCurrentProcessId ();#else #ifdef HAVE_GETPID
@@ -190,7 +190,7 @@ int platform_chdir (const char* dir) {#ifdef HAVE_CHDIR -#ifdef WIN32 +#ifdef _WIN32int res;struct gc_arena gc =gc_new (); res =_wchdir (wide_string (dir, &gc));
@@ -210,7 +210,7 @@ platform_chdir (const char* dir)bool platform_system_ok (int stat) { -#ifdef WIN32 +#ifdef _WIN32return stat ==0 ;#else return stat !=-1 &&WIFEXITED (stat) &&WEXITSTATUS (stat) ==0 ;
@@ -220,7 +220,7 @@ platform_system_ok (int stat)int platform_access (const char *path,int mode) { -#ifdef WIN32 +#ifdef _WIN32struct gc_arena gc =gc_new ();int ret =_waccess (wide_string (path, &gc), mode & ~X_OK );gc_free (&gc);
@@ -236,7 +236,7 @@ platform_access (const char *path, int mode)void platform_sleep_milliseconds (unsigned int n) { -#ifdef WIN32 +#ifdef _WIN32Sleep (n);#else struct timeval tv;
@@ -252,7 +252,7 @@ platform_sleep_milliseconds (unsigned int n)void platform_sleep_until_signal (void ) { -#ifdef WIN32 +#ifdef _WIN32ASSERT (0 );#else select (0 ,NULL ,NULL ,NULL ,NULL );
@@ -263,7 +263,7 @@ platform_sleep_until_signal (void)bool platform_unlink (const char *filename) { -#if defined(WIN32 ) +#if defined(_WIN32)struct gc_arena gc =gc_new ();BOOL ret =DeleteFileW (wide_string (filename, &gc));gc_free (&gc);
@@ -278,7 +278,7 @@ platform_unlink (const char *filename)FILE *platform_fopen (const char *path,const char *mode) { -#ifdef WIN32 +#ifdef _WIN32struct gc_arena gc =gc_new ();FILE *f =_wfopen (wide_string (path, &gc),wide_string (mode, &gc));gc_free (&gc);
@@ -291,7 +291,7 @@ platform_fopen (const char *path, const char *mode)int platform_open (const char *path,int flags,int mode) { -#ifdef WIN32 +#ifdef _WIN32struct gc_arena gc =gc_new ();int fd =_wopen (wide_string (path, &gc), flags, mode);gc_free (&gc);
@@ -304,7 +304,7 @@ platform_open (const char *path, int flags, int mode)int platform_stat (const char *path,platform_stat_t *buf) { -#ifdef WIN32 +#ifdef _WIN32struct gc_arena gc =gc_new ();int res =_wstat (wide_string (path, &gc), buf);gc_free (&gc);
src/openvpn/platform.h +1 -1
@@ -130,7 +130,7 @@ int platform_putenv (char *string);FILE *platform_fopen (const char *path,const char *mode);int platform_open (const char *path,int flags,int mode); -#ifdef WIN32 +#ifdef _WIN32typedef struct _stat platform_stat_t ;#else typedef struct stat platform_stat_t ;
src/openvpn/plugin.c +4 -4
@@ -175,7 +175,7 @@ plugin_option_list_print (const struct plugin_option_list *list, int msglevel) }#endif -#ifndef WIN32 +#ifndef _WIN32static void libdl_resolve_symbol (void *handle,void **dest,const char *symbol,const char *plugin_name,const unsigned int flags)
@@ -206,7 +206,7 @@ plugin_init_item (struct plugin *p, const struct plugin_option *o) p->so_pathname = o->so_pathname; p->plugin_type_mask =plugin_supported_types (); -#ifndef WIN32 +#ifndef _WIN32 p->handle =NULL ;#if defined(PLUGIN_LIBDIR )
@@ -519,10 +519,10 @@ plugin_close_item (struct plugin *p)if (p->plugin_handle) (*p->close)(p->plugin_handle); -#ifndef WIN32 +#ifndef _WIN32if (dlclose (p->handle))msg (M_WARN ,"PLUGIN_CLOSE: dlclose() failed on plugin: %s" , p->so_pathname); -#elif defined(WIN32 ) +#elif defined(_WIN32)if (!FreeLibrary (p->module))msg (M_WARN ,"PLUGIN_CLOSE: FreeLibrary() failed on plugin: %s" , p->so_pathname);#endif
src/openvpn/plugin.h +1 -1
@@ -59,7 +59,7 @@ struct plugin {unsigned int plugin_type_mask;int requested_initialization_point; -#ifndef WIN32 +#ifndef _WIN32void *handle;#else HMODULE module;
src/openvpn/route.c +13 -13
@@ -49,7 +49,7 @@#include <linux/rtnetlink.h> /* RTM_GETROUTE etc. */ #endif -#ifdef WIN32 +#ifdef _WIN32#include "openvpn-msg.h" #define METRIC_NOT_USED ((DWORD)-1)
@@ -807,7 +807,7 @@ init_route_ipv6_list (struct route_ipv6_list *rl6,if ( !(rl6->rgi6.flags &RGI_ON_LINK ) ) { r6->gateway = rl6->rgi6.gateway.addr_ipv6; } r6->metric =1 ; -#ifdef WIN32 +#ifdef _WIN32 r6->adapter_index = rl6->rgi6.adapter_index;#else r6->iface = rl6->rgi6.iface;
@@ -1214,7 +1214,7 @@ print_default_gateway(const int msglevel,buf_printf (&out," %s" ,print_in_addr_t (rgi->gateway.addr,0 , &gc));if (rgi->flags &RGI_NETMASK_DEFINED )buf_printf (&out,"/%s" ,print_in_addr_t (rgi->gateway.netmask,0 , &gc)); -#ifdef WIN32 +#ifdef _WIN32if (rgi->flags &RGI_IFACE_DEFINED )buf_printf (&out," I=%u" , (unsigned int )rgi->adapter_index);#else
@@ -1235,7 +1235,7 @@ print_default_gateway(const int msglevel,buf_printf (&out," ON_LINK" );if (rgi6->flags &RGI_NETMASK_DEFINED )buf_printf (&out,"/%d" , rgi6->gateway.netbits_ipv6); -#ifdef WIN32 +#ifdef _WIN32if (rgi6->flags &RGI_IFACE_DEFINED )buf_printf (&out," I=%u" , (unsigned int )rgi6->adapter_index);#else
@@ -1455,7 +1455,7 @@ add_route (struct route_ipv4 *r,buf_printf (&out,"%s %s %s" , network, netmask, gateway);management_android_control (management,"ROUTE" ,buf_bptr (&out)); -#elif defined (WIN32 ) +#elif defined (_WIN32) {DWORD ai =TUN_ADAPTER_INDEX_INVALID ; argv_printf (&argv, "%s%sc ADD %s MASK %s %s",
@@ -1683,7 +1683,7 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flaif (! (r6->flags &RT_DEFINED ) )return ; -#ifndef WIN32 +#ifndef _WIN32if ( r6->iface !=NULL )/* vpn server special route */ { device = r6->iface;
@@ -1778,7 +1778,7 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flamanagement_android_control (management,"ROUTE6" ,buf_bptr (&out)); -#elif defined (WIN32 ) +#elif defined (_WIN32)if (tt->options.msg_channel) status =add_route_ipv6_service (r6, tt);
@@ -1969,7 +1969,7 @@ delete_route (struct route_ipv4 *r,argv_msg (D_ROUTE , &argv);openvpn_execve_check (&argv, es,0 ,"ERROR: Linux route delete command failed" ); -#elif defined (WIN32 ) +#elif defined (_WIN32) argv_printf (&argv, "%s%sc DELETE %s MASK %s %s", get_win_sys_path(),
@@ -2116,7 +2116,7 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigneif ((r6->flags & (RT_DEFINED |RT_ADDED )) != (RT_DEFINED |RT_ADDED ))return ; -#ifndef WIN32 +#ifndef _WIN32if ( r6->iface !=NULL )/* vpn server special route */ { device = r6->iface;
@@ -2190,7 +2190,7 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigneargv_msg (D_ROUTE , &argv);openvpn_execve_check (&argv, es,0 ,"ERROR: Linux route -6/-A inet6 del command failed" ); -#elif defined (WIN32 ) +#elif defined (_WIN32)if (tt->options.msg_channel)del_route_ipv6_service (r6, tt);
@@ -2326,7 +2326,7 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigne* to get the current default gateway. */ -#if defined(WIN32 ) +#if defined(_WIN32)static const MIB_IPFORWARDTABLE *get_windows_routing_table (struct gc_arena *gc)
@@ -3704,7 +3704,7 @@ int netmask_to_netbits2 (in_addr_t netmask)* so that outgoing packets to these servers don't end up in the tunnel. */ -#if defined(WIN32 ) +#if defined(_WIN32)static void add_host_route_if_nonlocal (struct route_bypass *rb,const in_addr_t addr)
@@ -3778,7 +3778,7 @@ get_bypass_addresses (struct route_bypass *rb, const unsigned int flags) /* PLA* Used by redirect-gateway autolocal feature */ -#if defined(WIN32 ) +#if defined(_WIN32)int test_local_addr (const in_addr_t addr,const struct route_gateway_info *rgi)
src/openvpn/route.h +5 -5
@@ -33,7 +33,7 @@#include "tun.h" #include "misc.h" -#ifdef WIN32 +#ifdef _WIN32/* * Windows route methods */
@@ -130,7 +130,7 @@ struct route_ipv6 {struct in6_addr gateway;int metric;/* gateway interface */ -# ifdef WIN32 +# ifdef _WIN32DWORD adapter_index;/* interface or ~0 if undefined */ #else char * iface;/* interface name (null terminated) */
@@ -153,7 +153,7 @@ struct route_gateway_info {unsigned int flags;/* gateway interface */ -# ifdef WIN32 +# ifdef _WIN32DWORD adapter_index;/* interface or ~0 if undefined */ #else char iface[16 ];/* interface name (null terminated), may be empty */
@@ -181,7 +181,7 @@ struct route_ipv6_gateway_info {unsigned int flags;/* gateway interface */ -# ifdef WIN32 +# ifdef _WIN32DWORD adapter_index;/* interface or ~0 if undefined */ #else char iface[16 ];/* interface name (null terminated), may be empty */
@@ -333,7 +333,7 @@ void print_route_options (const struct route_option_list *rol,void print_routes (const struct route_list *rl,int level); -#ifdef WIN32 +#ifdef _WIN32void show_routes (int msglev);bool test_routes (const struct route_list *rl,const struct tuntap *tt);
src/openvpn/sig.c +4 -4
@@ -221,7 +221,7 @@ static int signal_mode; /* GLOBAL */void pre_init_signal_catch (void ) { -#ifndef WIN32 +#ifndef _WIN32#ifdef HAVE_SIGNAL_H signal_mode =SM_PRE_INIT ;signal (SIGINT , signal_handler);
@@ -231,13 +231,13 @@ pre_init_signal_catch (void)signal (SIGUSR2 ,SIG_IGN );signal (SIGPIPE ,SIG_IGN );#endif /* HAVE_SIGNAL_H */ -#endif /* WIN32 */ +#endif /* _WIN32 */ }void post_init_signal_catch (void ) { -#ifndef WIN32 +#ifndef _WIN32#ifdef HAVE_SIGNAL_H signal_mode =SM_POST_INIT ;signal (SIGINT , signal_handler);
@@ -291,7 +291,7 @@ print_status (const struct context *c, struct status_output *so)status_printf (so,"Pre-encrypt truncations," counter_format, c->c2.n_trunc_pre_encrypt);status_printf (so,"Post-decrypt truncations," counter_format, c->c2.n_trunc_post_decrypt);#endif -#ifdef WIN32 +#ifdef _WIN32if (tuntap_defined (c->c1.tuntap))status_printf (so,"TAP-WIN32 driver status,\"%s\"" ,tap_win_getinfo (c->c1.tuntap, &gc));
src/openvpn/sig.h +1 -1
@@ -79,7 +79,7 @@ void register_signal (struct context *c, int sig, const char *text);void process_explicit_exit_notification_timer_wakeup (struct context *c);#endif -#ifdef WIN32 +#ifdef _WIN32static inline void get_signal (volatile int *sig)
src/openvpn/socket.c +20 -20
@@ -376,7 +376,7 @@ openvpn_getaddrinfo (unsigned int flags,*/ while (true) { -#ifndef WIN32 +#ifndef _WIN32res_init ();#endif /* try hostname lookup */
@@ -690,7 +690,7 @@ socket_set_buffers (int fd, const struct socket_buffer_size *sbs)static bool socket_set_tcp_nodelay (int sd,int state) { -#if defined(WIN32 ) || (defined(HAVE_SETSOCKOPT ) && defined(IPPROTO_TCP ) && defined(TCP_NODELAY )) +#if defined(_WIN32) || (defined(HAVE_SETSOCKOPT ) && defined(IPPROTO_TCP ) && defined(TCP_NODELAY ))if (setsockopt (sd,IPPROTO_TCP ,TCP_NODELAY , (void *) &state,sizeof (state)) !=0 ) {msg (M_WARN ,"NOTE: setsockopt TCP_NODELAY=%d failed" , state);
@@ -761,7 +761,7 @@ create_socket_tcp (struct addrinfo* addrinfo)if ((sd =socket (addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol)) <0 )msg (M_ERR ,"Cannot create TCP socket" ); -#ifndef WIN32 /* using SO_REUSEADDR on Windows will cause bind to succeed on port conflicts! */ +#ifndef _WIN32/* using SO_REUSEADDR on Windows will cause bind to succeed on port conflicts! */ /* set SO_REUSEADDR on socket */ {int on =1 ;
@@ -1066,7 +1066,7 @@ socket_listen_accept (socket_descriptor_t sd,/* older mingw versions and WinXP do not have this define, * but Vista and up support the functionality - just define it here */ -#ifdef WIN32 +#ifdef _WIN32# ifndef IPV6_V6ONLY # define IPV6_V6ONLY 27# endif
@@ -1141,7 +1141,7 @@ openvpn_connect (socket_descriptor_t sd,if (status) status =openvpn_errno (); if ( -#ifdef WIN32 +#ifdef _WIN32 status == WSAEWOULDBLOCK#else status ==EINPROGRESS
@@ -1184,7 +1184,7 @@ openvpn_connect (socket_descriptor_t sd, {if (--connect_timeout <0 ) { -#ifdef WIN32 +#ifdef _WIN32 status =WSAETIMEDOUT ;#else status =ETIMEDOUT ;
@@ -1296,7 +1296,7 @@ socket_connect (socket_descriptor_t* sd,static void socket_frame_init (const struct frame *frame,struct link_socket *sock) { -#ifdef WIN32 +#ifdef _WIN32overlapped_io_init (&sock->reads, frame, FALSE, false);overlapped_io_init (&sock->writes, frame, TRUE, false); sock->rw_handle.read = sock->reads.overlapped.hEvent;
@@ -1305,7 +1305,7 @@ socket_frame_init (const struct frame *frame, struct link_socket *sock)if (link_socket_connection_oriented (sock)) { -#ifdef WIN32 +#ifdef _WIN32 stream_buf_init (&sock->stream_buf, &sock->reads.buf_init, sock->sockflags,
@@ -1970,7 +1970,7 @@ link_socket_close (struct link_socket *sock)if (socket_defined (sock->sd)) { -#ifdef WIN32 +#ifdef _WIN32close_net_event_win32 (&sock->listen_handle, sock->sd,0 );#endif if (!gremlin)
@@ -1980,7 +1980,7 @@ link_socket_close (struct link_socket *sock)msg (M_WARN |M_ERRNO ,"TCP/UDP: Close Socket failed" ); } sock->sd =SOCKET_UNDEFINED ; -#ifdef WIN32 +#ifdef _WIN32if (!gremlin) {overlapped_io_close (&sock->reads);
@@ -2174,7 +2174,7 @@ socket_stat (const struct link_socket *s, unsigned int rwflags, struct gc_arena {buf_printf (&out,"S%s" , (s->rwflags_debug &EVENT_READ ) ?"R" :"r" ); -#ifdef WIN32 +#ifdef _WIN32buf_printf (&out,"%s" ,overlapped_io_state_ascii (&s->reads));#endif
@@ -2183,7 +2183,7 @@ socket_stat (const struct link_socket *s, unsigned int rwflags, struct gc_arena {buf_printf (&out,"S%s" , (s->rwflags_debug &EVENT_WRITE ) ?"W" :"w" ); -#ifdef WIN32 +#ifdef _WIN32buf_printf (&out,"%s" ,overlapped_io_state_ascii (&s->writes));#endif
@@ -2358,7 +2358,7 @@ stream_buf_close (struct stream_buf* sb)event_t socket_listen_event_handle (struct link_socket *s) { -#ifdef WIN32 +#ifdef _WIN32if (!defined_net_event_win32 (&s->listen_handle))init_net_event_win32 (&s->listen_handle,FD_ACCEPT , s->sd,0 );return &s->listen_handle;
@@ -2834,7 +2834,7 @@ link_socket_read_tcp (struct link_socket *sock,if (!sock->stream_buf.residual_fully_formed) { -#ifdef WIN32 +#ifdef _WIN32 len =socket_finalize (sock->sd, &sock->reads, buf,NULL );#else struct buffer frag;
@@ -2859,7 +2859,7 @@ link_socket_read_tcp (struct link_socket *sock,return buf->len =0 ;/* no error, but packet is still incomplete */ } -#ifndef WIN32 +#ifndef _WIN32#if ENABLE_IP_PKTINFO
@@ -2980,7 +2980,7 @@ link_socket_write_tcp (struct link_socket *sock,ASSERT (len <= sock->stream_buf.maxlen); len =htonps (len);ASSERT (buf_write_prepend (buf, &len,sizeof (len))); -#ifdef WIN32 +#ifdef _WIN32return link_socket_write_win32 (sock, buf, to);#else return link_socket_write_tcp_posix (sock, buf, to);
@@ -3068,7 +3068,7 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,* Win32 overlapped socket I/O functions. */ -#ifdef WIN32 +#ifdef _WIN32int socket_recv_queue (struct link_socket *sock,int maxsize)
@@ -3376,7 +3376,7 @@ socket_finalize (SOCKET s,case sizeof (struct sockaddr_in ):case sizeof (struct sockaddr_in6 ):/* TODO(jjo): for some reason (?) I'm getting 24,28 for AF_INET6 -* under WIN32*/ +* under _WIN32*/ case sizeof (struct sockaddr_in6 )-4 :break ;default :
@@ -3402,7 +3402,7 @@ socket_finalize (SOCKET s, return ret; } -#endif /* WIN32 */ +#endif /* _WIN32 */ /* * Socket event notification
@@ -3423,7 +3423,7 @@ socket_set (struct link_socket *s, rwflags &= ~EVENT_READ ; } -#ifdef WIN32 +#ifdef _WIN32if (rwflags &EVENT_READ )socket_recv_queue (s,0 );#endif
src/openvpn/socket.h +9 -9
@@ -169,7 +169,7 @@ struct link_socketsocket_descriptor_t sd;socket_descriptor_t ctrl_sd;/* only used for UDP over Socks */ -#ifdef WIN32 +#ifdef _WIN32struct overlapped_io reads;struct overlapped_io writes;struct rw_handle rw_handle;
@@ -257,7 +257,7 @@ struct link_socket#define MSG_NOSIGNAL 0#endif -#ifdef WIN32 +#ifdef _WIN32#define openvpn_close_socket (s) closesocket(s)
@@ -842,7 +842,7 @@ socket_connection_reset (const struct link_socket *sock, int status)else if (status <0 ) {const int err =openvpn_errno (); -#ifdef WIN32 +#ifdef _WIN32return err ==WSAECONNRESET || err ==WSAECONNABORTED ;#else return err ==ECONNRESET ;
@@ -950,7 +950,7 @@ stream_buf_read_setup (struct link_socket* sock)int link_socket_read_tcp (struct link_socket *sock,struct buffer *buf); -#ifdef WIN32 +#ifdef _WIN32 static inline int link_socket_read_udp_win32 (struct link_socket *sock,
@@ -978,7 +978,7 @@ link_socket_read (struct link_socket *sock, {int res; -#ifdef WIN32 +#ifdef _WIN32 res =link_socket_read_udp_win32 (sock, buf, from);#else res =link_socket_read_udp_posix (sock, buf, from);
@@ -1006,7 +1006,7 @@ int link_socket_write_tcp (struct link_socket *sock,struct buffer *buf, struct link_socket_actual *to); -#ifdef WIN32 +#ifdef _WIN32 static inline int link_socket_write_win32 (struct link_socket *sock,
@@ -1068,7 +1068,7 @@ link_socket_write_udp (struct link_socket *sock,struct buffer *buf, struct link_socket_actual *to) { -#ifdef WIN32 +#ifdef _WIN32 return link_socket_write_win32 (sock, buf, to);#else return link_socket_write_udp_posix (sock, buf, to);
@@ -1138,7 +1138,7 @@ socket_read_residual (const struct link_socket *s)static inline event_t socket_event_handle (const struct link_socket *s) { -#ifdef WIN32 +#ifdef _WIN32return &s->rw_handle;#else return s->sd;
@@ -1169,7 +1169,7 @@ socket_set_listen_persistent (struct link_socket *s,static inline void socket_reset_listen_persistent (struct link_socket *s) { -#ifdef WIN32 +#ifdef _WIN32reset_net_event_win32 (&s->listen_handle, s->sd);#endif }
src/openvpn/ssl.c +2 -2
@@ -1950,7 +1950,7 @@ push_peer_info(struct buffer *buf, struct tls_session *session)buf_printf (&out,"IV_PLAT=freebsd\n" );#elif defined(TARGET_ANDROID )buf_printf (&out,"IV_PLAT=android\n" ); -#elif defined(WIN32 ) +#elif defined(_WIN32)buf_printf (&out,"IV_PLAT=win\n" );#endif
@@ -1980,7 +1980,7 @@ push_peer_info(struct buffer *buf, struct tls_session *session)if (rgi.flags &RGI_HWADDR_DEFINED )buf_printf (&out,"IV_HWADDR=%s\n" ,format_hex_ex (rgi.hwaddr,6 ,0 ,1 ,":" , &gc));buf_printf (&out,"IV_SSL=%s\n" ,get_ssl_library_version () ); -#if defined(WIN32 ) +#if defined(_WIN32)buf_printf (&out,"IV_PLAT_VER=%s\n" ,win32_version_string (&gc, false));#endif }
src/openvpn/ssl_backend.h +1 -1
@@ -230,7 +230,7 @@ int tls_ctx_load_pkcs12(struct tls_root_ctx *ctx, const char *pkcs12_file,*/ #ifdef ENABLE_CRYPTOAPI void tls_ctx_load_cryptoapi (struct tls_root_ctx *ctx,const char *cryptoapi_cert); -#endif /* WIN32 */ +#endif /* _WIN32 */ /** * Load certificate file into the given TLS context. If the given certificate
src/openvpn/ssl_mbedtls.c +1 -1
@@ -283,7 +283,7 @@ tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert) {msg (M_FATAL ,"Windows CryptoAPI not yet supported for mbed TLS." ); } -#endif /* WIN32 */ +#endif /* _WIN32 */ void tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file,
src/openvpn/ssl_openssl.c +1 -1
@@ -633,7 +633,7 @@ tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert)if (!SSL_CTX_use_CryptoAPI_certificate (ctx->ctx, cryptoapi_cert)) crypto_msg (M_FATAL, "Cannot load certificate \"%s\" from Microsoft Certificate Store", cryptoapi_cert); } -#endif /* WIN32 */ +#endif /* _WIN32 */ static void tls_ctx_add_extra_certs (struct tls_root_ctx *ctx,BIO *bio)
src/openvpn/syshead.h +8 -18
@@ -37,7 +37,7 @@# define unlikely (x) (x)#endif -#ifdef WIN32 +#ifdef _WIN32#include <windows.h> #include <winsock2.h> #define sleep (x) Sleep((x)*1000)
@@ -64,7 +64,7 @@# include <sys/wait.h> #endif -#ifndef WIN32 +#ifndef _WIN32#ifndef WEXITSTATUS # define WEXITSTATUS (stat_val) ((unsigned)(stat_val) >> 8)#endif
@@ -358,7 +358,7 @@#endif /* TARGET_DARWIN */ -#ifdef WIN32 +#ifdef _WIN32// Missing declarations for MinGW 32. // #if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 2 typedef int MIB_TCP_STATE ;
@@ -405,7 +405,7 @@/* * Do we have nanoseconds gettimeofday? */ -#if defined(HAVE_GETTIMEOFDAY ) || defined(WIN32 ) +#if defined(HAVE_GETTIMEOFDAY ) || defined(_WIN32)#define HAVE_GETTIMEOFDAY_NANOSECONDS 1#endif
@@ -470,26 +470,16 @@ typedef unsigned short sa_family_t;/* * Directory separation char */ -#ifdef WIN32 +#ifdef _WIN32#define OS_SPECIFIC_DIRSEP '\\'#else #define OS_SPECIFIC_DIRSEP '/'#endif /* -* Define a boolean value based -* on Win32 status. -*/ -#ifdef WIN32 -#define WIN32_0_1 1 -#else -#define WIN32_0_1 0 -#endif - -/* * Our socket descriptor type. */ -#ifdef WIN32 +#ifdef _WIN32#define SOCKET_UNDEFINED (INVALID_SOCKET)typedef SOCKET socket_descriptor_t ;#else
@@ -590,7 +580,7 @@ socket_defined (const socket_descriptor_t sd)/* * Do we support Unix domain sockets? */ -#if defined(PF_UNIX ) && !defined(WIN32 ) +#if defined(PF_UNIX ) && !defined(_WIN32)#define UNIX_SOCK_SUPPORT 1#else #define UNIX_SOCK_SUPPORT 0
@@ -624,7 +614,7 @@ socket_defined (const socket_descriptor_t sd)/* * Do we have CryptoAPI capability? */ -#if defined(WIN32 ) && defined(ENABLE_CRYPTO ) && defined(ENABLE_CRYPTO_OPENSSL ) +#if defined(_WIN32) && defined(ENABLE_CRYPTO ) && defined(ENABLE_CRYPTO_OPENSSL )#define ENABLE_CRYPTOAPI #endif
src/openvpn/tun.c +12 -12
@@ -49,13 +49,13 @@#include "memdbg.h" -#ifdef WIN32 +#ifdef _WIN32#include "openvpn-msg.h" #endif #include <string.h> -#ifdef WIN32 +#ifdef _WIN32/* #define SIMULATE_DHCP_FAILED */ /* simulate bad DHCP negotiation */
@@ -198,7 +198,7 @@ guess_tuntap_dev (const char *dev,const char *dev_node, struct gc_arena *gc) { -#ifdef WIN32 +#ifdef _WIN32 const int dt = dev_type_enum (dev, dev_type);if (dt ==DEV_TYPE_TUN || dt ==DEV_TYPE_TAP ) {
@@ -421,7 +421,7 @@ tun_stat (const struct tuntap *tt, unsigned int rwflags, struct gc_arena *gc) {buf_printf (&out,"T%s" , (tt->rwflags_debug &EVENT_READ ) ?"R" :"r" ); -#ifdef WIN32 +#ifdef _WIN32buf_printf (&out,"%s" ,overlapped_io_state_ascii (&tt->reads));#endif
@@ -430,7 +430,7 @@ tun_stat (const struct tuntap *tt, unsigned int rwflags, struct gc_arena *gc) {buf_printf (&out,"T%s" , (tt->rwflags_debug &EVENT_WRITE ) ?"W" :"w" ); -#ifdef WIN32 +#ifdef _WIN32buf_printf (&out,"%s" ,overlapped_io_state_ascii (&tt->writes));#endif
@@ -611,7 +611,7 @@ init_tun (const char *dev, /* --dev option */ tt->broadcast =generate_ifconfig_broadcast_addr (tt->local, tt->remote_netmask); } -#ifdef WIN32 +#ifdef _WIN32/* * Make sure that both ifconfig addresses are part of the * same .252 subnet.
@@ -665,7 +665,7 @@ init_tun_post (struct tuntap *tt, const struct tuntap_options *options) { tt->options = *options; -#ifdef WIN32 +#ifdef _WIN32overlapped_io_init (&tt->reads, frame, FALSE, true);overlapped_io_init (&tt->writes, frame, TRUE, true); tt->rw_handle.read = tt->reads.overlapped.hEvent;
@@ -674,7 +674,7 @@ init_tun_post (struct tuntap *tt,#endif } -#if defined(WIN32 ) || \ +#if defined(_WIN32) || \ defined(TARGET_DARWIN ) || defined(TARGET_NETBSD ) || defined(TARGET_OPENBSD )/* some of the platforms will auto-add a "network route" pointing
@@ -1340,7 +1340,7 @@ do_ifconfig (struct tuntap *tt, }env_set_destroy (aix_es); } -#elif defined (WIN32) +#elif defined (_WIN32) {ASSERT (actual !=NULL );
@@ -1399,7 +1399,7 @@ static void clear_tuntap (struct tuntap *tuntap) {CLEAR (*tuntap); -#ifdef WIN32 +#ifdef _WIN32 tuntap->hand =NULL ;#else tuntap->fd =-1 ;
@@ -1497,7 +1497,7 @@ read_tun_header (struct tuntap* tt, uint8_t *buf, int len)#endif -#ifndef WIN32 +#ifndef _WIN32 static void open_tun_generic (const char *dev, const char *dev_type, const char *dev_node, bool ipv6_explicitly_supported, bool dynamic,
@@ -3109,7 +3109,7 @@ read_tun (struct tuntap* tt, uint8_t *buf, int len) return read (tt->fd, buf, len); } -#elif defined(WIN32) +#elif defined(_WIN32)int tun_read_queue (struct tuntap *tt,int maxsize)
src/openvpn/tun.h +9 -9
@@ -25,7 +25,7 @@#ifndef TUN_H #define TUN_H -#ifdef WIN32 +#ifdef _WIN32#include <winioctl.h> #include <tap-windows.h> #endif
@@ -38,7 +38,7 @@#include "proto.h" #include "misc.h" -#if defined(WIN32 ) || defined(TARGET_ANDROID ) +#if defined(_WIN32) || defined(TARGET_ANDROID )#define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1)
@@ -58,7 +58,7 @@ struct tuntap_options {# define IPW32_SET_N 5int ip_win32_type; -#ifdef WIN32 +#ifdef _WIN32HANDLE msg_channel;#endif
@@ -159,7 +159,7 @@ struct tuntapstruct in6_addr remote_ipv6;int netbits_ipv6; -#ifdef WIN32 +#ifdef _WIN32HANDLE hand;struct overlapped_io reads;struct overlapped_io writes;
@@ -199,7 +199,7 @@ struct tuntapstatic inline bool tuntap_defined (const struct tuntap *tt) { -#ifdef WIN32 +#ifdef _WIN32return tt && tt->hand !=NULL ;#else return tt && tt->fd >=0 ;
@@ -300,7 +300,7 @@ ifconfig_order(void)return IFCONFIG_AFTER_TUN_OPEN ;#elif defined(TARGET_NETBSD )return IFCONFIG_AFTER_TUN_OPEN ; -#elif defined(WIN32 ) +#elif defined(_WIN32)return IFCONFIG_AFTER_TUN_OPEN ;#elif defined(TARGET_ANDROID )return IFCONFIG_BEFORE_TUN_OPEN ;
@@ -324,7 +324,7 @@ route_order(void) } -#ifdef WIN32 +#ifdef _WIN32#define TUN_PASS_BUFFER
@@ -478,7 +478,7 @@ tun_standby (struct tuntap *tt)static inline event_t tun_event_handle (const struct tuntap *tt) { -#ifdef WIN32 +#ifdef _WIN32return &tt->rw_handle;#else return tt->fd;
@@ -501,7 +501,7 @@ tun_set (struct tuntap *tt,if (persistent) *persistent = rwflags; } -#ifdef WIN32 +#ifdef _WIN32if (rwflags &EVENT_READ )tun_read_queue (tt,0 );#endif
src/openvpn/win32.c +1 -1
@@ -35,7 +35,7 @@#include "syshead.h" -#ifdef WIN32 +#ifdef _WIN32#include "buffer.h" #include "error.h"
src/openvpn/win32.h +1 -1
@@ -22,7 +22,7 @@* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef WIN32 +#ifdef _WIN32#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H
Signature · 1 line
1.9.1
PATCH v2 1/1 Replace WIN32 by _WIN32
With c99, "WIN32" is no longer automatically defined when (cross-)building for Windows, and proper compilation relies on including <windefs.h>, before checking the macro. "_WIN32" is the official define that is guaranteed to be defined by the compiler itself, no includes are needed.
So, mechanically change all occurrances of "WIN32" to "_WIN32".
While at it, get rid of unused WIN32_0_1 #define in syshead.h
Trac #746
v2: rebased to master, merge the console[_builtin].c changes
--- doc/doxygen/openvpn.doxyfile | 2 +- include/openvpn-plugin.h.in | 2 +- m4/ax_socklen_t.m4 | 2 +- src/compat/compat-gettimeofday.c | 4 ++-- src/compat/compat-inet_ntop.c | 2 +- src/compat/compat-inet_pton.c | 2 +- src/openvpn/block_dns.c | 2 +- src/openvpn/block_dns.h | 2 +- src/openvpn/common.h | 2 +- src/openvpn/console_builtin.c | 6 +++--- src/openvpn/cryptoapi.c | 2 +- src/openvpn/error.c | 10 +++++----- src/openvpn/error.h | 6 +++--- src/openvpn/event.c | 8 ++++---- src/openvpn/event.h | 4 ++-- src/openvpn/fdmisc.c | 4 ++-- src/openvpn/fdmisc.h | 2 +- src/openvpn/forward.c | 4 ++-- src/openvpn/init.c | 36 ++++++++++++++++++------------------ src/openvpn/manage.c | 18 +++++++++--------- src/openvpn/manage.h | 2 +- src/openvpn/misc.c | 16 ++++++++-------- src/openvpn/misc.h | 2 +- src/openvpn/openvpn.c | 8 ++++---- src/openvpn/options.c | 40 ++++++++++++++++++++-------------------- src/openvpn/options.h | 6 +++--- src/openvpn/otime.h | 8 ++++---- src/openvpn/platform.c | 20 ++++++++++---------- src/openvpn/platform.h | 2 +- src/openvpn/plugin.c | 8 ++++---- src/openvpn/plugin.h | 2 +- src/openvpn/route.c | 26 +++++++++++++------------- src/openvpn/route.h | 10 +++++----- src/openvpn/sig.c | 8 ++++---- src/openvpn/sig.h | 2 +- src/openvpn/socket.c | 40 ++++++++++++++++++++-------------------- src/openvpn/socket.h | 18 +++++++++--------- src/openvpn/ssl.c | 4 ++-- src/openvpn/ssl_backend.h | 2 +- src/openvpn/ssl_mbedtls.c | 2 +- src/openvpn/ssl_openssl.c | 2 +- src/openvpn/syshead.h | 26 ++++++++------------------ src/openvpn/tun.c | 24 ++++++++++++------------ src/openvpn/tun.h | 18 +++++++++--------- src/openvpn/win32.c | 2 +- src/openvpn/win32.h | 2 +- 46 files changed, 205 insertions(+), 215 deletions(-)
doc/doxygen/openvpn.doxyfile +1 -1
@@ -235,7 +235,7 @@ EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = -PREDEFINED = WIN32 NTLM USE_LZO ENABLE_FRAGMENT P2MP P2MP_SERVER ENABLE_CRYPTO ENABLE_CRYPTO_OPENSSL ENABLE_PLUGIN ENABLE_MANAGEMENT ENABLE_OCC HAVE_GETTIMEOFDAY +PREDEFINED = _WIN32 NTLM USE_LZO ENABLE_FRAGMENT P2MP P2MP_SERVER ENABLE_CRYPTO ENABLE_CRYPTO_OPENSSL ENABLE_PLUGIN ENABLE_MANAGEMENT ENABLE_OCC HAVE_GETTIMEOFDAY EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #---------------------------------------------------------------------------
include/openvpn-plugin.h.in +1 -1
@@ -154,7 +154,7 @@ typedef void *openvpn_plugin_handle_t; /* * For Windows (needs to be modified for MSVC) */ -#if defined(WIN32) && !defined(OPENVPN_PLUGIN_H) +#if defined(_WIN32) && !defined(OPENVPN_PLUGIN_H) # define OPENVPN_EXPORT __declspec(dllexport) #else # define OPENVPN_EXPORT
m4/ax_socklen_t.m4 +1 -1
@@ -55,7 +55,7 @@ getpeername(0,0,&len); ], [[ #include <sys/types.h> -#ifdef WIN32 +#ifdef _WIN32 #include <ws2tcpip.h> #else #include <sys/socket.h>
src/compat/compat-gettimeofday.c +2 -2
@@ -32,7 +32,7 @@#include "compat.h" -#ifdef WIN32 +#ifdef _WIN32/* * NOTICE: mingw has much faster gettimeofday! * autoconf will set HAVE_GETTIMEOFDAY
@@ -126,6 +126,6 @@ gettimeofday (struct timeval *tv, void *tz)return 0 ; } -#endif /* WIN32 */ +#endif /* _WIN32 */ #endif /* HAVE_GETTIMEOFDAY */
src/compat/compat-inet_ntop.c +1 -1
@@ -32,7 +32,7 @@#include "compat.h" -#ifdef WIN32 +#ifdef _WIN32#include <windows.h>
src/compat/compat-inet_pton.c +1 -1
@@ -32,7 +32,7 @@#include "compat.h" -#ifdef WIN32 +#ifdef _WIN32#include <windows.h> #include <string.h>
src/openvpn/block_dns.c +1 -1
@@ -35,7 +35,7 @@#include "syshead.h" -#ifdef WIN32 +#ifdef _WIN32#include <fwpmu.h> #include <initguid.h>
src/openvpn/block_dns.h +1 -1
@@ -22,7 +22,7 @@* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef WIN32 +#ifdef _WIN32#ifndef OPENVPN_BLOCK_DNS_H #define OPENVPN_BLOCK_DNS_H
src/openvpn/common.h +1 -1
@@ -30,7 +30,7 @@*/ #ifdef USE_64_BIT_COUNTERS typedef unsigned long long int counter_type ; -# ifdef WIN32 +# ifdef _WIN32# define counter_format "%I64u"# else # define counter_format "%llu"
src/openvpn/console_builtin.c +3 -3
@@ -41,7 +41,7 @@#include "buffer.h" #include "misc.h" -#ifdef WIN32 +#ifdef _WIN32#include "win32.h"
@@ -119,7 +119,7 @@ static bool get_console_input_win32 (const char *prompt, const bool echo, char * return false; } -#endif /* WIN32 */ +#endif /* _WIN32 */ #ifdef HAVE_GETPASS
@@ -176,7 +176,7 @@ static bool get_console_input (const char *prompt, const bool echo, char *input,ASSERT (capacity >0 ); input[0 ] ='\0' ; -#if defined(WIN32 ) +#if defined(_WIN32)return get_console_input_win32 (prompt, echo, input, capacity);#elif defined(HAVE_GETPASS )
src/openvpn/cryptoapi.c +1 -1
@@ -465,4 +465,4 @@ int SSL_CTX_use_CryptoAPI_certificate(SSL_CTX *ssl_ctx, const char *cert_prop)#ifdef _MSC_VER/* Dummy function needed to avoid empty file compiler warning in Microsoft VC */ static void dummy (void ) {}#endif -#endif /* WIN32 */ +#endif /* _WIN32 */
src/openvpn/error.c +5 -5
@@ -453,7 +453,7 @@ close_syslog ()#endif } -#ifdef WIN32 +#ifdef _WIN32static HANDLE orig_stderr;
@@ -471,7 +471,7 @@ get_orig_stderr (void)void redirect_stdout_stderr (const char *file,bool append) { -#if defined(WIN32 ) +#if defined(_WIN32)if (!std_redir) {struct gc_arena gc =gc_new ();
@@ -622,7 +622,7 @@ x_check_status (int status, sock->info.mtu_changed = true; } } -#elif defined(WIN32) +#elif defined(_WIN32)/* get possible driver error from TAP-Windows driver */ extended_msg =tap_win_getinfo (tt, &gc);#endif
@@ -677,7 +677,7 @@ openvpn_exit (const int status)tun_abort (); -#ifdef WIN32 +#ifdef _WIN32uninit_win32 ();#endif
@@ -737,7 +737,7 @@ crash (void) }#endif -#ifdef WIN32 +#ifdef _WIN32const char *strerror_win32 (DWORD errnum,struct gc_arena *gc)
src/openvpn/error.h +3 -3
@@ -68,7 +68,7 @@ struct gc_arena;/* String and Error functions */ -#ifdef WIN32 +#ifdef _WIN32# define openvpn_errno () GetLastError()# define openvpn_strerror (e, gc) strerror_win32(e, gc)const char *strerror_win32 (DWORD errnum,struct gc_arena *gc);
@@ -258,7 +258,7 @@ void close_syslog ();/* log file output */ void redirect_stdout_stderr (const char *file,bool append); -#ifdef WIN32 +#ifdef _WIN32/* get original stderr handle, even if redirected by --log/--log-append */ HANDLE get_orig_stderr (void );#endif
@@ -353,7 +353,7 @@ static inline bool ignore_sys_error (const int err) {/* I/O operation pending */ -#ifdef WIN32 +#ifdef _WIN32if (err ==WSAEWOULDBLOCK || err ==WSAEINVAL )return true;#else
src/openvpn/event.c +4 -4
@@ -49,7 +49,7 @@/* * All non-windows OSes are assumed to have select() */ -#ifdef WIN32 +#ifdef _WIN32#define SELECT 0#else #define SELECT 1
@@ -74,7 +74,7 @@ tv_to_ms_timeout (const struct timeval *tv)return max_int (tv->tv_sec *1000 + (tv->tv_usec +500 ) /1000 ,1 ); } -#ifdef WIN32 +#ifdef _WIN32struct we_set {
@@ -462,7 +462,7 @@ we_init (int *maxevents, unsigned int flags) return (struct event_set *) wes; } -#endif /* WIN32 */ +#endif /* _WIN32 */ #if EPOLL
@@ -1007,7 +1007,7 @@ static struct event_set * event_set_init_simple (int *maxevents, unsigned int flags) {struct event_set *ret =NULL ; -#ifdef WIN32 +#ifdef _WIN32 ret =we_init (maxevents, flags);#elif POLL &&SELECT #if 0 /* Define to 1 if EVENT_METHOD_US_TIMEOUT should cause select to be favored over poll */
src/openvpn/event.h +2 -2
@@ -42,7 +42,7 @@#define EVENT_METHOD_US_TIMEOUT (1<<0)#define EVENT_METHOD_FAST (1<<1) -#ifdef WIN32 +#ifdef _WIN32typedef const struct rw_handle *event_t ;
@@ -137,7 +137,7 @@ event_set_return_init (struct event_set_return *esr) esr->arg =NULL ; } -#ifdef WIN32 +#ifdef _WIN32static inline void wait_signal (struct event_set *es,void *arg)
src/openvpn/fdmisc.c +2 -2
@@ -39,7 +39,7 @@bool set_nonblock_action (int fd) { -#ifdef WIN32 +#ifdef _WIN32u_long arg =1 ;if (ioctlsocket (fd,FIONBIO , &arg))return false;
@@ -54,7 +54,7 @@ set_nonblock_action (int fd)bool set_cloexec_action (int fd) { -#ifndef WIN32 +#ifndef _WIN32if (fcntl (fd,F_SETFD ,FD_CLOEXEC ) <0 )return false;#endif
src/openvpn/fdmisc.h +1 -1
@@ -37,7 +37,7 @@ void set_cloexec (int fd);static inline void openvpn_fd_set (int fd,fd_set *setp) { -#ifndef WIN32 /* The Windows FD_SET() implementation does not overflow */ +#ifndef _WIN32/* The Windows FD_SET() implementation does not overflow */ ASSERT (fd >=0 && fd <FD_SETSIZE );#endif FD_SET (fd, setp);
src/openvpn/forward.c +2 -2
@@ -301,7 +301,7 @@ check_add_routes_dowork (struct context *c) {register_signal (c,SIGHUP ,"ip-fail" ); c->persist.restart_sleep_seconds =10 ; -#ifdef WIN32 +#ifdef _WIN32show_routes (M_INFO |M_NOPREFIX );show_adapters (M_INFO |M_NOPREFIX );#endif
@@ -1420,7 +1420,7 @@ pre_select (struct context *c) c->c2.timeval.tv_sec =BIG_TIMEOUT ; c->c2.timeval.tv_usec =0 ; -#if defined(WIN32 ) +#if defined(_WIN32)if (check_debug_level (D_TAP_WIN_DEBUG )) { c->c2.timeval.tv_sec =1 ;
src/openvpn/init.c +18 -18
@@ -577,7 +577,7 @@ init_static (void)error_reset ();/* initialize error.c */ reset_check_status ();/* initialize status check code in socket.c */ -#ifdef WIN32 +#ifdef _WIN32init_win32 ();#endif
@@ -1024,7 +1024,7 @@ format_common_name (struct context *c, struct gc_arena *gc)void pre_setup (const struct options *options) { -#ifdef WIN32 +#ifdef _WIN32if (options->exit_event_name) { win32_signal_open (&win32_signal,
@@ -1245,7 +1245,7 @@ initialization_sequence_completed (struct context *c, const unsigned int flags)/* Test if errors */ if (flags &ISC_ERRORS ) { -#ifdef WIN32 +#ifdef _WIN32show_routes (M_INFO |M_NOPREFIX );show_adapters (M_INFO |M_NOPREFIX );msg (M_INFO ,"%s With Errors ( see http://openvpn.net/faq.html#dhcpclientserv )" , message);
@@ -1260,7 +1260,7 @@ initialization_sequence_completed (struct context *c, const unsigned int flags)if ((flags & (ISC_ERRORS |ISC_SERVER )) ==0 ) c->options.no_advance=true; -#ifdef WIN32 +#ifdef _WIN32fork_register_dns_action (c->c1.tuntap);#endif
@@ -1355,7 +1355,7 @@ do_route (const struct options *options,argv_reset (&argv); } -#ifdef WIN32 +#ifdef _WIN32if (options->show_net_up) {show_routes (M_INFO |M_NOPREFIX );
@@ -1421,7 +1421,7 @@ do_open_tun (struct context *c)/* initialize (but do not open) tun/tap object */ do_init_tun (c); -#ifdef WIN32 +#ifdef _WIN32/* store (hide) interactive service handle in tuntap_options */ c->c1.tuntap->options.msg_channel = c->options.msg_channel;msg (D_ROUTE ,"interactive service msg_channel=%u" , (unsigned int ) c->options.msg_channel);
@@ -1482,7 +1482,7 @@ do_open_tun (struct context *c) c->plugins,OPENVPN_PLUGIN_UP , c->c1.tuntap->actual_name, -#ifdef WIN32 +#ifdef _WIN32 c->c1.tuntap->adapter_index, #endif dev_type_string (c->options.dev, c->options.dev_type),
@@ -1495,7 +1495,7 @@ do_open_tun (struct context *c)"up" , c->c2.es); -#if defined(WIN32 ) +#if defined(_WIN32)if (c->options.block_outside_dns) {dmsg (D_LOW ,"Blocking outside DNS" );
@@ -1535,7 +1535,7 @@ do_open_tun (struct context *c) c->plugins,OPENVPN_PLUGIN_UP , c->c1.tuntap->actual_name, -#ifdef WIN32 +#ifdef _WIN32 c->c1.tuntap->adapter_index, #endif dev_type_string (c->options.dev, c->options.dev_type),
@@ -1547,7 +1547,7 @@ do_open_tun (struct context *c)NULL ,"up" , c->c2.es); -#if defined(WIN32 ) +#if defined(_WIN32)if (c->options.block_outside_dns) {dmsg (D_LOW ,"Blocking outside DNS" );
@@ -1585,7 +1585,7 @@ do_close_tun (struct context *c, bool force)if (c->c1.tuntap && c->c1.tuntap_owned) {const char *tuntap_actual =string_alloc (c->c1.tuntap->actual_name, &gc); -#ifdef WIN32 +#ifdef _WIN32DWORD adapter_index = c->c1.tuntap->adapter_index;#endif const in_addr_t local = c->c1.tuntap->local;
@@ -1611,7 +1611,7 @@ do_close_tun (struct context *c, bool force) c->plugins,OPENVPN_PLUGIN_ROUTE_PREDOWN , tuntap_actual, -#ifdef WIN32 +#ifdef _WIN32 adapter_index, #endif NULL,
@@ -1639,7 +1639,7 @@ do_close_tun (struct context *c, bool force) c->plugins,OPENVPN_PLUGIN_DOWN , tuntap_actual, -#ifdef WIN32 +#ifdef _WIN32 adapter_index, #endif NULL,
@@ -1653,7 +1653,7 @@ do_close_tun (struct context *c, bool force)"down" , c->c2.es); -#if defined(WIN32 ) +#if defined(_WIN32)if (c->options.block_outside_dns) {if (!win_wfp_uninit (c->options.msg_channel))
@@ -1673,7 +1673,7 @@ do_close_tun (struct context *c, bool force) c->plugins,OPENVPN_PLUGIN_DOWN , tuntap_actual, -#ifdef WIN32 +#ifdef _WIN32 adapter_index, #endif NULL,
@@ -1687,7 +1687,7 @@ do_close_tun (struct context *c, bool force)"down" , c->c2.es); -#if defined(WIN32 ) +#if defined(_WIN32)if (c->options.block_outside_dns) {if (!win_wfp_uninit (c->options.msg_channel))
@@ -3202,7 +3202,7 @@ do_setup_fast_io (struct context *c) {if (c->options.fast_io) { -#ifdef WIN32 +#ifdef _WIN32msg (M_INFO ,"NOTE: --fast-io is disabled since we are running on Windows" );#else if (!proto_is_udp (c->options.ce.proto))
@@ -3315,7 +3315,7 @@ management_callback_status_p2p (void *arg, const int version, struct status_outpvoid management_show_net_callback (void *arg,const int msglevel) { -#ifdef WIN32 +#ifdef _WIN32show_routes (msglevel);show_adapters (msglevel);msg (msglevel,"END" );
src/openvpn/manage.c +9 -9
@@ -270,7 +270,7 @@ man_delete_unix_socket (struct management *man)static void man_close_socket (struct management *man,const socket_descriptor_t sd) { -#ifndef WIN32 +#ifndef _WIN32/* * Windows doesn't need this because the ne32 event is permanently * enabled at struct management scope.
@@ -1413,7 +1413,7 @@ man_dispatch_command (struct management *man, struct status_output *so, const chgc_free (&gc); } -#ifdef WIN32 +#ifdef _WIN32static void man_start_ne32 (struct management *man)
@@ -1503,7 +1503,7 @@ man_new_connection_post (struct management *man, const char *description)man_connection_settings_reset (man); -#ifdef WIN32 +#ifdef _WIN32man_start_ne32 (man);#endif
@@ -1590,7 +1590,7 @@ man_accept (struct management *man)if (socket_defined (man->connection.sd_top)) { -#ifdef WIN32 +#ifdef _WIN32man_stop_ne32 (man);#endif }
@@ -1654,7 +1654,7 @@ man_listen (struct management *man) print_sockaddr (man->settings.local->ai_addr, &gc)); } -#ifdef WIN32 +#ifdef _WIN32man_start_ne32 (man);#endif
@@ -1737,7 +1737,7 @@ man_reset_client_socket (struct management *man, const bool exiting) {if (socket_defined (man->connection.sd_cli)) { -#ifdef WIN32 +#ifdef _WIN32man_stop_ne32 (man);#endif man_close_socket (man, man->connection.sd_cli);
@@ -2254,7 +2254,7 @@ man_connection_init (struct management *man) {if (man->connection.state ==MS_INITIAL ) { -#ifdef WIN32 +#ifdef _WIN32/* * This object is a sort of TCP/IP helper * for Windows.
@@ -2295,7 +2295,7 @@ man_connection_close (struct management *man)if (mc->es)event_free (mc->es); -#ifdef WIN32 +#ifdef _WIN32net_event_win32_close (&mc->ne32);#endif if (socket_defined (mc->sd_top))
@@ -2731,7 +2731,7 @@ man_persist_state (unsigned int *persistent, const int n)return true; } -#ifdef WIN32 +#ifdef _WIN32 void management_socket_set (struct management *man,
src/openvpn/manage.h +1 -1
@@ -257,7 +257,7 @@ struct man_connection {socket_descriptor_t sd_cli;struct openvpn_sockaddr remote; -#ifdef WIN32 +#ifdef _WIN32struct net_event_win32 ne32;#endif
src/openvpn/misc.c +8 -8
@@ -64,7 +64,7 @@ run_up_down (const char *command,const struct plugin_list *plugins, int plugin_type, const char *arg, -#ifdef WIN32 +#ifdef _WIN32 DWORD adapter_index, #endif const char *dev_type,
@@ -87,7 +87,7 @@ run_up_down (const char *command,setenv_str (es,"dev" , arg);if (dev_type)setenv_str (es,"dev_type" , dev_type); -#ifdef WIN32 +#ifdef _WIN32setenv_int (es,"dev_idx" , adapter_index);#endif
@@ -199,7 +199,7 @@ save_inetd_socket_descriptor (void)void warn_if_group_others_accessible (const char * filename) { -#ifndef WIN32 +#ifndef _WIN32 #ifdef HAVE_STAT if (strcmp (filename, INLINE_FILE_TAG)) {
@@ -225,7 +225,7 @@ const char * system_error_message (int stat, struct gc_arena *gc) { struct buffer out = alloc_buf_gc (256, gc); -#ifdef WIN32 +#ifdef _WIN32if (stat ==-1 )buf_printf (&out,"external program did not execute -- " );buf_printf (&out,"returned error code %d" , stat);
@@ -281,7 +281,7 @@ openvpn_execve_allowed (const unsigned int flags) } -#ifndef WIN32 +#ifndef _WIN32/* * Run execve() inside a fork(). Designed to replicate the semantics of system() but * in a safer way that doesn't require the invocation of a shell or the risks
@@ -979,7 +979,7 @@ hostname_randomize(const char *hostname, struct gc_arena *gc)const char *gen_path (const char *directory,const char *filename,struct gc_arena *gc) { -#ifdef WIN32 +#ifdef _WIN32const int CC_PATH_RESERVED =CC_LESS_THAN |CC_GREATER_THAN |CC_COLON |CC_DOUBLE_QUOTE |CC_SLASH |CC_BACKSLASH |CC_PIPE |CC_QUESTION_MARK |CC_ASTERISK ;#else
@@ -990,7 +990,7 @@ gen_path (const char *directory, const char *filename, struct gc_arena *gc)if (safe_filename &&strcmp (safe_filename,"." ) &&strcmp (safe_filename,".." ) -#ifdef WIN32 +#ifdef _WIN32 &&win_safe_filename (safe_filename) #endif )
@@ -1018,7 +1018,7 @@ absolute_pathname (const char *pathname)if (pathname) {const int c = pathname[0 ]; -#ifdef WIN32 +#ifdef _WIN32return c =='\\' || (isalpha (c) && pathname[1 ] ==':' && pathname[2 ] =='\\' );#else return c =='/' ;
src/openvpn/misc.h +1 -1
@@ -63,7 +63,7 @@ void run_up_down (const char *command,const struct plugin_list *plugins, int plugin_type, const char *arg, -#ifdef WIN32 +#ifdef _WIN32 DWORD adapter_index, #endif const char *dev_type,
src/openvpn/openvpn.c +4 -4
@@ -138,7 +138,7 @@ openvpn_main (int argc, char *argv[])return 1 ;#endif -#ifdef WIN32 +#ifdef _WIN32SetConsoleOutputCP (CP_UTF8 );#endif
@@ -172,7 +172,7 @@ openvpn_main (int argc, char *argv[])/* initialize environmental variable store */ c.es =env_set_create (NULL ); -#ifdef WIN32 +#ifdef _WIN32set_win_sys_path_via_env (c.es);#endif
@@ -220,7 +220,7 @@ openvpn_main (int argc, char *argv[])/* print version number */ msg (M_INFO ,"%s" , title_string); -#ifdef WIN32 +#ifdef _WIN32show_windows_version (M_INFO );#endif show_library_versions (M_INFO );
@@ -312,7 +312,7 @@ openvpn_main (int argc, char *argv[])return 0 ;/* NOTREACHED */ } -#ifdef WIN32 +#ifdef _WIN32int wmain (int argc,wchar_t *wargv[]) {char **argv;
src/openvpn/options.c +20 -20
@@ -592,7 +592,7 @@ static const char usage_message[] =" Default is CN in the Subject field.\n" #endif"--verify-hash : Specify SHA1 fingerprint for level-1 cert.\n" -#ifdef WIN32 +#ifdef _WIN32"--cryptoapicert select-string : Load the certificate and private key from the\n" " Windows Certificate System Store.\n"#endif
@@ -670,7 +670,7 @@ static const char usage_message[] ="--show-digests : Show message digest algorithms to use with --auth option.\n" "--show-engines : Show hardware crypto accelerator engines (if available).\n" "--show-tls : Show all TLS ciphers (TLS used only as a control channel).\n" -#ifdef WIN32 +#ifdef _WIN32"\n" "Windows Specific:\n" "--win-sys path : Pathname of Windows system directory. Default is the pathname\n"
@@ -720,7 +720,7 @@ static const char usage_message[] = " optional parameter controls the initial state of ex.\n" "--show-net-up : Show " PACKAGE_NAME "'s view of routing table and net adapter list\n" " after TAP adapter is up and routes have been added.\n" -#ifdef WIN32 +#ifdef _WIN32 "--block-outside-dns : Block DNS on other network adapters to prevent DNS leaks\n" #endif"Windows Standalone Options:\n"
@@ -816,7 +816,7 @@ init_options (struct options *o, const bool init_gc)#ifdef TARGET_LINUX o->tuntap_options.txqueuelen =100 ;#endif -#ifdef WIN32 +#ifdef _WIN32#if 0 o->tuntap_options.ip_win32_type =IPW32_SET_ADAPTIVE ;#else
@@ -879,7 +879,7 @@ init_options (struct options *o, const bool init_gc) o->auth_token_generate = false;/* Set default --tmp-dir */ -#ifdef WIN32 +#ifdef _WIN32/* On Windows, find temp dir via enviroment variables */ o->tmp_dir =win_get_tempdir ();#else
@@ -888,7 +888,7 @@ init_options (struct options *o, const bool init_gc)if ( !o->tmp_dir ) { o->tmp_dir ="/tmp" ; } -#endif /* WIN32 */ +#endif /* _WIN32 */ #endif /* P2MP_SERVER */ o->allow_recursive_routing = false; }
@@ -1141,7 +1141,7 @@ parse_hash_fingerprint(const char *str, int nbytes, int msglevel, struct gc_aren }#endif -#ifdef WIN32 +#ifdef _WIN32#ifndef ENABLE_SMALL
@@ -1186,7 +1186,7 @@ show_tuntap_options (const struct tuntap_options *o)#endif #endif -#if defined(WIN32 ) || defined(TARGET_ANDROID ) +#if defined(_WIN32) || defined(TARGET_ANDROID )static void dhcp_option_address_parse (const char *name,const char *parm,in_addr_t *array,int *len,int msglevel) {
@@ -1741,7 +1741,7 @@ show_settings (const struct options *o)show_p2mp_parms (o);#endif -#ifdef WIN32 +#ifdef _WIN32SHOW_BOOL (show_net_up);SHOW_INT (route_method);SHOW_BOOL (block_outside_dns);
@@ -2033,7 +2033,7 @@ options_postprocess_verify_ce (const struct options *options, const struct conne* Windows-specific options. */ -#ifdef WIN32 +#ifdef _WIN32if (dev ==DEV_TYPE_TUN && !(pull || (options->ifconfig_local && options->ifconfig_remote_netmask)))msg (M_USAGE ,"On Windows, --ifconfig is required when --dev tun is used" );
@@ -2505,7 +2505,7 @@ options_postprocess_mutate_ce (struct options *o, struct connection_entry *ce)static void options_postprocess_mutate_invariant (struct options *options) { -#ifdef WIN32 +#ifdef _WIN32const int dev =dev_type_enum (options->dev, options->dev_type);#endif
@@ -2516,7 +2516,7 @@ options_postprocess_mutate_invariant (struct options *options)if (options->inetd ==INETD_NOWAIT ) options->ifconfig_noexec = true; -#ifdef WIN32 +#ifdef _WIN32if ((dev ==DEV_TYPE_TUN || dev ==DEV_TYPE_TAP ) && !options->route_delay_defined) {if (options->mode ==MODE_POINT_TO_POINT )
@@ -2539,7 +2539,7 @@ options_postprocess_mutate_invariant (struct options *options)*/ if (options->mode ==MODE_SERVER ) { -#ifdef WIN32 +#ifdef _WIN32/* * We need to explicitly set --tap-sleep because * we do not schedule event timers in the top-level context.
@@ -3568,7 +3568,7 @@ usage_small (void)openvpn_exit (OPENVPN_EXIT_STATUS_USAGE );/* exit point */ } -#ifdef WIN32 +#ifdef _WIN32void show_windows_version (const unsigned int flags) {struct gc_arena gc =gc_new ();
@@ -3602,7 +3602,7 @@ usage_version (void) {msg (M_INFO |M_NOPREFIX ,"%s" , title_string);show_library_versions (M_INFO |M_NOPREFIX ); -#ifdef WIN32 +#ifdef _WIN32show_windows_version (M_INFO |M_NOPREFIX );#endif msg (M_INFO |M_NOPREFIX ,"Originally developed by James Yonan" );
@@ -3649,7 +3649,7 @@ positive_atoi (const char *str)return i <0 ?0 : i; } -#ifdef WIN32 /* This function is only used when compiling on Windows */ +#ifdef _WIN32/* This function is only used when compiling on Windows */ static unsigned int atou (const char *str) {
@@ -6234,7 +6234,7 @@ add_option (struct options *options,#endif else if (streq (p[0], "msg-channel") && p[1]) { -#ifdef WIN32 +#ifdef _WIN32VERIFY_PERMISSION (OPT_P_GENERAL );HANDLE process =GetCurrentProcess ();HANDLE handle = (HANDLE )atoi (p[1 ]);
@@ -6250,7 +6250,7 @@ add_option (struct options *options, goto err;#endif } -#ifdef WIN32 +#ifdef _WIN32 else if (streq (p[0], "win-sys") && p[1] && !p[2]) {VERIFY_PERMISSION (OPT_P_GENERAL );
@@ -6331,7 +6331,7 @@ add_option (struct options *options, to->ip_win32_defined = true; }#endif -#if defined(WIN32 ) || defined(TARGET_ANDROID ) +#if defined(_WIN32) || defined(TARGET_ANDROID ) else if (streq (p[0], "dhcp-option") && p[1] && !p[3]) {struct tuntap_options *o = &options->tuntap_options;
@@ -6384,7 +6384,7 @@ add_option (struct options *options, o->dhcp_options = true; }#endif -#ifdef WIN32 +#ifdef _WIN32 else if (streq (p[0], "show-adapters") && !p[1]) {VERIFY_PERMISSION (OPT_P_GENERAL );
src/openvpn/options.h +3 -3
@@ -578,7 +578,7 @@ struct options/* special state parms */ int foreign_option_index; -#ifdef WIN32 +#ifdef _WIN32HANDLE msg_channel;const char *exit_event_name;bool exit_event_initial_state;
@@ -655,7 +655,7 @@ struct options#define PUSH_DEFINED (opt) (false)#endif -#ifdef WIN32 +#ifdef _WIN32#define ROUTE_OPTION_FLAGS (o) ((o)->route_method & ROUTE_METHOD_MASK)#else #define ROUTE_OPTION_FLAGS (o) (0)
@@ -693,7 +693,7 @@ void usage_small (void);void show_library_versions (const unsigned int flags); -#ifdef WIN32 +#ifdef _WIN32void show_windows_version (const unsigned int flags);#endif
src/openvpn/otime.h +4 -4
@@ -76,8 +76,8 @@ openvpn_gettimeofday (struct timeval *tv, void *tz)static inline void update_time (void ) { -#ifdef WIN32 -/* on WIN32, gettimeofday is faster than time(NULL) */ +#ifdef _WIN32 +/* on _WIN32, gettimeofday is faster than time(NULL) */ struct timeval tv;openvpn_gettimeofday (&tv,NULL );#else
@@ -90,8 +90,8 @@ update_time (void)static inline void update_time (void ) { -#if defined(WIN32 ) -/* on WIN32, gettimeofday is faster than time(NULL) */ +#if defined(_WIN32) +/* on _WIN32, gettimeofday is faster than time(NULL) */ struct timeval tv;if (!gettimeofday (&tv,NULL )) {
src/openvpn/platform.c +10 -10
@@ -158,7 +158,7 @@ platform_nice (int niceval)unsigned int platform_getpid () { -#ifdef WIN32 +#ifdef _WIN32return (unsigned int )GetCurrentProcessId ();#else #ifdef HAVE_GETPID
@@ -190,7 +190,7 @@ int platform_chdir (const char* dir) {#ifdef HAVE_CHDIR -#ifdef WIN32 +#ifdef _WIN32int res;struct gc_arena gc =gc_new (); res =_wchdir (wide_string (dir, &gc));
@@ -210,7 +210,7 @@ platform_chdir (const char* dir)bool platform_system_ok (int stat) { -#ifdef WIN32 +#ifdef _WIN32return stat ==0 ;#else return stat !=-1 &&WIFEXITED (stat) &&WEXITSTATUS (stat) ==0 ;
@@ -220,7 +220,7 @@ platform_system_ok (int stat)int platform_access (const char *path,int mode) { -#ifdef WIN32 +#ifdef _WIN32struct gc_arena gc =gc_new ();int ret =_waccess (wide_string (path, &gc), mode & ~X_OK );gc_free (&gc);
@@ -236,7 +236,7 @@ platform_access (const char *path, int mode)void platform_sleep_milliseconds (unsigned int n) { -#ifdef WIN32 +#ifdef _WIN32Sleep (n);#else struct timeval tv;
@@ -252,7 +252,7 @@ platform_sleep_milliseconds (unsigned int n)void platform_sleep_until_signal (void ) { -#ifdef WIN32 +#ifdef _WIN32ASSERT (0 );#else select (0 ,NULL ,NULL ,NULL ,NULL );
@@ -263,7 +263,7 @@ platform_sleep_until_signal (void)bool platform_unlink (const char *filename) { -#if defined(WIN32 ) +#if defined(_WIN32)struct gc_arena gc =gc_new ();BOOL ret =DeleteFileW (wide_string (filename, &gc));gc_free (&gc);
@@ -278,7 +278,7 @@ platform_unlink (const char *filename)FILE *platform_fopen (const char *path,const char *mode) { -#ifdef WIN32 +#ifdef _WIN32struct gc_arena gc =gc_new ();FILE *f =_wfopen (wide_string (path, &gc),wide_string (mode, &gc));gc_free (&gc);
@@ -291,7 +291,7 @@ platform_fopen (const char *path, const char *mode)int platform_open (const char *path,int flags,int mode) { -#ifdef WIN32 +#ifdef _WIN32struct gc_arena gc =gc_new ();int fd =_wopen (wide_string (path, &gc), flags, mode);gc_free (&gc);
@@ -304,7 +304,7 @@ platform_open (const char *path, int flags, int mode)int platform_stat (const char *path,platform_stat_t *buf) { -#ifdef WIN32 +#ifdef _WIN32struct gc_arena gc =gc_new ();int res =_wstat (wide_string (path, &gc), buf);gc_free (&gc);
src/openvpn/platform.h +1 -1
@@ -130,7 +130,7 @@ int platform_putenv (char *string);FILE *platform_fopen (const char *path,const char *mode);int platform_open (const char *path,int flags,int mode); -#ifdef WIN32 +#ifdef _WIN32typedef struct _stat platform_stat_t ;#else typedef struct stat platform_stat_t ;
src/openvpn/plugin.c +4 -4
@@ -175,7 +175,7 @@ plugin_option_list_print (const struct plugin_option_list *list, int msglevel) }#endif -#ifndef WIN32 +#ifndef _WIN32static void libdl_resolve_symbol (void *handle,void **dest,const char *symbol,const char *plugin_name,const unsigned int flags)
@@ -206,7 +206,7 @@ plugin_init_item (struct plugin *p, const struct plugin_option *o) p->so_pathname = o->so_pathname; p->plugin_type_mask =plugin_supported_types (); -#ifndef WIN32 +#ifndef _WIN32 p->handle =NULL ;#if defined(PLUGIN_LIBDIR )
@@ -519,10 +519,10 @@ plugin_close_item (struct plugin *p)if (p->plugin_handle) (*p->close)(p->plugin_handle); -#ifndef WIN32 +#ifndef _WIN32if (dlclose (p->handle))msg (M_WARN ,"PLUGIN_CLOSE: dlclose() failed on plugin: %s" , p->so_pathname); -#elif defined(WIN32 ) +#elif defined(_WIN32)if (!FreeLibrary (p->module))msg (M_WARN ,"PLUGIN_CLOSE: FreeLibrary() failed on plugin: %s" , p->so_pathname);#endif
src/openvpn/plugin.h +1 -1
@@ -59,7 +59,7 @@ struct plugin {unsigned int plugin_type_mask;int requested_initialization_point; -#ifndef WIN32 +#ifndef _WIN32void *handle;#else HMODULE module;
src/openvpn/route.c +13 -13
@@ -49,7 +49,7 @@#include <linux/rtnetlink.h> /* RTM_GETROUTE etc. */ #endif -#ifdef WIN32 +#ifdef _WIN32#include "openvpn-msg.h" #define METRIC_NOT_USED ((DWORD)-1)
@@ -807,7 +807,7 @@ init_route_ipv6_list (struct route_ipv6_list *rl6,if ( !(rl6->rgi6.flags &RGI_ON_LINK ) ) { r6->gateway = rl6->rgi6.gateway.addr_ipv6; } r6->metric =1 ; -#ifdef WIN32 +#ifdef _WIN32 r6->adapter_index = rl6->rgi6.adapter_index;#else r6->iface = rl6->rgi6.iface;
@@ -1214,7 +1214,7 @@ print_default_gateway(const int msglevel,buf_printf (&out," %s" ,print_in_addr_t (rgi->gateway.addr,0 , &gc));if (rgi->flags &RGI_NETMASK_DEFINED )buf_printf (&out,"/%s" ,print_in_addr_t (rgi->gateway.netmask,0 , &gc)); -#ifdef WIN32 +#ifdef _WIN32if (rgi->flags &RGI_IFACE_DEFINED )buf_printf (&out," I=%u" , (unsigned int )rgi->adapter_index);#else
@@ -1235,7 +1235,7 @@ print_default_gateway(const int msglevel,buf_printf (&out," ON_LINK" );if (rgi6->flags &RGI_NETMASK_DEFINED )buf_printf (&out,"/%d" , rgi6->gateway.netbits_ipv6); -#ifdef WIN32 +#ifdef _WIN32if (rgi6->flags &RGI_IFACE_DEFINED )buf_printf (&out," I=%u" , (unsigned int )rgi6->adapter_index);#else
@@ -1455,7 +1455,7 @@ add_route (struct route_ipv4 *r,buf_printf (&out,"%s %s %s" , network, netmask, gateway);management_android_control (management,"ROUTE" ,buf_bptr (&out)); -#elif defined (WIN32 ) +#elif defined (_WIN32) {DWORD ai =TUN_ADAPTER_INDEX_INVALID ; argv_printf (&argv, "%s%sc ADD %s MASK %s %s",
@@ -1683,7 +1683,7 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flaif (! (r6->flags &RT_DEFINED ) )return ; -#ifndef WIN32 +#ifndef _WIN32if ( r6->iface !=NULL )/* vpn server special route */ { device = r6->iface;
@@ -1779,7 +1779,7 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flamanagement_android_control (management,"ROUTE6" ,buf_bptr (&out)); -#elif defined (WIN32 ) +#elif defined (_WIN32)if (tt->options.msg_channel) status =add_route_ipv6_service (r6, tt);
@@ -1970,7 +1970,7 @@ delete_route (struct route_ipv4 *r,argv_msg (D_ROUTE , &argv);openvpn_execve_check (&argv, es,0 ,"ERROR: Linux route delete command failed" ); -#elif defined (WIN32 ) +#elif defined (_WIN32) argv_printf (&argv, "%s%sc DELETE %s MASK %s %s", get_win_sys_path(),
@@ -2117,7 +2117,7 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigneif ((r6->flags & (RT_DEFINED |RT_ADDED )) != (RT_DEFINED |RT_ADDED ))return ; -#ifndef WIN32 +#ifndef _WIN32if ( r6->iface !=NULL )/* vpn server special route */ { device = r6->iface;
@@ -2184,7 +2184,7 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigneargv_msg (D_ROUTE , &argv);openvpn_execve_check (&argv, es,0 ,"ERROR: Linux route -6/-A inet6 del command failed" ); -#elif defined (WIN32 ) +#elif defined (_WIN32)if (tt->options.msg_channel)del_route_ipv6_service (r6, tt);
@@ -2320,7 +2320,7 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigne* to get the current default gateway. */ -#if defined(WIN32 ) +#if defined(_WIN32)static const MIB_IPFORWARDTABLE *get_windows_routing_table (struct gc_arena *gc)
@@ -3698,7 +3698,7 @@ int netmask_to_netbits2 (in_addr_t netmask)* so that outgoing packets to these servers don't end up in the tunnel. */ -#if defined(WIN32 ) +#if defined(_WIN32)static void add_host_route_if_nonlocal (struct route_bypass *rb,const in_addr_t addr)
@@ -3772,7 +3772,7 @@ get_bypass_addresses (struct route_bypass *rb, const unsigned int flags) /* PLA* Used by redirect-gateway autolocal feature */ -#if defined(WIN32 ) +#if defined(_WIN32)int test_local_addr (const in_addr_t addr,const struct route_gateway_info *rgi)
src/openvpn/route.h +5 -5
@@ -33,7 +33,7 @@#include "tun.h" #include "misc.h" -#ifdef WIN32 +#ifdef _WIN32/* * Windows route methods */
@@ -130,7 +130,7 @@ struct route_ipv6 {struct in6_addr gateway;int metric;/* gateway interface */ -# ifdef WIN32 +# ifdef _WIN32DWORD adapter_index;/* interface or ~0 if undefined */ #else char * iface;/* interface name (null terminated) */
@@ -153,7 +153,7 @@ struct route_gateway_info {unsigned int flags;/* gateway interface */ -# ifdef WIN32 +# ifdef _WIN32DWORD adapter_index;/* interface or ~0 if undefined */ #else char iface[16 ];/* interface name (null terminated), may be empty */
@@ -181,7 +181,7 @@ struct route_ipv6_gateway_info {unsigned int flags;/* gateway interface */ -# ifdef WIN32 +# ifdef _WIN32DWORD adapter_index;/* interface or ~0 if undefined */ #else char iface[16 ];/* interface name (null terminated), may be empty */
@@ -333,7 +333,7 @@ void print_route_options (const struct route_option_list *rol,void print_routes (const struct route_list *rl,int level); -#ifdef WIN32 +#ifdef _WIN32void show_routes (int msglev);bool test_routes (const struct route_list *rl,const struct tuntap *tt);
src/openvpn/sig.c +4 -4
@@ -221,7 +221,7 @@ static int signal_mode; /* GLOBAL */void pre_init_signal_catch (void ) { -#ifndef WIN32 +#ifndef _WIN32#ifdef HAVE_SIGNAL_H signal_mode =SM_PRE_INIT ;signal (SIGINT , signal_handler);
@@ -231,13 +231,13 @@ pre_init_signal_catch (void)signal (SIGUSR2 ,SIG_IGN );signal (SIGPIPE ,SIG_IGN );#endif /* HAVE_SIGNAL_H */ -#endif /* WIN32 */ +#endif /* _WIN32 */ }void post_init_signal_catch (void ) { -#ifndef WIN32 +#ifndef _WIN32#ifdef HAVE_SIGNAL_H signal_mode =SM_POST_INIT ;signal (SIGINT , signal_handler);
@@ -291,7 +291,7 @@ print_status (const struct context *c, struct status_output *so)status_printf (so,"Pre-encrypt truncations," counter_format, c->c2.n_trunc_pre_encrypt);status_printf (so,"Post-decrypt truncations," counter_format, c->c2.n_trunc_post_decrypt);#endif -#ifdef WIN32 +#ifdef _WIN32if (tuntap_defined (c->c1.tuntap))status_printf (so,"TAP-WIN32 driver status,\"%s\"" ,tap_win_getinfo (c->c1.tuntap, &gc));
src/openvpn/sig.h +1 -1
@@ -79,7 +79,7 @@ void register_signal (struct context *c, int sig, const char *text);void process_explicit_exit_notification_timer_wakeup (struct context *c);#endif -#ifdef WIN32 +#ifdef _WIN32static inline void get_signal (volatile int *sig)
src/openvpn/socket.c +20 -20
@@ -376,7 +376,7 @@ openvpn_getaddrinfo (unsigned int flags,*/ while (true) { -#ifndef WIN32 +#ifndef _WIN32res_init ();#endif /* try hostname lookup */
@@ -690,7 +690,7 @@ socket_set_buffers (int fd, const struct socket_buffer_size *sbs)static bool socket_set_tcp_nodelay (int sd,int state) { -#if defined(WIN32 ) || (defined(HAVE_SETSOCKOPT ) && defined(IPPROTO_TCP ) && defined(TCP_NODELAY )) +#if defined(_WIN32) || (defined(HAVE_SETSOCKOPT ) && defined(IPPROTO_TCP ) && defined(TCP_NODELAY ))if (setsockopt (sd,IPPROTO_TCP ,TCP_NODELAY , (void *) &state,sizeof (state)) !=0 ) {msg (M_WARN ,"NOTE: setsockopt TCP_NODELAY=%d failed" , state);
@@ -761,7 +761,7 @@ create_socket_tcp (struct addrinfo* addrinfo)if ((sd =socket (addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol)) <0 )msg (M_ERR ,"Cannot create TCP socket" ); -#ifndef WIN32 /* using SO_REUSEADDR on Windows will cause bind to succeed on port conflicts! */ +#ifndef _WIN32/* using SO_REUSEADDR on Windows will cause bind to succeed on port conflicts! */ /* set SO_REUSEADDR on socket */ {int on =1 ;
@@ -1066,7 +1066,7 @@ socket_listen_accept (socket_descriptor_t sd,/* older mingw versions and WinXP do not have this define, * but Vista and up support the functionality - just define it here */ -#ifdef WIN32 +#ifdef _WIN32# ifndef IPV6_V6ONLY # define IPV6_V6ONLY 27# endif
@@ -1141,7 +1141,7 @@ openvpn_connect (socket_descriptor_t sd,if (status) status =openvpn_errno (); if ( -#ifdef WIN32 +#ifdef _WIN32 status == WSAEWOULDBLOCK#else status ==EINPROGRESS
@@ -1184,7 +1184,7 @@ openvpn_connect (socket_descriptor_t sd, {if (--connect_timeout <0 ) { -#ifdef WIN32 +#ifdef _WIN32 status =WSAETIMEDOUT ;#else status =ETIMEDOUT ;
@@ -1296,7 +1296,7 @@ socket_connect (socket_descriptor_t* sd,static void socket_frame_init (const struct frame *frame,struct link_socket *sock) { -#ifdef WIN32 +#ifdef _WIN32overlapped_io_init (&sock->reads, frame, FALSE, false);overlapped_io_init (&sock->writes, frame, TRUE, false); sock->rw_handle.read = sock->reads.overlapped.hEvent;
@@ -1305,7 +1305,7 @@ socket_frame_init (const struct frame *frame, struct link_socket *sock)if (link_socket_connection_oriented (sock)) { -#ifdef WIN32 +#ifdef _WIN32 stream_buf_init (&sock->stream_buf, &sock->reads.buf_init, sock->sockflags,
@@ -1971,7 +1971,7 @@ link_socket_close (struct link_socket *sock)if (socket_defined (sock->sd)) { -#ifdef WIN32 +#ifdef _WIN32close_net_event_win32 (&sock->listen_handle, sock->sd,0 );#endif if (!gremlin)
@@ -1981,7 +1981,7 @@ link_socket_close (struct link_socket *sock)msg (M_WARN |M_ERRNO ,"TCP/UDP: Close Socket failed" ); } sock->sd =SOCKET_UNDEFINED ; -#ifdef WIN32 +#ifdef _WIN32if (!gremlin) {overlapped_io_close (&sock->reads);
@@ -2175,7 +2175,7 @@ socket_stat (const struct link_socket *s, unsigned int rwflags, struct gc_arena {buf_printf (&out,"S%s" , (s->rwflags_debug &EVENT_READ ) ?"R" :"r" ); -#ifdef WIN32 +#ifdef _WIN32buf_printf (&out,"%s" ,overlapped_io_state_ascii (&s->reads));#endif
@@ -2184,7 +2184,7 @@ socket_stat (const struct link_socket *s, unsigned int rwflags, struct gc_arena {buf_printf (&out,"S%s" , (s->rwflags_debug &EVENT_WRITE ) ?"W" :"w" ); -#ifdef WIN32 +#ifdef _WIN32buf_printf (&out,"%s" ,overlapped_io_state_ascii (&s->writes));#endif
@@ -2359,7 +2359,7 @@ stream_buf_close (struct stream_buf* sb)event_t socket_listen_event_handle (struct link_socket *s) { -#ifdef WIN32 +#ifdef _WIN32if (!defined_net_event_win32 (&s->listen_handle))init_net_event_win32 (&s->listen_handle,FD_ACCEPT , s->sd,0 );return &s->listen_handle;
@@ -2836,7 +2836,7 @@ link_socket_read_tcp (struct link_socket *sock,if (!sock->stream_buf.residual_fully_formed) { -#ifdef WIN32 +#ifdef _WIN32 len =socket_finalize (sock->sd, &sock->reads, buf,NULL );#else struct buffer frag;
@@ -2861,7 +2861,7 @@ link_socket_read_tcp (struct link_socket *sock,return buf->len =0 ;/* no error, but packet is still incomplete */ } -#ifndef WIN32 +#ifndef _WIN32#if ENABLE_IP_PKTINFO
@@ -2982,7 +2982,7 @@ link_socket_write_tcp (struct link_socket *sock,ASSERT (len <= sock->stream_buf.maxlen); len =htonps (len);ASSERT (buf_write_prepend (buf, &len,sizeof (len))); -#ifdef WIN32 +#ifdef _WIN32return link_socket_write_win32 (sock, buf, to);#else return link_socket_write_tcp_posix (sock, buf, to);
@@ -3070,7 +3070,7 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,* Win32 overlapped socket I/O functions. */ -#ifdef WIN32 +#ifdef _WIN32int socket_recv_queue (struct link_socket *sock,int maxsize)
@@ -3378,7 +3378,7 @@ socket_finalize (SOCKET s,case sizeof (struct sockaddr_in ):case sizeof (struct sockaddr_in6 ):/* TODO(jjo): for some reason (?) I'm getting 24,28 for AF_INET6 -* under WIN32*/ +* under _WIN32*/ case sizeof (struct sockaddr_in6 )-4 :break ;default :
@@ -3404,7 +3404,7 @@ socket_finalize (SOCKET s, return ret; } -#endif /* WIN32 */ +#endif /* _WIN32 */ /* * Socket event notification
@@ -3425,7 +3425,7 @@ socket_set (struct link_socket *s, rwflags &= ~EVENT_READ ; } -#ifdef WIN32 +#ifdef _WIN32if (rwflags &EVENT_READ )socket_recv_queue (s,0 );#endif
src/openvpn/socket.h +9 -9
@@ -169,7 +169,7 @@ struct link_socketsocket_descriptor_t sd;socket_descriptor_t ctrl_sd;/* only used for UDP over Socks */ -#ifdef WIN32 +#ifdef _WIN32struct overlapped_io reads;struct overlapped_io writes;struct rw_handle rw_handle;
@@ -257,7 +257,7 @@ struct link_socket#define MSG_NOSIGNAL 0#endif -#ifdef WIN32 +#ifdef _WIN32#define openvpn_close_socket (s) closesocket(s)
@@ -842,7 +842,7 @@ socket_connection_reset (const struct link_socket *sock, int status)else if (status <0 ) {const int err =openvpn_errno (); -#ifdef WIN32 +#ifdef _WIN32return err ==WSAECONNRESET || err ==WSAECONNABORTED ;#else return err ==ECONNRESET ;
@@ -950,7 +950,7 @@ stream_buf_read_setup (struct link_socket* sock)int link_socket_read_tcp (struct link_socket *sock,struct buffer *buf); -#ifdef WIN32 +#ifdef _WIN32 static inline int link_socket_read_udp_win32 (struct link_socket *sock,
@@ -978,7 +978,7 @@ link_socket_read (struct link_socket *sock, {int res; -#ifdef WIN32 +#ifdef _WIN32 res =link_socket_read_udp_win32 (sock, buf, from);#else res =link_socket_read_udp_posix (sock, buf, from);
@@ -1006,7 +1006,7 @@ int link_socket_write_tcp (struct link_socket *sock,struct buffer *buf, struct link_socket_actual *to); -#ifdef WIN32 +#ifdef _WIN32 static inline int link_socket_write_win32 (struct link_socket *sock,
@@ -1068,7 +1068,7 @@ link_socket_write_udp (struct link_socket *sock,struct buffer *buf, struct link_socket_actual *to) { -#ifdef WIN32 +#ifdef _WIN32 return link_socket_write_win32 (sock, buf, to);#else return link_socket_write_udp_posix (sock, buf, to);
@@ -1138,7 +1138,7 @@ socket_read_residual (const struct link_socket *s)static inline event_t socket_event_handle (const struct link_socket *s) { -#ifdef WIN32 +#ifdef _WIN32return &s->rw_handle;#else return s->sd;
@@ -1169,7 +1169,7 @@ socket_set_listen_persistent (struct link_socket *s,static inline void socket_reset_listen_persistent (struct link_socket *s) { -#ifdef WIN32 +#ifdef _WIN32reset_net_event_win32 (&s->listen_handle, s->sd);#endif }
src/openvpn/ssl.c +2 -2
@@ -1978,7 +1978,7 @@ push_peer_info(struct buffer *buf, struct tls_session *session)buf_printf (&out,"IV_PLAT=freebsd\n" );#elif defined(TARGET_ANDROID )buf_printf (&out,"IV_PLAT=android\n" ); -#elif defined(WIN32 ) +#elif defined(_WIN32)buf_printf (&out,"IV_PLAT=win\n" );#endif
@@ -2008,7 +2008,7 @@ push_peer_info(struct buffer *buf, struct tls_session *session)if (rgi.flags &RGI_HWADDR_DEFINED )buf_printf (&out,"IV_HWADDR=%s\n" ,format_hex_ex (rgi.hwaddr,6 ,0 ,1 ,":" , &gc));buf_printf (&out,"IV_SSL=%s\n" ,get_ssl_library_version () ); -#if defined(WIN32 ) +#if defined(_WIN32)buf_printf (&out,"IV_PLAT_VER=%s\n" ,win32_version_string (&gc, false));#endif }
src/openvpn/ssl_backend.h +1 -1
@@ -232,7 +232,7 @@ int tls_ctx_load_pkcs12(struct tls_root_ctx *ctx, const char *pkcs12_file,*/ #ifdef ENABLE_CRYPTOAPI void tls_ctx_load_cryptoapi (struct tls_root_ctx *ctx,const char *cryptoapi_cert); -#endif /* WIN32 */ +#endif /* _WIN32 */ /** * Load certificate file into the given TLS context. If the given certificate
src/openvpn/ssl_mbedtls.c +1 -1
@@ -283,7 +283,7 @@ tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert) {msg (M_FATAL ,"Windows CryptoAPI not yet supported for mbed TLS." ); } -#endif /* WIN32 */ +#endif /* _WIN32 */ void tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file,
src/openvpn/ssl_openssl.c +1 -1
@@ -633,7 +633,7 @@ tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert)if (!SSL_CTX_use_CryptoAPI_certificate (ctx->ctx, cryptoapi_cert)) crypto_msg (M_FATAL, "Cannot load certificate \"%s\" from Microsoft Certificate Store", cryptoapi_cert); } -#endif /* WIN32 */ +#endif /* _WIN32 */ static void tls_ctx_add_extra_certs (struct tls_root_ctx *ctx,BIO *bio)
src/openvpn/syshead.h +8 -18
@@ -37,7 +37,7 @@# define unlikely (x) (x)#endif -#ifdef WIN32 +#ifdef _WIN32#include <windows.h> #include <winsock2.h> #define sleep (x) Sleep((x)*1000)
@@ -64,7 +64,7 @@# include <sys/wait.h> #endif -#ifndef WIN32 +#ifndef _WIN32#ifndef WEXITSTATUS # define WEXITSTATUS (stat_val) ((unsigned)(stat_val) >> 8)#endif
@@ -358,7 +358,7 @@#endif /* TARGET_DARWIN */ -#ifdef WIN32 +#ifdef _WIN32// Missing declarations for MinGW 32. // #if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 2 typedef int MIB_TCP_STATE ;
@@ -405,7 +405,7 @@/* * Do we have nanoseconds gettimeofday? */ -#if defined(HAVE_GETTIMEOFDAY ) || defined(WIN32 ) +#if defined(HAVE_GETTIMEOFDAY ) || defined(_WIN32)#define HAVE_GETTIMEOFDAY_NANOSECONDS 1#endif
@@ -470,26 +470,16 @@ typedef unsigned short sa_family_t;/* * Directory separation char */ -#ifdef WIN32 +#ifdef _WIN32#define OS_SPECIFIC_DIRSEP '\\'#else #define OS_SPECIFIC_DIRSEP '/'#endif /* -* Define a boolean value based -* on Win32 status. -*/ -#ifdef WIN32 -#define WIN32_0_1 1 -#else -#define WIN32_0_1 0 -#endif - -/* * Our socket descriptor type. */ -#ifdef WIN32 +#ifdef _WIN32#define SOCKET_UNDEFINED (INVALID_SOCKET)typedef SOCKET socket_descriptor_t ;#else
@@ -590,7 +580,7 @@ socket_defined (const socket_descriptor_t sd)/* * Do we support Unix domain sockets? */ -#if defined(PF_UNIX ) && !defined(WIN32 ) +#if defined(PF_UNIX ) && !defined(_WIN32)#define UNIX_SOCK_SUPPORT 1#else #define UNIX_SOCK_SUPPORT 0
@@ -624,7 +614,7 @@ socket_defined (const socket_descriptor_t sd)/* * Do we have CryptoAPI capability? */ -#if defined(WIN32 ) && defined(ENABLE_CRYPTO ) && defined(ENABLE_CRYPTO_OPENSSL ) +#if defined(_WIN32) && defined(ENABLE_CRYPTO ) && defined(ENABLE_CRYPTO_OPENSSL )#define ENABLE_CRYPTOAPI #endif
src/openvpn/tun.c +12 -12
@@ -49,13 +49,13 @@#include "memdbg.h" -#ifdef WIN32 +#ifdef _WIN32#include "openvpn-msg.h" #endif #include <string.h> -#ifdef WIN32 +#ifdef _WIN32/* #define SIMULATE_DHCP_FAILED */ /* simulate bad DHCP negotiation */
@@ -198,7 +198,7 @@ guess_tuntap_dev (const char *dev,const char *dev_node, struct gc_arena *gc) { -#ifdef WIN32 +#ifdef _WIN32 const int dt = dev_type_enum (dev, dev_type);if (dt ==DEV_TYPE_TUN || dt ==DEV_TYPE_TAP ) {
@@ -421,7 +421,7 @@ tun_stat (const struct tuntap *tt, unsigned int rwflags, struct gc_arena *gc) {buf_printf (&out,"T%s" , (tt->rwflags_debug &EVENT_READ ) ?"R" :"r" ); -#ifdef WIN32 +#ifdef _WIN32buf_printf (&out,"%s" ,overlapped_io_state_ascii (&tt->reads));#endif
@@ -430,7 +430,7 @@ tun_stat (const struct tuntap *tt, unsigned int rwflags, struct gc_arena *gc) {buf_printf (&out,"T%s" , (tt->rwflags_debug &EVENT_WRITE ) ?"W" :"w" ); -#ifdef WIN32 +#ifdef _WIN32buf_printf (&out,"%s" ,overlapped_io_state_ascii (&tt->writes));#endif
@@ -611,7 +611,7 @@ init_tun (const char *dev, /* --dev option */ tt->broadcast =generate_ifconfig_broadcast_addr (tt->local, tt->remote_netmask); } -#ifdef WIN32 +#ifdef _WIN32/* * Make sure that both ifconfig addresses are part of the * same .252 subnet.
@@ -665,7 +665,7 @@ init_tun_post (struct tuntap *tt, const struct tuntap_options *options) { tt->options = *options; -#ifdef WIN32 +#ifdef _WIN32overlapped_io_init (&tt->reads, frame, FALSE, true);overlapped_io_init (&tt->writes, frame, TRUE, true); tt->rw_handle.read = tt->reads.overlapped.hEvent;
@@ -674,7 +674,7 @@ init_tun_post (struct tuntap *tt,#endif } -#if defined(WIN32 ) || \ +#if defined(_WIN32) || \ defined(TARGET_DARWIN ) || defined(TARGET_NETBSD ) || defined(TARGET_OPENBSD )/* some of the platforms will auto-add a "network route" pointing
@@ -1348,7 +1348,7 @@ do_ifconfig (struct tuntap *tt, }env_set_destroy (aix_es); } -#elif defined (WIN32) +#elif defined (_WIN32) {ASSERT (actual !=NULL );
@@ -1407,7 +1407,7 @@ static void clear_tuntap (struct tuntap *tuntap) {CLEAR (*tuntap); -#ifdef WIN32 +#ifdef _WIN32 tuntap->hand =NULL ;#else tuntap->fd =-1 ;
@@ -1504,7 +1504,7 @@ read_tun_header (struct tuntap* tt, uint8_t *buf, int len)#endif -#ifndef WIN32 +#ifndef _WIN32static void open_tun_generic (const char *dev,const char *dev_type,const char *dev_node,bool dynamic,struct tuntap *tt)
@@ -3024,7 +3024,7 @@ read_tun (struct tuntap* tt, uint8_t *buf, int len) return read (tt->fd, buf, len); } -#elif defined(WIN32) +#elif defined(_WIN32)int tun_read_queue (struct tuntap *tt,int maxsize)
src/openvpn/tun.h +9 -9
@@ -25,7 +25,7 @@#ifndef TUN_H #define TUN_H -#ifdef WIN32 +#ifdef _WIN32#include <winioctl.h> #include <tap-windows.h> #endif
@@ -38,7 +38,7 @@#include "proto.h" #include "misc.h" -#if defined(WIN32 ) || defined(TARGET_ANDROID ) +#if defined(_WIN32) || defined(TARGET_ANDROID )#define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1)
@@ -58,7 +58,7 @@ struct tuntap_options {# define IPW32_SET_N 5int ip_win32_type; -#ifdef WIN32 +#ifdef _WIN32HANDLE msg_channel;#endif
@@ -157,7 +157,7 @@ struct tuntapstruct in6_addr remote_ipv6;int netbits_ipv6; -#ifdef WIN32 +#ifdef _WIN32HANDLE hand;struct overlapped_io reads;struct overlapped_io writes;
@@ -197,7 +197,7 @@ struct tuntapstatic inline bool tuntap_defined (const struct tuntap *tt) { -#ifdef WIN32 +#ifdef _WIN32return tt && tt->hand !=NULL ;#else return tt && tt->fd >=0 ;
@@ -298,7 +298,7 @@ ifconfig_order(void)return IFCONFIG_AFTER_TUN_OPEN ;#elif defined(TARGET_NETBSD )return IFCONFIG_AFTER_TUN_OPEN ; -#elif defined(WIN32 ) +#elif defined(_WIN32)return IFCONFIG_AFTER_TUN_OPEN ;#elif defined(TARGET_ANDROID )return IFCONFIG_BEFORE_TUN_OPEN ;
@@ -322,7 +322,7 @@ route_order(void) } -#ifdef WIN32 +#ifdef _WIN32#define TUN_PASS_BUFFER
@@ -476,7 +476,7 @@ tun_standby (struct tuntap *tt)static inline event_t tun_event_handle (const struct tuntap *tt) { -#ifdef WIN32 +#ifdef _WIN32return &tt->rw_handle;#else return tt->fd;
@@ -499,7 +499,7 @@ tun_set (struct tuntap *tt,if (persistent) *persistent = rwflags; } -#ifdef WIN32 +#ifdef _WIN32if (rwflags &EVENT_READ )tun_read_queue (tt,0 );#endif
src/openvpn/win32.c +1 -1
@@ -35,7 +35,7 @@#include "syshead.h" -#ifdef WIN32 +#ifdef _WIN32#include "buffer.h" #include "error.h"
src/openvpn/win32.h +1 -1
@@ -22,7 +22,7 @@* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef WIN32 +#ifdef _WIN32#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H
Signature · 1 line
1.9.1
Hi,
Quoted 48 lines · Gert Doering
With c99, "WIN32" is no longer automatically defined when (cross-)building for Windows, and proper compilation relies on including <
windefs.h>, before checking the macro. "_WIN32" is the official define that is guaranteed to be defined by the compiler itself, no includes are needed.So, mechanically change all occurrances of "WIN32" to "
_WIN32".While at it, get rid of unused
WIN32_0_1#define insyshead.hTrac #746
v2: rebased to master, merge the console[_builtin].c changes
[...snip...]
src/openvpn/ssl_backend.h +1
-1@@ -232,7 +232,7 @@ int tls_ctx_load_pkcs12(struct tls_root_ctx *ctx, const char *pkcs12_file,*/ #ifdef ENABLE_CRYPTOAPI void tls_ctx_load_cryptoapi (struct tls_root_ctx *ctx,const char *cryptoapi_cert); -#endif /* WIN32 */ +#endif /* _WIN32 */ /** * Load certificate file into the given TLS context. If the given certificate src/openvpn/ssl_mbedtls.c +1
-1@@ -283,7 +283,7 @@ tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert) {msg (M_FATAL ,"Windows CryptoAPI not yet supported for mbed TLS." ); } -#endif /* WIN32 */ +#endif /* _WIN32 */ void tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file,src/openvpn/ssl_openssl.c +0
-0
src/openvpn/ssl_openssl.c tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert) · line 639
Quoted 8 lines
src/openvpn/ssl_openssl.c +1
-1@@ -633,7 +633,7 @@ tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert)if (!SSL_CTX_use_CryptoAPI_certificate (ctx->ctx, cryptoapi_cert)) crypto_msg (M_FATAL, "Cannot load certificate \"%s\" from Microsoft Certificate Store", cryptoapi_cert); } -#endif /* WIN32 */ +#endif /* _WIN32 */ static void tls_ctx_add_extra_certs (struct tls_root_ctx *ctx,BIO *bio)
These should actually be "#endif /* ENABLE_CRYPTOAPI */".
Other than that, ACK.
-Steffan
Patch has been applied to the master branch.
I have changed the '#endif /* ENABLE_CRYPTOAPI */' as suggested (because it obviously makes sense), and had to move one hunk from misc.c to options.c (someone moved warn_if_group_others_accessible() around while I was not looking).
Further, the change to m4/ax_socklen_t.m4 was already brought in by commit 11eedcd00, so skipped that hunk.
commit 445b192a7c31187c7b5c66c8250a1886b04a2b2c
Author: Gert Doering Date: Sun Nov 13 20:52:28 2016 +0100
Replace WIN32 by _WIN32
Signed-off-by: Gert Doering <[email protected]...>
Acked-by: Steffan Karger <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg13035.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering