From 74fce85ee80ee5f484b62a3a81e9981e5698f1e1 Mon Sep 17 00:00:00 2001 From: James Yonan Date: Wed, 31 Mar 2010 06:38:21 +0000 Subject: Updated MSVC build scripts to Visual Studio 2008: python msvc\config.py nmake /f msvc\msvc.mak Version 2.1.1e git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@5516 e7ae566f-a301-0410-adde-c780ea21d3b5 --- .svnignore | 2 +- INSTALL | 6 +- Makefile.am | 5 +- buffer.c | 2 +- config-win32.h | 304 +++++++++++++++++++++++++++++++++++++++++++++++++ config-win32.h.in | 325 ----------------------------------------------------- configure.ac | 1 - crypto.c | 12 +- makefile.w32-vc | 186 ------------------------------ manage.c | 2 +- misc.c | 3 +- msvc/autodefs.h.in | 20 ++++ msvc/config.py | 93 +++++++++++++++ msvc/msvc.mak | 52 +++++++++ multi.c | 2 +- sig.c | 2 +- tun.c | 2 +- version.m4 | 2 +- 18 files changed, 491 insertions(+), 530 deletions(-) create mode 100644 config-win32.h delete mode 100644 config-win32.h.in delete mode 100644 makefile.w32-vc create mode 100644 msvc/autodefs.h.in create mode 100644 msvc/config.py create mode 100644 msvc/msvc.mak diff --git a/.svnignore b/.svnignore index 34bbff2..c02d2b8 100644 --- a/.svnignore +++ b/.svnignore @@ -1,4 +1,5 @@ *.o +*.obj config.status config.log config.guess @@ -12,7 +13,6 @@ config.h Makefile config.h.in configure -config-win32.h config.sub openvpn.spec stamp-h1 diff --git a/INSTALL b/INSTALL index ea1124a..961fbd6 100644 --- a/INSTALL +++ b/INSTALL @@ -12,9 +12,13 @@ QUICK START: Unix: ./configure && make && make-install - Windows: + Windows MinGW, using MSYS bash shell: ./domake-win (see comments in the script for more info) + Windows MSVC using Visual Studio 2008 Command Prompt window: + python msvc\config.py + nmake /f msvc\msvc.mak + ************************************************************************* To download OpenVPN, go to: diff --git a/Makefile.am b/Makefile.am index 7bccc11..4cc3ce2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,7 +36,7 @@ MAINTAINERCLEANFILES = \ $(srcdir)/install-sh $(srcdir)/ltmain.sh $(srcdir)/missing \ $(srcdir)/depcomp $(srcdir)/aclocal.m4 \ $(srcdir)/config.guess $(srcdir)/config.sub \ - $(srcdir)/config-win32.h $(srcdir)/openvpn.spec + $(srcdir)/openvpn.spec CLEANFILES = openvpn.8.html EXTRA_DIST = \ @@ -58,8 +58,7 @@ SUBDIRS = \ TESTS = t_lpback.sh t_cltsrv.sh sbin_PROGRAMS = openvpn -dist_noinst_HEADERS = \ - config-win32.h +dist_noinst_HEADERS = dist_noinst_SCRIPTS = \ $(TESTS) \ diff --git a/buffer.c b/buffer.c index d448e5d..485c696 100644 --- a/buffer.c +++ b/buffer.c @@ -43,7 +43,7 @@ array_mult_safe (const size_t m1, const size_t m2, const size_t extra) } void -buf_size_error (size_t size) +buf_size_error (const size_t size) { msg (M_FATAL, "fatal buffer size error, size=%lu", (unsigned long)size); } diff --git a/config-win32.h b/config-win32.h new file mode 100644 index 0000000..d845ec0 --- /dev/null +++ b/config-win32.h @@ -0,0 +1,304 @@ +/* + * OpenVPN -- An application to securely tunnel IP networks + * over a single UDP port, with support for SSL/TLS-based + * session authentication and key exchange, + * packet encryption, packet authentication, and + * packet compression. + * + * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program (see the file COPYING included with this + * distribution); if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Configuration header for Win32 using the MSVC environment. + */ + +#include +#include +#include "autodefs.h" /* machine generated */ + +//#define sleep(x) Sleep((x)*1000) + +//#define random rand +//#define srandom srand + +typedef unsigned long in_addr_t; + +#ifndef _SSIZE_T_ +#define _SSIZE_T_ + typedef unsigned int ssize_t; +#endif + +/* Append a label to program startup title */ +/*#define DEBUG_LABEL "DEBUG1"*/ + +/* Should we print debug info from driver? */ +#ifdef PRODUCT_TAP_DEBUG +#define TAP_WIN32_DEBUG +#endif + +/* Enable client/server capability */ +#define ENABLE_CLIENT_SERVER 1 + +/* Enable client capability only */ +#define ENABLE_CLIENT_ONLY + +/* Enable management server capability */ +#define ENABLE_MANAGEMENT 1 + +/* Enable PKCS#11 support */ +/* #define USE_PKCS11 1 */ + +/* Enable HTTP proxy support */ +#define ENABLE_HTTP_PROXY 1 + +/* Enable Socks proxy support */ +#define ENABLE_SOCKS 1 + +/* Enable internal fragmentation support */ +#define ENABLE_FRAGMENT 1 + +/* Enable smaller executable size */ +/* #undef ENABLE_SMALL */ + +/* Enable debugging support */ +#define ENABLE_DEBUG 1 + +/* if defined, will allow usage of the --plugin directive */ +#define USE_LOAD_LIBRARY + +/* Dimension size to use for empty array declaration */ +#define EMPTY_ARRAY_SIZE 0 + +/* Define to 1 if you have the `getsockname' function. */ +#define HAVE_GETSOCKNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_ENGINE_H 1 + +/* Define to 1 if you have the `ENGINE_load_builtin_engines' function. */ +#define HAVE_ENGINE_LOAD_BUILTIN_ENGINES 1 + +/* Define to 1 if you have the `ENGINE_register_all_complete' function. */ +#define HAVE_ENGINE_REGISTER_ALL_COMPLETE 1 + +/* Define to 1 if you have the `ENGINE_cleanup' function. */ +#define HAVE_ENGINE_CLEANUP 1 + +/* gettimeofday() is implemented in otime.c for Windows */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the 'chsize' function. */ +#define HAVE_CHSIZE 1 + +/* Define to 1 if you have the `chdir' function. */ +#define HAVE_CHDIR 1 + +/* Define to 1 if your compiler supports GNU GCC-style variadic macros */ +#ifndef _MSC_VER /* Defines MSFT compiler version. Defined as 1200 for MSVC++ 6.0. */ +#define HAVE_CPP_VARARG_MACRO_GCC 1 +#endif + +/* Define to 1 if you have the header file. */ +#define HAVE_CTYPE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `EVP_CIPHER_CTX_set_key_length' function. */ +#define HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `getsockopt' function. */ +#define HAVE_GETSOCKOPT 1 + +/* Define to 1 if you have the `inet_ntoa' function. */ +#define HAVE_INET_NTOA 1 + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#define HAVE_MALLOC 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have the `setsockopt' function. */ +#define HAVE_SETSOCKOPT 1 + +/* Define to 1 if you have the `socket' function. */ +#define HAVE_SOCKET 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDARG_H 1 + +/* Define to 1 if you have the header file. */ +#ifndef _MSC_VER +#define HAVE_STDINT_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `system' function. */ +#define HAVE_SYSTEM 1 + +/* Define to 1 if you have the header file. */ +#ifndef _MSC_VER +#define HAVE_SYS_FILE_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#ifndef _MSC_VER +#define HAVE_SYS_TIME_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the `time' function. */ +#define HAVE_TIME 1 + +/* Define to 1 if you have the header file. */ +#ifndef _MSC_VER +#define HAVE_UNISTD_H 1 +#endif + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Special Windows version of getpass() defined in io.c */ +#define HAVE_GETPASS 1 + +/* Define to the address where bug reports for this package should be sent. */ +//#define PACKAGE_BUGREPORT "openvpn-users@lists.sourceforge.net" + +/* Define to the full name and version of this package. */ +#ifdef DEBUG_LABEL +#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION " " DEBUG_LABEL +#else +#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION +#endif + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* The size of a `unsigned int', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_INT 4 + +/* The size of a `unsigned long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG 4 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* A string representing our target */ +#ifdef _MSC_VER +#define TARGET_ALIAS "Win32-MSVC++" +#else +#define TARGET_ALIAS "Win32-MinGW" +#endif + +/* Define to 1 if you can safely include both and . */ +#ifndef _MSC_VER +#define TIME_WITH_SYS_TIME 1 +#endif + +/* Use OpenSSL crypto library */ +#define USE_CRYPTO 1 + +/* Use LZO compression library */ +#define USE_LZO 1 + +/* LZO version number */ +#define LZO_VERSION_NUM "2" + +/* Use lzo/ directory prefix for LZO header files (for LZO 2.0) */ +#define LZO_HEADER_DIR 1 + +/* Use OpenSSL SSL library */ +#define USE_SSL 1 + +/* Version number of package */ +#define VERSION PACKAGE_VERSION + +/* Define as `__inline' if that's what the C compiler calls it, or to nothing + if it is not supported. */ +#define inline __inline + +/* type to use in place of socklen_t if not defined */ +#define socklen_t unsigned int + +/* 32-bit unsigned type */ +#define uint32_t unsigned int + +/* 16-bit unsigned type */ +#define uint16_t unsigned short + +/* 8-bit unsigned type */ +#define uint8_t unsigned char + +/* Route command */ +#define ROUTE_PATH "route" + +/* Windows doesn't support PTHREAD yet */ +#ifdef USE_PTHREAD +#error The Windows version of OpenVPN does not support PTHREAD yet +#endif + +#ifdef _MSC_VER +/* MSVC++ hacks */ +#pragma warning(disable:4244) // conversion from 'foo' to 'bar', possible loss of data +#pragma warning(disable:4018) // signed/unsigned mismatch +#include +#include +//#define vsnprintf _vsnprintf +//#define vsnwprintf _vsnwprintf +#define snwprintf _snwprintf +#define write _write +#define open _open +#define read _read +#define close _close +#define lseek _lseek +#define chdir _chdir +#define strdup _strdup +#define chsize _chsize +#define S_IRUSR 0 +#define S_IWUSR 0 +#define TV_SEC_CAST (long) +#define TV_USEC_CAST (long) +typedef int intptr_t; +/* Visual Studio 2005 supports vararg macros */ +#if _MSC_VER >= 1400 +#define HAVE_CPP_VARARG_MACRO_ISO 1 +#endif +#endif diff --git a/config-win32.h.in b/config-win32.h.in deleted file mode 100644 index 6f699bb..0000000 --- a/config-win32.h.in +++ /dev/null @@ -1,325 +0,0 @@ -/* - * OpenVPN -- An application to securely tunnel IP networks - * over a single UDP port, with support for SSL/TLS-based - * session authentication and key exchange, - * packet encryption, packet authentication, and - * packet compression. - * - * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program (see the file COPYING included with this - * distribution); if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Configuration header for Win32 using the mingw environment. - * Manually edited based on linux version as generated by autoconf. - * - * config-win32.h is normally generated by copying - * config-win32.h.in -> config-win32.h and replacing - * [ampersand] VERSION [ampersand] - * with the appropriate version #. This is normally - * done automatically by configure.ac - */ - -#include -#include -#include "autodefs/defs.h" - -#define sleep(x) Sleep((x)*1000) - -#define random rand -#define srandom srand - -typedef unsigned long in_addr_t; - -#ifndef _SSIZE_T_ -#define _SSIZE_T_ - typedef unsigned int ssize_t; -#endif - -/* Append a label to program startup title */ -/*#define DEBUG_LABEL "DEBUG1"*/ - -/* Should we print debug info from driver? */ -#ifdef PRODUCT_TAP_DEBUG -#define TAP_WIN32_DEBUG -#endif - -/* - * Minimum TAP-Win32 version number expected by userspace - * - * The TAP-Win32 version number is defined in tap-win32/SOURCES - */ -#define TAP_ID @TAP_ID@ -#define TAP_WIN32_MIN_MAJOR @TAP_WIN32_MIN_MAJOR@ -#define TAP_WIN32_MIN_MINOR @TAP_WIN32_MIN_MINOR@ - -/* Enable client/server capability */ -#define ENABLE_CLIENT_SERVER 1 - -/* Enable client capability only */ -/* #undef ENABLE_CLIENT_ONLY */ - -/* Enable management server capability */ -#define ENABLE_MANAGEMENT 1 - -/* Enable PKCS#11 support */ -#define USE_PKCS11 1 - -/* Enable HTTP proxy support */ -#define ENABLE_HTTP_PROXY 1 - -/* Enable Socks proxy support */ -#define ENABLE_SOCKS 1 - -/* Enable internal fragmentation support */ -#define ENABLE_FRAGMENT 1 - -/* Enable smaller executable size */ -/* #undef ENABLE_SMALL */ - -/* Enable debugging support */ -#define ENABLE_DEBUG 1 - -/* if defined, will allow usage of the --plugin directive */ -#define USE_LOAD_LIBRARY - -/* Dimension size to use for empty array declaration */ -#define EMPTY_ARRAY_SIZE 0 - -/* Define to 1 if you have the `getsockname' function. */ -#define HAVE_GETSOCKNAME 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_OPENSSL_ENGINE_H 1 - -/* Define to 1 if you have the `ENGINE_load_builtin_engines' function. */ -#define HAVE_ENGINE_LOAD_BUILTIN_ENGINES 1 - -/* Define to 1 if you have the `ENGINE_register_all_complete' function. */ -#define HAVE_ENGINE_REGISTER_ALL_COMPLETE 1 - -/* Define to 1 if you have the `ENGINE_cleanup' function. */ -#define HAVE_ENGINE_CLEANUP 1 - -/* gettimeofday() is implemented in otime.c for Windows */ -#define HAVE_GETTIMEOFDAY 1 - -/* Define to 1 if you have the 'chsize' function. */ -#define HAVE_CHSIZE 1 - -/* Define to 1 if you have the `chdir' function. */ -#define HAVE_CHDIR 1 - -/* Define to 1 if your compiler supports GNU GCC-style variadic macros */ -#ifndef _MSC_VER /* Defines MSFT compiler version. Defined as 1200 for MSVC++ 6.0. */ -#define HAVE_CPP_VARARG_MACRO_GCC 1 -#endif - -/* Define to 1 if you have the header file. */ -#define HAVE_CTYPE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ERRNO_H 1 - -/* Define to 1 if you have the `EVP_CIPHER_CTX_set_key_length' function. */ -#define HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `getsockopt' function. */ -#define HAVE_GETSOCKOPT 1 - -/* Define to 1 if you have the `inet_ntoa' function. */ -#define HAVE_INET_NTOA 1 - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#define HAVE_MALLOC 1 - -/* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 - -/* Define to 1 if you have the `setsockopt' function. */ -#define HAVE_SETSOCKOPT 1 - -/* Define to 1 if you have the `socket' function. */ -#define HAVE_SOCKET 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDARG_H 1 - -/* Define to 1 if you have the header file. */ -#ifndef _MSC_VER -#define HAVE_STDINT_H 1 -#endif - -/* Define to 1 if you have the header file. */ -#define HAVE_STDIO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strerror' function. */ -#define HAVE_STRERROR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `system' function. */ -#define HAVE_SYSTEM 1 - -/* Define to 1 if you have the header file. */ -#ifndef _MSC_VER -#define HAVE_SYS_FILE_H 1 -#endif - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#ifndef _MSC_VER -#define HAVE_SYS_TIME_H 1 -#endif - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the `time' function. */ -#define HAVE_TIME 1 - -/* Define to 1 if you have the header file. */ -#ifndef _MSC_VER -#define HAVE_UNISTD_H 1 -#endif - -/* Define to 1 if you have the `vsnprintf' function. */ -#define HAVE_VSNPRINTF 1 - -/* Special Windows version of getpass() defined in io.c */ -#define HAVE_GETPASS 1 - -/* Name of package */ -#define PACKAGE @PACKAGE@ - -/* Define to the address where bug reports for this package should be sent. */ -//#define PACKAGE_BUGREPORT "openvpn-users@lists.sourceforge.net" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME @PACKAGE_NAME@ - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME @PACKAGE_TARNAME@ - -/* Define to the version of this package. */ -#define PACKAGE_VERSION @PACKAGE_VERSION@ - -/* Define to the full name and version of this package. */ -#ifdef DEBUG_LABEL -#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION " " DEBUG_LABEL -#else -#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION -#endif - -/* Define as the return type of signal handlers (`int' or `void'). */ -#define RETSIGTYPE void - -/* The size of a `unsigned int', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_INT 4 - -/* The size of a `unsigned long', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_LONG 4 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* A string representing our target */ -#ifdef _MSC_VER -#define TARGET_ALIAS "Win32-MSVC++" -#else -#define TARGET_ALIAS "Win32-MinGW" -#endif - -/* Define to 1 if you can safely include both and . */ -#ifndef _MSC_VER -#define TIME_WITH_SYS_TIME 1 -#endif - -/* Use OpenSSL crypto library */ -#define USE_CRYPTO 1 - -/* Use LZO compression library */ -#define USE_LZO 1 - -/* LZO version number */ -#define LZO_VERSION_NUM "2" - -/* Use lzo/ directory prefix for LZO header files (for LZO 2.0) */ -#define LZO_HEADER_DIR 1 - -/* Use OpenSSL SSL library */ -#define USE_SSL 1 - -/* Version number of package */ -#define VERSION PACKAGE_VERSION - -/* Define as `__inline' if that's what the C compiler calls it, or to nothing - if it is not supported. */ -#define inline __inline - -/* type to use in place of socklen_t if not defined */ -#define socklen_t unsigned int - -/* 32-bit unsigned type */ -#define uint32_t unsigned int - -/* 16-bit unsigned type */ -#define uint16_t unsigned short - -/* 8-bit unsigned type */ -#define uint8_t unsigned char - -/* Route command */ -#define ROUTE_PATH "route" - -/* Windows doesn't support PTHREAD yet */ -#ifdef USE_PTHREAD -#error The Windows version of OpenVPN does not support PTHREAD yet -#endif - -#ifdef _MSC_VER -/* MSVC++ hacks */ -#include -#include -#define vsnprintf _vsnprintf -#define vsnwprintf _vsnwprintf -#define snwprintf _snwprintf -#define write _write -#define open _open -#define read _read -#define close _close -#define chdir _chdir -#define S_IRUSR 0 -#define S_IWUSR 0 -typedef int intptr_t; -/* Visual Studio 2005 supports vararg macros */ -#if _MSC_VER >= 1400 -#define HAVE_CPP_VARARG_MACRO_ISO 1 -#endif -#endif diff --git a/configure.ac b/configure.ac index 116ff7c..4f7231a 100644 --- a/configure.ac +++ b/configure.ac @@ -914,7 +914,6 @@ fi AC_OUTPUT([ Makefile openvpn.spec - config-win32.h images/Makefile service-win32/Makefile install-win32/Makefile diff --git a/crypto.c b/crypto.c index 444f036..55cca43 100644 --- a/crypto.c +++ b/crypto.c @@ -985,8 +985,8 @@ get_tls_handshake_key (const struct key_type *key_type, #endif /* header and footer for static key file */ -static const char static_key_head[] = "-----BEGIN " PACKAGE_NAME " Static key V1-----"; -static const char static_key_foot[] = "-----END " PACKAGE_NAME " Static key V1-----"; +static const char static_key_head[] = "-----BEGIN OpenVPN Static key V1-----"; +static const char static_key_foot[] = "-----END OpenVPN Static key V1-----"; static const char printable_char_fmt[] = "Non-Hex character ('%c') found at line %d in key file '%s' (%d/%d/%d bytes found/min/max)"; @@ -1065,8 +1065,8 @@ read_key_file (struct key2 *key2, const char *file, const unsigned int flags) const unsigned char c = *cp; #if 0 - msg (M_INFO, "char='%c' s=%d ln=%d li=%d m=%d c=%d", - c, state, line_num, line_index, match, count); + msg (M_INFO, "char='%c'[%d] s=%d ln=%d li=%d m=%d c=%d", + c, (int)c, state, line_num, line_index, match, count); #endif if (c == '\n') @@ -1150,7 +1150,7 @@ read_key_file (struct key2 *key2, const char *file, const unsigned int flags) if (flags & RKF_MUST_SUCCEED) { if (!key2->n) - msg (M_FATAL, "Insufficient key material or header text not found found in file '%s' (%d/%d/%d bytes found/min/max)", + msg (M_FATAL, "Insufficient key material or header text not found in file '%s' (%d/%d/%d bytes found/min/max)", error_filename, count, onekeylen, keylen); if (state != PARSE_FINISHED) @@ -1297,7 +1297,7 @@ write_key_file (const int nkeys, const char *filename) buf_printf (&out, "%s\n", static_key_foot); /* write number of bits */ - buf_printf (&nbits_head_text, "#\n# %d bit " PACKAGE_NAME " static key\n#\n", nbits); + buf_printf (&nbits_head_text, "#\n# %d bit OpenVPN static key\n#\n", nbits); buf_write_string_file (&nbits_head_text, filename, fd); /* write key file, now formatted in out, to file */ diff --git a/makefile.w32-vc b/makefile.w32-vc deleted file mode 100644 index addf9da..0000000 --- a/makefile.w32-vc +++ /dev/null @@ -1,186 +0,0 @@ -# This makefile builds the user-mode component -# of OpenVPN for WIN32 in the MSVC++ environment. -# -# Build Dependencies: -# OpenSSL (SSL/TLS/crypto library) -# LZO (real-time compression library) -# -# Targets: -# static -- link statically with OpenSSL -# dynamic -- link dynamically with OpenSSL -# -# Note that LZO is always linked statically. - -# Change these to point to your OpenSSL and LZO top-level -# directories. - -OPENSSL = \src\openssl-0.9.7d -OPENSSL_STATIC = libeay32s.lib ssleay32s.lib -#OPENSSL_STATIC = libeay32sd.lib ssleay32sd.lib -OPENSSL_DYNAMIC = libeay32.lib ssleay32.lib -#OPENSSL_DYNAMIC = libeay32d.lib ssleay32d.lib - -LZO = \src\lzo-1.08.vc - -PKCS11_HELPER = \src\pkcs11-helper-1.02 - -INCLUDE_DIRS = -I$(OPENSSL)/include -I$(LZO)/include -I$(PKCS11_HELPER)/include - -LIBS = lzo.lib libpkcs11-helper-1.lib ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib - -LIB_DIRS = -LIBPATH:$(OPENSSL)\out -LIBPATH:$(LZO) -LIBPATH:$(PKCS11_HELPER)\lib - -EXE = openvpn.exe - -CPP=cl.exe -CPP_ARG_COMMON=/nologo /W3 /G5 /O2 -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CONSOLE -D_MBCS -D_CRT_SECURE_NO_DEPRECATE $(INCLUDE_DIRS) /FD /c -# release: -CPP_PROJ=$(CPP_ARG_COMMON) /MD -DNDEBUG -# debug: -#CPP_PROJ=$(CPP_ARG_COMMON) /MDd /Zi /Od -D_DEBUG - -LINK32=link.exe -# release: -LINK32_FLAGS=/nologo /subsystem:console /incremental:no /out:"$(EXE)" -# debug: -#LINK32_FLAGS=/nologo /subsystem:console /incremental:no /debug /out:"$(EXE)" - -# Make sure the HEADERS and OBJS definitions below match the same -# definitions in makefile.w32. - -HEADERS = \ - base64.h \ - basic.h \ - buffer.h \ - circ_list.h common.h \ - tap-win32/common.h \ - config-win32.h \ - crypto.h \ - cryptoapi.h \ - errlevel.h \ - error.h \ - event.h \ - fdmisc.h \ - forward-inline.h \ - forward.h \ - fragment.h \ - gremlin.h \ - helper.h \ - init.h \ - integer.h \ - interval.h \ - list.h \ - lzo.h \ - manage.h \ - mbuf.h \ - memdbg.h \ - misc.h \ - mroute.h \ - mss.h \ - mtcp.h \ - mtu.h \ - mudp.h \ - multi.h \ - ntlm.h \ - occ-inline.h \ - occ.h \ - pkcs11.h \ - openvpn.h \ - openvpn-plugin.h \ - options.h \ - otime.h \ - packet_id.h \ - perf.h \ - ping-inline.h \ - ping.h \ - plugin.h \ - pool.h \ - proto.h \ - proxy.h \ - push.h \ - reliable.h \ - route.h \ - schedule.h \ - session_id.h \ - shaper.h \ - sig.h \ - socket.h \ - socks.h \ - ssl.h \ - status.h \ - syshead.h \ - thread.h \ - tun.h \ - lladdr.h \ - win32.h - -OBJS = base64.obj \ - buffer.obj \ - crypto.obj \ - cryptoapi.obj \ - error.obj \ - event.obj \ - fdmisc.obj \ - forward.obj \ - fragment.obj \ - gremlin.obj \ - helper.obj \ - init.obj \ - interval.obj \ - list.obj \ - lzo.obj \ - manage.obj \ - mbuf.obj \ - misc.obj \ - mroute.obj \ - mss.obj \ - mtcp.obj \ - mtu.obj \ - mudp.obj \ - multi.obj \ - ntlm.obj \ - occ.obj \ - pkcs11.obj \ - openvpn.obj \ - options.obj \ - otime.obj \ - packet_id.obj \ - perf.obj \ - ping.obj \ - plugin.obj \ - pool.obj \ - proto.obj \ - proxy.obj \ - push.obj \ - reliable.obj \ - route.obj \ - schedule.obj \ - session_id.obj \ - shaper.obj \ - sig.obj \ - socket.obj \ - socks.obj \ - ssl.obj \ - status.obj \ - thread.obj \ - tun.obj \ - lladdr.obj \ - win32.obj - -dynamic : $(OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LIB_DIRS) $(LIBS) $(OPENSSL_DYNAMIC) $(OBJS) -<< - -static : $(OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LIB_DIRS) $(LIBS) $(OPENSSL_STATIC) $(OBJS) -<< - -clean : - del /Q $(OBJS) $(EXE) *.idb *.pdb - -.c.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< diff --git a/manage.c b/manage.c index e87d996..bd88c11 100644 --- a/manage.c +++ b/manage.c @@ -225,7 +225,7 @@ man_prompt (struct management *man) man_output_list_push (man, "ENTER PASSWORD:"); #if 0 /* should we use prompt? */ else - man_output_list_push (man, PACKAGE_NAME ">"); + man_output_list_push (man, ">"); #endif } diff --git a/misc.c b/misc.c index 33e6762..b52a042 100644 --- a/misc.c +++ b/misc.c @@ -1194,7 +1194,7 @@ create_temp_filename (const char *directory, const char *prefix, struct gc_arena const char * hostname_randomize(const char *hostname, struct gc_arena *gc) { - const int n_rnd_bytes = 6; +# define n_rnd_bytes 6 char *hst = string_alloc(hostname, gc); char *dot = strchr(hst, '.'); @@ -1213,6 +1213,7 @@ hostname_randomize(const char *hostname, struct gc_arena *gc) } else return hostname; +# undef n_rnd_bytes } #else diff --git a/msvc/autodefs.h.in b/msvc/autodefs.h.in new file mode 100644 index 0000000..9814022 --- /dev/null +++ b/msvc/autodefs.h.in @@ -0,0 +1,20 @@ +/* + * Minimum TAP-Win32 version number expected by userspace + * + * The TAP-Win32 version number is defined in tap-win32/SOURCES + */ +#define TAP_ID "@PRODUCT_TAP_ID@" +#define TAP_WIN32_MIN_MAJOR @PRODUCT_TAP_WIN32_MIN_MAJOR@ +#define TAP_WIN32_MIN_MINOR @PRODUCT_TAP_WIN32_MIN_MINOR@ + +/* Name of package */ +#define PACKAGE "@PRODUCT_UNIX_NAME@" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "@PRODUCT_NAME@" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "@PRODUCT_UNIX_NAME@" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "@PRODUCT_VERSION@" diff --git a/msvc/config.py b/msvc/config.py new file mode 100644 index 0000000..04ea4c5 --- /dev/null +++ b/msvc/config.py @@ -0,0 +1,93 @@ +# build autodefs.h and + +import re + +autogen = "Automatically generated by config.py" + +def parse_version_m4(kv, version_m4): + r = re.compile(r'^define\((\w+),\[(.*)\]\)$') + f = open(version_m4) + for line in f: + line = line.rstrip() + m = re.match(r, line) + if m: + g = m.groups() + kv[g[0]] = g[1] + f.close() + +def parse_settings_in(kv, settings_in): + r = re.compile(r'^!define\s+(\w+)(?:\s+"?(.*?)"?)$') + f = open(settings_in) + for line in f: + line = line.rstrip() + m = re.match(r, line) + if m: + g = m.groups() + kv[g[0]] = g[1] or '' + f.close() + +def build_autodefs(kv, autodefs_in, autodefs_out): + def repfn(m): + var, = m.groups() + return kv.get(var, '') + + r = re.compile(r'@(\w+)@') + fin = open(autodefs_in) + fout = open(autodefs_out, 'w') + fout.write("/* %s */\n\n" % autogen) + for line in fin: + newline = re.sub(r, repfn, line) + fout.write(newline) + fin.close() + fout.close() + +def print_key_values(kv): + for k, v in sorted(kv.items()): + print "%s%s%s" % (k, ' '*(32-len(k)), repr(v)) + +def get_sources(makefile_am): + c = set() + h = set() + f = open(makefile_am) + state = False + for line in f: + line = line.rstrip() + if line == 'openvpn_SOURCES = \\': + state = True + elif not line: + state = False + elif state: + for sf in line.split(): + if sf.endswith('.c'): + c.add(sf[:-2]) + elif sf.endswith('.h'): + h.add(sf[:-2]) + elif sf == '\\': + pass + else: + print >>sys.stderr, "Unrecognized filename:", sf + f.close() + return [ sorted(list(s)) for s in (c, h) ] + +def output_mak_list(out, title, srclist, ext): + out.write("%s =" % (title,)) + for x in srclist: + out.write(" \\\n\t%s.%s" % (x, ext)) + out.write('\n\n') + +def output_mak(makefile_am, outfile): + c, h = get_sources(makefile_am) + out = open(outfile, 'w') + out.write("# %s\n\n" % autogen) + output_mak_list(out, 'HEADERS', h, 'h') + output_mak_list(out, 'OBJS', c, 'obj') + out.close() + +def main(): + kv = {} + parse_version_m4(kv, 'version.m4') + parse_settings_in(kv, 'install-win32/settings.in') + build_autodefs(kv, 'msvc/autodefs.h.in', 'autodefs.h') + output_mak('Makefile.am', 'head_obj.mak') + +main() diff --git a/msvc/msvc.mak b/msvc/msvc.mak new file mode 100644 index 0000000..bca779f --- /dev/null +++ b/msvc/msvc.mak @@ -0,0 +1,52 @@ +# This makefile builds the user-mode component +# of OpenVPN for Windows in the Visual Studio 2008 environment. + +# To build: +# python msvc\config.py +# nmake /f msvc\msvc.mak + +# Each of the OPENSSL and LZO dirs should have 'lib' and 'include' +# directories under them. + +OPENSSL = \src\openssl +OPENSSL_DYNAMIC = libeay32.lib ssleay32.lib + +LZO = \src\lzo +LZO_DYNAMIC = lzo2.lib + +INCLUDE_DIRS = -I$(OPENSSL)/include -I$(LZO)/include + +LIBS = $(OPENSSL_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib + +LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(LZO)\lib + +EXE = openvpn.exe + +CPP=cl.exe +CPP_ARG_COMMON=/nologo /W3 /O2 -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CONSOLE -D_MBCS -D_CRT_SECURE_NO_DEPRECATE $(INCLUDE_DIRS) /FD /c +# release: +CPP_PROJ=$(CPP_ARG_COMMON) /MD -DNDEBUG +# debug: +#CPP_PROJ=$(CPP_ARG_COMMON) /MDd /Zi /Od -D_DEBUG + +LINK32=link.exe +# release: +LINK32_FLAGS=/nologo /subsystem:console /incremental:no /out:"$(EXE)" +# debug: +#LINK32_FLAGS=/nologo /subsystem:console /incremental:no /debug /out:"$(EXE)" + +# HEADERS and OBJS definitions, automatically generated +!INCLUDE head_obj.mak + +openvpn : $(OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LIB_DIRS) $(LIBS) $(OBJS) +<< + +clean : + del /Q $(OBJS) $(EXE) *.idb *.pdb + +.c.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< diff --git a/multi.c b/multi.c index 342871a..2b04428 100644 --- a/multi.c +++ b/multi.c @@ -721,7 +721,7 @@ multi_print_status (struct multi_context *m, struct status_output *so, const int /* * Status file version 1 */ - status_printf (so, PACKAGE_NAME " CLIENT LIST"); + status_printf (so, "OpenVPN CLIENT LIST"); status_printf (so, "Updated,%s", time_string (0, 0, false, &gc_top)); status_printf (so, "Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since"); hash_iterator_init (m->hash, &hi, true); diff --git a/sig.c b/sig.c index 4dd6b09..b7a3508 100644 --- a/sig.c +++ b/sig.c @@ -257,7 +257,7 @@ print_status (const struct context *c, struct status_output *so) status_reset (so); - status_printf (so, PACKAGE_NAME " STATISTICS"); + status_printf (so, "OpenVPN STATISTICS"); status_printf (so, "Updated,%s", time_string (0, 0, false, &gc)); status_printf (so, "TUN/TAP read bytes," counter_format, c->c2.tun_read_bytes); status_printf (so, "TUN/TAP write bytes," counter_format, c->c2.tun_write_bytes); diff --git a/tun.c b/tun.c index d82ac49..725dce4 100644 --- a/tun.c +++ b/tun.c @@ -55,7 +55,7 @@ static void netsh_ifconfig (const struct tuntap_options *to, const char *flex_name, const in_addr_t ip, const in_addr_t netmask, - unsigned int flags); + const unsigned int flags); static const char *netsh_get_id (const char *dev_node, struct gc_arena *gc); diff --git a/version.m4 b/version.m4 index 826720b..0877b9c 100644 --- a/version.m4 +++ b/version.m4 @@ -1,5 +1,5 @@ dnl define the OpenVPN version -define(PRODUCT_VERSION,[2.1.1d]) +define(PRODUCT_VERSION,[2.1.1e]) dnl define the TAP version define(PRODUCT_TAP_ID,[tap0901]) define(PRODUCT_TAP_WIN32_MIN_MAJOR,[9]) -- cgit v1.2.3