OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/network_interfaces_linux.h" | 5 #include "net/base/network_interfaces_linux.h" |
6 | 6 |
7 #if !defined(OS_ANDROID) | 7 #if !defined(OS_ANDROID) |
8 #include <linux/ethtool.h> | 8 #include <linux/ethtool.h> |
9 #endif // !defined(OS_ANDROID) | 9 #endif // !defined(OS_ANDROID) |
10 #include <linux/if.h> | 10 #include <linux/if.h> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 wreq.u.essid.pointer = ssid; | 106 wreq.u.essid.pointer = ssid; |
107 wreq.u.essid.length = IW_ESSID_MAX_SIZE; | 107 wreq.u.essid.length = IW_ESSID_MAX_SIZE; |
108 if (ioctl(ioctl_socket.get(), SIOCGIWESSID, &wreq) != -1) | 108 if (ioctl(ioctl_socket.get(), SIOCGIWESSID, &wreq) != -1) |
109 return ssid; | 109 return ssid; |
110 return ""; | 110 return ""; |
111 } | 111 } |
112 | 112 |
113 bool GetNetworkListImpl( | 113 bool GetNetworkListImpl( |
114 NetworkInterfaceList* networks, | 114 NetworkInterfaceList* networks, |
115 int policy, | 115 int policy, |
116 const std::unordered_set<int>& online_links, | 116 const base::hash_set<int>& online_links, |
117 const internal::AddressTrackerLinux::AddressMap& address_map, | 117 const internal::AddressTrackerLinux::AddressMap& address_map, |
118 GetInterfaceNameFunction get_interface_name) { | 118 GetInterfaceNameFunction get_interface_name) { |
119 std::map<int, std::string> ifnames; | 119 std::map<int, std::string> ifnames; |
120 | 120 |
121 for (internal::AddressTrackerLinux::AddressMap::const_iterator it = | 121 for (internal::AddressTrackerLinux::AddressMap::const_iterator it = |
122 address_map.begin(); | 122 address_map.begin(); |
123 it != address_map.end(); ++it) { | 123 it != address_map.end(); ++it) { |
124 // Ignore addresses whose links are not online. | 124 // Ignore addresses whose links are not online. |
125 if (online_links.find(it->second.ifa_index) == online_links.end()) | 125 if (online_links.find(it->second.ifa_index) == online_links.end()) |
126 continue; | 126 continue; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 std::string GetWifiSSID() { | 213 std::string GetWifiSSID() { |
214 NetworkInterfaceList networks; | 214 NetworkInterfaceList networks; |
215 if (GetNetworkList(&networks, INCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES)) { | 215 if (GetNetworkList(&networks, INCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES)) { |
216 return internal::GetWifiSSIDFromInterfaceListInternal( | 216 return internal::GetWifiSSIDFromInterfaceListInternal( |
217 networks, internal::GetInterfaceSSID); | 217 networks, internal::GetInterfaceSSID); |
218 } | 218 } |
219 return ""; | 219 return ""; |
220 } | 220 } |
221 | 221 |
222 } // namespace net | 222 } // namespace net |
OLD | NEW |