First Commit
Some checks failed
/ build_macos (push) Has been cancelled
/ build_windows (push) Has been cancelled
/ build_ubuntu (push) Has been cancelled

This commit is contained in:
2025-11-19 16:23:45 +07:00
commit dbdc5bcc4a
1791 changed files with 489451 additions and 0 deletions

29
windows/README.md Normal file
View File

@@ -0,0 +1,29 @@
This folder contains the Windows driver code, Windows-specific service code, and the Microsoft Visual Studio projects and "solution" for doing Windows builds.
This code may also build with MinGW but this hasn't been tested.
## Building
```
MSBuild ZeroTierOne.sln /property:Configuration=Release /property:Platform=ARM64
```
(substitute e.g. `Debug`, `x64`, etc. as needed above, or use Visual Studio to select a target)
## Testing
PowerShell admin session #1 inside `<PROJECT_DIR>\windows\Build\<ARCH>\<TARGET>`:
```
PS C:\Users\<USER>\ZeroTierOne\windows\Build\ARM64\Release> .\zerotier-one_arm64.exe -p9994 -C C:\<SOME_TEMP_DIR>\
Starting Control Plane...
Starting V6 Control Plane...
```
Session #2:
```
PS C:\Users\<USER>\ZeroTierOne\windows\Build\ARM64\Release> zerotier-cli.bat -p9994 -D"\Users\rcode\scratch\zt1_home\" info
info c3e46fa070 1.12.2 ONLINE
PS C:\Users\<USER>\code\ZeroTierOne\windows\Build\ARM64\Release> zerotier-cli.bat -p9994 -D"\Users\<SOME_TEMP_DIR>\scratch\zt1_home\" join ebe7fbd4458bde97
200 join OK PS C:\Users\<USER>\code\ZeroTierOne\windows\Build\ARM64\Release>
```

View File

@@ -0,0 +1,253 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Win8 Debug|ARM64">
<Configuration>Win8 Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8 Debug|Win32">
<Configuration>Win8 Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8 Release|ARM64">
<Configuration>Win8 Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8 Release|Win32">
<Configuration>Win8 Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8 Debug|x64">
<Configuration>Win8 Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8 Release|x64">
<Configuration>Win8 Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}</ProjectGuid>
<TemplateGuid>{1bc93793-694f-48fe-9372-81e2b05556fd}</TemplateGuid>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<Configuration>Win8 Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
</PropertyGroup>
<PropertyGroup Label="Globals">
<RootNamespace>TapDriver6</RootNamespace>
<VCTargetsPath Condition="'$(VCTargetsPath11)' != '' and '$(VisualStudioVersion)' == '11.0'">$(VCTargetsPath11)</VCTargetsPath>
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Label="PropertySheets">
<ConfigurationType>Driver</ConfigurationType>
<DriverType>KMDF</DriverType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'" Label="Configuration">
<TargetVersion>Windows8</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'" Label="Configuration">
<TargetVersion>Windows8</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<Driver_SpectreMitigation>false</Driver_SpectreMitigation>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'" Label="Configuration">
<TargetVersion>Windows8</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|ARM64'" Label="Configuration">
<TargetVersion>Windows8</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'" Label="Configuration">
<TargetVersion>Windows8</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<Driver_SpectreMitigation>false</Driver_SpectreMitigation>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'" Label="Configuration">
<TargetVersion>Windows8</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<Driver_SpectreMitigation>false</Driver_SpectreMitigation>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">
<TargetName>zttap300</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">
<TargetName>zttap300</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">
<TargetName>zttap300</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|ARM64'">
<TargetName>zttap300</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">
<TargetName>zttap300</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'">
<TargetName>zttap300</TargetName>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<WppEnabled>false</WppEnabled>
<WppScanConfigurationData Condition="'%(ClCompile. ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
<WppKernelMode>false</WppKernelMode>
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">false</WppMinimalRebuildFromTracking>
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">false</WppMinimalRebuildFromTracking>
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">false</WppMinimalRebuildFromTracking>
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|ARM64'">false</WppMinimalRebuildFromTracking>
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">false</WppMinimalRebuildFromTracking>
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'">false</WppMinimalRebuildFromTracking>
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">Level1</WarningLevel>
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">Level1</WarningLevel>
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">Level1</WarningLevel>
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|ARM64'">Level1</WarningLevel>
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">Level1</WarningLevel>
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'">Level1</WarningLevel>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">Default</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">Default</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">Default</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|ARM64'">Default</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">Default</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'">Default</CompileAs>
<BufferSecurityCheck Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">false</BufferSecurityCheck>
<BufferSecurityCheck Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'">false</BufferSecurityCheck>
<ControlFlowGuard Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">false</ControlFlowGuard>
<ControlFlowGuard Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'">false</ControlFlowGuard>
<FunctionLevelLinking Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">false</FunctionLevelLinking>
<FunctionLevelLinking Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'">false</FunctionLevelLinking>
<BufferSecurityCheck Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">false</BufferSecurityCheck>
<ControlFlowGuard Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">false</ControlFlowGuard>
<FunctionLevelLinking Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">false</FunctionLevelLinking>
</ClCompile>
<Link />
<Link>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">C:\WinDDK\7600.16385.1\lib\win7\amd64\ndis.lib;C:\WinDDK\7600.16385.1\lib\win7\amd64\ntstrsafe.lib;C:\WinDDK\7600.16385.1\lib\win7\amd64\wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|ARM64'">C:\WinDDK\7600.16385.1\lib\win7\amd64\ndis.lib;C:\WinDDK\7600.16385.1\lib\win7\amd64\ntstrsafe.lib;C:\WinDDK\7600.16385.1\lib\win7\amd64\wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link />
<Link />
<Link />
<Link>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\km\x64\ndis.lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\km\x64\ntstrsafe.lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\km\x64\wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'">C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\km\x64\ndis.lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\km\x64\ntstrsafe.lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\km\x64\wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link />
<Link>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">C:\WinDDK\7600.16385.1\lib\win7\i386\ndis.lib;C:\WinDDK\7600.16385.1\lib\win7\i386\ntstrsafe.lib;C:\WinDDK\7600.16385.1\lib\win7\i386\wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link />
<Link />
<Link />
<Link>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\km\x86\ndis.lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\km\x86\ntstrsafe.lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\km\x86\wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Inf />
<Inf>
<TimeStamp Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">3.00.00.0</TimeStamp>
<SpecifyDriverVerDirectiveVersion Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">false</SpecifyDriverVerDirectiveVersion>
<SpecifyDriverVerDirectiveDate Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">false</SpecifyDriverVerDirectiveDate>
</Inf>
<Inf />
<Inf />
<Inf />
<Inf>
<TimeStamp Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">3.00.00.0</TimeStamp>
<SpecifyDriverVerDirectiveVersion Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">false</SpecifyDriverVerDirectiveVersion>
<SpecifyDriverVerDirectiveDate Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">false</SpecifyDriverVerDirectiveDate>
</Inf>
<Inf />
<Inf>
<TimeStamp Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">3.00.00.0</TimeStamp>
<TimeStamp Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|ARM64'">3.00.00.0</TimeStamp>
<SpecifyDriverVerDirectiveVersion Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">false</SpecifyDriverVerDirectiveVersion>
<SpecifyDriverVerDirectiveVersion Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|ARM64'">false</SpecifyDriverVerDirectiveVersion>
<SpecifyDriverVerDirectiveDate Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">false</SpecifyDriverVerDirectiveDate>
<SpecifyDriverVerDirectiveDate Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|ARM64'">false</SpecifyDriverVerDirectiveDate>
</Inf>
<Inf />
<Inf />
<Inf />
<Inf>
<TimeStamp Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">3.00.00.0</TimeStamp>
<TimeStamp Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'">3.00.00.0</TimeStamp>
<SpecifyDriverVerDirectiveVersion Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">false</SpecifyDriverVerDirectiveVersion>
<SpecifyDriverVerDirectiveVersion Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'">false</SpecifyDriverVerDirectiveVersion>
<SpecifyDriverVerDirectiveDate Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">false</SpecifyDriverVerDirectiveDate>
<SpecifyDriverVerDirectiveDate Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'">false</SpecifyDriverVerDirectiveDate>
</Inf>
</ItemDefinitionGroup>
<ItemGroup>
<FilesToPackage Include="$(TargetPath)" />
<FilesToPackage Include="@(Inf->'%(CopyOutput)')" Condition="'@(Inf)'!=''" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="adapter.c" />
<ClCompile Include="device.c" />
<ClCompile Include="error.c" />
<ClCompile Include="macinfo.c" />
<ClCompile Include="mem.c" />
<ClCompile Include="oidrequest.c" />
<ClCompile Include="rxpath.c" />
<ClCompile Include="tapdrvr.c" />
<ClCompile Include="txpath.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="adapter.h" />
<ClInclude Include="config.h" />
<ClInclude Include="constants.h" />
<ClInclude Include="device.h" />
<ClInclude Include="endian.h" />
<ClInclude Include="error.h" />
<ClInclude Include="hexdump.h" />
<ClInclude Include="lock.h" />
<ClInclude Include="macinfo.h" />
<ClInclude Include="mem.h" />
<ClInclude Include="proto.h" />
<ClInclude Include="prototypes.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="tap-windows.h" />
<ClInclude Include="tap.h" />
<ClInclude Include="types.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resource.rc" />
</ItemGroup>
<ItemGroup>
<Inf Include="zttap300.inf">
<SpecifyDriverVerDirectiveVersion Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">false</SpecifyDriverVerDirectiveVersion>
<TimeStamp Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">3.00.00.0</TimeStamp>
<SpecifyDriverVerDirectiveVersion Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">false</SpecifyDriverVerDirectiveVersion>
<TimeStamp Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">3.00.00.0</TimeStamp>
<SpecifyDriverVerDirectiveVersion Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">false</SpecifyDriverVerDirectiveVersion>
<SpecifyDriverVerDirectiveVersion Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|ARM64'">false</SpecifyDriverVerDirectiveVersion>
<TimeStamp Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">3.00.00.0</TimeStamp>
<TimeStamp Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|ARM64'">3.00.00.0</TimeStamp>
<SpecifyDriverVerDirectiveVersion Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">false</SpecifyDriverVerDirectiveVersion>
<SpecifyDriverVerDirectiveVersion Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'">false</SpecifyDriverVerDirectiveVersion>
<TimeStamp Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">3.00.00.0</TimeStamp>
<TimeStamp Condition="'$(Configuration)|$(Platform)'=='Win8 Release|ARM64'">3.00.00.0</TimeStamp>
</Inf>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Driver Files">
<UniqueIdentifier>{8E41214B-6785-4CFE-B992-037D68949A14}</UniqueIdentifier>
<Extensions>inf;inv;inx;mof;mc;</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="adapter.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="device.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="error.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="macinfo.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mem.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="oidrequest.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="rxpath.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="tapdrvr.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="txpath.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="adapter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="config.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="constants.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="device.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="endian.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="error.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="hexdump.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lock.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="macinfo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="mem.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="proto.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="prototypes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="tap.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="tap-windows.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="types.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resource.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Inf Include="zttap300.inf">
<Filter>Driver Files</Filter>
</Inf>
</ItemGroup>
</Project>

1717
windows/TapDriver6/adapter.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,352 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
#ifndef __TAP_ADAPTER_CONTEXT_H_
#define __TAP_ADAPTER_CONTEXT_H_
#include "tap.h"
// Memory allocation tags.
#define TAP_ADAPTER_TAG ((ULONG)'ApaT') // "TapA
#define TAP_RX_NBL_TAG ((ULONG)'RpaT') // "TapR
#define TAP_RX_INJECT_BUFFER_TAG ((ULONG)'IpaT') // "TapI
#define TAP_MAX_NDIS_NAME_LENGTH 64 // 38 character GUID string plus extra..
// TAP receive indication NBL flag definitions.
#define TAP_RX_NBL_FLAGS NBL_FLAGS_MINIPORT_RESERVED
#define TAP_RX_NBL_FLAGS_CLEAR_ALL(_NBL) ((_NBL)->Flags &= ~TAP_RX_NBL_FLAGS)
#define TAP_RX_NBL_FLAG_SET(_NBL, _F) ((_NBL)->Flags |= ((_F) & TAP_RX_NBL_FLAGS))
#define TAP_RX_NBL_FLAG_CLEAR(_NBL, _F) ((_NBL)->Flags &= ~((_F) & TAP_RX_NBL_FLAGS))
#define TAP_RX_NBL_FLAG_TEST(_NBL, _F) (((_NBL)->Flags & ((_F) & TAP_RX_NBL_FLAGS)) != 0)
#define TAP_RX_NBL_FLAGS_IS_P2P 0x00001000
#define TAP_RX_NBL_FLAGS_IS_INJECTED 0x00002000
// MSDN Ref: http://msdn.microsoft.com/en-us/library/windows/hardware/ff560490(v=vs.85).aspx
typedef
enum _TAP_MINIPORT_ADAPTER_STATE
{
// The Halted state is the initial state of all adapters. When an
// adapter is in the Halted state, NDIS can call the driver's
// MiniportInitializeEx function to initialize the adapter.
MiniportHaltedState,
// In the Shutdown state, a system shutdown and restart must occur
// before the system can use the adapter again.
MiniportShutdownState,
// In the Initializing state, a miniport driver completes any
//operations that are required to initialize an adapter.
MiniportInitializingState,
// Entering the Paused state...
MiniportPausingState,
// In the Paused state, the adapter does not indicate received
// network data or accept send requests.
MiniportPausedState,
// In the Running state, a miniport driver performs send and
// receive processing for an adapter.
MiniportRunning,
// In the Restarting state, a miniport driver completes any
// operations that are required to restart send and receive
// operations for an adapter.
MiniportRestartingState
} TAP_MINIPORT_ADAPTER_STATE, *PTAP_MINIPORT_ADAPTER_STATE;
//
// Each adapter managed by this driver has a TapAdapter struct.
// ------------------------------------------------------------
// Since there is a one-to-one relationship between adapter instances
// and device instances this structure is the device extension as well.
//
typedef struct _TAP_ADAPTER_CONTEXT
{
LIST_ENTRY AdapterListLink;
volatile LONG RefCount;
NDIS_HANDLE MiniportAdapterHandle;
NDIS_SPIN_LOCK AdapterLock; // Lock for protection of state and outstanding sends and recvs
//
// All fields that are protected by the AdapterLock are included
// in the Locked structure to remind us to take the Lock
// before accessing them :)
//
struct
{
TAP_MINIPORT_ADAPTER_STATE AdapterState;
} Locked;
BOOLEAN ResetInProgress;
//
// NetCfgInstanceId as UNICODE_STRING
// ----------------------------------
// This a GUID string provided by NDIS that identifies the adapter instance.
// An example is:
//
// NetCfgInstanceId={410EB49D-2381-4FE7-9B36-498E22619DF0}
//
// Other names are derived from NetCfgInstanceId. For example, MiniportName:
//
// MiniportName=\DEVICE\{410EB49D-2381-4FE7-9B36-498E22619DF0}
//
NDIS_STRING NetCfgInstanceId;
WCHAR NetCfgInstanceIdBuffer[TAP_MAX_NDIS_NAME_LENGTH];
# define MINIPORT_INSTANCE_ID(a) ((a)->NetCfgInstanceIdAnsi.Buffer)
ANSI_STRING NetCfgInstanceIdAnsi; // Used occasionally
ULONG MtuSize; // 1500 byte (typical)
// TRUE if adapter should always be "connected" even when device node
// is not open by a userspace process.
//
// FALSE if connection state is application controlled.
BOOLEAN MediaStateAlwaysConnected;
// TRUE if device is "connected".
BOOLEAN LogicalMediaState;
NDIS_DEVICE_POWER_STATE CurrentPowerState;
BOOLEAN AllowNonAdmin;
MACADDR PermanentAddress; // From registry, if available
MACADDR CurrentAddress;
// Device registration parameters from NdisRegisterDeviceEx.
NDIS_STRING DeviceName;
WCHAR DeviceNameBuffer[TAP_MAX_NDIS_NAME_LENGTH];
NDIS_STRING LinkName;
WCHAR LinkNameBuffer[TAP_MAX_NDIS_NAME_LENGTH];
NDIS_HANDLE DeviceHandle;
PDEVICE_OBJECT DeviceObject;
BOOLEAN TapDeviceCreated; // WAS: m_TapIsRunning
PFILE_OBJECT TapFileObject; // Exclusive access
BOOLEAN TapFileIsOpen; // WAS: m_TapOpens
LONG TapFileOpenCount; // WAS: m_NumTapOpens
// Cancel-Safe read IRP queue.
TAP_IRP_CSQ PendingReadIrpQueue;
// Queue containing TAP packets representing host send NBs. These are
// waiting to be read by user-mode application.
TAP_PACKET_QUEUE SendPacketQueue;
// NBL pool for making TAP receive indications.
NDIS_HANDLE ReceiveNblPool;
volatile LONG ReceiveNblInFlightCount;
#define TAP_WAIT_POLL_LOOP_TIMEOUT 3000 // 3 seconds
NDIS_EVENT ReceiveNblInFlightCountZeroEvent;
/*
// Info for point-to-point mode
BOOLEAN m_tun;
IPADDR m_localIP;
IPADDR m_remoteNetwork;
IPADDR m_remoteNetmask;
ETH_HEADER m_TapToUser;
ETH_HEADER m_UserToTap;
ETH_HEADER m_UserToTap_IPv6; // same as UserToTap but proto=ipv6
*/
// Info for DHCP server masquerade
/*
BOOLEAN m_dhcp_enabled;
IPADDR m_dhcp_addr;
ULONG m_dhcp_netmask;
IPADDR m_dhcp_server_ip;
BOOLEAN m_dhcp_server_arp;
MACADDR m_dhcp_server_mac;
ULONG m_dhcp_lease_time;
UCHAR m_dhcp_user_supplied_options_buffer[DHCP_USER_SUPPLIED_OPTIONS_BUFFER_SIZE];
ULONG m_dhcp_user_supplied_options_buffer_len;
BOOLEAN m_dhcp_received_discover;
ULONG m_dhcp_bad_requests;
*/
// Multicast list. Fixed size.
ULONG ulMCListSize;
UCHAR MCList[TAP_MAX_MCAST_LIST][MACADDR_SIZE];
ULONG PacketFilter;
ULONG ulLookahead;
//
// Statistics
// -------------------------------------------------------------------------
//
// Packet counts
ULONG64 FramesRxDirected;
ULONG64 FramesRxMulticast;
ULONG64 FramesRxBroadcast;
ULONG64 FramesTxDirected;
ULONG64 FramesTxMulticast;
ULONG64 FramesTxBroadcast;
// Byte counts
ULONG64 BytesRxDirected;
ULONG64 BytesRxMulticast;
ULONG64 BytesRxBroadcast;
ULONG64 BytesTxDirected;
ULONG64 BytesTxMulticast;
ULONG64 BytesTxBroadcast;
// Count of transmit errors
ULONG TxAbortExcessCollisions;
ULONG TxLateCollisions;
ULONG TxDmaUnderrun;
ULONG TxLostCRS;
ULONG TxOKButDeferred;
ULONG OneRetry;
ULONG MoreThanOneRetry;
ULONG TotalRetries;
ULONG TransmitFailuresOther;
// Count of receive errors
ULONG RxCrcErrors;
ULONG RxAlignmentErrors;
ULONG RxResourceErrors;
ULONG RxDmaOverrunErrors;
ULONG RxCdtFrames;
ULONG RxRuntErrors;
#if PACKET_TRUNCATION_CHECK
LONG m_RxTrunc, m_TxTrunc;
#endif
BOOLEAN m_InterfaceIsRunning;
LONG m_Rx, m_RxErr;
NDIS_MEDIUM m_Medium;
// Help to tear down the adapter by keeping
// some state information on allocated
// resources.
BOOLEAN m_CalledAdapterFreeResources;
BOOLEAN m_RegisteredAdapterShutdownHandler;
} TAP_ADAPTER_CONTEXT, *PTAP_ADAPTER_CONTEXT;
FORCEINLINE
LONG
tapAdapterContextReference(
__in PTAP_ADAPTER_CONTEXT Adapter
)
{
LONG refCount = NdisInterlockedIncrement(&Adapter->RefCount);
ASSERT(refCount>1); // Cannot dereference a zombie.
return refCount;
}
VOID
tapAdapterContextFree(
__in PTAP_ADAPTER_CONTEXT Adapter
);
FORCEINLINE
LONG
tapAdapterContextDereference(
IN PTAP_ADAPTER_CONTEXT Adapter
)
{
LONG refCount = NdisInterlockedDecrement(&Adapter->RefCount);
ASSERT(refCount >= 0);
if (!refCount)
{
tapAdapterContextFree(Adapter);
}
return refCount;
}
VOID
tapAdapterAcquireLock(
__in PTAP_ADAPTER_CONTEXT Adapter,
__in BOOLEAN DispatchLevel
);
VOID
tapAdapterReleaseLock(
__in PTAP_ADAPTER_CONTEXT Adapter,
__in BOOLEAN DispatchLevel
);
// Returns with added reference on adapter context.
PTAP_ADAPTER_CONTEXT
tapAdapterContextFromDeviceObject(
__in PDEVICE_OBJECT DeviceObject
);
BOOLEAN
tapAdapterReadAndWriteReady(
__in PTAP_ADAPTER_CONTEXT Adapter
);
NDIS_STATUS
tapAdapterSendAndReceiveReady(
__in PTAP_ADAPTER_CONTEXT Adapter
);
ULONG
tapGetNetBufferFrameType(
__in PNET_BUFFER NetBuffer
);
ULONG
tapGetNetBufferCountsFromNetBufferList(
__in PNET_BUFFER_LIST NetBufferList,
__inout_opt PULONG TotalByteCount // Of all linked NBs
);
// Prototypes for standard NDIS miniport entry points
MINIPORT_SET_OPTIONS AdapterSetOptions;
MINIPORT_INITIALIZE AdapterCreate;
MINIPORT_HALT AdapterHalt;
MINIPORT_UNLOAD TapDriverUnload;
MINIPORT_PAUSE AdapterPause;
MINIPORT_RESTART AdapterRestart;
MINIPORT_OID_REQUEST AdapterOidRequest;
MINIPORT_SEND_NET_BUFFER_LISTS AdapterSendNetBufferLists;
MINIPORT_RETURN_NET_BUFFER_LISTS AdapterReturnNetBufferLists;
MINIPORT_CANCEL_SEND AdapterCancelSend;
MINIPORT_CHECK_FOR_HANG AdapterCheckForHangEx;
MINIPORT_RESET AdapterReset;
MINIPORT_DEVICE_PNP_EVENT_NOTIFY AdapterDevicePnpEventNotify;
MINIPORT_SHUTDOWN AdapterShutdownEx;
MINIPORT_CANCEL_OID_REQUEST AdapterCancelOidRequest;
#endif // __TAP_ADAPTER_CONTEXT_H_

View File

@@ -0,0 +1,9 @@
#define PRODUCT_NAME "ZeroTier Virtual Port"
#define PRODUCT_VERSION "3.0.0"
#define PRODUCT_VERSION_RESOURCE 3,0,0,1
#define PRODUCT_TAP_WIN_COMPONENT_ID "zttap300"
#define PRODUCT_TAP_WIN_MAJOR 3
#define PRODUCT_TAP_WIN_MINOR 0
#define PRODUCT_TAP_WIN_PROVIDER "ZeroTier"
#define PRODUCT_TAP_WIN_DEVICE_DESCRIPTION PRODUCT_NAME
#define PRODUCT_TAP_WIN_RELDATE "11/24/2020"

View File

