Commit d0689dce authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

Revert "[Fuchsia] Use Netstack FIDL interface to get network interfaces."

This reverts commit b29fc269.

Reason for revert: Generated code lacks export directives, causing linker errors on component/debug builds. https://logs.chromium.org/v/?s=chromium%2Fbb%2Fchromium.fyi%2FFuchsia__dbg_%2F18935%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout

Original change's description:
> [Fuchsia] Use Netstack FIDL interface to get network interfaces.
> 
> 1. Updated FILD GN template to generate and compile tables file, FIDL
>    generated code was failing to link without them.
> 2. Updated GetNetworkList() for Fuchsia to FIDL API instead of ioctl().
> 
> Bug: 831384
> Change-Id: Ib90303a5110a465ea5f2bad787a7b63a2bf13f61
> Reviewed-on: https://chromium-review.googlesource.com/1023124
> Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
> Reviewed-by: James Robinson <jamesr@chromium.org>
> Reviewed-by: Matt Menke <mmenke@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#554868}

TBR=jamesr@chromium.org,mmenke@chromium.org,sergeyu@chromium.org

Change-Id: Iaaa6e563c90acced9c87bd1adccd2e313c57292e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 831384
Reviewed-on: https://chromium-review.googlesource.com/1036383Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554885}
parent bbcce752
...@@ -2046,7 +2046,6 @@ component("net") { ...@@ -2046,7 +2046,6 @@ component("net") {
"cert/cert_database_fuchsia.cc", "cert/cert_database_fuchsia.cc",
"cert/test_root_certs_fuchsia.cc", "cert/test_root_certs_fuchsia.cc",
] ]
deps += [ "//third_party/fuchsia-sdk:netstack" ]
} }
} else { } else {
public_deps += [ "//native_client_sdk/src/libraries/nacl_io" ] public_deps += [ "//native_client_sdk/src/libraries/nacl_io" ]
......
...@@ -4,57 +4,68 @@ ...@@ -4,57 +4,68 @@
#include "net/base/network_interfaces.h" #include "net/base/network_interfaces.h"
#include <fuchsia/cpp/netstack.h> #include <netstack/netconfig.h>
#include "base/fuchsia/component_context.h"
#include "net/base/ip_endpoint.h" #include "net/base/ip_endpoint.h"
#include "net/base/network_interfaces_posix.h"
namespace net { namespace net {
IPAddress NetAddressToIPAddress(const netstack::NetAddress& addr) { bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
if (addr.ipv4) { int s = socket(AF_INET, SOCK_DGRAM, 0);
return IPAddress(addr.ipv4->addr.data(), addr.ipv4->addr.count()); if (s <= 0) {
PLOG(ERROR) << "socket";
return false;
} }
if (addr.ipv6) {
return IPAddress(addr.ipv6->addr.data(), addr.ipv6->addr.count()); uint32_t num_ifs = 0;
if (ioctl_netc_get_num_ifs(s, &num_ifs) < 0) {
PLOG(ERROR) << "ioctl_netc_get_num_ifs";
PCHECK(close(s) == 0);
return false;
} }
return IPAddress();
}
bool GetNetworkList(NetworkInterfaceList* networks, int policy) { for (uint32_t i = 0; i < num_ifs; ++i) {
netstack::NetstackSyncPtr netstack = netc_if_info_t interface;
base::fuchsia::ComponentContext::GetDefault()
->ConnectToServiceSync<netstack::Netstack>();
fidl::VectorPtr<netstack::NetInterface> interfaces; if (ioctl_netc_get_if_info_at(s, &i, &interface) < 0) {
if (!netstack->GetInterfaces(&interfaces)) PLOG(WARNING) << "ioctl_netc_get_if_info_at";
return false; continue;
}
for (auto& interface : interfaces.get()) { // Skip loopback addresses.
// Check if the interface is up. if (internal::IsLoopbackOrUnspecifiedAddress(
if (!(interface.flags & netstack::NetInterfaceFlagUp)) reinterpret_cast<sockaddr*>(&(interface.addr)))) {
continue; continue;
}
// Skip loopback. IPEndPoint address;
if (interface.features & netstack::interfaceFeatureLoopback) if (!address.FromSockAddr(reinterpret_cast<sockaddr*>(&(interface.addr)),
sizeof(interface.addr))) {
DLOG(WARNING) << "ioctl_netc_get_if_info returned invalid address.";
continue; continue;
}
NetworkChangeNotifier::ConnectionType connection_type = int prefix_length = 0;
(interface.features & netstack::interfaceFeatureWlan) IPEndPoint netmask;
? NetworkChangeNotifier::CONNECTION_WIFI if (netmask.FromSockAddr(reinterpret_cast<sockaddr*>(&(interface.netmask)),
: NetworkChangeNotifier::CONNECTION_UNKNOWN; sizeof(interface.netmask))) {
prefix_length = MaskPrefixLength(netmask.address());
}
// TODO(sergeyu): attributes field is used to return address state for IPv6 // TODO(sergeyu): attributes field is used to return address state for IPv6
// addresses. Currently Netstack doesn't provide this information. // addresses. Currently ioctl_netc_get_if_info doesn't provide this
// information.
int attributes = 0; int attributes = 0;
networks->push_back(NetworkInterface( networks->push_back(
*interface.name, *interface.name, interface.id, connection_type, NetworkInterface(interface.name, interface.name, interface.index,
NetAddressToIPAddress(interface.addr), NetworkChangeNotifier::CONNECTION_UNKNOWN,
MaskPrefixLength(NetAddressToIPAddress(interface.netmask)), address.address(), prefix_length, attributes));
attributes));
} }
PCHECK(close(s) == 0);
return true; return true;
} }
......
...@@ -181,10 +181,3 @@ fuchsia_sdk_pkg("fdio") { ...@@ -181,10 +181,3 @@ fuchsia_sdk_pkg("fdio") {
"include/fdio/watcher.h", "include/fdio/watcher.h",
] ]
} }
fuchsia_sdk_pkg("netstack") {
fidl_files = [
"net_address.fidl",
"netstack.fidl",
]
}
...@@ -19,7 +19,6 @@ template("fuchsia_sdk_pkg") { ...@@ -19,7 +19,6 @@ template("fuchsia_sdk_pkg") {
json_representation = "$target_gen_dir/$pkg_name.fidl.json" json_representation = "$target_gen_dir/$pkg_name.fidl.json"
output_gen_base = "$target_gen_dir/fidl" output_gen_base = "$target_gen_dir/fidl"
output_gen_dir = "$output_gen_base/fuchsia/cpp" output_gen_dir = "$output_gen_base/fuchsia/cpp"
tables_file = "$output_gen_base/$pkg_name.fidl-tables.cc"
action("${target_name}_response_file") { action("${target_name}_response_file") {
visibility = [ ":*" ] visibility = [ ":*" ]
...@@ -35,7 +34,7 @@ template("fuchsia_sdk_pkg") { ...@@ -35,7 +34,7 @@ template("fuchsia_sdk_pkg") {
sources = [] sources = []
foreach(file, invoker.fidl_files) { foreach(file, invoker.fidl_files) {
sources += [ "sdk/fidl/${pkg_name}/${file}" ] sources += [ "sdk/pkg/${pkg_name}/${file}" ]
} }
libraries_file = "$target_gen_dir/$pkg_name.fidl_libraries" libraries_file = "$target_gen_dir/$pkg_name.fidl_libraries"
...@@ -50,8 +49,6 @@ template("fuchsia_sdk_pkg") { ...@@ -50,8 +49,6 @@ template("fuchsia_sdk_pkg") {
rebase_path(response_file, root_build_dir), rebase_path(response_file, root_build_dir),
"--out-libraries", "--out-libraries",
rebase_path(libraries_file, root_build_dir), rebase_path(libraries_file, root_build_dir),
"--tables",
rebase_path(tables_file, root_build_dir),
"--json", "--json",
rebase_path(json_representation, root_build_dir), rebase_path(json_representation, root_build_dir),
"--name", "--name",
...@@ -94,7 +91,6 @@ template("fuchsia_sdk_pkg") { ...@@ -94,7 +91,6 @@ template("fuchsia_sdk_pkg") {
outputs = [ outputs = [
json_representation, json_representation,
tables_file,
] ]
rebased_response_file = rebase_path(response_file, root_build_dir) rebased_response_file = rebase_path(response_file, root_build_dir)
...@@ -163,15 +159,11 @@ template("fuchsia_sdk_pkg") { ...@@ -163,15 +159,11 @@ template("fuchsia_sdk_pkg") {
if (!defined(deps)) { if (!defined(deps)) {
deps = [] deps = []
} }
deps += [ deps += [ ":${invoker.target_name}_cpp_gen" ]
":${invoker.target_name}_compile",
":${invoker.target_name}_cpp_gen",
]
sources = [ sources = [
"$output_gen_dir/$pkg_name.cc", "$output_gen_dir/$pkg_name.cc",
"$output_gen_dir/$pkg_name.h", "$output_gen_dir/$pkg_name.h",
tables_file,
] ]
assert(pkg_name != "fidl" && pkg_name != "fidl_cpp") assert(pkg_name != "fidl" && pkg_name != "fidl_cpp")
......
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