现在的位置: 首页 > 综合 > 正文

在Windows下编译OpenVPN源码(原创)

2012年09月15日 ⁄ 综合 ⁄ 共 22346字 ⁄ 字号 评论关闭

    最近闲来无事,把OpenVPN在Windows下的编译过程写出来,废话不多说,下面就是编译过程:

 

在Windows下编译OpenVPN-2.2-beta5的步骤:

(1). 需要的软件包

 ActivePerl-5.8.8.822-MSWin32-x86-280952.zip (安装openssl需要)
 lzo-2.03.tar.gz (打包用的)
 openssl-0.9.8g.tar.gz (加解密用的)
 pkcs11-helper-1.07.tar.bz2 (用于证书,数字签名之类的)
 openvpn-2.2-beta5.zip (OpenVPN源码包)
 windows sdk (特定平台的开发包)
 
  软件的开发平台: windows XP SP3
  编辑,编译环境:VC6
 
(2). 解压,安装ActivePerl-5.8.8.822,安装后可测试一下perl命令是否可用。

(3). 生成openssl库
   a) 解压openssl-0.9.8g.tar.gz到C盘下.
  
   b)进入openssl目录
  
      C:/>cd openssl-0.9.8g

    c) C:/openssl-0.9.8g>perl Configure VC-WIN32
   
    d) 运行VCVARS32.BAT,设置编译环境
    
       C:/openssl-0.9.8g>D:
       D:/>cd D:/Microsoft Visual Studio/VC98/Bin
       D:/Microsoft Visual Studio/VC98/Bin>VCVARS32.BAT
      
       如过不出啥错的话,环境应该已经设置好了。
       注:D:/Microsoft Visual Studio/VC98/Bin是我VC6安装的位置,你应该将其替换为自己安装的位置。
      
    e)重新切换回C:/openssl-0.9.8g,然后使用命令:
      
      C:/openssl-0.9.8g>ms/do_masm.bat
     
    f)生成库,使用命令:
      C:/openssl-0.9.8g>nmake -f ms/ntdll.mak
     
      当这个命令执行完成后,会在C:/openssl-0.9.8g目录下生成:out32dll, tmp32dll, inc32三个目录。
      out32dll:是存储的是生成的动态,静态库,后面生成openvpn时候需要这些库支持(libeay32.dll libeay32.lib ssleay32.dll和 ssleay32.lib)
      tmp32dll:是存储的是编译过程中生成的目标文件
      inc32:   是头文件哈,在开发的时候需要包含的openssl的头文件所在的目录
   
    g)测试库是否正确,执行命令:
      C:/openssl-0.9.8g>nmake -f ms/ntdll.mak test
     
      当看到"passed all tests" 出现时,就说明我们生成的库是正确的。
   
(4). 生成lzo库
    a) 将lzo-2.03.tar.gz解压在c盘下,然后进入该目录:
       
       C:/lzo-2.03>
      
    b) 执行如下命令:
       C:/lzo-2.03>b/win32/vc.bat
      
       命令成功执行后会在C:/lzo-2.03目录下生成lzo2.lib库(后面编译openvpn时会用到该库)。