@@ -0,0 +1,196 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
//====================================================================
// Product and Version public settings
//====================================================================
#define PRODUCT_STRING PRODUCT_TAP_DEVICE_DESCRIPTION
//
// Update the driver version number every time you release a new driver
// The high word is the major version. The low word is the minor version.
// Also make sure that VER_FILEVERSION specified in the .RC file also
// matches with the driver version because NDISTESTER checks for that.
//
#ifndef TAP_DRIVER_MAJOR_VERSION
#define TAP_DRIVER_MAJOR_VERSION 0x04
#define TAP_DRIVER_MINOR_VERSION 0x02
#endif
#define TAP_DRIVER_VENDOR_VERSION ((TAP_DRIVER_MAJOR_VERSION << 16) | TAP_DRIVER_MINOR_VERSION)
//
// Define the NDIS miniport interface version that this driver targets.
//
#if defined(NDIS60_MINIPORT)
# define TAP_NDIS_MAJOR_VERSION 6
# define TAP_NDIS_MINOR_VERSION 0
#elif defined(NDIS61_MINIPORT)
# define TAP_NDIS_MAJOR_VERSION 6
# define TAP_NDIS_MINOR_VERSION 1
#elif defined(NDIS620_MINIPORT)
# define TAP_NDIS_MAJOR_VERSION 6
# define TAP_NDIS_MINOR_VERSION 20
#elif defined(NDIS630_MINIPORT)
# define TAP_NDIS_MAJOR_VERSION 6
# define TAP_NDIS_MINOR_VERSION 30
#else
#define TAP_NDIS_MAJOR_VERSION 5
#define TAP_NDIS_MINOR_VERSION 0
#endif
//===========================================================
// Driver constants
//===========================================================
#define ETHERNET_HEADER_SIZE (sizeof (ETH_HEADER))
//#define ETHERNET_MTU 1500
#define ETHERNET_MTU 2800
#define ETHERNET_PACKET_SIZE (ETHERNET_MTU + ETHERNET_HEADER_SIZE)
#define DEFAULT_PACKET_LOOKAHEAD (ETHERNET_PACKET_SIZE)
#define VLAN_TAG_SIZE 4
//===========================================================
// Medium properties
//===========================================================
#define TAP_FRAME_HEADER_SIZE ETHERNET_HEADER_SIZE
#define TAP_FRAME_MAX_DATA_SIZE ETHERNET_MTU
#define TAP_MAX_FRAME_SIZE (TAP_FRAME_HEADER_SIZE + TAP_FRAME_MAX_DATA_SIZE)
#define TAP_MIN_FRAME_SIZE 60
#define TAP_MEDIUM_TYPE NdisMedium802_3
//===========================================================
// Physical adapter properties
//===========================================================
// The bus that connects the adapter to the PC.
// (Example: PCI adapters should use NdisInterfacePci).
#define TAP_INTERFACE_TYPE NdisInterfaceInternal
#define TAP_VENDOR_DESC PRODUCT_TAP_WIN_DEVICE_DESCRIPTION
// Highest byte is the NIC byte plus three vendor bytes. This is normally
// obtained from the NIC.
#define TAP_VENDOR_ID 0x00FFFFFF
// If you have physical hardware on 802.3, use NdisPhysicalMedium802_3.
#define TAP_PHYSICAL_MEDIUM NdisPhysicalMediumUnspecified
// Claim to be 100mbps duplex
#define MEGABITS_PER_SECOND 1000000ULL
#define TAP_XMIT_SPEED (100ULL*MEGABITS_PER_SECOND)
#define TAP_RECV_SPEED (100ULL*MEGABITS_PER_SECOND)
// Max number of multicast addresses supported in hardware
#define TAP_MAX_MCAST_LIST 128
#define TAP_MAX_LOOKAHEAD TAP_FRAME_MAX_DATA_SIZE
#define TAP_BUFFER_SIZE TAP_MAX_FRAME_SIZE
// Set this value to TRUE if there is a physical adapter.
#define TAP_HAS_PHYSICAL_CONNECTOR FALSE
#define TAP_ACCESS_TYPE NET_IF_ACCESS_BROADCAST
#define TAP_DIRECTION_TYPE NET_IF_DIRECTION_SENDRECEIVE
#define TAP_CONNECTION_TYPE NET_IF_CONNECTION_DEDICATED
// This value must match the *IfType in the driver .inf file
#define TAP_IFTYPE IF_TYPE_ETHERNET_CSMACD
//
// This is a virtual device, so it can tolerate surprise removal and
// suspend. Ensure the correct flags are set for your hardware.
//
#define TAP_ADAPTER_ATTRIBUTES_FLAGS (\
NDIS_MINIPORT_ATTRIBUTES_SURPRISE_REMOVE_OK | NDIS_MINIPORT_ATTRIBUTES_NDIS_WDM)
#define TAP_SUPPORTED_FILTERS ( \
NDIS_PACKET_TYPE_DIRECTED | \
NDIS_PACKET_TYPE_MULTICAST | \
NDIS_PACKET_TYPE_BROADCAST | \
NDIS_PACKET_TYPE_ALL_LOCAL | \
NDIS_PACKET_TYPE_PROMISCUOUS | \
NDIS_PACKET_TYPE_ALL_MULTICAST)
//#define TAP_MAX_MCAST_LIST 128 // Max length of multicast address list
//
// Specify a bitmask that defines optional properties of the NIC.
// This miniport indicates receive with NdisMIndicateReceiveNetBufferLists
// function. Such a driver should set this NDIS_MAC_OPTION_TRANSFERS_NOT_PEND
// flag.
//
// NDIS_MAC_OPTION_NO_LOOPBACK tells NDIS that NIC has no internal
// loopback support so NDIS will manage loopbacks on behalf of
// this driver.
//
// NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA tells the protocol that
// our receive buffer is not on a device-specific card. If
// NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA is not set, multi-buffer
// indications are copied to a single flat buffer.
//
#define TAP_MAC_OPTIONS (\
NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA | \
NDIS_MAC_OPTION_TRANSFERS_NOT_PEND | \
NDIS_MAC_OPTION_NO_LOOPBACK)
#define TAP_ADAPTER_CHECK_FOR_HANG_TIME_IN_SECONDS 4
// NDIS 6.x miniports must support all counters in OID_GEN_STATISTICS.
#define TAP_SUPPORTED_STATISTICS (\
NDIS_STATISTICS_FLAGS_VALID_DIRECTED_FRAMES_RCV | \
NDIS_STATISTICS_FLAGS_VALID_MULTICAST_FRAMES_RCV | \
NDIS_STATISTICS_FLAGS_VALID_BROADCAST_FRAMES_RCV | \
NDIS_STATISTICS_FLAGS_VALID_BYTES_RCV | \
NDIS_STATISTICS_FLAGS_VALID_RCV_DISCARDS | \
NDIS_STATISTICS_FLAGS_VALID_RCV_ERROR | \
NDIS_STATISTICS_FLAGS_VALID_DIRECTED_FRAMES_XMIT | \
NDIS_STATISTICS_FLAGS_VALID_MULTICAST_FRAMES_XMIT | \
NDIS_STATISTICS_FLAGS_VALID_BROADCAST_FRAMES_XMIT | \
NDIS_STATISTICS_FLAGS_VALID_BYTES_XMIT | \
NDIS_STATISTICS_FLAGS_VALID_XMIT_ERROR | \
NDIS_STATISTICS_FLAGS_VALID_XMIT_DISCARDS | \
NDIS_STATISTICS_FLAGS_VALID_DIRECTED_BYTES_RCV | \
NDIS_STATISTICS_FLAGS_VALID_MULTICAST_BYTES_RCV | \
NDIS_STATISTICS_FLAGS_VALID_BROADCAST_BYTES_RCV | \
NDIS_STATISTICS_FLAGS_VALID_DIRECTED_BYTES_XMIT | \
NDIS_STATISTICS_FLAGS_VALID_MULTICAST_BYTES_XMIT | \
NDIS_STATISTICS_FLAGS_VALID_BROADCAST_BYTES_XMIT)
#define MINIMUM_MTU 576 // USE TCP Minimum MTU
#define MAXIMUM_MTU 65536 // IP maximum MTU
#define PACKET_QUEUE_SIZE 64 // tap -> userspace queue size
#define IRP_QUEUE_SIZE 16 // max number of simultaneous i/o operations from userspace
#define INJECT_QUEUE_SIZE 16 // DHCP/ARP -> tap injection queue
#define TAP_LITTLE_ENDIAN // affects ntohs, htonl, etc. functions

1209
windows/TapDriver6/device.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,50 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
#ifndef __TAP_DEVICE_H_
#define __TAP_DEVICE_H_
//======================================================================
// TAP Prototypes for standard Win32 device I/O entry points
//======================================================================
__drv_dispatchType(IRP_MJ_CREATE)
DRIVER_DISPATCH TapDeviceCreate;
__drv_dispatchType(IRP_MJ_READ)
DRIVER_DISPATCH TapDeviceRead;
__drv_dispatchType(IRP_MJ_WRITE)
DRIVER_DISPATCH TapDeviceWrite;
__drv_dispatchType(IRP_MJ_DEVICE_CONTROL)
DRIVER_DISPATCH TapDeviceControl;
__drv_dispatchType(IRP_MJ_CLEANUP)
DRIVER_DISPATCH TapDeviceCleanup;
__drv_dispatchType(IRP_MJ_CLOSE)
DRIVER_DISPATCH TapDeviceClose;
#endif // __TAP_DEVICE_H_

View File

@@ -0,0 +1,35 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
#ifdef TAP_LITTLE_ENDIAN
#define ntohs(x) RtlUshortByteSwap(x)
#define htons(x) RtlUshortByteSwap(x)
#define ntohl(x) RtlUlongByteSwap(x)
#define htonl(x) RtlUlongByteSwap(x)
#else
#define ntohs(x) ((USHORT)(x))
#define htons(x) ((USHORT)(x))
#define ntohl(x) ((ULONG)(x))
#define htonl(x) ((ULONG)(x))
#endif

398
windows/TapDriver6/error.c Normal file
View File

@@ -0,0 +1,398 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
#include "tap.h"
//-----------------
// DEBUGGING OUTPUT
//-----------------
const char *g_LastErrorFilename;
int g_LastErrorLineNumber;
#if DBG
DebugOutput g_Debug;
BOOLEAN
NewlineExists (const char *str, int len)
{
while (len-- > 0)
{
const char c = *str++;
if (c == '\n')
return TRUE;
else if (c == '\0')
break;
}
return FALSE;
}
VOID
MyDebugInit (unsigned int bufsiz)
{
NdisZeroMemory (&g_Debug, sizeof (g_Debug));
g_Debug.text = (char *) MemAlloc (bufsiz, FALSE);
if (g_Debug.text)
{
g_Debug.capacity = bufsiz;
}
}
VOID
MyDebugFree ()
{
if (g_Debug.text)
{
MemFree (g_Debug.text, g_Debug.capacity);
}
NdisZeroMemory (&g_Debug, sizeof (g_Debug));
}
VOID
MyDebugPrint (const unsigned char* format, ...)
{
if (g_Debug.text && g_Debug.capacity > 0 && CAN_WE_PRINT)
{
BOOLEAN owned;
ACQUIRE_MUTEX_ADAPTIVE (&g_Debug.lock, owned);
if (owned)
{
const int remaining = (int)g_Debug.capacity - (int)g_Debug.out;
if (remaining > 0)
{
va_list args;
NTSTATUS status;
char *end;
#ifdef DBG_PRINT
va_start (args, format);
vDbgPrintEx (DPFLTR_IHVNETWORK_ID, DPFLTR_INFO_LEVEL, format, args);
va_end (args);
#endif
va_start (args, format);
status = RtlStringCchVPrintfExA (g_Debug.text + g_Debug.out,
remaining,
&end,
NULL,
STRSAFE_NO_TRUNCATION | STRSAFE_IGNORE_NULLS,
format,
args);
va_end (args);
va_start (args, format);
vDbgPrintEx(DPFLTR_IHVDRIVER_ID , 1, format, args);
va_end (args);
if (status == STATUS_SUCCESS)
g_Debug.out = (unsigned int) (end - g_Debug.text);
else
g_Debug.error = TRUE;
}
else
g_Debug.error = TRUE;
RELEASE_MUTEX (&g_Debug.lock);
}
else
g_Debug.error = TRUE;
}
}
BOOLEAN
GetDebugLine (
__in char *buf,
__in const int len
)
{
static const char *truncated = "[OUTPUT TRUNCATED]\n";
BOOLEAN ret = FALSE;
NdisZeroMemory (buf, len);
if (g_Debug.text && g_Debug.capacity > 0)
{
BOOLEAN owned;
ACQUIRE_MUTEX_ADAPTIVE (&g_Debug.lock, owned);
if (owned)
{
int i = 0;
if (g_Debug.error || NewlineExists (g_Debug.text + g_Debug.in, (int)g_Debug.out - (int)g_Debug.in))
{
while (i < (len - 1) && g_Debug.in < g_Debug.out)
{
const char c = g_Debug.text[g_Debug.in++];
if (c == '\n')
break;
buf[i++] = c;
}
if (i < len)
buf[i] = '\0';
}
if (!i)
{
if (g_Debug.in == g_Debug.out)
{
g_Debug.in = g_Debug.out = 0;
if (g_Debug.error)
{
const unsigned int tlen = strlen (truncated);
if (tlen < g_Debug.capacity)
{
NdisMoveMemory (g_Debug.text, truncated, tlen+1);
g_Debug.out = tlen;
}
g_Debug.error = FALSE;
}
}
}
else
ret = TRUE;
RELEASE_MUTEX (&g_Debug.lock);
}
}
return ret;
}
VOID
PrMac (const MACADDR mac)
{
DEBUGP (("%x:%x:%x:%x:%x:%x",
mac[0], mac[1], mac[2],
mac[3], mac[4], mac[5]));
}
VOID
PrIP (IPADDR ip_addr)
{
const unsigned char *ip = (const unsigned char *) &ip_addr;
DEBUGP (("%d.%d.%d.%d",
ip[0], ip[1], ip[2], ip[3]));
}
const char *
PrIPProto (int proto)
{
switch (proto)
{
case IPPROTO_UDP:
return "UDP";
case IPPROTO_TCP:
return "TCP";
case IPPROTO_ICMP:
return "ICMP";
case IPPROTO_IGMP:
return "IGMP";
default:
return "???";
}
}
VOID
DumpARP (const char *prefix, const ARP_PACKET *arp)
{
DEBUGP (("%s ARP src=", prefix));
PrMac (arp->m_MAC_Source);
DEBUGP ((" dest="));
PrMac (arp->m_MAC_Destination);
DEBUGP ((" OP=0x%04x",
(int)ntohs(arp->m_ARP_Operation)));
DEBUGP ((" M=0x%04x(%d)",
(int)ntohs(arp->m_MAC_AddressType),
(int)arp->m_MAC_AddressSize));
DEBUGP ((" P=0x%04x(%d)",
(int)ntohs(arp->m_PROTO_AddressType),
(int)arp->m_PROTO_AddressSize));
DEBUGP ((" MacSrc="));
PrMac (arp->m_ARP_MAC_Source);
DEBUGP ((" MacDest="));
PrMac (arp->m_ARP_MAC_Destination);
DEBUGP ((" IPSrc="));
PrIP (arp->m_ARP_IP_Source);
DEBUGP ((" IPDest="));
PrIP (arp->m_ARP_IP_Destination);
DEBUGP (("\n"));
}
struct ethpayload
{
ETH_HEADER eth;
UCHAR payload[DEFAULT_PACKET_LOOKAHEAD];
};
#ifdef ALLOW_PACKET_DUMP
VOID
DumpPacket2(
__in const char *prefix,
__in const ETH_HEADER *eth,
__in const unsigned char *data,
__in unsigned int len
)
{
struct ethpayload *ep = (struct ethpayload *) MemAlloc (sizeof (struct ethpayload), TRUE);
if (ep)
{
if (len > DEFAULT_PACKET_LOOKAHEAD)
len = DEFAULT_PACKET_LOOKAHEAD;
ep->eth = *eth;
NdisMoveMemory (ep->payload, data, len);
DumpPacket (prefix, (unsigned char *) ep, sizeof (ETH_HEADER) + len);
MemFree (ep, sizeof (struct ethpayload));
}
}
VOID
DumpPacket(
__in const char *prefix,
__in const unsigned char *data,
__in unsigned int len
)
{
const ETH_HEADER *eth = (const ETH_HEADER *) data;
const IPHDR *ip = (const IPHDR *) (data + sizeof (ETH_HEADER));
if (len < sizeof (ETH_HEADER))
{
DEBUGP (("%s TRUNCATED PACKET LEN=%d\n", prefix, len));
return;
}
// ARP Packet?
if (len >= sizeof (ARP_PACKET) && eth->proto == htons (ETH_P_ARP))
{
DumpARP (prefix, (const ARP_PACKET *) data);
return;
}
// IPv4 packet?
if (len >= (sizeof (IPHDR) + sizeof (ETH_HEADER))
&& eth->proto == htons (ETH_P_IP)
&& IPH_GET_VER (ip->version_len) == 4)
{
const int hlen = IPH_GET_LEN (ip->version_len);
const int blen = len - sizeof (ETH_HEADER);
BOOLEAN did = FALSE;
DEBUGP (("%s IPv4 %s[%d]", prefix, PrIPProto (ip->protocol), len));
if (!(ntohs (ip->tot_len) == blen && hlen <= blen))
{
DEBUGP ((" XXX"));
return;
}
// TCP packet?
if (ip->protocol == IPPROTO_TCP
&& blen - hlen >= (sizeof (TCPHDR)))
{
const TCPHDR *tcp = (TCPHDR *) (data + sizeof (ETH_HEADER) + hlen);
DEBUGP ((" "));
PrIP (ip->saddr);
DEBUGP ((":%d", ntohs (tcp->source)));
DEBUGP ((" -> "));
PrIP (ip->daddr);
DEBUGP ((":%d", ntohs (tcp->dest)));
did = TRUE;
}
// UDP packet?
else if ((ntohs (ip->frag_off) & IP_OFFMASK) == 0
&& ip->protocol == IPPROTO_UDP
&& blen - hlen >= (sizeof (UDPHDR)))
{
const UDPHDR *udp = (UDPHDR *) (data + sizeof (ETH_HEADER) + hlen);
// DHCP packet?
if ((udp->dest == htons (BOOTPC_PORT) || udp->dest == htons (BOOTPS_PORT))
&& blen - hlen >= (sizeof (UDPHDR) + sizeof (DHCP)))
{
const DHCP *dhcp = (DHCP *) (data
+ hlen
+ sizeof (ETH_HEADER)
+ sizeof (UDPHDR));
int optlen = len
- sizeof (ETH_HEADER)
- hlen
- sizeof (UDPHDR)
- sizeof (DHCP);
if (optlen < 0)
optlen = 0;
DumpDHCP (eth, ip, udp, dhcp, optlen);
did = TRUE;
}
if (!did)
{
DEBUGP ((" "));
PrIP (ip->saddr);
DEBUGP ((":%d", ntohs (udp->source)));
DEBUGP ((" -> "));
PrIP (ip->daddr);
DEBUGP ((":%d", ntohs (udp->dest)));
did = TRUE;
}
}
if (!did)
{
DEBUGP ((" ipproto=%d ", ip->protocol));
PrIP (ip->saddr);
DEBUGP ((" -> "));
PrIP (ip->daddr);
}
DEBUGP (("\n"));
return;
}
{
DEBUGP (("%s ??? src=", prefix));
PrMac (eth->src);
DEBUGP ((" dest="));
PrMac (eth->dest);
DEBUGP ((" proto=0x%04x len=%d\n",
(int) ntohs(eth->proto),
len));
}
}
#endif // ALLOW_PACKET_DUMP
#endif

114
windows/TapDriver6/error.h Normal file
View File

@@ -0,0 +1,114 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
//-----------------
// DEBUGGING OUTPUT
//-----------------
extern const char *g_LastErrorFilename;
extern int g_LastErrorLineNumber;
// Debug info output
#define ALSO_DBGPRINT 1
#define DEBUGP_AT_DISPATCH 1
// Uncomment line below to allow packet dumps
//#define ALLOW_PACKET_DUMP 1
#define NOTE_ERROR() \
{ \
g_LastErrorFilename = __FILE__; \
g_LastErrorLineNumber = __LINE__; \
}
#if DBG
typedef struct
{
unsigned int in;
unsigned int out;
unsigned int capacity;
char *text;
BOOLEAN error;
MUTEX lock;
} DebugOutput;
VOID MyDebugPrint (const unsigned char* format, ...);
VOID PrMac (const MACADDR mac);
VOID PrIP (IPADDR ip_addr);
#ifdef ALLOW_PACKET_DUMP
VOID
DumpPacket(
__in const char *prefix,
__in const unsigned char *data,
__in unsigned int len
);
DumpPacket2(
__in const char *prefix,
__in const ETH_HEADER *eth,
__in const unsigned char *data,
__in unsigned int len
);
#else
#define DUMP_PACKET(prefix, data, len)
#define DUMP_PACKET2(prefix, eth, data, len)
#endif
#define CAN_WE_PRINT (DEBUGP_AT_DISPATCH || KeGetCurrentIrql () < DISPATCH_LEVEL)
#if ALSO_DBGPRINT
#define DEBUGP(fmt) { MyDebugPrint fmt; if (CAN_WE_PRINT) DbgPrint fmt; }
#else
#define DEBUGP(fmt) { MyDebugPrint fmt; }
#endif
#ifdef ALLOW_PACKET_DUMP
#define DUMP_PACKET(prefix, data, len) \
DumpPacket (prefix, data, len)
#define DUMP_PACKET2(prefix, eth, data, len) \
DumpPacket2 (prefix, eth, data, len)
#endif
BOOLEAN
GetDebugLine (
__in char *buf,
__in const int len
);
#else
#define DEBUGP(fmt)
#define DUMP_PACKET(prefix, data, len)
#define DUMP_PACKET2(prefix, eth, data, len)
#endif

View File

@@ -0,0 +1,63 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
#ifndef HEXDUMP_DEFINED
#define HEXDUMP_DEFINED
#ifdef __cplusplus
extern "C" {
#endif
//=====================================================================================
// Debug Routines
//=====================================================================================
#ifndef NDIS_MINIPORT_DRIVER
# include <stdio.h>
# include <ctype.h>
# include <windows.h>
# include <winnt.h>
# include <memory.h>
# ifndef DEBUGP
# define DEBUGP(fmt) { DbgMessage fmt; }
# endif
extern VOID (*DbgMessage)(char *p_Format, ...);
VOID DisplayDebugString (char *p_Format, ...);
#endif
//===================================================================================
// Reporting / Debugging
//===================================================================================
#define IfPrint(c) (c >= 32 && c < 127 ? c : '.')
VOID HexDump (unsigned char *p_Buffer, unsigned long p_Size);
#ifdef __cplusplus
}
#endif
#endif

75
windows/TapDriver6/lock.h Normal file
View File

@@ -0,0 +1,75 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
typedef struct
{
volatile long count;
} MUTEX;
#define MUTEX_SLEEP_TIME 10000 // microseconds
#define INIT_MUTEX(m) { (m)->count = 0; }
#define ACQUIRE_MUTEX_BLOCKING(m) \
{ \
while (NdisInterlockedIncrement (&((m)->count)) != 1) \
{ \
NdisInterlockedDecrement(&((m)->count)); \
NdisMSleep(MUTEX_SLEEP_TIME); \
} \
}
#define RELEASE_MUTEX(m) \
{ \
NdisInterlockedDecrement(&((m)->count)); \
}
#define ACQUIRE_MUTEX_NONBLOCKING(m, result) \
{ \
if (NdisInterlockedIncrement (&((m)->count)) != 1) \
{ \
NdisInterlockedDecrement(&((m)->count)); \
result = FALSE; \
} \
else \
{ \
result = TRUE; \
} \
}
#define ACQUIRE_MUTEX_ADAPTIVE(m, result) \
{ \
result = TRUE; \
while (NdisInterlockedIncrement (&((m)->count)) != 1) \
{ \
NdisInterlockedDecrement(&((m)->count)); \
if (KeGetCurrentIrql () < DISPATCH_LEVEL) \
NdisMSleep(MUTEX_SLEEP_TIME); \
else \
{ \
result = FALSE; \
break; \
} \
} \
}

