diff --git a/.github/workflows/msbuild.yml b/.github/workflows/msbuild.yml index 9c43a92..eccdcdb 100644 --- a/.github/workflows/msbuild.yml +++ b/.github/workflows/msbuild.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: arch: [x64, x86, ARM64] - build_conf: [Debug, Release] + build_conf: [Debug, Release, Debug-Win11, Release-Win11] steps: - uses: actions/checkout@v2 diff --git a/PropertySheet.props b/PropertySheet.props index 9ef1bda..9762399 100644 --- a/PropertySheet.props +++ b/PropertySheet.props @@ -4,9 +4,7 @@ 0 7 - 0 - $(DDK_INC_PATH)\netcx\kmdf\adapter\2.0\ - $(DDK_LIB_PATH)\netcx\kmdf\adapter\2.0\ + 1 @@ -30,13 +28,5 @@ $(OVPN_DCO_VERSION_PATCH) true - - $(NETADAPTER_INC_PATH) - true - - - $(NETADAPTER_LIB_PATH) - true - \ No newline at end of file diff --git a/adapter.cpp b/adapter.cpp index 2f4b811..f996324 100644 --- a/adapter.cpp +++ b/adapter.cpp @@ -28,7 +28,41 @@ // maximum link speed for send and recv in bps #define OVPN_MEDIA_MAX_SPEED 1'000'000'000 -static void +#if (NETADAPTER_VERSION_MAJOR >= 2) && (NETADAPTER_VERSION_MINOR >= 1) + +EVT_NET_ADAPTER_OFFLOAD_SET_RX_CHECKSUM OvpnEvtAdapterOffloadSetRxChecksum; + +_Use_decl_annotations_ +VOID +OvpnEvtAdapterOffloadSetRxChecksum(NETADAPTER netAdapter, NETOFFLOAD offload) +{ + UNREFERENCED_PARAMETER(netAdapter); + + LOG_INFO("Checksum offload settings changed", + TraceLoggingValue(NetOffloadIsRxChecksumIPv4Enabled(offload), "ipv4"), + TraceLoggingValue(NetOffloadIsRxChecksumTcpEnabled(offload), "tcp"), + TraceLoggingValue(NetOffloadIsRxChecksumUdpEnabled(offload), "udp")); + + // we don't really care about those settings, since we always report tunnel checksums as valid +} + +static +VOID +OvpnAdapterSetOffloadCapabilities(_In_ POVPN_ADAPTER adapter) +{ + // Configure the hardware's Rx checksum offload capabilities + NET_ADAPTER_OFFLOAD_RX_CHECKSUM_CAPABILITIES rxChecksumOffloadCapabilities; + + NET_ADAPTER_OFFLOAD_RX_CHECKSUM_CAPABILITIES_INIT(&rxChecksumOffloadCapabilities, OvpnEvtAdapterOffloadSetRxChecksum); + + // Set the current Rx checksum offload capabilities and register the callback for future changes in active capabilities + NetAdapterOffloadSetRxChecksumCapabilities(adapter->NetAdapter, &rxChecksumOffloadCapabilities); +} + +#endif + +static +VOID OvpnAdapterSetDatapathCapabilities(_In_ POVPN_ADAPTER adapter) { NET_ADAPTER_TX_CAPABILITIES txCapabilities; @@ -41,7 +75,7 @@ OvpnAdapterSetDatapathCapabilities(_In_ POVPN_ADAPTER adapter) } static -void +VOID OvpnAdapterSetLinkLayerCapabilities(_In_ POVPN_ADAPTER adapter) { ULONG64 maxXmitLinkSpeed = OVPN_MEDIA_MAX_SPEED; @@ -57,7 +91,7 @@ OvpnAdapterSetLinkLayerCapabilities(_In_ POVPN_ADAPTER adapter) } static -void +VOID OvpnAdapterSetLinkState(_In_ POVPN_ADAPTER adapter) { NET_ADAPTER_LINK_STATE linkState; @@ -149,8 +183,6 @@ OvpnAdapterCreate(OVPN_DEVICE * device) { NET_ADAPTER_DATAPATH_CALLBACKS_INIT(&datapathCallbacks, OvpnEvtAdapterCreateTxQueue, OvpnEvtAdapterCreateRxQueue); NetAdapterInitSetDatapathCallbacks(adapterInit, &datapathCallbacks); - NetAdapterInitSetDatapathCallbacks(adapterInit, &datapathCallbacks); - WDF_OBJECT_ATTRIBUTES adapterAttributes; WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&adapterAttributes, OVPN_ADAPTER); @@ -167,6 +199,10 @@ OvpnAdapterCreate(OVPN_DEVICE * device) { OvpnAdapterSetDatapathCapabilities(adapter); OvpnAdapterSetLinkLayerCapabilities(adapter); +#if (NETADAPTER_VERSION_MAJOR >= 2) && (NETADAPTER_VERSION_MINOR >= 1) + OvpnAdapterSetOffloadCapabilities(adapter); +#endif + OvpnAdapterSetLinkState(adapter); status = NetAdapterStart(adapter->NetAdapter); diff --git a/ovpn-dco-win.sln b/ovpn-dco-win.sln index d824ebe..dfa15f7 100644 --- a/ovpn-dco-win.sln +++ b/ovpn-dco-win.sln @@ -13,10 +13,18 @@ Global Debug|ARM64 = Debug|ARM64 Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 + Debug-Win11|Any CPU = Debug-Win11|Any CPU + Debug-Win11|ARM64 = Debug-Win11|ARM64 + Debug-Win11|x64 = Debug-Win11|x64 + Debug-Win11|x86 = Debug-Win11|x86 Release|Any CPU = Release|Any CPU Release|ARM64 = Release|ARM64 Release|x64 = Release|x64 Release|x86 = Release|x86 + Release-Win11|Any CPU = Release-Win11|Any CPU + Release-Win11|ARM64 = Release-Win11|ARM64 + Release-Win11|x64 = Release-Win11|x64 + Release-Win11|x86 = Release-Win11|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C91D6DBF-F373-44CD-8179-D0F55888A015}.Debug|Any CPU.ActiveCfg = Debug|Win32 @@ -29,6 +37,14 @@ Global {C91D6DBF-F373-44CD-8179-D0F55888A015}.Debug|x86.ActiveCfg = Debug|Win32 {C91D6DBF-F373-44CD-8179-D0F55888A015}.Debug|x86.Build.0 = Debug|Win32 {C91D6DBF-F373-44CD-8179-D0F55888A015}.Debug|x86.Deploy.0 = Debug|Win32 + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Debug-Win11|Any CPU.ActiveCfg = Debug-Win11|ARM + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Debug-Win11|Any CPU.Build.0 = Debug-Win11|ARM + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Debug-Win11|ARM64.ActiveCfg = Debug-Win11|ARM64 + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Debug-Win11|ARM64.Build.0 = Debug-Win11|ARM64 + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Debug-Win11|x64.ActiveCfg = Debug-Win11|x64 + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Debug-Win11|x64.Build.0 = Debug-Win11|x64 + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Debug-Win11|x86.ActiveCfg = Debug-Win11|x64 + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Debug-Win11|x86.Build.0 = Debug-Win11|x64 {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release|Any CPU.ActiveCfg = Release|Win32 {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release|ARM64.ActiveCfg = Release|ARM64 {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release|ARM64.Build.0 = Release|ARM64 @@ -39,12 +55,25 @@ Global {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release|x86.ActiveCfg = Release|Win32 {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release|x86.Build.0 = Release|Win32 {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release|x86.Deploy.0 = Release|Win32 + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release-Win11|Any CPU.ActiveCfg = Release-Win11|ARM + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release-Win11|Any CPU.Build.0 = Release-Win11|ARM + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release-Win11|ARM64.ActiveCfg = Release-Win11|ARM64 + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release-Win11|ARM64.Build.0 = Release-Win11|ARM64 + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release-Win11|x64.ActiveCfg = Release-Win11|x64 + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release-Win11|x64.Build.0 = Release-Win11|x64 + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release-Win11|x86.ActiveCfg = Release-Win11|Win32 + {C91D6DBF-F373-44CD-8179-D0F55888A015}.Release-Win11|x86.Build.0 = Release-Win11|Win32 {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Debug|Any CPU.ActiveCfg = Debug|Win32 {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Debug|ARM64.ActiveCfg = Debug|ARM64 {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Debug|x64.ActiveCfg = Debug|x64 {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Debug|x64.Build.0 = Debug|x64 {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Debug|x86.ActiveCfg = Debug|Win32 {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Debug|x86.Build.0 = Debug|Win32 + {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Debug-Win11|Any CPU.ActiveCfg = Release-Win11|x64 + {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Debug-Win11|ARM64.ActiveCfg = Debug|ARM64 + {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Debug-Win11|x64.ActiveCfg = Debug|x64 + {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Debug-Win11|x64.Build.0 = Debug|x64 + {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Debug-Win11|x86.ActiveCfg = Debug|x64 {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Release|Any CPU.ActiveCfg = Release|Win32 {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Release|ARM64.ActiveCfg = Release|ARM64 {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Release|ARM64.Build.0 = Release|ARM64 @@ -52,6 +81,11 @@ Global {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Release|x64.Build.0 = Release|x64 {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Release|x86.ActiveCfg = Release|Win32 {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Release|x86.Build.0 = Release|Win32 + {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Release-Win11|Any CPU.ActiveCfg = Release-Win11|x64 + {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Release-Win11|ARM64.ActiveCfg = Release|ARM64 + {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Release-Win11|x64.ActiveCfg = Release|x64 + {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Release-Win11|x64.Build.0 = Release|x64 + {BA23900A-7FAC-49CF-9AC7-C20CD52F42AF}.Release-Win11|x86.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ovpn-dco-win.vcxproj b/ovpn-dco-win.vcxproj index 0cd847c..f61dfdf 100644 --- a/ovpn-dco-win.vcxproj +++ b/ovpn-dco-win.vcxproj @@ -1,10 +1,42 @@  + + Debug-Win11 + ARM + + + Debug-Win11 + ARM64 + + + Debug-Win11 + Win32 + + + Debug-Win11 + x64 + Debug Win32 + + Release-Win11 + ARM + + + Release-Win11 + ARM64 + + + Release-Win11 + Win32 + + + Release-Win11 + x64 + Release Win32 @@ -89,6 +121,17 @@ 2 0 + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + true + 2 + 1 + Windows10 false @@ -100,6 +143,17 @@ 2 0 + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + true + 2 + 1 + Windows10 true @@ -113,6 +167,18 @@ 2 0 + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + true + + 2 + 1 + Windows10 false @@ -124,6 +190,17 @@ 2 0 + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + true + 2 + 1 + Windows10 true @@ -135,6 +212,17 @@ 2 0 + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + true + 2 + 1 + Windows10 false @@ -146,6 +234,17 @@ 2 0 + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + true + 2 + 1 + Windows10 true @@ -157,6 +256,17 @@ 2 0 + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + true + 2 + 1 + Windows10 false @@ -168,6 +278,17 @@ 2 0 + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + true + 2 + 1 + dvl @@ -180,27 +301,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -210,47 +355,104 @@ $(SolutionDir)$(Platform)\$(ConfigurationName)\ $(Platform)\$(ConfigurationName)\ + + DbgengKernelDebugger + $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH) + false + $(SolutionDir)$(Platform)\$(ConfigurationName)\ + $(Platform)\$(ConfigurationName)\ + DbgengKernelDebugger $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH) $(SolutionDir)$(Platform)\$(ConfigurationName)\ $(Platform)\$(ConfigurationName)\ + + DbgengKernelDebugger + $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH) + $(SolutionDir)$(Platform)\$(ConfigurationName)\ + $(Platform)\$(ConfigurationName)\ + DbgengKernelDebugger $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH);$(SolutionDir)driverhelper false ..\..\..\..\Program Files (x86)\Windows Kits\10\CodeAnalysis\DriverRecommendedRules.ruleset + + DbgengKernelDebugger + $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH);$(SolutionDir)driverhelper + false + ..\..\..\..\Program Files (x86)\Windows Kits\10\CodeAnalysis\DriverRecommendedRules.ruleset + DbgengKernelDebugger $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH);$(SolutionDir)driverhelper + + DbgengKernelDebugger + $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH);$(SolutionDir)driverhelper + DbgengKernelDebugger $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH) false + + DbgengKernelDebugger + $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH) + false + DbgengKernelDebugger $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH) + + DbgengKernelDebugger + $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH) + DbgengKernelDebugger $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH);$(SolutionDir)driverhelper false + + DbgengKernelDebugger + $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH);$(SolutionDir)driverhelper + false + DbgengKernelDebugger $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH);$(SolutionDir)driverhelper + + DbgengKernelDebugger + $(SolutionDir)dmf\dmf;$(IncludePath);$(NETADAPTER_INC_PATH);$(SolutionDir)driverhelper + true %(AdditionalIncludeDirectories) - OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);%(PreprocessorDefinitions) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) + + + Netio.lib;Bcrypt.lib;uuid.lib%(AdditionalDependencies) + + + + SHA256 + + + + + + + true + %(AdditionalIncludeDirectories) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) Netio.lib;Bcrypt.lib;uuid.lib%(AdditionalDependencies) @@ -266,7 +468,34 @@ true %(AdditionalIncludeDirectories) - OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);%(PreprocessorDefinitions) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) + false + + + copy /Y $(ProjectDir)ovpn-dco.DVL.XML $(ProjectDir)$(Platform)\$(ConfigurationName) + $(ProjectDir)ovpn-dco.DVL.XML + $(ProjectDir)$(Platform)\$(ConfigurationName)\ovpn-dco.DVL.XML + + + Netio.lib;Bcrypt.lib;uuid.lib%(AdditionalDependencies) + /Brepro %(AdditionalOptions) + false + false + + + $(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH) + + + SHA256 + + + + + + + true + %(AdditionalIncludeDirectories) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) false @@ -293,7 +522,31 @@ true %(AdditionalIncludeDirectories) - OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);%(PreprocessorDefinitions) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) + + + uuid.lib;Netio.lib;Ksecdd.lib;%(AdditionalDependencies) + + + + + + + + + + + + SHA256 + + + + + + + true + %(AdditionalIncludeDirectories) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) uuid.lib;Netio.lib;Ksecdd.lib;%(AdditionalDependencies) @@ -317,7 +570,34 @@ true %(AdditionalIncludeDirectories) - OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);%(PreprocessorDefinitions) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) + false + + + copy /Y $(ProjectDir)ovpn-dco.DVL.XML $(ProjectDir)$(Platform)\$(ConfigurationName) + $(ProjectDir)ovpn-dco.DVL.XML + $(ProjectDir)$(Platform)\$(ConfigurationName)\ovpn-dco.DVL.XML + + + uuid.lib;Netio.lib;Ksecdd.lib;%(AdditionalDependencies) + /Brepro %(AdditionalOptions) + false + false + + + $(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH) + + + SHA256 + + + + + + + true + %(AdditionalIncludeDirectories) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) false @@ -344,7 +624,23 @@ true %(AdditionalIncludeDirectories) - OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);%(PreprocessorDefinitions) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) + + + Netio.lib;%(AdditionalDependencies) + + + + SHA256 + + + + + + + true + %(AdditionalIncludeDirectories) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) Netio.lib;%(AdditionalDependencies) @@ -360,7 +656,29 @@ true %(AdditionalIncludeDirectories) - OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);%(PreprocessorDefinitions) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) + false + + + Netio.lib;%(AdditionalDependencies) + /Brepro %(AdditionalOptions) + false + false + + + $(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH) + + + SHA256 + + + + + + + true + %(AdditionalIncludeDirectories) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) false @@ -382,7 +700,34 @@ true %(AdditionalIncludeDirectories) - OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);%(PreprocessorDefinitions) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) + false + + + copy /Y $(ProjectDir)ovpn-dco.DVL.XML $(ProjectDir)$(Platform)\$(ConfigurationName) + $(ProjectDir)ovpn-dco.DVL.XML + $(ProjectDir)$(Platform)\$(ConfigurationName)\ovpn-dco.DVL.XML + + + uuid.lib;Netio.lib;Ksecdd.lib;%(AdditionalDependencies) + /Brepro %(AdditionalOptions) + false + false + + + $(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH) + + + SHA256 + + + + + + + true + %(AdditionalIncludeDirectories) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) false @@ -409,7 +754,23 @@ true %(AdditionalIncludeDirectories) - OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);%(PreprocessorDefinitions) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) + + + uuid.lib;Netio.lib;Ksecdd.lib;%(AdditionalDependencies) + + + + SHA256 + + + + + + + true + %(AdditionalIncludeDirectories) + OVPN_DCO_VERSION_MAJOR=$(OVPN_DCO_VERSION_MAJOR);OVPN_DCO_VERSION_MINOR=$(OVPN_DCO_VERSION_MINOR);OVPN_DCO_VERSION_PATCH=$(OVPN_DCO_VERSION_PATCH);OVPN_DCO_VERSION_STR=$(OVPN_DCO_VERSION_MAJOR).$(OVPN_DCO_VERSION_MINOR).$(OVPN_DCO_VERSION_PATCH);NETADAPTER_VERSION_MAJOR=$(NETADAPTER_VERSION_MAJOR);NETADAPTER_VERSION_MINOR=$(NETADAPTER_VERSION_MINOR);%(PreprocessorDefinitions) uuid.lib;Netio.lib;Ksecdd.lib;%(AdditionalDependencies) diff --git a/rxqueue.cpp b/rxqueue.cpp index 1261743..afda2f2 100644 --- a/rxqueue.cpp +++ b/rxqueue.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "driver.h" #include "bufferpool.h" @@ -31,6 +32,35 @@ EVT_PACKET_QUEUE_ADVANCE OvpnEvtRxQueueAdvance; +static inline UINT8 +OvpnRxQueueGetLayer4Type(const VOID* buf, size_t len) +{ + UINT8 ret = NetPacketLayer4TypeUnspecified; + + if (len < sizeof(IPV4_HEADER)) + return ret; + + const auto ipv4hdr = (IPV4_HEADER*)buf; + if (ipv4hdr->Version == IPV4_VERSION) { + if (ipv4hdr->Protocol == IPPROTO_TCP) + ret = NetPacketLayer4TypeTcp; + else if (ipv4hdr->Protocol == IPPROTO_UDP) + ret = NetPacketLayer4TypeUdp; + } + else if (ipv4hdr->Version == 6) { + if (len < sizeof(IPV6_HEADER)) + return ret; + + const auto ipv6hdr = (IPV6_HEADER*)buf; + if (ipv6hdr->NextHeader == IPPROTO_TCP) + ret = NetPacketLayer4TypeTcp; + else if (ipv6hdr->NextHeader == IPPROTO_UDP) + ret = NetPacketLayer4TypeUdp; + } + + return ret; +} + _Use_decl_annotations_ VOID OvpnEvtRxQueueAdvance(NETPACKETQUEUE netPacketQueue) @@ -62,6 +92,15 @@ OvpnEvtRxQueueAdvance(NETPACKETQUEUE netPacketQueue) packet->Layout = {}; + const auto checksum = NetExtensionGetPacketChecksum(&queue->ChecksumExtension, NetPacketIteratorGetIndex(&pi)); + + // Win11/2022 and newer + if (checksum) { + checksum->Layer3 = NetPacketRxChecksumEvaluationValid; // IP checksum + checksum->Layer4 = NetPacketRxChecksumEvaluationValid; // TCP/UDP checksum + packet->Layout.Layer4Type = OvpnRxQueueGetLayer4Type(virtualAddr->VirtualAddress, buffer->Len); + } + NetFragmentIteratorAdvance(&fi); NetPacketIteratorAdvance(&pi); @@ -112,4 +151,8 @@ OvpnRxQueueInitialize(NETPACKETQUEUE netPacketQueue, POVPN_ADAPTER adapter) NET_EXTENSION_QUERY extension; NET_EXTENSION_QUERY_INIT(&extension, NET_FRAGMENT_EXTENSION_VIRTUAL_ADDRESS_NAME, NET_FRAGMENT_EXTENSION_VIRTUAL_ADDRESS_VERSION_1, NetExtensionTypeFragment); NetRxQueueGetExtension(netPacketQueue, &extension, &queue->VirtualAddressExtension); + + // Query checksum packet extension offset and store it in the context + NET_EXTENSION_QUERY_INIT(&extension, NET_PACKET_EXTENSION_CHECKSUM_NAME, NET_PACKET_EXTENSION_CHECKSUM_VERSION_1, NetExtensionTypePacket); + NetRxQueueGetExtension(netPacketQueue, &extension, &queue->ChecksumExtension); } diff --git a/rxqueue.h b/rxqueue.h index 6c59f2e..8a5e1de 100644 --- a/rxqueue.h +++ b/rxqueue.h @@ -30,6 +30,7 @@ typedef struct _OVPN_RXQUEUE NET_RING_COLLECTION const * Rings; NET_EXTENSION VirtualAddressExtension; + NET_EXTENSION ChecksumExtension; LONG NotificationEnabled = 0; } OVPN_RXQUEUE, * POVPN_RXQUEUE;