mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Paul Stewart | 735eab5 | 2013-03-29 09:19:23 -0700 | [diff] [blame] | 5 | #ifndef SHILL_WIFI_H_ |
| 6 | #define SHILL_WIFI_H_ |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 7 | |
Gary Morain | 22601da | 2012-03-16 10:48:39 -0700 | [diff] [blame] | 8 | // A WiFi device represents a wireless network interface implemented as an IEEE |
| 9 | // 802.11 station. An Access Point (AP) (or, more correctly, a Basic Service |
| 10 | // Set(BSS)) is represented by a WiFiEndpoint. An AP provides a WiFiService, |
| 11 | // which is the same concept as Extended Service Set (ESS) in 802.11, |
| 12 | // identified by an SSID. A WiFiService includes zero or more WiFiEndpoints |
| 13 | // that provide that service. |
| 14 | // |
| 15 | // A WiFi device interacts with a real device through WPA Supplicant. |
| 16 | // Wifi::Start() creates a connection to WPA Supplicant, represented by |
| 17 | // |supplicant_interface_proxy_|. [1] |
| 18 | // |
| 19 | // A WiFi device becomes aware of WiFiEndpoints through BSSAdded signals from |
| 20 | // WPA Supplicant, which identifies them by a "path". The WiFi object maintains |
| 21 | // an EndpointMap in |endpoint_by_rpcid_|, in which the key is the "path" and |
| 22 | // the value is a pointer to a WiFiEndpoint object. When a WiFiEndpoint is |
| 23 | // added, it is associated with a WiFiService. |
| 24 | // |
Gary Morain | 22601da | 2012-03-16 10:48:39 -0700 | [diff] [blame] | 25 | // The WiFi device connects to a WiFiService, not a WiFiEndpoint, through WPA |
| 26 | // Supplicant. It is the job of WPA Supplicant to select a BSS (aka |
| 27 | // WiFiEndpoint) to connect to. The protocol for establishing a connection is |
| 28 | // as follows: |
| 29 | // |
| 30 | // 1. The WiFi device sends AddNetwork to WPA Supplicant, which returns a |
| 31 | // "network path" when done. |
| 32 | // |
| 33 | // 2. The WiFi device sends SelectNetwork, indicating the network path |
| 34 | // received in 1, to WPA Supplicant, which begins the process of associating |
| 35 | // with an AP in the ESS. At this point the WiFiService which is being |
| 36 | // connected is called the |pending_service_|. |
| 37 | // |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 38 | // 3. During association to an EAP-TLS network, WPA Supplicant can send |
| 39 | // multiple "Certification" events, which provide information about the |
| 40 | // identity of the remote entity. |
| 41 | // |
| 42 | // 4. When association is complete, WPA Supplicant sends a PropertiesChanged |
| 43 | // signal to the WiFi device, indicating a change in the CurrentBSS. The |
| 44 | // WiFiService indicated by the new value of CurrentBSS is set as the |
| 45 | // |current_service_|, and |pending_service_| is (normally) cleared. |
Gary Morain | 22601da | 2012-03-16 10:48:39 -0700 | [diff] [blame] | 46 | // |
| 47 | // Some key things to notice are 1) WPA Supplicant does the work of selecting |
| 48 | // the AP (aka WiFiEndpoint) and it tells the WiFi device which AP it selected. |
| 49 | // 2) The process of connecting is asynchronous. There is a |current_service_| |
| 50 | // to which the WiFi device is presently using and a |pending_service_| to which |
| 51 | // the WiFi device has initiated a connection. |
| 52 | // |
| 53 | // A WiFi device is notified that an AP has gone away via the BSSRemoved signal. |
| 54 | // When the last WiFiEndpoint of a WiFiService is removed, the WiFiService |
| 55 | // itself is deleted. |
| 56 | // |
| 57 | // TODO(gmorain): Add explanation of hidden SSIDs. |
| 58 | // |
| 59 | // WPA Supplicant's PropertiesChanged signal communicates changes in the state |
| 60 | // of WPA Supplicant's current service. This state is stored in |
| 61 | // |supplicant_state_| and reflects WPA Supplicant's view of the state of the |
| 62 | // connection to an AP. Changes in this state sometimes cause state changes in |
| 63 | // the WiFiService to which a WiFi device is connected. For example, when WPA |
| 64 | // Supplicant signals the new state to be "completed", then the WiFiService |
| 65 | // state gets changed to "configuring". State change notifications are not |
| 66 | // reliable because WPA Supplicant may coalesce state changes in quick |
| 67 | // succession so that only the last of the changes is signaled. |
| 68 | // |
| 69 | // Notes: |
| 70 | // |
| 71 | // 1. Shill's definition of the interface is described in |
| 72 | // shill/dbus_bindings/supplicant-interface.xml, and the WPA Supplicant's |
| 73 | // description of the same interface is in |
| 74 | // third_party/wpa_supplicant/doc/dbus.doxygen. |
| 75 | |
mukesh agrawal | 5c05b29 | 2012-03-07 10:12:52 -0800 | [diff] [blame] | 76 | #include <time.h> |
| 77 | |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 78 | #include <map> |
Wade Guthrie | 92d0636 | 2013-04-25 15:41:30 -0700 | [diff] [blame] | 79 | #include <set> |
Chris Masone | 46eaaf5 | 2011-05-24 13:08:30 -0700 | [diff] [blame] | 80 | #include <string> |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 81 | #include <vector> |
Chris Masone | 46eaaf5 | 2011-05-24 13:08:30 -0700 | [diff] [blame] | 82 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 83 | #include <base/callback_forward.h> |
mukesh agrawal | b66c646 | 2012-05-07 11:45:25 -0700 | [diff] [blame] | 84 | #include <base/cancelable_callback.h> |
Wade Guthrie | 2edd58b | 2013-05-23 11:16:08 -0700 | [diff] [blame] | 85 | #include <base/file_path.h> |
Paul Stewart | 735eab5 | 2013-03-29 09:19:23 -0700 | [diff] [blame] | 86 | #include <base/memory/scoped_ptr.h> |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 87 | #include <base/memory/weak_ptr.h> |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 88 | #include <dbus-c++/dbus.h> |
Paul Stewart | 6ab23a9 | 2011-11-09 17:17:47 -0800 | [diff] [blame] | 89 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 90 | #include <metrics/timer.h> |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 91 | |
Darin Petkov | 2b8e44e | 2012-06-25 15:13:26 +0200 | [diff] [blame] | 92 | #include "shill/dbus_manager.h" |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 93 | #include "shill/device.h" |
Paul Stewart | 26b327e | 2011-10-19 11:38:09 -0700 | [diff] [blame] | 94 | #include "shill/event_dispatcher.h" |
Wade Guthrie | b9e0ee7 | 2013-05-31 09:23:30 -0700 | [diff] [blame] | 95 | #include "shill/metrics.h" |
Gary Morain | ac1bdb4 | 2012-02-16 17:42:29 -0800 | [diff] [blame] | 96 | #include "shill/power_manager.h" |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 97 | #include "shill/refptr_types.h" |
Paul Stewart | 1369c2b | 2013-01-11 05:41:26 -0800 | [diff] [blame] | 98 | #include "shill/service.h" |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 99 | #include "shill/supplicant_event_delegate_interface.h" |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 100 | |
| 101 | namespace shill { |
| 102 | |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 103 | class Error; |
Gaurav Shah | 6d2c72d | 2012-10-16 16:30:44 -0700 | [diff] [blame] | 104 | class GeolocationInfo; |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 105 | class KeyValueStore; |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 106 | class NetlinkManager; |
Wade Guthrie | 92d0636 | 2013-04-25 15:41:30 -0700 | [diff] [blame] | 107 | class NetlinkMessage; |
Wade Guthrie | 7347bf2 | 2013-04-30 11:21:51 -0700 | [diff] [blame] | 108 | class Nl80211Message; |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 109 | class ProxyFactory; |
Wade Guthrie | 5a4e2ef | 2013-04-30 12:51:39 -0700 | [diff] [blame] | 110 | class ScanSession; |
Paul Stewart | 735eab5 | 2013-03-29 09:19:23 -0700 | [diff] [blame] | 111 | class SupplicantEAPStateHandler; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 112 | class SupplicantInterfaceProxyInterface; |
| 113 | class SupplicantProcessProxyInterface; |
Paul Stewart | 3c50401 | 2013-01-17 17:49:58 -0800 | [diff] [blame] | 114 | class WiFiProvider; |
mukesh agrawal | 445e72c | 2011-06-22 11:13:50 -0700 | [diff] [blame] | 115 | class WiFiService; |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 116 | |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 117 | // WiFi class. Specialization of Device for WiFi. |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 118 | class WiFi : public Device, public SupplicantEventDelegateInterface { |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 119 | public: |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 120 | WiFi(ControlInterface *control_interface, |
| 121 | EventDispatcher *dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 122 | Metrics *metrics, |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 123 | Manager *manager, |
Chris Masone | 626719f | 2011-08-18 16:58:48 -0700 | [diff] [blame] | 124 | const std::string &link, |
| 125 | const std::string &address, |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 126 | int interface_index); |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 127 | virtual ~WiFi(); |
Darin Petkov | c086531 | 2011-09-16 15:31:20 -0700 | [diff] [blame] | 128 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 129 | virtual void Start(Error *error, const EnabledStateChangedCallback &callback); |
| 130 | virtual void Stop(Error *error, const EnabledStateChangedCallback &callback); |
Wade Guthrie | 4823f4f | 2013-07-25 10:03:03 -0700 | [diff] [blame] | 131 | virtual void Scan(ScanType scan_type, Error *error, |
| 132 | const std::string &reason); |
mukesh agrawal | 2f9df4e | 2012-08-08 12:29:20 -0700 | [diff] [blame] | 133 | // Callback for system resume. If this WiFi device is idle, a scan |
| 134 | // is initiated. Additionally, the base class implementation is |
| 135 | // invoked unconditionally. |
Christopher Wiley | 5519e9e | 2013-01-08 16:55:56 -0800 | [diff] [blame] | 136 | virtual void OnAfterResume(); |
| 137 | // Callback for when a service is configured with an IP. |
| 138 | virtual void OnConnected(); |
Paul Stewart | f6f9648 | 2013-07-12 12:49:15 -0700 | [diff] [blame] | 139 | // Callback for when a service fails to configure with an IP. |
| 140 | virtual void OnIPConfigFailure() override; |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 141 | |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 142 | // Implementation of SupplicantEventDelegateInterface. These methods |
| 143 | // are called by SupplicantInterfaceProxy, in response to events from |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 144 | // wpa_supplicant. |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 145 | virtual void BSSAdded( |
| 146 | const ::DBus::Path &BSS, |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 147 | const std::map<std::string, ::DBus::Variant> &properties); |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 148 | virtual void BSSRemoved(const ::DBus::Path &BSS); |
| 149 | virtual void Certification( |
| 150 | const std::map<std::string, ::DBus::Variant> &properties); |
| 151 | virtual void EAPEvent( |
| 152 | const std::string &status, const std::string ¶meter); |
| 153 | virtual void PropertiesChanged( |
| 154 | const std::map<std::string, ::DBus::Variant> &properties); |
| 155 | virtual void ScanDone(); |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 156 | |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 157 | // Called by WiFiService. |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 158 | virtual void ConnectTo( |
| 159 | WiFiService *service, |
mukesh agrawal | 6489632 | 2011-12-01 01:13:10 +0000 | [diff] [blame] | 160 | std::map<std::string, ::DBus::Variant> service_params); |
Paul Stewart | 835934a | 2012-12-06 19:27:09 -0800 | [diff] [blame] | 161 | // If |service| is connected, initiate the process of disconnecting it. |
| 162 | // Otherwise, if it a pending or current service, discontinue the process |
| 163 | // of connecting and return |service| to the idle state. |
mukesh agrawal | 0ed0f2e | 2011-12-05 20:36:17 +0000 | [diff] [blame] | 164 | virtual void DisconnectFrom(WiFiService *service); |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 165 | virtual bool IsIdle() const; |
Paul Stewart | 835934a | 2012-12-06 19:27:09 -0800 | [diff] [blame] | 166 | // Clear any cached credentials wpa_supplicant may be holding for |
| 167 | // |service|. This has a side-effect of disconnecting the service |
| 168 | // if it is connected. |
| 169 | virtual void ClearCachedCredentials(const WiFiService *service); |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 170 | |
mukesh agrawal | b20776f | 2012-02-10 16:00:36 -0800 | [diff] [blame] | 171 | // Called by WiFiEndpoint. |
Paul Stewart | 3c50401 | 2013-01-17 17:49:58 -0800 | [diff] [blame] | 172 | virtual void NotifyEndpointChanged(const WiFiEndpointConstRefPtr &endpoint); |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 173 | |
mukesh agrawal | 16bc1b8 | 2012-02-09 18:38:26 -0800 | [diff] [blame] | 174 | // Utility, used by WiFiService and WiFiEndpoint. |
| 175 | // Replace non-ASCII characters with '?'. Return true if one or more |
| 176 | // characters were changed. |
| 177 | static bool SanitizeSSID(std::string *ssid); |
| 178 | |
Darin Petkov | 50cb78a | 2013-02-06 16:17:49 +0100 | [diff] [blame] | 179 | // Formats |ssid| for logging purposes, to ease scrubbing. |
| 180 | static std::string LogSSID(const std::string &ssid); |
| 181 | |
Paul Stewart | 3c508e1 | 2012-08-09 11:40:06 -0700 | [diff] [blame] | 182 | // Called by Linkmonitor (overriden from Device superclass). |
| 183 | virtual void OnLinkMonitorFailure(); |
| 184 | |
Wade Guthrie | 8bc5088 | 2012-10-31 16:23:20 -0700 | [diff] [blame] | 185 | bool IsCurrentService(const WiFiServiceRefPtr service) { |
| 186 | return service.get() == current_service_.get(); |
| 187 | } |
| 188 | |
Arman Uguray | ed8e610 | 2012-11-29 14:47:20 -0800 | [diff] [blame] | 189 | // Overridden from Device superclass |
Gaurav Shah | 6d2c72d | 2012-10-16 16:30:44 -0700 | [diff] [blame] | 190 | virtual std::vector<GeolocationInfo> GetGeolocationObjects() const; |
| 191 | |
Arman Uguray | ed8e610 | 2012-11-29 14:47:20 -0800 | [diff] [blame] | 192 | // Overridden from Device superclass |
| 193 | virtual bool ShouldUseArpGateway() const; |
| 194 | |
Paul Stewart | 3c50401 | 2013-01-17 17:49:58 -0800 | [diff] [blame] | 195 | // Called by a WiFiService when it disassociates itself from this Device. |
| 196 | virtual void DisassociateFromService(const WiFiServiceRefPtr &service); |
| 197 | |
Albert Chaulk | 0e1cdea | 2013-02-27 15:32:55 -0800 | [diff] [blame] | 198 | // Called by a WiFiService when it unloads to destroy its lease file. |
| 199 | virtual void DestroyServiceLease(const WiFiService &service); |
| 200 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 201 | private: |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 202 | enum ScanMethod { |
| 203 | kScanMethodNone, |
| 204 | kScanMethodFull, |
| 205 | kScanMethodProgressive, |
| 206 | kScanMethodProgressiveErrorToFull, |
| 207 | kScanMethodProgressiveFinishedToFull |
| 208 | }; |
| 209 | enum ScanState { |
| 210 | kScanIdle, |
| 211 | kScanScanning, |
Wade Guthrie | df6d61b | 2013-07-17 11:43:55 -0700 | [diff] [blame] | 212 | kScanTransitionToConnecting, |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 213 | kScanConnecting, |
| 214 | kScanConnected, |
| 215 | kScanFoundNothing |
| 216 | }; |
| 217 | |
Paul Stewart | e369ece | 2012-05-22 09:11:03 -0700 | [diff] [blame] | 218 | friend class WiFiObjectTest; // access to supplicant_*_proxy_, link_up_ |
Paul Stewart | 1aff730 | 2012-08-04 20:04:47 -0700 | [diff] [blame] | 219 | friend class WiFiTimerTest; // kNumFastScanAttempts, kFastScanIntervalSeconds |
Darin Petkov | 4a66cc5 | 2012-06-15 10:08:29 +0200 | [diff] [blame] | 220 | FRIEND_TEST(WiFiMainTest, AppendBgscan); |
Wade Guthrie | df6d61b | 2013-07-17 11:43:55 -0700 | [diff] [blame] | 221 | FRIEND_TEST(WiFiMainTest, ConnectToServiceNotPending); // ScanState |
| 222 | FRIEND_TEST(WiFiMainTest, ConnectToWithError); // ScanState |
| 223 | FRIEND_TEST(WiFiMainTest, ConnectWhileNotScanning); // ScanState |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 224 | FRIEND_TEST(WiFiMainTest, CurrentBSSChangedUpdateServiceEndpoint); |
Christopher Wiley | c618448 | 2012-10-24 15:31:56 -0700 | [diff] [blame] | 225 | FRIEND_TEST(WiFiMainTest, DisconnectCurrentServiceWithErrors); |
Paul Stewart | e369ece | 2012-05-22 09:11:03 -0700 | [diff] [blame] | 226 | FRIEND_TEST(WiFiMainTest, FlushBSSOnResume); // kMaxBSSResumeAgeSeconds |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 227 | FRIEND_TEST(WiFiMainTest, FullScanConnecting); // ScanMethod, ScanState |
| 228 | FRIEND_TEST(WiFiMainTest, FullScanConnectingToConnected); |
| 229 | FRIEND_TEST(WiFiMainTest, FullScanFindsNothing); // ScanMethod, ScanState |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 230 | FRIEND_TEST(WiFiMainTest, InitialSupplicantState); // kInterfaceStateUnknown |
Paul Stewart | 3c508e1 | 2012-08-09 11:40:06 -0700 | [diff] [blame] | 231 | FRIEND_TEST(WiFiMainTest, LinkMonitorFailure); // set_link_monitor() |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 232 | FRIEND_TEST(WiFiMainTest, ProgressiveScanConnectingToConnected); |
Wade Guthrie | df6d61b | 2013-07-17 11:43:55 -0700 | [diff] [blame] | 233 | FRIEND_TEST(WiFiMainTest, ProgressiveScanConnectingToNotFound); |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 234 | FRIEND_TEST(WiFiMainTest, ProgressiveScanError); // ScanMethod, ScanState |
| 235 | FRIEND_TEST(WiFiMainTest, ProgressiveScanFound); // ScanMethod, ScanState |
| 236 | FRIEND_TEST(WiFiMainTest, ProgressiveScanNotFound); // ScanMethod, ScanState |
Thieu Le | e41a72d | 2012-02-06 20:46:51 +0000 | [diff] [blame] | 237 | FRIEND_TEST(WiFiMainTest, ScanResults); // EndpointMap |
mukesh agrawal | 165e614 | 2011-11-22 02:22:56 +0000 | [diff] [blame] | 238 | FRIEND_TEST(WiFiMainTest, ScanResultsWithUpdates); // EndpointMap |
Wade Guthrie | df6d61b | 2013-07-17 11:43:55 -0700 | [diff] [blame] | 239 | FRIEND_TEST(WiFiMainTest, ScanStateHandleDisconnect); // ScanState |
| 240 | FRIEND_TEST(WiFiMainTest, ScanStateNotScanningNoUma); // ScanState |
Wade Guthrie | b9e0ee7 | 2013-05-31 09:23:30 -0700 | [diff] [blame] | 241 | FRIEND_TEST(WiFiMainTest, ScanStateUma); // ScanState, ScanMethod |
mukesh agrawal | c4f368f | 2012-06-04 19:45:52 -0700 | [diff] [blame] | 242 | FRIEND_TEST(WiFiMainTest, Stop); // weak_ptr_factory_ |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 243 | FRIEND_TEST(WiFiMainTest, TimeoutPendingServiceWithEndpoints); |
Darin Petkov | 60ceaf3 | 2012-10-18 10:36:01 +0200 | [diff] [blame] | 244 | FRIEND_TEST(WiFiMainTest, VerifyPaths); |
Darin Petkov | 4a66cc5 | 2012-06-15 10:08:29 +0200 | [diff] [blame] | 245 | FRIEND_TEST(WiFiPropertyTest, BgscanMethodProperty); // bgscan_method_ |
Paul Stewart | 1aff730 | 2012-08-04 20:04:47 -0700 | [diff] [blame] | 246 | FRIEND_TEST(WiFiTimerTest, FastRescan); // kFastScanIntervalSeconds |
Paul Stewart | 6ab23a9 | 2011-11-09 17:17:47 -0800 | [diff] [blame] | 247 | |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 248 | typedef std::map<const std::string, WiFiEndpointRefPtr> EndpointMap; |
Paul Stewart | 835934a | 2012-12-06 19:27:09 -0800 | [diff] [blame] | 249 | typedef std::map<const WiFiService *, std::string> ReverseServiceMap; |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 250 | |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 251 | static const char *kDefaultBgscanMethod; |
| 252 | static const uint16 kDefaultBgscanShortIntervalSeconds; |
| 253 | static const int32 kDefaultBgscanSignalThresholdDbm; |
| 254 | static const uint16 kDefaultScanIntervalSeconds; |
Darin Petkov | 4a66cc5 | 2012-06-15 10:08:29 +0200 | [diff] [blame] | 255 | static const uint16 kBackgroundScanIntervalSeconds; |
mukesh agrawal | 5c05b29 | 2012-03-07 10:12:52 -0800 | [diff] [blame] | 256 | static const time_t kMaxBSSResumeAgeSeconds; |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 257 | static const char kInterfaceStateUnknown[]; |
mukesh agrawal | f202817 | 2012-03-13 14:20:22 -0700 | [diff] [blame] | 258 | // Delay between scans when supplicant finds "No suitable network". |
| 259 | static const time_t kRescanIntervalSeconds; |
Paul Stewart | e369ece | 2012-05-22 09:11:03 -0700 | [diff] [blame] | 260 | // Number of times to quickly attempt a scan after startup / disconnect. |
| 261 | static const int kNumFastScanAttempts; |
| 262 | static const int kFastScanIntervalSeconds; |
Paul Stewart | 2b05e62 | 2012-07-13 20:38:44 -0700 | [diff] [blame] | 263 | static const int kPendingTimeoutSeconds; |
Paul Stewart | 4466392 | 2012-07-30 11:03:03 -0700 | [diff] [blame] | 264 | static const int kReconnectTimeoutSeconds; |
Wade Guthrie | 5a4e2ef | 2013-04-30 12:51:39 -0700 | [diff] [blame] | 265 | static const size_t kMinumumFrequenciesToScan; |
Wade Guthrie | 2edd58b | 2013-05-23 11:16:08 -0700 | [diff] [blame] | 266 | static const float kDefaultFractionPerScan; |
Wade Guthrie | 5a4e2ef | 2013-04-30 12:51:39 -0700 | [diff] [blame] | 267 | static const char kProgressiveScanFlagFile[]; |
Wade Guthrie | 2edd58b | 2013-05-23 11:16:08 -0700 | [diff] [blame] | 268 | // TODO(wdg): Remove after progressive scan field trial is over. |
| 269 | static const char kProgressiveScanFieldTrialFlagFile[]; |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 270 | |
Wade Guthrie | 92d0636 | 2013-04-25 15:41:30 -0700 | [diff] [blame] | 271 | // Gets the list of frequencies supported by this device. |
Wade Guthrie | 2edd58b | 2013-05-23 11:16:08 -0700 | [diff] [blame] | 272 | // TODO(wdg): Remove after progressive scan field trial is over. |
| 273 | void ParseFieldTrialFile(const FilePath &field_trial_file_path); |
Wade Guthrie | 92d0636 | 2013-04-25 15:41:30 -0700 | [diff] [blame] | 274 | void ConfigureScanFrequencies(); |
Darin Petkov | 4a66cc5 | 2012-06-15 10:08:29 +0200 | [diff] [blame] | 275 | void AppendBgscan(WiFiService *service, |
| 276 | std::map<std::string, DBus::Variant> *service_params) const; |
| 277 | std::string GetBgscanMethod(const int &argument, Error *error); |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 278 | uint16 GetBgscanShortInterval(Error */* error */) { |
| 279 | return bgscan_short_interval_seconds_; |
| 280 | } |
| 281 | int32 GetBgscanSignalThreshold(Error */* error */) { |
| 282 | return bgscan_signal_threshold_dbm_; |
| 283 | } |
| 284 | uint16 GetScanInterval(Error */* error */) { return scan_interval_seconds_; } |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 285 | bool GetScanPending(Error */* error */); |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 286 | bool SetBgscanMethod( |
Darin Petkov | 4a66cc5 | 2012-06-15 10:08:29 +0200 | [diff] [blame] | 287 | const int &argument, const std::string &method, Error *error); |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 288 | bool SetBgscanShortInterval(const uint16 &seconds, Error *error); |
| 289 | bool SetBgscanSignalThreshold(const int32 &dbm, Error *error); |
| 290 | bool SetScanInterval(const uint16 &seconds, Error *error); |
Darin Petkov | 4a66cc5 | 2012-06-15 10:08:29 +0200 | [diff] [blame] | 291 | void ClearBgscanMethod(const int &argument, Error *error); |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 292 | |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 293 | void CurrentBSSChanged(const ::DBus::Path &new_bss); |
Paul Stewart | 835934a | 2012-12-06 19:27:09 -0800 | [diff] [blame] | 294 | // Return the RPC identifier associated with the wpa_supplicant network |
| 295 | // entry created for |service|. If one does not exist, an empty string |
| 296 | // is returned, and |error| is populated. |
| 297 | std::string FindNetworkRpcidForService(const WiFiService *service, |
| 298 | Error *error); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 299 | void HandleDisconnect(); |
| 300 | void HandleRoam(const ::DBus::Path &new_bssid); |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 301 | void BSSAddedTask(const ::DBus::Path &BSS, |
| 302 | const std::map<std::string, ::DBus::Variant> &properties); |
| 303 | void BSSRemovedTask(const ::DBus::Path &BSS); |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 304 | void CertificationTask( |
| 305 | const std::map<std::string, ::DBus::Variant> &properties); |
Paul Stewart | db0f917 | 2012-11-30 16:48:09 -0800 | [diff] [blame] | 306 | void EAPEventTask(const std::string &status, const std::string ¶meter); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 307 | void PropertiesChangedTask( |
| 308 | const std::map<std::string, ::DBus::Variant> &properties); |
mukesh agrawal | dc42bb3 | 2011-07-28 10:40:26 -0700 | [diff] [blame] | 309 | void ScanDoneTask(); |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 310 | // UpdateScanStateAfterScanDone is spawned as a task from ScanDoneTask in |
| 311 | // order to guarantee that it is run after the start of any connections that |
| 312 | // result from a scan. This works because supplicant sends all BSSAdded |
| 313 | // signals to shill before it sends a ScanDone signal. The code that |
| 314 | // handles those signals launch tasks such that the tasks have the following |
| 315 | // dependencies (an arrow from X->Y indicates X is guaranteed to run before |
| 316 | // Y): |
| 317 | // |
| 318 | // [BSSAdded]-->[BssAddedTask]-->[SortServiceTask (calls ConnectTo)] |
| 319 | // | | | |
| 320 | // V V V |
| 321 | // [ScanDone]-->[ScanDoneTask]-->[UpdateScanStateAfterScanDone] |
| 322 | void UpdateScanStateAfterScanDone(); |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 323 | void ScanTask(); |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 324 | void StateChanged(const std::string &new_state); |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 325 | // Heuristic check if a connection failure was due to bad credentials. |
Paul Stewart | 1369c2b | 2013-01-11 05:41:26 -0800 | [diff] [blame] | 326 | // Returns true and puts type of failure in |failure| if a credential |
| 327 | // problem is detected. |
Paul Stewart | bca08f8 | 2013-07-09 16:32:37 -0700 | [diff] [blame] | 328 | bool SuspectCredentials(WiFiServiceRefPtr service, |
Paul Stewart | 1369c2b | 2013-01-11 05:41:26 -0800 | [diff] [blame] | 329 | Service::ConnectFailure *failure) const; |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 330 | void HelpRegisterDerivedInt32( |
| 331 | PropertyStore *store, |
| 332 | const std::string &name, |
| 333 | int32(WiFi::*get)(Error *error), |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 334 | bool(WiFi::*set)(const int32 &value, Error *error)); |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 335 | void HelpRegisterDerivedUint16( |
| 336 | PropertyStore *store, |
| 337 | const std::string &name, |
| 338 | uint16(WiFi::*get)(Error *error), |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 339 | bool(WiFi::*set)(const uint16 &value, Error *error)); |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 340 | void HelpRegisterConstDerivedBool( |
| 341 | PropertyStore *store, |
| 342 | const std::string &name, |
| 343 | bool(WiFi::*get)(Error *error)); |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 344 | |
Paul Stewart | 835934a | 2012-12-06 19:27:09 -0800 | [diff] [blame] | 345 | // Disable a network entry in wpa_supplicant, and catch any exception |
| 346 | // that occurs. Returns false if an exception occurred, true otherwise. |
| 347 | bool DisableNetwork(const ::DBus::Path &network); |
| 348 | // Disable the wpa_supplicant network entry associated with |service|. |
| 349 | // Any cached credentials stored in wpa_supplicant related to this |
| 350 | // network entry will be preserved. This will have the side-effect of |
| 351 | // disconnecting this service if it is currently connected. Returns |
| 352 | // true if successful, otherwise returns false and populates |error| |
| 353 | // with the reason for failure. |
| 354 | virtual bool DisableNetworkForService( |
| 355 | const WiFiService *service, Error *error); |
Paul Stewart | 71f6ecd | 2012-09-13 14:52:18 -0700 | [diff] [blame] | 356 | // Remove a network entry from wpa_supplicant, and catch any exception |
| 357 | // that occurs. Returns false if an exception occurred, true otherwise. |
| 358 | bool RemoveNetwork(const ::DBus::Path &network); |
Paul Stewart | 835934a | 2012-12-06 19:27:09 -0800 | [diff] [blame] | 359 | // Remove the wpa_supplicant network entry associated with |service|. |
| 360 | // Any cached credentials stored in wpa_supplicant related to this |
| 361 | // network entry will be removed. This will have the side-effect of |
| 362 | // disconnecting this service if it is currently connected. Returns |
| 363 | // true if successful, otherwise returns false and populates |error| |
| 364 | // with the reason for failure. |
| 365 | virtual bool RemoveNetworkForService( |
| 366 | const WiFiService *service, Error *error); |
Wade Guthrie | 5a4e2ef | 2013-04-30 12:51:39 -0700 | [diff] [blame] | 367 | // Perform the next in a series of progressive scans. |
| 368 | void ProgressiveScanTask(); |
| 369 | // Recovers from failed progressive scan. |
| 370 | void OnFailedProgressiveScan(); |
Paul Stewart | e369ece | 2012-05-22 09:11:03 -0700 | [diff] [blame] | 371 | // Restart fast scanning after disconnection. |
| 372 | void RestartFastScanAttempts(); |
mukesh agrawal | b66c646 | 2012-05-07 11:45:25 -0700 | [diff] [blame] | 373 | // Schedules a scan attempt at time |scan_interval_seconds_| in the |
| 374 | // future. Cancels any currently pending scan timer. |
| 375 | void StartScanTimer(); |
| 376 | // Cancels any currently pending scan timer. |
| 377 | void StopScanTimer(); |
| 378 | // Initiates a scan, if idle. Reschedules the scan timer regardless. |
| 379 | void ScanTimerHandler(); |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 380 | // Abort any current scan (at the shill-level; let any request that's |
| 381 | // already gone out finish). |
| 382 | void AbortScan(); |
Paul Stewart | 2b05e62 | 2012-07-13 20:38:44 -0700 | [diff] [blame] | 383 | // Starts a timer in order to limit the length of an attempt to |
| 384 | // connect to a pending network. |
| 385 | void StartPendingTimer(); |
| 386 | // Cancels any currently pending network timer. |
| 387 | void StopPendingTimer(); |
| 388 | // Aborts a pending network that is taking too long to connect. |
| 389 | void PendingTimeoutHandler(); |
Paul Stewart | 4466392 | 2012-07-30 11:03:03 -0700 | [diff] [blame] | 390 | // Starts a timer in order to limit the length of an attempt to |
| 391 | // reconnect to the current network. |
| 392 | void StartReconnectTimer(); |
| 393 | // Stops any pending reconnect timer. |
| 394 | void StopReconnectTimer(); |
| 395 | // Disconnects from the current service that is taking too long |
| 396 | // to reconnect on its own. |
| 397 | void ReconnectTimeoutHandler(); |
Paul Stewart | 2b05e62 | 2012-07-13 20:38:44 -0700 | [diff] [blame] | 398 | // Sets the current pending service. If the argument is non-NULL, |
| 399 | // the Pending timer is started and the associated service is set |
| 400 | // to "Associating", otherwise it is stopped. |
| 401 | void SetPendingService(const WiFiServiceRefPtr &service); |
Gary Morain | ac1bdb4 | 2012-02-16 17:42:29 -0800 | [diff] [blame] | 402 | |
Darin Petkov | 2b8e44e | 2012-06-25 15:13:26 +0200 | [diff] [blame] | 403 | void OnSupplicantAppear(const std::string &owner); |
| 404 | void OnSupplicantVanish(); |
Paul Stewart | 5581d07 | 2012-12-17 17:30:20 -0800 | [diff] [blame] | 405 | // Called by ScopeLogger when WiFi debug scope is enabled/disabled. |
| 406 | void OnWiFiDebugScopeChanged(bool enabled); |
Paul Stewart | a47c3c6 | 2012-12-18 12:14:29 -0800 | [diff] [blame] | 407 | // Enable or disable debugging for the current connection attempt. |
| 408 | void SetConnectionDebugging(bool enabled); |
Christopher Wiley | 5519e9e | 2013-01-08 16:55:56 -0800 | [diff] [blame] | 409 | // Enable high bitrates for the current network. High rates are disabled |
| 410 | // on the initial association and every reassociation afterward. |
| 411 | void EnableHighBitrates(); |
Darin Petkov | 2b8e44e | 2012-06-25 15:13:26 +0200 | [diff] [blame] | 412 | |
| 413 | void ConnectToSupplicant(); |
| 414 | |
| 415 | void Restart(); |
| 416 | |
Albert Chaulk | 0e1cdea | 2013-02-27 15:32:55 -0800 | [diff] [blame] | 417 | std::string GetServiceLeaseName(const WiFiService &service); |
| 418 | |
Wade Guthrie | 92d0636 | 2013-04-25 15:41:30 -0700 | [diff] [blame] | 419 | // Netlink message handler for NL80211_CMD_NEW_WIPHY messages; copies |
| 420 | // device's supported frequencies from that message into |
| 421 | // |all_scan_frequencies_|. |
Wade Guthrie | 7347bf2 | 2013-04-30 11:21:51 -0700 | [diff] [blame] | 422 | void OnNewWiphy(const Nl80211Message &nl80211_message); |
Wade Guthrie | 92d0636 | 2013-04-25 15:41:30 -0700 | [diff] [blame] | 423 | |
Wade Guthrie | b0def9f | 2013-07-12 13:49:18 -0700 | [diff] [blame] | 424 | void SetScanState(ScanState new_state, |
| 425 | ScanMethod new_method, |
| 426 | const char *reason); |
Wade Guthrie | b9e0ee7 | 2013-05-31 09:23:30 -0700 | [diff] [blame] | 427 | void ReportScanResultToUma(ScanState state, ScanMethod method); |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 428 | static std::string ScanStateString(ScanState state, ScanMethod type); |
| 429 | |
Paul Stewart | 3c50401 | 2013-01-17 17:49:58 -0800 | [diff] [blame] | 430 | // Pointer to the provider object that maintains WiFiService objects. |
| 431 | WiFiProvider *provider_; |
| 432 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 433 | base::WeakPtrFactory<WiFi> weak_ptr_factory_; |
| 434 | |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 435 | // Store cached copies of singletons for speed/ease of testing. |
| 436 | ProxyFactory *proxy_factory_; |
mukesh agrawal | 5c05b29 | 2012-03-07 10:12:52 -0800 | [diff] [blame] | 437 | Time *time_; |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 438 | |
Darin Petkov | 2b8e44e | 2012-06-25 15:13:26 +0200 | [diff] [blame] | 439 | DBusManager::CancelableAppearedCallback on_supplicant_appear_; |
| 440 | DBusManager::CancelableVanishedCallback on_supplicant_vanish_; |
| 441 | bool supplicant_present_; |
| 442 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 443 | scoped_ptr<SupplicantProcessProxyInterface> supplicant_process_proxy_; |
| 444 | scoped_ptr<SupplicantInterfaceProxyInterface> supplicant_interface_proxy_; |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 445 | // The rpcid used as the key is wpa_supplicant's D-Bus path for the |
| 446 | // Endpoint (BSS, in supplicant parlance). |
| 447 | EndpointMap endpoint_by_rpcid_; |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 448 | // Map from Services to the D-Bus path for the corresponding wpa_supplicant |
| 449 | // Network. |
| 450 | ReverseServiceMap rpcid_by_service_; |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 451 | // The Service we are presently connected to. May be NULL is we're not |
| 452 | // not connected to any Service. |
| 453 | WiFiServiceRefPtr current_service_; |
| 454 | // The Service we're attempting to connect to. May be NULL if we're |
| 455 | // not attempting to connect to a new Service. If non-NULL, should |
| 456 | // be distinct from |current_service_|. (A service should not |
| 457 | // simultaneously be both pending, and current.) |
| 458 | WiFiServiceRefPtr pending_service_; |
| 459 | std::string supplicant_state_; |
| 460 | std::string supplicant_bss_; |
mukesh agrawal | 5c05b29 | 2012-03-07 10:12:52 -0800 | [diff] [blame] | 461 | // Indicates that we should flush supplicant's BSS cache after the |
| 462 | // next scan completes. |
| 463 | bool need_bss_flush_; |
| 464 | struct timeval resumed_at_; |
mukesh agrawal | b66c646 | 2012-05-07 11:45:25 -0700 | [diff] [blame] | 465 | // Executes when the (foreground) scan timer expires. Calls ScanTimerHandler. |
| 466 | base::CancelableClosure scan_timer_callback_; |
Paul Stewart | 2b05e62 | 2012-07-13 20:38:44 -0700 | [diff] [blame] | 467 | // Executes when a pending service connect timer expires. Calls |
| 468 | // PendingTimeoutHandler. |
| 469 | base::CancelableClosure pending_timeout_callback_; |
Paul Stewart | 4466392 | 2012-07-30 11:03:03 -0700 | [diff] [blame] | 470 | // Executes when a reconnecting service timer expires. Calls |
| 471 | // ReconnectTimeoutHandler. |
| 472 | base::CancelableClosure reconnect_timeout_callback_; |
Paul Stewart | e369ece | 2012-05-22 09:11:03 -0700 | [diff] [blame] | 473 | // Number of remaining fast scans to be done during startup and disconnect. |
| 474 | int fast_scans_remaining_; |
Christopher Wiley | 8f81e2a | 2012-10-17 16:51:32 -0700 | [diff] [blame] | 475 | // Indicates that the current BSS has reached the completed state according |
| 476 | // to supplicant. |
| 477 | bool has_already_completed_; |
Paul Stewart | a47c3c6 | 2012-12-18 12:14:29 -0800 | [diff] [blame] | 478 | // Indicates that we are debugging a problematic connection. |
| 479 | bool is_debugging_connection_; |
Paul Stewart | 735eab5 | 2013-03-29 09:19:23 -0700 | [diff] [blame] | 480 | // Tracks the process of an EAP negotiation. |
| 481 | scoped_ptr<SupplicantEAPStateHandler> eap_state_handler_; |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 482 | |
Chris Masone | 853b81b | 2011-06-24 14:11:41 -0700 | [diff] [blame] | 483 | // Properties |
| 484 | std::string bgscan_method_; |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 485 | uint16 bgscan_short_interval_seconds_; |
| 486 | int32 bgscan_signal_threshold_dbm_; |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 487 | uint16 scan_interval_seconds_; |
Chris Masone | 853b81b | 2011-06-24 14:11:41 -0700 | [diff] [blame] | 488 | |
Wade Guthrie | 5a4e2ef | 2013-04-30 12:51:39 -0700 | [diff] [blame] | 489 | bool progressive_scan_enabled_; |
Wade Guthrie | 04fd048 | 2013-07-25 10:43:01 -0700 | [diff] [blame] | 490 | std::string scan_configuration_; |
Wade Guthrie | bb9fca2 | 2013-04-10 17:21:42 -0700 | [diff] [blame] | 491 | NetlinkManager *netlink_manager_; |
Wade Guthrie | 92d0636 | 2013-04-25 15:41:30 -0700 | [diff] [blame] | 492 | std::set<uint16_t> all_scan_frequencies_; |
Wade Guthrie | 5a4e2ef | 2013-04-30 12:51:39 -0700 | [diff] [blame] | 493 | scoped_ptr<ScanSession> scan_session_; |
| 494 | size_t min_frequencies_to_scan_; |
| 495 | size_t max_frequencies_to_scan_; |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 496 | |
Wade Guthrie | 2edd58b | 2013-05-23 11:16:08 -0700 | [diff] [blame] | 497 | // Fraction of previously seen scan frequencies to include in each |
| 498 | // progressive scan batch (since the frequencies are sorted, the sum of the |
| 499 | // fraction_per_scan_ over the scans in a session (* 100) is the percentile |
| 500 | // of the frequencies that have been scanned). |
| 501 | float fraction_per_scan_; |
Wade Guthrie | bee87c2 | 2013-03-06 11:00:46 -0800 | [diff] [blame] | 502 | |
Wade Guthrie | 0cf3c98 | 2013-05-29 09:11:35 -0700 | [diff] [blame] | 503 | ScanState scan_state_; |
| 504 | ScanMethod scan_method_; |
| 505 | chromeos_metrics::Timer scan_timer_; |
| 506 | |
Paul Stewart | f6f9648 | 2013-07-12 12:49:15 -0700 | [diff] [blame] | 507 | // Used to compute the number of bytes received since the link went up. |
| 508 | uint64 receive_byte_count_at_connect_; |
| 509 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 510 | DISALLOW_COPY_AND_ASSIGN(WiFi); |
| 511 | }; |
| 512 | |
| 513 | } // namespace shill |
| 514 | |
Paul Stewart | 735eab5 | 2013-03-29 09:19:23 -0700 | [diff] [blame] | 515 | #endif // SHILL_WIFI_H_ |