View File

@@ -0,0 +1,164 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
#include "tap.h"
int
HexStringToDecimalInt (const int p_Character)
{
int l_Value = 0;
if (p_Character >= 'A' && p_Character <= 'F')
l_Value = (p_Character - 'A') + 10;
else if (p_Character >= 'a' && p_Character <= 'f')
l_Value = (p_Character - 'a') + 10;
else if (p_Character >= '0' && p_Character <= '9')
l_Value = p_Character - '0';
return l_Value;
}
BOOLEAN
ParseMAC (MACADDR dest, const char *src)
{
int c;
int mac_index = 0;
BOOLEAN high_digit = FALSE;
int delim_action = 1;
ASSERT (src);
ASSERT (dest);
CLEAR_MAC (dest);
while (c = *src++)
{
if (IsMacDelimiter (c))
{
mac_index += delim_action;
high_digit = FALSE;
delim_action = 1;
}
else if (IsHexDigit (c))
{
const int digit = HexStringToDecimalInt (c);
if (mac_index < sizeof (MACADDR))
{
if (!high_digit)
{
dest[mac_index] = (char)(digit);
high_digit = TRUE;
delim_action = 1;
}
else
{
dest[mac_index] = (char)(dest[mac_index] * 16 + digit);
++mac_index;
high_digit = FALSE;
delim_action = 0;
}
}
else
return FALSE;
}
else
return FALSE;
}
return (mac_index + delim_action) >= sizeof (MACADDR);
}
/*
* Generate a MAC using the GUID in the adapter name.
*
* The mac is constructed as 00:FF:xx:xx:xx:xx where
* the Xs are taken from the first 32 bits of the GUID in the
* adapter name. This is similar to the Linux 2.4 tap MAC
* generator, except linux uses 32 random bits for the Xs.
*
* In general, this solution is reasonable for most
* applications except for very large bridged TAP networks,
* where the probability of address collisions becomes more
* than infintesimal.
*
* Using the well-known "birthday paradox", on a 1000 node
* network the probability of collision would be
* 0.000116292153. On a 10,000 node network, the probability
* of collision would be 0.01157288998621678766.
*/
VOID
GenerateRandomMac(
__in MACADDR mac,
__in const unsigned char *adapter_name
)
{
unsigned const char *cp = adapter_name;
unsigned char c;
unsigned int i = 2;
unsigned int byte = 0;
int brace = 0;
int state = 0;
CLEAR_MAC (mac);
mac[0] = 0x00;
mac[1] = 0xFF;
while (c = *cp++)
{
if (i >= sizeof (MACADDR))
break;
if (c == '{')
brace = 1;
if (IsHexDigit (c) && brace)
{
const unsigned int digit = HexStringToDecimalInt (c);
if (state)
{
byte <<= 4;
byte |= digit;
mac[i++] = (unsigned char) byte;
state = 0;
}
else
{
byte = digit;
state = 1;
}
}
}
}
VOID
GenerateRelatedMAC(
__in MACADDR dest,
__in const MACADDR src,
__in const int delta
)
{
ETH_COPY_NETWORK_ADDRESS (dest, src);
dest[2] += (UCHAR) delta;
}

View File

@@ -0,0 +1,53 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
#ifndef MacInfoDefined
#define MacInfoDefined
//===================================================================================
// Macros
//===================================================================================
#define IsMacDelimiter(a) (a == ':' || a == '-' || a == '.')
#define IsHexDigit(c) ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'))
#define CLEAR_MAC(dest) NdisZeroMemory ((dest), sizeof (MACADDR))
#define MAC_EQUAL(a,b) (memcmp ((a), (b), sizeof (MACADDR)) == 0)
BOOLEAN
ParseMAC (MACADDR dest, const char *src);
VOID
GenerateRandomMac(
__in MACADDR mac,
__in const unsigned char *adapter_name
);
VOID
GenerateRelatedMAC(
__in MACADDR dest,
__in const MACADDR src,
__in const int delta
);
#endif

401
windows/TapDriver6/mem.c Normal file
View File

