network_interfaces_linux.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef NET_BASE_NETWORK_INTERFACES_LINUX_H_
  5. #define NET_BASE_NETWORK_INTERFACES_LINUX_H_
  6. // This file is only used to expose some of the internals
  7. // of network_interfaces_linux.cc to address_tracker_linux and tests.
  8. #include <string>
  9. #include <unordered_set>
  10. #include "base/files/scoped_file.h"
  11. #include "net/base/address_tracker_linux.h"
  12. #include "net/base/net_export.h"
  13. #include "net/base/network_interfaces.h"
  14. namespace net::internal {
  15. typedef char* (*GetInterfaceNameFunction)(int interface_index, char* ifname);
  16. typedef std::string (*GetInterfaceSSIDFunction)(const std::string& ifname);
  17. NET_EXPORT bool GetNetworkListImpl(
  18. NetworkInterfaceList* networks,
  19. int policy,
  20. const std::unordered_set<int>& online_links,
  21. const internal::AddressTrackerLinux::AddressMap& address_map,
  22. GetInterfaceNameFunction get_interface_name);
  23. // Gets the current Wi-Fi SSID based on |interfaces|. Returns
  24. // empty string if there are no interfaces or if two interfaces have different
  25. // connection types. Otherwise returns the SSID of all interfaces if they have
  26. // the same SSID. This is adapted from
  27. // NetworkChangeNotifier::ConnectionTypeFromInterfaceList.
  28. NET_EXPORT std::string GetWifiSSIDFromInterfaceListInternal(
  29. const NetworkInterfaceList& interfaces,
  30. internal::GetInterfaceSSIDFunction get_interface_ssid);
  31. // Returns a socket useful for performing ioctl()s.
  32. base::ScopedFD GetSocketForIoctl();
  33. } // namespace net::internal
  34. #endif // NET_BASE_NETWORK_INTERFACES_LINUX_H_