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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 return; | 279 return; |
280 | 280 |
281 DWORD cur_version = 0; | 281 DWORD cur_version = 0; |
282 const DWORD kMaxClientVersion = 2; | 282 const DWORD kMaxClientVersion = 2; |
283 DWORD result = wlanapi.OpenHandle( | 283 DWORD result = wlanapi.OpenHandle( |
284 kMaxClientVersion, &cur_version, &client_); | 284 kMaxClientVersion, &cur_version, &client_); |
285 if (result != ERROR_SUCCESS) | 285 if (result != ERROR_SUCCESS) |
286 return; | 286 return; |
287 | 287 |
288 WLAN_INTERFACE_INFO_LIST* interface_list_ptr = NULL; | 288 WLAN_INTERFACE_INFO_LIST* interface_list_ptr = NULL; |
289 result = wlanapi.enum_interfaces_func(client_, NULL, &interface_list_ptr); | 289 result = wlanapi.enum_interfaces_func(client_.Get(), NULL, |
| 290 &interface_list_ptr); |
290 if (result != ERROR_SUCCESS) | 291 if (result != ERROR_SUCCESS) |
291 return; | 292 return; |
292 scoped_ptr<WLAN_INTERFACE_INFO_LIST, internal::WlanApiDeleter> | 293 scoped_ptr<WLAN_INTERFACE_INFO_LIST, internal::WlanApiDeleter> |
293 interface_list(interface_list_ptr); | 294 interface_list(interface_list_ptr); |
294 | 295 |
295 for (unsigned i = 0; i < interface_list->dwNumberOfItems; ++i) { | 296 for (unsigned i = 0; i < interface_list->dwNumberOfItems; ++i) { |
296 WLAN_INTERFACE_INFO* info = &interface_list->InterfaceInfo[i]; | 297 WLAN_INTERFACE_INFO* info = &interface_list->InterfaceInfo[i]; |
297 if (options & WIFI_OPTIONS_DISABLE_SCAN) { | 298 if (options & WIFI_OPTIONS_DISABLE_SCAN) { |
298 BOOL data = false; | 299 BOOL data = false; |
299 wlanapi.set_interface_func(client_, | 300 wlanapi.set_interface_func(client_.Get(), |
300 &info->InterfaceGuid, | 301 &info->InterfaceGuid, |
301 wlan_intf_opcode_background_scan_enabled, | 302 wlan_intf_opcode_background_scan_enabled, |
302 sizeof(data), | 303 sizeof(data), |
303 &data, | 304 &data, |
304 NULL); | 305 NULL); |
305 } | 306 } |
306 if (options & WIFI_OPTIONS_MEDIA_STREAMING_MODE) { | 307 if (options & WIFI_OPTIONS_MEDIA_STREAMING_MODE) { |
307 BOOL data = true; | 308 BOOL data = true; |
308 wlanapi.set_interface_func(client_, | 309 wlanapi.set_interface_func(client_.Get(), |
309 &info->InterfaceGuid, | 310 &info->InterfaceGuid, |
310 wlan_intf_opcode_media_streaming_mode, | 311 wlan_intf_opcode_media_streaming_mode, |
311 sizeof(data), | 312 sizeof(data), |
312 &data, | 313 &data, |
313 NULL); | 314 NULL); |
314 } | 315 } |
315 } | 316 } |
316 } | 317 } |
317 | 318 |
318 private: | 319 private: |
319 internal::WlanHandle client_; | 320 internal::WlanHandle client_; |
320 }; | 321 }; |
321 | 322 |
322 scoped_ptr<ScopedWifiOptions> SetWifiOptions(int options) { | 323 scoped_ptr<ScopedWifiOptions> SetWifiOptions(int options) { |
323 return scoped_ptr<ScopedWifiOptions>(new WifiOptionSetter(options)); | 324 return scoped_ptr<ScopedWifiOptions>(new WifiOptionSetter(options)); |
324 } | 325 } |
325 | 326 |
326 } // namespace net | 327 } // namespace net |
OLD | NEW |