(5). 编译pkcs11-helper-1.07
   a) 将pkcs11-helper-1.07.tar.bz2解压到c盘下,然后进入该目下的lib目录:
     C:/pkcs11-helper-1.07/lib>
    
   b) 然后执行命令(nmake -f Makefile.w32-vc OPENSSL=1 OPENSSL_HOME=c:/openssl-0.9.8g),见如下:
      C:/pkcs11-helper-1.07/lib>nmake -f Makefile.w32-vc OPENSSL=1 OPENSSL_HOME=C:/openssl-0.9.8g
     
      //命令执行后,出现如下错误:
      /-------------------------------------------------------------------------------------------------/
      C:/pkcs11-helper-1.07/lib>nmake -f Makefile.w32-vc OPENSSL=1 OPENSSL_HOME=C:/openssl-0.9.8g

    Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
    Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

        cl.exe @C:/DOCUME~1/qq/LOCALS~1/Temp/nma00972.
    pkcs11h-threading.c
    pkcs11h-threading.c(477) : error C2036: 'void *' : unknown size
    NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
    Stop.
    /-------------------------------------------------------------------------------------------------/
    
    //根据上面的出错提示:打开C:/pkcs11-helper-1.07/lib/pkcs11h-threading.c文件。
    //找到477行,发现如下代码:
    
         ret = (unsigned)(_data->start (_data->data) - (void*)0);
        
    //从上面的代码可以看出,在对void类型进行加减运算,这在c/c++中是不允许的。
    //上面的命令说不知道'void *'的大小,其实,是类型单位大小未知,因为C/C++不允许对一个指向未知
        //尺寸类型(unknown size)的指针进行直接运算。void* 和void都属于未知大小类型.
        //另外,在这里减去的是(void*)0,因为任何数减0等于本身,所以可以直接将:
       
        ret = (unsigned)(_data->start (_data->data) - (void*)0);
   
        修改成:
       
        ret = (unsigned)(_data->start (_data->data));
       
        //想不清楚为什么会减去一个0,也许有作者的道理。。。。
       
    c) 修改后继续执行上面的命令,执行完后,出现如下错误:
       /-------------------------------------------------------------------------------------------------/
       C:/pkcs11-helper-1.07/lib>nmake -f Makefile.w32-vc OPENSSL=1 OPENSSL_HOME=C:/openssl-0.9.8g

     Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
     Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

          cl.exe @C:/DOCUME~1/qq/LOCALS~1/Temp/nma03272.
     pkcs11h-threading.c
         link.exe @C:/DOCUME~1/qq/LOCALS~1/Temp/nmb03272.
     LINK : fatal error LNK1181: cannot open input file "libeay32.lib"
     NMAKE : fatal error U1077: 'link.exe' : return code '0x49d'
     Stop.
    /-------------------------------------------------------------------------------------------------/

       //这个问题好解决,就是找不到库"libeay32.lib"的位置嘛。
       //好,我们修改C:/pkcs11-helper-1.07/lib/Makefile.w32-vc文件,以使其找到正确的位置。
      
       我们将:
    !ifdef OPENSSL
    OPENSSL_STATIC = libeay32.lib
    #OPENSSL_STATIC = libeay32sd.lib
    OPENSSL_DYNAMIC = libeay32.lib
    #OPENSSL_DYNAMIC = libeay32d.lib
    
    修改为:
    
    !ifdef OPENSSL
     OPENSSL_STATIC = C://openssl-0.9.8g//out32dll//libeay32.lib
    #OPENSSL_STATIC = libeay32sd.lib
    OPENSSL_DYNAMIC = C://openssl-0.9.8g//out32dll//libeay32.lib
    #OPENSSL_DYNAMIC = libeay32d.lib
    
    //这里我使用的是绝对路径。
    
  d)再次执行nmake -f Makefile.w32-vc OPENSSL=1 OPENSSL_HOME=C:/openssl-0.9.8g命令,出现:
    /----------------------------------------------------------------------------------------------/
   Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
     Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

        link.exe @C:/DOCUME~1/qq/LOCALS~1/Temp/nma04168.
     Creating library libpkcs11-helper-1.lib and object libpkcs11-helper-1.exp
        move libpkcs11-helper-1.lib pkcs11-helper.dll.lib
        lib.exe @C:/DOCUME~1/qq/LOCALS~1/Temp/nmb04168.
     /----------------------------------------------------------------------------------------------/
       
     //这下生成成功了。在C:/pkcs11-helper-1.07/lib下生成了libpkcs11-helper-1.dll和pkcs11-helper.lib
    
(6)安装sdk,具体过程这就不用说了。只说说安装后的情况。
  当sdk安装完成后,执行Register PSDK Directories with Visual Studio就会在系统中注册。
  同时,也会在开发环境(如:VC6)的:工具-->选项-->目录-->Includes files,Library files中注册头
  文件和库的位置。

