Darin Petkov | c64fe5e | 2012-01-11 12:46:13 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -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 | |
Darin Petkov | 2b8e44e | 2012-06-25 15:13:26 +0200 | [diff] [blame] | 5 | #ifndef SHILL_DEVICE_H_ |
| 6 | #define SHILL_DEVICE_H_ |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 7 | |
Chris Masone | 46eaaf5 | 2011-05-24 13:08:30 -0700 | [diff] [blame] | 8 | #include <string> |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 11 | #include <base/basictypes.h> |
Chris Masone | 487b8bf | 2011-05-13 16:27:57 -0700 | [diff] [blame] | 12 | #include <base/memory/ref_counted.h> |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 13 | #include <base/memory/scoped_ptr.h> |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 14 | #include <base/memory/weak_ptr.h> |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 15 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Paul Stewart | d584377 | 2011-05-11 15:40:42 -0700 | [diff] [blame] | 16 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 17 | #include "shill/adaptor_interfaces.h" |
| 18 | #include "shill/callbacks.h" |
Arman Uguray | f84a424 | 2013-04-09 20:01:07 -0700 | [diff] [blame] | 19 | #include "shill/connection_health_checker.h" |
Paul Stewart | 26b327e | 2011-10-19 11:38:09 -0700 | [diff] [blame] | 20 | #include "shill/event_dispatcher.h" |
Paul Stewart | 2bf1d35 | 2011-12-06 15:02:55 -0800 | [diff] [blame] | 21 | #include "shill/ip_address.h" |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 22 | #include "shill/ipconfig.h" |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 23 | #include "shill/portal_detector.h" |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 24 | #include "shill/property_store.h" |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 25 | #include "shill/refptr_types.h" |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 26 | #include "shill/service.h" |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 27 | #include "shill/technology.h" |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 28 | |
| 29 | namespace shill { |
| 30 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 31 | class ControlInterface; |
Darin Petkov | 77cb681 | 2011-08-15 16:19:41 -0700 | [diff] [blame] | 32 | class DHCPProvider; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 33 | class DeviceAdaptorInterface; |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 34 | class Endpoint; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 35 | class Error; |
| 36 | class EventDispatcher; |
Gaurav Shah | 6d2c72d | 2012-10-16 16:30:44 -0700 | [diff] [blame] | 37 | class GeolocationInfo; |
Paul Stewart | 036dba0 | 2012-08-07 12:34:41 -0700 | [diff] [blame] | 38 | class LinkMonitor; |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 39 | class Manager; |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 40 | class Metrics; |
Thieu Le | fb46caf | 2012-03-08 11:57:15 -0800 | [diff] [blame] | 41 | class RTNLHandler; |
Ben Chan | b061f89 | 2013-02-27 17:46:55 -0800 | [diff] [blame] | 42 | class TrafficMonitor; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 43 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 44 | // Device superclass. Individual network interfaces types will inherit from |
| 45 | // this class. |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 46 | class Device : public base::RefCounted<Device> { |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 47 | public: |
Wade Guthrie | 68d4109 | 2013-04-02 12:56:02 -0700 | [diff] [blame] | 48 | // Progressively scanning for access points (APs) is done with multiple scans, |
| 49 | // each containing a group of channels. The scans are performed in order of |
| 50 | // decreasing likelihood of connecting on one of the channels in a group |
| 51 | // (the number of channels in a group is a matter for system tuning). Fully |
| 52 | // scanning for APs does a complete scan of all the channels in a single scan. |
| 53 | // Progressive scanning is supported for wifi devices; technologies that |
| 54 | // support scan but don't support progressive scan will always perform a full |
| 55 | // scan, regardless of the requested scan type. |
| 56 | enum ScanType { kProgressiveScan, kFullScan }; |
| 57 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 58 | // A constructor for the Device object |
| 59 | Device(ControlInterface *control_interface, |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 60 | EventDispatcher *dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 61 | Metrics *metrics, |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 62 | Manager *manager, |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 63 | const std::string &link_name, |
Chris Masone | 626719f | 2011-08-18 16:58:48 -0700 | [diff] [blame] | 64 | const std::string &address, |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 65 | int interface_index, |
| 66 | Technology::Identifier technology); |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 67 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 68 | // Enable or disable the device. |
| 69 | virtual void SetEnabled(bool enable); |
| 70 | // Enable or disable the device, and save the setting in the profile. |
| 71 | // The setting is persisted before the enable or disable operation |
| 72 | // starts, so that even if it fails, the user's intent is still recorded |
| 73 | // for the next time shill restarts. |
Jason Glasgow | df7c553 | 2012-05-14 14:41:45 -0400 | [diff] [blame] | 74 | virtual void SetEnabledPersistent(bool enable, |
| 75 | Error *error, |
| 76 | const ResultCallback &callback); |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 77 | |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 78 | // Returns true if the underlying device reports that it is already enabled. |
| 79 | // Used when the device is registered with the Manager, so that shill can |
| 80 | // sync its state/ with the true state of the device. The default is to |
| 81 | // report false. |
| 82 | virtual bool IsUnderlyingDeviceEnabled() const; |
| 83 | |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 84 | virtual void LinkEvent(unsigned flags, unsigned change); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 85 | |
Darin Petkov | 9ae310f | 2011-08-30 15:41:13 -0700 | [diff] [blame] | 86 | // The default implementation sets |error| to kNotSupported. |
Wade Guthrie | 68d4109 | 2013-04-02 12:56:02 -0700 | [diff] [blame] | 87 | virtual void Scan(ScanType scan_type, Error *error); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 88 | virtual void RegisterOnNetwork(const std::string &network_id, Error *error, |
| 89 | const ResultCallback &callback); |
| 90 | virtual void RequirePIN(const std::string &pin, bool require, |
| 91 | Error *error, const ResultCallback &callback); |
| 92 | virtual void EnterPIN(const std::string &pin, |
| 93 | Error *error, const ResultCallback &callback); |
Darin Petkov | e42e101 | 2011-08-31 12:35:04 -0700 | [diff] [blame] | 94 | virtual void UnblockPIN(const std::string &unblock_code, |
| 95 | const std::string &pin, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 96 | Error *error, const ResultCallback &callback); |
Darin Petkov | e42e101 | 2011-08-31 12:35:04 -0700 | [diff] [blame] | 97 | virtual void ChangePIN(const std::string &old_pin, |
| 98 | const std::string &new_pin, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 99 | Error *error, const ResultCallback &callback); |
Ben Chan | ad663e1 | 2013-01-08 01:58:47 -0800 | [diff] [blame] | 100 | virtual void Reset(Error *error, const ResultCallback &callback); |
| 101 | |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 102 | virtual void SetCarrier(const std::string &carrier, |
| 103 | Error *error, const ResultCallback &callback); |
Paul Stewart | 2bf1d35 | 2011-12-06 15:02:55 -0800 | [diff] [blame] | 104 | virtual void DisableIPv6(); |
| 105 | virtual void EnableIPv6(); |
| 106 | virtual void EnableIPv6Privacy(); |
Darin Petkov | 9ae310f | 2011-08-30 15:41:13 -0700 | [diff] [blame] | 107 | |
Paul Stewart | c8f4bef | 2011-12-13 09:45:51 -0800 | [diff] [blame] | 108 | // Request the removal of reverse-path filtering for this interface. |
| 109 | // This will allow packets destined for this interface to be accepted, |
| 110 | // even if this is not the default route for such a packet to arrive. |
| 111 | virtual void DisableReversePathFilter(); |
| 112 | |
| 113 | // Request reverse-path filtering for this interface. |
| 114 | virtual void EnableReversePathFilter(); |
| 115 | |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 116 | // Returns true if the selected service on the device (if any) is connected. |
| 117 | // Returns false if there is no selected service, or if the selected service |
| 118 | // is not connected. |
| 119 | bool IsConnected() const; |
| 120 | |
Christopher Wiley | 5519e9e | 2013-01-08 16:55:56 -0800 | [diff] [blame] | 121 | // Called by Device so that subclasses can run hooks on the selected service |
| 122 | // getting an IP. Subclasses should call up to the parent first. |
| 123 | virtual void OnConnected(); |
| 124 | |
Paul Stewart | 8596f9f | 2013-03-14 07:58:26 -0700 | [diff] [blame] | 125 | // Called by the Connection so that the Device can update the service sorting |
| 126 | // after one connection is bound to another. |
| 127 | virtual void OnConnectionUpdated(); |
| 128 | |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 129 | // Returns true if the selected service on the device (if any) is connected |
| 130 | // and matches the passed-in argument |service|. Returns false if there is |
| 131 | // no connected service, or if it does not match |service|. |
| 132 | virtual bool IsConnectedToService(const ServiceRefPtr &service) const; |
| 133 | |
| 134 | // Restart the portal detection process on a connected device. This is |
| 135 | // useful if the properties on the connected service have changed in a |
| 136 | // way that may affect the decision to run portal detection at all. |
| 137 | // Returns true if portal detection was started. |
| 138 | virtual bool RestartPortalDetection(); |
| 139 | |
Ben Chan | b061f89 | 2013-02-27 17:46:55 -0800 | [diff] [blame] | 140 | // Get receive and transmit byte counters. |
| 141 | virtual uint64 GetReceiveByteCount(); |
| 142 | virtual uint64 GetTransmitByteCount(); |
| 143 | |
Paul Stewart | 6ff27f5 | 2012-07-11 06:51:41 -0700 | [diff] [blame] | 144 | // Reset the persisted byte counters associated with the device. |
| 145 | void ResetByteCounters(); |
| 146 | |
Paul Stewart | c681fa0 | 2012-03-02 19:40:04 -0800 | [diff] [blame] | 147 | // Requests that portal detection be done, if this device has the default |
| 148 | // connection. Returns true if portal detection was started. |
| 149 | virtual bool RequestPortalDetection(); |
| 150 | |
mukesh agrawal | f6b3209 | 2013-04-10 15:49:55 -0700 | [diff] [blame] | 151 | std::string GetRpcIdentifier() const; |
Chris Masone | 5dec5f4 | 2011-07-22 14:07:55 -0700 | [diff] [blame] | 152 | std::string GetStorageIdentifier(); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 153 | |
Gaurav Shah | 6d2c72d | 2012-10-16 16:30:44 -0700 | [diff] [blame] | 154 | // Returns a list of Geolocation objects. Each object is multiple |
| 155 | // key-value pairs representing one entity that can be used for |
| 156 | // Geolocation. |
| 157 | virtual std::vector<GeolocationInfo> GetGeolocationObjects() const; |
| 158 | |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 159 | const std::string &address() const { return hardware_address_; } |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 160 | const std::string &link_name() const { return link_name_; } |
| 161 | int interface_index() const { return interface_index_; } |
Paul Stewart | e613202 | 2011-08-16 09:11:02 -0700 | [diff] [blame] | 162 | const ConnectionRefPtr &connection() const { return connection_; } |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 163 | bool enabled() const { return enabled_; } |
| 164 | bool enabled_persistent() const { return enabled_persistent_; } |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 165 | virtual Technology::Identifier technology() const { return technology_; } |
Jason Glasgow | b579005 | 2012-01-27 01:03:52 -0500 | [diff] [blame] | 166 | std::string GetTechnologyString(Error *error); |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 167 | |
Thieu Le | 0302666 | 2013-04-04 10:45:11 -0700 | [diff] [blame] | 168 | virtual const IPConfigRefPtr &ipconfig() const { return ipconfig_; } |
Darin Petkov | 31a2eca | 2012-03-14 11:07:18 +0100 | [diff] [blame] | 169 | void set_ipconfig(const IPConfigRefPtr &config) { ipconfig_ = config; } |
| 170 | |
Chris Masone | 19e3040 | 2011-07-19 15:48:47 -0700 | [diff] [blame] | 171 | const std::string &FriendlyName() const; |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 172 | |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 173 | // Returns a string that is guaranteed to uniquely identify this Device |
| 174 | // instance. |
| 175 | const std::string &UniqueName() const; |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 176 | |
mukesh agrawal | de29fa8 | 2011-09-16 16:16:36 -0700 | [diff] [blame] | 177 | PropertyStore *mutable_store() { return &store_; } |
| 178 | const PropertyStore &store() const { return store_; } |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 179 | RTNLHandler *rtnl_handler() { return rtnl_handler_; } |
Ben Chan | 19f8397 | 2012-10-03 23:25:56 -0700 | [diff] [blame] | 180 | bool running() const { return running_; } |
Chris Masone | 19e3040 | 2011-07-19 15:48:47 -0700 | [diff] [blame] | 181 | |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 182 | EventDispatcher *dispatcher() const { return dispatcher_; } |
| 183 | |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 184 | // Load configuration for the device from |storage|. This may include |
| 185 | // instantiating non-visible services for which configuration has been |
| 186 | // stored. |
| 187 | virtual bool Load(StoreInterface *storage); |
| 188 | |
| 189 | // Save configuration for the device to |storage|. |
Chris Masone | 877ff98 | 2011-09-21 16:18:24 -0700 | [diff] [blame] | 190 | virtual bool Save(StoreInterface *storage); |
Chris Masone | 5dec5f4 | 2011-07-22 14:07:55 -0700 | [diff] [blame] | 191 | |
Darin Petkov | 77cb681 | 2011-08-15 16:19:41 -0700 | [diff] [blame] | 192 | void set_dhcp_provider(DHCPProvider *provider) { dhcp_provider_ = provider; } |
| 193 | |
Darin Petkov | 3cfbf21 | 2011-11-21 16:02:09 +0100 | [diff] [blame] | 194 | DeviceAdaptorInterface *adaptor() const { return adaptor_.get(); } |
| 195 | |
Prathmesh Prabhu | ba99b59 | 2013-04-17 15:13:14 -0700 | [diff] [blame] | 196 | void set_health_checker(ConnectionHealthChecker *health_checker) { |
| 197 | health_checker_.reset(health_checker); |
| 198 | } |
| 199 | |
mukesh agrawal | 784566d | 2012-08-08 18:32:58 -0700 | [diff] [blame] | 200 | // Suspend event handler. Called by Manager before the system |
| 201 | // suspends. For this callback to be useful, the device must specify |
| 202 | // a suspend delay. Otherwise, there is no guarantee that the device |
| 203 | // will have time to complete its suspend actions, before the system |
| 204 | // is suspended. |
| 205 | // |
Paul Stewart | ee6b3d7 | 2013-07-12 16:07:51 -0700 | [diff] [blame] | 206 | // TODO(quiche): Add support for suspend delays. crbug.com/215582 |
mukesh agrawal | 784566d | 2012-08-08 18:32:58 -0700 | [diff] [blame] | 207 | virtual void OnBeforeSuspend(); |
| 208 | |
| 209 | // Resume event handler. Called by Manager as the system resumes. |
| 210 | // The base class implementation takes care of renewing a DHCP lease |
| 211 | // (if necessary). Derived classes may implement any technology |
| 212 | // specific requirements by overriding, but should include a call to |
| 213 | // the base class implementation. |
| 214 | virtual void OnAfterResume(); |
| 215 | |
Albert Chaulk | 0e1cdea | 2013-02-27 15:32:55 -0800 | [diff] [blame] | 216 | // Destroy the lease, if any, with this |name|. |
| 217 | // Called by the service during Unload() as part of the cleanup sequence. |
| 218 | virtual void DestroyIPConfigLease(const std::string &name); |
| 219 | |
Paul Stewart | d584377 | 2011-05-11 15:40:42 -0700 | [diff] [blame] | 220 | protected: |
Darin Petkov | 2b8e44e | 2012-06-25 15:13:26 +0200 | [diff] [blame] | 221 | friend class base::RefCounted<Device>; |
Arman Uguray | f84a424 | 2013-04-09 20:01:07 -0700 | [diff] [blame] | 222 | friend class DeviceHealthCheckerTest; |
Ben Chan | 19f8397 | 2012-10-03 23:25:56 -0700 | [diff] [blame] | 223 | FRIEND_TEST(CellularServiceTest, IsAutoConnectable); |
Arman Uguray | d42d8ec | 2013-04-08 19:28:21 -0700 | [diff] [blame] | 224 | FRIEND_TEST(CellularTest, EnableTrafficMonitor); |
Eric Shienbrood | 7fce52c | 2012-04-13 19:11:02 -0400 | [diff] [blame] | 225 | FRIEND_TEST(CellularTest, ModemStateChangeDisable); |
Arman Uguray | ed8e610 | 2012-11-29 14:47:20 -0800 | [diff] [blame] | 226 | FRIEND_TEST(CellularTest, UseNoArpGateway); |
Darin Petkov | 13e6d55 | 2012-05-09 14:22:23 +0200 | [diff] [blame] | 227 | FRIEND_TEST(ConnectionTest, OnRouteQueryResponse); |
Prathmesh Prabhu | ba99b59 | 2013-04-17 15:13:14 -0700 | [diff] [blame] | 228 | FRIEND_TEST(DeviceHealthCheckerTest, HealthCheckerPersistsAcrossDeviceReset); |
Arman Uguray | f84a424 | 2013-04-09 20:01:07 -0700 | [diff] [blame] | 229 | FRIEND_TEST(DeviceHealthCheckerTest, RequestConnectionHealthCheck); |
Prathmesh Prabhu | ba99b59 | 2013-04-17 15:13:14 -0700 | [diff] [blame] | 230 | FRIEND_TEST(DeviceHealthCheckerTest, SetupHealthChecker); |
Paul Stewart | 2bf1d35 | 2011-12-06 15:02:55 -0800 | [diff] [blame] | 231 | FRIEND_TEST(DeviceTest, AcquireIPConfig); |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 232 | FRIEND_TEST(DeviceTest, DestroyIPConfig); |
| 233 | FRIEND_TEST(DeviceTest, DestroyIPConfigNULL); |
Chris Masone | 95207da | 2011-06-29 16:50:49 -0700 | [diff] [blame] | 234 | FRIEND_TEST(DeviceTest, GetProperties); |
Paul Stewart | 6ff27f5 | 2012-07-11 06:51:41 -0700 | [diff] [blame] | 235 | FRIEND_TEST(DeviceTest, Load); |
Chris Masone | 5dec5f4 | 2011-07-22 14:07:55 -0700 | [diff] [blame] | 236 | FRIEND_TEST(DeviceTest, Save); |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 237 | FRIEND_TEST(DeviceTest, SelectedService); |
Darin Petkov | e7c6ad3 | 2012-06-29 10:22:09 +0200 | [diff] [blame] | 238 | FRIEND_TEST(DeviceTest, SetEnabledPersistent); |
Paul Stewart | c681fa0 | 2012-03-02 19:40:04 -0800 | [diff] [blame] | 239 | FRIEND_TEST(DeviceTest, SetServiceConnectedState); |
Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 240 | FRIEND_TEST(DeviceTest, Start); |
Ben Chan | b061f89 | 2013-02-27 17:46:55 -0800 | [diff] [blame] | 241 | FRIEND_TEST(DeviceTest, StartTrafficMonitor); |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 242 | FRIEND_TEST(DeviceTest, Stop); |
Ben Chan | b061f89 | 2013-02-27 17:46:55 -0800 | [diff] [blame] | 243 | FRIEND_TEST(DeviceTest, StopTrafficMonitor); |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 244 | FRIEND_TEST(ManagerTest, DeviceRegistrationAndStart); |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 245 | FRIEND_TEST(ManagerTest, ConnectedTechnologies); |
| 246 | FRIEND_TEST(ManagerTest, DefaultTechnology); |
mukesh agrawal | 46c27cc | 2013-07-10 16:39:10 -0700 | [diff] [blame^] | 247 | FRIEND_TEST(ManagerTest, SetEnabledStateForTechnology); |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 248 | FRIEND_TEST(WiFiMainTest, Connect); |
Arman Uguray | ed8e610 | 2012-11-29 14:47:20 -0800 | [diff] [blame] | 249 | FRIEND_TEST(WiFiMainTest, UseArpGateway); |
Darin Petkov | 3a4100c | 2012-06-14 11:36:59 +0200 | [diff] [blame] | 250 | FRIEND_TEST(WiMaxTest, ConnectTimeout); |
Arman Uguray | ed8e610 | 2012-11-29 14:47:20 -0800 | [diff] [blame] | 251 | FRIEND_TEST(WiMaxTest, UseNoArpGateway); |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 252 | |
Darin Petkov | 2b8e44e | 2012-06-25 15:13:26 +0200 | [diff] [blame] | 253 | virtual ~Device(); |
| 254 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 255 | // Each device must implement this method to do the work needed to |
| 256 | // enable the device to operate for establishing network connections. |
| 257 | // The |error| argument, if not NULL, |
| 258 | // will refer to an Error that starts out with the value |
| 259 | // Error::kOperationInitiated. This reflects the assumption that |
| 260 | // enable (and disable) operations will usually be non-blocking, |
| 261 | // and their completion will be indicated by means of an asynchronous |
| 262 | // reply sometime later. There are two circumstances in which a |
| 263 | // device's Start() method may overwrite |error|: |
| 264 | // |
| 265 | // 1. If an early failure is detected, such that the non-blocking |
| 266 | // part of the operation never takes place, then |error| should |
| 267 | // be set to the appropriate value corresponding to the type |
| 268 | // of failure. This is the "immediate failure" case. |
| 269 | // 2. If the device is enabled without performing any non-blocking |
| 270 | // steps, then |error| should be Reset, i.e., its value set |
| 271 | // to Error::kSuccess. This is the "immediate success" case. |
| 272 | // |
| 273 | // In these two cases, because completion is immediate, |callback| |
| 274 | // is not used. If neither of these two conditions holds, then |error| |
| 275 | // should not be modified, and |callback| should be passed to the |
| 276 | // method that will initiate the non-blocking operation. |
| 277 | virtual void Start(Error *error, |
| 278 | const EnabledStateChangedCallback &callback) = 0; |
| 279 | |
| 280 | // Each device must implement this method to do the work needed to |
| 281 | // disable the device, i.e., clear any running state, and make the |
| 282 | // device no longer capable of establishing network connections. |
| 283 | // The discussion for Start() regarding the use of |error| and |
| 284 | // |callback| apply to Stop() as well. |
| 285 | virtual void Stop(Error *error, |
| 286 | const EnabledStateChangedCallback &callback) = 0; |
| 287 | |
| 288 | // The EnabledStateChangedCallback that gets passed to the device's |
| 289 | // Start() and Stop() methods is bound to this method. |callback| |
| 290 | // is the callback that was passed to SetEnabled(). |
| 291 | void OnEnabledStateChanged(const ResultCallback &callback, |
| 292 | const Error &error); |
| 293 | |
Darin Petkov | 2b8e44e | 2012-06-25 15:13:26 +0200 | [diff] [blame] | 294 | // Drops the currently selected service along with its IP configuration and |
| 295 | // connection, if any. |
mukesh agrawal | 5d851b1 | 2013-07-11 14:09:41 -0700 | [diff] [blame] | 296 | virtual void DropConnection(); |
Darin Petkov | 2b8e44e | 2012-06-25 15:13:26 +0200 | [diff] [blame] | 297 | |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 298 | // If there's an IP configuration in |ipconfig_|, releases the IP address and |
| 299 | // destroys the configuration instance. |
| 300 | void DestroyIPConfig(); |
| 301 | |
| 302 | // Creates a new DHCP IP configuration instance, stores it in |ipconfig_| and |
Paul Stewart | d408fdf | 2012-05-07 17:15:57 -0700 | [diff] [blame] | 303 | // requests a new IP configuration. Saves the DHCP lease to the generic |
| 304 | // lease filename based on the interface name. Registers a callback to |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 305 | // IPConfigUpdatedCallback on IP configuration changes. Returns true if the IP |
| 306 | // request was successfully sent. |
Paul Stewart | 2bf1d35 | 2011-12-06 15:02:55 -0800 | [diff] [blame] | 307 | bool AcquireIPConfig(); |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 308 | |
Paul Stewart | d408fdf | 2012-05-07 17:15:57 -0700 | [diff] [blame] | 309 | // Creates a new DHCP IP configuration instance, stores it in |ipconfig_| and |
| 310 | // requests a new IP configuration. Saves the DHCP lease to a filename |
| 311 | // based on the passed-in |lease_name|. Registers a callback to |
| 312 | // IPConfigUpdatedCallback on IP configuration changes. Returns true if the IP |
| 313 | // request was successfully sent. |
| 314 | bool AcquireIPConfigWithLeaseName(const std::string &lease_name); |
| 315 | |
Darin Petkov | 79d74c9 | 2012-03-07 17:20:32 +0100 | [diff] [blame] | 316 | // Callback invoked on every IP configuration update. |
| 317 | void OnIPConfigUpdated(const IPConfigRefPtr &ipconfig, bool success); |
| 318 | |
Paul Stewart | f6f9648 | 2013-07-12 12:49:15 -0700 | [diff] [blame] | 319 | // Called by Device so that subclasses can run hooks on the selected service |
| 320 | // failing to get an IP. The default implementation disconnects the selected |
| 321 | // service with Service::kFailureDHCP. |
| 322 | virtual void OnIPConfigFailure(); |
| 323 | |
Paul Stewart | e613202 | 2011-08-16 09:11:02 -0700 | [diff] [blame] | 324 | // Maintain connection state (Routes, IP Addresses and DNS) in the OS. |
| 325 | void CreateConnection(); |
| 326 | |
| 327 | // Remove connection state |
| 328 | void DestroyConnection(); |
| 329 | |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 330 | // Selects a service to be "current" -- i.e. link-state or configuration |
| 331 | // events that happen to the device are attributed to this service. |
| 332 | void SelectService(const ServiceRefPtr &service); |
| 333 | |
| 334 | // Set the state of the selected service |
mukesh agrawal | 0381f9a | 2013-07-11 16:41:52 -0700 | [diff] [blame] | 335 | virtual void SetServiceState(Service::ConnectState state); |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 336 | |
| 337 | // Set the failure of the selected service (implicitly sets the state to |
| 338 | // "failure") |
mukesh agrawal | 0381f9a | 2013-07-11 16:41:52 -0700 | [diff] [blame] | 339 | virtual void SetServiceFailure(Service::ConnectFailure failure_state); |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 340 | |
Eric Shienbrood | cc95c5d | 2012-03-30 15:25:49 -0400 | [diff] [blame] | 341 | // Records the failure mode and time of the selected service, and |
| 342 | // sets the Service state of the selected service to "Idle". |
| 343 | // Avoids showing a failure mole in the UI. |
mukesh agrawal | 0381f9a | 2013-07-11 16:41:52 -0700 | [diff] [blame] | 344 | virtual void SetServiceFailureSilent(Service::ConnectFailure failure_state); |
Eric Shienbrood | cc95c5d | 2012-03-30 15:25:49 -0400 | [diff] [blame] | 345 | |
Prathmesh Prabhu | ba99b59 | 2013-04-17 15:13:14 -0700 | [diff] [blame] | 346 | virtual void SetupConnectionHealthChecker(); |
Arman Uguray | f84a424 | 2013-04-09 20:01:07 -0700 | [diff] [blame] | 347 | |
| 348 | // Checks the network connectivity status by creating a TCP connection, and |
| 349 | // optionally sending a small amout of data. |
| 350 | void RequestConnectionHealthCheck(); |
| 351 | |
| 352 | // Responds to the result from connection health checker in a device specific |
| 353 | // manner. |
| 354 | virtual void OnConnectionHealthCheckerResult( |
| 355 | ConnectionHealthChecker::Result result); |
| 356 | |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 357 | // Called by the Portal Detector whenever a trial completes. Device |
| 358 | // subclasses that choose unique mappings from portal results to connected |
| 359 | // states can override this method in order to do so. |
| 360 | virtual void PortalDetectorCallback(const PortalDetector::Result &result); |
| 361 | |
| 362 | // Initiate portal detection, if enabled for this device type. |
| 363 | bool StartPortalDetection(); |
| 364 | |
| 365 | // Stop portal detection if it is running. |
| 366 | void StopPortalDetection(); |
| 367 | |
Paul Stewart | 036dba0 | 2012-08-07 12:34:41 -0700 | [diff] [blame] | 368 | // Initiate link monitoring, if enabled for this device type. |
| 369 | bool StartLinkMonitor(); |
| 370 | |
| 371 | // Stop link monitoring if it is running. |
| 372 | void StopLinkMonitor(); |
| 373 | |
| 374 | // Respond to a LinkMonitor failure in a Device-specific manner. |
| 375 | virtual void OnLinkMonitorFailure(); |
| 376 | |
Ben Chan | b061f89 | 2013-02-27 17:46:55 -0800 | [diff] [blame] | 377 | // Initiates traffic monitoring if it's enabled via |
| 378 | // set_traffic_monitor_enabled() and returns true if the monitoring |
| 379 | // is started. |
| 380 | bool StartTrafficMonitor(); |
| 381 | |
| 382 | // Stops traffic monitoring if it is running. |
| 383 | void StopTrafficMonitor(); |
| 384 | |
Thieu Le | 0302666 | 2013-04-04 10:45:11 -0700 | [diff] [blame] | 385 | // Responds to a TrafficMonitor no-network-routing failure in a |
Ben Chan | b061f89 | 2013-02-27 17:46:55 -0800 | [diff] [blame] | 386 | // Device-specific manner. |
Thieu Le | 0302666 | 2013-04-04 10:45:11 -0700 | [diff] [blame] | 387 | virtual void OnNoNetworkRouting(); |
Ben Chan | b061f89 | 2013-02-27 17:46:55 -0800 | [diff] [blame] | 388 | |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 389 | // Set the state of the selected service, with checks to make sure |
| 390 | // the service is already in a connected state before doing so. |
| 391 | void SetServiceConnectedState(Service::ConnectState state); |
| 392 | |
Arman Uguray | ed8e610 | 2012-11-29 14:47:20 -0800 | [diff] [blame] | 393 | // Specifies whether an ARP gateway should be used for the |
| 394 | // device technology. |
| 395 | virtual bool ShouldUseArpGateway() const; |
| 396 | |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 397 | const ServiceRefPtr &selected_service() const { return selected_service_; } |
| 398 | |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 399 | void HelpRegisterConstDerivedString( |
Jason Glasgow | b579005 | 2012-01-27 01:03:52 -0500 | [diff] [blame] | 400 | const std::string &name, |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 401 | std::string(Device::*get)(Error *)); |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 402 | |
Jason Glasgow | 08afdff | 2012-04-03 10:22:26 -0400 | [diff] [blame] | 403 | void HelpRegisterConstDerivedRpcIdentifiers( |
| 404 | const std::string &name, |
| 405 | RpcIdentifiers(Device::*get)(Error *)); |
| 406 | |
Paul Stewart | 6ff27f5 | 2012-07-11 06:51:41 -0700 | [diff] [blame] | 407 | void HelpRegisterConstDerivedUint64( |
| 408 | const std::string &name, |
| 409 | uint64(Device::*get)(Error *)); |
| 410 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 411 | // Property getters reserved for subclasses |
| 412 | ControlInterface *control_interface() const { return control_interface_; } |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 413 | Metrics *metrics() const { return metrics_; } |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 414 | Manager *manager() const { return manager_; } |
Paul Stewart | 036dba0 | 2012-08-07 12:34:41 -0700 | [diff] [blame] | 415 | const LinkMonitor *link_monitor() const { return link_monitor_.get(); } |
| 416 | void set_link_monitor(LinkMonitor *link_monitor); |
Ben Chan | b061f89 | 2013-02-27 17:46:55 -0800 | [diff] [blame] | 417 | const TrafficMonitor *traffic_monitor() const { |
| 418 | return traffic_monitor_.get(); |
| 419 | } |
| 420 | |
| 421 | // Ownership of |traffic_monitor| is taken. |
| 422 | void set_traffic_monitor(TrafficMonitor *traffic_monitor); |
| 423 | bool traffic_monitor_enabled() const { return traffic_monitor_enabled_; } |
| 424 | void set_traffic_monitor_enabled(bool traffic_monitor_enabled) { |
| 425 | traffic_monitor_enabled_ = traffic_monitor_enabled; |
| 426 | } |
Paul Stewart | d584377 | 2011-05-11 15:40:42 -0700 | [diff] [blame] | 427 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 428 | private: |
Darin Petkov | 3189a47 | 2012-10-05 09:55:33 +0200 | [diff] [blame] | 429 | friend class CellularCapabilityTest; |
| 430 | friend class CellularTest; |
Chris Masone | 413a319 | 2011-05-09 17:10:05 -0700 | [diff] [blame] | 431 | friend class DeviceAdaptorInterface; |
Paul Stewart | 6ff27f5 | 2012-07-11 06:51:41 -0700 | [diff] [blame] | 432 | friend class DeviceByteCountTest; |
Paul Stewart | c681fa0 | 2012-03-02 19:40:04 -0800 | [diff] [blame] | 433 | friend class DevicePortalDetectionTest; |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 434 | friend class DeviceTest; |
Paul Stewart | ced3ad7 | 2013-04-03 13:39:25 -0700 | [diff] [blame] | 435 | friend class EthernetTest; |
Darin Petkov | 3189a47 | 2012-10-05 09:55:33 +0200 | [diff] [blame] | 436 | friend class OpenVPNDriverTest; |
Paul Stewart | e369ece | 2012-05-22 09:11:03 -0700 | [diff] [blame] | 437 | friend class WiFiObjectTest; |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 438 | |
Paul Stewart | 2bf1d35 | 2011-12-06 15:02:55 -0800 | [diff] [blame] | 439 | static const char kIPFlagTemplate[]; |
| 440 | static const char kIPFlagVersion4[]; |
| 441 | static const char kIPFlagVersion6[]; |
| 442 | static const char kIPFlagDisableIPv6[]; |
| 443 | static const char kIPFlagUseTempAddr[]; |
| 444 | static const char kIPFlagUseTempAddrUsedAndDefault[]; |
Paul Stewart | c8f4bef | 2011-12-13 09:45:51 -0800 | [diff] [blame] | 445 | static const char kIPFlagReversePathFilter[]; |
| 446 | static const char kIPFlagReversePathFilterEnabled[]; |
| 447 | static const char kIPFlagReversePathFilterLooseMode[]; |
Paul Stewart | 41a071e | 2013-04-26 07:56:04 -0700 | [diff] [blame] | 448 | static const char kStorageIPConfigs[]; |
Prathmesh Prabhu | ba99b59 | 2013-04-17 15:13:14 -0700 | [diff] [blame] | 449 | static const char kStoragePowered[]; |
Paul Stewart | 6ff27f5 | 2012-07-11 06:51:41 -0700 | [diff] [blame] | 450 | static const char kStorageReceiveByteCount[]; |
| 451 | static const char kStorageTransmitByteCount[]; |
Chris Masone | 5dec5f4 | 2011-07-22 14:07:55 -0700 | [diff] [blame] | 452 | |
Paul Stewart | 1062d9d | 2012-04-27 10:42:27 -0700 | [diff] [blame] | 453 | // Configure static IP address parameters if the service provides them. |
| 454 | void ConfigureStaticIPTask(); |
| 455 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 456 | void SetEnabledInternal(bool enable, bool persist, |
| 457 | Error *error, const ResultCallback &callback); |
| 458 | |
Chris Masone | 5dec5f4 | 2011-07-22 14:07:55 -0700 | [diff] [blame] | 459 | // Right now, Devices reference IPConfigs directly when persisted to disk |
| 460 | // It's not clear that this makes sense long-term, but that's how it is now. |
| 461 | // This call generates a string in the right format for this persisting. |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 462 | // |suffix| is injected into the storage identifier used for the configs. |
| 463 | std::string SerializeIPConfigs(const std::string &suffix); |
Chris Masone | 5dec5f4 | 2011-07-22 14:07:55 -0700 | [diff] [blame] | 464 | |
Paul Stewart | 2bf1d35 | 2011-12-06 15:02:55 -0800 | [diff] [blame] | 465 | // Set an IP configuration flag on the device. |ip_version| should be |
| 466 | // "ipv6" or "ipv4". |flag| should be the name of the flag to be set |
| 467 | // and |value| is what this flag should be set to. |
| 468 | bool SetIPFlag(IPAddress::Family family, const std::string &flag, |
| 469 | const std::string &value); |
| 470 | |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 471 | std::vector<std::string> AvailableIPConfigs(Error *error); |
Chris Masone | 4e85161 | 2011-07-01 10:46:53 -0700 | [diff] [blame] | 472 | std::string GetRpcConnectionIdentifier(); |
| 473 | |
Paul Stewart | 036dba0 | 2012-08-07 12:34:41 -0700 | [diff] [blame] | 474 | // Get the LinkMonitor's average response time. |
| 475 | uint64 GetLinkMonitorResponseTime(Error *error); |
| 476 | |
Ben Chan | b061f89 | 2013-02-27 17:46:55 -0800 | [diff] [blame] | 477 | // Get receive and transmit byte counters. These methods simply wrap |
| 478 | // GetReceiveByteCount and GetTransmitByteCount in order to be used by |
| 479 | // HelpRegisterConstDerivedUint64. |
| 480 | uint64 GetReceiveByteCountProperty(Error *error); |
| 481 | uint64 GetTransmitByteCountProperty(Error *error); |
Paul Stewart | 6ff27f5 | 2012-07-11 06:51:41 -0700 | [diff] [blame] | 482 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 483 | // |enabled_persistent_| is the value of the Powered property, as |
| 484 | // read from the profile. If it is not found in the profile, it |
| 485 | // defaults to true. |enabled_| reflects the real-time state of |
| 486 | // the device, i.e., enabled or disabled. |enabled_pending_| reflects |
| 487 | // the target state of the device while an enable or disable operation |
| 488 | // is occurring. |
| 489 | // |
| 490 | // Some typical sequences for these state variables are shown below. |
| 491 | // |
| 492 | // Shill starts up, profile has been read: |
| 493 | // |enabled_persistent_|=true |enabled_|=false |enabled_pending_|=false |
| 494 | // |
| 495 | // Shill acts on the value of |enabled_persistent_|, calls SetEnabled(true): |
| 496 | // |enabled_persistent_|=true |enabled_|=false |enabled_pending_|=true |
| 497 | // |
| 498 | // SetEnabled completes successfully, device is enabled: |
| 499 | // |enabled_persistent_|=true |enabled_|=true |enabled_pending_|=true |
| 500 | // |
| 501 | // User presses "Disable" button, SetEnabled(false) is called: |
| 502 | // |enabled_persistent_|=false |enabled_|=true |enabled_pending_|=false |
| 503 | // |
| 504 | // SetEnabled completes successfully, device is disabled: |
| 505 | // |enabled_persistent_|=false |enabled_|=false |enabled_pending_|=false |
| 506 | bool enabled_; |
| 507 | bool enabled_persistent_; |
| 508 | bool enabled_pending_; |
| 509 | |
| 510 | // Other properties |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 511 | bool reconnect_; |
| 512 | const std::string hardware_address_; |
| 513 | |
| 514 | PropertyStore store_; |
| 515 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 516 | const int interface_index_; |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 517 | bool running_; // indicates whether the device is actually in operation |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 518 | const std::string link_name_; |
| 519 | const std::string unique_id_; |
| 520 | ControlInterface *control_interface_; |
| 521 | EventDispatcher *dispatcher_; |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 522 | Metrics *metrics_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 523 | Manager *manager_; |
| 524 | IPConfigRefPtr ipconfig_; |
| 525 | ConnectionRefPtr connection_; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 526 | base::WeakPtrFactory<Device> weak_ptr_factory_; |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 527 | scoped_ptr<DeviceAdaptorInterface> adaptor_; |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 528 | scoped_ptr<PortalDetector> portal_detector_; |
Paul Stewart | 036dba0 | 2012-08-07 12:34:41 -0700 | [diff] [blame] | 529 | scoped_ptr<LinkMonitor> link_monitor_; |
Ben Chan | b061f89 | 2013-02-27 17:46:55 -0800 | [diff] [blame] | 530 | scoped_ptr<TrafficMonitor> traffic_monitor_; |
Arman Uguray | f84a424 | 2013-04-09 20:01:07 -0700 | [diff] [blame] | 531 | scoped_ptr<ConnectionHealthChecker> health_checker_; |
Ben Chan | b061f89 | 2013-02-27 17:46:55 -0800 | [diff] [blame] | 532 | bool traffic_monitor_enabled_; |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 533 | base::Callback<void(const PortalDetector::Result &)> |
| 534 | portal_detector_callback_; |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 535 | Technology::Identifier technology_; |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 536 | // The number of portal detection attempts from Connected to Online state. |
| 537 | // This includes all failure/timeout attempts and the final successful |
| 538 | // attempt. |
| 539 | int portal_attempts_to_online_; |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 540 | |
Paul Stewart | 6ff27f5 | 2012-07-11 06:51:41 -0700 | [diff] [blame] | 541 | // Keep track of the offset between the interface-reported byte counters |
| 542 | // and our persisted value. |
| 543 | uint64 receive_byte_offset_; |
| 544 | uint64 transmit_byte_offset_; |
| 545 | |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 546 | // Maintain a reference to the connected / connecting service |
| 547 | ServiceRefPtr selected_service_; |
| 548 | |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 549 | // Cache singleton pointers for performance and test purposes. |
Darin Petkov | 77cb681 | 2011-08-15 16:19:41 -0700 | [diff] [blame] | 550 | DHCPProvider *dhcp_provider_; |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 551 | RTNLHandler *rtnl_handler_; |
Darin Petkov | 77cb681 | 2011-08-15 16:19:41 -0700 | [diff] [blame] | 552 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 553 | DISALLOW_COPY_AND_ASSIGN(Device); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 554 | }; |
| 555 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 556 | } // namespace shill |
| 557 | |
Darin Petkov | 2b8e44e | 2012-06-25 15:13:26 +0200 | [diff] [blame] | 558 | #endif // SHILL_DEVICE_H_ |