@@ -0,0 +1,401 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
//------------------
// Memory Management
//------------------
#include "tap.h"
PVOID
MemAlloc(
__in ULONG p_Size,
__in BOOLEAN zero
)
{
PVOID l_Return = NULL;
if (p_Size)
{
__try
{
if (NdisAllocateMemoryWithTag (&l_Return, p_Size, 'APAT')
== NDIS_STATUS_SUCCESS)
{
if (zero)
{
NdisZeroMemory (l_Return, p_Size);
}
}
else
{
l_Return = NULL;
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
l_Return = NULL;
}
}
return l_Return;
}
VOID
MemFree(
__in PVOID p_Addr,
__in ULONG p_Size
)
{
if (p_Addr && p_Size)
{
__try
{
#if DBG
NdisZeroMemory (p_Addr, p_Size);
#endif
NdisFreeMemory (p_Addr, p_Size, 0);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
}
}
}
//======================================================================
// TAP Packet Queue Support
//======================================================================
VOID
tapPacketQueueInsertTail(
__in PTAP_PACKET_QUEUE TapPacketQueue,
__in PTAP_PACKET TapPacket
)
{
KIRQL irql;
KeAcquireSpinLock(&TapPacketQueue->QueueLock,&irql);
InsertTailList(&TapPacketQueue->Queue,&TapPacket->QueueLink);
// BUGBUG!!! Enforce PACKET_QUEUE_SIZE queue count limit???
// For NDIS 6 there is no per-packet status, so this will need to
// be handled on per-NBL basis in AdapterSendNetBufferLists...
// Update counts
++TapPacketQueue->Count;
if(TapPacketQueue->Count > TapPacketQueue->MaxCount)
{
TapPacketQueue->MaxCount = TapPacketQueue->Count;
DEBUGP (("[TAP] tapPacketQueueInsertTail: New MAX queued packet count = %d\n",
TapPacketQueue->MaxCount));
}
KeReleaseSpinLock(&TapPacketQueue->QueueLock,irql);
}
// Call with QueueLock held
PTAP_PACKET
tapPacketRemoveHeadLocked(
__in PTAP_PACKET_QUEUE TapPacketQueue
)
{
PTAP_PACKET tapPacket = NULL;
PLIST_ENTRY listEntry;
listEntry = RemoveHeadList(&TapPacketQueue->Queue);
if(listEntry != &TapPacketQueue->Queue)
{
tapPacket = CONTAINING_RECORD(listEntry, TAP_PACKET, QueueLink);
// Update counts
--TapPacketQueue->Count;
}
return tapPacket;
}
PTAP_PACKET
tapPacketRemoveHead(
__in PTAP_PACKET_QUEUE TapPacketQueue
)
{
PTAP_PACKET tapPacket = NULL;
KIRQL irql;
KeAcquireSpinLock(&TapPacketQueue->QueueLock,&irql);
tapPacket = tapPacketRemoveHeadLocked(TapPacketQueue);
KeReleaseSpinLock(&TapPacketQueue->QueueLock,irql);
return tapPacket;
}
VOID
tapPacketQueueInitialize(
__in PTAP_PACKET_QUEUE TapPacketQueue
)
{
KeInitializeSpinLock(&TapPacketQueue->QueueLock);
NdisInitializeListHead(&TapPacketQueue->Queue);
}
//======================================================================
// TAP Cancel-Safe Queue Support
//======================================================================
VOID
tapIrpCsqInsert (
__in struct _IO_CSQ *Csq,
__in PIRP Irp
)
{
PTAP_IRP_CSQ tapIrpCsq;
tapIrpCsq = (PTAP_IRP_CSQ )Csq;
InsertTailList(
&tapIrpCsq->Queue,
&Irp->Tail.Overlay.ListEntry
);
// Update counts
++tapIrpCsq->Count;
if(tapIrpCsq->Count > tapIrpCsq->MaxCount)
{
tapIrpCsq->MaxCount = tapIrpCsq->Count;
DEBUGP (("[TAP] tapIrpCsqInsert: New MAX queued IRP count = %d\n",
tapIrpCsq->MaxCount));
}
}
VOID
tapIrpCsqRemoveIrp(
__in PIO_CSQ Csq,
__in PIRP Irp
)
{
PTAP_IRP_CSQ tapIrpCsq;
tapIrpCsq = (PTAP_IRP_CSQ )Csq;
// Update counts
--tapIrpCsq->Count;
RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
}
PIRP
tapIrpCsqPeekNextIrp(
__in PIO_CSQ Csq,
__in PIRP Irp,
__in PVOID PeekContext
)
{
PTAP_IRP_CSQ tapIrpCsq;
PIRP nextIrp = NULL;
PLIST_ENTRY nextEntry;
PLIST_ENTRY listHead;
PIO_STACK_LOCATION irpStack;
tapIrpCsq = (PTAP_IRP_CSQ )Csq;
listHead = &tapIrpCsq->Queue;
//
// If the IRP is NULL, we will start peeking from the listhead, else
// we will start from that IRP onwards. This is done under the
// assumption that new IRPs are always inserted at the tail.
//
if (Irp == NULL)
{
nextEntry = listHead->Flink;
}
else
{
nextEntry = Irp->Tail.Overlay.ListEntry.Flink;
}
while(nextEntry != listHead)
{
nextIrp = CONTAINING_RECORD(nextEntry, IRP, Tail.Overlay.ListEntry);
irpStack = IoGetCurrentIrpStackLocation(nextIrp);
//
// If context is present, continue until you find a matching one.
// Else you break out as you got next one.
//
if (PeekContext)
{
if (irpStack->FileObject == (PFILE_OBJECT) PeekContext)
{
break;
}
}
else
{
break;
}
nextIrp = NULL;
nextEntry = nextEntry->Flink;
}
return nextIrp;
}
//
// tapIrpCsqAcquireQueueLock modifies the execution level of the current processor.
//
// KeAcquireSpinLock raises the execution level to Dispatch Level and stores
// the current execution level in the Irql parameter to be restored at a later
// time. KeAcqurieSpinLock also requires us to be running at no higher than
// Dispatch level when it is called.
//
// The annotations reflect these changes and requirments.
//
__drv_raisesIRQL(DISPATCH_LEVEL)
__drv_maxIRQL(DISPATCH_LEVEL)
VOID
tapIrpCsqAcquireQueueLock(
__in PIO_CSQ Csq,
__out PKIRQL Irql
)
{
PTAP_IRP_CSQ tapIrpCsq;
tapIrpCsq = (PTAP_IRP_CSQ )Csq;
//
// Suppressing because the address below csq is valid since it's
// part of TAP_ADAPTER_CONTEXT structure.
//
#pragma prefast(suppress: __WARNING_BUFFER_UNDERFLOW, "Underflow using expression 'adapter->PendingReadCsqQueueLock'")
KeAcquireSpinLock(&tapIrpCsq->QueueLock, Irql);
}
//
// tapIrpCsqReleaseQueueLock modifies the execution level of the current processor.
//
// KeReleaseSpinLock assumes we already hold the spin lock and are therefore
// running at Dispatch level. It will use the Irql parameter saved in a
// previous call to KeAcquireSpinLock to return the thread back to it's original
// execution level.
//
// The annotations reflect these changes and requirments.
//
__drv_requiresIRQL(DISPATCH_LEVEL)
VOID
tapIrpCsqReleaseQueueLock(
__in PIO_CSQ Csq,
__in KIRQL Irql
)
{
PTAP_IRP_CSQ tapIrpCsq;
tapIrpCsq = (PTAP_IRP_CSQ )Csq;
//
// Suppressing because the address below csq is valid since it's
// part of TAP_ADAPTER_CONTEXT structure.
//
#pragma prefast(suppress: __WARNING_BUFFER_UNDERFLOW, "Underflow using expression 'adapter->PendingReadCsqQueueLock'")
KeReleaseSpinLock(&tapIrpCsq->QueueLock, Irql);
}
VOID
tapIrpCsqCompleteCanceledIrp(
__in PIO_CSQ pCsq,
__in PIRP Irp
)
{
UNREFERENCED_PARAMETER(pCsq);
Irp->IoStatus.Status = STATUS_CANCELLED;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
VOID
tapIrpCsqInitialize(
__in PTAP_IRP_CSQ TapIrpCsq
)
{
KeInitializeSpinLock(&TapIrpCsq->QueueLock);
NdisInitializeListHead(&TapIrpCsq->Queue);
IoCsqInitialize(
&TapIrpCsq->CsqQueue,
tapIrpCsqInsert,
tapIrpCsqRemoveIrp,
tapIrpCsqPeekNextIrp,
tapIrpCsqAcquireQueueLock,
tapIrpCsqReleaseQueueLock,
tapIrpCsqCompleteCanceledIrp
);
}
VOID
tapIrpCsqFlush(
__in PTAP_IRP_CSQ TapIrpCsq
)
{
PIRP pendingIrp;
//
// Flush the pending read IRP queue.
//
pendingIrp = IoCsqRemoveNextIrp(
&TapIrpCsq->CsqQueue,
NULL
);
while(pendingIrp)
{
// Cancel the IRP
pendingIrp->IoStatus.Information = 0;
pendingIrp->IoStatus.Status = STATUS_CANCELLED;
IoCompleteRequest(pendingIrp, IO_NO_INCREMENT);
pendingIrp = IoCsqRemoveNextIrp(
&TapIrpCsq->CsqQueue,
NULL
);
}
ASSERT(IsListEmpty(&TapIrpCsq->Queue));
}

113
windows/TapDriver6/mem.h Normal file
View File

@@ -0,0 +1,113 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
//------------------
// Memory Management
//------------------
PVOID
MemAlloc(
__in ULONG p_Size,
__in BOOLEAN zero
);
VOID
MemFree(
__in PVOID p_Addr,
__in ULONG p_Size
);
//======================================================================
// TAP Packet Queue
//======================================================================
typedef
struct _TAP_PACKET
{
LIST_ENTRY QueueLink;
# define TAP_PACKET_SIZE(data_size) (sizeof (TAP_PACKET) + (data_size))
# define TP_TUN 0x80000000
# define TP_SIZE_MASK (~TP_TUN)
ULONG m_SizeFlags;
// m_Data must be the last struct member
UCHAR m_Data [];
} TAP_PACKET, *PTAP_PACKET;
#define TAP_PACKET_TAG '6PAT' // "TAP6"
typedef struct _TAP_PACKET_QUEUE
{
KSPIN_LOCK QueueLock;
LIST_ENTRY Queue;
ULONG Count; // Count of currently queued items
ULONG MaxCount;
} TAP_PACKET_QUEUE, *PTAP_PACKET_QUEUE;
VOID
tapPacketQueueInsertTail(
__in PTAP_PACKET_QUEUE TapPacketQueue,
__in PTAP_PACKET TapPacket
);
// Call with QueueLock held
PTAP_PACKET
tapPacketRemoveHeadLocked(
__in PTAP_PACKET_QUEUE TapPacketQueue
);
PTAP_PACKET
tapPacketRemoveHead(
__in PTAP_PACKET_QUEUE TapPacketQueue
);
VOID
tapPacketQueueInitialize(
__in PTAP_PACKET_QUEUE TapPacketQueue
);
//----------------------
// Cancel-Safe IRP Queue
//----------------------
typedef struct _TAP_IRP_CSQ
{
IO_CSQ CsqQueue;
KSPIN_LOCK QueueLock;
LIST_ENTRY Queue;
ULONG Count; // Count of currently queued items
ULONG MaxCount;
} TAP_IRP_CSQ, *PTAP_IRP_CSQ;
VOID
tapIrpCsqInitialize(
__in PTAP_IRP_CSQ TapIrpCsq
);
VOID
tapIrpCsqFlush(
__in PTAP_IRP_CSQ TapIrpCsq
);

File diff suppressed because it is too large Load Diff

224
windows/TapDriver6/proto.h Normal file
View File

@@ -0,0 +1,224 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
//============================================================
// MAC address, Ethernet header, and ARP
//============================================================
#pragma pack(1)
#define IP_HEADER_SIZE 20
#define IPV6_HEADER_SIZE 40
#define MACADDR_SIZE 6
typedef unsigned char MACADDR[MACADDR_SIZE];
typedef unsigned long IPADDR;
typedef unsigned char IPV6ADDR[16];
//-----------------
// Ethernet address
//-----------------
typedef struct {
MACADDR addr;
} ETH_ADDR;
typedef struct {
ETH_ADDR list[TAP_MAX_MCAST_LIST];
} MC_LIST;
// BUGBUG!!! Consider using ststem defines in netiodef.h!!!
//----------------
// Ethernet header
//----------------
typedef struct
{
MACADDR dest; /* destination eth addr */
MACADDR src; /* source ether addr */
USHORT proto; /* packet type ID field */
} ETH_HEADER, *PETH_HEADER;
//----------------
// ARP packet
//----------------
typedef struct
{
MACADDR m_MAC_Destination; // Reverse these two
MACADDR m_MAC_Source; // to answer ARP requests
USHORT m_Proto; // 0x0806
# define MAC_ADDR_TYPE 0x0001
USHORT m_MAC_AddressType; // 0x0001
USHORT m_PROTO_AddressType; // 0x0800
UCHAR m_MAC_AddressSize; // 0x06
UCHAR m_PROTO_AddressSize; // 0x04
# define ARP_REQUEST 0x0001
# define ARP_REPLY 0x0002
USHORT m_ARP_Operation; // 0x0001 for ARP request, 0x0002 for ARP reply
MACADDR m_ARP_MAC_Source;
IPADDR m_ARP_IP_Source;
MACADDR m_ARP_MAC_Destination;
IPADDR m_ARP_IP_Destination;
}
ARP_PACKET, *PARP_PACKET;
//----------
// IP Header
//----------
typedef struct {
# define IPH_GET_VER(v) (((v) >> 4) & 0x0F)
# define IPH_GET_LEN(v) (((v) & 0x0F) << 2)
UCHAR version_len;
UCHAR tos;
USHORT tot_len;
USHORT id;
# define IP_OFFMASK 0x1fff
USHORT frag_off;
UCHAR ttl;
# define IPPROTO_UDP 17 /* UDP protocol */
# define IPPROTO_TCP 6 /* TCP protocol */
# define IPPROTO_ICMP 1 /* ICMP protocol */
# define IPPROTO_IGMP 2 /* IGMP protocol */
UCHAR protocol;
USHORT check;
ULONG saddr;
ULONG daddr;
/* The options start here. */
} IPHDR;
//-----------
// UDP header
//-----------
typedef struct {
USHORT source;
USHORT dest;
USHORT len;
USHORT check;
} UDPHDR;
//--------------------------
// TCP header, per RFC 793.
//--------------------------
typedef struct {
USHORT source; /* source port */
USHORT dest; /* destination port */
ULONG seq; /* sequence number */
ULONG ack_seq; /* acknowledgement number */
# define TCPH_GET_DOFF(d) (((d) & 0xF0) >> 2)
UCHAR doff_res;
# define TCPH_FIN_MASK (1<<0)
# define TCPH_SYN_MASK (1<<1)
# define TCPH_RST_MASK (1<<2)
# define TCPH_PSH_MASK (1<<3)
# define TCPH_ACK_MASK (1<<4)
# define TCPH_URG_MASK (1<<5)
# define TCPH_ECE_MASK (1<<6)
# define TCPH_CWR_MASK (1<<7)
UCHAR flags;
USHORT window;
USHORT check;
USHORT urg_ptr;
} TCPHDR;
#define TCPOPT_EOL 0
#define TCPOPT_NOP 1
#define TCPOPT_MAXSEG 2
#define TCPOLEN_MAXSEG 4
//------------
// IPv6 Header
//------------
typedef struct {
UCHAR version_prio;
UCHAR flow_lbl[3];
USHORT payload_len;
# define IPPROTO_ICMPV6 0x3a /* ICMP protocol v6 */
UCHAR nexthdr;
UCHAR hop_limit;
IPV6ADDR saddr;
IPV6ADDR daddr;
} IPV6HDR;
//--------------------------------------------
// IPCMPv6 NS/NA Packets (RFC4443 and RFC4861)
//--------------------------------------------
// Neighbor Solictiation - RFC 4861, 4.3
// (this is just the ICMPv6 part of the packet)
typedef struct {
UCHAR type;
# define ICMPV6_TYPE_NS 135 // neighbour solicitation
UCHAR code;
# define ICMPV6_CODE_0 0 // no specific sub-code for NS/NA
USHORT checksum;
ULONG reserved;
IPV6ADDR target_addr;
} ICMPV6_NS;
// Neighbor Advertisement - RFC 4861, 4.4 + 4.6/4.6.1
// (this is just the ICMPv6 payload)
typedef struct {
UCHAR type;
# define ICMPV6_TYPE_NA 136 // neighbour advertisement
UCHAR code;
# define ICMPV6_CODE_0 0 // no specific sub-code for NS/NA
USHORT checksum;
UCHAR rso_bits; // Router(0), Solicited(2), Ovrrd(4)
UCHAR reserved[3];
IPV6ADDR target_addr;
// always include "Target Link-layer Address" option (RFC 4861 4.6.1)
UCHAR opt_type;
#define ICMPV6_OPTION_TLLA 2
UCHAR opt_length;
#define ICMPV6_LENGTH_TLLA 1 // multiplied by 8 -> 1 = 8 bytes
MACADDR target_macaddr;
} ICMPV6_NA;
// this is the complete packet with Ethernet and IPv6 headers
typedef struct {
ETH_HEADER eth;
IPV6HDR ipv6;
ICMPV6_NA icmpv6;
} ICMPV6_NA_PKT;
#pragma pack()

View File

@@ -0,0 +1,91 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
#ifndef TAP_PROTOTYPES_DEFINED
#define TAP_PROTOTYPES_DEFINED
DRIVER_INITIALIZE DriverEntry;
//VOID AdapterFreeResources
// (
// TapAdapterPointer p_Adapter
// );
//
//
//NTSTATUS TapDeviceHook
// (
// IN PDEVICE_OBJECT p_DeviceObject,
// IN PIRP p_IRP
// );
//
NDIS_STATUS
CreateTapDevice(
__in PTAP_ADAPTER_CONTEXT Adapter
);
VOID
DestroyTapDevice(
__in PTAP_ADAPTER_CONTEXT Adapter
);
// Flush the pending send TAP packet queue.
VOID
tapFlushSendPacketQueue(
__in PTAP_ADAPTER_CONTEXT Adapter
);
VOID
IndicateReceivePacket(
__in PTAP_ADAPTER_CONTEXT Adapter,
__in PUCHAR packetData,
__in const unsigned int packetLength
);
/*
BOOLEAN
ProcessDHCP(
__in PTAP_ADAPTER_CONTEXT Adapter,
__in const ETH_HEADER *eth,
__in const IPHDR *ip,
__in const UDPHDR *udp,
__in const DHCP *dhcp,
__in int optlen
);
*/
/*
BOOLEAN
ProcessARP(
__in PTAP_ADAPTER_CONTEXT Adapter,
__in const PARP_PACKET src,
__in const IPADDR adapter_ip,
__in const IPADDR ip_network,
__in const IPADDR ip_netmask,
__in const MACADDR mac
);
*/
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,88 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,0,0,0
PRODUCTVERSION 3,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x9L
#else
FILEFLAGS 0x8L
#endif
FILEOS 0x40004L
FILETYPE 0x3L
FILESUBTYPE 0x6L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "ZeroTier Networks LLC"
VALUE "FileDescription", "ZeroTier One Virtual Network Port"
VALUE "FileVersion", "3.0.0 3/0"
VALUE "InternalName", "zttap300.sys"
VALUE "LegalCopyright", "ZeroTier, Inc., OpenVPN Technologies, Inc."
VALUE "OriginalFilename", "zttap300.sys"
VALUE "ProductName", "ZeroTier One Virtual Network Port"
VALUE "ProductVersion", "3.0.0 3/0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

669
windows/TapDriver6/rxpath.c Normal file
View File

@@ -0,0 +1,669 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
//
// Include files.
//
#include "tap.h"
//======================================================================
// TAP Receive Path Support
//======================================================================
#ifdef ALLOC_PRAGMA
#pragma alloc_text( PAGE, TapDeviceWrite)
#endif // ALLOC_PRAGMA
//===============================================================
// Used in cases where internally generated packets such as
// ARP or DHCP replies must be returned to the kernel, to be
// seen as an incoming packet "arriving" on the interface.
//===============================================================
VOID
IndicateReceivePacket(
__in PTAP_ADAPTER_CONTEXT Adapter,
__in PUCHAR packetData,
__in const unsigned int packetLength
)
{
PUCHAR injectBuffer;
//
// Handle miniport Pause
// ---------------------
// NDIS 6 miniports implement a temporary "Pause" state normally followed
// by the Restart. While in the Pause state it is forbidden for the miniport
// to indicate receive NBLs.
//
// That is: The device interface may be "up", but the NDIS miniport send/receive
// interface may be temporarily "down".
//
// BUGBUG!!! In the initial implementation of the NDIS 6 TapOas inject path
// the code below will simply ignore inject packets passed to the driver while
// the miniport is in the Paused state.
//
// The correct implementation is to go ahead and build the NBLs corresponding
// to the inject packet - but queue them. When Restart is entered the
// queued NBLs would be dequeued and indicated to the host.
//
if(tapAdapterSendAndReceiveReady(Adapter) != NDIS_STATUS_SUCCESS)
{
DEBUGP (("[%s] Lying send in IndicateReceivePacket while adapter paused\n",
MINIPORT_INSTANCE_ID (Adapter)));
return;
}
// Allocate flat buffer for packet data.
injectBuffer = (PUCHAR )NdisAllocateMemoryWithTagPriority(
Adapter->MiniportAdapterHandle,
packetLength,
TAP_RX_INJECT_BUFFER_TAG,
NormalPoolPriority
);
if( injectBuffer)
{
PMDL mdl;
// Copy packet data to flat buffer.
NdisMoveMemory (injectBuffer, packetData, packetLength);
// Allocate MDL for flat buffer.
mdl = NdisAllocateMdl(
Adapter->MiniportAdapterHandle,
injectBuffer,
packetLength
);
if( mdl )
{
PNET_BUFFER_LIST netBufferList;
mdl->Next = NULL; // No next MDL
// Allocate the NBL and NB. Link MDL chain to NB.
netBufferList = NdisAllocateNetBufferAndNetBufferList(
Adapter->ReceiveNblPool,
0, // ContextSize
0, // ContextBackFill
mdl, // MDL chain
0,
packetLength
);
if(netBufferList != NULL)
{
ULONG receiveFlags = 0;
LONG nblCount;
NET_BUFFER_LIST_NEXT_NBL(netBufferList) = NULL; // Only one NBL
if(KeGetCurrentIrql() == DISPATCH_LEVEL)
{
receiveFlags |= NDIS_RECEIVE_FLAGS_DISPATCH_LEVEL;
}
// Set flag indicating that this is an injected packet
TAP_RX_NBL_FLAGS_CLEAR_ALL(netBufferList);
TAP_RX_NBL_FLAG_SET(netBufferList,TAP_RX_NBL_FLAGS_IS_INJECTED);
netBufferList->MiniportReserved[0] = NULL;
netBufferList->MiniportReserved[1] = NULL;
// Increment in-flight receive NBL count.
nblCount = NdisInterlockedIncrement(&Adapter->ReceiveNblInFlightCount);
ASSERT(nblCount > 0 );
netBufferList->SourceHandle = Adapter->MiniportAdapterHandle;
//
// Indicate the packet
// -------------------
// Irp->AssociatedIrp.SystemBuffer with length irpSp->Parameters.Write.Length
// contains the complete packet including Ethernet header and payload.
//
NdisMIndicateReceiveNetBufferLists(
Adapter->MiniportAdapterHandle,
netBufferList,
NDIS_DEFAULT_PORT_NUMBER,
1, // NumberOfNetBufferLists
receiveFlags
);
return;
}
else
{
DEBUGP (("[%s] NdisAllocateNetBufferAndNetBufferList failed in IndicateReceivePacket\n",
MINIPORT_INSTANCE_ID (Adapter)));
NOTE_ERROR ();
NdisFreeMdl(mdl);
NdisFreeMemory(injectBuffer,0,0);
}
}
else
{
DEBUGP (("[%s] NdisAllocateMdl failed in IndicateReceivePacket\n",
MINIPORT_INSTANCE_ID (Adapter)));
NOTE_ERROR ();
NdisFreeMemory(injectBuffer,0,0);
}
}
else
{
DEBUGP (("[%s] NdisAllocateMemoryWithTagPriority failed in IndicateReceivePacket\n",
MINIPORT_INSTANCE_ID (Adapter)));
NOTE_ERROR ();
}
}
VOID
tapCompleteIrpAndFreeReceiveNetBufferList(
__in PTAP_ADAPTER_CONTEXT Adapter,
__in PNET_BUFFER_LIST NetBufferList, // Only one NB here...
__in NTSTATUS IoCompletionStatus
)
{
PIRP irp;
ULONG frameType, netBufferCount, byteCount;
LONG nblCount;
// Fetch NB frame type.
frameType = tapGetNetBufferFrameType(NET_BUFFER_LIST_FIRST_NB(NetBufferList));
// Fetch statistics for all NBs linked to the NB.
netBufferCount = tapGetNetBufferCountsFromNetBufferList(
NetBufferList,
&byteCount
);
// Update statistics by frame type
if(IoCompletionStatus == STATUS_SUCCESS)
{
switch(frameType)
{
case NDIS_PACKET_TYPE_DIRECTED:
Adapter->FramesRxDirected += netBufferCount;
Adapter->BytesRxDirected += byteCount;
break;
case NDIS_PACKET_TYPE_BROADCAST:
Adapter->FramesRxBroadcast += netBufferCount;
Adapter->BytesRxBroadcast += byteCount;
break;
case NDIS_PACKET_TYPE_MULTICAST:
Adapter->FramesRxMulticast += netBufferCount;
Adapter->BytesRxMulticast += byteCount;
break;
default:
ASSERT(FALSE);
break;
}
}
//
// Handle P2P Packet
// -----------------
// Free MDL allocated for P2P Ethernet header.
//
if(TAP_RX_NBL_FLAG_TEST(NetBufferList,TAP_RX_NBL_FLAGS_IS_P2P))
{
PNET_BUFFER netBuffer;
PMDL mdl;
netBuffer = NET_BUFFER_LIST_FIRST_NB(NetBufferList);
mdl = NET_BUFFER_FIRST_MDL(netBuffer);
mdl->Next = NULL;
NdisFreeMdl(mdl);
}
//
// Handle Injected Packet
// -----------------------
// Free MDL and data buffer allocated for injected packet.
//
if(TAP_RX_NBL_FLAG_TEST(NetBufferList,TAP_RX_NBL_FLAGS_IS_INJECTED))
{
PNET_BUFFER netBuffer;
PMDL mdl;
PUCHAR injectBuffer;
netBuffer = NET_BUFFER_LIST_FIRST_NB(NetBufferList);
mdl = NET_BUFFER_FIRST_MDL(netBuffer);
injectBuffer = (PUCHAR )MmGetSystemAddressForMdlSafe(mdl,NormalPagePriority);
if(injectBuffer)
{
NdisFreeMemory(injectBuffer,0,0);
}
NdisFreeMdl(mdl);
}
//
// Complete the IRP
//
irp = (PIRP )NetBufferList->MiniportReserved[0];
if(irp)
{
irp->IoStatus.Status = IoCompletionStatus;
IoCompleteRequest(irp, IO_NO_INCREMENT);
}
// Decrement in-flight receive NBL count.
nblCount = NdisInterlockedDecrement(&Adapter->ReceiveNblInFlightCount);
ASSERT(nblCount >= 0 );
if (0 == nblCount)
{
NdisSetEvent(&Adapter->ReceiveNblInFlightCountZeroEvent);
}
// Free the NBL
NdisFreeNetBufferList(NetBufferList);
}
VOID
AdapterReturnNetBufferLists(
__in NDIS_HANDLE MiniportAdapterContext,
__in PNET_BUFFER_LIST NetBufferLists,
__in ULONG ReturnFlags
)
{
PTAP_ADAPTER_CONTEXT adapter = (PTAP_ADAPTER_CONTEXT )MiniportAdapterContext;
PNET_BUFFER_LIST currentNbl, nextNbl;
UNREFERENCED_PARAMETER(ReturnFlags);
//
// Process each NBL individually
//
currentNbl = NetBufferLists;
while (currentNbl)
{
PNET_BUFFER_LIST nextNbl;
nextNbl = NET_BUFFER_LIST_NEXT_NBL(currentNbl);
NET_BUFFER_LIST_NEXT_NBL(currentNbl) = NULL;
// Complete write IRP and free NBL and associated resources.
tapCompleteIrpAndFreeReceiveNetBufferList(
adapter,
currentNbl,
STATUS_SUCCESS
);
// Move to next NBL
currentNbl = nextNbl;
}
}
// IRP_MJ_WRITE callback.
NTSTATUS
TapDeviceWrite(
PDEVICE_OBJECT DeviceObject,
PIRP Irp
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;// Assume success
PIO_STACK_LOCATION irpSp;// Pointer to current stack location
PTAP_ADAPTER_CONTEXT adapter = NULL;
ULONG dataLength;
PAGED_CODE();
irpSp = IoGetCurrentIrpStackLocation( Irp );
//
// Fetch adapter context for this device.
// --------------------------------------
// Adapter pointer was stashed in FsContext when handle was opened.
//
adapter = (PTAP_ADAPTER_CONTEXT )(irpSp->FileObject)->FsContext;
ASSERT(adapter);
//
// Sanity checks on state variables
//
if (!tapAdapterReadAndWriteReady(adapter))
{
//DEBUGP (("[%s] Interface is down in IRP_MJ_WRITE\n",
// MINIPORT_INSTANCE_ID (adapter)));
//NOTE_ERROR();
Irp->IoStatus.Status = ntStatus = STATUS_CANCELLED;
Irp->IoStatus.Information = 0;
IoCompleteRequest (Irp, IO_NO_INCREMENT);
return ntStatus;
}
// Save IRP-accessible copy of buffer length
Irp->IoStatus.Information = irpSp->Parameters.Write.Length;
if (Irp->MdlAddress == NULL)
{
DEBUGP (("[%s] MdlAddress is NULL for IRP_MJ_WRITE\n",
MINIPORT_INSTANCE_ID (adapter)));
NOTE_ERROR();
Irp->IoStatus.Status = ntStatus = STATUS_INVALID_PARAMETER;
Irp->IoStatus.Information = 0;
IoCompleteRequest (Irp, IO_NO_INCREMENT);
return ntStatus;
}
//
// Try to get a virtual address for the MDL.
//
NdisQueryMdl(
Irp->MdlAddress,
&Irp->AssociatedIrp.SystemBuffer,
&dataLength,
NormalPagePriority
);
if (Irp->AssociatedIrp.SystemBuffer == NULL)
{
DEBUGP (("[%s] Could not map address in IRP_MJ_WRITE\n",
MINIPORT_INSTANCE_ID (adapter)));
NOTE_ERROR();
Irp->IoStatus.Status = ntStatus = STATUS_INSUFFICIENT_RESOURCES;
Irp->IoStatus.Information = 0;
IoCompleteRequest (Irp, IO_NO_INCREMENT);
return ntStatus;
}
ASSERT(dataLength == irpSp->Parameters.Write.Length);
Irp->IoStatus.Information = irpSp->Parameters.Write.Length;
//
// Handle miniport Pause
// ---------------------
// NDIS 6 miniports implement a temporary "Pause" state normally followed
// by the Restart. While in the Pause state it is forbidden for the miniport
// to indicate receive NBLs.
//
// That is: The device interface may be "up", but the NDIS miniport send/receive
// interface may be temporarily "down".
//
// BUGBUG!!! In the initial implementation of the NDIS 6 TapOas receive path
// the code below will perform a "lying send" for write IRPs passed to the
// driver while the miniport is in the Paused state.
//
// The correct implementation is to go ahead and build the NBLs corresponding
// to the user-mode write - but queue them. When Restart is entered the
// queued NBLs would be dequeued and indicated to the host.
//
if(tapAdapterSendAndReceiveReady(adapter) == NDIS_STATUS_SUCCESS)
{
if (/*!adapter->m_tun &&*/ ((irpSp->Parameters.Write.Length) >= ETHERNET_HEADER_SIZE))
{
PNET_BUFFER_LIST netBufferList;
DUMP_PACKET ("IRP_MJ_WRITE ETH",
(unsigned char *) Irp->AssociatedIrp.SystemBuffer,
irpSp->Parameters.Write.Length);
//=====================================================
// If IPv4 packet, check whether or not packet
// was truncated.
//=====================================================
#if PACKET_TRUNCATION_CHECK
IPv4PacketSizeVerify (
(unsigned char *) Irp->AssociatedIrp.SystemBuffer,
irpSp->Parameters.Write.Length,
FALSE,
"RX",
&adapter->m_RxTrunc
);
#endif
(Irp->MdlAddress)->Next = NULL; // No next MDL
// Allocate the NBL and NB. Link MDL chain to NB.
netBufferList = NdisAllocateNetBufferAndNetBufferList(
adapter->ReceiveNblPool,
0, // ContextSize
0, // ContextBackFill
Irp->MdlAddress, // MDL chain
0,
dataLength
);
if(netBufferList != NULL)
{
LONG nblCount;
NET_BUFFER_LIST_NEXT_NBL(netBufferList) = NULL; // Only one NBL
// Stash IRP pointer in NBL MiniportReserved[0] field.
netBufferList->MiniportReserved[0] = Irp;
netBufferList->MiniportReserved[1] = NULL;
// This IRP is pended.
IoMarkIrpPending(Irp);
// This IRP cannot be cancelled while in-flight.
IoSetCancelRoutine(Irp,NULL);
TAP_RX_NBL_FLAGS_CLEAR_ALL(netBufferList);
// Increment in-flight receive NBL count.
nblCount = NdisInterlockedIncrement(&adapter->ReceiveNblInFlightCount);
ASSERT(nblCount > 0 );
//
// Indicate the packet
// -------------------
// Irp->AssociatedIrp.SystemBuffer with length irpSp->Parameters.Write.Length
// contains the complete packet including Ethernet header and payload.
//
NdisMIndicateReceiveNetBufferLists(
adapter->MiniportAdapterHandle,
netBufferList,
NDIS_DEFAULT_PORT_NUMBER,
1, // NumberOfNetBufferLists
0 // ReceiveFlags
);
ntStatus = STATUS_PENDING;
}
else
{
DEBUGP (("[%s] NdisMIndicateReceiveNetBufferLists failed in IRP_MJ_WRITE\n",
MINIPORT_INSTANCE_ID (adapter)));
NOTE_ERROR ();
// Fail the IRP
Irp->IoStatus.Information = 0;
ntStatus = STATUS_INSUFFICIENT_RESOURCES;
}
}
/*
else if (adapter->m_tun && ((irpSp->Parameters.Write.Length) >= IP_HEADER_SIZE))
{
PETH_HEADER p_UserToTap = &adapter->m_UserToTap;
PMDL mdl; // Head of MDL chain.
// For IPv6, need to use Ethernet header with IPv6 proto
if ( IPH_GET_VER( ((IPHDR*) Irp->AssociatedIrp.SystemBuffer)->version_len) == 6 )
{
p_UserToTap = &adapter->m_UserToTap_IPv6;
}
DUMP_PACKET2 ("IRP_MJ_WRITE P2P",
p_UserToTap,
(unsigned char *) Irp->AssociatedIrp.SystemBuffer,
irpSp->Parameters.Write.Length);
//=====================================================
// If IPv4 packet, check whether or not packet
// was truncated.
//=====================================================
#if PACKET_TRUNCATION_CHECK
IPv4PacketSizeVerify (
(unsigned char *) Irp->AssociatedIrp.SystemBuffer,
irpSp->Parameters.Write.Length,
TRUE,
"RX",
&adapter->m_RxTrunc
);
#endif
//
// Allocate MDL for Ethernet header
// --------------------------------
// Irp->AssociatedIrp.SystemBuffer with length irpSp->Parameters.Write.Length
// contains the only the Ethernet payload. Prepend the user-mode provided
// payload with the Ethernet header pointed to by p_UserToTap.
//
mdl = NdisAllocateMdl(
adapter->MiniportAdapterHandle,
p_UserToTap,
sizeof(ETH_HEADER)
);
if(mdl != NULL)
{
PNET_BUFFER_LIST netBufferList;
// Chain user's Ethernet payload behind Ethernet header.
mdl->Next = Irp->MdlAddress;
(Irp->MdlAddress)->Next = NULL; // No next MDL
// Allocate the NBL and NB. Link MDL chain to NB.
netBufferList = NdisAllocateNetBufferAndNetBufferList(
adapter->ReceiveNblPool,
0, // ContextSize
0, // ContextBackFill
mdl, // MDL chain
0,
sizeof(ETH_HEADER) + dataLength
);
if(netBufferList != NULL)
{
LONG nblCount;
NET_BUFFER_LIST_NEXT_NBL(netBufferList) = NULL; // Only one NBL
// This IRP is pended.
IoMarkIrpPending(Irp);
// This IRP cannot be cancelled while in-flight.
IoSetCancelRoutine(Irp,NULL);
// Stash IRP pointer in NBL MiniportReserved[0] field.
netBufferList->MiniportReserved[0] = Irp;
netBufferList->MiniportReserved[1] = NULL;
// Set flag indicating that this is P2P packet
TAP_RX_NBL_FLAGS_CLEAR_ALL(netBufferList);
TAP_RX_NBL_FLAG_SET(netBufferList,TAP_RX_NBL_FLAGS_IS_P2P);
// Increment in-flight receive NBL count.
nblCount = NdisInterlockedIncrement(&adapter->ReceiveNblInFlightCount);
ASSERT(nblCount > 0 );
//
// Indicate the packet
//
NdisMIndicateReceiveNetBufferLists(
adapter->MiniportAdapterHandle,
netBufferList,
NDIS_DEFAULT_PORT_NUMBER,
1, // NumberOfNetBufferLists
0 // ReceiveFlags
);
ntStatus = STATUS_PENDING;
}
else
{
mdl->Next = NULL;
NdisFreeMdl(mdl);
DEBUGP (("[%s] NdisMIndicateReceiveNetBufferLists failed in IRP_MJ_WRITE\n",
MINIPORT_INSTANCE_ID (adapter)));
NOTE_ERROR ();
// Fail the IRP
Irp->IoStatus.Information = 0;
ntStatus = STATUS_INSUFFICIENT_RESOURCES;
}
}
else
{
DEBUGP (("[%s] NdisAllocateMdl failed in IRP_MJ_WRITE\n",
MINIPORT_INSTANCE_ID (adapter)));
NOTE_ERROR ();
// Fail the IRP
Irp->IoStatus.Information = 0;
ntStatus = STATUS_INSUFFICIENT_RESOURCES;
}
}
*/
else
{
DEBUGP (("[%s] Bad buffer size in IRP_MJ_WRITE, len=%d\n",
MINIPORT_INSTANCE_ID (adapter),
irpSp->Parameters.Write.Length));
NOTE_ERROR ();
Irp->IoStatus.Information = 0; // ETHERNET_HEADER_SIZE;
Irp->IoStatus.Status = ntStatus = STATUS_BUFFER_TOO_SMALL;
}
}
else
{
DEBUGP (("[%s] Lying send in IRP_MJ_WRITE while adapter paused\n",
MINIPORT_INSTANCE_ID (adapter)));
ntStatus = STATUS_SUCCESS;
}
if (ntStatus != STATUS_PENDING)
{
Irp->IoStatus.Status = ntStatus;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
return ntStatus;
}

View File

@@ -0,0 +1,83 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
#ifndef __TAP_WIN_H
#define __TAP_WIN_H
/*
* =============
* TAP IOCTLs
* =============
*/
#define TAP_WIN_CONTROL_CODE(request,method) \
CTL_CODE (FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS)
/* Present in 8.1 */
#define TAP_WIN_IOCTL_GET_MAC TAP_WIN_CONTROL_CODE (1, METHOD_BUFFERED)
#define TAP_WIN_IOCTL_GET_VERSION TAP_WIN_CONTROL_CODE (2, METHOD_BUFFERED)
#define TAP_WIN_IOCTL_GET_MTU TAP_WIN_CONTROL_CODE (3, METHOD_BUFFERED)
//#define TAP_WIN_IOCTL_GET_INFO TAP_WIN_CONTROL_CODE (4, METHOD_BUFFERED)
//#define TAP_WIN_IOCTL_CONFIG_POINT_TO_POINT TAP_WIN_CONTROL_CODE (5, METHOD_BUFFERED)
#define TAP_WIN_IOCTL_SET_MEDIA_STATUS TAP_WIN_CONTROL_CODE (6, METHOD_BUFFERED)
//#define TAP_WIN_IOCTL_CONFIG_DHCP_MASQ TAP_WIN_CONTROL_CODE (7, METHOD_BUFFERED)
#if DBG
#define TAP_WIN_IOCTL_GET_LOG_LINE TAP_WIN_CONTROL_CODE (8, METHOD_BUFFERED)
#endif
//#define TAP_WIN_IOCTL_CONFIG_DHCP_SET_OPT TAP_WIN_CONTROL_CODE (9, METHOD_BUFFERED)
/* Added in 8.2 */
/* obsoletes TAP_WIN_IOCTL_CONFIG_POINT_TO_POINT */
//#define TAP_WIN_IOCTL_CONFIG_TUN TAP_WIN_CONTROL_CODE (10, METHOD_BUFFERED)
// Used by ZT1 to get multicast memberships at the L2 level -- Windows provides no native way to do this that I know of
#define TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS TAP_WIN_CONTROL_CODE (11, METHOD_BUFFERED)
// Must be the same as NIC_MAX_MCAST_LIST in constants.h
#define TAP_MAX_MCAST_LIST 128
// Amount of memory that must be provided to ioctl TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS
#define TAP_WIN_IOCTL_GET_MULTICAST_MEMBERSHIPS_OUTPUT_BUF_SIZE (TAP_MAX_MCAST_LIST * 6)
/*
* =================
* Registry keys
* =================
*/
#define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
#define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
/*
* ======================
* Filesystem prefixes
* ======================
*/
#define USERMODEDEVICEDIR "\\\\.\\Global\\"
#define SYSDEVICEDIR "\\Device\\"
#define USERDEVICEDIR "\\DosDevices\\Global\\"
#define TAP_WIN_SUFFIX ".tap"
#endif // __TAP_WIN_H

89
windows/TapDriver6/tap.h Normal file
View File

@@ -0,0 +1,89 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
#ifndef __TAP_H
#define __TAP_H
#ifndef NDIS_SUPPORT_NDIS6
#define NDIS_MINIPORT_DRIVER 1
#define NDIS_SUPPORT_NDIS6 1
#define NDIS_SUPPORT_NDIS630 1
#define NDIS_WDM1 1
#define NDIS630_MINIPORT 1
#endif
#include <ntifs.h>
#include <ndis.h>
#include <ntstrsafe.h>
#include <netioapi.h>
#include "config.h"
#include "lock.h"
#include "constants.h"
#include "proto.h"
#include "mem.h"
#include "macinfo.h"
#include "error.h"
#include "endian.h"
#include "types.h"
#include "adapter.h"
#include "device.h"
#include "prototypes.h"
#include "tap-windows.h"
//========================================================
// Check for truncated IPv4 packets, log errors if found.
//========================================================
#define PACKET_TRUNCATION_CHECK 0
//========================================================
// EXPERIMENTAL -- Configure TAP device object to be
// accessible from non-administrative accounts, based
// on an advanced properties setting.
//
// Duplicates the functionality of OpenVPN's
// --allow-nonadmin directive.
//========================================================
#define ENABLE_NONADMIN 0
//
// The driver has exactly one instance of the TAP_GLOBAL structure. NDIS keeps
// an opaque handle to this data, (it doesn't attempt to read or interpret this
// data), and it passes the handle back to the miniport in MiniportSetOptions
// and MiniportInitializeEx.
//
typedef struct _TAP_GLOBAL
{
LIST_ENTRY AdapterList;
NDIS_RW_LOCK Lock;
NDIS_HANDLE NdisDriverHandle; // From NdisMRegisterMiniportDriver
} TAP_GLOBAL, *PTAP_GLOBAL;
// Global data
extern TAP_GLOBAL GlobalData;
#endif // __TAP_H

View File

@@ -0,0 +1,232 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
//======================================================
// This driver is designed to work on Windows Vista or higher
// versions of Windows.
//
// It is SMP-safe and handles power management.
//
// By default we operate as a "tap" virtual ethernet
// 802.3 interface, but we can emulate a "tun"
// interface (point-to-point IPv4) through the
// TAP_WIN_IOCTL_CONFIG_POINT_TO_POINT or
// TAP_WIN_IOCTL_CONFIG_TUN ioctl.
//======================================================
//
// Include files.
//
#include <string.h>
#include "tap.h"
// Global data
TAP_GLOBAL GlobalData;
#ifdef ALLOC_PRAGMA
#pragma alloc_text( INIT, DriverEntry )
#pragma alloc_text( PAGE, TapDriverUnload)
#endif // ALLOC_PRAGMA
NTSTATUS
DriverEntry(
__in PDRIVER_OBJECT DriverObject,
__in PUNICODE_STRING RegistryPath
)
/*++
Routine Description:
In the context of its DriverEntry function, a miniport driver associates
itself with NDIS, specifies the NDIS version that it is using, and
registers its entry points.
Arguments:
PVOID DriverObject - pointer to the driver object.
PVOID RegistryPath - pointer to the driver registry path.
Return Value:
NTSTATUS code
--*/
{
NTSTATUS status;
UNREFERENCED_PARAMETER(RegistryPath);
DEBUGP (("[TAP] --> DriverEntry; version [%d.%d] %s %s\n",
TAP_DRIVER_MAJOR_VERSION,
TAP_DRIVER_MINOR_VERSION,
__DATE__,
__TIME__));
DEBUGP (("[TAP] Registry Path: '%wZ'\n", RegistryPath));
//
// Initialize any driver-global variables here.
//
NdisZeroMemory(&GlobalData, sizeof(GlobalData));
//
// The ApaterList in the GlobalData structure is used to track multiple
// adapters controlled by this miniport.
//
NdisInitializeListHead(&GlobalData.AdapterList);
//
// This lock protects the AdapterList.
//
NdisInitializeReadWriteLock(&GlobalData.Lock);
do
{
NDIS_MINIPORT_DRIVER_CHARACTERISTICS miniportCharacteristics;
NdisZeroMemory(&miniportCharacteristics, sizeof(miniportCharacteristics));
{C_ASSERT(sizeof(miniportCharacteristics) >= NDIS_SIZEOF_MINIPORT_DRIVER_CHARACTERISTICS_REVISION_2);}
miniportCharacteristics.Header.Type = NDIS_OBJECT_TYPE_MINIPORT_DRIVER_CHARACTERISTICS;
miniportCharacteristics.Header.Size = NDIS_SIZEOF_MINIPORT_DRIVER_CHARACTERISTICS_REVISION_2;
miniportCharacteristics.Header.Revision = NDIS_MINIPORT_DRIVER_CHARACTERISTICS_REVISION_2;
miniportCharacteristics.MajorNdisVersion = TAP_NDIS_MAJOR_VERSION;
miniportCharacteristics.MinorNdisVersion = TAP_NDIS_MINOR_VERSION;
miniportCharacteristics.MajorDriverVersion = TAP_DRIVER_MAJOR_VERSION;
miniportCharacteristics.MinorDriverVersion = TAP_DRIVER_MINOR_VERSION;
miniportCharacteristics.Flags = 0;
//miniportCharacteristics.SetOptionsHandler = MPSetOptions; // Optional
miniportCharacteristics.InitializeHandlerEx = AdapterCreate;
miniportCharacteristics.HaltHandlerEx = AdapterHalt;
miniportCharacteristics.UnloadHandler = TapDriverUnload;
miniportCharacteristics.PauseHandler = AdapterPause;
miniportCharacteristics.RestartHandler = AdapterRestart;
miniportCharacteristics.OidRequestHandler = AdapterOidRequest;
miniportCharacteristics.SendNetBufferListsHandler = AdapterSendNetBufferLists;
miniportCharacteristics.ReturnNetBufferListsHandler = AdapterReturnNetBufferLists;
miniportCharacteristics.CancelSendHandler = AdapterCancelSend;
miniportCharacteristics.CheckForHangHandlerEx = AdapterCheckForHangEx;
miniportCharacteristics.ResetHandlerEx = AdapterReset;
miniportCharacteristics.DevicePnPEventNotifyHandler = AdapterDevicePnpEventNotify;
miniportCharacteristics.ShutdownHandlerEx = AdapterShutdownEx;
miniportCharacteristics.CancelOidRequestHandler = AdapterCancelOidRequest;
//
// Associate the miniport driver with NDIS by calling the
// NdisMRegisterMiniportDriver. This function returns an NdisDriverHandle.
// The miniport driver must retain this handle but it should never attempt
// to access or interpret this handle.
//
// By calling NdisMRegisterMiniportDriver, the driver indicates that it
// is ready for NDIS to call the driver's MiniportSetOptions and
// MiniportInitializeEx handlers.
//
DEBUGP (("[TAP] Calling NdisMRegisterMiniportDriver...\n"));
//NDIS_DECLARE_MINIPORT_DRIVER_CONTEXT(TAP_GLOBAL);
status = NdisMRegisterMiniportDriver(
DriverObject,
RegistryPath,
&GlobalData,
&miniportCharacteristics,
&GlobalData.NdisDriverHandle
);
if (NDIS_STATUS_SUCCESS == status)
{
DEBUGP (("[TAP] Registered miniport successfully\n"));
}
else
{
DEBUGP(("[TAP] NdisMRegisterMiniportDriver failed: %8.8X\n", status));
TapDriverUnload(DriverObject);
status = NDIS_STATUS_FAILURE;
break;
}
} while(FALSE);
DEBUGP (("[TAP] <-- DriverEntry; status = %8.8X\n",status));
return status;
}
VOID
TapDriverUnload(
__in PDRIVER_OBJECT DriverObject
)
/*++
Routine Description:
The unload handler is called during driver unload to free up resources
acquired in DriverEntry. This handler is registered in DriverEntry through
NdisMRegisterMiniportDriver. Note that an unload handler differs from
a MiniportHalt function in that this unload handler releases resources that
are global to the driver, while the halt handler releases resource for a
particular adapter.
Runs at IRQL = PASSIVE_LEVEL.
Arguments:
DriverObject Not used
Return Value:
None.
--*/
{
PDEVICE_OBJECT deviceObject = DriverObject->DeviceObject;
UNICODE_STRING uniWin32NameString;
DEBUGP (("[TAP] --> TapDriverUnload; version [%d.%d] %s %s unloaded\n",
TAP_DRIVER_MAJOR_VERSION,
TAP_DRIVER_MINOR_VERSION,
__DATE__,
__TIME__
));
PAGED_CODE();
//
// Clean up all globals that were allocated in DriverEntry
//
ASSERT(IsListEmpty(&GlobalData.AdapterList));
if(GlobalData.NdisDriverHandle != NULL )
{
NdisMDeregisterMiniportDriver(GlobalData.NdisDriverHandle);
}
DEBUGP (("[TAP] <-- TapDriverUnload\n"));
}

1175
windows/TapDriver6/txpath.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,90 @@
/*
* TAP-Windows -- A kernel driver to provide virtual tap
* device functionality on Windows.
*
* This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
*
* This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
* 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 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
*/
#ifndef TAP_TYPES_DEFINED
#define TAP_TYPES_DEFINED
//typedef
//struct _Queue
//{
// ULONG base;
// ULONG size;
// ULONG capacity;
// ULONG max_size;
// PVOID data[];
//} Queue;
//typedef struct _TAP_PACKET;
//typedef struct _TapExtension
//{
// // TAP device object and packet queues
// Queue *m_PacketQueue, *m_IrpQueue;
// PDEVICE_OBJECT m_TapDevice;
// NDIS_HANDLE m_TapDeviceHandle;
// ULONG TapFileIsOpen;
//
// // Used to lock packet queues
// NDIS_SPIN_LOCK m_QueueLock;
// BOOLEAN m_AllocatedSpinlocks;
//
// // Used to bracket open/close
// // state changes.
// MUTEX m_OpenCloseMutex;
//
// // True if device has been permanently halted
// BOOLEAN m_Halt;
//
// // TAP device name
// unsigned char *m_TapName;
// UNICODE_STRING m_UnicodeLinkName;
// BOOLEAN m_CreatedUnicodeLinkName;
//
// // Used for device status ioctl only
// const char *m_LastErrorFilename;
// int m_LastErrorLineNumber;
// LONG TapFileOpenCount;
//
// // Flags
// BOOLEAN TapDeviceCreated;
// BOOLEAN m_CalledTapDeviceFreeResources;
//
// // DPC queue for deferred packet injection
// BOOLEAN m_InjectDpcInitialized;
// KDPC m_InjectDpc;
// NDIS_SPIN_LOCK m_InjectLock;
// Queue *m_InjectQueue;
//}
//TapExtension, *TapExtensionPointer;
typedef struct _InjectPacket
{
# define INJECT_PACKET_SIZE(data_size) (sizeof (InjectPacket) + (data_size))
# define INJECT_PACKET_FREE(ib) NdisFreeMemory ((ib), INJECT_PACKET_SIZE ((ib)->m_Size), 0)
ULONG m_Size;
UCHAR m_Data []; // m_Data must be the last struct member
}
InjectPacket, *InjectPacketPointer;
#endif

View File

@@ -0,0 +1,145 @@
;
; ****************************************************************************
; * Copyright (C) 2002-2014 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. *
; ****************************************************************************
;
;
; ZeroTier One Virtual Network Port NDIS6 Driver
;
; Modified by ZeroTier, Inc. - https://www.zerotier.com/
;
; (1) Comment out 'tun' functionality and related features such as DHCP
; emulation, since we don't use any of that. Just want straight 'tap'.
; (2) Added custom IOCTL to enumerate L2 multicast memberships.
; (3) Increase maximum number of multicast memberships to 128.
; (4) Set default and max device MTU to 2800.
; (5) Rename/rebrand driver as ZeroTier network port driver.
;
; Original copyright below. Modifications released under GPLv2 as well.
[Version]
Signature = "$Windows NT$"
CatalogFile = zttap300.cat
ClassGUID = {4d36e972-e325-11ce-bfc1-08002be10318}
Provider = %Provider%
Class = Net
DriverVer=11/24/2020,3.00.00.1
[Strings]
DeviceDescription = "ZeroTier Virtual Port"
Provider = "ZeroTier"
[Manufacturer]
%Provider%=zttap300,NTx86
%Provider%=zttap300,NTamd64
%Provider%=zttap300,NTarm64
[zttap300.NTx86]
%DeviceDescription% = zttap300.ndi, root\zttap300 ; Root enumerated
%DeviceDescription% = zttap300.ndi, zttap300 ; Legacy
[zttap300.NTamd64]
%DeviceDescription% = zttap300.ndi, root\zttap300 ; Root enumerated
%DeviceDescription% = zttap300.ndi, zttap300 ; Legacy
[zttap300.NTarm64]
%DeviceDescription% = zttap300.ndi, root\zttap300 ; Root enumerated
%DeviceDescription% = zttap300.ndi, zttap300 ; Legacy
;----------------- Characteristics ------------
; NCF_PHYSICAL = 0x04
; NCF_VIRTUAL = 0x01
; NCF_SOFTWARE_ENUMERATED = 0x02
; NCF_HIDDEN = 0x08
; NCF_NO_SERVICE = 0x10
; NCF_HAS_UI = 0x80
;----------------- Characteristics ------------
[zttap300.ndi]
CopyFiles = zttap300.driver, zttap300.files
AddReg = zttap300.reg
AddReg = zttap300.params.reg
Characteristics = 0x81
*IfType = 0x6 ; IF_TYPE_ETHERNET_CSMACD
*MediaType = 0x0 ; NdisMedium802_3
*PhysicalMediaType = 14 ; NdisPhysicalMedium802_3
[zttap300.ndi.Services]
AddService = zttap300, 2, zttap300.service
[zttap300.reg]
HKR, Ndi, Service, 0, "zttap300"
HKR, Ndi\Interfaces, UpperRange, 0, "ndis5" ; yes, 'ndis5' is correct... yup, Windows.
HKR, Ndi\Interfaces, LowerRange, 0, "ethernet"
HKR, , Manufacturer, 0, "%Provider%"
HKR, , ProductName, 0, "%DeviceDescription%"
[zttap300.params.reg]
HKR, Ndi\params\MTU, ParamDesc, 0, "MTU"
HKR, Ndi\params\MTU, Type, 0, "int"
HKR, Ndi\params\MTU, Default, 0, "2800"
HKR, Ndi\params\MTU, Optional, 0, "0"
HKR, Ndi\params\MTU, Min, 0, "100"
HKR, Ndi\params\MTU, Max, 0, "2800"
HKR, Ndi\params\MTU, Step, 0, "1"
HKR, Ndi\params\MediaStatus, ParamDesc, 0, "Media Status"
HKR, Ndi\params\MediaStatus, Type, 0, "enum"
HKR, Ndi\params\MediaStatus, Default, 0, "0"
HKR, Ndi\params\MediaStatus, Optional, 0, "0"
HKR, Ndi\params\MediaStatus\enum, "0", 0, "Application Controlled"
HKR, Ndi\params\MediaStatus\enum, "1", 0, "Always Connected"
HKR, Ndi\params\MAC, ParamDesc, 0, "MAC Address"
HKR, Ndi\params\MAC, Type, 0, "edit"
HKR, Ndi\params\MAC, Optional, 0, "1"
HKR, Ndi\params\AllowNonAdmin, ParamDesc, 0, "Non-Admin Access"
HKR, Ndi\params\AllowNonAdmin, Type, 0, "enum"
HKR, Ndi\params\AllowNonAdmin, Default, 0, "0"
HKR, Ndi\params\AllowNonAdmin, Optional, 0, "0"
HKR, Ndi\params\AllowNonAdmin\enum, "0", 0, "Not Allowed"
HKR, Ndi\params\AllowNonAdmin\enum, "1", 0, "Allowed"
;---------- Service Type -------------
; SERVICE_KERNEL_DRIVER = 0x01
; SERVICE_WIN32_OWN_PROCESS = 0x10
;---------- Service Type -------------
;---------- Start Mode ---------------
; SERVICE_BOOT_START = 0x0
; SERVICE_SYSTEM_START = 0x1
; SERVICE_AUTO_START = 0x2
; SERVICE_DEMAND_START = 0x3
; SERVICE_DISABLED = 0x4
;---------- Start Mode ---------------
[zttap300.service]
DisplayName = %DeviceDescription%
ServiceType = 1
StartType = 3
ErrorControl = 1
LoadOrderGroup = NDIS
ServiceBinary = %12%\zttap300.sys
;----------------- Copy Flags ------------
; COPYFLG_NOSKIP = 0x02
; COPYFLG_NOVERSIONCHECK = 0x04
;----------------- Copy Flags ------------
[SourceDisksNames]
1 = %DeviceDescription%, zttap300.sys
[SourceDisksFiles]
zttap300.sys = 1
[DestinationDirs]
zttap300.files = 11
zttap300.driver = 12
[zttap300.files]
;
[zttap300.driver]
zttap300.sys,,,6 ; COPYFLG_NOSKIP | COPYFLG_NOVERSIONCHECK

133
windows/ZeroTierOne.sln Normal file
View File

@@ -0,0 +1,133 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34622.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZeroTierOne", "ZeroTierOne\ZeroTierOne.vcxproj", "{B00A4957-5977-4AC1-9EF4-571DC27EADA2}"
ProjectSection(ProjectDependencies) = postProject
{175C340F-F5BA-4CB1-88AD-533B102E3799} = {175C340F-F5BA-4CB1-88AD-533B102E3799}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TapDriver6", "TapDriver6\TapDriver6.vcxproj", "{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zeroidc", "..\rustybits\zeroidc.vcxproj", "{175C340F-F5BA-4CB1-88AD-533B102E3799}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Profile|Any CPU = Profile|Any CPU
Profile|ARM = Profile|ARM
Profile|ARM64 = Profile|ARM64
Profile|Mixed Platforms = Profile|Mixed Platforms
Profile|Win32 = Profile|Win32
Profile|x64 = Profile|x64
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Debug|Any CPU.ActiveCfg = Debug|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Debug|ARM.ActiveCfg = Debug|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Debug|ARM64.ActiveCfg = Debug|ARM64
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Debug|ARM64.Build.0 = Debug|ARM64
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Debug|Mixed Platforms.Deploy.0 = Debug|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Debug|Win32.ActiveCfg = Debug|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Debug|Win32.Build.0 = Debug|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Debug|Win32.Deploy.0 = Debug|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Debug|x64.ActiveCfg = Debug|x64
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Debug|x64.Build.0 = Debug|x64
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Profile|Any CPU.ActiveCfg = Profile|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Profile|ARM.ActiveCfg = Profile|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Profile|ARM64.ActiveCfg = Profile|ARM64
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Profile|Mixed Platforms.ActiveCfg = Profile|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Profile|Mixed Platforms.Build.0 = Profile|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Profile|Win32.ActiveCfg = Profile|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Profile|Win32.Build.0 = Profile|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Profile|x64.ActiveCfg = Profile|x64
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Profile|x64.Build.0 = Profile|x64
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Release|Any CPU.ActiveCfg = Release|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Release|ARM.ActiveCfg = Release|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Release|ARM64.ActiveCfg = Release|ARM64
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Release|ARM64.Build.0 = Release|ARM64
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Release|Mixed Platforms.Build.0 = Release|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Release|Mixed Platforms.Deploy.0 = Release|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Release|Win32.ActiveCfg = Release|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Release|Win32.Build.0 = Release|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Release|Win32.Deploy.0 = Release|Win32
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Release|x64.ActiveCfg = Release|x64
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Release|x64.Build.0 = Release|x64
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|Any CPU.ActiveCfg = Win8 Debug|ARM64
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|ARM.ActiveCfg = Win8 Debug|ARM64
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|ARM64.ActiveCfg = Win8 Debug|ARM64
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|Mixed Platforms.ActiveCfg = Win8 Debug|Win32
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|Win32.ActiveCfg = Win8 Debug|Win32
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|x64.ActiveCfg = Win8 Debug|x64
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Profile|Any CPU.ActiveCfg = Win8 Debug|x64
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Profile|ARM.ActiveCfg = Win8 Debug|ARM64
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Profile|ARM64.ActiveCfg = Win8 Debug|ARM64
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Profile|Mixed Platforms.ActiveCfg = Win8 Debug|Win32
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Profile|Win32.ActiveCfg = Win8 Debug|Win32
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Profile|x64.ActiveCfg = Win8 Debug|x64
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|Any CPU.ActiveCfg = Win8 Release|Win32
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|ARM.ActiveCfg = Win8 Debug|ARM64
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|ARM64.ActiveCfg = Win8 Release|ARM64
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|Mixed Platforms.ActiveCfg = Win8 Release|Win32
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|Mixed Platforms.Build.0 = Win8 Release|Win32
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|Mixed Platforms.Deploy.0 = Win8 Release|Win32
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|Win32.ActiveCfg = Win8 Release|Win32
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|Win32.Build.0 = Win8 Release|Win32
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|Win32.Deploy.0 = Win8 Release|Win32
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|x64.ActiveCfg = Win8 Release|x64
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|x64.Build.0 = Win8 Release|x64
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|x64.Deploy.0 = Win8 Release|x64
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Debug|Any CPU.ActiveCfg = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Debug|ARM.ActiveCfg = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Debug|ARM64.ActiveCfg = Debug|ARM64
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Debug|ARM64.Build.0 = Debug|ARM64
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Debug|Win32.ActiveCfg = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Debug|Win32.Build.0 = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Debug|x64.ActiveCfg = Debug|x64
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Debug|x64.Build.0 = Debug|x64
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Profile|Any CPU.ActiveCfg = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Profile|Any CPU.Build.0 = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Profile|ARM.ActiveCfg = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Profile|ARM.Build.0 = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Profile|ARM64.ActiveCfg = Debug|ARM64
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Profile|ARM64.Build.0 = Debug|ARM64
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Profile|Mixed Platforms.ActiveCfg = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Profile|Mixed Platforms.Build.0 = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Profile|Win32.ActiveCfg = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Profile|Win32.Build.0 = Debug|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Profile|x64.ActiveCfg = Debug|x64
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Profile|x64.Build.0 = Debug|x64
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Release|Any CPU.ActiveCfg = Release|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Release|ARM.ActiveCfg = Release|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Release|ARM64.ActiveCfg = Release|ARM64
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Release|ARM64.Build.0 = Release|ARM64
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Release|Mixed Platforms.Build.0 = Release|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Release|Win32.ActiveCfg = Release|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Release|Win32.Build.0 = Release|Win32
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Release|x64.ActiveCfg = Release|x64
{175C340F-F5BA-4CB1-88AD-533B102E3799}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AD00A172-C020-4874-B00A-C396AAC893FC}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,563 @@
/****************************** Module Header ******************************\
* Module Name: ServiceBase.cpp
* Project: CppWindowsService
* Copyright (c) Microsoft Corporation.
*
* Provides a base class for a service that will exist as part of a service
* application. CServiceBase must be derived from when creating a new service
* class.
*
* This source is subject to the Microsoft Public License.
* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
* All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
#pragma region Includes
#include "ServiceBase.h"
#include <assert.h>
#include <strsafe.h>
#include <string>
#pragma endregion
#pragma region Static Members
// Initialize the singleton service instance.
CServiceBase *CServiceBase::s_service = NULL;
//
// FUNCTION: CServiceBase::Run(CServiceBase &)
//
// PURPOSE: Register the executable for a service with the Service Control
// Manager (SCM). After you call Run(ServiceBase), the SCM issues a Start
// command, which results in a call to the OnStart method in the service.
// This method blocks until the service has stopped.
//
// PARAMETERS:
// * service - the reference to a CServiceBase object. It will become the
// singleton service instance of this service application.
//
// RETURN VALUE: If the function succeeds, the return value is TRUE. If the
// function fails, the return value is FALSE. To get extended error
// information, call GetLastError.
//
BOOL CServiceBase::Run(CServiceBase &service)
{
s_service = &service;
SERVICE_TABLE_ENTRYA serviceTable[] =
{
{ service.m_name, ServiceMain },
{ NULL, NULL }
};
// Connects the main thread of a service process to the service control
// manager, which causes the thread to be the service control dispatcher
// thread for the calling process. This call returns when the service has
// stopped. The process should simply terminate when the call returns.
return StartServiceCtrlDispatcher(serviceTable);
}
//
// FUNCTION: CServiceBase::ServiceMain(DWORD, PWSTR *)
//
// PURPOSE: Entry point for the service. It registers the handler function
// for the service and starts the service.
//
// PARAMETERS:
// * dwArgc - number of command line arguments
// * lpszArgv - array of command line arguments
//
void WINAPI CServiceBase::ServiceMain(DWORD dwArgc, PSTR *pszArgv)
{
assert(s_service != NULL);
// Register the handler function for the service
s_service->m_statusHandle = RegisterServiceCtrlHandler(
s_service->m_name, ServiceCtrlHandler);
if (s_service->m_statusHandle == NULL)
{
throw GetLastError();
}
// Start the service.
s_service->Start(dwArgc, pszArgv);
}
//
// FUNCTION: CServiceBase::ServiceCtrlHandler(DWORD)
//
// PURPOSE: The function is called by the SCM whenever a control code is
// sent to the service.
//
// PARAMETERS:
// * dwCtrlCode - the control code. This parameter can be one of the
// following values:
//
// SERVICE_CONTROL_CONTINUE
// SERVICE_CONTROL_INTERROGATE
// SERVICE_CONTROL_NETBINDADD
// SERVICE_CONTROL_NETBINDDISABLE
// SERVICE_CONTROL_NETBINDREMOVE
// SERVICE_CONTROL_PARAMCHANGE
// SERVICE_CONTROL_PAUSE
// SERVICE_CONTROL_SHUTDOWN
// SERVICE_CONTROL_STOP
//
// This parameter can also be a user-defined control code ranges from 128
// to 255.
//
void WINAPI CServiceBase::ServiceCtrlHandler(DWORD dwCtrl)
{
switch (dwCtrl)
{
case SERVICE_CONTROL_STOP: s_service->Stop(); break;
case SERVICE_CONTROL_PAUSE: s_service->Pause(); break;
case SERVICE_CONTROL_CONTINUE: s_service->Continue(); break;
case SERVICE_CONTROL_SHUTDOWN: s_service->Shutdown(); break;
case SERVICE_CONTROL_INTERROGATE: break;
default: break;
}
}
#pragma endregion
#pragma region Service Constructor and Destructor
//
// FUNCTION: CServiceBase::CServiceBase(PWSTR, BOOL, BOOL, BOOL)
//
// PURPOSE: The constructor of CServiceBase. It initializes a new instance
// of the CServiceBase class. The optional parameters (fCanStop,
/// fCanShutdown and fCanPauseContinue) allow you to specify whether the
// service can be stopped, paused and continued, or be notified when system
// shutdown occurs.
//
// PARAMETERS:
// * pszServiceName - the name of the service
// * fCanStop - the service can be stopped
// * fCanShutdown - the service is notified when system shutdown occurs
// * fCanPauseContinue - the service can be paused and continued
//
CServiceBase::CServiceBase(PSTR pszServiceName,
BOOL fCanStop,
BOOL fCanShutdown,
BOOL fCanPauseContinue)
{
// Service name must be a valid string and cannot be NULL.
m_name = (pszServiceName == NULL) ? "" : pszServiceName;
m_statusHandle = NULL;
// The service runs in its own process.
m_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
// The service is starting.
m_status.dwCurrentState = SERVICE_START_PENDING;
// The accepted commands of the service.
DWORD dwControlsAccepted = 0;
if (fCanStop)
dwControlsAccepted |= SERVICE_ACCEPT_STOP;
if (fCanShutdown)
dwControlsAccepted |= SERVICE_ACCEPT_SHUTDOWN;
if (fCanPauseContinue)
dwControlsAccepted |= SERVICE_ACCEPT_PAUSE_CONTINUE;
m_status.dwControlsAccepted = dwControlsAccepted;
m_status.dwWin32ExitCode = NO_ERROR;
m_status.dwServiceSpecificExitCode = 0;
m_status.dwCheckPoint = 0;
m_status.dwWaitHint = 0;
}
//
// FUNCTION: CServiceBase::~CServiceBase()
//
// PURPOSE: The virtual destructor of CServiceBase.
//
CServiceBase::~CServiceBase(void)
{
}
#pragma endregion
#pragma region Service Start, Stop, Pause, Continue, and Shutdown
//
// FUNCTION: CServiceBase::Start(DWORD, PWSTR *)
//
// PURPOSE: The function starts the service. It calls the OnStart virtual
// function in which you can specify the actions to take when the service
// starts. If an error occurs during the startup, the error will be logged
// in the Application event log, and the service will be stopped.
//
// PARAMETERS:
// * dwArgc - number of command line arguments
// * lpszArgv - array of command line arguments
//
void CServiceBase::Start(DWORD dwArgc, PSTR *pszArgv)
{
try
{
// Tell SCM that the service is starting.
SetServiceStatus(SERVICE_START_PENDING);
// Perform service-specific initialization.
OnStart(dwArgc, pszArgv);
// Tell SCM that the service is started.
SetServiceStatus(SERVICE_RUNNING);
}
catch (DWORD dwError)
{
// Log the error.
WriteErrorLogEntry("Service Start", dwError);
// Set the service status to be stopped.
SetServiceStatus(SERVICE_STOPPED, dwError);
}
catch (...)
{
// Log the error.
WriteEventLogEntry("Service failed to start.", EVENTLOG_ERROR_TYPE);
// Set the service status to be stopped.
SetServiceStatus(SERVICE_STOPPED);
}
}
//
// FUNCTION: CServiceBase::OnStart(DWORD, PWSTR *)
//
// PURPOSE: When implemented in a derived class, executes when a Start
// command is sent to the service by the SCM or when the operating system
// starts (for a service that starts automatically). Specifies actions to
// take when the service starts. Be sure to periodically call
// CServiceBase::SetServiceStatus() with SERVICE_START_PENDING if the
// procedure is going to take long time. You may also consider spawning a
// new thread in OnStart to perform time-consuming initialization tasks.
//
// PARAMETERS:
// * dwArgc - number of command line arguments
// * lpszArgv - array of command line arguments
//
void CServiceBase::OnStart(DWORD dwArgc, PSTR *pszArgv)
{
}
//
// FUNCTION: CServiceBase::Stop()
//
// PURPOSE: The function stops the service. It calls the OnStop virtual
// function in which you can specify the actions to take when the service
// stops. If an error occurs, the error will be logged in the Application
// event log, and the service will be restored to the original state.
//
void CServiceBase::Stop()
{
DWORD dwOriginalState = m_status.dwCurrentState;
try
{
// Tell SCM that the service is stopping.
SetServiceStatus(SERVICE_STOP_PENDING);
// Perform service-specific stop operations.
OnStop();
// Tell SCM that the service is stopped.
SetServiceStatus(SERVICE_STOPPED);
}
catch (DWORD dwError)
{
// Log the error.
WriteErrorLogEntry("Service Stop", dwError);
// Set the orginal service status.
SetServiceStatus(dwOriginalState);
}
catch (...)
{
// Log the error.
WriteEventLogEntry("Service failed to stop.", EVENTLOG_ERROR_TYPE);
// Set the orginal service status.
SetServiceStatus(dwOriginalState);
}
}
//
// FUNCTION: CServiceBase::OnStop()
//
// PURPOSE: When implemented in a derived class, executes when a Stop
// command is sent to the service by the SCM. Specifies actions to take
// when a service stops running. Be sure to periodically call
// CServiceBase::SetServiceStatus() with SERVICE_STOP_PENDING if the
// procedure is going to take long time.
//
void CServiceBase::OnStop()
{
}
//
// FUNCTION: CServiceBase::Pause()
//
// PURPOSE: The function pauses the service if the service supports pause
// and continue. It calls the OnPause virtual function in which you can
// specify the actions to take when the service pauses. If an error occurs,
// the error will be logged in the Application event log, and the service
// will become running.
//
void CServiceBase::Pause()
{
try
{
// Tell SCM that the service is pausing.
SetServiceStatus(SERVICE_PAUSE_PENDING);
// Perform service-specific pause operations.
OnPause();
// Tell SCM that the service is paused.
SetServiceStatus(SERVICE_PAUSED);
}
catch (DWORD dwError)
{
// Log the error.
WriteErrorLogEntry("Service Pause", dwError);
// Tell SCM that the service is still running.
SetServiceStatus(SERVICE_RUNNING);
}
catch (...)
{
// Log the error.
WriteEventLogEntry("Service failed to pause.", EVENTLOG_ERROR_TYPE);
// Tell SCM that the service is still running.
SetServiceStatus(SERVICE_RUNNING);
}
}
//
// FUNCTION: CServiceBase::OnPause()
//
// PURPOSE: When implemented in a derived class, executes when a Pause
// command is sent to the service by the SCM. Specifies actions to take
// when a service pauses.
//
void CServiceBase::OnPause()
{
}
//
// FUNCTION: CServiceBase::Continue()
//
// PURPOSE: The function resumes normal functioning after being paused if
// the service supports pause and continue. It calls the OnContinue virtual
// function in which you can specify the actions to take when the service
// continues. If an error occurs, the error will be logged in the
// Application event log, and the service will still be paused.
//
void CServiceBase::Continue()
{
try
{
// Tell SCM that the service is resuming.
SetServiceStatus(SERVICE_CONTINUE_PENDING);
// Perform service-specific continue operations.
OnContinue();
// Tell SCM that the service is running.
SetServiceStatus(SERVICE_RUNNING);
}
catch (DWORD dwError)
{
// Log the error.
WriteErrorLogEntry("Service Continue", dwError);
// Tell SCM that the service is still paused.
SetServiceStatus(SERVICE_PAUSED);
}
catch (...)
{
// Log the error.
WriteEventLogEntry("Service failed to resume.", EVENTLOG_ERROR_TYPE);
// Tell SCM that the service is still paused.
SetServiceStatus(SERVICE_PAUSED);
}
}
//
// FUNCTION: CServiceBase::OnContinue()
//
// PURPOSE: When implemented in a derived class, OnContinue runs when a
// Continue command is sent to the service by the SCM. Specifies actions to
// take when a service resumes normal functioning after being paused.
//
void CServiceBase::OnContinue()
{
}
//
// FUNCTION: CServiceBase::Shutdown()
//
// PURPOSE: The function executes when the system is shutting down. It
// calls the OnShutdown virtual function in which you can specify what
// should occur immediately prior to the system shutting down. If an error
// occurs, the error will be logged in the Application event log.
//
void CServiceBase::Shutdown()
{
try
{
// Perform service-specific shutdown operations.
OnShutdown();
// Tell SCM that the service is stopped.
SetServiceStatus(SERVICE_STOPPED);
}
catch (DWORD dwError)
{
// Log the error.
WriteErrorLogEntry("Service Shutdown", dwError);
}
catch (...)
{
// Log the error.
WriteEventLogEntry("Service failed to shut down.", EVENTLOG_ERROR_TYPE);
}
}
//
// FUNCTION: CServiceBase::OnShutdown()
//
// PURPOSE: When implemented in a derived class, executes when the system
// is shutting down. Specifies what should occur immediately prior to the
// system shutting down.
//
void CServiceBase::OnShutdown()
{
}
#pragma endregion
#pragma region Helper Functions
//
// FUNCTION: CServiceBase::SetServiceStatus(DWORD, DWORD, DWORD)
//
// PURPOSE: The function sets the service status and reports the status to
// the SCM.
//
// PARAMETERS:
// * dwCurrentState - the state of the service
// * dwWin32ExitCode - error code to report
// * dwWaitHint - estimated time for pending operation, in milliseconds
//
void CServiceBase::SetServiceStatus(DWORD dwCurrentState,
DWORD dwWin32ExitCode,
DWORD dwWaitHint)
{
static DWORD dwCheckPoint = 1;
// Fill in the SERVICE_STATUS structure of the service.
m_status.dwCurrentState = dwCurrentState;
m_status.dwWin32ExitCode = dwWin32ExitCode;
m_status.dwWaitHint = dwWaitHint;
m_status.dwCheckPoint =
((dwCurrentState == SERVICE_RUNNING) ||
(dwCurrentState == SERVICE_STOPPED)) ?
0 : dwCheckPoint++;
// Report the status of the service to the SCM.
::SetServiceStatus(m_statusHandle, &m_status);
}
//
// FUNCTION: CServiceBase::WriteEventLogEntry(PWSTR, WORD)
//
// PURPOSE: Log a message to the Application event log.
//
// PARAMETERS:
// * pszMessage - string message to be logged.
// * wType - the type of event to be logged. The parameter can be one of
// the following values.
//
// EVENTLOG_SUCCESS
// EVENTLOG_AUDIT_FAILURE
// EVENTLOG_AUDIT_SUCCESS
// EVENTLOG_ERROR_TYPE
// EVENTLOG_INFORMATION_TYPE
// EVENTLOG_WARNING_TYPE
//
void CServiceBase::WriteEventLogEntry(PSTR pszMessage, WORD wType)
{
HANDLE hEventSource = NULL;
LPCSTR lpszStrings[2] = { NULL, NULL };
hEventSource = RegisterEventSource(NULL, m_name);
if (hEventSource)
{
lpszStrings[0] = m_name;
lpszStrings[1] = pszMessage;
ReportEvent(hEventSource, // Event log handle
wType, // Event type
0, // Event category
0, // Event identifier
NULL, // No security identifier
2, // Size of lpszStrings array
0, // No binary data
lpszStrings, // Array of strings
NULL // No binary data
);
DeregisterEventSource(hEventSource);
}
}
//
// FUNCTION: CServiceBase::WriteErrorLogEntry(PWSTR, DWORD)
//
// PURPOSE: Log an error message to the Application event log.
//
// PARAMETERS:
// * pszFunction - the function that gives the error
// * dwError - the error code
//
void CServiceBase::WriteErrorLogEntry(PSTR pszFunction, DWORD dwError)
{
char szMessage[260];
StringCchPrintf(szMessage, ARRAYSIZE(szMessage),
"%s failed w/err 0x%08lx", pszFunction, dwError);
WriteEventLogEntry(szMessage, EVENTLOG_ERROR_TYPE);
}
#pragma endregion

View File

@@ -0,0 +1,122 @@
/****************************** Module Header ******************************\
* Module Name: ServiceBase.h
* Project: CppWindowsService
* Copyright (c) Microsoft Corporation.
*
* Provides a base class for a service that will exist as part of a service
* application. CServiceBase must be derived from when creating a new service
* class.
*
* This source is subject to the Microsoft Public License.
* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
* All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
#pragma once
#include <winsock2.h>
#include <windows.h>
class CServiceBase
{
public:
// Register the executable for a service with the Service Control Manager
// (SCM). After you call Run(ServiceBase), the SCM issues a Start command,
// which results in a call to the OnStart method in the service. This
// method blocks until the service has stopped.
static BOOL Run(CServiceBase &service);
// Service object constructor. The optional parameters (fCanStop,
// fCanShutdown and fCanPauseContinue) allow you to specify whether the
// service can be stopped, paused and continued, or be notified when
// system shutdown occurs.
CServiceBase(LPSTR pszServiceName,
BOOL fCanStop = TRUE,
BOOL fCanShutdown = TRUE,
BOOL fCanPauseContinue = FALSE);
// Service object destructor.
virtual ~CServiceBase(void);
// Stop the service.
void Stop();
protected:
// When implemented in a derived class, executes when a Start command is
// sent to the service by the SCM or when the operating system starts
// (for a service that starts automatically). Specifies actions to take
// when the service starts.
virtual void OnStart(DWORD dwArgc, PSTR *pszArgv);
// When implemented in a derived class, executes when a Stop command is
// sent to the service by the SCM. Specifies actions to take when a
// service stops running.
virtual void OnStop();
// When implemented in a derived class, executes when a Pause command is
// sent to the service by the SCM. Specifies actions to take when a
// service pauses.
virtual void OnPause();
// When implemented in a derived class, OnContinue runs when a Continue
// command is sent to the service by the SCM. Specifies actions to take
// when a service resumes normal functioning after being paused.
virtual void OnContinue();
// When implemented in a derived class, executes when the system is
// shutting down. Specifies what should occur immediately prior to the
// system shutting down.
virtual void OnShutdown();
// Set the service status and report the status to the SCM.
void SetServiceStatus(DWORD dwCurrentState,
DWORD dwWin32ExitCode = NO_ERROR,
DWORD dwWaitHint = 0);
// Log a message to the Application event log.
void WriteEventLogEntry(PSTR pszMessage, WORD wType);
// Log an error message to the Application event log.
void WriteErrorLogEntry(PSTR pszFunction,
DWORD dwError = GetLastError());
private:
// Entry point for the service. It registers the handler function for the
// service and starts the service.
static void WINAPI ServiceMain(DWORD dwArgc, LPSTR *lpszArgv);
// The function is called by the SCM whenever a control code is sent to
// the service.
static void WINAPI ServiceCtrlHandler(DWORD dwCtrl);
// Start the service.
void Start(DWORD dwArgc, PSTR *pszArgv);
// Pause the service.
void Pause();
// Resume the service after being paused.
void Continue();
// Execute when the system is shutting down.
void Shutdown();
// The singleton service instance.
static CServiceBase *s_service;
// The name of the service
LPSTR m_name;
// The status of the service
SERVICE_STATUS m_status;
// The service status handle
SERVICE_STATUS_HANDLE m_statusHandle;
};

View File

@@ -0,0 +1,197 @@
/****************************** Module Header ******************************\
* Module Name: ServiceInstaller.cpp
* Project: CppWindowsService
* Copyright (c) Microsoft Corporation.
*
* The file implements functions that install and uninstall the service.
*
* This source is subject to the Microsoft Public License.
* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
* All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
#pragma region "Includes"
#include <stdio.h>
#include <windows.h>
#include "ServiceInstaller.h"
#pragma endregion
//
// FUNCTION: InstallService
//
// PURPOSE: Install the current application as a service to the local
// service control manager database.
//
// PARAMETERS:
// * pszServiceName - the name of the service to be installed
// * pszDisplayName - the display name of the service
// * dwStartType - the service start option. This parameter can be one of
// the following values: SERVICE_AUTO_START, SERVICE_BOOT_START,
// SERVICE_DEMAND_START, SERVICE_DISABLED, SERVICE_SYSTEM_START.
// * pszDependencies - a pointer to a double null-terminated array of null-
// separated names of services or load ordering groups that the system
// must start before this service.
// * pszAccount - the name of the account under which the service runs.
// * pszPassword - the password to the account name.
//
// NOTE: If the function fails to install the service, it prints the error
// in the standard output stream for users to diagnose the problem.
//
std::string InstallService(PSTR pszServiceName,
PSTR pszDisplayName,
DWORD dwStartType,
PSTR pszDependencies,
PSTR pszAccount,
PSTR pszPassword)
{
std::string ret;
std::string path(0x7FFF, '\0');
SC_HANDLE schSCManager = NULL;
SC_HANDLE schService = NULL;
SERVICE_DESCRIPTION sd;
LPTSTR szDesc = TEXT("ZeroTier network virtualization service.");
DWORD dwCharacters = GetModuleFileName(NULL, path.data(), path.size());
if (dwCharacters == 0)
{
ret = "GetModuleFileName failed, unable to get path to self";
goto Cleanup;
}
// Trim excess nulls which the returned size does not include
path.resize(dwCharacters);
// Quote path in case it contains spaces
path = '"' + path + '"';
// Open the local default service control manager database
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT |
SC_MANAGER_CREATE_SERVICE);
if (schSCManager == NULL)
{
ret = "OpenSCManager failed";
goto Cleanup;
}
// Install the service into SCM by calling CreateService
schService = CreateService(
schSCManager, // SCManager database
pszServiceName, // Name of service
pszDisplayName, // Name to display
SERVICE_ALL_ACCESS, // Desired access
SERVICE_WIN32_OWN_PROCESS, // Service type
dwStartType, // Service start type
SERVICE_ERROR_NORMAL, // Error control type
path.c_str(), // Service's binary
NULL, // No load ordering group
NULL, // No tag identifier
pszDependencies, // Dependencies
pszAccount, // Service running account
pszPassword // Password of the account
);
if (schService == NULL)
{
ret = "CreateService failed";
goto Cleanup;
}
// Setup service description
sd.lpDescription = szDesc;
ChangeServiceConfig2(schService, SERVICE_CONFIG_DESCRIPTION, &sd);
Cleanup:
// Centralized cleanup for all allocated resources.
if (schSCManager)
{
CloseServiceHandle(schSCManager);
schSCManager = NULL;
}
if (schService)
{
CloseServiceHandle(schService);
schService = NULL;
}
return ret;
}
//
// FUNCTION: UninstallService
//
// PURPOSE: Stop and remove the service from the local service control
// manager database.
//
// PARAMETERS:
// * pszServiceName - the name of the service to be removed.
//
// NOTE: If the function fails to uninstall the service, it prints the
// error in the standard output stream for users to diagnose the problem.
//
std::string UninstallService(PSTR pszServiceName)
{
std::string ret;
SC_HANDLE schSCManager = NULL;
SC_HANDLE schService = NULL;
SERVICE_STATUS ssSvcStatus = {};
// Open the local default service control manager database
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
if (schSCManager == NULL)
{
ret = "OpenSCManager failed";
goto Cleanup;
}
// Open the service with delete, stop, and query status permissions
schService = OpenService(schSCManager, pszServiceName, SERVICE_STOP |
SERVICE_QUERY_STATUS | DELETE);
if (schService == NULL)
{
ret = "OpenService failed (is service installed?)";
goto Cleanup;
}
// Try to stop the service
if (ControlService(schService, SERVICE_CONTROL_STOP, &ssSvcStatus))
{
Sleep(500);
while (QueryServiceStatus(schService, &ssSvcStatus))
{
if (ssSvcStatus.dwCurrentState == SERVICE_STOP_PENDING)
{
Sleep(500);
}
else break;
}
}
// Now remove the service by calling DeleteService.
if (!DeleteService(schService))
{
ret = "DeleteService failed (is service running?)";
goto Cleanup;
}
Cleanup:
// Centralized cleanup for all allocated resources.
if (schSCManager)
{
CloseServiceHandle(schSCManager);
schSCManager = NULL;
}
if (schService)
{
CloseServiceHandle(schService);
schService = NULL;
}
return ret;
}

View File

@@ -0,0 +1,64 @@
/****************************** Module Header ******************************\
* Module Name: ServiceInstaller.h
* Project: CppWindowsService
* Copyright (c) Microsoft Corporation.
*
* The file declares functions that install and uninstall the service.
*
* This source is subject to the Microsoft Public License.
* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
* All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
#pragma once
#include <string>
//
// FUNCTION: InstallService
//
// PURPOSE: Install the current application as a service to the local
// service control manager database.
//
// PARAMETERS:
// * pszServiceName - the name of the service to be installed
// * pszDisplayName - the display name of the service
// * dwStartType - the service start option. This parameter can be one of
// the following values: SERVICE_AUTO_START, SERVICE_BOOT_START,
// SERVICE_DEMAND_START, SERVICE_DISABLED, SERVICE_SYSTEM_START.
// * pszDependencies - a pointer to a double null-terminated array of null-
// separated names of services or load ordering groups that the system
// must start before this service.
// * pszAccount - the name of the account under which the service runs.
// * pszPassword - the password to the account name.
//
// NOTE: If the function fails to install the service, it prints the error
// in the standard output stream for users to diagnose the problem.
//
// modified for ZT1 to return an error or empty string on success
std::string InstallService(PSTR pszServiceName,
PSTR pszDisplayName,
DWORD dwStartType,
PSTR pszDependencies,
PSTR pszAccount,
PSTR pszPassword);
//
// FUNCTION: UninstallService
//
// PURPOSE: Stop and remove the service from the local service control
// manager database.
//
// PARAMETERS:
// * pszServiceName - the name of the service to be removed.
//
// NOTE: If the function fails to uninstall the service, it prints the
// error in the standard output stream for users to diagnose the problem.
//
// Also modified to return rather than print errors
std::string UninstallService(PSTR pszServiceName);

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,660 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Profile|ARM64">
<Configuration>Profile</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Profile|Win32">
<Configuration>Profile</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Profile|x64">
<Configuration>Profile</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\controller\DB.cpp" />
<ClCompile Include="..\..\controller\DBMirrorSet.cpp" />
<ClCompile Include="..\..\controller\EmbeddedNetworkController.cpp" />
<ClCompile Include="..\..\controller\FileDB.cpp" />
<ClCompile Include="..\..\controller\LFDB.cpp" />
<ClCompile Include="..\..\controller\PostgreSQL.cpp" />
<ClCompile Include="..\..\ext\http-parser\http_parser.c" />
<ClCompile Include="..\..\ext\libnatpmp\getgateway.c" />
<ClCompile Include="..\..\ext\libnatpmp\natpmp.c" />
<ClCompile Include="..\..\ext\libnatpmp\wingettimeofday.c" />
<ClCompile Include="..\..\ext\miniupnpc\connecthostport.c" />
<ClCompile Include="..\..\ext\miniupnpc\igd_desc_parse.c" />
<ClCompile Include="..\..\ext\miniupnpc\minisoap.c" />
<ClCompile Include="..\..\ext\miniupnpc\minissdpc.c" />
<ClCompile Include="..\..\ext\miniupnpc\miniupnpc.c" />
<ClCompile Include="..\..\ext\miniupnpc\miniwget.c" />
<ClCompile Include="..\..\ext\miniupnpc\minixml.c" />
<ClCompile Include="..\..\ext\miniupnpc\portlistingparse.c" />
<ClCompile Include="..\..\ext\miniupnpc\receivedata.c" />
<ClCompile Include="..\..\ext\miniupnpc\upnpcommands.c" />
<ClCompile Include="..\..\ext\miniupnpc\upnpdev.c" />
<ClCompile Include="..\..\ext\miniupnpc\upnperrors.c" />
<ClCompile Include="..\..\ext\miniupnpc\upnpreplyparse.c" />
<ClCompile Include="..\..\node\AES.cpp" />
<ClCompile Include="..\..\node\AES_aesni.cpp" />
<ClCompile Include="..\..\node\AES_armcrypto.cpp" />
<ClCompile Include="..\..\node\Bond.cpp" />
<ClCompile Include="..\..\node\C25519.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MaxSpeed</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">MaxSpeed</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">MaxSpeed</Optimization>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Default</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Default</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">Default</BasicRuntimeChecks>
</ClCompile>
<ClCompile Include="..\..\node\Capability.cpp" />
<ClCompile Include="..\..\node\CertificateOfMembership.cpp" />
<ClCompile Include="..\..\node\CertificateOfOwnership.cpp" />
<ClCompile Include="..\..\node\Identity.cpp" />
<ClCompile Include="..\..\node\IncomingPacket.cpp" />
<ClCompile Include="..\..\node\InetAddress.cpp" />
<ClCompile Include="..\..\node\Membership.cpp" />
<ClCompile Include="..\..\node\Metrics.cpp" />
<ClCompile Include="..\..\node\Multicaster.cpp" />
<ClCompile Include="..\..\node\Network.cpp" />
<ClCompile Include="..\..\node\NetworkConfig.cpp" />
<ClCompile Include="..\..\node\Node.cpp" />
<ClCompile Include="..\..\node\OutboundMulticast.cpp" />
<ClCompile Include="..\..\node\Packet.cpp" />
<ClCompile Include="..\..\node\PacketMultiplexer.cpp" />
<ClCompile Include="..\..\node\Path.cpp" />
<ClCompile Include="..\..\node\Peer.cpp" />
<ClCompile Include="..\..\node\Poly1305.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MaxSpeed</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">MaxSpeed</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">MaxSpeed</Optimization>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Default</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Default</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">Default</BasicRuntimeChecks>
</ClCompile>
<ClCompile Include="..\..\node\Revocation.cpp" />
<ClCompile Include="..\..\node\Salsa20.cpp" />
<ClCompile Include="..\..\node\SelfAwareness.cpp" />
<ClCompile Include="..\..\node\SHA512.cpp" />
<ClCompile Include="..\..\node\Switch.cpp" />
<ClCompile Include="..\..\node\Tag.cpp" />
<ClCompile Include="..\..\node\Topology.cpp" />
<ClCompile Include="..\..\node\Trace.cpp" />
<ClCompile Include="..\..\node\Utils.cpp" />
<ClCompile Include="..\..\one.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Profile|ARM64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\osdep\EthernetTap.cpp" />
<ClCompile Include="..\..\osdep\Http.cpp" />
<ClCompile Include="..\..\osdep\ManagedRoute.cpp" />
<ClCompile Include="..\..\osdep\OSUtils.cpp" />
<ClCompile Include="..\..\osdep\PortMapper.cpp" />
<ClCompile Include="..\..\osdep\WinDNSHelper.cpp" />
<ClCompile Include="..\..\osdep\WindowsEthernetTap.cpp" />
<ClCompile Include="..\..\osdep\WinFWHelper.cpp" />
<ClCompile Include="..\..\selftest.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Profile|ARM64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\service\OneService.cpp" />
<ClCompile Include="..\..\service\SoftwareUpdater.cpp" />
<ClCompile Include="ServiceBase.cpp" />
<ClCompile Include="ServiceInstaller.cpp" />
<ClCompile Include="ZeroTierOneService.cpp">
<FunctionLevelLinking Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</FunctionLevelLinking>
<EnableParallelCodeGeneration Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</EnableParallelCodeGeneration>
<FunctionLevelLinking Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</FunctionLevelLinking>
<FunctionLevelLinking Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">false</FunctionLevelLinking>
<EnableParallelCodeGeneration Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</EnableParallelCodeGeneration>
<EnableParallelCodeGeneration Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</EnableParallelCodeGeneration>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NoExtensions</EnableEnhancedInstructionSet>
<FloatingPointExceptions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</FloatingPointExceptions>
<CreateHotpatchableImage Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CreateHotpatchableImage>
<FloatingPointExceptions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</FloatingPointExceptions>
<FloatingPointExceptions Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">false</FloatingPointExceptions>
<CreateHotpatchableImage Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CreateHotpatchableImage>
<CreateHotpatchableImage Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">false</CreateHotpatchableImage>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NoExtensions</EnableEnhancedInstructionSet>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\controller\DB.hpp" />
<ClInclude Include="..\..\controller\DBMirrorSet.hpp" />
<ClInclude Include="..\..\controller\EmbeddedNetworkController.hpp" />
<ClInclude Include="..\..\controller\FileDB.hpp" />
<ClInclude Include="..\..\controller\LFDB.hpp" />
<ClInclude Include="..\..\controller\PostgreSQL.hpp" />
<ClInclude Include="..\..\controller\Redis.hpp" />
<ClInclude Include="..\..\ext\cpp-httplib\httplib.h" />
<ClInclude Include="..\..\ext\http-parser\http_parser.h" />
<ClInclude Include="..\..\ext\json\json.hpp" />
<ClInclude Include="..\..\ext\libnatpmp\getgateway.h" />
<ClInclude Include="..\..\ext\libnatpmp\natpmp.h" />
<ClInclude Include="..\..\ext\libnatpmp\wingettimeofday.h" />
<ClInclude Include="..\..\ext\miniupnpc\codelength.h" />
<ClInclude Include="..\..\ext\miniupnpc\connecthostport.h" />
<ClInclude Include="..\..\ext\miniupnpc\igd_desc_parse.h" />
<ClInclude Include="..\..\ext\miniupnpc\minisoap.h" />
<ClInclude Include="..\..\ext\miniupnpc\minissdpc.h" />
<ClInclude Include="..\..\ext\miniupnpc\miniupnpc.h" />
<ClInclude Include="..\..\ext\miniupnpc\miniupnpctypes.h" />
<ClInclude Include="..\..\ext\miniupnpc\miniupnpc_declspec.h" />
<ClInclude Include="..\..\ext\miniupnpc\miniwget.h" />
<ClInclude Include="..\..\ext\miniupnpc\minixml.h" />
<ClInclude Include="..\..\ext\miniupnpc\portlistingparse.h" />
<ClInclude Include="..\..\ext\miniupnpc\receivedata.h" />
<ClInclude Include="..\..\ext\miniupnpc\upnpcommands.h" />
<ClInclude Include="..\..\ext\miniupnpc\upnpdev.h" />
<ClInclude Include="..\..\ext\miniupnpc\upnperrors.h" />
<ClInclude Include="..\..\ext\miniupnpc\upnpreplyparse.h" />
<ClInclude Include="..\..\ext\x64-salsa2012-asm\salsa2012.h" />
<ClInclude Include="..\..\include\ZeroTierOne.h" />
<ClInclude Include="..\..\node\Address.hpp" />
<ClInclude Include="..\..\node\AtomicCounter.hpp" />
<ClInclude Include="..\..\node\Bond.hpp" />
<ClInclude Include="..\..\node\BondController.hpp" />
<ClInclude Include="..\..\node\Buffer.hpp" />
<ClInclude Include="..\..\node\C25519.hpp" />
<ClInclude Include="..\..\node\CertificateOfMembership.hpp" />
<ClInclude Include="..\..\node\CertificateOfOwnership.hpp" />
<ClInclude Include="..\..\node\Constants.hpp" />
<ClInclude Include="..\..\node\Credential.hpp" />
<ClInclude Include="..\..\node\Dictionary.hpp" />
<ClInclude Include="..\..\node\Hashtable.hpp" />
<ClInclude Include="..\..\node\Identity.hpp" />
<ClInclude Include="..\..\node\IncomingPacket.hpp" />
<ClInclude Include="..\..\node\InetAddress.hpp" />
<ClInclude Include="..\..\node\MAC.hpp" />
<ClInclude Include="..\..\node\Membership.hpp" />
<ClInclude Include="..\..\node\Metrics.hpp" />
<ClInclude Include="..\..\node\Multicaster.hpp" />
<ClInclude Include="..\..\node\MulticastGroup.hpp" />
<ClInclude Include="..\..\node\Mutex.hpp" />
<ClInclude Include="..\..\node\Network.hpp" />
<ClInclude Include="..\..\node\NetworkConfig.hpp" />
<ClInclude Include="..\..\node\NetworkController.hpp" />
<ClInclude Include="..\..\node\Node.hpp" />
<ClInclude Include="..\..\node\OutboundMulticast.hpp" />
<ClInclude Include="..\..\node\Packet.hpp" />
<ClInclude Include="..\..\node\Path.hpp" />
<ClInclude Include="..\..\node\Peer.hpp" />
<ClInclude Include="..\..\node\Poly1305.hpp" />
<ClInclude Include="..\..\node\RuntimeEnvironment.hpp" />
<ClInclude Include="..\..\node\Salsa20.hpp" />
<ClInclude Include="..\..\node\SelfAwareness.hpp" />
<ClInclude Include="..\..\node\SHA512.hpp" />
<ClInclude Include="..\..\node\SharedPtr.hpp" />
<ClInclude Include="..\..\node\Switch.hpp" />
<ClInclude Include="..\..\node\Topology.hpp" />
<ClInclude Include="..\..\node\Trace.hpp" />
<ClInclude Include="..\..\node\Utils.hpp" />
<ClInclude Include="..\..\node\World.hpp" />
<ClInclude Include="..\..\osdep\Binder.hpp" />
<ClInclude Include="..\..\osdep\EthernetTap.hpp" />
<ClInclude Include="..\..\osdep\Http.hpp" />
<ClInclude Include="..\..\osdep\ManagedRoute.hpp" />
<ClInclude Include="..\..\osdep\OSUtils.hpp" />
<ClInclude Include="..\..\osdep\Phy.hpp" />
<ClInclude Include="..\..\osdep\PortMapper.hpp" />
<ClInclude Include="..\..\osdep\Thread.hpp" />
<ClInclude Include="..\..\osdep\WinDNSHelper.hpp" />
<ClInclude Include="..\..\osdep\WindowsEthernetTap.hpp" />
<ClInclude Include="..\..\osdep\WinFWHelper.hpp" />
<ClInclude Include="..\..\service\OneService.hpp" />
<ClInclude Include="..\..\service\SoftwareUpdater.hpp" />
<ClInclude Include="..\..\version.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="ServiceBase.h" />
<ClInclude Include="ServiceInstaller.h" />
<ClInclude Include="ZeroTierOneService.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ZeroTierOne.rc" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B00A4957-5977-4AC1-9EF4-571DC27EADA2}</ProjectGuid>
<RootNamespace>ZeroTierOne</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Profile|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetExt>.exe</TargetExt>
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
<TargetName>zerotier-one_x86</TargetName>
<IntDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">
<TargetExt>.exe</TargetExt>
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
<TargetName>zerotier-one_x86</TargetName>
<IntDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetExt>.exe</TargetExt>
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
<TargetName>zerotier-one_x86</TargetName>
<IntDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetExt>.exe</TargetExt>
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
<TargetName>zerotier-one_x64</TargetName>
<IntDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<TargetExt>.exe</TargetExt>
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
<TargetName>zerotier-one_arm64</TargetName>
<IntDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">
<TargetExt>.exe</TargetExt>
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
<TargetName>zerotier-one_x64</TargetName>
<IntDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Profile|ARM64'">
<TargetExt>.exe</TargetExt>
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
<TargetName>zerotier-one_arm64</TargetName>
<IntDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetExt>.exe</TargetExt>
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
<TargetName>zerotier-one_x64</TargetName>
<IntDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<TargetExt>.exe</TargetExt>
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
<TargetName>zerotier-one_arm64</TargetName>
<IntDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)\..\ext;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\core\include;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\simpleapi\include;$(SolutionDir)\..\rustybits\target;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZT_SSO_ENABLED=1;ZT_EXPORT;FD_SETSIZE=1024;NOMINMAX;STATICLIB;WIN32;ZT_TRACE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<GuardEHContMetadata>false</GuardEHContMetadata>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;zeroidc.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalLibraryDirectories>$(SolutionDir)\..\rustybits\target\i686-pc-windows-msvc\debug\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)\..\ext;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\core\include;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\simpleapi\include;$(SolutionDir)\..\rustybits\target;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZT_SSO_ENABLED=1;ZT_EXPORT;FD_SETSIZE=1024;NOMINMAX;STATICLIB;WIN32;ZT_TRACE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<GuardEHContMetadata>false</GuardEHContMetadata>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)\..\ext;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\core\include;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\simpleapi\include;$(SolutionDir)\..\rustybits\target;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZT_SSO_ENABLED=1;ZT_EXPORT;FD_SETSIZE=1024;NOMINMAX;STATICLIB;WIN32;ZT_TRACE;ZT_RULES_ENGINE_DEBUGGING;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<GuardEHContMetadata>false</GuardEHContMetadata>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>wbemuuid.lib;wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;zeroidc.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalOptions>"notelemetry.obj" %(AdditionalOptions)</AdditionalOptions>
<AdditionalLibraryDirectories>$(SolutionDir)..\rustybits\target\x86_64-pc-windows-msvc\debug\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)\..\ext;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\core\include;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\simpleapi\include;$(SolutionDir)\..\rustybits\target;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZT_EXPORT;FD_SETSIZE=1024;NOMINMAX;STATICLIB;WIN32;ZT_TRACE;ZT_RULES_ENGINE_DEBUGGING;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<GuardEHContMetadata>false</GuardEHContMetadata>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>wbemuuid.lib;wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;zeroidc.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalLibraryDirectories>$(SolutionDir)..\rustybits\target\aarch64-pc-windows-msvc\debug\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)\..\ext;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\core\include;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\simpleapi\include;$(SolutionDir)\..\rustybits\target;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZT_SSO_ENABLED=1;ZT_EXPORT;FD_SETSIZE=1024;NOMINMAX;STATICLIB;WIN32;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<GuardEHContMetadata>false</GuardEHContMetadata>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalOptions>"notelemetry.obj" %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|ARM64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)\..\ext;$(SolutionDir)\..\rustybits\target;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZT_EXPORT;FD_SETSIZE=1024;NOMINMAX;STATICLIB;WIN32;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<GuardEHContMetadata>false</GuardEHContMetadata>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalOptions>"notelemetry.obj" %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>false</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)\..\ext;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\core\include;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\simpleapi\include;$(SolutionDir)\..\rustybits\target;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZT_SSO_ENABLED=1;ZT_EXPORT;FD_SETSIZE=1024;STATICLIB;ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;ZT_SOFTWARE_UPDATE_DEFAULT="apply";ZT_BUILD_PLATFORM=2;ZT_BUILD_ARCHITECTURE=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<StringPooling>true</StringPooling>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<ControlFlowGuard>Guard</ControlFlowGuard>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<DebugInformationFormat>None</DebugInformationFormat>
<CompileAsManaged>false</CompileAsManaged>
<CompileAsWinRT>false</CompileAsWinRT>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnableParallelCodeGeneration>false</EnableParallelCodeGeneration>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<GuardEHContMetadata>false</GuardEHContMetadata>
</ClCompile>
<Link>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;zeroidc.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalLibraryDirectories>$(SolutionDir)..\rustybits\target\i686-pc-windows-msvc\release\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>false</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)\..\ext;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\core\include;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\simpleapi\include;$(SolutionDir)\..\rustybits\target;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZT_SSO_ENABLED=1;ZT_EXPORT;FD_SETSIZE=1024;STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="apply";ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;ZT_BUILD_PLATFORM=2;ZT_BUILD_ARCHITECTURE=2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<StringPooling>true</StringPooling>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<ControlFlowGuard>Guard</ControlFlowGuard>
<EnableParallelCodeGeneration>false</EnableParallelCodeGeneration>
<CallingConvention>Cdecl</CallingConvention>
<LanguageStandard>stdcpp17</LanguageStandard>
<DebugInformationFormat>None</DebugInformationFormat>
<CompileAsManaged>false</CompileAsManaged>
<CompileAsWinRT>false</CompileAsWinRT>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<GuardEHContMetadata>false</GuardEHContMetadata>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
</ClCompile>
<Link>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>wbemuuid.lib;wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;zeroidc.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalLibraryDirectories>$(SolutionDir)..\rustybits\target\x86_64-pc-windows-msvc\release\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>false</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)\..\ext;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\core\include;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\simpleapi\include;$(SolutionDir)\..\rustybits\target;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZT_SSO_ENABLED=1;ZT_EXPORT;FD_SETSIZE=1024;STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="apply";ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;ZT_BUILD_PLATFORM=2;ZT_BUILD_ARCHITECTURE=2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<StringPooling>true</StringPooling>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<ControlFlowGuard>Guard</ControlFlowGuard>
<EnableParallelCodeGeneration>false</EnableParallelCodeGeneration>
<CallingConvention>Cdecl</CallingConvention>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<DebugInformationFormat>None</DebugInformationFormat>
<CompileAsManaged>false</CompileAsManaged>
<CompileAsWinRT>false</CompileAsWinRT>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<GuardEHContMetadata>false</GuardEHContMetadata>
</ClCompile>
<Link>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>wbemuuid.lib;wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;zeroidc.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalLibraryDirectories>$(SolutionDir)..\rustybits\target\aarch64-pc-windows-msvc\release\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,575 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Source Files\node">
<UniqueIdentifier>{67b1c0f8-b018-4169-9c14-7032ed12c786}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\include">
<UniqueIdentifier>{40761a4c-e8db-4a91-9cab-7afef332f4a8}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\node">
<UniqueIdentifier>{da3b8126-840c-45db-8abe-9d7e7976f8be}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\osdep">
<UniqueIdentifier>{6054dfae-4ed2-4d69-8cf5-d6f27646f2d7}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\service">
<UniqueIdentifier>{9944293a-4a1a-40e9-b92a-eff31fe87e2c}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\osdep">
<UniqueIdentifier>{ca21bd6b-ff4e-4f9e-bedd-c9f603d2d0d6}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\service">
<UniqueIdentifier>{e1743b3c-1d18-47f1-ab5a-f5703c19f1df}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\ext">
<UniqueIdentifier>{71865460-d693-4c73-84f6-dbff42f49df6}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\ext\http-parser">
<UniqueIdentifier>{17ae9a01-d39f-4c6d-a800-8f2cd0804c96}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\ext">
<UniqueIdentifier>{7784af31-5b60-4300-b07e-44cf864c54db}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\ext\http-parser">
<UniqueIdentifier>{f8a1c208-15b8-4d85-a4cb-11d2b82f2d1e}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\windows">
<UniqueIdentifier>{43f75f84-c70d-4d44-a0ef-28a7a399abd4}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\windows\ZeroTierOne">
<UniqueIdentifier>{0da07a2f-8922-4827-ac51-29ca3f30f881}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\windows">
<UniqueIdentifier>{b74916eb-bb6c-4449-a2a2-fa0b17f60121}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\windows\ZeroTierOne">
<UniqueIdentifier>{bf604491-14c4-4a74-81a6-6105d07c5c7c}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\ext\miniupnpc">
<UniqueIdentifier>{5423fb64-896b-432e-a19d-88d4467f89f9}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\ext\miniupnpc">
<UniqueIdentifier>{56cc3ab8-3336-4a22-9471-c267ee46cd54}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\ext\libnatpmp">
<UniqueIdentifier>{d7292d0d-72a0-4ed6-b717-21debb120737}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\ext\libnatpmp">
<UniqueIdentifier>{409ec37e-ff36-4c13-b18d-52d6052e0ca2}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\controller">
<UniqueIdentifier>{3cad34c8-c436-43ae-8323-57803637c832}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\ext\json">
<UniqueIdentifier>{ff20532b-d9a2-440d-a7b4-b49e26a9b2f8}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\ext\x64-salsa2012-asm">
<UniqueIdentifier>{05d9cde8-03ae-4e37-b9f7-7417de98cbe9}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\controller">
<UniqueIdentifier>{7dc22e9c-f869-41e7-b43d-f07f5b94f6fb}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\ext\cpp-httplib">
<UniqueIdentifier>{4dfde4c7-2950-40ee-92f2-05e0916d36c5}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\service\OneService.cpp">
<Filter>Source Files\service</Filter>
</ClCompile>
<ClCompile Include="..\..\osdep\Http.cpp">
<Filter>Source Files\osdep</Filter>
</ClCompile>
<ClCompile Include="..\..\osdep\OSUtils.cpp">
<Filter>Source Files\osdep</Filter>
</ClCompile>
<ClCompile Include="..\..\node\C25519.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\CertificateOfMembership.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Identity.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\IncomingPacket.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\InetAddress.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Multicaster.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Network.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\NetworkConfig.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Node.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\OutboundMulticast.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Packet.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Peer.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Poly1305.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Salsa20.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\SelfAwareness.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\SHA512.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Switch.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Topology.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Utils.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\http-parser\http_parser.c">
<Filter>Source Files\ext\http-parser</Filter>
</ClCompile>
<ClCompile Include="ServiceBase.cpp">
<Filter>Source Files\windows\ZeroTierOne</Filter>
</ClCompile>
<ClCompile Include="ServiceInstaller.cpp">
<Filter>Source Files\windows\ZeroTierOne</Filter>
</ClCompile>
<ClCompile Include="ZeroTierOneService.cpp">
<Filter>Source Files\windows\ZeroTierOne</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Path.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\miniupnpc\connecthostport.c">
<Filter>Source Files\ext\miniupnpc</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\miniupnpc\igd_desc_parse.c">
<Filter>Source Files\ext\miniupnpc</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\miniupnpc\minisoap.c">
<Filter>Source Files\ext\miniupnpc</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\miniupnpc\minissdpc.c">
<Filter>Source Files\ext\miniupnpc</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\miniupnpc\miniupnpc.c">
<Filter>Source Files\ext\miniupnpc</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\miniupnpc\miniwget.c">
<Filter>Source Files\ext\miniupnpc</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\miniupnpc\minixml.c">
<Filter>Source Files\ext\miniupnpc</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\miniupnpc\portlistingparse.c">
<Filter>Source Files\ext\miniupnpc</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\miniupnpc\receivedata.c">
<Filter>Source Files\ext\miniupnpc</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\miniupnpc\upnpcommands.c">
<Filter>Source Files\ext\miniupnpc</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\miniupnpc\upnpdev.c">
<Filter>Source Files\ext\miniupnpc</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\miniupnpc\upnperrors.c">
<Filter>Source Files\ext\miniupnpc</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\miniupnpc\upnpreplyparse.c">
<Filter>Source Files\ext\miniupnpc</Filter>
</ClCompile>
<ClCompile Include="..\..\osdep\PortMapper.cpp">
<Filter>Source Files\osdep</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\libnatpmp\getgateway.c">
<Filter>Source Files\ext\libnatpmp</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\libnatpmp\natpmp.c">
<Filter>Source Files\ext\libnatpmp</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\libnatpmp\wingettimeofday.c">
<Filter>Source Files\ext\libnatpmp</Filter>
</ClCompile>
<ClCompile Include="..\..\osdep\ManagedRoute.cpp">
<Filter>Source Files\osdep</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Membership.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Capability.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Revocation.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Tag.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\controller\EmbeddedNetworkController.cpp">
<Filter>Source Files\controller</Filter>
</ClCompile>
<ClCompile Include="..\..\service\SoftwareUpdater.cpp">
<Filter>Source Files\service</Filter>
</ClCompile>
<ClCompile Include="..\..\node\CertificateOfOwnership.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\one.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\selftest.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Trace.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\controller\DB.cpp">
<Filter>Source Files\controller</Filter>
</ClCompile>
<ClCompile Include="..\..\controller\FileDB.cpp">
<Filter>Source Files\controller</Filter>
</ClCompile>
<ClCompile Include="..\..\controller\PostgreSQL.cpp">
<Filter>Source Files\controller</Filter>
</ClCompile>
<ClCompile Include="..\..\controller\LFDB.cpp">
<Filter>Source Files\controller</Filter>
</ClCompile>
<ClCompile Include="..\..\controller\DBMirrorSet.cpp">
<Filter>Source Files\controller</Filter>
</ClCompile>
<ClCompile Include="..\..\osdep\EthernetTap.cpp">
<Filter>Source Files\osdep</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Bond.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\osdep\WinDNSHelper.cpp">
<Filter>Source Files\osdep</Filter>
</ClCompile>
<ClCompile Include="..\..\osdep\WindowsEthernetTap.cpp">
<Filter>Source Files\osdep</Filter>
</ClCompile>
<ClCompile Include="..\..\node\AES.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\AES_aesni.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\AES_armcrypto.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\osdep\WinFWHelper.cpp">
<Filter>Source Files\osdep</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Metrics.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
<ClCompile Include="..\..\node\PacketMultiplexer.cpp">
<Filter>Source Files\node</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\version.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ZeroTierOne.h">
<Filter>Header Files\include</Filter>
</ClInclude>
<ClInclude Include="..\..\osdep\Http.hpp">
<Filter>Header Files\osdep</Filter>
</ClInclude>
<ClInclude Include="..\..\osdep\OSUtils.hpp">
<Filter>Header Files\osdep</Filter>
</ClInclude>
<ClInclude Include="..\..\osdep\Phy.hpp">
<Filter>Header Files\osdep</Filter>
</ClInclude>
<ClInclude Include="..\..\osdep\Thread.hpp">
<Filter>Header Files\osdep</Filter>
</ClInclude>
<ClInclude Include="..\..\osdep\WindowsEthernetTap.hpp">
<Filter>Header Files\osdep</Filter>
</ClInclude>
<ClInclude Include="..\..\service\OneService.hpp">
<Filter>Header Files\service</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Address.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\AtomicCounter.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Buffer.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\C25519.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\CertificateOfMembership.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Constants.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Dictionary.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Identity.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\IncomingPacket.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\InetAddress.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\MAC.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Multicaster.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\MulticastGroup.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Mutex.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Network.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\NetworkConfig.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\NetworkController.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Node.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\OutboundMulticast.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Packet.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Path.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Peer.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Poly1305.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\RuntimeEnvironment.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Salsa20.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\SelfAwareness.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\SHA512.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\SharedPtr.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Switch.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Topology.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Utils.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\http-parser\http_parser.h">
<Filter>Header Files\ext\http-parser</Filter>
</ClInclude>
<ClInclude Include="ServiceBase.h">
<Filter>Header Files\windows\ZeroTierOne</Filter>
</ClInclude>
<ClInclude Include="ServiceInstaller.h">
<Filter>Header Files\windows\ZeroTierOne</Filter>
</ClInclude>
<ClInclude Include="ZeroTierOneService.h">
<Filter>Header Files\windows\ZeroTierOne</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Hashtable.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\World.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\codelength.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\connecthostport.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\igd_desc_parse.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\minisoap.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\minissdpc.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\miniupnpc.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\miniupnpc_declspec.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\miniupnpctypes.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\miniwget.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\minixml.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\portlistingparse.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\receivedata.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\upnpcommands.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\upnpdev.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\upnperrors.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\miniupnpc\upnpreplyparse.h">
<Filter>Header Files\ext\miniupnpc</Filter>
</ClInclude>
<ClInclude Include="..\..\osdep\PortMapper.hpp">
<Filter>Header Files\osdep</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\libnatpmp\getgateway.h">
<Filter>Header Files\ext\libnatpmp</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\libnatpmp\natpmp.h">
<Filter>Header Files\ext\libnatpmp</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\libnatpmp\wingettimeofday.h">
<Filter>Header Files\ext\libnatpmp</Filter>
</ClInclude>
<ClInclude Include="..\..\osdep\Binder.hpp">
<Filter>Header Files\osdep</Filter>
</ClInclude>
<ClInclude Include="..\..\osdep\ManagedRoute.hpp">
<Filter>Header Files\osdep</Filter>
</ClInclude>
<ClInclude Include="..\..\service\SoftwareUpdater.hpp">
<Filter>Header Files\service</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\json\json.hpp">
<Filter>Header Files\ext\json</Filter>
</ClInclude>
<ClInclude Include="..\..\node\CertificateOfOwnership.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Credential.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\x64-salsa2012-asm\salsa2012.h">
<Filter>Header Files\ext\x64-salsa2012-asm</Filter>
</ClInclude>
<ClInclude Include="..\..\controller\EmbeddedNetworkController.hpp">
<Filter>Header Files\controller</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Trace.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\controller\DB.hpp">
<Filter>Header Files\controller</Filter>
</ClInclude>
<ClInclude Include="..\..\controller\FileDB.hpp">
<Filter>Header Files\controller</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Membership.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\controller\PostgreSQL.hpp">
<Filter>Header Files\controller</Filter>
</ClInclude>
<ClInclude Include="..\..\controller\LFDB.hpp">
<Filter>Header Files\controller</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\cpp-httplib\httplib.h">
<Filter>Header Files\ext\cpp-httplib</Filter>
</ClInclude>
<ClInclude Include="..\..\controller\DBMirrorSet.hpp">
<Filter>Header Files\controller</Filter>
</ClInclude>
<ClInclude Include="..\..\osdep\EthernetTap.hpp">
<Filter>Header Files\osdep</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Bond.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\node\BondController.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
<ClInclude Include="..\..\controller\Redis.hpp">
<Filter>Header Files\controller</Filter>
</ClInclude>
<ClInclude Include="..\..\osdep\WinDNSHelper.hpp">
<Filter>Header Files\osdep</Filter>
</ClInclude>
<ClInclude Include="..\..\osdep\WinFWHelper.hpp">
<Filter>Header Files\osdep</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Metrics.hpp">
<Filter>Header Files\node</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ZeroTierOne.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,160 @@
/*
* Copyright (c)2019 ZeroTier, Inc.
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file in the project's root directory.
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/
/****/
#pragma region Includes
#if defined(_WIN32) || defined(_WIN64)
#include <winsock2.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "ZeroTierOneService.h"
#include "../../version.h"
#include "../../include/ZeroTierOne.h"
#include "../../node/Constants.hpp"
#include "../../node/Utils.hpp"
#include "../../osdep/OSUtils.hpp"
#include "../../service/OneService.hpp"
#pragma endregion // Includes
#ifdef ZT_DEBUG_SERVICE
FILE *SVCDBGfile = (FILE *)0;
ZeroTier::Mutex SVCDBGfile_m;
#endif
ZeroTierOneService::ZeroTierOneService() :
CServiceBase(ZT_SERVICE_NAME,TRUE,TRUE,FALSE),
_service((ZeroTier::OneService *)0)
{
#ifdef ZT_DEBUG_SERVICE
SVCDBGfile_m.lock();
if (!SVCDBGfile)
SVCDBGfile = fopen(ZT_DEBUG_SERVICE,"a");
SVCDBGfile_m.unlock();
#endif
ZT_SVCDBG("ZeroTierOneService::ZeroTierOneService()\r\n");
}
ZeroTierOneService::~ZeroTierOneService(void)
{
ZT_SVCDBG("ZeroTierOneService::~ZeroTierOneService()\r\n");
#ifdef ZT_DEBUG_SERVICE
SVCDBGfile_m.lock();
if (SVCDBGfile) {
fclose(SVCDBGfile);
SVCDBGfile = (FILE *)0;
}
SVCDBGfile_m.unlock();
#endif
}
void ZeroTierOneService::threadMain()
throw()
{
ZT_SVCDBG("ZeroTierOneService::threadMain()\r\n");
restart_node:
try {
{
ZeroTier::Mutex::Lock _l(_lock);
delete _service;
_service = (ZeroTier::OneService *)0; // in case newInstance() fails
_service = ZeroTier::OneService::newInstance(_path.c_str(), ZT_DEFAULT_PORT);
}
switch(_service->run()) {
case ZeroTier::OneService::ONE_UNRECOVERABLE_ERROR: {
std::string err("ZeroTier One encountered an unrecoverable error: ");
err.append(_service->fatalErrorMessage());
err.append(" (restarting in 5 seconds)");
WriteEventLogEntry(const_cast <PSTR>(err.c_str()),EVENTLOG_ERROR_TYPE);
Sleep(5000);
} goto restart_node;
case ZeroTier::OneService::ONE_IDENTITY_COLLISION: {
std::string homeDir(ZeroTier::OneService::platformDefaultHomePath());
delete _service;
_service = (ZeroTier::OneService *)0;
std::string oldid;
ZeroTier::OSUtils::readFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str(),oldid);
if (oldid.length()) {
ZeroTier::OSUtils::writeFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret.saved_after_collision").c_str(),oldid);
ZeroTier::OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str());
ZeroTier::OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.public").c_str());
}
} goto restart_node;
default: // normal termination
break;
}
} catch ( ... ) {
// sanity check, shouldn't happen since Node::run() should catch all its own errors
// could also happen if we're out of memory though!
WriteEventLogEntry("unexpected exception (out of memory?) (trying again in 5 seconds)",EVENTLOG_ERROR_TYPE);
Sleep(5000);
goto restart_node;
}
{
ZeroTier::Mutex::Lock _l(_lock);
delete _service;
_service = (ZeroTier::OneService *)0;
}
}
void ZeroTierOneService::OnStart(DWORD dwArgc, PSTR *lpszArgv)
{
ZT_SVCDBG("ZeroTierOneService::OnStart()\r\n");
if ((dwArgc > 1)&&(lpszArgv[1])&&(strlen(lpszArgv[1]) > 0)) {
this->_path = lpszArgv[1];
} else {
this->_path = ZeroTier::OneService::platformDefaultHomePath();
}
try {
_thread = ZeroTier::Thread::start(this);
} catch ( ... ) {
throw (DWORD)ERROR_EXCEPTION_IN_SERVICE;
}
}
void ZeroTierOneService::OnStop()
{
ZT_SVCDBG("ZeroTierOneService::OnStop()\r\n");
_lock.lock();
ZeroTier::OneService *s = _service;
_lock.unlock();
if (s) {
s->terminate();
ZeroTier::Thread::join(_thread);
}
}
void ZeroTierOneService::OnShutdown()
{
ZT_SVCDBG("ZeroTierOneService::OnShutdown()\r\n");
// stop thread on system shutdown (if it hasn't happened already)
OnStop();
}
#endif

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c)2019 ZeroTier, Inc.
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file in the project's root directory.
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/
/****/
#pragma once
#if defined(_WIN32) || defined(_WIN64)
#include <stdio.h>
#include "ServiceBase.h"
#include <string>
#include "../../node/Mutex.hpp"
#include "../../osdep/Thread.hpp"
#include "../../service/OneService.hpp"
// Uncomment to make debugging Windows services suck slightly less hard.
//#define ZT_DEBUG_SERVICE "C:\\ZeroTierOneServiceDebugLog.txt"
#ifdef ZT_DEBUG_SERVICE
extern FILE *SVCDBGfile;
extern ZeroTier::Mutex SVCDBGfile_m;
#define ZT_SVCDBG(f,...) { SVCDBGfile_m.lock(); fprintf(SVCDBGfile,f,##__VA_ARGS__); fflush(SVCDBGfile); SVCDBGfile_m.unlock(); }
#else
#define ZT_SVCDBG(f,...) {}
#endif
#define ZT_SERVICE_NAME "ZeroTierOneService"
#define ZT_SERVICE_DISPLAY_NAME "ZeroTier One"
#define ZT_SERVICE_START_TYPE SERVICE_AUTO_START
#define ZT_SERVICE_DEPENDENCIES ""
//#define ZT_SERVICE_ACCOUNT "NT AUTHORITY\\LocalService"
#define ZT_SERVICE_ACCOUNT NULL
#define ZT_SERVICE_PASSWORD NULL
class ZeroTierOneService : public CServiceBase
{
public:
ZeroTierOneService();
virtual ~ZeroTierOneService(void);
/**
* Thread main method; do not call elsewhere
*/
void threadMain()
throw();
protected:
virtual void OnStart(DWORD dwArgc, PSTR *pszArgv);
virtual void OnStop();
virtual void OnShutdown();
private:
std::string _path;
ZeroTier::OneService *volatile _service;
ZeroTier::Mutex _lock;
ZeroTier::Thread _thread;
};
#endif

