| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/net_util.h" | 5 #include "net/base/net_util.h" |
| 6 | 6 |
| 7 #include <iphlpapi.h> | 7 #include <iphlpapi.h> |
| 8 #include <wlanapi.h> | 8 #include <wlanapi.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 result = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapters, &len); | 194 result = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapters, &len); |
| 195 if (result != NO_ERROR) { | 195 if (result != NO_ERROR) { |
| 196 LOG(ERROR) << "GetAdaptersAddresses failed: " << result; | 196 LOG(ERROR) << "GetAdaptersAddresses failed: " << result; |
| 197 return false; | 197 return false; |
| 198 } | 198 } |
| 199 | 199 |
| 200 return internal::GetNetworkListImpl(networks, policy, is_xp, adapters); | 200 return internal::GetNetworkListImpl(networks, policy, is_xp, adapters); |
| 201 } | 201 } |
| 202 | 202 |
| 203 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() { | 203 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() { |
| 204 // TODO(rtenneti): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
| 205 tracked_objects::ScopedTracker tracking_profile1( | |
| 206 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 207 "422516 net_util_win::GetWifiPHYLayerProtocol1")); | |
| 208 const internal::WlanApi& wlanapi = internal::WlanApi::GetInstance(); | 204 const internal::WlanApi& wlanapi = internal::WlanApi::GetInstance(); |
| 209 if (!wlanapi.initialized) | 205 if (!wlanapi.initialized) |
| 210 return WIFI_PHY_LAYER_PROTOCOL_NONE; | 206 return WIFI_PHY_LAYER_PROTOCOL_NONE; |
| 211 | 207 |
| 212 internal::WlanHandle client; | 208 internal::WlanHandle client; |
| 213 DWORD cur_version = 0; | 209 DWORD cur_version = 0; |
| 214 const DWORD kMaxClientVersion = 2; | 210 const DWORD kMaxClientVersion = 2; |
| 215 // TODO(rtenneti): Remove ScopedTracker below once crbug.com/422516 is fixed. | 211 { |
| 216 tracked_objects::ScopedTracker tracking_profile2( | 212 // TODO(rtenneti): Remove ScopedTracker below once crbug.com/422516 is |
| 217 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 213 // fixed. |
| 218 "422516 net_util_win::GetWifiPHYLayerProtocol2")); | 214 tracked_objects::ScopedTracker tracking_profile( |
| 219 DWORD result = wlanapi.OpenHandle(kMaxClientVersion, &cur_version, &client); | 215 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 OpenHandle()")); |
| 220 if (result != ERROR_SUCCESS) | 216 DWORD result = wlanapi.OpenHandle(kMaxClientVersion, &cur_version, &client); |
| 221 return WIFI_PHY_LAYER_PROTOCOL_NONE; | 217 if (result != ERROR_SUCCESS) |
| 218 return WIFI_PHY_LAYER_PROTOCOL_NONE; |
| 219 } |
| 222 | 220 |
| 223 // TODO(rtenneti): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
| 224 tracked_objects::ScopedTracker tracking_profile3( | |
| 225 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 226 "422516 net_util_win::GetWifiPHYLayerProtocol3")); | |
| 227 WLAN_INTERFACE_INFO_LIST* interface_list_ptr = NULL; | 221 WLAN_INTERFACE_INFO_LIST* interface_list_ptr = NULL; |
| 228 result = wlanapi.enum_interfaces_func(client.Get(), NULL, | 222 DWORD result = |
| 229 &interface_list_ptr); | 223 wlanapi.enum_interfaces_func(client.Get(), NULL, &interface_list_ptr); |
| 230 if (result != ERROR_SUCCESS) | 224 if (result != ERROR_SUCCESS) |
| 231 return WIFI_PHY_LAYER_PROTOCOL_NONE; | 225 return WIFI_PHY_LAYER_PROTOCOL_NONE; |
| 232 scoped_ptr<WLAN_INTERFACE_INFO_LIST, internal::WlanApiDeleter> interface_list( | 226 scoped_ptr<WLAN_INTERFACE_INFO_LIST, internal::WlanApiDeleter> interface_list( |
| 233 interface_list_ptr); | 227 interface_list_ptr); |
| 234 | 228 |
| 235 // TODO(rtenneti): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
| 236 tracked_objects::ScopedTracker tracking_profile4( | |
| 237 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 238 "422516 net_util_win::GetWifiPHYLayerProtocol4")); | |
| 239 // Assume at most one connected wifi interface. | 229 // Assume at most one connected wifi interface. |
| 240 WLAN_INTERFACE_INFO* info = NULL; | 230 WLAN_INTERFACE_INFO* info = NULL; |
| 241 for (unsigned i = 0; i < interface_list->dwNumberOfItems; ++i) { | 231 for (unsigned i = 0; i < interface_list->dwNumberOfItems; ++i) { |
| 242 if (interface_list->InterfaceInfo[i].isState == | 232 if (interface_list->InterfaceInfo[i].isState == |
| 243 wlan_interface_state_connected) { | 233 wlan_interface_state_connected) { |
| 244 info = &interface_list->InterfaceInfo[i]; | 234 info = &interface_list->InterfaceInfo[i]; |
| 245 break; | 235 break; |
| 246 } | 236 } |
| 247 } | 237 } |
| 248 | 238 |
| 249 if (info == NULL) | 239 if (info == NULL) |
| 250 return WIFI_PHY_LAYER_PROTOCOL_NONE; | 240 return WIFI_PHY_LAYER_PROTOCOL_NONE; |
| 251 | 241 |
| 252 WLAN_CONNECTION_ATTRIBUTES* conn_info_ptr; | 242 WLAN_CONNECTION_ATTRIBUTES* conn_info_ptr; |
| 253 DWORD conn_info_size = 0; | 243 DWORD conn_info_size = 0; |
| 254 WLAN_OPCODE_VALUE_TYPE op_code; | 244 WLAN_OPCODE_VALUE_TYPE op_code; |
| 255 // TODO(rtenneti): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
| 256 tracked_objects::ScopedTracker tracking_profile5( | |
| 257 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 258 "422516 net_util_win::GetWifiPHYLayerProtocol5")); | |
| 259 result = wlanapi.query_interface_func( | 245 result = wlanapi.query_interface_func( |
| 260 client.Get(), &info->InterfaceGuid, wlan_intf_opcode_current_connection, | 246 client.Get(), &info->InterfaceGuid, wlan_intf_opcode_current_connection, |
| 261 NULL, &conn_info_size, reinterpret_cast<VOID**>(&conn_info_ptr), | 247 NULL, &conn_info_size, reinterpret_cast<VOID**>(&conn_info_ptr), |
| 262 &op_code); | 248 &op_code); |
| 263 if (result != ERROR_SUCCESS) | 249 if (result != ERROR_SUCCESS) |
| 264 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; | 250 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; |
| 265 scoped_ptr<WLAN_CONNECTION_ATTRIBUTES, internal::WlanApiDeleter> conn_info( | 251 scoped_ptr<WLAN_CONNECTION_ATTRIBUTES, internal::WlanApiDeleter> conn_info( |
| 266 conn_info_ptr); | 252 conn_info_ptr); |
| 267 | 253 |
| 268 switch (conn_info->wlanAssociationAttributes.dot11PhyType) { | 254 switch (conn_info->wlanAssociationAttributes.dot11PhyType) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 scoped_ptr<ScopedWifiOptions> SetWifiOptions(int options) { | 326 scoped_ptr<ScopedWifiOptions> SetWifiOptions(int options) { |
| 341 return scoped_ptr<ScopedWifiOptions>(new WifiOptionSetter(options)); | 327 return scoped_ptr<ScopedWifiOptions>(new WifiOptionSetter(options)); |
| 342 } | 328 } |
| 343 | 329 |
| 344 std::string GetWifiSSID() { | 330 std::string GetWifiSSID() { |
| 345 NOTIMPLEMENTED(); | 331 NOTIMPLEMENTED(); |
| 346 return ""; | 332 return ""; |
| 347 } | 333 } |
| 348 | 334 |
| 349 } // namespace net | 335 } // namespace net |
| OLD | NEW |