Commit cb9c68ba authored by Tamir Duberstein's avatar Tamir Duberstein Committed by Commit Bot

[fuchsia] Prepare to migrate NetInterface::flags.

This allows the flags field to be changed to a FIDL |bits| type without
breaking the Chromium build.

The |static_cast|s introduced in this change will be removed after the
next Fuchsia SDK roll.

Bug: 1099393
Change-Id: Ie0628ac0dbe7dd8dd407d5907b0ef38cbd839da8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2353295
Commit-Queue: Tamir Duberstein <tamird@google.com>
Reviewed-by: default avatarWez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798196}
parent e9b9e868
......@@ -68,7 +68,8 @@ fuchsia::netstack::NetInterface DefaultNetInterface() {
// is sufficient.
fuchsia::netstack::NetInterface interface;
interface.id = kDefaultInterfaceId;
interface.flags = fuchsia::netstack::NetInterfaceFlagUp;
interface.flags = static_cast<decltype(interface.flags)>(
fuchsia::netstack::NetInterfaceFlagUp);
interface.features = {};
interface.addr = IpAddressFrom(kDefaultIPv4Address);
interface.netmask = IpAddressFrom(kDefaultIPv4Netmask);
......@@ -81,7 +82,8 @@ fuchsia::netstack::NetInterface SecondaryNetInterface() {
// is sufficient.
fuchsia::netstack::NetInterface interface;
interface.id = kSecondaryInterfaceId;
interface.flags = fuchsia::netstack::NetInterfaceFlagUp;
interface.flags = static_cast<decltype(interface.flags)>(
fuchsia::netstack::NetInterfaceFlagUp);
interface.features = {};
interface.addr = IpAddressFrom(kSecondaryIPv4Address);
interface.netmask = IpAddressFrom(kSecondaryIPv4Netmask);
......@@ -507,7 +509,7 @@ TEST_F(NetworkChangeNotifierFuchsiaTest, InterfaceDown) {
EXPECT_EQ(NetworkChangeNotifier::ConnectionType::CONNECTION_UNKNOWN,
notifier_->GetCurrentConnectionType());
interfaces[0].flags = 0;
interfaces[0].flags = {};
netstack_.SetInterfaces(interfaces);
EXPECT_TRUE(type_observer_->RunAndExpectConnectionTypes(
......@@ -518,14 +520,15 @@ TEST_F(NetworkChangeNotifierFuchsiaTest, InterfaceDown) {
TEST_F(NetworkChangeNotifierFuchsiaTest, InterfaceUp) {
std::vector<fuchsia::netstack::NetInterface> interfaces(1);
interfaces[0] = DefaultNetInterface();
interfaces[0].flags = 0;
interfaces[0].flags = {};
netstack_.SetInterfaces(interfaces);
CreateNotifier();
EXPECT_EQ(NetworkChangeNotifier::ConnectionType::CONNECTION_NONE,
notifier_->GetCurrentConnectionType());
interfaces[0].flags = fuchsia::netstack::NetInterfaceFlagUp;
interfaces[0].flags = static_cast<decltype(interfaces[0].flags)>(
fuchsia::netstack::NetInterfaceFlagUp);
netstack_.SetInterfaces(interfaces);
EXPECT_TRUE(type_observer_->RunAndExpectConnectionTypes(
......
......@@ -62,7 +62,9 @@ NetworkChangeNotifier::ConnectionType ConvertConnectionType(
const fuchsia::netstack::NetInterface& iface) {
auto wlan = static_cast<decltype(iface.features)>(
fuchsia::hardware::ethernet::INFO_FEATURE_WLAN);
if (!(iface.flags & fuchsia::netstack::NetInterfaceFlagUp)) {
auto up =
static_cast<decltype(iface.flags)>(fuchsia::netstack::NetInterfaceFlagUp);
if ((iface.flags & up) != up) {
return NetworkChangeNotifier::CONNECTION_NONE;
} else if ((iface.features & wlan) == wlan) {
return NetworkChangeNotifier::CONNECTION_WIFI;
......
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