(7)编译openvpn的先决条件现在都已准备完成,这下可以编译openvpn-2.2-beta5了。

 a) 打开vc6,新建一个工程:
   工程名:OpenVPN2_2_beta5
   工程的类型:Win32 Console Application
   工程的位置:D:/Microsoft Visual Studio/MyProjects/OpenVPN2_2_beta5
   选择创建一个新的工作空间
   平台选择:win32
   控制台类型选择创建一个空的工程(这样利于排错)
  
   然后点击"完成"就是了。
  
 b) 复制openvpn-2.2-beta5.zip到D:/Microsoft Visual Studio/MyProjects/OpenVPN2_2_beta5目录下,
   然后将该压缩文件解压到当前目录下。解压后生成的openvpn-2.2-beta5文件夹下就是我能需要编译的
   OpenVPN源码。
  
   我们将openvpn-2.2-beta5文件名修改为code。
  
 c) 回到工程中,我们将code这个文件夹下的所有文件都添加到工程中。
   
    在开始编译前,我们将OpenVPN需要的头文件和库的位置给设定好。
   
    在:工具-->选项-->目录-->Includes files中添加:
       C:/OPENSSL-0.9.8G/INC32
       C:/LZO-2.03/INCLUDE
       C:/PKCS11-HELPER-1.07/INCLUDE
      
    在:工具-->选项-->目录-->Library files中
       C:/OPENSSL-0.9.8G/OUT32DLL
       C:/LZO-2.03
       C:/PKCS11-HELPER-1.07/LIB
      
    在:工程-->设置-->连接选项的'分类'中选择'输入',然后在'对象/库模块'下加入如下库名:
       pkcs11-helper.lib libeay32.lib ssleay32.lib lzo2.lib
       Wininet.lib Ws2_32.lib Iphlpapi.lib crypt32.lib
      
    在:工程-->设置-->C/C++选项的'分类'中选择'Code Generation',在Use run-time library中
        选择'Debug Multithreaded DLL'
      
    openssl, lzo, pksc11我们在上面都已经编译并生成了相应的库文件,我们在这里将其头文件和库文件
    包含到我们工程中就是了。
   
    当然,也可以创建新的头文件夹和库文件夹,并将这些头文件和库文件放到里面去,然后设置路径也可以。
    在这里,我们只是直接设置就可以了。
   
 d) 然后开始编译,组建工程。
    编译后出现如下错误:
   
    /--------------------------------------------------------------------------------------------------------------------------------------------------------------------/
    Compiling...
   base64.c
   d:/microsoft visual studio/myprojects/openvpn2_2_beta5/code/syshead.h(33) : fatal error C1083: Cannot open include file: 'config-win32.h': No such file or directory
   /--------------------------------------------------------------------------------------------------------------------------------------------------------------------/
  
   我在code目录下搜索了一下,确实没有发现config-win32.h这个文件。
   从文件名可以看出,这是一个在windows平台编译openvpn的配置文件而已(这个文件可能从某个脚本去产生,看看源码目录下,也没发现tool目录以及工具)。
   哎,对openvpn的配置文件又不清楚它到底要配置些啥选项(没那么深的研究),到网上搜搜也没发现有类似的错误(也许是新版本的缘故)。
   现在只有到低版本的openvpn源码中去看看是否有这个文件。不出所料,我在低版本的OpenVPN中发现了有这个文件,然后将这个文件作了修改。
   然后将该修改过的文件拷贝一份放到我们的code目录下,然后将其添加入工程。
  
   注:修改过后的文件我放在最后面了,如果要用该配置文件的话,可以拷贝一份,然后重命名为config-win32.h,然后将其放在code目录下就是了。
  
   在编译的过程中我又发现了其他的错误,我都将需要改变的地方写在下面了,如果将发现过程写出来就有点啰嗦了,所以我讲需要修改的地方写在下面:
  
    /-------------------------------------------------------------------------------------/
    将:code/tap-win32/common.h中的(注意:不要和code目录下的common.h文件混淆哈....)
   
    #include "autodefs.h"
   修改为:
   #define PRODUCT_TAP_ID "tap0901"
  
   "tap0901"这个是设备名而已。
  
   将:
   #define TAP_COMPONENT_ID TAP_ID
  
   修改为:
  
   #define TAP_COMPONENT_ID PRODUCT_TAP_ID
   /-------------------------------------------------------------------------------------/
  
   /-----------------------------------------------/
   将:code/common.h中
   typedef unsigned long long int counter_type;
   修改为:
   typedef unsigned __int64 counter_type;
   /-----------------------------------------------/
  
   /----------------------------------------------------------------------------------------------/
   将:code/options.c中的#include "configure.h"给注释掉,因为编译中发现根本不需要改文件。
   /----------------------------------------------------------------------------------------------/
  
   /-----------------------------------------------------------------------------------------------------------------------------/
   将:code/buffer.c中
  
   size_t
   array_mult_safe (const size_t m1, const size_t m2, const size_t extra)
   {
     const size_t limit = 0xFFFFFFFF;
     unsigned long long res = (unsigned long long)m1 * (unsigned long long)m2 + (unsigned long long)extra;
     if (unlikely(m1 > limit) || unlikely(m2 > limit) || unlikely(extra > limit) || unlikely(res > (unsigned long long)limit))
        msg (M_FATAL, "attemped allocation of excessively large array");
     return (size_t) res;
   }
  
   修改为:
   size_t
   array_mult_safe (const size_t m1, const size_t m2, const size_t extra)
   {
     const size_t limit = 0xFFFFFFFF;
     unsigned __int64 res = (unsigned __int64)m1 * (unsigned __int64)m2 + (unsigned __int64)extra;
     if (unlikely(m1 > limit) || unlikely(m2 > limit) || unlikely(extra > limit) || unlikely(res > (unsigned __int64)limit))
        msg (M_FATAL, "attemped allocation of excessively large array");
     return (size_t) res;
   }
  
   因为在VC6中编译器不认识long long这种表述64位的数据类型,要修改成__int64就成了。
   /-----------------------------------------------------------------------------------------------------------------------------/
  
   好了,现在重新编译一下,如果不出啥问题的话,OpenVPN2_2_beta5.exe应该在目录OpenVPN2_2_beta5/Debug下生成了。
  
   但是我们需要注意的是:在结尾出现了一个警告,显示如下:
   /------------------------------------------------------------------------------------------------------/
   Linking...
    LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
   /------------------------------------------------------------------------------------------------------/
    
     这是库的冲突问题而引起的警告,因为我们使用的是Debug版的'DLL的多线程'来编译该程序,所以我们作如下修改:
    
     在:工程-->设置-->'连接'选项的'分类'中选择'输入',然后在'忽略库'下加入如下库名:
         libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib (注意哈,库名与库名之间用逗号隔开,不要用空格哈..)
        
     再次重新编译,链接冲突的警告没了,好了,下面我们开始测试我们所生成的EXE文件了。
  
