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

This is a reland of b29fc269716e556be6b4e999bb4b24332cc43c6e

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=mmenke@chromium.org

Bug: 831384
Change-Id: Iabb29661680b835b947b2780d169e204fd5e2559
Reviewed-on: https://chromium-review.googlesource.com/1036484
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: Kevin Marshall <kmarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554946}
bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
IPAddress NetAddressToIPAddress(const netstack::NetAddress& addr) {
  if (addr.ipv4) {
    return IPAddress(addr.ipv4->addr.data(), addr.ipv4->addr.count());
   }
  if (addr.ipv6) {
    return IPAddress(addr.ipv6->addr.data(), addr.ipv6->addr.count());
   }
  return IPAddress();
}
 
bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
  netstack::NetstackSyncPtr netstack =
      base::fuchsia::ComponentContext::GetDefault()
          ->ConnectToServiceSync<netstack::Netstack>();
 
  fidl::VectorPtr<netstack::NetInterface> interfaces;
  if (!netstack->GetInterfaces(&interfaces))
    return false;
 
  for (auto& interface : interfaces.get()) {
    // Check if the interface is up.
    if (!(interface.flags & netstack::NetInterfaceFlagUp))
       continue;
 
    // Skip loopback.
    if (interface.features & netstack::interfaceFeatureLoopback)
       continue;
 
    NetworkChangeNotifier::ConnectionType connection_type =
        (interface.features & netstack::interfaceFeatureWlan)
            ? NetworkChangeNotifier::CONNECTION_WIFI
            : NetworkChangeNotifier::CONNECTION_UNKNOWN;
 
    // addresses. Currently Netstack doesn't provide this information.
     int attributes = 0;
 
    networks->push_back(NetworkInterface(
        *interface.name, *interface.name, interface.id, connection_type,
        NetAddressToIPAddress(interface.addr),
        MaskPrefixLength(NetAddressToIPAddress(interface.netmask)),
        attributes));
   }
 
   return true;
 }

bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
  int s = socket(AF_INET, SOCK_DGRAM, 0);
  if (s <= 0) {
    PLOG(ERROR) << "socket";
    return false;
   }
  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;
   }
 
  for (uint32_t i = 0; i < num_ifs; ++i) {
    netc_if_info_t interface;
 
    if (ioctl_netc_get_if_info_at(s, &i, &interface) < 0) {
      PLOG(WARNING) << "ioctl_netc_get_if_info_at";
      continue;
    }
 
    if (internal::IsLoopbackOrUnspecifiedAddress(
            reinterpret_cast<sockaddr*>(&(interface.addr)))) {
       continue;
    }
 
    IPEndPoint address;
    if (!address.FromSockAddr(reinterpret_cast<sockaddr*>(&(interface.addr)),
                              sizeof(interface.addr))) {
      DLOG(WARNING) << "ioctl_netc_get_if_info returned invalid address.";
       continue;
    }
 
    int prefix_length = 0;
    IPEndPoint netmask;
    if (netmask.FromSockAddr(reinterpret_cast<sockaddr*>(&(interface.netmask)),
                             sizeof(interface.netmask))) {
      prefix_length = MaskPrefixLength(netmask.address());
    }
 
     int attributes = 0;
 
    networks->push_back(
        NetworkInterface(interface.name, interface.name, interface.index,
                         NetworkChangeNotifier::CONNECTION_UNKNOWN,
                         address.address(), prefix_length, attributes));
   }
 
  PCHECK(close(s) == 0);
   return true;
 }
