summaryrefslogtreecommitdiff
path: root/osdep
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@zerotier.com>2015-04-25 15:22:43 -0700
committerAdam Ierymenko <adam.ierymenko@zerotier.com>2015-04-25 15:22:43 -0700
commit720ac93ba9067da6fcab8d7bc6ddf6a20497fe4d (patch)
treecc2399d01d583aa9b8824db0125100bc417eb646 /osdep
parent42b41488763b379aed8d078b6470b2d9f65bc181 (diff)
downloadinfinitytier-720ac93ba9067da6fcab8d7bc6ddf6a20497fe4d.tar.gz
infinitytier-720ac93ba9067da6fcab8d7bc6ddf6a20497fe4d.zip
Use NDIS6 driver preferentially if available.
Diffstat (limited to 'osdep')
-rw-r--r--osdep/WindowsEthernetTap.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/osdep/WindowsEthernetTap.cpp b/osdep/WindowsEthernetTap.cpp
index a0999b3d..220516ab 100644
--- a/osdep/WindowsEthernetTap.cpp
+++ b/osdep/WindowsEthernetTap.cpp
@@ -72,20 +72,21 @@ public:
#ifdef _WIN64
is64Bit = TRUE;
devcon = "\\devcon_x64.exe";
- tapDriver = "\\tap-windows\\x64\\zttap200.inf";
+ tapDriverNdis5 = "\\tap-windows\\x64\\zttap200.inf";
+ tapDriverNdis6 = "\\tap-windows\\x64\\zttap300.inf";
#else
is64Bit = FALSE;
IsWow64Process(GetCurrentProcess(),&is64Bit);
devcon = ((is64Bit == TRUE) ? "\\devcon_x64.exe" : "\\devcon_x86.exe");
- tapDriver = ((is64Bit == TRUE) ? "\\tap-windows\\x64\\zttap200.inf" : "\\tap-windows\\x86\\zttap200.inf");
+ tapDriverNdis5 = ((is64Bit == TRUE) ? "\\tap-windows\\x64\\zttap200.inf" : "\\tap-windows\\x86\\zttap200.inf");
+ tapDriverNdis6 = ((is64Bit == TRUE) ? "\\tap-windows\\x64\\zttap300.inf" : "\\tap-windows\\x86\\zttap300.inf");
#endif
}
-
BOOL is64Bit;
- std::string devcon;
- std::string tapDriver;
+ const char *devcon;
+ const char *tapDriverNdis5;
+ const char *tapDriverNdis6;
};
-
static const WindowsEthernetTapEnv WINENV;
} // anonymous namespace
@@ -123,6 +124,16 @@ WindowsEthernetTap::WindowsEthernetTap(
Mutex::Lock _l(_systemTapInitLock);
+ std::string tapDriverPath(_pathToHelpers + WINENV.tapDriverNdis6);
+ const char *tapDriverName = "zttap300";
+ if (::PathFileExistsA(tapDriverPath.c_str()) == FALSE) {
+ tapDriverPath = _pathToHelpers + WINENV.tapDriverNdis5;
+ tapDriverName = "zttap200";
+ if (::PathFileExistsA(tapDriverPath.c_str()) == FALSE) {
+ throw std::runtime_error("no tap driver available: cannot find zttap300.inf (NDIS6) or zttap200.inf (NDIS5) under home path");
+ }
+ }
+
HKEY nwAdapters;
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}",0,KEY_READ|KEY_WRITE,&nwAdapters) != ERROR_SUCCESS)
throw std::runtime_error("unable to open registry key for network adapter enumeration");
@@ -198,7 +209,7 @@ WindowsEthernetTap::WindowsEthernetTap(
PROCESS_INFORMATION processInfo;
memset(&startupInfo,0,sizeof(STARTUPINFOA));
memset(&processInfo,0,sizeof(PROCESS_INFORMATION));
- if (!CreateProcessA(NULL,(LPSTR)(std::string("\"") + _pathToHelpers + WINENV.devcon + "\" install \"" + _pathToHelpers + WINENV.tapDriver + "\" zttap200").c_str(),NULL,NULL,FALSE,0,NULL,NULL,&startupInfo,&processInfo)) {
+ if (!CreateProcessA(NULL,(LPSTR)(std::string("\"") + _pathToHelpers + WINENV.devcon + "\" install \"" + tapDriverPath + "\" " + tapDriverName).c_str(),NULL,NULL,FALSE,0,NULL,NULL,&startupInfo,&processInfo)) {
RegCloseKey(nwAdapters);
if (devconLog != INVALID_HANDLE_VALUE)
CloseHandle(devconLog);