View File

@@ -0,0 +1,14 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by ZeroTierOne.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,28 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZeroTierOneSDK", "ZeroTierOneSDK\ZeroTierOneSDK.vcxproj", "{05E8E6B2-4067-4660-AD85-C8F6130FAFC5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{05E8E6B2-4067-4660-AD85-C8F6130FAFC5}.Debug|x64.ActiveCfg = Debug|x64
{05E8E6B2-4067-4660-AD85-C8F6130FAFC5}.Debug|x64.Build.0 = Debug|x64
{05E8E6B2-4067-4660-AD85-C8F6130FAFC5}.Debug|x86.ActiveCfg = Debug|Win32
{05E8E6B2-4067-4660-AD85-C8F6130FAFC5}.Debug|x86.Build.0 = Debug|Win32
{05E8E6B2-4067-4660-AD85-C8F6130FAFC5}.Release|x64.ActiveCfg = Release|x64
{05E8E6B2-4067-4660-AD85-C8F6130FAFC5}.Release|x64.Build.0 = Release|x64
{05E8E6B2-4067-4660-AD85-C8F6130FAFC5}.Release|x86.ActiveCfg = Release|Win32
{05E8E6B2-4067-4660-AD85-C8F6130FAFC5}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,257 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{05E8E6B2-4067-4660-AD85-C8F6130FAFC5}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ZeroTierOneSDK</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<TargetName>ZeroTierOne_x86d</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
<TargetName>ZeroTierOne_x64d</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<TargetName>ZeroTierOne_x86</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
<TargetName>ZeroTierOne_x64</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;NOMINMAX;ZT_EXPORT;ZT_TRACE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(SolutionDir)lib\$(TargetName).lib</ImportLibrary>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;WIN32;NOMINMAX;ZT_EXPORT;ZT_TRACE;ZT_RULES_ENGINE_DEBUGGING_NO;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(SolutionDir)lib\$(TargetName).lib</ImportLibrary>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;ZT_EXPORT;ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;ZT_SOFTWARE_UPDATE_DEFAULT="apply";ZT_BUILD_PLATFORM=2;ZT_BUILD_ARCHITECTURE=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(SolutionDir)lib\$(TargetName).lib</ImportLibrary>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;ZT_EXPORT;ZT_SOFTWARE_UPDATE_DEFAULT="apply";ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;NOMINMAX;ZT_BUILD_PLATFORM=2;ZT_BUILD_ARCHITECTURE=2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImportLibrary>$(SolutionDir)lib\$(TargetName).lib</ImportLibrary>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\ZeroTierOne.h" />
<ClInclude Include="..\..\node\Address.hpp" />
<ClInclude Include="..\..\node\Array.hpp" />
<ClInclude Include="..\..\node\AtomicCounter.hpp" />
<ClInclude Include="..\..\node\Buffer.hpp" />
<ClInclude Include="..\..\node\C25519.hpp" />
<ClInclude Include="..\..\node\Capability.hpp" />
<ClInclude Include="..\..\node\CertificateOfMembership.hpp" />
<ClInclude Include="..\..\node\CertificateOfOwnership.hpp" />
<ClInclude Include="..\..\node\CertificateOfRepresentation.hpp" />
<ClInclude Include="..\..\node\Cluster.hpp" />
<ClInclude Include="..\..\node\Constants.hpp" />
<ClInclude Include="..\..\node\Credential.hpp" />
<ClInclude Include="..\..\node\Dictionary.hpp" />
<ClInclude Include="..\..\node\Hashtable.hpp" />
<ClInclude Include="..\..\node\Identity.hpp" />
<ClInclude Include="..\..\node\IncomingPacket.hpp" />
<ClInclude Include="..\..\node\InetAddress.hpp" />
<ClInclude Include="..\..\node\MAC.hpp" />
<ClInclude Include="..\..\node\Membership.hpp" />
<ClInclude Include="..\..\node\Multicaster.hpp" />
<ClInclude Include="..\..\node\MulticastGroup.hpp" />
<ClInclude Include="..\..\node\Mutex.hpp" />
<ClInclude Include="..\..\node\Network.hpp" />
<ClInclude Include="..\..\node\NetworkConfig.hpp" />
<ClInclude Include="..\..\node\NetworkController.hpp" />
<ClInclude Include="..\..\node\Node.hpp" />
<ClInclude Include="..\..\node\NonCopyable.hpp" />
<ClInclude Include="..\..\node\OutboundMulticast.hpp" />
<ClInclude Include="..\..\node\Packet.hpp" />
<ClInclude Include="..\..\node\Path.hpp" />
<ClInclude Include="..\..\node\Peer.hpp" />
<ClInclude Include="..\..\node\Poly1305.hpp" />
<ClInclude Include="..\..\node\Revocation.hpp" />
<ClInclude Include="..\..\node\RuntimeEnvironment.hpp" />
<ClInclude Include="..\..\node\Salsa20.hpp" />
<ClInclude Include="..\..\node\SelfAwareness.hpp" />
<ClInclude Include="..\..\node\SHA512.hpp" />
<ClInclude Include="..\..\node\SharedPtr.hpp" />
<ClInclude Include="..\..\node\Switch.hpp" />
<ClInclude Include="..\..\node\Tag.hpp" />
<ClInclude Include="..\..\node\Topology.hpp" />
<ClInclude Include="..\..\node\Utils.hpp" />
<ClInclude Include="..\..\node\World.hpp" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\node\C25519.cpp" />
<ClCompile Include="..\..\node\Capability.cpp" />
<ClCompile Include="..\..\node\CertificateOfMembership.cpp" />
<ClCompile Include="..\..\node\CertificateOfOwnership.cpp" />
<ClCompile Include="..\..\node\Cluster.cpp" />
<ClCompile Include="..\..\node\Identity.cpp" />
<ClCompile Include="..\..\node\IncomingPacket.cpp" />
<ClCompile Include="..\..\node\InetAddress.cpp" />
<ClCompile Include="..\..\node\Membership.cpp" />
<ClCompile Include="..\..\node\Multicaster.cpp" />
<ClCompile Include="..\..\node\Network.cpp" />
<ClCompile Include="..\..\node\NetworkConfig.cpp" />
<ClCompile Include="..\..\node\Node.cpp" />
<ClCompile Include="..\..\node\OutboundMulticast.cpp" />
<ClCompile Include="..\..\node\Packet.cpp" />
<ClCompile Include="..\..\node\Path.cpp" />
<ClCompile Include="..\..\node\Peer.cpp" />
<ClCompile Include="..\..\node\Poly1305.cpp" />
<ClCompile Include="..\..\node\Revocation.cpp" />
<ClCompile Include="..\..\node\Salsa20.cpp" />
<ClCompile Include="..\..\node\SelfAwareness.cpp" />
<ClCompile Include="..\..\node\SHA512.cpp" />
<ClCompile Include="..\..\node\Switch.cpp" />
<ClCompile Include="..\..\node\Tag.cpp" />
<ClCompile Include="..\..\node\Topology.cpp" />
<ClCompile Include="..\..\node\Utils.cpp" />
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,240 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ZeroTierOne.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Node.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Utils.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Address.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Array.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\AtomicCounter.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Buffer.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\C25519.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Capability.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\CertificateOfMembership.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\CertificateOfOwnership.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\CertificateOfRepresentation.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Cluster.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Constants.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Credential.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Dictionary.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Hashtable.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Identity.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\IncomingPacket.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\InetAddress.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\MAC.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Membership.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Multicaster.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\MulticastGroup.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Mutex.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Network.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\NetworkConfig.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\NetworkController.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\NonCopyable.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\OutboundMulticast.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Packet.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Path.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Peer.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Poly1305.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Revocation.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\RuntimeEnvironment.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Salsa20.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\SelfAwareness.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\SHA512.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\SharedPtr.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Switch.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Tag.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\Topology.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\node\World.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Node.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\C25519.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Capability.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\CertificateOfMembership.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\CertificateOfOwnership.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Cluster.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Identity.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\IncomingPacket.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\InetAddress.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Membership.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Multicaster.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Network.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\NetworkConfig.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\OutboundMulticast.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Packet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Path.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Peer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Poly1305.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Revocation.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Salsa20.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\SelfAwareness.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\SHA512.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Switch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Tag.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\node\Topology.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,22 @@
// dllmain.cpp : Defines the entry point for the DLL application.
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include "targetver.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

View File

@@ -0,0 +1,8 @@
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>

3
windows/packages/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*
!repositories.config
!.gitignore

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\WinUI\packages.config" />
</repositories>