summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--talpid-core/src/firewall/windows.rs2
-rw-r--r--talpid-core/src/winnet.rs10
-rw-r--r--windows/winnet/src/winnet/InterfacePair.cpp4
-rw-r--r--windows/winnet/src/winnet/InterfacePair.h2
-rw-r--r--windows/winnet/src/winnet/NetworkInterfaces.cpp12
-rw-r--r--windows/winnet/src/winnet/NetworkInterfaces.h8
-rw-r--r--windows/winnet/src/winnet/winnet.cpp12
-rw-r--r--windows/winnet/src/winnet/winnet.def2
-rw-r--r--windows/winnet/src/winnet/winnet.h12
9 files changed, 32 insertions, 32 deletions
diff --git a/talpid-core/src/firewall/windows.rs b/talpid-core/src/firewall/windows.rs
index 38e388ecbf..89e880da7e 100644
--- a/talpid-core/src/firewall/windows.rs
+++ b/talpid-core/src/firewall/windows.rs
@@ -194,7 +194,7 @@ impl Firewall {
protocol: WinFwProt::from(endpoint.protocol),
};
- let metrics_set = winnet::ensure_top_metric_for_interface(&tunnel_metadata.interface)
+ let metrics_set = winnet::ensure_best_metric_for_interface(&tunnel_metadata.interface)
.map_err(Error::SetTapMetric)?;
if metrics_set {
diff --git a/talpid-core/src/winnet.rs b/talpid-core/src/winnet.rs
index 2eee4b205a..256695eb5c 100644
--- a/talpid-core/src/winnet.rs
+++ b/talpid-core/src/winnet.rs
@@ -35,12 +35,12 @@ fn logging_context() -> *const u8 {
}
/// Returns true if metrics were changed, false otherwise
-pub fn ensure_top_metric_for_interface(interface_alias: &str) -> Result<bool, Error> {
+pub fn ensure_best_metric_for_interface(interface_alias: &str) -> Result<bool, Error> {
let interface_alias_ws =
WideCString::from_str(interface_alias).map_err(Error::InvalidInterfaceAlias)?;
let metric_result = unsafe {
- WinNet_EnsureTopMetric(
+ WinNet_EnsureBestMetric(
interface_alias_ws.as_ptr(),
Some(log_sink),
logging_context(),
@@ -56,7 +56,7 @@ pub fn ensure_top_metric_for_interface(interface_alias: &str) -> Result<bool, Er
2 => Err(Error::MetricApplication),
// Unexpected value
i => {
- log::error!("Unexpected return code from WinNet_EnsureTopMetric: {}", i);
+ log::error!("Unexpected return code from WinNet_EnsureBestMetric: {}", i);
Err(Error::MetricApplication)
}
}
@@ -365,8 +365,8 @@ mod api {
#[link_name = "WinNet_DeactivateRouteManager"]
pub fn WinNet_DeactivateRouteManager();
- #[link_name = "WinNet_EnsureTopMetric"]
- pub fn WinNet_EnsureTopMetric(
+ #[link_name = "WinNet_EnsureBestMetric"]
+ pub fn WinNet_EnsureBestMetric(
tunnel_interface_alias: *const wchar_t,
sink: Option<LogSink>,
sink_context: *const u8,
diff --git a/windows/winnet/src/winnet/InterfacePair.cpp b/windows/winnet/src/winnet/InterfacePair.cpp
index 1a52652ae8..b48d3ec6ae 100644
--- a/windows/winnet/src/winnet/InterfacePair.cpp
+++ b/windows/winnet/src/winnet/InterfacePair.cpp
@@ -17,7 +17,7 @@ InterfacePair::InterfacePair(NET_LUID interface_luid)
IPv6Iface.InterfaceLuid = interface_luid;
InitializeInterface(&IPv6Iface);
- if (!(HasIPv4() || HasIPv6()))
+ if (!HasIPv4() && !HasIPv6())
{
std::stringstream ss;
@@ -33,7 +33,7 @@ int InterfacePair::WorstMetric()
return IPv6Iface.Metric >= IPv4Iface.Metric ? IPv6Iface.Metric : IPv4Iface.Metric;
}
-int InterfacePair::HighestMetric()
+int InterfacePair::BestMetric()
{
return IPv6Iface.Metric < IPv4Iface.Metric ? IPv4Iface.Metric : IPv6Iface.Metric;
}
diff --git a/windows/winnet/src/winnet/InterfacePair.h b/windows/winnet/src/winnet/InterfacePair.h
index 467115b218..f574ac2845 100644
--- a/windows/winnet/src/winnet/InterfacePair.h
+++ b/windows/winnet/src/winnet/InterfacePair.h
@@ -9,7 +9,7 @@ class InterfacePair
{
public:
InterfacePair(NET_LUID interface_luid);
- int HighestMetric();
+ int BestMetric();
int WorstMetric();
void SetMetric(unsigned int metric);
diff --git a/windows/winnet/src/winnet/NetworkInterfaces.cpp b/windows/winnet/src/winnet/NetworkInterfaces.cpp
index e7f75fdda1..dc27e95e92 100644
--- a/windows/winnet/src/winnet/NetworkInterfaces.cpp
+++ b/windows/winnet/src/winnet/NetworkInterfaces.cpp
@@ -7,7 +7,7 @@
#include <sstream>
#include <cstdint>
-bool NetworkInterfaces::HasHighestMetric(PMIB_IPINTERFACE_ROW targetIface)
+bool NetworkInterfaces::HasBestMetric(PMIB_IPINTERFACE_ROW targetIface)
{
for (unsigned int i = 0; i < mInterfaces->NumEntries; ++i)
{
@@ -32,19 +32,19 @@ NetworkInterfaces::NetworkInterfaces()
}
}
-bool NetworkInterfaces::SetTopMetricForInterfacesByAlias(const wchar_t * deviceAlias)
+bool NetworkInterfaces::SetBestMetricForInterfacesByAlias(const wchar_t * deviceAlias)
{
- return SetTopMetricForInterfacesWithLuid(GetInterfaceLuid(deviceAlias));
+ return SetBestMetricForInterfacesWithLuid(GetInterfaceLuid(deviceAlias));
}
-bool NetworkInterfaces::SetTopMetricForInterfacesWithLuid(NET_LUID targetIfaceId)
+bool NetworkInterfaces::SetBestMetricForInterfacesWithLuid(NET_LUID targetIfaceId)
{
InterfacePair targetInterfaces = InterfacePair(targetIfaceId);
- if (MAX_METRIC == targetInterfaces.WorstMetric())
+ if (BEST_METRIC == targetInterfaces.WorstMetric())
{
return false;
}
- targetInterfaces.SetMetric(MAX_METRIC);
+ targetInterfaces.SetMetric(BEST_METRIC);
return true;
}
diff --git a/windows/winnet/src/winnet/NetworkInterfaces.h b/windows/winnet/src/winnet/NetworkInterfaces.h
index 515bbe09e6..e987939454 100644
--- a/windows/winnet/src/winnet/NetworkInterfaces.h
+++ b/windows/winnet/src/winnet/NetworkInterfaces.h
@@ -13,19 +13,19 @@ class NetworkInterfaces
private:
PMIB_IPINTERFACE_TABLE mInterfaces;
- bool HasHighestMetric(PMIB_IPINTERFACE_ROW targetIface);
+ bool HasBestMetric(PMIB_IPINTERFACE_ROW targetIface);
public:
NetworkInterfaces(const NetworkInterfaces &) = delete;
NetworkInterfaces &operator=(const NetworkInterfaces &) = delete;
NetworkInterfaces();
- bool SetTopMetricForInterfacesByAlias(const wchar_t *deviceAlias);
- bool SetTopMetricForInterfacesWithLuid(NET_LUID targetIface);
+ bool SetBestMetricForInterfacesByAlias(const wchar_t *deviceAlias);
+ bool SetBestMetricForInterfacesWithLuid(NET_LUID targetIface);
~NetworkInterfaces();
static NET_LUID GetInterfaceLuid(const std::wstring &interfaceAlias);
const MIB_IPINTERFACE_ROW *GetInterface(NET_LUID interfaceLuid, ADDRESS_FAMILY interfaceFamily);
};
-constexpr static uint32_t MAX_METRIC = 1;
+constexpr static uint32_t BEST_METRIC = 1;
diff --git a/windows/winnet/src/winnet/winnet.cpp b/windows/winnet/src/winnet/winnet.cpp
index 7a206635ed..f572b188be 100644
--- a/windows/winnet/src/winnet/winnet.cpp
+++ b/windows/winnet/src/winnet/winnet.cpp
@@ -33,9 +33,9 @@ std::shared_ptr<shared::logging::LogSinkAdapter> g_RouteManagerLogSink;
extern "C"
WINNET_LINKAGE
-WINNET_ETM_STATUS
+WINNET_EBM_STATUS
WINNET_API
-WinNet_EnsureTopMetric(
+WinNet_EnsureBestMetric(
const wchar_t *deviceAlias,
MullvadLogSink logSink,
void *logSinkContext
@@ -44,17 +44,17 @@ WinNet_EnsureTopMetric(
try
{
NetworkInterfaces interfaces;
- bool metrics_set = interfaces.SetTopMetricForInterfacesByAlias(deviceAlias);
- return metrics_set ? WINNET_ETM_STATUS_METRIC_SET : WINNET_ETM_STATUS_METRIC_NO_CHANGE;
+ bool metrics_set = interfaces.SetBestMetricForInterfacesByAlias(deviceAlias);
+ return metrics_set ? WINNET_EBM_STATUS_METRIC_SET : WINNET_EBM_STATUS_METRIC_NO_CHANGE;
}
catch (const std::exception &err)
{
shared::logging::UnwindAndLog(logSink, logSinkContext, err);
- return WINNET_ETM_STATUS_FAILURE;
+ return WINNET_EBM_STATUS_FAILURE;
}
catch (...)
{
- return WINNET_ETM_STATUS_FAILURE;
+ return WINNET_EBM_STATUS_FAILURE;
}
};
diff --git a/windows/winnet/src/winnet/winnet.def b/windows/winnet/src/winnet/winnet.def
index b23ae6c854..ecec97959e 100644
--- a/windows/winnet/src/winnet/winnet.def
+++ b/windows/winnet/src/winnet/winnet.def
@@ -1,6 +1,6 @@
LIBRARY winnet
EXPORTS
- WinNet_EnsureTopMetric
+ WinNet_EnsureBestMetric
WinNet_GetTapInterfaceIpv6Status
WinNet_GetTapInterfaceAlias
WinNet_ReleaseString
diff --git a/windows/winnet/src/winnet/winnet.h b/windows/winnet/src/winnet/winnet.h
index 5afc4052eb..5e2a4154a4 100644
--- a/windows/winnet/src/winnet/winnet.h
+++ b/windows/winnet/src/winnet/winnet.h
@@ -16,18 +16,18 @@
#define WINNET_API __stdcall
-enum WINNET_ETM_STATUS
+enum WINNET_EBM_STATUS
{
- WINNET_ETM_STATUS_METRIC_NO_CHANGE = 0,
- WINNET_ETM_STATUS_METRIC_SET = 1,
- WINNET_ETM_STATUS_FAILURE = 2,
+ WINNET_EBM_STATUS_METRIC_NO_CHANGE = 0,
+ WINNET_EBM_STATUS_METRIC_SET = 1,
+ WINNET_EBM_STATUS_FAILURE = 2,
};
extern "C"
WINNET_LINKAGE
-WINNET_ETM_STATUS
+WINNET_EBM_STATUS
WINNET_API
-WinNet_EnsureTopMetric(
+WinNet_EnsureBestMetric(
const wchar_t *deviceAlias,
MullvadLogSink logSink,
void *logSinkContext