mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
Tap works on Windows now, sort of. Now I discovered that Windows has two mechanisms for assigning IP addresses: the registry and lower-level calls. Joy.
This commit is contained in:
parent
a0916b926f
commit
9232ba1da0
2 changed files with 14 additions and 13 deletions
|
@ -981,12 +981,12 @@ EthernetTap::EthernetTap(
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
BOOL is64Bit = TRUE;
|
BOOL is64Bit = TRUE;
|
||||||
const char *devcon = "\\devcon_x64.exe";
|
const char *devcon = "\\devcon_x64.exe";
|
||||||
const char *tapDriver = "\\tap-windows\\x64\\ztTap100.inf";
|
const char *tapDriver = "\\tap-windows\\x64\\zttap200.inf";
|
||||||
#else
|
#else
|
||||||
BOOL is64Bit = FALSE;
|
BOOL is64Bit = FALSE;
|
||||||
IsWow64Process(GetCurrentProcess(),&is64Bit);
|
IsWow64Process(GetCurrentProcess(),&is64Bit);
|
||||||
const char *devcon = ((is64Bit == TRUE) ? "\\devcon_x64.exe" : "\\devcon_x86.exe");
|
const char *devcon = ((is64Bit == TRUE) ? "\\devcon_x64.exe" : "\\devcon_x86.exe");
|
||||||
const char *tapDriver = ((is64Bit == TRUE) ? "\\tap-windows\\x64\\ztTap100.inf" : "\\tap-windows\\x86\\ztTap100.inf");
|
const char *tapDriver = ((is64Bit == TRUE) ? "\\tap-windows\\x64\\zttap200.inf" : "\\tap-windows\\x86\\zttap200.inf");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Mutex::Lock _l(_systemTapInitLock); // only init one tap at a time, process-wide
|
Mutex::Lock _l(_systemTapInitLock); // only init one tap at a time, process-wide
|
||||||
|
@ -1054,7 +1054,7 @@ EthernetTap::EthernetTap(
|
||||||
PROCESS_INFORMATION processInfo;
|
PROCESS_INFORMATION processInfo;
|
||||||
memset(&startupInfo,0,sizeof(STARTUPINFOA));
|
memset(&startupInfo,0,sizeof(STARTUPINFOA));
|
||||||
memset(&processInfo,0,sizeof(PROCESS_INFORMATION));
|
memset(&processInfo,0,sizeof(PROCESS_INFORMATION));
|
||||||
if (!CreateProcessA(NULL,(LPSTR)(std::string("\"") + _r->homePath + devcon + "\" install \"" + _r->homePath + tapDriver + "\" ztTap100").c_str(),NULL,NULL,FALSE,0,NULL,NULL,&startupInfo,&processInfo)) {
|
if (!CreateProcessA(NULL,(LPSTR)(std::string("\"") + _r->homePath + devcon + "\" install \"" + _r->homePath + tapDriver + "\" zttap200").c_str(),NULL,NULL,FALSE,0,NULL,NULL,&startupInfo,&processInfo)) {
|
||||||
RegCloseKey(nwAdapters);
|
RegCloseKey(nwAdapters);
|
||||||
throw std::runtime_error(std::string("unable to find or execute devcon at ")+devcon);
|
throw std::runtime_error(std::string("unable to find or execute devcon at ")+devcon);
|
||||||
}
|
}
|
||||||
|
@ -1133,6 +1133,14 @@ EthernetTap::EthernetTap(
|
||||||
throw std::runtime_error("unable to convert instance ID GUID to native GUID (invalid NetCfgInstanceId in registry?)");
|
throw std::runtime_error("unable to convert instance ID GUID to native GUID (invalid NetCfgInstanceId in registry?)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable DHCP -- this might get changed if/when DHCP is supported
|
||||||
|
HKEY tcpIpInterfaces;
|
||||||
|
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters\\Interfaces",0,KEY_READ|KEY_WRITE,&tcpIpInterfaces) == ERROR_SUCCESS) {
|
||||||
|
DWORD enable = 0;
|
||||||
|
RegSetKeyValueA(tcpIpInterfaces,_myDeviceInstanceId.c_str(),"EnableDHCP",REG_DWORD,&enable,sizeof(enable));
|
||||||
|
RegCloseKey(tcpIpInterfaces);
|
||||||
|
}
|
||||||
|
|
||||||
// Disable and enable interface to ensure registry settings take effect
|
// Disable and enable interface to ensure registry settings take effect
|
||||||
{
|
{
|
||||||
STARTUPINFOA startupInfo;
|
STARTUPINFOA startupInfo;
|
||||||
|
@ -1375,7 +1383,6 @@ bool EthernetTap::updateMulticastGroups(std::set<MulticastGroup> &groups)
|
||||||
unsigned char mcastbuf[TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS_OUTPUT_BUF_SIZE];
|
unsigned char mcastbuf[TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS_OUTPUT_BUF_SIZE];
|
||||||
DWORD bytesReturned = 0;
|
DWORD bytesReturned = 0;
|
||||||
if (DeviceIoControl(_tap,TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS,(LPVOID)0,0,(LPVOID)mcastbuf,sizeof(mcastbuf),&bytesReturned,NULL)) {
|
if (DeviceIoControl(_tap,TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS,(LPVOID)0,0,(LPVOID)mcastbuf,sizeof(mcastbuf),&bytesReturned,NULL)) {
|
||||||
printf("TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS: got %d bytes\n",(int)bytesReturned);
|
|
||||||
MAC mac;
|
MAC mac;
|
||||||
DWORD i = 0;
|
DWORD i = 0;
|
||||||
while ((i + 6) <= bytesReturned) {
|
while ((i + 6) <= bytesReturned) {
|
||||||
|
@ -1385,13 +1392,11 @@ bool EthernetTap::updateMulticastGroups(std::set<MulticastGroup> &groups)
|
||||||
mac.data[3] = mcastbuf[i++];
|
mac.data[3] = mcastbuf[i++];
|
||||||
mac.data[4] = mcastbuf[i++];
|
mac.data[4] = mcastbuf[i++];
|
||||||
mac.data[5] = mcastbuf[i++];
|
mac.data[5] = mcastbuf[i++];
|
||||||
if (mac.isMulticast()) { // exclude the nulls that may be returned or any other junk Windows puts in there
|
if (mac.isMulticast()) {
|
||||||
|
// exclude the nulls that may be returned or any other junk Windows puts in there
|
||||||
newGroups.insert(MulticastGroup(mac,0));
|
newGroups.insert(MulticastGroup(mac,0));
|
||||||
printf("TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS: %s\n",mac.toString().c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
printf("TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS: failed\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newGroups.insert(_blindWildcardMulticastGroup); // always join this
|
newGroups.insert(_blindWildcardMulticastGroup); // always join this
|
||||||
|
|
|
@ -216,8 +216,6 @@ Global
|
||||||
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win7 Release|Win32.Build.0 = Win7 Release|Win32
|
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win7 Release|Win32.Build.0 = Win7 Release|Win32
|
||||||
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win7 Release|Win32.Deploy.0 = Win7 Release|Win32
|
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win7 Release|Win32.Deploy.0 = Win7 Release|Win32
|
||||||
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win7 Release|x64.ActiveCfg = Win7 Release|x64
|
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win7 Release|x64.ActiveCfg = Win7 Release|x64
|
||||||
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win7 Release|x64.Build.0 = Win7 Release|x64
|
|
||||||
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win7 Release|x64.Deploy.0 = Win7 Release|x64
|
|
||||||
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win8 Debug|Any CPU.ActiveCfg = Win8 Debug|Win32
|
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win8 Debug|Any CPU.ActiveCfg = Win8 Debug|Win32
|
||||||
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win8 Debug|Mixed Platforms.ActiveCfg = Win8 Debug|Win32
|
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win8 Debug|Mixed Platforms.ActiveCfg = Win8 Debug|Win32
|
||||||
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32
|
{689210B1-467C-4850-BB7D-2E10D5B4A3DA}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32
|
||||||
|
@ -310,8 +308,6 @@ Global
|
||||||
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win7 Release|Win32.Build.0 = Win7 Release|Win32
|
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win7 Release|Win32.Build.0 = Win7 Release|Win32
|
||||||
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win7 Release|Win32.Deploy.0 = Win7 Release|Win32
|
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win7 Release|Win32.Deploy.0 = Win7 Release|Win32
|
||||||
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win7 Release|x64.ActiveCfg = Win7 Release|x64
|
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win7 Release|x64.ActiveCfg = Win7 Release|x64
|
||||||
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win7 Release|x64.Build.0 = Win7 Release|x64
|
|
||||||
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win7 Release|x64.Deploy.0 = Win7 Release|x64
|
|
||||||
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win8 Debug|Any CPU.ActiveCfg = Win8 Debug|Win32
|
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win8 Debug|Any CPU.ActiveCfg = Win8 Debug|Win32
|
||||||
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win8 Debug|Mixed Platforms.ActiveCfg = Win8 Debug|Win32
|
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win8 Debug|Mixed Platforms.ActiveCfg = Win8 Debug|Win32
|
||||||
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32
|
{FDA1DD8D-1D56-4BC1-B402-FCC0B550D946}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32
|
||||||
|
@ -406,7 +402,7 @@ Global
|
||||||
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win7 Release|Win32.ActiveCfg = Release|Win32
|
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win7 Release|Win32.ActiveCfg = Release|Win32
|
||||||
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win7 Release|Win32.Build.0 = Release|Win32
|
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win7 Release|Win32.Build.0 = Release|Win32
|
||||||
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win7 Release|Win32.Deploy.0 = Release|Win32
|
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win7 Release|Win32.Deploy.0 = Release|Win32
|
||||||
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win7 Release|x64.ActiveCfg = Release|Win32
|
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win7 Release|x64.ActiveCfg = Release|x64
|
||||||
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win8 Debug|Any CPU.ActiveCfg = Debug|Win32
|
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win8 Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||||
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win8 Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win8 Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||||
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win8 Debug|Mixed Platforms.Build.0 = Debug|Win32
|
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win8 Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||||
|
|
Loading…
Add table
Reference in a new issue