(8) 测试
    在开始测试前:我们需要自己将OpenVPN的服务端搭建好。
    服务端最好是与我们测试的客户端是同一个版本的。
    另外:在OpenVPN中客户端和服务端的区别是依靠配置文件中的选项来区别的。
          配置文件的例子文件在源码目录的sample-config-files文件夹下,在该目录下,我们可以看到有:
          client.conf, server.conf这样的客户端,服务端的配置文件样例。
          我们可以修改这些文件来符合我们的需求。
   
     
  a) 在'开始'-->'运行'中输入cmd, 打开控制台
  
  b) 然后转到D:/Microsoft Visual Studio/MyProjects/OpenVPN2_2_beta5/Debug目录下:
     D:/Microsoft Visual Studio/MyProjects/OpenVPN2_2_beta5/Debug>

  c) 因为我们在程序中使用了动态库,所以,我们将libeay32.dll和ssleay32.dll拷贝到D:/Microsoft Visual Studio/MyProjects/OpenVPN2_2_beta5/Debug目录下。
  
  d) 执行命令:
    D:/Microsoft Visual Studio/MyProjects/OpenVPN2_2_beta5/Debug>OpenVPN2_2_beta5.exe --help | more
   
    出现了如下提示
    /---------------------------------------------------------------------------------------------------/
    D:/Microsoft Visual Studio/MyProjects/OpenVPN2_2_beta5/Debug>OpenVPN2_2_beta5.exe --help | more
    OpenVPN 2.2-beta5 Win32-MSVC++ [SSL] [LZO2] [PKCS11] built on Jan 13 2011

    General Options:
    --config file   : Read configuration options from file.
     --help          : Show options.
    --version       : Show copyright and version information.
   
    .....(省略了)
    /---------------------------------------------------------------------------------------------------/
   
    从上面的提示可知,我们可以使用配置文件的方式来运行该OpenVPN2_2_beta5.exe
   
  e) 继续执行命令:
     D:/Microsoft Visual Studio/MyProjects/OpenVPN2_2_beta5/Debug>OpenVPN2_2_beta5.exe --config C:/config/client.ovpn
    
     C:/config/client.ovpn下的这个文件是我用来链接OpenVPN服务器的配置文件。
    
     /----------------------------------------------------------------------------------------------------------------------------/
    Thu Jan 13 14:59:13 2011 OPTIONS IMPORT: timers and/or timeouts modified
    Thu Jan 13 14:59:13 2011 OPTIONS IMPORT: --ifconfig/up options modified
    Thu Jan 13 14:59:13 2011 OPTIONS IMPORT: route-related options modified
    Thu Jan 13 14:59:13 2011 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
    Thu Jan 13 14:59:13 2011 There are no TAP-Win32 adapters on this system.  You should be able to create a TAP-Win32 adapter
    OpenVPN -> Add a new TAP-Win32 virtual ethernet adapter.
    Thu Jan 13 14:59:13 2011 Exiting
     /----------------------------------------------------------------------------------------------------------------------------/
    
     从上面的错误提示:
     Thu Jan 13 14:59:13 2011 There are no TAP-Win32 adapters on this system.  You should be able to create a TAP-Win32 adapter
       OpenVPN -> Add a new TAP-Win32 virtual ethernet adapter.
      
       我们知道我们缺少了'TAP-Win32 adapters'在我们的系统上。于是我使用命令:OpenVPN2_2_beta5.exe --help | more想找出生成这个设备
       的方法,很不幸,没这个方法。
      
       还好,从上面的提示:You should be able to create a TAP-Win32 adapter OpenVPN -> Add a new TAP-Win32 virtual ethernet adapter.
       我猜测可能是官网上有生成这个设备的工具和相应的驱动程序,于是我找到了原来我从官网上下载的Windows下openvpn-2.2-beta3-install.exe,
       这个文件OpenVPN的安装文件,我已经将它安装在公司的一个电脑系统上,所以直接转到那台电脑的C:/Program Files/OpenVPN目录下查看,
       果然发现了,在bin目录下有addtap.bat和deltapall.bat的批处理文件,并且也发现了驱动程序(在driver目录下)。
      
       这下好了,我直接拷贝bin目录和driver目录到我的电脑上,并将其安排在相应的位置(我是放在C:/Program Files/OpenVPN目录下的,因为批处理
       上的就是这个目录,我也懒得改了)。
      
       然后执行bin目录下的addtap.bat批处理文件就行了。这样会在我们的电脑上生成一个名叫:TAP-Win32 Adapter V9的网络适配器。
      
       注意:如果是像上面的直接拷贝的话,系统要相同,比如如果以前安装在Windows XP下的openvpn-2.2-beta3-install.exe,然后拷贝bin和driver到
           WIN7下是不能用的(因为环境改变了,导致以前与环境相关的都会出现错误)。所以最好的方式是直接用安装程序安装那个虚拟网卡驱动到我们的系统上。
      
    d) 生成了TAP-Win32 Adapter V9后,我们重复前面的命令:
       D:/Microsoft Visual Studio/MyProjects/OpenVPN2_2_beta5/Debug>OpenVPN2_2_beta5.exe --config C:/config/client.ovpn
      
       结果显示:
       /-----------------------------------------------------------------------------------------------------------------/
       ......
      
       Thu Jan 13 15:40:44 2011 Notified TAP-Win32 driver to set a DHCP IP/netmask of 10.8.0.2/255.255.255.0
    serv: 10.8.0.0, lease-time: 31536000]
    Thu Jan 13 15:40:44 2011 Successful ARP Flush on interface [131078] {3B94B347-B247-4EE8-BA7A-BB6FF0E1
    Thu Jan 13 15:40:49 2011 TEST ROUTES: 0/0 succeeded len=-1 ret=1 a=0 u/d=up
    Thu Jan 13 15:40:49 2011 Initialization Sequence Completed
    /-----------------------------------------------------------------------------------------------------------------/
   
    看到'set a DHCP IP/netmask of 10.8.0.2/255.255.255.0'和'Initialization Sequence Completed',就说明我们已经顺利的连接上服务器了。
    再用ipconfig /all命令查看,看到了:
      /---------------------------------------------------------------------/  
    Ethernet adapter 本地连接 4:

        Connection-specific DNS Suffix  . :
        Description . . . . . . . . . . . : TAP-Win32 Adapter V9
        Physical Address. . . . . . . . . : 00-FF-3B-94-B3-47
        Dhcp Enabled. . . . . . . . . . . : Yes
        Autoconfiguration Enabled . . . . : Yes
        IP Address. . . . . . . . . . . . : 10.8.0.2
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . :
        DHCP Server . . . . . . . . . . . : 10.8.0.0
        DNS Servers . . . . . . . . . . . : 61.139.2.69
        Lease Obtained. . . . . . . . . . : 2011年1月13日 15:40:46
        Lease Expires . . . . . . . . . . : 2012年1月13日 15:40:46
      /---------------------------------------------------------------------/
     
      没错,确实连上了,并且用ping命令ping一下网关10.8.0.1,ping成功。这样就足以证明我们生成的文件是成功的。

(9) 修改过后的config-win32.h文件
/*
 *  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-2005 OpenVPN Solutions LLC <info@openvpn.net>
 *
 *  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
 */

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
//#include "autodefs/defs.h"

//new code
#ifdef _MSC_VER
#define strcasecmp stricmp
#define strncasecmp strnicmp
#endif

#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_WIN32_MIN_MAJOR 9
#define TAP_WIN32_MIN_MINOR 1

/* 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 <openssl/engine.h> 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 <ctype.h> header file. */
#define HAVE_CTYPE_H 1

/* Define to 1 if you have the <errno.h> 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 <fcntl.h> 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 <stdarg.h> header file. */
#define HAVE_STDARG_H 1

/* Define to 1 if you have the <stdint.h> header file. */
#ifndef _MSC_VER
#define HAVE_STDINT_H 1
#endif

/* Define to 1 if you have the <stdio.h> header file. */
#define HAVE_STDIO_H 1

/* Define to 1 if you have the <stdlib.h> 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 <strings.h> header file. */
#define HAVE_STRINGS_H 1

/* Define to 1 if you have the <string.h> 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 <sys/file.h> header file. */
#ifndef _MSC_VER
#define HAVE_SYS_FILE_H 1
#endif

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/time.h> header file. */
#ifndef _MSC_VER
#define HAVE_SYS_TIME_H 1
#endif

/* Define to 1 if you have the <sys/types.h> 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 <unistd.h> 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 PRODUCT_UNIX_NAME
#define PACKAGE "openvpn"

/* 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 PRODUCT_NAME
#define PACKAGE_NAME "OpenVPN"

/* Define to the one symbol short name of this package. */
//#define PACKAGE_TARNAME PACKAGE
#define PACKAGE_TARNAME "openvpn"

/* Define to the version of this package. */
//#define PACKAGE_VERSION PRODUCT_VERSION
#define PACKAGE_VERSION "2.2-beta5"

/* Define to the full name and version of this package. */
#ifdef DEBUG_LABEL
//#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION " " DEBUG_LABEL
#define PACKAGE_STRING "OpenVPN " PACKAGE_VERSION " " DEBUG_LABEL
#else
//#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION
#define PACKAGE_STRING "OpenVPN " 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 <sys/time.h> and <time.h>. */
#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 <io.h>
#include <direct.h>
#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;
#undef S_NORMAL
#endif

抱歉!评论已关闭.