summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/anytun.suobin57856 -> 57856 bytes
-rw-r--r--src/anytun.vcproj8
-rw-r--r--src/deviceConfig.hpp4
-rw-r--r--src/win32/common.h14
-rw-r--r--src/win32/tunDevice.cpp27
5 files changed, 32 insertions, 21 deletions
diff --git a/src/anytun.suo b/src/anytun.suo
index 71a022b..41e43e0 100644
--- a/src/anytun.suo
+++ b/src/anytun.suo
Binary files differ
diff --git a/src/anytun.vcproj b/src/anytun.vcproj
index b576bd5..2f118c7 100644
--- a/src/anytun.vcproj
+++ b/src/anytun.vcproj
@@ -397,6 +397,14 @@
<File
RelativePath=".\options.cpp"
>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="ANYTUN_OPTIONS"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath=".\packetSource.cpp"
diff --git a/src/deviceConfig.hpp b/src/deviceConfig.hpp
index 3e6c912..3c3fd41 100644
--- a/src/deviceConfig.hpp
+++ b/src/deviceConfig.hpp
@@ -68,8 +68,8 @@ public:
else if(dev_type == "tap")
type_ = TYPE_TAP;
- if(type_ == TYPE_TUN && (ifcfg_lp == "" || ifcfg_rnmp == ""))
- throw std::runtime_error("Device type tun requires ifconfig parameters (--ifconfig)");
+ if(type_ == TYPE_TUN && ifcfg_addr == "")
+ throw std::runtime_error("Device type tun requires ifconfig parameter (--ifconfig)");
#endif
if(ifcfg_addr != "")
diff --git a/src/win32/common.h b/src/win32/common.h
index 39a8349..3c183c2 100644
--- a/src/win32/common.h
+++ b/src/win32/common.h
@@ -8,13 +8,12 @@
* Copyright (C) Damion K. Wilson, 2003, and is released under the
* GPL version 2 (see below).
*
- * All other source code is Copyright (C) James Yonan, 2003-2004,
+ * All other source code is Copyright (C) 2002-2005 OpenVPN Solutions LLC,
* and is released under the GPL version 2 (see below).
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * 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
@@ -40,6 +39,8 @@
#define TAP_CONTROL_CODE(request,method) \
CTL_CODE (FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS)
+// Present in 8.1
+
#define TAP_IOCTL_GET_MAC TAP_CONTROL_CODE (1, METHOD_BUFFERED)
#define TAP_IOCTL_GET_VERSION TAP_CONTROL_CODE (2, METHOD_BUFFERED)
#define TAP_IOCTL_GET_MTU TAP_CONTROL_CODE (3, METHOD_BUFFERED)
@@ -50,6 +51,11 @@
#define TAP_IOCTL_GET_LOG_LINE TAP_CONTROL_CODE (8, METHOD_BUFFERED)
#define TAP_IOCTL_CONFIG_DHCP_SET_OPT TAP_CONTROL_CODE (9, METHOD_BUFFERED)
+// Added in 8.2
+
+/* obsoletes TAP_IOCTL_CONFIG_POINT_TO_POINT */
+#define TAP_IOCTL_CONFIG_TUN TAP_CONTROL_CODE (10, METHOD_BUFFERED)
+
//=================
// Registry keys
//=================
diff --git a/src/win32/tunDevice.cpp b/src/win32/tunDevice.cpp
index 94fc657..850711d 100644
--- a/src/win32/tunDevice.cpp
+++ b/src/win32/tunDevice.cpp
@@ -43,9 +43,9 @@
#include "common.h"
#define MIN_TAP_VER_MAJOR 8
-#define MIN_TAP_VER_MINOR 1
+#define MIN_TAP_VER_MINOR 2
-TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifcfg_lp, std::string ifcfg_rnmp) : conf_(dev_name, dev_type, ifcfg_lp, ifcfg_rnmp, 1400)
+TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifcfg_addr, u_int16_t ifcfg_prefix) : conf_(dev_name, dev_type, ifcfg_addr, ifcfg_prefix, 1400)
{
if(conf_.type_ != TYPE_TUN && conf_.type_ != TYPE_TAP)
throw std::runtime_error("unable to recognize type of device (tun or tap)");
@@ -84,19 +84,20 @@ TunDevice::TunDevice(std::string dev_name, std::string dev_type, std::string ifc
}
if(conf_.type_ == TYPE_TUN) {
- u_long ep[2];
- ep[0] = htonl(conf_.local_.getNetworkAddressV4().to_ulong());
- ep[1] = htonl(conf_.remote_netmask_.getNetworkAddressV4().to_ulong());
- err = performIoControl(TAP_IOCTL_CONFIG_POINT_TO_POINT, ep, sizeof(ep), ep, sizeof(ep));
+ u_long ep[3];
+ ep[0] = htonl(conf_.addr_.getNetworkAddressV4().to_ulong());
+ ep[1] = htonl(conf_.addr_.getNetworkAddressV4().to_ulong() & conf_.netmask_.getNetworkAddressV4().to_ulong());
+ ep[2] = htonl(conf_.netmask_.getNetworkAddressV4().to_ulong());
+ err = performIoControl(TAP_IOCTL_CONFIG_TUN, ep, sizeof(ep), ep, sizeof(ep));
if(err != ERROR_SUCCESS) {
CloseHandle(handle_);
std::stringstream msg;
- msg << "Unable to set device point-to-point mode: " << LogErrno(err);
+ msg << "Unable to set device tun mode: " << LogErrno(err);
throw std::runtime_error(msg.str());
}
}
- if(ifcfg_lp != "" && ifcfg_rnmp != "")
+ if(ifcfg_addr != "")
do_ifconfig();
int status = true;
@@ -267,14 +268,10 @@ void TunDevice::init_post()
void TunDevice::do_ifconfig()
{
- u_long remote_netmask = conf_.remote_netmask_.getNetworkAddressV4().to_ulong();
- u_long adapter_mask = (conf_.type_ == TYPE_TUN) ? ~3 : remote_netmask;
- u_long local = conf_.local_.getNetworkAddressV4().to_ulong();
-
u_long ep[4];
- ep[0] = htonl(local);
- ep[1] = htonl(adapter_mask);
- ep[2] = (conf_.type_ == TYPE_TUN) ? htonl(remote_netmask) : htonl(local & adapter_mask);
+ ep[0] = htonl(conf_.addr_.getNetworkAddressV4().to_ulong());
+ ep[1] = htonl(conf_.netmask_.getNetworkAddressV4().to_ulong());
+ ep[2] = htonl(conf_.addr_.getNetworkAddressV4().to_ulong() & conf_.netmask_.getNetworkAddressV4().to_ulong());
ep[3] = 365 * 24 * 3600; // lease time in seconds
DWORD err = performIoControl(TAP_IOCTL_CONFIG_DHCP_MASQ, ep, sizeof(ep), ep, sizeof(ep));
if(err != ERROR_SUCCESS) {