mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
NDIS6 driver with VS project to build -- builds correctly, not customized for ZT yet.
This commit is contained in:
parent
ce09e363dc
commit
1ebe2ad920
31 changed files with 10013 additions and 0 deletions
249
windows/TapDriver6/TapDriver6.vcxproj
Normal file
249
windows/TapDriver6/TapDriver6.vcxproj
Normal file
|
@ -0,0 +1,249 @@
|
||||||
|
<?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|Win32">
|
||||||
|
<Configuration>Win8 Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Win8 Release|Win32">
|
||||||
|
<Configuration>Win8 Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Win7 Debug|Win32">
|
||||||
|
<Configuration>Win7 Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Win7 Release|Win32">
|
||||||
|
<Configuration>Win7 Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Vista Debug|Win32">
|
||||||
|
<Configuration>Vista Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Vista Release|Win32">
|
||||||
|
<Configuration>Vista 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>
|
||||||
|
<ProjectConfiguration Include="Win7 Debug|x64">
|
||||||
|
<Configuration>Win7 Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Win7 Release|x64">
|
||||||
|
<Configuration>Win7 Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Vista Debug|x64">
|
||||||
|
<Configuration>Vista Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Vista Release|x64">
|
||||||
|
<Configuration>Vista 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>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Label="PropertySheets">
|
||||||
|
<PlatformToolset>WindowsKernelModeDriver8.0</PlatformToolset>
|
||||||
|
<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>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'" Label="Configuration">
|
||||||
|
<TargetVersion>Windows8</TargetVersion>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|Win32'" Label="Configuration">
|
||||||
|
<TargetVersion>Windows7</TargetVersion>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win7 Release|Win32'" Label="Configuration">
|
||||||
|
<TargetVersion>Windows7</TargetVersion>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Vista Debug|Win32'" Label="Configuration">
|
||||||
|
<TargetVersion>Vista</TargetVersion>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Vista Release|Win32'" Label="Configuration">
|
||||||
|
<TargetVersion>Vista</TargetVersion>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'" Label="Configuration">
|
||||||
|
<TargetVersion>Windows8</TargetVersion>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'" Label="Configuration">
|
||||||
|
<TargetVersion>Windows8</TargetVersion>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|x64'" Label="Configuration">
|
||||||
|
<TargetVersion>Windows7</TargetVersion>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win7 Release|x64'" Label="Configuration">
|
||||||
|
<TargetVersion>Windows7</TargetVersion>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Vista Debug|x64'" Label="Configuration">
|
||||||
|
<TargetVersion>Vista</TargetVersion>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Vista Release|x64'" Label="Configuration">
|
||||||
|
<TargetVersion>Vista</TargetVersion>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
</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 />
|
||||||
|
<PropertyGroup>
|
||||||
|
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<WppEnabled>false</WppEnabled>
|
||||||
|
<WppScanConfigurationData Condition="'%(ClCompile. ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
|
||||||
|
<WppKernelMode>false</WppKernelMode>
|
||||||
|
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Vista Debug|Win32'">false</WppMinimalRebuildFromTracking>
|
||||||
|
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">false</WppMinimalRebuildFromTracking>
|
||||||
|
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Vista Release|Win32'">false</WppMinimalRebuildFromTracking>
|
||||||
|
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|Win32'">false</WppMinimalRebuildFromTracking>
|
||||||
|
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win7 Release|Win32'">false</WppMinimalRebuildFromTracking>
|
||||||
|
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">false</WppMinimalRebuildFromTracking>
|
||||||
|
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Vista Debug|x64'">false</WppMinimalRebuildFromTracking>
|
||||||
|
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">false</WppMinimalRebuildFromTracking>
|
||||||
|
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Vista Release|x64'">false</WppMinimalRebuildFromTracking>
|
||||||
|
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|x64'">false</WppMinimalRebuildFromTracking>
|
||||||
|
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win7 Release|x64'">false</WppMinimalRebuildFromTracking>
|
||||||
|
<WppMinimalRebuildFromTracking Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">false</WppMinimalRebuildFromTracking>
|
||||||
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Vista Debug|Win32'">Level1</WarningLevel>
|
||||||
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">Level1</WarningLevel>
|
||||||
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Vista Release|Win32'">Level1</WarningLevel>
|
||||||
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|Win32'">Level1</WarningLevel>
|
||||||
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win7 Release|Win32'">Level1</WarningLevel>
|
||||||
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">Level1</WarningLevel>
|
||||||
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Vista Debug|x64'">Level1</WarningLevel>
|
||||||
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">Level1</WarningLevel>
|
||||||
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Vista Release|x64'">Level1</WarningLevel>
|
||||||
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|x64'">Level1</WarningLevel>
|
||||||
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win7 Release|x64'">Level1</WarningLevel>
|
||||||
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">Level1</WarningLevel>
|
||||||
|
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Vista Debug|Win32'">Default</CompileAs>
|
||||||
|
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">Default</CompileAs>
|
||||||
|
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Vista Release|Win32'">Default</CompileAs>
|
||||||
|
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|Win32'">Default</CompileAs>
|
||||||
|
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win7 Release|Win32'">Default</CompileAs>
|
||||||
|
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">Default</CompileAs>
|
||||||
|
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Vista Debug|x64'">Default</CompileAs>
|
||||||
|
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">Default</CompileAs>
|
||||||
|
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Vista Release|x64'">Default</CompileAs>
|
||||||
|
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|x64'">Default</CompileAs>
|
||||||
|
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win7 Release|x64'">Default</CompileAs>
|
||||||
|
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">Default</CompileAs>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Vista 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>
|
||||||
|
</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>
|
||||||
|
</Link>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Vista Release|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>
|
||||||
|
</Link>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Win7 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>
|
||||||
|
</Link>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Win7 Release|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>
|
||||||
|
</Link>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Win8 Release|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>
|
||||||
|
</Link>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Vista 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>
|
||||||
|
<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>
|
||||||
|
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Vista Release|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>
|
||||||
|
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Win7 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>
|
||||||
|
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Win7 Release|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>
|
||||||
|
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Win8 Release|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>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<FilesToPackage Include="$(TargetPath)" />
|
||||||
|
<FilesToPackage Include="@(Inf->'%(CopyOutput)')" Condition="'@(Inf)'!=''" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="adapter.c" />
|
||||||
|
<ClCompile Include="device.c" />
|
||||||
|
<ClCompile Include="dhcp.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="dhcp.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="tap-windows.h" />
|
||||||
|
<ClInclude Include="tap.h" />
|
||||||
|
<ClInclude Include="types.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="resource.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
108
windows/TapDriver6/TapDriver6.vcxproj.filters
Normal file
108
windows/TapDriver6/TapDriver6.vcxproj.filters
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
<?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="dhcp.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="dhcp.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>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="resource.rc">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
1716
windows/TapDriver6/adapter.c
Normal file
1716
windows/TapDriver6/adapter.c
Normal file
File diff suppressed because it is too large
Load diff
348
windows/TapDriver6/adapter.h
Normal file
348
windows/TapDriver6/adapter.h
Normal file
|
@ -0,0 +1,348 @@
|
||||||
|
/*
|
||||||
|
* 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_
|
20
windows/TapDriver6/config.h
Normal file
20
windows/TapDriver6/config.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
#define PRODUCT_NAME "@PRODUCT_NAME@"
|
||||||
|
#define PRODUCT_VERSION "@PRODUCT_VERSION@"
|
||||||
|
#define PRODUCT_VERSION_RESOURCE @PRODUCT_VERSION_RESOURCE@
|
||||||
|
#define PRODUCT_TAP_WIN_COMPONENT_ID "@PRODUCT_TAP_WIN_COMPONENT_ID@"
|
||||||
|
#define PRODUCT_TAP_WIN_MAJOR @PRODUCT_TAP_WIN_MAJOR@
|
||||||
|
#define PRODUCT_TAP_WIN_MINOR @PRODUCT_TAP_WIN_MINOR@
|
||||||
|
#define PRODUCT_TAP_WIN_PROVIDER "@PRODUCT_TAP_WIN_PROVIDER@"
|
||||||
|
#define PRODUCT_TAP_WIN_DEVICE_DESCRIPTION "@PRODUCT_TAP_WIN_DEVICE_DESCRIPTION@"
|
||||||
|
#define PRODUCT_TAP_WIN_RELDATE "@PRODUCT_TAP_WIN_RELDATE@"
|
||||||
|
*/
|
||||||
|
#define PRODUCT_NAME "ZeroTier One Virtual Network 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 Networks"
|
||||||
|
#define PRODUCT_TAP_WIN_DEVICE_DESCRIPTION PRODUCT_NAME
|
||||||
|
#define PRODUCT_TAP_WIN_RELDATE "04/24/2015"
|
195
windows/TapDriver6/constants.h
Normal file
195
windows/TapDriver6/constants.h
Normal file
|
@ -0,0 +1,195 @@
|
||||||
|
/*
|
||||||
|
* 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_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 32
|
||||||
|
|
||||||
|
#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 32 // 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
|
1169
windows/TapDriver6/device.c
Normal file
1169
windows/TapDriver6/device.c
Normal file
File diff suppressed because it is too large
Load diff
50
windows/TapDriver6/device.h
Normal file
50
windows/TapDriver6/device.h
Normal 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_
|
710
windows/TapDriver6/dhcp.c
Normal file
710
windows/TapDriver6/dhcp.c
Normal file
|
@ -0,0 +1,710 @@
|
||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
//=========================
|
||||||
|
// Code to set DHCP options
|
||||||
|
//=========================
|
||||||
|
|
||||||
|
VOID
|
||||||
|
SetDHCPOpt(
|
||||||
|
__in DHCPMsg *m,
|
||||||
|
__in void *data,
|
||||||
|
__in unsigned int len
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!m->overflow)
|
||||||
|
{
|
||||||
|
if (m->optlen + len <= DHCP_OPTIONS_BUFFER_SIZE)
|
||||||
|
{
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
NdisMoveMemory (m->msg.options + m->optlen, data, len);
|
||||||
|
m->optlen += len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m->overflow = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
SetDHCPOpt0(
|
||||||
|
__in DHCPMsg *msg,
|
||||||
|
__in int type
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DHCPOPT0 opt;
|
||||||
|
opt.type = (UCHAR) type;
|
||||||
|
SetDHCPOpt (msg, &opt, sizeof (opt));
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
SetDHCPOpt8(
|
||||||
|
__in DHCPMsg *msg,
|
||||||
|
__in int type,
|
||||||
|
__in ULONG data
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DHCPOPT8 opt;
|
||||||
|
opt.type = (UCHAR) type;
|
||||||
|
opt.len = sizeof (opt.data);
|
||||||
|
opt.data = (UCHAR) data;
|
||||||
|
SetDHCPOpt (msg, &opt, sizeof (opt));
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
SetDHCPOpt32(
|
||||||
|
__in DHCPMsg *msg,
|
||||||
|
__in int type,
|
||||||
|
__in ULONG data
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DHCPOPT32 opt;
|
||||||
|
opt.type = (UCHAR) type;
|
||||||
|
opt.len = sizeof (opt.data);
|
||||||
|
opt.data = data;
|
||||||
|
SetDHCPOpt (msg, &opt, sizeof (opt));
|
||||||
|
}
|
||||||
|
|
||||||
|
//==============
|
||||||
|
// Checksum code
|
||||||
|
//==============
|
||||||
|
|
||||||
|
USHORT
|
||||||
|
ip_checksum(
|
||||||
|
__in const UCHAR *buf,
|
||||||
|
__in const int len_ip_header
|
||||||
|
)
|
||||||
|
{
|
||||||
|
USHORT word16;
|
||||||
|
ULONG sum = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// make 16 bit words out of every two adjacent 8 bit words in the packet
|
||||||
|
// and add them up
|
||||||
|
for (i = 0; i < len_ip_header - 1; i += 2)
|
||||||
|
{
|
||||||
|
word16 = ((buf[i] << 8) & 0xFF00) + (buf[i+1] & 0xFF);
|
||||||
|
sum += (ULONG) word16;
|
||||||
|
}
|
||||||
|
|
||||||
|
// take only 16 bits out of the 32 bit sum and add up the carries
|
||||||
|
while (sum >> 16)
|
||||||
|
{
|
||||||
|
sum = (sum & 0xFFFF) + (sum >> 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
// one's complement the result
|
||||||
|
return ((USHORT) ~sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
USHORT
|
||||||
|
udp_checksum (
|
||||||
|
__in const UCHAR *buf,
|
||||||
|
__in const int len_udp,
|
||||||
|
__in const UCHAR *src_addr,
|
||||||
|
__in const UCHAR *dest_addr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
USHORT word16;
|
||||||
|
ULONG sum = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// make 16 bit words out of every two adjacent 8 bit words and
|
||||||
|
// calculate the sum of all 16 bit words
|
||||||
|
for (i = 0; i < len_udp; i += 2)
|
||||||
|
{
|
||||||
|
word16 = ((buf[i] << 8) & 0xFF00) + ((i + 1 < len_udp) ? (buf[i+1] & 0xFF) : 0);
|
||||||
|
sum += word16;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the UDP pseudo header which contains the IP source and destination addresses
|
||||||
|
for (i = 0; i < 4; i += 2)
|
||||||
|
{
|
||||||
|
word16 =((src_addr[i] << 8) & 0xFF00) + (src_addr[i+1] & 0xFF);
|
||||||
|
sum += word16;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < 4; i += 2)
|
||||||
|
{
|
||||||
|
word16 =((dest_addr[i] << 8) & 0xFF00) + (dest_addr[i+1] & 0xFF);
|
||||||
|
sum += word16;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the protocol number and the length of the UDP packet
|
||||||
|
sum += (USHORT) IPPROTO_UDP + (USHORT) len_udp;
|
||||||
|
|
||||||
|
// keep only the last 16 bits of the 32 bit calculated sum and add the carries
|
||||||
|
while (sum >> 16)
|
||||||
|
{
|
||||||
|
sum = (sum & 0xFFFF) + (sum >> 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Take the one's complement of sum
|
||||||
|
return ((USHORT) ~sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
//================================
|
||||||
|
// Set IP and UDP packet checksums
|
||||||
|
//================================
|
||||||
|
|
||||||
|
VOID
|
||||||
|
SetChecksumDHCPMsg(
|
||||||
|
__in DHCPMsg *m
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Set IP checksum
|
||||||
|
m->msg.pre.ip.check = htons (ip_checksum ((UCHAR *) &m->msg.pre.ip, sizeof (IPHDR)));
|
||||||
|
|
||||||
|
// Set UDP Checksum
|
||||||
|
m->msg.pre.udp.check = htons (udp_checksum ((UCHAR *) &m->msg.pre.udp,
|
||||||
|
sizeof (UDPHDR) + sizeof (DHCP) + m->optlen,
|
||||||
|
(UCHAR *)&m->msg.pre.ip.saddr,
|
||||||
|
(UCHAR *)&m->msg.pre.ip.daddr));
|
||||||
|
}
|
||||||
|
|
||||||
|
//===================
|
||||||
|
// DHCP message tests
|
||||||
|
//===================
|
||||||
|
|
||||||
|
int
|
||||||
|
GetDHCPMessageType(
|
||||||
|
__in const DHCP *dhcp,
|
||||||
|
__in const int optlen
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const UCHAR *p = (UCHAR *) (dhcp + 1);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < optlen; ++i)
|
||||||
|
{
|
||||||
|
const UCHAR type = p[i];
|
||||||
|
const int room = optlen - i - 1;
|
||||||
|
|
||||||
|
if (type == DHCP_END) // didn't find what we were looking for
|
||||||
|
return -1;
|
||||||
|
else if (type == DHCP_PAD) // no-operation
|
||||||
|
;
|
||||||
|
else if (type == DHCP_MSG_TYPE) // what we are looking for
|
||||||
|
{
|
||||||
|
if (room >= 2)
|
||||||
|
{
|
||||||
|
if (p[i+1] == 1) // message length should be 1
|
||||||
|
return p[i+2]; // return message type
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else // some other message
|
||||||
|
{
|
||||||
|
if (room >= 1)
|
||||||
|
{
|
||||||
|
const int len = p[i+1]; // get message length
|
||||||
|
i += (len + 1); // advance to next message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
DHCPMessageOurs (
|
||||||
|
__in const PTAP_ADAPTER_CONTEXT Adapter,
|
||||||
|
__in const ETH_HEADER *eth,
|
||||||
|
__in const IPHDR *ip,
|
||||||
|
__in const UDPHDR *udp,
|
||||||
|
__in const DHCP *dhcp
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Must be UDPv4 protocol
|
||||||
|
if (!(eth->proto == htons (NDIS_ETH_TYPE_IPV4) && ip->protocol == IPPROTO_UDP))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Source MAC must be our adapter
|
||||||
|
if (!MAC_EQUAL (eth->src, Adapter->CurrentAddress))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dest MAC must be either broadcast or our virtual DHCP server
|
||||||
|
if (!(ETH_IS_BROADCAST(eth->dest)
|
||||||
|
|| MAC_EQUAL (eth->dest, Adapter->m_dhcp_server_mac)))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Port numbers must be correct
|
||||||
|
if (!(udp->dest == htons (BOOTPS_PORT)
|
||||||
|
&& udp->source == htons (BOOTPC_PORT)))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hardware address must be MAC addr sized
|
||||||
|
if (!(dhcp->hlen == sizeof (MACADDR)))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hardware address must match our adapter
|
||||||
|
if (!MAC_EQUAL (eth->src, dhcp->chaddr))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================
|
||||||
|
// Build all of DHCP packet except for DHCP options.
|
||||||
|
// Assume that *p has been zeroed before we are called.
|
||||||
|
//=====================================================
|
||||||
|
|
||||||
|
VOID
|
||||||
|
BuildDHCPPre (
|
||||||
|
__in const PTAP_ADAPTER_CONTEXT Adapter,
|
||||||
|
__inout DHCPPre *p,
|
||||||
|
__in const ETH_HEADER *eth,
|
||||||
|
__in const IPHDR *ip,
|
||||||
|
__in const UDPHDR *udp,
|
||||||
|
__in const DHCP *dhcp,
|
||||||
|
__in const int optlen,
|
||||||
|
__in const int type)
|
||||||
|
{
|
||||||
|
// Should we broadcast or direct to a specific MAC / IP address?
|
||||||
|
const BOOLEAN broadcast = (type == DHCPNAK
|
||||||
|
|| ETH_IS_BROADCAST(eth->dest));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build ethernet header
|
||||||
|
//
|
||||||
|
ETH_COPY_NETWORK_ADDRESS (p->eth.src, Adapter->m_dhcp_server_mac);
|
||||||
|
|
||||||
|
if (broadcast)
|
||||||
|
{
|
||||||
|
memset(p->eth.dest,0xFF,ETH_LENGTH_OF_ADDRESS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ETH_COPY_NETWORK_ADDRESS (p->eth.dest, eth->src);
|
||||||
|
}
|
||||||
|
|
||||||
|
p->eth.proto = htons (NDIS_ETH_TYPE_IPV4);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build IP header
|
||||||
|
//
|
||||||
|
p->ip.version_len = (4 << 4) | (sizeof (IPHDR) >> 2);
|
||||||
|
p->ip.tos = 0;
|
||||||
|
p->ip.tot_len = htons (sizeof (IPHDR) + sizeof (UDPHDR) + sizeof (DHCP) + optlen);
|
||||||
|
p->ip.id = 0;
|
||||||
|
p->ip.frag_off = 0;
|
||||||
|
p->ip.ttl = 16;
|
||||||
|
p->ip.protocol = IPPROTO_UDP;
|
||||||
|
p->ip.check = 0;
|
||||||
|
p->ip.saddr = Adapter->m_dhcp_server_ip;
|
||||||
|
|
||||||
|
if (broadcast)
|
||||||
|
{
|
||||||
|
p->ip.daddr = ~0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p->ip.daddr = Adapter->m_dhcp_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build UDP header
|
||||||
|
//
|
||||||
|
p->udp.source = htons (BOOTPS_PORT);
|
||||||
|
p->udp.dest = htons (BOOTPC_PORT);
|
||||||
|
p->udp.len = htons (sizeof (UDPHDR) + sizeof (DHCP) + optlen);
|
||||||
|
p->udp.check = 0;
|
||||||
|
|
||||||
|
// Build DHCP response
|
||||||
|
|
||||||
|
p->dhcp.op = BOOTREPLY;
|
||||||
|
p->dhcp.htype = 1;
|
||||||
|
p->dhcp.hlen = sizeof (MACADDR);
|
||||||
|
p->dhcp.hops = 0;
|
||||||
|
p->dhcp.xid = dhcp->xid;
|
||||||
|
p->dhcp.secs = 0;
|
||||||
|
p->dhcp.flags = 0;
|
||||||
|
p->dhcp.ciaddr = 0;
|
||||||
|
|
||||||
|
if (type == DHCPNAK)
|
||||||
|
{
|
||||||
|
p->dhcp.yiaddr = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p->dhcp.yiaddr = Adapter->m_dhcp_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
p->dhcp.siaddr = Adapter->m_dhcp_server_ip;
|
||||||
|
p->dhcp.giaddr = 0;
|
||||||
|
ETH_COPY_NETWORK_ADDRESS (p->dhcp.chaddr, eth->src);
|
||||||
|
p->dhcp.magic = htonl (0x63825363);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=============================
|
||||||
|
// Build specific DHCP messages
|
||||||
|
//=============================
|
||||||
|
|
||||||
|
VOID
|
||||||
|
SendDHCPMsg(
|
||||||
|
__in PTAP_ADAPTER_CONTEXT Adapter,
|
||||||
|
__in const int type,
|
||||||
|
__in const ETH_HEADER *eth,
|
||||||
|
__in const IPHDR *ip,
|
||||||
|
__in const UDPHDR *udp,
|
||||||
|
__in const DHCP *dhcp
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DHCPMsg *pkt;
|
||||||
|
|
||||||
|
if (!(type == DHCPOFFER || type == DHCPACK || type == DHCPNAK))
|
||||||
|
{
|
||||||
|
DEBUGP (("[TAP] SendDHCPMsg: Bad DHCP type: %d\n", type));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pkt = (DHCPMsg *) MemAlloc (sizeof (DHCPMsg), TRUE);
|
||||||
|
|
||||||
|
if(pkt)
|
||||||
|
{
|
||||||
|
//-----------------------
|
||||||
|
// Build DHCP options
|
||||||
|
//-----------------------
|
||||||
|
|
||||||
|
// Message Type
|
||||||
|
SetDHCPOpt8 (pkt, DHCP_MSG_TYPE, type);
|
||||||
|
|
||||||
|
// Server ID
|
||||||
|
SetDHCPOpt32 (pkt, DHCP_SERVER_ID, Adapter->m_dhcp_server_ip);
|
||||||
|
|
||||||
|
if (type == DHCPOFFER || type == DHCPACK)
|
||||||
|
{
|
||||||
|
// Lease Time
|
||||||
|
SetDHCPOpt32 (pkt, DHCP_LEASE_TIME, htonl (Adapter->m_dhcp_lease_time));
|
||||||
|
|
||||||
|
// Netmask
|
||||||
|
SetDHCPOpt32 (pkt, DHCP_NETMASK, Adapter->m_dhcp_netmask);
|
||||||
|
|
||||||
|
// Other user-defined options
|
||||||
|
SetDHCPOpt (
|
||||||
|
pkt,
|
||||||
|
Adapter->m_dhcp_user_supplied_options_buffer,
|
||||||
|
Adapter->m_dhcp_user_supplied_options_buffer_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
// End
|
||||||
|
SetDHCPOpt0 (pkt, DHCP_END);
|
||||||
|
|
||||||
|
if (!DHCPMSG_OVERFLOW (pkt))
|
||||||
|
{
|
||||||
|
// The initial part of the DHCP message (not including options) gets built here
|
||||||
|
BuildDHCPPre (
|
||||||
|
Adapter,
|
||||||
|
&pkt->msg.pre,
|
||||||
|
eth,
|
||||||
|
ip,
|
||||||
|
udp,
|
||||||
|
dhcp,
|
||||||
|
DHCPMSG_LEN_OPT (pkt),
|
||||||
|
type);
|
||||||
|
|
||||||
|
SetChecksumDHCPMsg (pkt);
|
||||||
|
|
||||||
|
DUMP_PACKET ("DHCPMsg",
|
||||||
|
DHCPMSG_BUF (pkt),
|
||||||
|
DHCPMSG_LEN_FULL (pkt));
|
||||||
|
|
||||||
|
// Return DHCP response to kernel
|
||||||
|
IndicateReceivePacket(
|
||||||
|
Adapter,
|
||||||
|
DHCPMSG_BUF (pkt),
|
||||||
|
DHCPMSG_LEN_FULL (pkt)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DEBUGP (("[TAP] SendDHCPMsg: DHCP buffer overflow\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
MemFree (pkt, sizeof (DHCPMsg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//===================================================================
|
||||||
|
// Handle a BOOTPS packet produced by the local system to
|
||||||
|
// resolve the address/netmask of this adapter.
|
||||||
|
// If we are in TAP_WIN_IOCTL_CONFIG_DHCP_MASQ mode, reply
|
||||||
|
// to the message. Return TRUE if we processed the passed
|
||||||
|
// message, so that downstream stages can ignore it.
|
||||||
|
//===================================================================
|
||||||
|
|
||||||
|
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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int msg_type;
|
||||||
|
|
||||||
|
// Sanity check IP header
|
||||||
|
if (!(ntohs (ip->tot_len) == sizeof (IPHDR) + sizeof (UDPHDR) + sizeof (DHCP) + optlen
|
||||||
|
&& (ntohs (ip->frag_off) & IP_OFFMASK) == 0))
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Does this message belong to us?
|
||||||
|
if (!DHCPMessageOurs (Adapter, eth, ip, udp, dhcp))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_type = GetDHCPMessageType (dhcp, optlen);
|
||||||
|
|
||||||
|
// Drop non-BOOTREQUEST messages
|
||||||
|
if (dhcp->op != BOOTREQUEST)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Drop any messages except DHCPDISCOVER or DHCPREQUEST
|
||||||
|
if (!(msg_type == DHCPDISCOVER || msg_type == DHCPREQUEST))
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should we reply with DHCPOFFER, DHCPACK, or DHCPNAK?
|
||||||
|
if (msg_type == DHCPREQUEST
|
||||||
|
&& ((dhcp->ciaddr && dhcp->ciaddr != Adapter->m_dhcp_addr)
|
||||||
|
|| !Adapter->m_dhcp_received_discover
|
||||||
|
|| Adapter->m_dhcp_bad_requests >= BAD_DHCPREQUEST_NAK_THRESHOLD))
|
||||||
|
{
|
||||||
|
SendDHCPMsg(
|
||||||
|
Adapter,
|
||||||
|
DHCPNAK,
|
||||||
|
eth, ip, udp, dhcp
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SendDHCPMsg(
|
||||||
|
Adapter,
|
||||||
|
(msg_type == DHCPDISCOVER ? DHCPOFFER : DHCPACK),
|
||||||
|
eth, ip, udp, dhcp
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remember if we received a DHCPDISCOVER
|
||||||
|
if (msg_type == DHCPDISCOVER)
|
||||||
|
{
|
||||||
|
Adapter->m_dhcp_received_discover = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is this a bad DHCPREQUEST?
|
||||||
|
if (msg_type == DHCPREQUEST && dhcp->ciaddr && dhcp->ciaddr != Adapter->m_dhcp_addr)
|
||||||
|
{
|
||||||
|
++Adapter->m_dhcp_bad_requests;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DBG
|
||||||
|
|
||||||
|
const char *
|
||||||
|
message_op_text (int op)
|
||||||
|
{
|
||||||
|
switch (op)
|
||||||
|
{
|
||||||
|
case BOOTREQUEST:
|
||||||
|
return "BOOTREQUEST";
|
||||||
|
|
||||||
|
case BOOTREPLY:
|
||||||
|
return "BOOTREPLY";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "???";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
message_type_text (int type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case DHCPDISCOVER:
|
||||||
|
return "DHCPDISCOVER";
|
||||||
|
|
||||||
|
case DHCPOFFER:
|
||||||
|
return "DHCPOFFER";
|
||||||
|
|
||||||
|
case DHCPREQUEST:
|
||||||
|
return "DHCPREQUEST";
|
||||||
|
|
||||||
|
case DHCPDECLINE:
|
||||||
|
return "DHCPDECLINE";
|
||||||
|
|
||||||
|
case DHCPACK:
|
||||||
|
return "DHCPACK";
|
||||||
|
|
||||||
|
case DHCPNAK:
|
||||||
|
return "DHCPNAK";
|
||||||
|
|
||||||
|
case DHCPRELEASE:
|
||||||
|
return "DHCPRELEASE";
|
||||||
|
|
||||||
|
case DHCPINFORM:
|
||||||
|
return "DHCPINFORM";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "???";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
port_name (int port)
|
||||||
|
{
|
||||||
|
switch (port)
|
||||||
|
{
|
||||||
|
case BOOTPS_PORT:
|
||||||
|
return "BOOTPS";
|
||||||
|
|
||||||
|
case BOOTPC_PORT:
|
||||||
|
return "BOOTPC";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
DumpDHCP (
|
||||||
|
const ETH_HEADER *eth,
|
||||||
|
const IPHDR *ip,
|
||||||
|
const UDPHDR *udp,
|
||||||
|
const DHCP *dhcp,
|
||||||
|
const int optlen
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DEBUGP ((" %s", message_op_text (dhcp->op)));
|
||||||
|
DEBUGP ((" %s ", message_type_text (GetDHCPMessageType (dhcp, optlen))));
|
||||||
|
PrIP (ip->saddr);
|
||||||
|
DEBUGP ((":%s[", port_name (ntohs (udp->source))));
|
||||||
|
PrMac (eth->src);
|
||||||
|
DEBUGP (("] -> "));
|
||||||
|
PrIP (ip->daddr);
|
||||||
|
DEBUGP ((":%s[", port_name (ntohs (udp->dest))));
|
||||||
|
PrMac (eth->dest);
|
||||||
|
DEBUGP (("]"));
|
||||||
|
if (dhcp->ciaddr)
|
||||||
|
{
|
||||||
|
DEBUGP ((" ci="));
|
||||||
|
PrIP (dhcp->ciaddr);
|
||||||
|
}
|
||||||
|
if (dhcp->yiaddr)
|
||||||
|
{
|
||||||
|
DEBUGP ((" yi="));
|
||||||
|
PrIP (dhcp->yiaddr);
|
||||||
|
}
|
||||||
|
if (dhcp->siaddr)
|
||||||
|
{
|
||||||
|
DEBUGP ((" si="));
|
||||||
|
PrIP (dhcp->siaddr);
|
||||||
|
}
|
||||||
|
if (dhcp->hlen == sizeof (MACADDR))
|
||||||
|
{
|
||||||
|
DEBUGP ((" ch="));
|
||||||
|
PrMac (dhcp->chaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUGP ((" xid=0x%08x", ntohl (dhcp->xid)));
|
||||||
|
|
||||||
|
if (ntohl (dhcp->magic) != 0x63825363)
|
||||||
|
DEBUGP ((" ma=0x%08x", ntohl (dhcp->magic)));
|
||||||
|
if (dhcp->htype != 1)
|
||||||
|
DEBUGP ((" htype=%d", dhcp->htype));
|
||||||
|
if (dhcp->hops)
|
||||||
|
DEBUGP ((" hops=%d", dhcp->hops));
|
||||||
|
if (ntohs (dhcp->secs))
|
||||||
|
DEBUGP ((" secs=%d", ntohs (dhcp->secs)));
|
||||||
|
if (ntohs (dhcp->flags))
|
||||||
|
DEBUGP ((" flags=0x%04x", ntohs (dhcp->flags)));
|
||||||
|
|
||||||
|
// extra stuff
|
||||||
|
|
||||||
|
if (ip->version_len != 0x45)
|
||||||
|
DEBUGP ((" vl=0x%02x", ip->version_len));
|
||||||
|
if (ntohs (ip->tot_len) != sizeof (IPHDR) + sizeof (UDPHDR) + sizeof (DHCP) + optlen)
|
||||||
|
DEBUGP ((" tl=%d", ntohs (ip->tot_len)));
|
||||||
|
if (ntohs (udp->len) != sizeof (UDPHDR) + sizeof (DHCP) + optlen)
|
||||||
|
DEBUGP ((" ul=%d", ntohs (udp->len)));
|
||||||
|
|
||||||
|
if (ip->tos)
|
||||||
|
DEBUGP ((" tos=0x%02x", ip->tos));
|
||||||
|
if (ntohs (ip->id))
|
||||||
|
DEBUGP ((" id=0x%04x", ntohs (ip->id)));
|
||||||
|
if (ntohs (ip->frag_off))
|
||||||
|
DEBUGP ((" frag_off=0x%04x", ntohs (ip->frag_off)));
|
||||||
|
|
||||||
|
DEBUGP ((" ttl=%d", ip->ttl));
|
||||||
|
DEBUGP ((" ic=0x%04x [0x%04x]", ntohs (ip->check),
|
||||||
|
ip_checksum ((UCHAR*)ip, sizeof (IPHDR))));
|
||||||
|
DEBUGP ((" uc=0x%04x [0x%04x/%d]", ntohs (udp->check),
|
||||||
|
udp_checksum ((UCHAR *) udp,
|
||||||
|
sizeof (UDPHDR) + sizeof (DHCP) + optlen,
|
||||||
|
(UCHAR *) &ip->saddr,
|
||||||
|
(UCHAR *) &ip->daddr),
|
||||||
|
optlen));
|
||||||
|
|
||||||
|
// Options
|
||||||
|
{
|
||||||
|
const UCHAR *opt = (UCHAR *) (dhcp + 1);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
DEBUGP ((" OPT"));
|
||||||
|
for (i = 0; i < optlen; ++i)
|
||||||
|
{
|
||||||
|
const UCHAR data = opt[i];
|
||||||
|
DEBUGP ((".%d", data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* DBG */
|
165
windows/TapDriver6/dhcp.h
Normal file
165
windows/TapDriver6/dhcp.h
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
|
||||||
|
//===================================================
|
||||||
|
// How many bad DHCPREQUESTs do we receive before we
|
||||||
|
// return a NAK?
|
||||||
|
//
|
||||||
|
// A bad DHCPREQUEST is defined to be one where the
|
||||||
|
// requestor doesn't know its IP address.
|
||||||
|
//===================================================
|
||||||
|
|
||||||
|
#define BAD_DHCPREQUEST_NAK_THRESHOLD 3
|
||||||
|
|
||||||
|
//==============================================
|
||||||
|
// Maximum number of DHCP options bytes supplied
|
||||||
|
//==============================================
|
||||||
|
|
||||||
|
#define DHCP_USER_SUPPLIED_OPTIONS_BUFFER_SIZE 256
|
||||||
|
#define DHCP_OPTIONS_BUFFER_SIZE 256
|
||||||
|
|
||||||
|
//===================================
|
||||||
|
// UDP port numbers of DHCP messages.
|
||||||
|
//===================================
|
||||||
|
|
||||||
|
#define BOOTPS_PORT 67
|
||||||
|
#define BOOTPC_PORT 68
|
||||||
|
|
||||||
|
//===========================
|
||||||
|
// The DHCP message structure
|
||||||
|
//===========================
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
# define BOOTREQUEST 1
|
||||||
|
# define BOOTREPLY 2
|
||||||
|
UCHAR op; /* message op */
|
||||||
|
|
||||||
|
UCHAR htype; /* hardware address type (e.g. '1' = 10Mb Ethernet) */
|
||||||
|
UCHAR hlen; /* hardware address length (e.g. '6' for 10Mb Ethernet) */
|
||||||
|
UCHAR hops; /* client sets to 0, may be used by relay agents */
|
||||||
|
ULONG xid; /* transaction ID, chosen by client */
|
||||||
|
USHORT secs; /* seconds since request process began, set by client */
|
||||||
|
USHORT flags;
|
||||||
|
ULONG ciaddr; /* client IP address, client sets if known */
|
||||||
|
ULONG yiaddr; /* 'your' IP address -- server's response to client */
|
||||||
|
ULONG siaddr; /* server IP address */
|
||||||
|
ULONG giaddr; /* relay agent IP address */
|
||||||
|
UCHAR chaddr[16]; /* client hardware address */
|
||||||
|
UCHAR sname[64]; /* optional server host name */
|
||||||
|
UCHAR file[128]; /* boot file name */
|
||||||
|
ULONG magic; /* must be 0x63825363 (network order) */
|
||||||
|
} DHCP;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ETH_HEADER eth;
|
||||||
|
IPHDR ip;
|
||||||
|
UDPHDR udp;
|
||||||
|
DHCP dhcp;
|
||||||
|
} DHCPPre;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DHCPPre pre;
|
||||||
|
UCHAR options[DHCP_OPTIONS_BUFFER_SIZE];
|
||||||
|
} DHCPFull;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int optlen;
|
||||||
|
BOOLEAN overflow;
|
||||||
|
DHCPFull msg;
|
||||||
|
} DHCPMsg;
|
||||||
|
|
||||||
|
//===================
|
||||||
|
// Macros for DHCPMSG
|
||||||
|
//===================
|
||||||
|
|
||||||
|
#define DHCPMSG_LEN_BASE(p) (sizeof (DHCPPre))
|
||||||
|
#define DHCPMSG_LEN_OPT(p) ((p)->optlen)
|
||||||
|
#define DHCPMSG_LEN_FULL(p) (DHCPMSG_LEN_BASE(p) + DHCPMSG_LEN_OPT(p))
|
||||||
|
#define DHCPMSG_BUF(p) ((UCHAR*) &(p)->msg)
|
||||||
|
#define DHCPMSG_OVERFLOW(p) ((p)->overflow)
|
||||||
|
|
||||||
|
//========================================
|
||||||
|
// structs to hold individual DHCP options
|
||||||
|
//========================================
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UCHAR type;
|
||||||
|
} DHCPOPT0;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UCHAR type;
|
||||||
|
UCHAR len;
|
||||||
|
UCHAR data;
|
||||||
|
} DHCPOPT8;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UCHAR type;
|
||||||
|
UCHAR len;
|
||||||
|
ULONG data;
|
||||||
|
} DHCPOPT32;
|
||||||
|
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
//==================
|
||||||
|
// DHCP Option types
|
||||||
|
//==================
|
||||||
|
|
||||||
|
#define DHCP_MSG_TYPE 53 /* message type (u8) */
|
||||||
|
#define DHCP_PARM_REQ 55 /* parameter request list: c1 (u8), ... */
|
||||||
|
#define DHCP_CLIENT_ID 61 /* client ID: type (u8), i1 (u8), ... */
|
||||||
|
#define DHCP_IP 50 /* requested IP addr (u32) */
|
||||||
|
#define DHCP_NETMASK 1 /* subnet mask (u32) */
|
||||||
|
#define DHCP_LEASE_TIME 51 /* lease time sec (u32) */
|
||||||
|
#define DHCP_RENEW_TIME 58 /* renewal time sec (u32) */
|
||||||
|
#define DHCP_REBIND_TIME 59 /* rebind time sec (u32) */
|
||||||
|
#define DHCP_SERVER_ID 54 /* server ID: IP addr (u32) */
|
||||||
|
#define DHCP_PAD 0
|
||||||
|
#define DHCP_END 255
|
||||||
|
|
||||||
|
//====================
|
||||||
|
// DHCP Messages types
|
||||||
|
//====================
|
||||||
|
|
||||||
|
#define DHCPDISCOVER 1
|
||||||
|
#define DHCPOFFER 2
|
||||||
|
#define DHCPREQUEST 3
|
||||||
|
#define DHCPDECLINE 4
|
||||||
|
#define DHCPACK 5
|
||||||
|
#define DHCPNAK 6
|
||||||
|
#define DHCPRELEASE 7
|
||||||
|
#define DHCPINFORM 8
|
||||||
|
|
||||||
|
#if DBG
|
||||||
|
|
||||||
|
VOID
|
||||||
|
DumpDHCP (const ETH_HEADER *eth,
|
||||||
|
const IPHDR *ip,
|
||||||
|
const UDPHDR *udp,
|
||||||
|
const DHCP *dhcp,
|
||||||
|
const int optlen);
|
||||||
|
|
||||||
|
#endif
|
35
windows/TapDriver6/endian.h
Normal file
35
windows/TapDriver6/endian.h
Normal 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
398
windows/TapDriver6/error.c
Normal 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
114
windows/TapDriver6/error.h
Normal 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
|
63
windows/TapDriver6/hexdump.h
Normal file
63
windows/TapDriver6/hexdump.h
Normal 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
75
windows/TapDriver6/lock.h
Normal 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; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
164
windows/TapDriver6/macinfo.c
Normal file
164
windows/TapDriver6/macinfo.c
Normal 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;
|
||||||
|
}
|
53
windows/TapDriver6/macinfo.h
Normal file
53
windows/TapDriver6/macinfo.h
Normal 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
401
windows/TapDriver6/mem.c
Normal 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
113
windows/TapDriver6/mem.h
Normal 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
|
||||||
|
);
|
1028
windows/TapDriver6/oidrequest.c
Normal file
1028
windows/TapDriver6/oidrequest.c
Normal file
File diff suppressed because it is too large
Load diff
224
windows/TapDriver6/proto.h
Normal file
224
windows/TapDriver6/proto.h
Normal 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()
|
87
windows/TapDriver6/prototypes.h
Normal file
87
windows/TapDriver6/prototypes.h
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* 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
|
BIN
windows/TapDriver6/resource.aps
Normal file
BIN
windows/TapDriver6/resource.aps
Normal file
Binary file not shown.
62
windows/TapDriver6/resource.rc
Normal file
62
windows/TapDriver6/resource.rc
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ntverp.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#undef VER_PRODUCTVERSION
|
||||||
|
#undef VER_PRODUCTVERSION_STR
|
||||||
|
#undef VER_COMPANYNAME_STR
|
||||||
|
#undef VER_PRODUCTNAME_STR
|
||||||
|
|
||||||
|
/* VER_FILETYPE, VER_FILESUBTYPE, VER_FILEDESCRIPTION_STR
|
||||||
|
* and VER_INTERNALNAME_STR must be defined before including COMMON.VER
|
||||||
|
* The strings don't need a '\0', since common.ver has them.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define VER_FILETYPE VFT_DRV
|
||||||
|
/* possible values: VFT_UNKNOWN
|
||||||
|
VFT_APP
|
||||||
|
VFT_DLL
|
||||||
|
VFT_DRV
|
||||||
|
VFT_FONT
|
||||||
|
VFT_VXD
|
||||||
|
VFT_STATIC_LIB
|
||||||
|
*/
|
||||||
|
#define VER_FILESUBTYPE VFT2_DRV_NETWORK
|
||||||
|
/* possible values VFT2_UNKNOWN
|
||||||
|
VFT2_DRV_PRINTER
|
||||||
|
VFT2_DRV_KEYBOARD
|
||||||
|
VFT2_DRV_LANGUAGE
|
||||||
|
VFT2_DRV_DISPLAY
|
||||||
|
VFT2_DRV_MOUSE
|
||||||
|
VFT2_DRV_NETWORK
|
||||||
|
VFT2_DRV_SYSTEM
|
||||||
|
VFT2_DRV_INSTALLABLE
|
||||||
|
VFT2_DRV_SOUND
|
||||||
|
VFT2_DRV_COMM
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define VER_COMPANYNAME_STR "The OpenVPN Project"
|
||||||
|
#define VER_FILEDESCRIPTION_STR "TAP-Windows Virtual Network Driver (NDIS 6.0)"
|
||||||
|
#define VER_ORIGINALFILENAME_STR PRODUCT_TAP_WIN_COMPONENT_ID ".sys"
|
||||||
|
#define VER_LEGALCOPYRIGHT_YEARS "2003-2014"
|
||||||
|
#define VER_LEGALCOPYRIGHT_STR "OpenVPN Technologies, Inc."
|
||||||
|
|
||||||
|
|
||||||
|
#define VER_PRODUCTNAME_STR VER_FILEDESCRIPTION_STR
|
||||||
|
#define VER_PRODUCTVERSION PRODUCT_TAP_WIN_MAJOR,00,00,PRODUCT_TAP_WIN_MINOR
|
||||||
|
|
||||||
|
#define XSTR(s) STR(s)
|
||||||
|
#define STR(s) #s
|
||||||
|
|
||||||
|
#define VSTRING PRODUCT_VERSION " " XSTR(PRODUCT_TAP_WIN_MAJOR) "/" XSTR(PRODUCT_TAP_WIN_MINOR)
|
||||||
|
|
||||||
|
#ifdef DBG
|
||||||
|
#define VER_PRODUCTVERSION_STR VSTRING " (DEBUG)"
|
||||||
|
#else
|
||||||
|
#define VER_PRODUCTVERSION_STR VSTRING
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define VER_INTERNALNAME_STR VER_ORIGINALFILENAME_STR
|
||||||
|
|
||||||
|
#include "common.ver"
|
667
windows/TapDriver6/rxpath.c
Normal file
667
windows/TapDriver6/rxpath.c
Normal file
|
@ -0,0 +1,667 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
74
windows/TapDriver6/tap-windows.h
Normal file
74
windows/TapDriver6/tap-windows.h
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* 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)
|
||||||
|
#define TAP_WIN_IOCTL_GET_LOG_LINE TAP_WIN_CONTROL_CODE (8, METHOD_BUFFERED)
|
||||||
|
#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)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* =================
|
||||||
|
* 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
|
90
windows/TapDriver6/tap.h
Normal file
90
windows/TapDriver6/tap.h
Normal 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_H
|
||||||
|
#define __TAP_H
|
||||||
|
|
||||||
|
#ifndef NDIS_SUPPORT_NDIS6
|
||||||
|
#define NDIS_SUPPORT_NDIS6 1
|
||||||
|
#define NDIS_SUPPORT_NDIS61 1
|
||||||
|
#define NDIS_WDM1 1
|
||||||
|
#define NDIS61_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 "dhcp.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "endian.h"
|
||||||
|
#include "dhcp.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 1
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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
|
232
windows/TapDriver6/tapdrvr.c
Normal file
232
windows/TapDriver6/tapdrvr.c
Normal 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"));
|
||||||
|
}
|
||||||
|
|
1168
windows/TapDriver6/txpath.c
Normal file
1168
windows/TapDriver6/txpath.c
Normal file
File diff suppressed because it is too large
Load diff
90
windows/TapDriver6/types.h
Normal file
90
windows/TapDriver6/types.h
Normal 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
|
|
@ -5,6 +5,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TapDriver", "TapDriver\TapD
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZeroTierOne", "ZeroTierOne\ZeroTierOne.vcxproj", "{B00A4957-5977-4AC1-9EF4-571DC27EADA2}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZeroTierOne", "ZeroTierOne\ZeroTierOne.vcxproj", "{B00A4957-5977-4AC1-9EF4-571DC27EADA2}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TapDriver6", "TapDriver6\TapDriver6.vcxproj", "{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
CD_ROM|Any CPU = CD_ROM|Any CPU
|
CD_ROM|Any CPU = CD_ROM|Any CPU
|
||||||
|
@ -295,6 +297,149 @@ Global
|
||||||
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win8 Release|x86.ActiveCfg = Release|Win32
|
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win8 Release|x86.ActiveCfg = Release|Win32
|
||||||
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win8 Release|x86.Build.0 = Release|Win32
|
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win8 Release|x86.Build.0 = Release|Win32
|
||||||
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win8 Release|x86.Deploy.0 = Release|Win32
|
{B00A4957-5977-4AC1-9EF4-571DC27EADA2}.Win8 Release|x86.Deploy.0 = Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.CD_ROM|Any CPU.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.CD_ROM|Mixed Platforms.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.CD_ROM|Mixed Platforms.Build.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.CD_ROM|Mixed Platforms.Deploy.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.CD_ROM|Win32.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.CD_ROM|Win32.Build.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.CD_ROM|Win32.Deploy.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.CD_ROM|x64.ActiveCfg = Win8 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.CD_ROM|x64.Build.0 = Win8 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.CD_ROM|x64.Deploy.0 = Win8 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.CD_ROM|x86.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.CD_ROM|x86.Build.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.CD_ROM|x86.Deploy.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|Any CPU.ActiveCfg = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|Mixed Platforms.ActiveCfg = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|Mixed Platforms.Build.0 = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|Mixed Platforms.Deploy.0 = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|Win32.ActiveCfg = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|Win32.Build.0 = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|Win32.Deploy.0 = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|x64.ActiveCfg = Win7 Debug|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|x64.Build.0 = Win7 Debug|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|x64.Deploy.0 = Win7 Debug|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|x86.ActiveCfg = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|x86.Build.0 = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Debug|x86.Deploy.0 = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.DVD-5|Any CPU.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.DVD-5|Mixed Platforms.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.DVD-5|Mixed Platforms.Build.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.DVD-5|Mixed Platforms.Deploy.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.DVD-5|Win32.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.DVD-5|Win32.Build.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.DVD-5|Win32.Deploy.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.DVD-5|x64.ActiveCfg = Win8 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.DVD-5|x64.Build.0 = Win8 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.DVD-5|x64.Deploy.0 = Win8 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.DVD-5|x86.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.DVD-5|x86.Build.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.DVD-5|x86.Deploy.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|Any CPU.ActiveCfg = Win8 Release|Win32
|
||||||
|
{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
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|x86.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|x86.Build.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Release|x86.Deploy.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.SingleImage|Any CPU.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.SingleImage|Mixed Platforms.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.SingleImage|Mixed Platforms.Build.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.SingleImage|Mixed Platforms.Deploy.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.SingleImage|Win32.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.SingleImage|Win32.Build.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.SingleImage|Win32.Deploy.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.SingleImage|x64.ActiveCfg = Win8 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.SingleImage|x64.Build.0 = Win8 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.SingleImage|x64.Deploy.0 = Win8 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.SingleImage|x86.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.SingleImage|x86.Build.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.SingleImage|x86.Deploy.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Debug|Any CPU.ActiveCfg = Vista Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Debug|Mixed Platforms.ActiveCfg = Vista Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Debug|Mixed Platforms.Build.0 = Vista Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Debug|Mixed Platforms.Deploy.0 = Vista Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Debug|Win32.ActiveCfg = Vista Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Debug|Win32.Build.0 = Vista Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Debug|Win32.Deploy.0 = Vista Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Debug|x64.ActiveCfg = Vista Debug|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Debug|x64.Build.0 = Vista Debug|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Debug|x64.Deploy.0 = Vista Debug|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Debug|x86.ActiveCfg = Vista Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Debug|x86.Build.0 = Vista Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Debug|x86.Deploy.0 = Vista Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Release|Any CPU.ActiveCfg = Vista Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Release|Mixed Platforms.ActiveCfg = Vista Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Release|Mixed Platforms.Build.0 = Vista Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Release|Mixed Platforms.Deploy.0 = Vista Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Release|Win32.ActiveCfg = Vista Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Release|Win32.Build.0 = Vista Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Release|Win32.Deploy.0 = Vista Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Release|x64.ActiveCfg = Vista Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Release|x64.Build.0 = Vista Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Release|x64.Deploy.0 = Vista Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Release|x86.ActiveCfg = Vista Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Release|x86.Build.0 = Vista Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Vista Release|x86.Deploy.0 = Vista Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Debug|Any CPU.ActiveCfg = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Debug|Mixed Platforms.ActiveCfg = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Debug|Mixed Platforms.Build.0 = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Debug|Mixed Platforms.Deploy.0 = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Debug|Win32.Deploy.0 = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Debug|x64.Build.0 = Win7 Debug|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Debug|x64.Deploy.0 = Win7 Debug|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Debug|x86.ActiveCfg = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Debug|x86.Build.0 = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Debug|x86.Deploy.0 = Win7 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Release|Any CPU.ActiveCfg = Win7 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Release|Mixed Platforms.ActiveCfg = Win7 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Release|Mixed Platforms.Build.0 = Win7 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Release|Mixed Platforms.Deploy.0 = Win7 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Release|Win32.Build.0 = Win7 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Release|Win32.Deploy.0 = Win7 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Release|x64.ActiveCfg = Win7 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Release|x64.Build.0 = Win7 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Release|x64.Deploy.0 = Win7 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Release|x86.ActiveCfg = Win7 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Release|x86.Build.0 = Win7 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win7 Release|x86.Deploy.0 = Win7 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Debug|Any CPU.ActiveCfg = Win8 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Debug|Mixed Platforms.ActiveCfg = Win8 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Debug|Mixed Platforms.Build.0 = Win8 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Debug|Mixed Platforms.Deploy.0 = Win8 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Debug|Win32.Deploy.0 = Win8 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Debug|x64.Build.0 = Win8 Debug|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Debug|x64.Deploy.0 = Win8 Debug|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Debug|x86.ActiveCfg = Win8 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Debug|x86.Build.0 = Win8 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Debug|x86.Deploy.0 = Win8 Debug|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Release|Any CPU.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Release|Mixed Platforms.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Release|Mixed Platforms.Build.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Release|Mixed Platforms.Deploy.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Release|Win32.Build.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Release|Win32.Deploy.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Release|x64.ActiveCfg = Win8 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Release|x64.Build.0 = Win8 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Release|x64.Deploy.0 = Win8 Release|x64
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Release|x86.ActiveCfg = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Release|x86.Build.0 = Win8 Release|Win32
|
||||||
|
{43BA7584-D4DB-4F7C-90FC-E2B18A68A213}.Win8 Release|x86.Deploy.0 = Win8 Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
Loading…
Add table
Reference in a new issue