diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-02-06 13:22:05 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-02-07 13:01:26 +0100 |
| commit | 81772b01cd7cabeef9435bb5c39df67b3d63f4bb (patch) | |
| tree | 63d62e67fa07de2b2b0987950f95ebb58a18cab9 /windows/winnet/src | |
| parent | 533b498658bad6ecb38b9a0e16e8fb3dd25975e5 (diff) | |
| download | mullvadvpn-81772b01cd7cabeef9435bb5c39df67b3d63f4bb.tar.xz mullvadvpn-81772b01cd7cabeef9435bb5c39df67b3d63f4bb.zip | |
Rename amgiguous metric identifiers
Diffstat (limited to 'windows/winnet/src')
| -rw-r--r-- | windows/winnet/src/winnet/InterfacePair.cpp | 4 | ||||
| -rw-r--r-- | windows/winnet/src/winnet/InterfacePair.h | 2 | ||||
| -rw-r--r-- | windows/winnet/src/winnet/NetworkInterfaces.cpp | 12 | ||||
| -rw-r--r-- | windows/winnet/src/winnet/NetworkInterfaces.h | 8 | ||||
| -rw-r--r-- | windows/winnet/src/winnet/winnet.cpp | 12 | ||||
| -rw-r--r-- | windows/winnet/src/winnet/winnet.def | 2 | ||||
| -rw-r--r-- | windows/winnet/src/winnet/winnet.h | 12 |
7 files changed, 26 insertions, 26 deletions
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 |
