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 
5 #ifndef NET_BASE_NETWORK_INTERFACES_LINUX_H_
6 #define NET_BASE_NETWORK_INTERFACES_LINUX_H_
7 
8 // This file is only used to expose some of the internals
9 // of network_interfaces_linux.cc to address_tracker_linux and tests.
10 
11 #include <string>
12 #include <unordered_set>
13 
14 #include "base/files/scoped_file.h"
15 #include "net/base/address_tracker_linux.h"
16 #include "net/base/net_export.h"
17 #include "net/base/network_interfaces.h"
18 
19 namespace net {
20 namespace internal {
21 
22 typedef char* (*GetInterfaceNameFunction)(int interface_index, char* ifname);
23 
24 typedef std::string (*GetInterfaceSSIDFunction)(const std::string& ifname);
25 
26 NET_EXPORT bool GetNetworkListImpl(
27     NetworkInterfaceList* networks,
28     int policy,
29     const std::unordered_set<int>& online_links,
30     const internal::AddressTrackerLinux::AddressMap& address_map,
31     GetInterfaceNameFunction get_interface_name);
32 
33 // Gets the current Wi-Fi SSID based on |interfaces|. Returns
34 // empty string if there are no interfaces or if two interfaces have different
35 // connection types. Otherwise returns the SSID of all interfaces if they have
36 // the same SSID. This is adapted from
37 // NetworkChangeNotifier::ConnectionTypeFromInterfaceList.
38 NET_EXPORT std::string GetWifiSSIDFromInterfaceListInternal(
39     const NetworkInterfaceList& interfaces,
40     internal::GetInterfaceSSIDFunction get_interface_ssid);
41 
42 // Returns a socket useful for performing ioctl()s.
43 base::ScopedFD GetSocketForIoctl();
44 
45 }  // namespace internal
46 }  // namespace net
47 
48 #endif  // NET_BASE_NETWORK_INTERFACES_LINUX_H_
49