summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJonathan <jonathan@mullvad.net>2022-10-18 13:36:38 +0200
committerJonathan <jonathan@mullvad.net>2022-10-18 14:42:33 +0200
commit56a3ef9ffbe3104a82c0504d8f1610545e23b121 (patch)
tree9e1bd08bd8478bb3750193b54008d6a34ece5a37
parentd3f7ed493ecc182e582697f7ac03b1b30a2c2f52 (diff)
downloadmullvadvpn-56a3ef9ffbe3104a82c0504d8f1610545e23b121.tar.xz
mullvadvpn-56a3ef9ffbe3104a82c0504d8f1610545e23b121.zip
Modify build scripts and remove c++ code
Also upgrade to 0.42.0 for windows-sys library
-rw-r--r--Cargo.lock16
-rwxr-xr-xbuild-windows-modules.sh1
-rwxr-xr-xbuild.sh1
-rw-r--r--gui/tasks/distribution.js6
-rw-r--r--talpid-core/Cargo.toml2
-rw-r--r--talpid-core/build.rs3
-rw-r--r--windows/winnet/extras.sln102
-rw-r--r--windows/winnet/src/extras/loader/loader.cpp29
-rw-r--r--windows/winnet/src/extras/loader/loader.vcxproj188
-rw-r--r--windows/winnet/src/extras/loader/loader.vcxproj.filters11
-rw-r--r--windows/winnet/src/extras/loader/stdafx.cpp8
-rw-r--r--windows/winnet/src/extras/loader/stdafx.h15
-rw-r--r--windows/winnet/src/extras/loader/targetver.h8
-rw-r--r--windows/winnet/src/extras/tests/adaptermonitor.cpp798
-rw-r--r--windows/winnet/src/extras/tests/networkadaptermonitor.vcxproj.filters42
-rw-r--r--windows/winnet/src/extras/tests/stdafx.cpp8
-rw-r--r--windows/winnet/src/extras/tests/stdafx.h13
-rw-r--r--windows/winnet/src/extras/tests/targetver.h8
-rw-r--r--windows/winnet/src/extras/tests/testadapterutil.cpp252
-rw-r--r--windows/winnet/src/extras/tests/testadapterutil.h73
-rw-r--r--windows/winnet/src/extras/tests/tests.vcxproj109
-rw-r--r--windows/winnet/src/winnet/converters.cpp145
-rw-r--r--windows/winnet/src/winnet/converters.h16
-rw-r--r--windows/winnet/src/winnet/dllmain.cpp11
-rw-r--r--windows/winnet/src/winnet/routing/defaultroutemonitor.cpp248
-rw-r--r--windows/winnet/src/winnet/routing/defaultroutemonitor.h78
-rw-r--r--windows/winnet/src/winnet/routing/helpers.cpp295
-rw-r--r--windows/winnet/src/winnet/routing/helpers.h46
-rw-r--r--windows/winnet/src/winnet/routing/routemanager.cpp647
-rw-r--r--windows/winnet/src/winnet/routing/routemanager.h176
-rw-r--r--windows/winnet/src/winnet/routing/types.cpp93
-rw-r--r--windows/winnet/src/winnet/routing/types.h74
-rw-r--r--windows/winnet/src/winnet/stdafx.cpp8
-rw-r--r--windows/winnet/src/winnet/stdafx.h20
-rw-r--r--windows/winnet/src/winnet/targetver.h12
-rw-r--r--windows/winnet/src/winnet/winnet.cpp398
-rw-r--r--windows/winnet/src/winnet/winnet.def5
-rw-r--r--windows/winnet/src/winnet/winnet.h186
-rw-r--r--windows/winnet/src/winnet/winnet.rc25
-rw-r--r--windows/winnet/src/winnet/winnet.vcxproj314
-rw-r--r--windows/winnet/src/winnet/winnet.vcxproj.filters50
-rw-r--r--windows/winnet/winnet.sln72
42 files changed, 10 insertions, 4602 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 16933b2567..a437183a59 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3975,15 +3975,17 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
-version = "0.36.1"
+version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e53b97a83176b369b0eb2fd8158d4ae215357d02df9d40c1e1bf1879c5482c80"
+checksum = "0286ba339aa753e70765d521bb0242cc48e1194562bfa2a2ad7ac8a6de28f5d5"
dependencies = [
- "windows_aarch64_msvc 0.36.1",
- "windows_i686_gnu 0.36.1",
- "windows_i686_msvc 0.36.1",
- "windows_x86_64_gnu 0.36.1",
- "windows_x86_64_msvc 0.36.1",
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc 0.42.0",
+ "windows_i686_gnu 0.42.0",
+ "windows_i686_msvc 0.42.0",
+ "windows_x86_64_gnu 0.42.0",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc 0.42.0",
]
[[package]]
diff --git a/build-windows-modules.sh b/build-windows-modules.sh
index 41433da069..849b80b2d6 100755
--- a/build-windows-modules.sh
+++ b/build-windows-modules.sh
@@ -92,7 +92,6 @@ function main {
clean_libraries
build_solution "./windows/winfw" "winfw.sln"
- build_solution "./windows/winnet" "winnet.sln"
build_solution "./windows/driverlogic" "driverlogic.sln"
diff --git a/build.sh b/build.sh
index 558b3d7c41..5eb8ba69f8 100755
--- a/build.sh
+++ b/build.sh
@@ -284,7 +284,6 @@ if [[ "$(uname -s)" == "MINGW"* ]]; then
if [[ "$SIGN" == "true" ]]; then
CPP_BINARIES=(
"windows/winfw/bin/x64-$CPP_BUILD_MODE/winfw.dll"
- "windows/winnet/bin/x64-$CPP_BUILD_MODE/winnet.dll"
"windows/driverlogic/bin/x64-$CPP_BUILD_MODE/driverlogic.exe"
# The nsis plugin is always built in 32 bit release mode
windows/nsis-plugins/bin/Win32-Release/*.dll
diff --git a/gui/tasks/distribution.js b/gui/tasks/distribution.js
index deb4342116..5ced2ed563 100644
--- a/gui/tasks/distribution.js
+++ b/gui/tasks/distribution.js
@@ -141,12 +141,6 @@ const config = {
from: root(path.join('windows', 'winfw', 'bin', 'x64-${env.CPP_BUILD_MODE}', 'winfw.dll')),
to: '.',
},
- {
- from: root(
- path.join('windows', 'winnet', 'bin', 'x64-${env.CPP_BUILD_MODE}', 'winnet.dll'),
- ),
- to: '.',
- },
{ from: distAssets('binaries/x86_64-pc-windows-msvc/openvpn.exe'), to: '.' },
{ from: root('build/lib/x86_64-pc-windows-msvc/libwg.dll'), to: '.' },
{ from: distAssets('binaries/x86_64-pc-windows-msvc/wintun/wintun.dll'), to: '.' },
diff --git a/talpid-core/Cargo.toml b/talpid-core/Cargo.toml
index 97bdf2db4b..fbd231a6a8 100644
--- a/talpid-core/Cargo.toml
+++ b/talpid-core/Cargo.toml
@@ -87,7 +87,7 @@ memoffset = "0.6"
windows-service = "0.5.0"
[target.'cfg(windows)'.dependencies.windows]
-version = "0.36.1"
+version = "0.42.0"
features = [
"Data_Xml_Dom",
"Win32_Foundation",
diff --git a/talpid-core/build.rs b/talpid-core/build.rs
index b46304d5a0..70a1fb6d53 100644
--- a/talpid-core/build.rs
+++ b/talpid-core/build.rs
@@ -6,7 +6,6 @@ mod win {
use std::{env, path::PathBuf};
pub static WINFW_BUILD_DIR: &'static str = "..\\windows\\winfw\\bin";
- pub static WINNET_BUILD_DIR: &'static str = "..\\windows\\winnet\\bin";
pub fn default_windows_build_artifact_dir(build_dir: &str) -> PathBuf {
manifest_dir().join(build_dir).join(&target_platform_dir())
@@ -49,9 +48,7 @@ fn main() {
use crate::win::*;
const WINFW_DIR_VAR: &str = "WINFW_LIB_DIR";
- const WINNET_DIR_VAR: &str = "WINNET_LIB_DIR";
declare_library(WINFW_DIR_VAR, WINFW_BUILD_DIR, "winfw");
- declare_library(WINNET_DIR_VAR, WINNET_BUILD_DIR, "winnet");
let lib_dir = manifest_dir().join("../build/lib/x86_64-pc-windows-msvc");
println!("cargo:rustc-link-search={}", &lib_dir.display());
println!("cargo:rustc-link-lib=dylib=libwg");
diff --git a/windows/winnet/extras.sln b/windows/winnet/extras.sln
deleted file mode 100644
index 0e85bd1879..0000000000
--- a/windows/winnet/extras.sln
+++ /dev/null
@@ -1,102 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.0.32014.148
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loader", "src\extras\loader\loader.vcxproj", "{227C50F4-D9F6-4D9A-84A0-33CE84432D0D}"
- ProjectSection(ProjectDependencies) = postProject
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D} = {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4} = {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winnet", "src\winnet\winnet.vcxproj", "{89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}"
- ProjectSection(ProjectDependencies) = postProject
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF} = {B52E2D10-A94A-4605-914A-2DCEF6A757EF}
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D} = {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcommon", "..\windows-libraries\src\libcommon\libcommon.vcxproj", "{B52E2D10-A94A-4605-914A-2DCEF6A757EF}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests", "src\extras\tests\tests.vcxproj", "{01A4E766-CC61-40B7-A3D6-7A37F6BF5CCB}"
- ProjectSection(ProjectDependencies) = postProject
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF} = {B52E2D10-A94A-4605-914A-2DCEF6A757EF}
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D} = {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4} = {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libshared", "..\libshared\src\libshared\libshared.vcxproj", "{EE69EA4A-CF71-4B88-866B-957F60C4CE0D}"
- ProjectSection(ProjectDependencies) = postProject
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF} = {B52E2D10-A94A-4605-914A-2DCEF6A757EF}
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Debug-AutoTests|x64 = Debug-AutoTests|x64
- Debug-AutoTests|x86 = Debug-AutoTests|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {227C50F4-D9F6-4D9A-84A0-33CE84432D0D}.Debug|x64.ActiveCfg = Debug|x64
- {227C50F4-D9F6-4D9A-84A0-33CE84432D0D}.Debug|x64.Build.0 = Debug|x64
- {227C50F4-D9F6-4D9A-84A0-33CE84432D0D}.Debug|x86.ActiveCfg = Debug|Win32
- {227C50F4-D9F6-4D9A-84A0-33CE84432D0D}.Debug|x86.Build.0 = Debug|Win32
- {227C50F4-D9F6-4D9A-84A0-33CE84432D0D}.Debug-AutoTests|x64.ActiveCfg = Debug|x64
- {227C50F4-D9F6-4D9A-84A0-33CE84432D0D}.Debug-AutoTests|x86.ActiveCfg = Debug|Win32
- {227C50F4-D9F6-4D9A-84A0-33CE84432D0D}.Release|x64.ActiveCfg = Release|x64
- {227C50F4-D9F6-4D9A-84A0-33CE84432D0D}.Release|x64.Build.0 = Release|x64
- {227C50F4-D9F6-4D9A-84A0-33CE84432D0D}.Release|x86.ActiveCfg = Release|Win32
- {227C50F4-D9F6-4D9A-84A0-33CE84432D0D}.Release|x86.Build.0 = Release|Win32
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug|x64.ActiveCfg = Debug|x64
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug|x64.Build.0 = Debug|x64
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug|x86.ActiveCfg = Debug|Win32
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug|x86.Build.0 = Debug|Win32
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug-AutoTests|x64.ActiveCfg = Debug Static|x64
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug-AutoTests|x64.Build.0 = Debug Static|x64
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug-AutoTests|x86.ActiveCfg = Debug Static|Win32
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug-AutoTests|x86.Build.0 = Debug Static|Win32
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Release|x64.ActiveCfg = Release|x64
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Release|x64.Build.0 = Release|x64
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Release|x86.ActiveCfg = Release|Win32
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Release|x86.Build.0 = Release|Win32
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x64.ActiveCfg = Debug|x64
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x64.Build.0 = Debug|x64
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x86.ActiveCfg = Debug|Win32
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x86.Build.0 = Debug|Win32
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug-AutoTests|x64.ActiveCfg = Debug|x64
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug-AutoTests|x64.Build.0 = Debug|x64
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug-AutoTests|x86.ActiveCfg = Debug|Win32
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug-AutoTests|x86.Build.0 = Debug|Win32
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x64.ActiveCfg = Release|x64
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x64.Build.0 = Release|x64
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x86.ActiveCfg = Release|Win32
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x86.Build.0 = Release|Win32
- {01A4E766-CC61-40B7-A3D6-7A37F6BF5CCB}.Debug|x64.ActiveCfg = Debug|x64
- {01A4E766-CC61-40B7-A3D6-7A37F6BF5CCB}.Debug|x86.ActiveCfg = Debug|Win32
- {01A4E766-CC61-40B7-A3D6-7A37F6BF5CCB}.Debug-AutoTests|x64.ActiveCfg = Debug|x64
- {01A4E766-CC61-40B7-A3D6-7A37F6BF5CCB}.Debug-AutoTests|x64.Build.0 = Debug|x64
- {01A4E766-CC61-40B7-A3D6-7A37F6BF5CCB}.Debug-AutoTests|x86.ActiveCfg = Debug|Win32
- {01A4E766-CC61-40B7-A3D6-7A37F6BF5CCB}.Debug-AutoTests|x86.Build.0 = Debug|Win32
- {01A4E766-CC61-40B7-A3D6-7A37F6BF5CCB}.Release|x64.ActiveCfg = Debug|x64
- {01A4E766-CC61-40B7-A3D6-7A37F6BF5CCB}.Release|x86.ActiveCfg = Debug|Win32
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x64.ActiveCfg = Debug|x64
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x64.Build.0 = Debug|x64
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x86.ActiveCfg = Debug|Win32
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x86.Build.0 = Debug|Win32
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug-AutoTests|x64.ActiveCfg = Debug|x64
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug-AutoTests|x64.Build.0 = Debug|x64
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug-AutoTests|x86.ActiveCfg = Debug|Win32
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug-AutoTests|x86.Build.0 = Debug|Win32
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x64.ActiveCfg = Release|x64
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x64.Build.0 = Release|x64
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x86.ActiveCfg = Release|Win32
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x86.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {B11B65B3-3DA6-495C-B0F5-5ACBB2F1743D}
- EndGlobalSection
-EndGlobal
diff --git a/windows/winnet/src/extras/loader/loader.cpp b/windows/winnet/src/extras/loader/loader.cpp
deleted file mode 100644
index acb5083b36..0000000000
--- a/windows/winnet/src/extras/loader/loader.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "stdafx.h"
-#include <winnet/winnet.h>
-#include <libshared/logging/stdoutlogger.h>
-#include <iostream>
-
-int main()
-{
- //wchar_t *alias = nullptr;
-
- //const auto status = WinNet_GetTapInterfaceAlias(&alias, nullptr, nullptr);
-
- //switch (status)
- //{
- // case WINNET_GTIA_STATUS::FAILURE:
- // {
- // std::wcout << L"Could not determine alias" << std::endl;
- // break;
- // }
- // case WINNET_GTIA_STATUS::SUCCESS:
- // {
- // std::wcout << L"Interface alias: " << alias << std::endl;
- // WinNet_ReleaseString(alias);
- // }
- //};
-
- _getwch();
-
- return 0;
-}
diff --git a/windows/winnet/src/extras/loader/loader.vcxproj b/windows/winnet/src/extras/loader/loader.vcxproj
deleted file mode 100644
index 665d5046a3..0000000000
--- a/windows/winnet/src/extras/loader/loader.vcxproj
+++ /dev/null
@@ -1,188 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="loader.cpp" />
- <ClCompile Include="stdafx.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="stdafx.h" />
- <ClInclude Include="targetver.h" />
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <VCProjectVersion>16.0</VCProjectVersion>
- <ProjectGuid>{227C50F4-D9F6-4D9A-84A0-33CE84432D0D}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>loader</RootNamespace>
- <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="Shared">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LinkIncremental>true</LinkIncremental>
- <IntDir>$(SolutionDir)bin\temp\$(Platform)-$(Configuration)\$(ProjectName)\</IntDir>
- <OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>true</LinkIncremental>
- <IntDir>$(SolutionDir)bin\temp\$(Platform)-$(Configuration)\$(ProjectName)\</IntDir>
- <OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LinkIncremental>false</LinkIncremental>
- <IntDir>$(SolutionDir)bin\temp\$(Platform)-$(Configuration)\$(ProjectName)\</IntDir>
- <OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <LinkIncremental>false</LinkIncremental>
- <IntDir>$(SolutionDir)bin\temp\$(Platform)-$(Configuration)\$(ProjectName)\</IntDir>
- <OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <PrecompiledHeader>Create</PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WINNET_STATIC;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <AdditionalIncludeDirectories>$(ProjectDir)../../;$(ProjectDir)../../../../libshared/src/</AdditionalIncludeDirectories>
- <LanguageStandard>stdcpplatest</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-$(Configuration)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libshared.lib;winnet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <PrecompiledHeader>Create</PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WINNET_STATIC;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <AdditionalIncludeDirectories>$(ProjectDir)../../;$(ProjectDir)../../../../libshared/src/</AdditionalIncludeDirectories>
- <LanguageStandard>stdcpplatest</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-$(Configuration)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libshared.lib;winnet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <PrecompiledHeader>Create</PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WINNET_STATIC;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <AdditionalIncludeDirectories>$(ProjectDir)../../;$(ProjectDir)../../../../libshared/src/</AdditionalIncludeDirectories>
- <LanguageStandard>stdcpplatest</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-$(Configuration)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libshared.lib;winnet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <PrecompiledHeader>Create</PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WINNET_STATIC;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <AdditionalIncludeDirectories>$(ProjectDir)../../;$(ProjectDir)../../../../libshared/src/</AdditionalIncludeDirectories>
- <LanguageStandard>stdcpplatest</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-$(Configuration)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libshared.lib;winnet.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/windows/winnet/src/extras/loader/loader.vcxproj.filters b/windows/winnet/src/extras/loader/loader.vcxproj.filters
deleted file mode 100644
index cd0f4643c7..0000000000
--- a/windows/winnet/src/extras/loader/loader.vcxproj.filters
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <ClCompile Include="loader.cpp" />
- <ClCompile Include="stdafx.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="stdafx.h" />
- <ClInclude Include="targetver.h" />
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/windows/winnet/src/extras/loader/stdafx.cpp b/windows/winnet/src/extras/loader/stdafx.cpp
deleted file mode 100644
index 8d6fa45555..0000000000
--- a/windows/winnet/src/extras/loader/stdafx.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-// stdafx.cpp : source file that includes just the standard includes
-// loader.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
diff --git a/windows/winnet/src/extras/loader/stdafx.h b/windows/winnet/src/extras/loader/stdafx.h
deleted file mode 100644
index b005a839de..0000000000
--- a/windows/winnet/src/extras/loader/stdafx.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#pragma once
-
-#include "targetver.h"
-
-#include <stdio.h>
-#include <tchar.h>
-
-
-
-// TODO: reference additional headers your program requires here
diff --git a/windows/winnet/src/extras/loader/targetver.h b/windows/winnet/src/extras/loader/targetver.h
deleted file mode 100644
index 87c0086de7..0000000000
--- a/windows/winnet/src/extras/loader/targetver.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-// Including SDKDDKVer.h defines the highest available Windows platform.
-
-// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
-// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
-
-#include <SDKDDKVer.h>
diff --git a/windows/winnet/src/extras/tests/adaptermonitor.cpp b/windows/winnet/src/extras/tests/adaptermonitor.cpp
deleted file mode 100644
index 465bb0b7cd..0000000000
--- a/windows/winnet/src/extras/tests/adaptermonitor.cpp
+++ /dev/null
@@ -1,798 +0,0 @@
-#include "stdafx.h"
-#include "testadapterutil.h"
-#include <libshared/logging/stdoutlogger.h>
-#include <libshared/logging/logsinkadapter.h>
-#include <iostream>
-#include <CppUnitTest.h>
-
-using namespace Microsoft::VisualStudio::CppUnitTestFramework;
-
-
-namespace
-{
-
-auto MakeStdoutLogger()
-{
- return std::make_shared<shared::logging::LogSinkAdapter>(shared::logging::StdoutLogger, nullptr);
-}
-
-enum class LastEvent
-{
- NoEvent,
- Add,
- Delete,
- Update
-};
-
-}
-
-namespace Microsoft::VisualStudio::CppUnitTestFramework
-{
-
-template<>
-std::wstring ToString<LastEvent>(const enum class LastEvent& t)
-{
- switch (t)
- {
- case LastEvent::NoEvent:
- return L"LastEvent::NoEvent";
- case LastEvent::Add:
- return L"LastEvent::Add";
- case LastEvent::Delete:
- return L"LastEvent::Delete";
- case LastEvent::Update:
- return L"LastEvent::Update";
- }
- return L"LastEvent::<Unknown value>";
-}
-
-}
-
-TEST_CLASS(NetworkAdapterMonitorTests)
-{
-public:
-
- TEST_METHOD(addAdapter)
- {
- auto logSink = MakeStdoutLogger();
-
- const auto filter = [](const MIB_IF_ROW2 &) -> bool
- {
- return true;
- };
-
- const auto testProvider = std::make_shared<TestDataProvider>();
- size_t adapterCount = 0;
-
- NetworkAdapterMonitor inst(
- logSink,
- [&adapterCount](const std::vector<MIB_IF_ROW2> &adapters, const MIB_IF_ROW2 *, UpdateType) -> void
- {
- adapterCount = adapters.size();
- },
- filter,
- testProvider
- );
-
- Assert::AreEqual(
- size_t(0),
- adapterCount,
- L"Expected 0 adapters initially"
- );
-
- //
- // Add new adapter
- //
-
- constexpr size_t currentLuid = 100;
-
- MIB_IF_ROW2 adapter = { 0 };
- adapter.InterfaceLuid.Value = currentLuid;
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_UP;
-
- MIB_IPINTERFACE_ROW iface = { 0 };
- iface.InterfaceLuid.Value = currentLuid;
- iface.Family = AF_INET;
-
- testProvider->addIpInterface(adapter, iface);
-
- testProvider->sendEvent(&iface, MibAddInstance);
-
- Assert::AreEqual(
- size_t(1),
- adapterCount,
- L"Expected new adapter"
- );
- }
-
- TEST_METHOD(addAdapter_Duplicate)
- {
- auto logSink = MakeStdoutLogger();
-
- const auto filter = [](const MIB_IF_ROW2 &) -> bool
- {
- return true;
- };
-
- const auto testProvider = std::make_shared<TestDataProvider>();
- size_t adapterCount = 0;
-
- NetworkAdapterMonitor inst(
- logSink,
- [&adapterCount](const std::vector<MIB_IF_ROW2> &adapters, const MIB_IF_ROW2 *, UpdateType) -> void
- {
- adapterCount = adapters.size();
- },
- filter,
- testProvider
- );
-
- //
- // Create a fake adapter
- //
-
- MIB_IF_ROW2 adapter = { 0 };
- adapter.InterfaceLuid.Value = 1;
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_UP;
-
- MIB_IPINTERFACE_ROW iface = { 0 };
- iface.InterfaceLuid.Value = 1;
- iface.Family = AF_INET;
-
- testProvider->addIpInterface(adapter, iface);
-
- testProvider->sendEvent(&iface, MibAddInstance);
-
- Assert::AreEqual(
- size_t(1),
- adapterCount,
- L"Expected new adapter"
- );
-
- //
- // Register the same interface twice
- //
- testProvider->sendEvent(&iface, MibAddInstance);
-
- Assert::AreEqual(
- size_t(1),
- adapterCount,
- L"Expected ignored duplicate interface event"
- );
- }
-
- TEST_METHOD(removeAdapter_AdminStatus)
- {
- auto logSink = MakeStdoutLogger();
-
- const auto filter = [](const MIB_IF_ROW2 &) -> bool
- {
- return true;
- };
-
- const auto testProvider = std::make_shared<TestDataProvider>();
- size_t adapterCount = 0;
-
- NetworkAdapterMonitor inst(
- logSink,
- [&adapterCount](const std::vector<MIB_IF_ROW2> &adapters, const MIB_IF_ROW2 *, UpdateType) -> void
- {
- adapterCount = adapters.size();
- },
- filter,
- testProvider
- );
-
- //
- // Create fake adapter
- //
- constexpr size_t luidValue = 1;
-
- MIB_IF_ROW2 adapter = { 0 };
- adapter.InterfaceLuid.Value = luidValue;
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_UP;
-
- MIB_IPINTERFACE_ROW iface = { 0 };
- iface.InterfaceLuid.Value = luidValue;
- iface.Family = AF_INET;
-
- testProvider->addIpInterface(adapter, iface);
-
- testProvider->sendEvent(&iface, MibAddInstance);
-
- Assert::AreEqual(
- luidValue,
- adapterCount,
- L"Expected new adapter"
- );
-
- //
- // Delete adapter (AdminStatus)
- //
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_DOWN;
- testProvider->addAdapter(adapter);
-
- testProvider->sendEvent(&iface, MibDeleteInstance);
-
- testProvider->removeAdapter(adapter);
-
- Assert::AreEqual(
- size_t(0),
- adapterCount,
- L"Expected removed adapter"
- );
- }
-
- TEST_METHOD(removeAdapter_NoInterfaces)
- {
- auto logSink = MakeStdoutLogger();
-
- const auto filter = [](const MIB_IF_ROW2 &) -> bool
- {
- return true;
- };
-
- const auto testProvider = std::make_shared<TestDataProvider>();
- size_t adapterCount = 0;
-
- NetworkAdapterMonitor inst(
- logSink,
- [&adapterCount](const std::vector<MIB_IF_ROW2> &adapters, const MIB_IF_ROW2 *, UpdateType) -> void
- {
- adapterCount = adapters.size();
- },
- filter,
- testProvider
- );
-
- //
- // Create fake adapter
- //
-
- constexpr size_t luidValue = 1;
-
- MIB_IF_ROW2 adapter = { 0 };
- adapter.InterfaceLuid.Value = luidValue;
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_UP;
-
- MIB_IPINTERFACE_ROW iface = { 0 };
- iface.InterfaceLuid.Value = luidValue;
- iface.Family = AF_INET;
-
- testProvider->addIpInterface(adapter, iface);
-
- testProvider->sendEvent(&iface, MibAddInstance);
-
- Assert::AreEqual(
- luidValue,
- adapterCount,
- L"Expected new adapter (with IPv4 interface)"
- );
-
- //
- // Delete IP interfaces on the adapter (should report Delete)
- //
-
- testProvider->removeIpInterface(iface);
- testProvider->sendEvent(&iface, MibDeleteInstance);
-
- adapter = { 0 };
- adapter.InterfaceLuid.Value = luidValue;
- testProvider->removeAdapter(adapter);
-
- Assert::AreEqual(
- size_t(0),
- adapterCount,
- L"Expected removed adapter"
- );
- }
-
- TEST_METHOD(removeAdapter_Duplicate)
- {
- auto logSink = MakeStdoutLogger();
-
- const auto filter = [](const MIB_IF_ROW2 &) -> bool
- {
- return true;
- };
-
- const auto testProvider = std::make_shared<TestDataProvider>();
- size_t adapterCount = 0;
-
- NetworkAdapterMonitor inst(
- logSink,
- [&adapterCount](const std::vector<MIB_IF_ROW2> &adapters, const MIB_IF_ROW2 *, UpdateType) -> void
- {
- adapterCount = adapters.size();
- },
- filter,
- testProvider
- );
-
- //
- // Create fake adapter
- //
- MIB_IF_ROW2 adapter = { 0 };
- adapter.InterfaceLuid.Value = 1;
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_UP;
-
- MIB_IPINTERFACE_ROW iface = { 0 };
- iface.InterfaceLuid.Value = 1;
- iface.Family = AF_INET;
-
- testProvider->addIpInterface(adapter, iface);
-
- testProvider->sendEvent(&iface, MibAddInstance);
-
- Assert::AreEqual(
- size_t(1),
- adapterCount,
- L"Expected new adapter"
- );
-
- //
- // Duplicate deletion events
- //
-
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_DOWN;
- testProvider->addAdapter(adapter); // update status
-
- testProvider->removeIpInterface(iface);
-
- testProvider->sendEvent(&iface, MibDeleteInstance);
- testProvider->sendEvent(&iface, MibDeleteInstance);
- testProvider->sendEvent(&iface, MibDeleteInstance);
- testProvider->sendEvent(&iface, MibDeleteInstance);
-
- Assert::AreEqual(
- size_t(0),
- adapterCount,
- L"State inconsistent after duplicate Delete event"
- );
- }
-
- TEST_METHOD(addIPv6Interface)
- {
- auto logSink = MakeStdoutLogger();
-
- const auto filter = [](const MIB_IF_ROW2 &) -> bool
- {
- return true;
- };
-
- const auto testProvider = std::make_shared<TestDataProvider>();
- size_t adapterCount = 0;
-
- NetworkAdapterMonitor inst(
- logSink,
- [&adapterCount](const std::vector<MIB_IF_ROW2> &adapters, const MIB_IF_ROW2 *, UpdateType) -> void
- {
- adapterCount = adapters.size();
- },
- filter,
- testProvider
- );
-
- //
- // Add IPv6 interface
- //
-
- constexpr size_t currentLuid = 100;
-
- MIB_IF_ROW2 adapter = { 0 };
- adapter.InterfaceLuid.Value = currentLuid;
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_UP;
-
- MIB_IPINTERFACE_ROW iface = { 0 };
- iface.InterfaceLuid.Value = currentLuid;
- iface.Family = AF_INET6;
-
- testProvider->addIpInterface(adapter, iface);
-
- testProvider->sendEvent(&iface, MibAddInstance);
-
- Assert::AreEqual(
- size_t(1),
- adapterCount,
- L"Expected new adapter"
- );
- }
-
- TEST_METHOD(addIPv4And6Interface)
- {
- auto logSink = MakeStdoutLogger();
-
- const auto filter = [](const MIB_IF_ROW2 &) -> bool
- {
- return true;
- };
-
- const auto testProvider = std::make_shared<TestDataProvider>();
- size_t adapterCount = 0;
-
- NetworkAdapterMonitor inst(
- logSink,
- [&adapterCount](const std::vector<MIB_IF_ROW2> &adapters, const MIB_IF_ROW2 *, UpdateType) -> void
- {
- adapterCount = adapters.size();
- },
- filter,
- testProvider
- );
-
- constexpr size_t currentLuid = 1;
- constexpr size_t expectedCount = 1;
-
- MIB_IF_ROW2 adapter = { 0 };
- adapter.InterfaceLuid.Value = currentLuid;
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_UP;
-
- //
- // Add IPv4 interface
- //
-
- MIB_IPINTERFACE_ROW iface4 = { 0 };
- iface4.InterfaceLuid.Value = currentLuid;
- iface4.Family = AF_INET;
- testProvider->addIpInterface(adapter, iface4);
- testProvider->sendEvent(&iface4, MibAddInstance);
-
- //
- // Add IPv6 interface
- //
-
- MIB_IPINTERFACE_ROW iface6 = { 0 };
- iface6.InterfaceLuid.Value = currentLuid;
- iface6.Family = AF_INET6;
- testProvider->addIpInterface(adapter, iface6);
- testProvider->sendEvent(&iface6, MibAddInstance);
-
- Assert::AreEqual(
- expectedCount,
- adapterCount,
- L"Expected single adapter with two IP interfaces"
- );
- }
-
- TEST_METHOD(addIPv4And6Interface_RemoveIPv4)
- {
- auto logSink = MakeStdoutLogger();
-
- const auto filter = [](const MIB_IF_ROW2 &) -> bool
- {
- return true;
- };
-
- const auto testProvider = std::make_shared<TestDataProvider>();
- size_t adapterCount = 0;
-
- NetworkAdapterMonitor inst(
- logSink,
- [&adapterCount](const std::vector<MIB_IF_ROW2> &adapters, const MIB_IF_ROW2 *, UpdateType) -> void
- {
- adapterCount = adapters.size();
- },
- filter,
- testProvider
- );
-
- constexpr size_t currentLuid = 1;
-
- MIB_IF_ROW2 adapter = { 0 };
- adapter.InterfaceLuid.Value = currentLuid;
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_UP;
-
- //
- // Add IPv4 interface
- //
-
- MIB_IPINTERFACE_ROW iface4 = { 0 };
- iface4.InterfaceLuid.Value = currentLuid;
- iface4.Family = AF_INET;
- testProvider->addIpInterface(adapter, iface4);
- testProvider->sendEvent(&iface4, MibAddInstance);
-
- //
- // Add IPv6 interface
- //
-
- MIB_IPINTERFACE_ROW iface6 = { 0 };
- iface6.InterfaceLuid.Value = currentLuid;
- iface6.Family = AF_INET6;
- testProvider->addIpInterface(adapter, iface6);
- testProvider->sendEvent(&iface6, MibAddInstance);
-
- //
- // Remove IPv4 interface
- //
- testProvider->removeIpInterface(iface4);
- testProvider->sendEvent(&iface4, MibDeleteInstance);
-
- constexpr size_t expectedCount = 1;
-
- Assert::AreEqual(
- expectedCount,
- adapterCount,
- L"Expected single adapter (with IPv6 interface)"
- );
- }
-
- TEST_METHOD(addIPv4And6Interface_RemoveIPv6)
- {
- auto logSink = MakeStdoutLogger();
-
- const auto filter = [](const MIB_IF_ROW2 &) -> bool
- {
- return true;
- };
-
- const auto testProvider = std::make_shared<TestDataProvider>();
- size_t adapterCount = 0;
-
- NetworkAdapterMonitor inst(
- logSink,
- [&adapterCount](const std::vector<MIB_IF_ROW2> &adapters, const MIB_IF_ROW2 *, UpdateType) -> void
- {
- adapterCount = adapters.size();
- },
- filter,
- testProvider
- );
-
- constexpr size_t currentLuid = 1;
-
- MIB_IF_ROW2 adapter = { 0 };
- adapter.InterfaceLuid.Value = currentLuid;
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_UP;
-
- //
- // Add IPv4 interface
- //
-
- MIB_IPINTERFACE_ROW iface4 = { 0 };
- iface4.InterfaceLuid.Value = currentLuid;
- iface4.Family = AF_INET;
- testProvider->addIpInterface(adapter, iface4);
- testProvider->sendEvent(&iface4, MibAddInstance);
-
- //
- // Add IPv6 interface
- //
-
- MIB_IPINTERFACE_ROW iface6 = { 0 };
- iface6.InterfaceLuid.Value = currentLuid;
- iface6.Family = AF_INET6;
- testProvider->addIpInterface(adapter, iface6);
- testProvider->sendEvent(&iface6, MibAddInstance);
-
- //
- // Remove IPv6 interface
- //
- testProvider->removeIpInterface(iface6);
- testProvider->sendEvent(&iface6, MibDeleteInstance);
-
- constexpr size_t expectedCount = 1;
-
- Assert::AreEqual(
- expectedCount,
- adapterCount,
- L"Expected single adapter (with IPv4 interface)"
- );
- }
-
- TEST_METHOD(addIPv4And6Interface_RemoveBoth)
- {
- auto logSink = MakeStdoutLogger();
-
- const auto filter = [](const MIB_IF_ROW2 &) -> bool
- {
- return true;
- };
-
- const auto testProvider = std::make_shared<TestDataProvider>();
- size_t adapterCount = 0;
-
- NetworkAdapterMonitor inst(
- logSink,
- [&adapterCount](const std::vector<MIB_IF_ROW2> &adapters, const MIB_IF_ROW2 *, UpdateType) -> void
- {
- adapterCount = adapters.size();
- },
- filter,
- testProvider
- );
-
- constexpr size_t currentLuid = 1;
-
- MIB_IF_ROW2 adapter = { 0 };
- adapter.InterfaceLuid.Value = currentLuid;
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_UP;
-
- //
- // Add IPv4 interface
- //
-
- MIB_IPINTERFACE_ROW iface4 = { 0 };
- iface4.InterfaceLuid.Value = currentLuid;
- iface4.Family = AF_INET;
- testProvider->addIpInterface(adapter, iface4);
- testProvider->sendEvent(&iface4, MibAddInstance);
-
- //
- // Add IPv6 interface
- //
-
- MIB_IPINTERFACE_ROW iface6 = { 0 };
- iface6.InterfaceLuid.Value = currentLuid;
- iface6.Family = AF_INET6;
- testProvider->addIpInterface(adapter, iface6);
- testProvider->sendEvent(&iface6, MibAddInstance);
-
- //
- // Remove IP interfaces
- //
- testProvider->removeIpInterface(iface4);
- testProvider->sendEvent(&iface4, MibDeleteInstance);
- testProvider->removeIpInterface(iface6);
- testProvider->sendEvent(&iface6, MibDeleteInstance);
-
- constexpr size_t expectedCount = 0;
-
- Assert::AreEqual(
- expectedCount,
- adapterCount,
- L"Expected no adapter (0 IP interfaces)"
- );
- }
-
- TEST_METHOD(filter)
- {
- auto logSink = MakeStdoutLogger();
-
- const auto testProvider = std::make_shared<TestDataProvider>();
-
- //
- // Exclude adapters not connected to the internet,
- // loopback devices, and software adapters
- //
-
- const auto filter = [](const MIB_IF_ROW2 &row) -> bool
- {
- switch (row.InterfaceLuid.Info.IfType)
- {
- case IF_TYPE_SOFTWARE_LOOPBACK:
- {
- return false;
- }
- }
-
- if (FALSE == row.InterfaceAndOperStatusFlags.HardwareInterface)
- {
- return false;
- }
- return IfOperStatusUp == row.OperStatus
- && MediaConnectStateConnected == row.MediaConnectState;
- };
-
- size_t adapterCount = 0;
- LastEvent lastEvent = LastEvent::NoEvent;
-
- NetworkAdapterMonitor inst(
- logSink,
- [&adapterCount, &lastEvent](const std::vector<MIB_IF_ROW2> &adapters, const MIB_IF_ROW2 *, UpdateType updateType) -> void
- {
- switch (updateType)
- {
- case UpdateType::Add:
- lastEvent = LastEvent::Add;
- break;
- case UpdateType::Delete:
- lastEvent = LastEvent::Delete;
- break;
- case UpdateType::Update:
- lastEvent = LastEvent::Update;
- break;
- default:
- Assert::Fail(L"Unhandled update type");
- }
-
- adapterCount = adapters.size();
- },
- filter,
- testProvider
- );
-
- //
- // Our filter should ignore loopback devices
- //
-
- constexpr size_t loopbackLuid = 1;
-
- MIB_IF_ROW2 adapter = { 0 };
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_UP;
- adapter.InterfaceLuid.Value = loopbackLuid;
- adapter.InterfaceLuid.Info.IfType = IF_TYPE_SOFTWARE_LOOPBACK;
- adapter.MediaConnectState = MediaConnectStateConnected;
- adapter.InterfaceAndOperStatusFlags.HardwareInterface = TRUE;
- adapter.OperStatus = IfOperStatusUp;
-
- MIB_IPINTERFACE_ROW iface4 = { 0 };
- iface4.InterfaceLuid.Value = loopbackLuid;
- iface4.Family = AF_INET;
-
- lastEvent = LastEvent::NoEvent;
-
- testProvider->addIpInterface(adapter, iface4);
- testProvider->sendEvent(&iface4, MibAddInstance);
-
- Assert::AreEqual(LastEvent::NoEvent, lastEvent, L"Unexpectedly received event for loopback adapter");
-
- Assert::AreEqual(
- size_t(0),
- adapterCount,
- L"Loopback adapter was not filtered correctly"
- );
-
- testProvider->removeIpInterface(iface4);
- testProvider->sendEvent(&iface4, MibDeleteInstance);
- testProvider->removeAdapter(adapter);
-
- Assert::AreEqual(LastEvent::NoEvent, lastEvent, L"Unexpectedly received event for loopback adapter");
-
- //
- // Our filter should ignore devices not connected to the internet
- //
-
- constexpr size_t disconnectedLuid = 2;
-
- adapter = { 0 };
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_UP;
- adapter.InterfaceLuid.Value = disconnectedLuid;
- adapter.MediaConnectState = MediaConnectStateDisconnected;
- adapter.InterfaceAndOperStatusFlags.HardwareInterface = TRUE;
- adapter.OperStatus = IfOperStatusUp;
-
- iface4 = { 0 };
- iface4.InterfaceLuid.Value = disconnectedLuid;
- iface4.Family = AF_INET;
- testProvider->addIpInterface(adapter, iface4);
- testProvider->sendEvent(&iface4, MibAddInstance);
-
- Assert::AreEqual(LastEvent::NoEvent, lastEvent, L"Unexpectedly received event for disconnected adapter");
-
- testProvider->removeIpInterface(iface4);
- testProvider->sendEvent(&iface4, MibDeleteInstance);
- testProvider->removeAdapter(adapter);
-
- Assert::AreEqual(LastEvent::NoEvent, lastEvent, L"Unexpectedly received event for disconnected adapter");
-
- //
- // Report events for hardware devices
- //
-
- constexpr size_t onlineHardwareLuid = 3;
-
- adapter = { 0 };
- adapter.AdminStatus = NET_IF_ADMIN_STATUS_UP;
- adapter.InterfaceLuid.Value = onlineHardwareLuid;
- adapter.MediaConnectState = MediaConnectStateConnected;
- adapter.InterfaceAndOperStatusFlags.HardwareInterface = TRUE;
- adapter.OperStatus = IfOperStatusUp;
-
- iface4 = { 0 };
- iface4.InterfaceLuid.Value = onlineHardwareLuid;
- iface4.Family = AF_INET;
- testProvider->addIpInterface(adapter, iface4);
- testProvider->sendEvent(&iface4, MibAddInstance);
-
- Assert::AreEqual(LastEvent::Add, lastEvent, L"Expected event for connected adapter was not received");
-
- lastEvent = LastEvent::NoEvent;
-
- testProvider->removeIpInterface(iface4);
- testProvider->sendEvent(&iface4, MibDeleteInstance);
- testProvider->removeAdapter(adapter);
-
- Assert::AreEqual(LastEvent::Delete, lastEvent, L"Expected event for connected adapter was not received");
- }
-};
diff --git a/windows/winnet/src/extras/tests/networkadaptermonitor.vcxproj.filters b/windows/winnet/src/extras/tests/networkadaptermonitor.vcxproj.filters
deleted file mode 100644
index 08573b397e..0000000000
--- a/windows/winnet/src/extras/tests/networkadaptermonitor.vcxproj.filters
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
- <Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="targetver.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="testadapterutil.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="adaptermonitor.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="offlinemonitor.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="testadapterutil.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/windows/winnet/src/extras/tests/stdafx.cpp b/windows/winnet/src/extras/tests/stdafx.cpp
deleted file mode 100644
index c5bc6dac72..0000000000
--- a/windows/winnet/src/extras/tests/stdafx.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-// stdafx.cpp : source file that includes just the standard includes
-// networkadaptermonitor.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
diff --git a/windows/winnet/src/extras/tests/stdafx.h b/windows/winnet/src/extras/tests/stdafx.h
deleted file mode 100644
index 6505f3e020..0000000000
--- a/windows/winnet/src/extras/tests/stdafx.h
+++ /dev/null
@@ -1,13 +0,0 @@
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#pragma once
-
-#include "targetver.h"
-
-// Headers for CppUnitTest
-#include <CppUnitTest.h>
-
-// TODO: reference additional headers your program requires here
diff --git a/windows/winnet/src/extras/tests/targetver.h b/windows/winnet/src/extras/tests/targetver.h
deleted file mode 100644
index 87c0086de7..0000000000
--- a/windows/winnet/src/extras/tests/targetver.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-// Including SDKDDKVer.h defines the highest available Windows platform.
-
-// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
-// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
-
-#include <SDKDDKVer.h>
diff --git a/windows/winnet/src/extras/tests/testadapterutil.cpp b/windows/winnet/src/extras/tests/testadapterutil.cpp
deleted file mode 100644
index 128cbee681..0000000000
--- a/windows/winnet/src/extras/tests/testadapterutil.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-#include "stdafx.h"
-#include "testadapterutil.h"
-#include <CppUnitTest.h>
-
-using namespace Microsoft::VisualStudio::CppUnitTestFramework;
-
-#include <libcommon/logging/logsink.h>
-#include <winnet/networkadaptermonitor.h>
-
-using FilterType = NetworkAdapterMonitor::FilterType;
-using UpdateSinkType = NetworkAdapterMonitor::UpdateSinkType;
-using UpdateType = NetworkAdapterMonitor::UpdateType;
-
-//
-// MibIfTable
-//
-
-#include <algorithm>
-
-void MibIfTable::add(const MIB_IF_ROW2 &row)
-{
- const auto it = std::find_if(
- m_table.begin(),
- m_table.end(),
- [&row](const MIB_IF_ROW2 &elem)
- {
- return elem.InterfaceLuid.Value == row.InterfaceLuid.Value;
- }
- );
-
- if (m_table.end() == it)
- {
- m_table.push_back(row);
- }
- else
- {
- *it = row;
- }
-}
-
-void MibIfTable::remove(const MIB_IF_ROW2 &row)
-{
- const auto it = std::find_if(
- m_table.begin(),
- m_table.end(),
- [&row](const MIB_IF_ROW2 &elem)
- {
- return elem.InterfaceLuid.Value == row.InterfaceLuid.Value;
- }
- );
-
- if (m_table.end() != it)
- {
- m_table.erase(it);
- }
-}
-
-
-//
-// TestDataProvider
-//
-
-DWORD TestDataProvider::notifyIpInterfaceChange(
- ADDRESS_FAMILY,
- PIPINTERFACE_CHANGE_CALLBACK Callback,
- PVOID CallerContext,
- BOOLEAN,
- HANDLE *
-)
-{
- // TODO: assert: m_callback == nullptr
- // TODO: multiple callbacks?
- m_callback = Callback;
- m_context = CallerContext;
-
- return NO_ERROR;
-}
-
-DWORD TestDataProvider::cancelMibChangeNotify2(HANDLE)
-{
- // TODO: assert: m_callback != nullptr
- // TODO: multiple callbacks?
- m_callback = nullptr;
- m_context = nullptr;
-
- return NO_ERROR;
-}
-
-DWORD TestDataProvider::getIfTable2(PMIB_IF_TABLE2 *tableOut)
-{
- MIB_IF_TABLE2 *tableCopy = reinterpret_cast<MIB_IF_TABLE2*>(new uint8_t[
- sizeof(MIB_IF_TABLE2)
- + sizeof(MIB_IF_ROW2) * m_adapterTable.entries().size()
- ]);
-
- tableCopy->NumEntries = static_cast<ULONG>(m_adapterTable.entries().size());
-
- std::copy(
- m_adapterTable.entries().begin(),
- m_adapterTable.entries().end(),
- static_cast<MIB_IF_ROW2*>(tableCopy->Table)
- );
-
- *tableOut = tableCopy;
- return NO_ERROR;
-}
-
-void TestDataProvider::freeMibTable(PVOID Memory)
-{
- delete[] reinterpret_cast<uint8_t*>(Memory);
-}
-
-DWORD TestDataProvider::getIfEntry2(PMIB_IF_ROW2 Row)
-{
- // TODO: accept InterfaceIndex as well
- // FIXME: should ERROR_INVALID_PARAMETER be returned if LUID = 0?
-
- if (nullptr == Row)
- {
- return ERROR_INVALID_PARAMETER;
- }
-
- const auto it = std::find_if(
- m_adapterTable.entries().begin(),
- m_adapterTable.entries().end(),
- [&Row](const MIB_IF_ROW2 &entry)
- {
- return entry.InterfaceLuid.Value == Row->InterfaceLuid.Value;
- }
- );
-
- if (m_adapterTable.entries().end() == it)
- {
- return ERROR_FILE_NOT_FOUND;
- }
-
- *Row = *it;
-
- return NO_ERROR;
-}
-
-DWORD TestDataProvider::getIpInterfaceEntry(PMIB_IPINTERFACE_ROW Row)
-{
- // TODO: accept InterfaceIndex as well
- // FIXME: should ERROR_INVALID_PARAMETER be returned if LUID = 0?
-
- if (nullptr == Row)
- {
- return ERROR_INVALID_PARAMETER;
- }
- if (AF_INET != Row->Family && AF_INET6 != Row->Family)
- {
- return ERROR_INVALID_PARAMETER;
- }
-
- bool foundMatchingLuid = false;
-
- for (const auto &candidate : m_ipInterfaces)
- {
- if (candidate.InterfaceLuid.Value != Row->InterfaceLuid.Value)
- {
- continue;
- }
-
- foundMatchingLuid = true;
-
- if (Row->Family == candidate.Family)
- {
- *Row = candidate;
- return NO_ERROR;
- }
- }
-
- if (foundMatchingLuid)
- {
- // "the Row parameter does not match the IP address family
- // specified in the Family member in the
- // MIB_IPINTERFACE_ROW structure."
- return ERROR_NOT_FOUND;
- }
-
- //
- // The LUID is also valid if it exists among adapters
- // without an IP interface
- //
- const auto it = std::find_if(
- m_adapterTable.entries().begin(),
- m_adapterTable.entries().end(),
- [Row](const MIB_IF_ROW2 &elem)
- {
- return Row->InterfaceLuid.Value == elem.InterfaceLuid.Value;
- }
- );
-
- if (m_adapterTable.entries().end() != it)
- {
- return ERROR_NOT_FOUND;
- }
-
- return ERROR_FILE_NOT_FOUND;
-}
-
-void TestDataProvider::addAdapter(const MIB_IF_ROW2& adapter)
-{
- m_adapterTable.add(adapter);
-}
-
-void TestDataProvider::addIpInterface(const MIB_IF_ROW2& adapter, const MIB_IPINTERFACE_ROW& iface)
-{
- addAdapter(adapter);
- m_ipInterfaces.push_back(iface);
-}
-
-void TestDataProvider::removeAdapter(const MIB_IF_ROW2& adapter)
-{
- for (auto it = m_ipInterfaces.begin(); m_ipInterfaces.end() != it; )
- {
- if (it->InterfaceLuid.Value == adapter.InterfaceLuid.Value)
- {
- it = m_ipInterfaces.erase(it);
- }
- else
- {
- ++it;
- }
- }
-
- m_adapterTable.remove(adapter);
-}
-
-void TestDataProvider::removeIpInterface(const MIB_IPINTERFACE_ROW& iface)
-{
- const auto it = std::find_if(
- m_ipInterfaces.begin(),
- m_ipInterfaces.end(),
- [&iface](const MIB_IPINTERFACE_ROW &elem)
- {
- return iface.InterfaceLuid.Value == elem.InterfaceLuid.Value
- && iface.Family == elem.Family;
- }
- );
-
- if (m_ipInterfaces.end() != it)
- {
- m_ipInterfaces.erase(it);
- }
-}
-
-void TestDataProvider::sendEvent(MIB_IPINTERFACE_ROW *hint, MIB_NOTIFICATION_TYPE updateType)
-{
- m_callback(m_context, hint, updateType);
-}
diff --git a/windows/winnet/src/extras/tests/testadapterutil.h b/windows/winnet/src/extras/tests/testadapterutil.h
deleted file mode 100644
index 5ae8cc32c2..0000000000
--- a/windows/winnet/src/extras/tests/testadapterutil.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#pragma once
-
-#include <functional>
-#include <winSock2.h>
-#include <winnet/networkadaptermonitor.h>
-
-using FilterType = NetworkAdapterMonitor::FilterType;
-using UpdateSinkType = NetworkAdapterMonitor::UpdateSinkType;
-using UpdateType = NetworkAdapterMonitor::UpdateType;
-
-
-class MibIfTable
-{
- std::vector<MIB_IF_ROW2> m_table;
-
-public:
-
- void add(const MIB_IF_ROW2 &row);
- void remove(const MIB_IF_ROW2 &row);
-
- const std::vector<MIB_IF_ROW2>& entries() const
- {
- return m_table;
- }
-};
-
-class TestDataProvider : public NetworkAdapterMonitor::IDataProvider
-{
-
- PIPINTERFACE_CHANGE_CALLBACK m_callback;
- void *m_context;
-
- MibIfTable m_adapterTable;
- std::vector<MIB_IPINTERFACE_ROW> m_ipInterfaces;
-
-public:
-
- TestDataProvider() : m_callback(nullptr), m_context(nullptr)
- {
- }
-
- TestDataProvider(const TestDataProvider&) = delete;
- TestDataProvider(TestDataProvider&&) = delete;
- TestDataProvider& operator=(const TestDataProvider&) = delete;
- TestDataProvider& operator=(const TestDataProvider&&) = delete;
-
- DWORD notifyIpInterfaceChange(
- ADDRESS_FAMILY Family,
- PIPINTERFACE_CHANGE_CALLBACK Callback,
- PVOID CallerContext,
- BOOLEAN InitialNotification,
- HANDLE *NotificationHandle
- ) override;
- DWORD cancelMibChangeNotify2(HANDLE NotificationHandle) override;
-
- DWORD getIfTable2(PMIB_IF_TABLE2 *Table) override;
- void freeMibTable(PVOID Memory) override;
-
- DWORD getIfEntry2(PMIB_IF_ROW2 Row) override;
- DWORD getIpInterfaceEntry(PMIB_IPINTERFACE_ROW Row) override;
-
- //
- // Test utilities
- //
-
- void addAdapter(const MIB_IF_ROW2 &adapter);
- void addIpInterface(const MIB_IF_ROW2 &adapter, const MIB_IPINTERFACE_ROW &iface);
-
- void removeAdapter(const MIB_IF_ROW2 &adapter);
- void removeIpInterface(const MIB_IPINTERFACE_ROW &iface);
-
- void sendEvent(MIB_IPINTERFACE_ROW *hint, MIB_NOTIFICATION_TYPE updateType);
-};
diff --git a/windows/winnet/src/extras/tests/tests.vcxproj b/windows/winnet/src/extras/tests/tests.vcxproj
deleted file mode 100644
index b131033d53..0000000000
--- a/windows/winnet/src/extras/tests/tests.vcxproj
+++ /dev/null
@@ -1,109 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <VCProjectVersion>16.0</VCProjectVersion>
- <ProjectGuid>{01A4E766-CC61-40B7-A3D6-7A37F6BF5CCB}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>tests</RootNamespace>
- <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
- <ProjectSubType>NativeUnitTestProject</ProjectSubType>
- <ProjectName>tests</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- <UseOfMfc>false</UseOfMfc>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- <UseOfMfc>false</UseOfMfc>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="Shared">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
- <IntDir>$(SolutionDir)bin\temp\$(Platform)-$(Configuration)\$(ProjectName)\</IntDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
- <IntDir>$(SolutionDir)bin\temp\$(Platform)-$(Configuration)\$(ProjectName)\</IntDir>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>$(ProjectDir)../../;$(ProjectDir)../../../../libshared/src;$(ProjectDir)../../../../windows-libraries/src;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <UseFullPaths>true</UseFullPaths>
- <LanguageStandard>stdcpplatest</LanguageStandard>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-$(Configuration);$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libshared.lib;libcommon.lib;winnet-static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>$(ProjectDir)../../;$(ProjectDir)../../../../libshared/src;$(ProjectDir)../../../../windows-libraries/src;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <UseFullPaths>true</UseFullPaths>
- <LanguageStandard>stdcpplatest</LanguageStandard>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-$(Configuration);$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libshared.lib;libcommon.lib;winnet-static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClInclude Include="stdafx.h" />
- <ClInclude Include="targetver.h" />
- <ClInclude Include="testadapterutil.h" />
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="adaptermonitor.cpp" />
- <ClCompile Include="testadapterutil.cpp" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/windows/winnet/src/winnet/converters.cpp b/windows/winnet/src/winnet/converters.cpp
deleted file mode 100644
index c09ae6339d..0000000000
--- a/windows/winnet/src/winnet/converters.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-#include <stdafx.h>
-#include "converters.h"
-#include <libcommon/error.h>
-#include <cstdint>
-
-using namespace winnet::routing;
-
-namespace
-{
-
-SOCKADDR_INET IpToNative(const WINNET_IP &from)
-{
- SOCKADDR_INET to = { 0 };
-
- switch (from.family)
- {
- case WINNET_ADDR_FAMILY_IPV4:
- {
- to.Ipv4.sin_family = AF_INET;
- to.Ipv4.sin_addr.s_addr = *reinterpret_cast<const uint32_t*>(from.bytes);
-
- break;
- }
- case WINNET_ADDR_FAMILY_IPV6:
- {
- to.Ipv6.sin6_family = AF_INET6;
- memcpy(to.Ipv6.sin6_addr.u.Byte, from.bytes, 16);
-
- break;
- }
- default:
- {
- THROW_ERROR("Invalid network address family");
- }
- }
-
- return to;
-}
-
-WINNET_IP IpFromNative(const SOCKADDR_INET &from)
-{
- WINNET_IP to = { 0 };
-
- switch (from.si_family)
- {
- case AF_INET:
- {
- *reinterpret_cast<uint32_t*>(to.bytes) = static_cast<uint32_t>(from.Ipv4.sin_addr.s_addr);
- to.family = WINNET_ADDR_FAMILY_IPV4;
- break;
- }
- case AF_INET6:
- {
- memcpy(to.bytes, from.Ipv6.sin6_addr.u.Byte, 16);
- to.family = WINNET_ADDR_FAMILY_IPV6;
- break;
- }
- default:
- {
- THROW_ERROR("Invalid network address family");
- }
- }
-
- return to;
-}
-
-} // anonymous namespace
-
-namespace winnet
-{
-
-Network ConvertNetwork(const WINNET_IP_NETWORK &in)
-{
- //
- // Convert WINNET_IPNETWORK into Network aka IP_ADDRESS_PREFIX
- //
-
- Network out = { 0 };
-
- out.PrefixLength = in.prefix;
- out.Prefix = IpToNative(in.addr);
-
- return out;
-}
-
-std::optional<Node> ConvertNode(const WINNET_NODE *in)
-{
- if (nullptr == in)
- {
- return std::nullopt;
- }
-
- if (nullptr == in->deviceName && nullptr == in->gateway)
- {
- THROW_ERROR("Invalid 'WINNET_NODE' definition");
- }
-
- std::optional<std::wstring> deviceName;
- std::optional<NodeAddress> gateway;
-
- if (nullptr != in->deviceName)
- {
- deviceName = in->deviceName;
- }
-
- if (nullptr != in->gateway)
- {
- gateway = IpToNative(*in->gateway);
- }
-
- return Node(deviceName, gateway);
-}
-
-std::vector<Route> ConvertRoutes(const WINNET_ROUTE *routes, uint32_t numRoutes)
-{
- std::vector<Route> out;
-
- out.reserve(numRoutes);
-
- for (size_t i = 0; i < numRoutes; ++i)
- {
- out.emplace_back(Route
- {
- ConvertNetwork(routes[i].network),
- ConvertNode(routes[i].node)
- });
- }
-
- return out;
-}
-
-std::vector<WINNET_IP> ConvertNativeAddresses(const SOCKADDR_INET *addresses, uint32_t numAddresses)
-{
- std::vector<WINNET_IP> out;
- out.reserve(numAddresses);
-
- for (uint32_t i = 0; i < numAddresses; ++i)
- {
- out.emplace_back(IpFromNative(addresses[i]));
- }
-
- return out;
-}
-
-}
diff --git a/windows/winnet/src/winnet/converters.h b/windows/winnet/src/winnet/converters.h
deleted file mode 100644
index a608958cee..0000000000
--- a/windows/winnet/src/winnet/converters.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#pragma once
-
-#include "winnet.h"
-#include "routing/types.h"
-#include <optional>
-#include <vector>
-
-namespace winnet
-{
-
-routing::Network ConvertNetwork(const WINNET_IP_NETWORK &in);
-std::optional<routing::Node> ConvertNode(const WINNET_NODE *in);
-std::vector<routing::Route> ConvertRoutes(const WINNET_ROUTE *routes, uint32_t numRoutes);
-std::vector<WINNET_IP> ConvertNativeAddresses(const SOCKADDR_INET *addresses, uint32_t numAddresses);
-
-}
diff --git a/windows/winnet/src/winnet/dllmain.cpp b/windows/winnet/src/winnet/dllmain.cpp
deleted file mode 100644
index e66eb0495d..0000000000
--- a/windows/winnet/src/winnet/dllmain.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "stdafx.h"
-#include <windows.h>
-
-BOOL APIENTRY DllMain(HMODULE, DWORD, LPVOID)
-{
- //
- // Avoid doing work in DllMain since the loader lock is held
- //
-
- return TRUE;
-}
diff --git a/windows/winnet/src/winnet/routing/defaultroutemonitor.cpp b/windows/winnet/src/winnet/routing/defaultroutemonitor.cpp
deleted file mode 100644
index 8e1e2599ad..0000000000
--- a/windows/winnet/src/winnet/routing/defaultroutemonitor.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-#include "stdafx.h"
-#include <libcommon/error.h>
-#include "defaultroutemonitor.h"
-#include "helpers.h"
-
-namespace winnet::routing
-{
-
-namespace
-{
-
-const uint32_t POINT_TWO_SECOND_BURST = 200;
-const uint32_t TWO_SECOND_INTERFERENCE = 2000;
-
-} // anonymous namespace
-
-DefaultRouteMonitor::DefaultRouteMonitor
-(
- ADDRESS_FAMILY family,
- Callback callback,
- std::shared_ptr<common::logging::ILogSink> logSink
-)
- : m_family(family)
- , m_callback(callback)
- , m_logSink(logSink)
- , m_refreshCurrentRoute(false)
- , m_evaluateRoutesGuard(std::make_unique<common::BurstGuard>(
- std::bind(&DefaultRouteMonitor::evaluateRoutes, this),
- POINT_TWO_SECOND_BURST,
- TWO_SECOND_INTERFERENCE
- ))
-{
- std::scoped_lock<std::mutex> lock(m_evaluationLock);
-
- auto status = NotifyRouteChange2(family, RouteChangeCallback, this, FALSE, &m_routeNotificationHandle);
-
- if (NO_ERROR != status)
- {
- THROW_WINDOWS_ERROR(status, "Register for route table change notifications");
- }
-
- status = NotifyIpInterfaceChange(family, InterfaceChangeCallback, this,
- FALSE, &m_interfaceNotificationHandle);
-
- if (NO_ERROR != status)
- {
- CancelMibChangeNotify2(m_routeNotificationHandle);
- THROW_WINDOWS_ERROR(status, "Register for network interface change notifications");
- }
-
- status = NotifyUnicastIpAddressChange(family, AddressChangeCallback, this,
- FALSE, &m_addressNotificationHandle);
-
- if (NO_ERROR != status)
- {
- CancelMibChangeNotify2(m_routeNotificationHandle);
- CancelMibChangeNotify2(m_interfaceNotificationHandle);
- THROW_WINDOWS_ERROR(status, "Register for unicast address change notifications");
- }
-
- try
- {
- m_bestRoute = GetBestDefaultRoute(m_family);
- }
- catch (...)
- {
- }
-}
-
-DefaultRouteMonitor::~DefaultRouteMonitor()
-{
- //
- // Cancel notifications to stop triggering the BurstGuard.
- //
-
- CancelMibChangeNotify2(m_addressNotificationHandle);
- CancelMibChangeNotify2(m_interfaceNotificationHandle);
- CancelMibChangeNotify2(m_routeNotificationHandle);
-
- //
- // Controlled destruction of BurstGuard to prevent it from calling here
- // after other member variables have been destructed.
- //
-
- m_evaluateRoutesGuard.reset();
-}
-
-//static
-void NETIOAPI_API_ DefaultRouteMonitor::RouteChangeCallback
-(
- void *context,
- MIB_IPFORWARD_ROW2 *row,
- MIB_NOTIFICATION_TYPE
-)
-{
- //
- // We're only interested in changes that add/remove/update a default route.
- //
-
- if (0 != row->DestinationPrefix.PrefixLength
- || false == RouteHasGateway(*row))
- {
- return;
- }
-
- const auto monitor = reinterpret_cast<DefaultRouteMonitor*>(context);
- monitor->updateRefreshFlag(row->InterfaceLuid, row->InterfaceIndex);
- monitor->m_evaluateRoutesGuard->trigger();
-}
-
-//static
-void NETIOAPI_API_ DefaultRouteMonitor::InterfaceChangeCallback
-(
- void *context,
- MIB_IPINTERFACE_ROW *row,
- MIB_NOTIFICATION_TYPE
-)
-{
- const auto monitor = reinterpret_cast<DefaultRouteMonitor*>(context);
- monitor->updateRefreshFlag(row->InterfaceLuid, row->InterfaceIndex);
- monitor->m_evaluateRoutesGuard->trigger();
-}
-
-//static
-void NETIOAPI_API_ DefaultRouteMonitor::AddressChangeCallback
-(
- void *context,
- MIB_UNICASTIPADDRESS_ROW *row,
- MIB_NOTIFICATION_TYPE
-)
-{
- const auto monitor = reinterpret_cast<DefaultRouteMonitor*>(context);
- monitor->updateRefreshFlag(row->InterfaceLuid, row->InterfaceIndex);
- monitor->m_evaluateRoutesGuard->trigger();
-}
-
-void DefaultRouteMonitor::updateRefreshFlag(const NET_LUID &luid, const NET_IFINDEX &index)
-{
- std::scoped_lock<std::mutex> lock(m_evaluationLock);
-
- if (!m_bestRoute.has_value())
- {
- return;
- }
-
- if (luid.Value == m_bestRoute->iface.Value)
- {
- m_refreshCurrentRoute = true;
- return;
- }
-
- if (luid.Value != 0)
- {
- return;
- }
-
- NET_IFINDEX defaultInterfaceIndex = 0;
- const auto routeLuid = &m_bestRoute->iface;
- ConvertInterfaceLuidToIndex(routeLuid, &defaultInterfaceIndex);
- m_refreshCurrentRoute = index == defaultInterfaceIndex ||
- (defaultInterfaceIndex == NET_IFINDEX_UNSPECIFIED);
-}
-
-void DefaultRouteMonitor::evaluateRoutes()
-{
- std::scoped_lock<std::mutex> lock(m_evaluationLock);
-
- try
- {
- evaluateRoutesInner();
- }
- catch (const std::exception &ex)
- {
- const auto msg = std::string("Failure while evaluating route table: ").append(ex.what());
- m_logSink->error(msg.c_str());
- }
- catch (...)
- {
- m_logSink->error("Unspecified failure while evaluating route table");
- }
-}
-
-void DefaultRouteMonitor::evaluateRoutesInner()
-{
- std::optional<InterfaceAndGateway> currentBestRoute;
-
- bool refreshCurrent = m_refreshCurrentRoute;
- m_refreshCurrentRoute = false;
-
- try
- {
- currentBestRoute = GetBestDefaultRoute(m_family);
- }
- catch (...)
- {
- }
-
- //
- // If there was no default route previously.
- //
-
- if (false == m_bestRoute.has_value())
- {
- if (currentBestRoute.has_value())
- {
- m_bestRoute = currentBestRoute;
- m_callback(EventType::Updated, m_bestRoute);
- }
-
- return;
- }
-
- //
- // There used to be a default route.
- // If there is not currently a default route.
- //
-
- if (false == currentBestRoute.has_value())
- {
- m_bestRoute.reset();
- m_callback(EventType::Removed, std::nullopt);
-
- return;
- }
-
- //
- // The current best route may have changed.
- //
-
- if (m_bestRoute.value() != currentBestRoute.value())
- {
- m_bestRoute = currentBestRoute;
- m_callback(EventType::Updated, m_bestRoute);
-
- return;
- }
-
- //
- // Interface details may have changed.
- //
-
- if (refreshCurrent)
- {
- m_callback(EventType::UpdatedDetails, m_bestRoute);
- }
-}
-
-}
diff --git a/windows/winnet/src/winnet/routing/defaultroutemonitor.h b/windows/winnet/src/winnet/routing/defaultroutemonitor.h
deleted file mode 100644
index ce2a3ce3f6..0000000000
--- a/windows/winnet/src/winnet/routing/defaultroutemonitor.h
+++ /dev/null
@@ -1,78 +0,0 @@
-#pragma once
-
-#include <ifdef.h>
-#include <ws2def.h>
-#include <functional>
-#include <optional>
-#include <memory>
-#include <mutex>
-#include <libcommon/logging/ilogsink.h>
-#include <libcommon/burstguard.h>
-#include "types.h"
-
-namespace winnet::routing
-{
-
-class DefaultRouteMonitor
-{
-public:
-
- enum class EventType
- {
- // The best default route changed.
- Updated,
-
- // Interface details changed; the associated interface and
- // gateway did not.
- UpdatedDetails,
-
- // No default routes exist.
- Removed,
- };
-
- using Callback = std::function<void
- (
- EventType eventType,
-
- // For update events, data associated with the new best default route.
- const std::optional<InterfaceAndGateway> &route
- )>;
-
- DefaultRouteMonitor(ADDRESS_FAMILY family, Callback callback, std::shared_ptr<common::logging::ILogSink> logSink);
- ~DefaultRouteMonitor();
-
- DefaultRouteMonitor(const DefaultRouteMonitor &) = delete;
- DefaultRouteMonitor(DefaultRouteMonitor &&) = delete;
- DefaultRouteMonitor &operator=(const DefaultRouteMonitor &) = delete;
- DefaultRouteMonitor &operator=(DefaultRouteMonitor &&) = delete;
-
-private:
-
- ADDRESS_FAMILY m_family;
- Callback m_callback;
- std::shared_ptr<common::logging::ILogSink> m_logSink;
-
- // This can't be a plain member variable.
- // We need to be able to delete it explicitly in order to have a controlled tear down.
- std::unique_ptr<common::BurstGuard> m_evaluateRoutesGuard;
-
- std::optional<InterfaceAndGateway> m_bestRoute;
- bool m_refreshCurrentRoute;
-
- HANDLE m_routeNotificationHandle;
- HANDLE m_interfaceNotificationHandle;
- HANDLE m_addressNotificationHandle;
-
- std::mutex m_evaluationLock;
-
- static void NETIOAPI_API_ RouteChangeCallback(void *context, MIB_IPFORWARD_ROW2 *row, MIB_NOTIFICATION_TYPE notificationType);
- static void NETIOAPI_API_ InterfaceChangeCallback(void *context, MIB_IPINTERFACE_ROW *row, MIB_NOTIFICATION_TYPE notificationType);
- static void NETIOAPI_API_ AddressChangeCallback(void *context, MIB_UNICASTIPADDRESS_ROW *row, MIB_NOTIFICATION_TYPE notificationType);
-
- void updateRefreshFlag(const NET_LUID &luid, const NET_IFINDEX &index);
-
- void evaluateRoutes();
- void evaluateRoutesInner();
-};
-
-}
diff --git a/windows/winnet/src/winnet/routing/helpers.cpp b/windows/winnet/src/winnet/routing/helpers.cpp
deleted file mode 100644
index 4a85fda1fb..0000000000
--- a/windows/winnet/src/winnet/routing/helpers.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-#include "stdafx.h"
-#include "helpers.h"
-#include <ws2def.h>
-#include <in6addr.h>
-#include <numeric>
-#include <libcommon/error.h>
-#include <libcommon/memory.h>
-
-namespace
-{
-
-// Interface description substrings found for virtual adapters.
-const wchar_t *TUNNEL_INTERFACE_DESCS[] = {
- L"WireGuard",
- L"Wintun",
- L"Tunnel"
-};
-
-bool IsRouteOnPhysicalInterface(const MIB_IPFORWARD_ROW2 &route)
-{
- switch (route.InterfaceLuid.Info.IfType)
- {
- case IF_TYPE_SOFTWARE_LOOPBACK:
- case IF_TYPE_TUNNEL:
- {
- return false;
- }
- }
-
- // OpenVPN uses interface type IF_TYPE_PROP_VIRTUAL,
- // but tethering etc. may rely on virtual adapters too,
- // so we have to filter out the TAP adapter specifically.
-
- MIB_IF_ROW2 row = { 0 };
- row.InterfaceLuid = route.InterfaceLuid;
-
- if (NO_ERROR != GetIfEntry2(&row))
- {
- THROW_ERROR("Cannot obtain interface information for the given route");
- }
-
- for (size_t i = 0; i < ARRAYSIZE(TUNNEL_INTERFACE_DESCS); i++)
- {
- if (nullptr != wcsstr(row.Description, TUNNEL_INTERFACE_DESCS[i]))
- {
- return false;
- }
- }
-
- return true;
-}
-
-} // anonymous namespace
-
-namespace winnet::routing
-{
-
-bool EqualAddress(const Network &lhs, const Network &rhs)
-{
- if (lhs.PrefixLength != rhs.PrefixLength)
- {
- return false;
- }
-
- return EqualAddress(lhs.Prefix, rhs.Prefix);
-}
-
-bool EqualAddress(const NodeAddress &lhs, const NodeAddress &rhs)
-{
- if (lhs.si_family != rhs.si_family)
- {
- return false;
- }
-
- switch (lhs.si_family)
- {
- case AF_INET:
- {
- return lhs.Ipv4.sin_addr.s_addr == rhs.Ipv4.sin_addr.s_addr;
- }
- case AF_INET6:
- {
- return 0 == memcmp(&lhs.Ipv6.sin6_addr, &rhs.Ipv6.sin6_addr, sizeof(IN6_ADDR));
- }
- default:
- {
- THROW_ERROR("Invalid address family for network address");
- }
- }
-}
-
-bool EqualAddress(const SOCKADDR_INET *lhs, const SOCKET_ADDRESS *rhs)
-{
- if (lhs->si_family != rhs->lpSockaddr->sa_family)
- {
- return false;
- }
-
- switch (lhs->si_family)
- {
- case AF_INET:
- {
- auto typedRhs = reinterpret_cast<const SOCKADDR_IN *>(rhs->lpSockaddr);
- return lhs->Ipv4.sin_addr.s_addr == typedRhs->sin_addr.s_addr;
- }
- case AF_INET6:
- {
- auto typedRhs = reinterpret_cast<const SOCKADDR_IN6 *>(rhs->lpSockaddr);
- return 0 == memcmp(lhs->Ipv6.sin6_addr.u.Byte, typedRhs->sin6_addr.u.Byte, 16);
- }
- default:
- {
- THROW_ERROR("Missing case handler in switch clause");
- }
- }
-}
-
-bool GetAdapterInterface(NET_LUID adapter, ADDRESS_FAMILY addressFamily, MIB_IPINTERFACE_ROW *iface)
-{
- memset(iface, 0, sizeof(MIB_IPINTERFACE_ROW));
-
- iface->Family = addressFamily;
- iface->InterfaceLuid = adapter;
-
- return NO_ERROR == GetIpInterfaceEntry(iface);
-}
-
-std::vector<AnnotatedRoute> AnnotateRoutes(const std::vector<const MIB_IPFORWARD_ROW2 *> &routes)
-{
- std::vector<AnnotatedRoute> annotated;
- annotated.reserve(routes.size());
-
- for (auto route : routes)
- {
- MIB_IPINTERFACE_ROW iface;
-
- if (false == GetAdapterInterface(route->InterfaceLuid, route->DestinationPrefix.Prefix.si_family, &iface))
- {
- continue;
- }
-
- annotated.emplace_back
- (
- AnnotatedRoute{ route, bool_cast(iface.Connected), route->Metric + iface.Metric }
- );
- }
-
- return annotated;
-}
-
-bool RouteHasGateway(const MIB_IPFORWARD_ROW2 &route)
-{
- switch (route.NextHop.si_family)
- {
- case AF_INET:
- {
- return 0 != route.NextHop.Ipv4.sin_addr.s_addr;
- }
- case AF_INET6:
- {
- const uint8_t *begin = &route.NextHop.Ipv6.sin6_addr.u.Byte[0];
- const uint8_t *end = begin + 16;
-
- return 0 != std::accumulate(begin, end, 0);
- }
- default:
- {
- return false;
- }
- };
-}
-
-std::optional<InterfaceAndGateway> GetBestDefaultRoute(ADDRESS_FAMILY family)
-{
- PMIB_IPFORWARD_TABLE2 table;
-
- auto status = GetIpForwardTable2(family, &table);
-
- if (NO_ERROR != status)
- {
- THROW_WINDOWS_ERROR(status, "Acquire route table");
- }
-
- common::memory::ScopeDestructor sd;
-
- sd += [table]
- {
- FreeMibTable(table);
- };
-
- std::vector<const MIB_IPFORWARD_ROW2 *> candidates;
- candidates.reserve(table->NumEntries);
-
- //
- // Enumerate routes looking for: route 0/0
- // The WireGuard interface route has no gateway.
- //
-
- for (ULONG i = 0; i < table->NumEntries; ++i)
- {
- const MIB_IPFORWARD_ROW2 &candidate = table->Table[i];
-
- if (0 == candidate.DestinationPrefix.PrefixLength
- && RouteHasGateway(candidate)
- && IsRouteOnPhysicalInterface(candidate))
- {
- candidates.emplace_back(&candidate);
- }
- }
-
- auto annotated = AnnotateRoutes(candidates);
-
- if (annotated.empty())
- {
- return std::nullopt;
- }
-
- //
- // Sort on (active, effectiveMetric) ascending by metric.
- //
-
- std::sort(annotated.begin(), annotated.end(), [](const AnnotatedRoute &lhs, const AnnotatedRoute &rhs)
- {
- if (lhs.active == rhs.active)
- {
- return lhs.effectiveMetric < rhs.effectiveMetric;
- }
-
- return lhs.active && false == rhs.active;
- });
-
- //
- // Ensure the top rated route is active.
- //
-
- if (false == annotated[0].active)
- {
- return std::nullopt;
- }
-
- return std::make_optional(InterfaceAndGateway { annotated[0].route->InterfaceLuid, annotated[0].route->NextHop });
-}
-
-bool AdapterInterfaceEnabled(const IP_ADAPTER_ADDRESSES *adapter, ADDRESS_FAMILY family)
-{
- switch (family)
- {
- case AF_INET:
- {
- return 0 != adapter->Ipv4Enabled;
- }
- case AF_INET6:
- {
- return 0 != adapter->Ipv6Enabled;
- }
- default:
- {
- THROW_ERROR("Missing case handler in switch clause");
- }
- }
-}
-
-std::vector<const SOCKET_ADDRESS *> IsolateGatewayAddresses
-(
- PIP_ADAPTER_GATEWAY_ADDRESS_LH head,
- ADDRESS_FAMILY family
-)
-{
- std::vector<const SOCKET_ADDRESS *> matches;
-
- for (auto gateway = head; nullptr != gateway; gateway = gateway->Next)
- {
- if (family == gateway->Address.lpSockaddr->sa_family)
- {
- matches.emplace_back(&gateway->Address);
- }
- }
-
- return matches;
-}
-
-bool AddressPresent(const std::vector<const SOCKET_ADDRESS *> &hay, const SOCKADDR_INET *needle)
-{
- for (const auto candidate : hay)
- {
- if (EqualAddress(needle, candidate))
- {
- return true;
- }
- }
-
- return false;
-}
-
-}
diff --git a/windows/winnet/src/winnet/routing/helpers.h b/windows/winnet/src/winnet/routing/helpers.h
deleted file mode 100644
index 9d73585da9..0000000000
--- a/windows/winnet/src/winnet/routing/helpers.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#pragma once
-
-#include "types.h"
-#include <vector>
-#include <optional>
-
-namespace winnet::routing
-{
-
-bool EqualAddress(const Network &lhs, const Network &rhs);
-bool EqualAddress(const NodeAddress &lhs, const NodeAddress &rhs);
-bool EqualAddress(const SOCKADDR_INET *lhs, const SOCKET_ADDRESS *rhs);
-
-bool GetAdapterInterface(NET_LUID adapter, ADDRESS_FAMILY addressFamily, MIB_IPINTERFACE_ROW *iface);
-
-struct AnnotatedRoute
-{
- const MIB_IPFORWARD_ROW2 *route;
- bool active;
- uint32_t effectiveMetric;
-};
-
-template<typename T>
-bool bool_cast(const T &value)
-{
- return 0 != value;
-}
-
-std::vector<AnnotatedRoute> AnnotateRoutes(const std::vector<const MIB_IPFORWARD_ROW2 *> &routes);
-
-bool RouteHasGateway(const MIB_IPFORWARD_ROW2 &route);
-
-std::optional<InterfaceAndGateway> GetBestDefaultRoute(ADDRESS_FAMILY family);
-
-bool AdapterInterfaceEnabled(const IP_ADAPTER_ADDRESSES *adapter, ADDRESS_FAMILY family);
-
-std::vector<const SOCKET_ADDRESS *> IsolateGatewayAddresses
-(
- PIP_ADAPTER_GATEWAY_ADDRESS_LH head,
- ADDRESS_FAMILY family
-);
-
-bool AddressPresent(const std::vector<const SOCKET_ADDRESS *> &hay, const SOCKADDR_INET *needle);
-
-
-}
diff --git a/windows/winnet/src/winnet/routing/routemanager.cpp b/windows/winnet/src/winnet/routing/routemanager.cpp
deleted file mode 100644
index 2c2257e916..0000000000
--- a/windows/winnet/src/winnet/routing/routemanager.cpp
+++ /dev/null
@@ -1,647 +0,0 @@
-#include "stdafx.h"
-#include "routemanager.h"
-#include "helpers.h"
-#include <libcommon/error.h>
-#include <libcommon/memory.h>
-#include <libcommon/string.h>
-#include <libcommon/network/adapters.h>
-#include <vector>
-#include <algorithm>
-#include <numeric>
-#include <sstream>
-
-using AutoLockType = std::scoped_lock<std::mutex>;
-using AutoRecursiveLockType = std::scoped_lock<std::recursive_mutex>;
-using namespace std::placeholders;
-
-namespace winnet::routing
-{
-
-namespace
-{
-
-using Adapters = common::network::Adapters;
-
-NET_LUID InterfaceLuidFromGateway(const NodeAddress &gateway)
-{
- const DWORD adapterFlags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER
- | GAA_FLAG_SKIP_FRIENDLY_NAME | GAA_FLAG_INCLUDE_GATEWAYS;
-
- Adapters adapters(gateway.si_family, adapterFlags);
-
- //
- // Process adapters to find matching ones.
- //
-
- std::vector<const IP_ADAPTER_ADDRESSES *> matches;
-
- for (auto adapter = adapters.next(); nullptr != adapter; adapter = adapters.next())
- {
- if (false == AdapterInterfaceEnabled(adapter, gateway.si_family))
- {
- continue;
- }
-
- auto gateways = IsolateGatewayAddresses(adapter->FirstGatewayAddress, gateway.si_family);
-
- if (AddressPresent(gateways, &gateway))
- {
- matches.emplace_back(adapter);
- }
- }
-
- if (matches.empty())
- {
- THROW_ERROR_TYPE(error::DeviceGatewayNotFound, "Unable to find network adapter with specified gateway");
- }
-
- //
- // Sort matching interfaces ascending by metric.
- //
-
- const bool targetV4 = (AF_INET == gateway.si_family);
-
- std::sort(matches.begin(), matches.end(), [&targetV4](const IP_ADAPTER_ADDRESSES *lhs, const IP_ADAPTER_ADDRESSES *rhs)
- {
- if (targetV4)
- {
- return lhs->Ipv4Metric < rhs->Ipv4Metric;
- }
-
- return lhs->Ipv6Metric < rhs->Ipv6Metric;
- });
-
- //
- // Select the interface with the best (lowest) metric.
- //
-
- return matches[0]->Luid;
-}
-
-bool ParseStringEncodedLuid(const std::wstring &encodedLuid, NET_LUID &luid)
-{
- //
- // The `#` is a valid character in adapter names so we use `?` instead.
- // The LUID is thus prefixed with `?` and hex encoded and left-padded with zeroes.
- // E.g. `?deadbeefcafebabe` or `?000dbeefcafebabe`.
- //
-
- static const size_t StringEncodedLuidLength = 17;
-
- if (encodedLuid.size() != StringEncodedLuidLength
- || L'?' != encodedLuid[0])
- {
- return false;
- }
-
- try
- {
- std::wstringstream ss;
-
- ss << std::hex << &encodedLuid[1];
- ss >> luid.Value;
- }
- catch (...)
- {
- const auto msg = std::string("Failed to parse string encoded LUID: ")
- .append(common::string::ToAnsi(encodedLuid));
-
- THROW_ERROR(msg.c_str());
- }
-
- return true;
-}
-
-InterfaceAndGateway ResolveNode(ADDRESS_FAMILY family, const std::optional<Node> &optionalNode)
-{
- //
- // There are four cases:
- //
- // Unspecified node (use interface and gateway of default route).
- // Node is specified by name.
- // Node is specified by name and gateway.
- // Node is specified by gateway.
- //
-
- if (false == optionalNode.has_value())
- {
- const auto default_route = GetBestDefaultRoute(family);
- if (!default_route.has_value())
- {
- THROW_ERROR_TYPE(error::NoDefaultRoute, "Unable to determine details of default route");
- }
- return default_route.value();
- }
-
- const auto &node = optionalNode.value();
-
- if (node.deviceName().has_value())
- {
- const auto &deviceName = node.deviceName().value();
- NET_LUID luid;
-
- if (false == ParseStringEncodedLuid(deviceName, luid)
- && 0 != ConvertInterfaceAliasToLuid(deviceName.c_str(), &luid))
- {
- const auto msg = std::string("Unable to derive interface LUID from interface alias: ")
- .append(common::string::ToAnsi(deviceName));
- THROW_ERROR_TYPE(error::DeviceNameNotFound, msg.c_str());
- }
-
- auto onLinkProvider = [&family]()
- {
- NodeAddress onLink = { 0 };
- onLink.si_family = family;
-
- return onLink;
- };
-
- return InterfaceAndGateway{ luid, node.gateway().value_or(onLinkProvider()) };
- }
-
- //
- // The node is specified only by gateway.
- //
-
- return InterfaceAndGateway{ InterfaceLuidFromGateway(node.gateway().value()), node.gateway().value() };
-}
-
-std::wstring FormatNetwork(const Network &network)
-{
- using namespace common::string;
-
- switch (network.Prefix.si_family)
- {
- case AF_INET:
- {
- return FormatIpv4<AddressOrder::NetworkByteOrder>(network.Prefix.Ipv4.sin_addr.s_addr, network.PrefixLength);
- }
- case AF_INET6:
- {
- return FormatIpv6(network.Prefix.Ipv6.sin6_addr.u.Byte, network.PrefixLength);
- }
- default:
- {
- return L"Failed to format network details";
- }
- }
-}
-
-} // anonymous namespace
-
-RouteManager::RouteManager(std::shared_ptr<common::logging::ILogSink> logSink)
- : m_logSink(logSink)
- , m_routeMonitorV4(std::make_unique<DefaultRouteMonitor>(
- static_cast<ADDRESS_FAMILY>(AF_INET),
- std::bind(&RouteManager::defaultRouteChanged, this, static_cast<ADDRESS_FAMILY>(AF_INET), _1, _2),
- logSink
- ))
- , m_routeMonitorV6(std::make_unique<DefaultRouteMonitor>(
- static_cast<ADDRESS_FAMILY>(AF_INET6),
- std::bind(&RouteManager::defaultRouteChanged, this, static_cast<ADDRESS_FAMILY>(AF_INET6), _1, _2),
- logSink
- ))
-{
-}
-
-RouteManager::~RouteManager()
-{
- //
- // Stop callbacks that are triggered by events in Windows from coming in.
- //
-
- m_routeMonitorV4.reset();
- m_routeMonitorV6.reset();
-
- deleteAppliedRoutes();
-}
-
-void RouteManager::addRoutes(const std::vector<Route> &routes)
-{
- AutoLockType lock(m_routesLock);
-
- std::vector<EventEntry> eventLog;
-
- for (const auto &route : routes)
- {
- try
- {
- RouteRecord newRecord{ route, addIntoRoutingTable(route) };
-
- eventLog.emplace_back(EventEntry{ EventType::ADD_ROUTE, newRecord });
-
- auto existingRecord = findRouteRecord(newRecord.registeredRoute);
-
- if (m_routes.end() == existingRecord)
- {
- m_routes.emplace_back(std::move(newRecord));
- }
- else
- {
- *existingRecord = std::move(newRecord);
- }
- }
- catch (const error::RouteManagerError&)
- {
- undoEvents(eventLog);
- throw;
- }
- catch (...)
- {
- undoEvents(eventLog);
- THROW_ERROR("Unexpected error during batch insertion of routes");
- }
- }
-}
-
-void RouteManager::deleteRoutes(const std::vector<Route> &routes)
-{
- AutoLockType lock(m_routesLock);
-
- std::vector<EventEntry> eventLog;
-
- for (const auto &route : routes)
- {
- try
- {
- const auto record = findRouteRecordFromSpec(route);
-
- if (m_routes.end() == record)
- {
- const auto err = std::wstring(L"Request to delete unknown route: ")
- .append(FormatNetwork(route.network()));
-
- m_logSink->warning(common::string::ToAnsi(err).c_str());
-
- continue;
- }
-
- deleteFromRoutingTable(record->registeredRoute);
-
- eventLog.emplace_back(EventEntry{ EventType::DELETE_ROUTE, *record });
- m_routes.erase(record);
- }
- catch (...)
- {
- undoEvents(eventLog);
-
- THROW_ERROR("Failed during batch removal of routes");
- }
- }
-}
-
-void RouteManager::deleteAppliedRoutes()
-{
- //
- // Delete all routes owned by us.
- //
-
- for (const auto &record : m_routes)
- {
- try
- {
- deleteFromRoutingTable(record.registeredRoute);
- }
- catch (const std::exception & ex)
- {
- std::wstringstream ss;
-
- ss << L"Failed to delete route while clearing applied routes, Route: "
- << FormatRegisteredRoute(record.registeredRoute);
-
- m_logSink->error(common::string::ToAnsi(ss.str()).c_str());
- m_logSink->error(ex.what());
- }
- }
-
- m_routes.clear();
-}
-
-RouteManager::CallbackHandle RouteManager::registerDefaultRouteChangedCallback(DefaultRouteChangedCallback callback)
-{
- AutoRecursiveLockType lock(m_defaultRouteCallbacksLock);
-
- m_defaultRouteCallbacks.emplace_back(callback);
-
- // Return raw address of record in list.
- return &m_defaultRouteCallbacks.back();
-}
-
-void RouteManager::unregisterDefaultRouteChangedCallback(CallbackHandle handle)
-{
- AutoRecursiveLockType lock(m_defaultRouteCallbacksLock);
-
- for (auto it = m_defaultRouteCallbacks.begin(); it != m_defaultRouteCallbacks.end(); ++it)
- {
- // Match on raw address of record.
- if (&*it == handle)
- {
- m_defaultRouteCallbacks.erase(it);
- return;
- }
- }
-}
-
-std::list<RouteManager::RouteRecord>::iterator RouteManager::findRouteRecord(const RegisteredRoute &route)
-{
- return std::find_if(m_routes.begin(), m_routes.end(), [&route](const auto &record)
- {
- return route == record.registeredRoute;
- });
-}
-
-std::list<RouteManager::RouteRecord>::iterator RouteManager::findRouteRecordFromSpec(const Route &route)
-{
- return std::find_if(m_routes.begin(), m_routes.end(), [&route](const auto &record)
- {
- return route == record.route;
- });
-}
-
-RouteManager::RegisteredRoute RouteManager::addIntoRoutingTable(const Route &route)
-{
- const auto node = ResolveNode(route.network().Prefix.si_family, route.node());
-
- MIB_IPFORWARD_ROW2 spec;
-
- InitializeIpForwardEntry(&spec);
-
- spec.InterfaceLuid = node.iface;
- spec.DestinationPrefix = route.network();
- spec.NextHop = node.gateway;
- spec.Metric = 0;
- spec.Protocol = MIB_IPPROTO_NETMGMT;
- spec.Origin = NlroManual;
-
- auto status = CreateIpForwardEntry2(&spec);
-
- //
- // The return code ERROR_OBJECT_ALREADY_EXISTS means there is already an existing route
- // on the same interface, with the same DestinationPrefix and NextHop.
- //
- // However, all the other properties of the route may be different. And the properties may
- // not have the exact same values as when the route was registered, because windows
- // will adjust route properties at time of route insertion as well as later.
- //
- // The simplest thing in this case is to just overwrite the route.
- //
-
- if (status == ERROR_OBJECT_ALREADY_EXISTS)
- {
- status = SetIpForwardEntry2(&spec);
- }
-
- if (NO_ERROR != status)
- {
- THROW_WINDOWS_ERROR(status, "Register route in routing table");
- }
-
- return RegisteredRoute { route.network(), node.iface, node.gateway };
-}
-
-void RouteManager::restoreIntoRoutingTable(const RegisteredRoute &route)
-{
- MIB_IPFORWARD_ROW2 spec;
-
- InitializeIpForwardEntry(&spec);
-
- spec.InterfaceLuid = route.luid;
- spec.DestinationPrefix = route.network;
- spec.NextHop = route.nextHop;
- spec.Metric = 0;
- spec.Protocol = MIB_IPPROTO_NETMGMT;
- spec.Origin = NlroManual;
-
- const auto status = CreateIpForwardEntry2(&spec);
-
- if (NO_ERROR != status)
- {
- THROW_WINDOWS_ERROR(status, "Register route in routing table");
- }
-}
-
-void RouteManager::deleteFromRoutingTable(const RegisteredRoute &route)
-{
- MIB_IPFORWARD_ROW2 r = { 0};
-
- r.InterfaceLuid = route.luid;
- r.DestinationPrefix = route.network;
- r.NextHop = route.nextHop;
-
- auto status = DeleteIpForwardEntry2(&r);
-
- if (ERROR_NOT_FOUND == status)
- {
- status = NO_ERROR;
-
- const auto err = std::wstring(L"Attempting to delete route which was not present in routing table, " \
- "ignoring and proceeding. Route: ").append(FormatRegisteredRoute(route));
-
- m_logSink->warning(common::string::ToAnsi(err).c_str());
- }
-
- if (NO_ERROR != status)
- {
- THROW_WINDOWS_ERROR(status, "Delete route in routing table");
- }
-}
-
-void RouteManager::undoEvents(const std::vector<EventEntry> &eventLog)
-{
- //
- // Rewind state by processing events in the reverse order.
- //
-
- for (auto it = eventLog.rbegin(); it != eventLog.rend(); ++it)
- {
- try
- {
- switch (it->type)
- {
- case EventType::ADD_ROUTE:
- {
- const auto record = findRouteRecord(it->record.registeredRoute);
-
- if (m_routes.end() == record)
- {
- THROW_ERROR("Internal state inconsistency in route manager");
- }
-
- deleteFromRoutingTable(record->registeredRoute);
- m_routes.erase(record);
-
- break;
- }
- case EventType::DELETE_ROUTE:
- {
- restoreIntoRoutingTable(it->record.registeredRoute);
- m_routes.emplace_back(it->record);
-
- break;
- }
- default:
- {
- THROW_ERROR("Missing case handler in switch clause");
- }
- }
- }
- catch (const std::exception &ex)
- {
- const auto err = std::string("Attempting to rollback state: ").append(ex.what());
- m_logSink->error(err.c_str());
- }
- }
-}
-
-// static
-std::wstring RouteManager::FormatRegisteredRoute(const RegisteredRoute &route)
-{
- using namespace common::string;
-
- std::wstringstream ss;
-
- if (AF_INET == route.network.Prefix.si_family)
- {
- std::wstring gateway(L"\"On-link\"");
-
- if (0 != route.nextHop.Ipv4.sin_addr.s_addr)
- {
- gateway = FormatIpv4<AddressOrder::NetworkByteOrder>(route.nextHop.Ipv4.sin_addr.s_addr);
- }
-
- ss << FormatIpv4<AddressOrder::NetworkByteOrder>(route.network.Prefix.Ipv4.sin_addr.s_addr, route.network.PrefixLength)
- << L" with gateway " << gateway
- << L" on interface with LUID 0x" << std::hex << route.luid.Value;
- }
- else if (AF_INET6 == route.network.Prefix.si_family)
- {
- std::wstring gateway(L"\"On-link\"");
-
- const uint8_t *begin = &route.nextHop.Ipv6.sin6_addr.u.Byte[0];
- const uint8_t *end = begin + 16;
-
- if (0 != std::accumulate(begin, end, 0))
- {
- gateway = FormatIpv6(route.nextHop.Ipv6.sin6_addr.u.Byte);
- }
-
- ss << FormatIpv6(route.network.Prefix.Ipv6.sin6_addr.u.Byte, route.network.PrefixLength)
- << L" with gateway " << gateway
- << L" on interface with LUID 0x" << std::hex << route.luid.Value;
- }
- else
- {
- ss << L"Failed to format route details";
- }
-
- return ss.str();
-}
-
-void RouteManager::defaultRouteChanged(ADDRESS_FAMILY family, DefaultRouteMonitor::EventType eventType,
- const std::optional<InterfaceAndGateway> &route)
-{
- //
- // Forward event to all registered listeners.
- //
-
- m_defaultRouteCallbacksLock.lock();
-
- for (const auto &callback : m_defaultRouteCallbacks)
- {
- try
- {
- callback(eventType, family, route);
- }
- catch (const std::exception &ex)
- {
- const auto msg = std::string("Failure in default-route-changed callback: ").append(ex.what());
- m_logSink->error(msg.c_str());
- }
- catch (...)
- {
- m_logSink->error("Unspecified failure in default-route-changed callback");
- }
- }
-
- m_defaultRouteCallbacksLock.unlock();
-
- //
- // Examine event to determine if best default route has changed.
- //
-
- if (DefaultRouteMonitor::EventType::Updated != eventType)
- {
- return;
- }
-
- //
- // Examine our routes to see if any of them are policy bound to the best default route.
- //
-
- AutoLockType routesLock(m_routesLock);
-
- using RecordIterator = std::list<RouteRecord>::iterator;
-
- std::list<RecordIterator> affectedRoutes;
-
- for (RecordIterator it = m_routes.begin(); it != m_routes.end(); ++it)
- {
- if (false == it->route.node().has_value()
- && family == it->route.network().Prefix.si_family)
- {
- affectedRoutes.emplace_back(it);
- }
- }
-
- if (affectedRoutes.empty())
- {
- return;
- }
-
- //
- // Update all affected routes.
- //
-
- m_logSink->info("Best default route has changed. Refreshing dependent routes");
-
- for (auto &it : affectedRoutes)
- {
- //
- // We can't update the existing route because defining characteristics are being changed.
- // So removing and adding again is the only option.
- //
-
- try
- {
- deleteFromRoutingTable(it->registeredRoute);
- }
- catch (const std::exception &ex)
- {
- const auto msg = std::string("Failed to delete route when refreshing " \
- "existing routes: ").append(ex.what());
-
- m_logSink->error(msg.c_str());
-
- continue;
- }
-
- it->registeredRoute.luid = route.value().iface;
- it->registeredRoute.nextHop = route.value().gateway;
-
- try
- {
- restoreIntoRoutingTable(it->registeredRoute);
- }
- catch (const std::exception &ex)
- {
- const auto msg = std::string("Failed to add route when refreshing " \
- "existing routes: ").append(ex.what());
-
- m_logSink->error(msg.c_str());
-
- continue;
- }
- }
-}
-
-}
diff --git a/windows/winnet/src/winnet/routing/routemanager.h b/windows/winnet/src/winnet/routing/routemanager.h
deleted file mode 100644
index 42949a657b..0000000000
--- a/windows/winnet/src/winnet/routing/routemanager.h
+++ /dev/null
@@ -1,176 +0,0 @@
-#pragma once
-
-#include <string>
-#include <memory>
-#include <vector>
-#include <list>
-#include <optional>
-#include <mutex>
-#include <functional>
-#include <windows.h>
-#include <ws2def.h>
-#include <ifdef.h>
-#include <libcommon/string.h>
-#include <libcommon/logging/ilogsink.h>
-#include "defaultroutemonitor.h"
-#include "helpers.h"
-
-namespace winnet::routing
-{
-
-namespace error
-{
-
-class RouteManagerError : public std::runtime_error
-{
-public:
-
- RouteManagerError(const char* message)
- : std::runtime_error(message)
- {
- }
-};
-
-class NoDefaultRoute : public RouteManagerError
-{
-public:
-
- NoDefaultRoute(const char* message)
- : RouteManagerError(message)
- {
- }
-};
-
-class DeviceNameNotFound : public RouteManagerError
-{
-public:
-
- DeviceNameNotFound(const char* message)
- : RouteManagerError(message)
- {
- }
-};
-
-class DeviceGatewayNotFound : public RouteManagerError
-{
-public:
-
- DeviceGatewayNotFound(const char* message)
- : RouteManagerError(message)
- {
- }
-};
-
-}
-
-class RouteManager
-{
-public:
-
- RouteManager(std::shared_ptr<common::logging::ILogSink> logSink);
- ~RouteManager();
-
- RouteManager(const RouteManager &) = delete;
- RouteManager(RouteManager &&) = default;
- RouteManager &operator=(const RouteManager &) = delete;
- RouteManager &operator=(RouteManager &&) = delete;
-
- void addRoutes(const std::vector<Route> &routes);
- void deleteRoutes(const std::vector<Route> &routes);
- void deleteAppliedRoutes();
-
- using DefaultRouteChangedEventType = DefaultRouteMonitor::EventType;
-
- using DefaultRouteChangedCallback = std::function<void
- (
- DefaultRouteChangedEventType eventType,
- ADDRESS_FAMILY family,
-
- // For update events, data associated with the new best default route.
- const std::optional<InterfaceAndGateway> &route
- )>;
-
- using CallbackHandle = void*;
-
- CallbackHandle registerDefaultRouteChangedCallback(DefaultRouteChangedCallback callback);
- void unregisterDefaultRouteChangedCallback(CallbackHandle handle);
-
-private:
-
- std::shared_ptr<common::logging::ILogSink> m_logSink;
-
- std::unique_ptr<DefaultRouteMonitor> m_routeMonitorV4;
- std::unique_ptr<DefaultRouteMonitor> m_routeMonitorV6;
-
- // These are the exact details derived from the route specification (`Route`).
- // They are used when registering and deleting a route in the system.
- struct RegisteredRoute
- {
- Network network;
- NET_LUID luid;
- NodeAddress nextHop;
-
- bool operator==(const RegisteredRoute &rhs) const
- {
- return luid.Value == rhs.luid.Value
- && EqualAddress(nextHop, rhs.nextHop)
- && EqualAddress(network, rhs.network);
- }
- };
-
- struct RouteRecord
- {
- Route route;
- RegisteredRoute registeredRoute;
- };
-
- std::list<RouteRecord> m_routes;
- std::mutex m_routesLock;
-
- std::list<DefaultRouteChangedCallback> m_defaultRouteCallbacks;
- std::recursive_mutex m_defaultRouteCallbacksLock;
-
- //
- // Find record based on route registration data.
- //
- // Note: Searching the records and matching on route specification is
- // unreliable because of the node attribute on the route. Different node
- // specifications can resolve to the same physical node.
- //
- // (node = exit node = interface)
- //
- std::list<RouteRecord>::iterator findRouteRecord(const RegisteredRoute &route);
-
- //
- // Find record based on route specification.
- //
- // Note: Only ever use this to find the registration data for a route
- // that was successfully registered previously.
- //
- std::list<RouteRecord>::iterator findRouteRecordFromSpec(const Route &route);
-
- RegisteredRoute addIntoRoutingTable(const Route &route);
- void restoreIntoRoutingTable(const RegisteredRoute &route);
- void deleteFromRoutingTable(const RegisteredRoute &route);
-
- enum class EventType
- {
- ADD_ROUTE,
- DELETE_ROUTE,
- };
-
- struct EventEntry
- {
- EventType type;
- RouteRecord record;
- };
-
- void undoEvents(const std::vector<EventEntry> &eventLog);
-
- static std::wstring FormatRegisteredRoute(const RegisteredRoute &route);
-
- void defaultRouteChanged(ADDRESS_FAMILY family, DefaultRouteMonitor::EventType eventType,
- const std::optional<InterfaceAndGateway> &route);
-};
-
-}
diff --git a/windows/winnet/src/winnet/routing/types.cpp b/windows/winnet/src/winnet/routing/types.cpp
deleted file mode 100644
index 9a7c755feb..0000000000
--- a/windows/winnet/src/winnet/routing/types.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-#include "stdafx.h"
-#include "types.h"
-#include "helpers.h"
-#include <libcommon/string.h>
-#include <libcommon/error.h>
-
-namespace winnet::routing
-{
-
-Node::Node(const std::optional<std::wstring> &deviceName, const std::optional<NodeAddress> &gateway)
- : m_deviceName(deviceName)
- , m_gateway(gateway)
-{
- if (false == m_deviceName.has_value() && false == m_gateway.has_value())
- {
- THROW_ERROR("Invalid node definition");
- }
-
- if (m_deviceName.has_value())
- {
- auto trimmed = common::string::Trim<>(m_deviceName.value());
-
- if (trimmed.empty())
- {
- THROW_ERROR("Invalid device name in node definition");
- }
-
- m_deviceName = std::move(trimmed);
- }
-}
-
-bool Node::operator==(const Node &rhs) const
-{
- if (m_deviceName.has_value())
- {
- if (false == rhs.m_deviceName.has_value()
- || 0 != _wcsicmp(m_deviceName.value().c_str(), rhs.deviceName().value().c_str()))
- {
- return false;
- }
- }
- else if (rhs.m_deviceName.has_value())
- {
- return false;
- }
-
- if (m_gateway.has_value())
- {
- if (false == rhs.m_gateway.has_value()
- || false == EqualAddress(m_gateway.value(), rhs.gateway().value()))
- {
- return false;
- }
- }
- else if (rhs.m_gateway.has_value())
- {
- return false;
- }
-
- return true;
-}
-
-Route::Route(const Network &network, const std::optional<Node> &node)
- : m_network(network)
- , m_node(node)
-{
-}
-
-bool Route::operator==(const Route &rhs) const
-{
- if (m_node.has_value())
- {
- return rhs.node().has_value()
- && EqualAddress(m_network, rhs.network())
- && m_node.value() == rhs.node().value();
- }
-
- return false == rhs.node().has_value()
- && EqualAddress(m_network, rhs.network());
-}
-
-bool InterfaceAndGateway::operator==(const InterfaceAndGateway &rhs)
-{
- return iface.Value == rhs.iface.Value
- && EqualAddress(gateway, rhs.gateway);
-}
-
-bool InterfaceAndGateway::operator!=(const InterfaceAndGateway &rhs)
-{
- return !(*this == rhs);
-}
-
-}
diff --git a/windows/winnet/src/winnet/routing/types.h b/windows/winnet/src/winnet/routing/types.h
deleted file mode 100644
index 4b70a5739d..0000000000
--- a/windows/winnet/src/winnet/routing/types.h
+++ /dev/null
@@ -1,74 +0,0 @@
-#pragma once
-
-#include <string>
-#include <optional>
-#include <winsock2.h>
-#include <windows.h>
-#include <ws2def.h>
-#include <ws2ipdef.h>
-#include <iphlpapi.h>
-
-namespace winnet::routing
-{
-
-using Network = IP_ADDRESS_PREFIX;
-using NodeAddress = SOCKADDR_INET;
-
-class Node
-{
-public:
-
- Node(const std::optional<std::wstring> &deviceName, const std::optional<NodeAddress> &gateway);
-
- const std::optional<std::wstring> &deviceName() const
- {
- return m_deviceName;
- }
-
- const std::optional<NodeAddress> &gateway() const
- {
- return m_gateway;
- }
-
- bool operator==(const Node &rhs) const;
-
-private:
-
- std::optional<std::wstring> m_deviceName;
- std::optional<NodeAddress> m_gateway;
-};
-
-class Route
-{
-public:
-
- Route(const Network &network, const std::optional<Node> &node);
-
- const Network &network() const
- {
- return m_network;
- }
-
- const std::optional<Node> &node() const
- {
- return m_node;
- }
-
- bool operator==(const Route &rhs) const;
-
-private:
-
- Network m_network;
- std::optional<Node> m_node;
-};
-
-struct InterfaceAndGateway
-{
- NET_LUID iface;
- NodeAddress gateway;
-
- bool operator==(const InterfaceAndGateway &rhs);
- bool operator!=(const InterfaceAndGateway &rhs);
-};
-
-}
diff --git a/windows/winnet/src/winnet/stdafx.cpp b/windows/winnet/src/winnet/stdafx.cpp
deleted file mode 100644
index b29c52afc9..0000000000
--- a/windows/winnet/src/winnet/stdafx.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-// stdafx.cpp : source file that includes just the standard includes
-// winroute.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
diff --git a/windows/winnet/src/winnet/stdafx.h b/windows/winnet/src/winnet/stdafx.h
deleted file mode 100644
index 3115e02cd4..0000000000
--- a/windows/winnet/src/winnet/stdafx.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#pragma once
-
-// wcscpy
-#define _CRT_SECURE_NO_WARNINGS 1
-
-#include "targetver.h"
-
-#define NOMINMAX
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-// Windows Header Files:
-#include <windows.h>
-
-
-
-// TODO: reference additional headers your program requires here
diff --git a/windows/winnet/src/winnet/targetver.h b/windows/winnet/src/winnet/targetver.h
deleted file mode 100644
index b8b7263c9e..0000000000
--- a/windows/winnet/src/winnet/targetver.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#pragma once
-
-// Including SDKDDKVer.h defines the highest available Windows platform.
-
-// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
-// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
-
-#include <WinSDKVer.h>
-
-#define _WIN32_WINNT _WIN32_WINNT_WIN7
-
-#include <SDKDDKVer.h>
diff --git a/windows/winnet/src/winnet/winnet.cpp b/windows/winnet/src/winnet/winnet.cpp
deleted file mode 100644
index 99ff24a351..0000000000
--- a/windows/winnet/src/winnet/winnet.cpp
+++ /dev/null
@@ -1,398 +0,0 @@
-#include "stdafx.h"
-#include "winnet.h"
-#include "routing/routemanager.h"
-#include "converters.h"
-#include <libshared/logging/logsinkadapter.h>
-#include <libshared/logging/unwind.h>
-#include <libcommon/error.h>
-#include <libcommon/memory.h>
-#include <libcommon/valuemapper.h>
-#include <cstdint>
-#include <memory>
-#include <optional>
-#include <mutex>
-
-using namespace winnet::routing;
-using AutoLockType = std::scoped_lock<std::mutex>;
-
-namespace
-{
-
-std::mutex g_RouteManagerLock;
-RouteManager *g_RouteManager = nullptr;
-std::shared_ptr<shared::logging::LogSinkAdapter> g_RouteManagerLogSink;
-
-} //anonymous namespace
-
-extern "C"
-WINNET_LINKAGE
-WINNET_STATUS
-WINNET_API
-WinNet_GetBestDefaultRoute(
- WINNET_ADDR_FAMILY family,
- WINNET_DEFAULT_ROUTE *route,
- MullvadLogSink logSink,
- void *logSinkContext
-)
-{
- try
- {
- if (nullptr == route)
- {
- THROW_ERROR("Invalid argument: route");
- }
-
- static const std::pair<WINNET_ADDR_FAMILY, ADDRESS_FAMILY> familyMap[] =
- {
- { WINNET_ADDR_FAMILY_IPV4, static_cast<ADDRESS_FAMILY>(AF_INET) },
- { WINNET_ADDR_FAMILY_IPV6, static_cast<ADDRESS_FAMILY>(AF_INET6) }
- };
- const auto win_family = common::ValueMapper::Map<>(family, familyMap);
-
- const auto ifaceAndGateway = GetBestDefaultRoute(win_family);
-
- if (!ifaceAndGateway.has_value())
- {
- return WINNET_STATUS_NOT_FOUND;
- }
-
- route->interfaceLuid = ifaceAndGateway->iface.Value;
- const auto ips = winnet::ConvertNativeAddresses(&ifaceAndGateway->gateway, 1);
- route->gateway = ips[0];
-
- return WINNET_STATUS_SUCCESS;
- }
- catch (const std::exception & err)
- {
- shared::logging::UnwindAndLog(logSink, logSinkContext, err);
- return WINNET_STATUS_FAILURE;
- }
- catch (...)
- {
- return WINNET_STATUS_FAILURE;
- }
-}
-
-extern "C"
-WINNET_LINKAGE
-bool
-WINNET_API
-WinNet_ActivateRouteManager(
- MullvadLogSink logSink,
- void *logSinkContext
-)
-{
- AutoLockType lock(g_RouteManagerLock);
-
- try
- {
- if (nullptr != g_RouteManager)
- {
- THROW_ERROR("Cannot activate route manager twice");
- }
-
- g_RouteManagerLogSink = std::make_shared<shared::logging::LogSinkAdapter>(logSink, logSinkContext);
- g_RouteManager = new RouteManager(g_RouteManagerLogSink);
-
- return true;
- }
- catch (const std::exception &err)
- {
- shared::logging::UnwindAndLog(logSink, logSinkContext, err);
- return false;
- }
- catch (...)
- {
- return false;
- }
-}
-
-extern "C"
-WINNET_LINKAGE
-WINNET_AR_STATUS
-WINNET_API
-WinNet_AddRoutes(
- const WINNET_ROUTE *routes,
- uint32_t numRoutes
-)
-{
- AutoLockType lock(g_RouteManagerLock);
-
- if (nullptr == g_RouteManager)
- {
- return WINNET_AR_STATUS_GENERAL_ERROR;
- }
-
- try
- {
- if (nullptr == routes)
- {
- THROW_ERROR("Invalid argument: routes");
- }
-
- g_RouteManager->addRoutes(winnet::ConvertRoutes(routes, numRoutes));
- return WINNET_AR_STATUS_SUCCESS;
- }
- catch (const winnet::routing::error::NoDefaultRoute &err)
- {
- common::error::UnwindException(err, g_RouteManagerLogSink);
- return WINNET_AR_STATUS_NO_DEFAULT_ROUTE;
- }
- catch (const winnet::routing::error::DeviceNameNotFound &err)
- {
- common::error::UnwindException(err, g_RouteManagerLogSink);
- return WINNET_AR_STATUS_NAME_NOT_FOUND;
- }
- catch (const winnet::routing::error::DeviceGatewayNotFound &err)
- {
- common::error::UnwindException(err, g_RouteManagerLogSink);
- return WINNET_AR_STATUS_GATEWAY_NOT_FOUND;
- }
- catch (const std::exception &err)
- {
- common::error::UnwindException(err, g_RouteManagerLogSink);
- return WINNET_AR_STATUS_GENERAL_ERROR;
- }
- catch (...)
- {
- return WINNET_AR_STATUS_GENERAL_ERROR;
- }
-}
-
-extern "C"
-WINNET_LINKAGE
-WINNET_AR_STATUS
-WINNET_API
-WinNet_AddRoute(
- const WINNET_ROUTE *route
-)
-{
- return WinNet_AddRoutes(route, 1);
-}
-
-extern "C"
-WINNET_LINKAGE
-bool
-WINNET_API
-WinNet_DeleteRoutes(
- const WINNET_ROUTE *routes,
- uint32_t numRoutes
-)
-{
- AutoLockType lock(g_RouteManagerLock);
-
- if (nullptr == g_RouteManager)
- {
- return false;
- }
-
- try
- {
- if (nullptr == routes)
- {
- THROW_ERROR("Invalid argument: routes");
- }
-
- g_RouteManager->deleteRoutes(winnet::ConvertRoutes(routes, numRoutes));
- return true;
- }
- catch (const std::exception &err)
- {
- common::error::UnwindException(err, g_RouteManagerLogSink);
- return false;
- }
- catch (...)
- {
- return false;
- }
-}
-
-extern "C"
-WINNET_LINKAGE
-bool
-WINNET_API
-WinNet_DeleteAppliedRoutes()
-{
- AutoLockType lock(g_RouteManagerLock);
-
- if (nullptr == g_RouteManager)
- {
- return false;
- }
-
- try
- {
- g_RouteManager->deleteAppliedRoutes();
- return true;
- }
- catch (const std::exception & err)
- {
- common::error::UnwindException(err, g_RouteManagerLogSink);
- return false;
- }
- catch (...)
- {
- return false;
- }
-}
-
-extern "C"
-WINNET_LINKAGE
-bool
-WINNET_API
-WinNet_DeleteRoute(
- const WINNET_ROUTE *route
-)
-{
- return WinNet_DeleteRoutes(route, 1);
-}
-
-extern "C"
-WINNET_LINKAGE
-bool
-WINNET_API
-WinNet_RegisterDefaultRouteChangedCallback(
- WinNetDefaultRouteChangedCallback callback,
- void *context,
- void **registrationHandle
-)
-{
- AutoLockType lock(g_RouteManagerLock);
-
- if (nullptr == g_RouteManager)
- {
- return false;
- }
-
- try
- {
- if (nullptr == callback)
- {
- THROW_ERROR("Invalid argument: callback");
- }
-
- if (nullptr == registrationHandle)
- {
- THROW_ERROR("Invalid argument: registrationHandle");
- }
-
- auto forwarder = [callback, context](RouteManager::DefaultRouteChangedEventType eventType,
- ADDRESS_FAMILY family, const std::optional<InterfaceAndGateway> &route)
- {
- //
- // Translate the event type.
- //
-
- using from_t = RouteManager::DefaultRouteChangedEventType;
- using to_t = WINNET_DEFAULT_ROUTE_CHANGED_EVENT_TYPE;
-
- static const std::pair<from_t, to_t> eventTypeMap[] =
- {
- { from_t::Updated, WINNET_DEFAULT_ROUTE_CHANGED_EVENT_TYPE_UPDATED },
- { from_t::UpdatedDetails, WINNET_DEFAULT_ROUTE_CHANGED_EVENT_TYPE_UPDATED_DETAILS },
- { from_t::Removed, WINNET_DEFAULT_ROUTE_CHANGED_EVENT_TYPE_REMOVED }
- };
-
- const auto translatedEventType = common::ValueMapper::Map<>(eventType, eventTypeMap);
-
- //
- // Translate the family type.
- //
-
- static const std::pair<ADDRESS_FAMILY, WINNET_ADDR_FAMILY> familyMap[] =
- {
- { static_cast<ADDRESS_FAMILY>(AF_INET), WINNET_ADDR_FAMILY_IPV4 },
- { static_cast<ADDRESS_FAMILY>(AF_INET6), WINNET_ADDR_FAMILY_IPV6 }
- };
-
- const auto translatedFamily = common::ValueMapper::Map<>(family, familyMap);
-
- WINNET_DEFAULT_ROUTE defaultRoute = { 0 };
-
- //
- // Determine which LUID and gateway to forward.
- //
-
- switch (eventType)
- {
- case RouteManager::DefaultRouteChangedEventType::Updated:
- case RouteManager::DefaultRouteChangedEventType::UpdatedDetails:
- {
- const auto ips = winnet::ConvertNativeAddresses(&route.value().gateway, 1);
- defaultRoute.gateway = ips[0];
- defaultRoute.interfaceLuid = route.value().iface.Value;
- break;
- }
- }
-
- //
- // Forward to client.
- //
-
- callback(translatedEventType, translatedFamily, defaultRoute, context);
- };
-
- *registrationHandle = g_RouteManager->registerDefaultRouteChangedCallback(forwarder);
-
- return true;
- }
- catch (const std::exception &err)
- {
- common::error::UnwindException(err, g_RouteManagerLogSink);
- return false;
- }
- catch (...)
- {
- return false;
- }
-}
-
-extern "C"
-WINNET_LINKAGE
-void
-WINNET_API
-WinNet_UnregisterDefaultRouteChangedCallback(
- void *registrationHandle
-)
-{
- AutoLockType lock(g_RouteManagerLock);
-
- if (nullptr == g_RouteManager)
- {
- return;
- }
-
- try
- {
- g_RouteManager->unregisterDefaultRouteChangedCallback(registrationHandle);
- }
- catch (const std::exception &err)
- {
- g_RouteManagerLogSink->error("Failed to unregister default-route-changed callback");
- common::error::UnwindException(err, g_RouteManagerLogSink);
- }
- catch (...)
- {
- }
-}
-
-extern "C"
-WINNET_LINKAGE
-void
-WINNET_API
-WinNet_DeactivateRouteManager(
-)
-{
- AutoLockType lock(g_RouteManagerLock);
-
- try
- {
- delete g_RouteManager;
- g_RouteManager = nullptr;
-
- g_RouteManagerLogSink.reset();
- }
- catch (...)
- {
- }
-}
diff --git a/windows/winnet/src/winnet/winnet.def b/windows/winnet/src/winnet/winnet.def
deleted file mode 100644
index 0bc759d8bc..0000000000
--- a/windows/winnet/src/winnet/winnet.def
+++ /dev/null
@@ -1,5 +0,0 @@
-LIBRARY winnet
-EXPORTS
- WinNet_ActivateRouteManager
- WinNet_DeactivateRouteManager
- WinNet_GetBestDefaultRoute
diff --git a/windows/winnet/src/winnet/winnet.h b/windows/winnet/src/winnet/winnet.h
deleted file mode 100644
index 38d1386a58..0000000000
--- a/windows/winnet/src/winnet/winnet.h
+++ /dev/null
@@ -1,186 +0,0 @@
-#pragma once
-
-#include <libshared/logging/logsink.h>
-#include <stdint.h>
-#include <stdbool.h>
-
-#ifndef WINNET_STATIC
-#ifdef WINNET_EXPORTS
-#define WINNET_LINKAGE __declspec(dllexport)
-#else
-#define WINNET_LINKAGE __declspec(dllimport)
-#endif
-#else
-#define WINNET_LINKAGE
-#endif
-
-#define WINNET_API __stdcall
-
-enum WINNET_ADDR_FAMILY
-{
- WINNET_ADDR_FAMILY_IPV4 = 0,
- WINNET_ADDR_FAMILY_IPV6 = 1,
-};
-
-typedef struct tag_WINNET_IP
-{
- WINNET_ADDR_FAMILY family;
- uint8_t bytes[16]; // Network byte order.
-}
-WINNET_IP;
-
-typedef struct tag_WINNET_IP_NETWORK
-{
- uint8_t prefix;
- WINNET_IP addr;
-}
-WINNET_IP_NETWORK;
-
-typedef struct tag_WINNET_NODE
-{
- const WINNET_IP *gateway;
- const wchar_t *deviceName;
-}
-WINNET_NODE;
-
-typedef struct tag_WINNET_ROUTE
-{
- WINNET_IP_NETWORK network;
- const WINNET_NODE *node;
-}
-WINNET_ROUTE;
-
-extern "C"
-WINNET_LINKAGE
-bool
-WINNET_API
-WinNet_ActivateRouteManager(
- MullvadLogSink logSink,
- void *logSinkContext
-);
-
-enum WINNET_AR_STATUS
-{
- WINNET_AR_STATUS_SUCCESS = 0,
- WINNET_AR_STATUS_GENERAL_ERROR = 1,
- WINNET_AR_STATUS_NO_DEFAULT_ROUTE = 2,
- WINNET_AR_STATUS_NAME_NOT_FOUND = 3,
- WINNET_AR_STATUS_GATEWAY_NOT_FOUND = 4,
-};
-
-extern "C"
-WINNET_LINKAGE
-WINNET_AR_STATUS
-WINNET_API
-WinNet_AddRoutes(
- const WINNET_ROUTE *routes,
- uint32_t numRoutes
-);
-
-extern "C"
-WINNET_LINKAGE
-WINNET_AR_STATUS
-WINNET_API
-WinNet_AddRoute(
- const WINNET_ROUTE *route
-);
-
-extern "C"
-WINNET_LINKAGE
-bool
-WINNET_API
-WinNet_DeleteRoutes(
- const WINNET_ROUTE *routes,
- uint32_t numRoutes
-);
-
-extern "C"
-WINNET_LINKAGE
-bool
-WINNET_API
-WinNet_DeleteRoute(
- const WINNET_ROUTE *route
-);
-
-extern "C"
-WINNET_LINKAGE
-bool
-WINNET_API
-WinNet_DeleteAppliedRoutes(
-);
-
-typedef struct tag_WINNET_DEFAULT_ROUTE
-{
- uint64_t interfaceLuid;
- WINNET_IP gateway;
-}
-WINNET_DEFAULT_ROUTE;
-
-enum WINNET_STATUS
-{
- WINNET_STATUS_SUCCESS = 0,
- WINNET_STATUS_NOT_FOUND = 1,
- WINNET_STATUS_FAILURE = 2,
-};
-
-extern "C"
-WINNET_LINKAGE
-WINNET_STATUS
-WINNET_API
-WinNet_GetBestDefaultRoute(
- WINNET_ADDR_FAMILY family,
- WINNET_DEFAULT_ROUTE *route,
- MullvadLogSink logSink,
- void *logSinkContext
-);
-
-enum WINNET_DEFAULT_ROUTE_CHANGED_EVENT_TYPE
-{
- // Best default route changed.
- WINNET_DEFAULT_ROUTE_CHANGED_EVENT_TYPE_UPDATED = 0,
-
- // The route (gateway or interface) did not change, but
- // interface details may have changed.
- WINNET_DEFAULT_ROUTE_CHANGED_EVENT_TYPE_UPDATED_DETAILS = 1,
-
- // No default routes exist.
- WINNET_DEFAULT_ROUTE_CHANGED_EVENT_TYPE_REMOVED = 2,
-};
-
-typedef void (WINNET_API *WinNetDefaultRouteChangedCallback)
-(
- WINNET_DEFAULT_ROUTE_CHANGED_EVENT_TYPE eventType,
-
- // Indicates which IP family the event relates to.
- WINNET_ADDR_FAMILY family,
-
- // For update events, indicates the interface associated with the new best default route.
- WINNET_DEFAULT_ROUTE route,
-
- void *context
-);
-
-extern "C"
-WINNET_LINKAGE
-bool
-WINNET_API
-WinNet_RegisterDefaultRouteChangedCallback(
- WinNetDefaultRouteChangedCallback callback,
- void *context,
- void **registrationHandle
-);
-
-extern "C"
-WINNET_LINKAGE
-void
-WINNET_API
-WinNet_UnregisterDefaultRouteChangedCallback(
- void *registrationHandle
-);
-
-extern "C"
-WINNET_LINKAGE
-void
-WINNET_API
-WinNet_DeactivateRouteManager(
-);
diff --git a/windows/winnet/src/winnet/winnet.rc b/windows/winnet/src/winnet/winnet.rc
deleted file mode 100644
index 0509b4a59e..0000000000
--- a/windows/winnet/src/winnet/winnet.rc
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "../../../version.h"
-
-1 VERSIONINFO
-FILEVERSION MAJOR_VERSION,MINOR_VERSION,PATCH_VERSION,0
-PRODUCTVERSION MAJOR_VERSION,MINOR_VERSION,PATCH_VERSION,0
-BEGIN
-BLOCK "StringFileInfo"
-BEGIN
- BLOCK "040904E4"
- BEGIN
- VALUE "CompanyName", "Mullvad VPN AB"
- VALUE "FileDescription", "Mullvad VPN networking module"
- VALUE "FileVersion", PRODUCT_VERSION
- VALUE "InternalName", "winnet"
- VALUE "LegalCopyright", "(c) 2022 Mullvad VPN AB"
- VALUE "OriginalFilename", "winnet.dll"
- VALUE "ProductName", "Mullvad VPN"
- VALUE "ProductVersion", PRODUCT_VERSION
- END
-END
-BLOCK "VarFileInfo"
-BEGIN
- VALUE "Translation", 0x409, 1252
-END
-END
diff --git a/windows/winnet/src/winnet/winnet.vcxproj b/windows/winnet/src/winnet/winnet.vcxproj
deleted file mode 100644
index e38fd0e4b1..0000000000
--- a/windows/winnet/src/winnet/winnet.vcxproj
+++ /dev/null
@@ -1,314 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Static|Win32">
- <Configuration>Debug Static</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Static|x64">
- <Configuration>Debug Static</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="converters.cpp" />
- <ClCompile Include="dllmain.cpp" />
- <ClCompile Include="routing\defaultroutemonitor.cpp" />
- <ClCompile Include="routing\helpers.cpp" />
- <ClCompile Include="routing\routemanager.cpp" />
- <ClCompile Include="routing\types.cpp" />
- <ClCompile Include="stdafx.cpp" />
- <ClCompile Include="winnet.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="converters.h" />
- <ClInclude Include="routing\defaultroutemonitor.h" />
- <ClInclude Include="routing\helpers.h" />
- <ClInclude Include="routing\routemanager.h" />
- <ClInclude Include="routing\types.h" />
- <ClInclude Include="stdafx.h" />
- <ClInclude Include="targetver.h" />
- <ClInclude Include="winnet.h" />
- </ItemGroup>
- <ItemGroup>
- <None Include="winnet.def" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="winnet.rc" />
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <VCProjectVersion>16.0</VCProjectVersion>
- <ProjectGuid>{89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>winnet</RootNamespace>
- <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v143</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="Shared">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>$(SolutionDir)\bin\$(Platform)-$(Configuration)\</OutDir>
- <IntDir>$(SolutionDir)\bin\temp\$(Platform)-$(Configuration)\$(ProjectName)\</IntDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|Win32'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>$(SolutionDir)\bin\$(Platform)-Debug\</OutDir>
- <IntDir>$(SolutionDir)\bin\temp\$(Platform)-Debug\$(ProjectName)\</IntDir>
- <TargetName>$(ProjectName)-static</TargetName>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>$(SolutionDir)\bin\$(Platform)-$(Configuration)\</OutDir>
- <IntDir>$(SolutionDir)\bin\temp\$(Platform)-$(Configuration)\$(ProjectName)\</IntDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|x64'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>$(SolutionDir)\bin\$(Platform)-Debug\</OutDir>
- <IntDir>$(SolutionDir)\bin\temp\$(Platform)-Debug\$(ProjectName)\</IntDir>
- <TargetName>$(ProjectName)-static</TargetName>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>$(SolutionDir)\bin\$(Platform)-$(Configuration)\</OutDir>
- <IntDir>$(SolutionDir)\bin\temp\$(Platform)-$(Configuration)\$(ProjectName)\</IntDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>$(SolutionDir)\bin\$(Platform)-$(Configuration)\</OutDir>
- <IntDir>$(SolutionDir)\bin\temp\$(Platform)-$(Configuration)\$(ProjectName)\</IntDir>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <PrecompiledHeader>Create</PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WIN32;_DEBUG;WINNET_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <LanguageStandard>stdcpplatest</LanguageStandard>
- <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\libshared\src\;$(ProjectDir)..\..\..\windows-libraries\src\;$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <ModuleDefinitionFile>winnet.def</ModuleDefinitionFile>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-$(Configuration)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libshared.lib;libcommon.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <PreBuildEvent>
- <Command>cargo run -q --bin mullvad-version version.h &gt; $(ProjectDir)..\..\..\version.h</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|Win32'">
- <ClCompile>
- <PrecompiledHeader>Create</PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WINNET_STATIC;WIN32;_DEBUG;WINNET_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <LanguageStandard>stdcpplatest</LanguageStandard>
- <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\libshared\src\;$(ProjectDir)..\..\..\windows-libraries\src\;$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <ModuleDefinitionFile>winnet.def</ModuleDefinitionFile>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-$(Configuration)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libcommon.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <Lib>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-Debug</AdditionalLibraryDirectories>
- <AdditionalDependencies>libshared.lib;libcommon.lib;Iphlpapi.lib</AdditionalDependencies>
- </Lib>
- <PreBuildEvent>
- <Command>cargo run -q --bin mullvad-version version.h &gt; $(ProjectDir)..\..\..\version.h</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <PrecompiledHeader>Create</PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>_DEBUG;WINNET_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <LanguageStandard>stdcpplatest</LanguageStandard>
- <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\libshared\src\;$(ProjectDir)..\..\..\windows-libraries\src\;$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>libshared.lib;libcommon.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-$(Configuration)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>winnet.def</ModuleDefinitionFile>
- </Link>
- <PreBuildEvent>
- <Command>cargo run -q --bin mullvad-version version.h &gt; $(ProjectDir)..\..\..\version.h</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|x64'">
- <ClCompile>
- <PrecompiledHeader>Create</PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WINNET_STATIC;_DEBUG;WINNET_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <LanguageStandard>stdcpplatest</LanguageStandard>
- <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\libshared\src\;$(ProjectDir)..\..\..\windows-libraries\src\;$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>libcommon.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-$(Configuration)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>winnet.def</ModuleDefinitionFile>
- </Link>
- <Lib>
- <AdditionalDependencies>libshared.lib;libcommon.lib;Iphlpapi.lib</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-Debug</AdditionalLibraryDirectories>
- </Lib>
- <PreBuildEvent>
- <Command>cargo run -q --bin mullvad-version version.h &gt; $(ProjectDir)..\..\..\version.h</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <PrecompiledHeader>Create</PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>WIN32;NDEBUG;WINNET_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <LanguageStandard>stdcpplatest</LanguageStandard>
- <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\libshared\src\;$(ProjectDir)..\..\..\windows-libraries\src\;$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <ModuleDefinitionFile>winnet.def</ModuleDefinitionFile>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-$(Configuration)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libshared.lib;libcommon.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <PreBuildEvent>
- <Command>cargo run -q --bin mullvad-version version.h &gt; $(ProjectDir)..\..\..\version.h</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <PrecompiledHeader>Create</PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>true</SDLCheck>
- <PreprocessorDefinitions>NDEBUG;WINNET_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ConformanceMode>true</ConformanceMode>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <LanguageStandard>stdcpplatest</LanguageStandard>
- <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\libshared\src\;$(ProjectDir)..\..\..\windows-libraries\src\;$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <ModuleDefinitionFile>winnet.def</ModuleDefinitionFile>
- <AdditionalLibraryDirectories>$(SolutionDir)/bin/$(Platform)-$(Configuration)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libshared.lib;libcommon.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <PreBuildEvent>
- <Command>cargo run -q --bin mullvad-version version.h &gt; $(ProjectDir)..\..\..\version.h</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/windows/winnet/src/winnet/winnet.vcxproj.filters b/windows/winnet/src/winnet/winnet.vcxproj.filters
deleted file mode 100644
index b9a9053165..0000000000
--- a/windows/winnet/src/winnet/winnet.vcxproj.filters
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <ClCompile Include="dllmain.cpp" />
- <ClCompile Include="stdafx.cpp" />
- <ClCompile Include="winnet.cpp" />
- <ClCompile Include="routing\types.cpp">
- <Filter>routing</Filter>
- </ClCompile>
- <ClCompile Include="routing\helpers.cpp">
- <Filter>routing</Filter>
- </ClCompile>
- <ClCompile Include="routing\defaultroutemonitor.cpp">
- <Filter>routing</Filter>
- </ClCompile>
- <ClCompile Include="routing\routemanager.cpp">
- <Filter>routing</Filter>
- </ClCompile>
- <ClCompile Include="converters.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="stdafx.h" />
- <ClInclude Include="targetver.h" />
- <ClInclude Include="winnet.h" />
- <ClInclude Include="routing\types.h">
- <Filter>routing</Filter>
- </ClInclude>
- <ClInclude Include="routing\helpers.h">
- <Filter>routing</Filter>
- </ClInclude>
- <ClInclude Include="routing\defaultroutemonitor.h">
- <Filter>routing</Filter>
- </ClInclude>
- <ClInclude Include="routing\routemanager.h">
- <Filter>routing</Filter>
- </ClInclude>
- <ClInclude Include="converters.h" />
- </ItemGroup>
- <ItemGroup>
- <None Include="winnet.def" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="winnet.rc" />
- </ItemGroup>
- <ItemGroup>
- <Filter Include="routing">
- <UniqueIdentifier>{8df22cc6-597f-4342-bc57-7647393084be}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/windows/winnet/winnet.sln b/windows/winnet/winnet.sln
deleted file mode 100644
index d77c5de04e..0000000000
--- a/windows/winnet/winnet.sln
+++ /dev/null
@@ -1,72 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.0.32014.148
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winnet", "src\winnet\winnet.vcxproj", "{89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}"
- ProjectSection(ProjectDependencies) = postProject
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF} = {B52E2D10-A94A-4605-914A-2DCEF6A757EF}
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D} = {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcommon", "..\windows-libraries\src\libcommon\libcommon.vcxproj", "{B52E2D10-A94A-4605-914A-2DCEF6A757EF}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libshared", "..\libshared\src\libshared\libshared.vcxproj", "{EE69EA4A-CF71-4B88-866B-957F60C4CE0D}"
- ProjectSection(ProjectDependencies) = postProject
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF} = {B52E2D10-A94A-4605-914A-2DCEF6A757EF}
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug Static|x64 = Debug Static|x64
- Debug Static|x86 = Debug Static|x86
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug Static|x64.ActiveCfg = Debug Static|x64
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug Static|x64.Build.0 = Debug Static|x64
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug Static|x86.ActiveCfg = Debug Static|Win32
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug Static|x86.Build.0 = Debug Static|Win32
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug|x64.ActiveCfg = Debug|x64
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug|x64.Build.0 = Debug|x64
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug|x86.ActiveCfg = Debug|Win32
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Debug|x86.Build.0 = Debug|Win32
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Release|x64.ActiveCfg = Release|x64
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Release|x64.Build.0 = Release|x64
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Release|x86.ActiveCfg = Release|Win32
- {89C5CDE8-04DB-4D9C-A8D8-7F786DAFB6D4}.Release|x86.Build.0 = Release|Win32
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug Static|x64.ActiveCfg = Debug|x64
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug Static|x64.Build.0 = Debug|x64
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug Static|x86.ActiveCfg = Debug|Win32
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug Static|x86.Build.0 = Debug|Win32
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x64.ActiveCfg = Debug|x64
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x64.Build.0 = Debug|x64
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x86.ActiveCfg = Debug|Win32
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x86.Build.0 = Debug|Win32
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x64.ActiveCfg = Release|x64
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x64.Build.0 = Release|x64
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x86.ActiveCfg = Release|Win32
- {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x86.Build.0 = Release|Win32
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug Static|x64.ActiveCfg = Debug|x64
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug Static|x64.Build.0 = Debug|x64
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug Static|x86.ActiveCfg = Debug|Win32
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug Static|x86.Build.0 = Debug|Win32
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x64.ActiveCfg = Debug|x64
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x64.Build.0 = Debug|x64
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x86.ActiveCfg = Debug|Win32
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x86.Build.0 = Debug|Win32
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x64.ActiveCfg = Release|x64
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x64.Build.0 = Release|x64
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x86.ActiveCfg = Release|Win32
- {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x86.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {B019612F-9475-4A56-A836-B74F90CE2E78}
- EndGlobalSection
-EndGlobal