Commit 1bd3e56f authored by Tamir Duberstein's avatar Tamir Duberstein Committed by Commit Bot

[fuchsia] Prepare to migrate NetInterface::features.

This is reworking changes made in b115d096.

Bug: 1099393
Change-Id: Id5d092887298a70ad4cc4dc9aaf97390a403933c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354883Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: Tamir Duberstein <tamird@google.com>
Cr-Commit-Position: refs/heads/master@{#798060}
parent d3e33c73
...@@ -100,11 +100,11 @@ void NetworkChangeNotifierFuchsia::OnRouteTableReceived( ...@@ -100,11 +100,11 @@ void NetworkChangeNotifierFuchsia::OnRouteTableReceived(
base::flat_set<IPAddress> addresses; base::flat_set<IPAddress> addresses;
for (auto& interface : interfaces) { for (auto& interface : interfaces) {
// Filter out loopback and invalid connection types. // Filter out loopback and invalid connection types.
auto loopback = static_cast<decltype(interface.features)>(
fuchsia::hardware::ethernet::INFO_FEATURE_LOOPBACK);
if ((internal::ConvertConnectionType(interface) == if ((internal::ConvertConnectionType(interface) ==
NetworkChangeNotifier::CONNECTION_NONE) || NetworkChangeNotifier::CONNECTION_NONE) ||
(interface.features & ((interface.features & loopback) == loopback)) {
static_cast<decltype(interface.features)>(
fuchsia::hardware::ethernet::INFO_FEATURE_LOOPBACK))) {
continue; continue;
} }
......
...@@ -355,7 +355,8 @@ TEST_F(NetworkChangeNotifierFuchsiaTest, NotifyNetworkChangeOnInitialIPChange) { ...@@ -355,7 +355,8 @@ TEST_F(NetworkChangeNotifierFuchsiaTest, NotifyNetworkChangeOnInitialIPChange) {
// Set a live interface with an IP address and create the notifier. // Set a live interface with an IP address and create the notifier.
std::vector<fuchsia::netstack::NetInterface> interfaces(1); std::vector<fuchsia::netstack::NetInterface> interfaces(1);
interfaces[0] = DefaultNetInterface(); interfaces[0] = DefaultNetInterface();
interfaces[0].features = {fuchsia::hardware::ethernet::INFO_FEATURE_WLAN}; interfaces[0].features = static_cast<decltype(interfaces[0].features)>(
fuchsia::hardware::ethernet::INFO_FEATURE_WLAN);
netstack_.SetInterfaces(interfaces); netstack_.SetInterfaces(interfaces);
CreateNotifier(); CreateNotifier();
...@@ -556,7 +557,8 @@ TEST_F(NetworkChangeNotifierFuchsiaTest, InterfaceAdded) { ...@@ -556,7 +557,8 @@ TEST_F(NetworkChangeNotifierFuchsiaTest, InterfaceAdded) {
std::vector<fuchsia::netstack::NetInterface> interfaces(1); std::vector<fuchsia::netstack::NetInterface> interfaces(1);
interfaces[0] = DefaultNetInterface(); interfaces[0] = DefaultNetInterface();
interfaces[0].features = {fuchsia::hardware::ethernet::INFO_FEATURE_WLAN}; interfaces[0].features = static_cast<decltype(interfaces[0].features)>(
fuchsia::hardware::ethernet::INFO_FEATURE_WLAN);
netstack_.SetInterfaces(interfaces); netstack_.SetInterfaces(interfaces);
...@@ -591,7 +593,8 @@ TEST_F(NetworkChangeNotifierFuchsiaTest, SecondaryInterfaceDeletedNoop) { ...@@ -591,7 +593,8 @@ TEST_F(NetworkChangeNotifierFuchsiaTest, SecondaryInterfaceDeletedNoop) {
TEST_F(NetworkChangeNotifierFuchsiaTest, FoundWiFi) { TEST_F(NetworkChangeNotifierFuchsiaTest, FoundWiFi) {
std::vector<fuchsia::netstack::NetInterface> interfaces(1); std::vector<fuchsia::netstack::NetInterface> interfaces(1);
interfaces[0] = DefaultNetInterface(); interfaces[0] = DefaultNetInterface();
interfaces[0].features = {fuchsia::hardware::ethernet::INFO_FEATURE_WLAN}; interfaces[0].features = static_cast<decltype(interfaces[0].features)>(
fuchsia::hardware::ethernet::INFO_FEATURE_WLAN);
netstack_.SetInterfaces(interfaces); netstack_.SetInterfaces(interfaces);
CreateNotifier(); CreateNotifier();
...@@ -602,7 +605,8 @@ TEST_F(NetworkChangeNotifierFuchsiaTest, FoundWiFi) { ...@@ -602,7 +605,8 @@ TEST_F(NetworkChangeNotifierFuchsiaTest, FoundWiFi) {
TEST_F(NetworkChangeNotifierFuchsiaTest, FindsInterfaceWithRequiredFeature) { TEST_F(NetworkChangeNotifierFuchsiaTest, FindsInterfaceWithRequiredFeature) {
std::vector<fuchsia::netstack::NetInterface> interfaces(1); std::vector<fuchsia::netstack::NetInterface> interfaces(1);
interfaces[0] = DefaultNetInterface(); interfaces[0] = DefaultNetInterface();
interfaces[0].features = {fuchsia::hardware::ethernet::INFO_FEATURE_WLAN}; interfaces[0].features = static_cast<decltype(interfaces[0].features)>(
fuchsia::hardware::ethernet::INFO_FEATURE_WLAN);
netstack_.SetInterfaces(interfaces); netstack_.SetInterfaces(interfaces);
CreateNotifier(fuchsia::hardware::ethernet::INFO_FEATURE_WLAN); CreateNotifier(fuchsia::hardware::ethernet::INFO_FEATURE_WLAN);
......
...@@ -60,11 +60,11 @@ NetworkInterface NetworkInterfaceFromAddress( ...@@ -60,11 +60,11 @@ NetworkInterface NetworkInterfaceFromAddress(
NetworkChangeNotifier::ConnectionType ConvertConnectionType( NetworkChangeNotifier::ConnectionType ConvertConnectionType(
const fuchsia::netstack::NetInterface& iface) { const fuchsia::netstack::NetInterface& iface) {
auto wlan = static_cast<decltype(iface.features)>(
fuchsia::hardware::ethernet::INFO_FEATURE_WLAN);
if (!(iface.flags & fuchsia::netstack::NetInterfaceFlagUp)) { if (!(iface.flags & fuchsia::netstack::NetInterfaceFlagUp)) {
return NetworkChangeNotifier::CONNECTION_NONE; return NetworkChangeNotifier::CONNECTION_NONE;
} else if (iface.features & } else if ((iface.features & wlan) == wlan) {
static_cast<decltype(iface.features)>(
fuchsia::hardware::ethernet::INFO_FEATURE_WLAN)) {
return NetworkChangeNotifier::CONNECTION_WIFI; return NetworkChangeNotifier::CONNECTION_WIFI;
} }
return NetworkChangeNotifier::CONNECTION_UNKNOWN; return NetworkChangeNotifier::CONNECTION_UNKNOWN;
...@@ -120,11 +120,11 @@ bool GetNetworkList(NetworkInterfaceList* networks, int policy) { ...@@ -120,11 +120,11 @@ bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
} }
for (auto& interface : interfaces) { for (auto& interface : interfaces) {
auto loopback = static_cast<decltype(interface.features)>(
fuchsia::hardware::ethernet::INFO_FEATURE_LOOPBACK);
if ((internal::ConvertConnectionType(interface) == if ((internal::ConvertConnectionType(interface) ==
NetworkChangeNotifier::CONNECTION_NONE) || NetworkChangeNotifier::CONNECTION_NONE) ||
(interface.features & ((interface.features & loopback) == loopback)) {
static_cast<decltype(interface.features)>(
fuchsia::hardware::ethernet::INFO_FEATURE_LOOPBACK))) {
continue; continue;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment