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 | |
| 5 | #ifndef SHILL_DEVICE_ |
| 6 | #define SHILL_DEVICE_ |
| 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> |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 12 | #include <base/callback.h> |
Chris Masone | 487b8bf | 2011-05-13 16:27:57 -0700 | [diff] [blame] | 13 | #include <base/memory/ref_counted.h> |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 14 | #include <base/memory/scoped_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 | |
Paul Stewart | 26b327e | 2011-10-19 11:38:09 -0700 | [diff] [blame] | 17 | #include "shill/event_dispatcher.h" |
Paul Stewart | 2bf1d35 | 2011-12-06 15:02:55 -0800 | [diff] [blame] | 18 | #include "shill/ip_address.h" |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 19 | #include "shill/ipconfig.h" |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 20 | #include "shill/portal_detector.h" |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 21 | #include "shill/property_store.h" |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 22 | #include "shill/refptr_types.h" |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 23 | #include "shill/service.h" |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 24 | #include "shill/technology.h" |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 25 | |
| 26 | namespace shill { |
| 27 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 28 | class ControlInterface; |
Darin Petkov | 77cb681 | 2011-08-15 16:19:41 -0700 | [diff] [blame] | 29 | class DHCPProvider; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 30 | class DeviceAdaptorInterface; |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 31 | class Endpoint; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 32 | class Error; |
| 33 | class EventDispatcher; |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 34 | class Manager; |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 35 | class Metrics; |
Darin Petkov | e5bc2cb | 2011-12-07 14:47:32 +0100 | [diff] [blame] | 36 | class ReturnerInterface; |
Thieu Le | fb46caf | 2012-03-08 11:57:15 -0800 | [diff] [blame] | 37 | class RoutingTable; |
| 38 | class RTNLHandler; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 39 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 40 | // Device superclass. Individual network interfaces types will inherit from |
| 41 | // this class. |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 42 | class Device : public base::RefCounted<Device> { |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 43 | public: |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 44 | // A constructor for the Device object |
| 45 | Device(ControlInterface *control_interface, |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 46 | EventDispatcher *dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 47 | Metrics *metrics, |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 48 | Manager *manager, |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 49 | const std::string &link_name, |
Chris Masone | 626719f | 2011-08-18 16:58:48 -0700 | [diff] [blame] | 50 | const std::string &address, |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 51 | int interface_index, |
| 52 | Technology::Identifier technology); |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 53 | virtual ~Device(); |
| 54 | |
| 55 | virtual void Start(); |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 56 | |
| 57 | // Clear running state, especially any fields that hold a reference back |
| 58 | // to us. After a call to Stop(), the Device may be restarted (with a call |
| 59 | // to Start()), or destroyed (if its refcount falls to zero). |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 60 | virtual void Stop(); |
| 61 | |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 62 | |
| 63 | // TODO(gauravsh): We do not really need this since technology() can be used |
| 64 | // to get a device's technology for direct comparison. |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 65 | // Base method always returns false. |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 66 | virtual bool TechnologyIs(const Technology::Identifier type) const; |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 67 | |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 68 | virtual void LinkEvent(unsigned flags, unsigned change); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 69 | |
Darin Petkov | 9ae310f | 2011-08-30 15:41:13 -0700 | [diff] [blame] | 70 | // The default implementation sets |error| to kNotSupported. |
Darin Petkov | c086531 | 2011-09-16 15:31:20 -0700 | [diff] [blame] | 71 | virtual void Scan(Error *error); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 72 | virtual void RegisterOnNetwork(const std::string &network_id, |
| 73 | ReturnerInterface *returner); |
Darin Petkov | c64fe5e | 2012-01-11 12:46:13 +0100 | [diff] [blame] | 74 | virtual void RequirePIN( |
| 75 | const std::string &pin, bool require, ReturnerInterface *returner); |
Darin Petkov | e5bc2cb | 2011-12-07 14:47:32 +0100 | [diff] [blame] | 76 | virtual void EnterPIN(const std::string &pin, ReturnerInterface *returner); |
Darin Petkov | e42e101 | 2011-08-31 12:35:04 -0700 | [diff] [blame] | 77 | virtual void UnblockPIN(const std::string &unblock_code, |
| 78 | const std::string &pin, |
Darin Petkov | c64fe5e | 2012-01-11 12:46:13 +0100 | [diff] [blame] | 79 | ReturnerInterface *returner); |
Darin Petkov | e42e101 | 2011-08-31 12:35:04 -0700 | [diff] [blame] | 80 | virtual void ChangePIN(const std::string &old_pin, |
| 81 | const std::string &new_pin, |
Darin Petkov | c64fe5e | 2012-01-11 12:46:13 +0100 | [diff] [blame] | 82 | ReturnerInterface *returner); |
Paul Stewart | 2bf1d35 | 2011-12-06 15:02:55 -0800 | [diff] [blame] | 83 | virtual void DisableIPv6(); |
| 84 | virtual void EnableIPv6(); |
| 85 | virtual void EnableIPv6Privacy(); |
Darin Petkov | 9ae310f | 2011-08-30 15:41:13 -0700 | [diff] [blame] | 86 | |
Paul Stewart | c8f4bef | 2011-12-13 09:45:51 -0800 | [diff] [blame] | 87 | // Request the removal of reverse-path filtering for this interface. |
| 88 | // This will allow packets destined for this interface to be accepted, |
| 89 | // even if this is not the default route for such a packet to arrive. |
| 90 | virtual void DisableReversePathFilter(); |
| 91 | |
| 92 | // Request reverse-path filtering for this interface. |
| 93 | virtual void EnableReversePathFilter(); |
| 94 | |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 95 | // Returns true if the selected service on the device (if any) is connected. |
| 96 | // Returns false if there is no selected service, or if the selected service |
| 97 | // is not connected. |
| 98 | bool IsConnected() const; |
| 99 | |
Paul Stewart | c681fa0 | 2012-03-02 19:40:04 -0800 | [diff] [blame] | 100 | // Requests that portal detection be done, if this device has the default |
| 101 | // connection. Returns true if portal detection was started. |
| 102 | virtual bool RequestPortalDetection(); |
| 103 | |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 104 | std::string GetRpcIdentifier(); |
Chris Masone | 5dec5f4 | 2011-07-22 14:07:55 -0700 | [diff] [blame] | 105 | std::string GetStorageIdentifier(); |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 106 | |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 107 | const std::string &address() const { return hardware_address_; } |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 108 | const std::string &link_name() const { return link_name_; } |
| 109 | int interface_index() const { return interface_index_; } |
Paul Stewart | e613202 | 2011-08-16 09:11:02 -0700 | [diff] [blame] | 110 | const ConnectionRefPtr &connection() const { return connection_; } |
Darin Petkov | 79d74c9 | 2012-03-07 17:20:32 +0100 | [diff] [blame] | 111 | const IPConfigRefPtr &ipconfig() const { return ipconfig_; } |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 112 | bool powered() const { return powered_; } |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 113 | virtual Technology::Identifier technology() const { return technology_; } |
Jason Glasgow | b579005 | 2012-01-27 01:03:52 -0500 | [diff] [blame] | 114 | std::string GetTechnologyString(Error *error); |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 115 | |
Chris Masone | 19e3040 | 2011-07-19 15:48:47 -0700 | [diff] [blame] | 116 | const std::string &FriendlyName() const; |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 117 | |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 118 | // Returns a string that is guaranteed to uniquely identify this Device |
| 119 | // instance. |
| 120 | const std::string &UniqueName() const; |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 121 | |
mukesh agrawal | de29fa8 | 2011-09-16 16:16:36 -0700 | [diff] [blame] | 122 | PropertyStore *mutable_store() { return &store_; } |
| 123 | const PropertyStore &store() const { return store_; } |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 124 | RTNLHandler *rtnl_handler() { return rtnl_handler_; } |
Chris Masone | 19e3040 | 2011-07-19 15:48:47 -0700 | [diff] [blame] | 125 | |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 126 | EventDispatcher *dispatcher() const { return dispatcher_; } |
| 127 | |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 128 | // Load configuration for the device from |storage|. This may include |
| 129 | // instantiating non-visible services for which configuration has been |
| 130 | // stored. |
| 131 | virtual bool Load(StoreInterface *storage); |
| 132 | |
| 133 | // Save configuration for the device to |storage|. |
Chris Masone | 877ff98 | 2011-09-21 16:18:24 -0700 | [diff] [blame] | 134 | virtual bool Save(StoreInterface *storage); |
Chris Masone | 5dec5f4 | 2011-07-22 14:07:55 -0700 | [diff] [blame] | 135 | |
Darin Petkov | 77cb681 | 2011-08-15 16:19:41 -0700 | [diff] [blame] | 136 | void set_dhcp_provider(DHCPProvider *provider) { dhcp_provider_ = provider; } |
| 137 | |
Darin Petkov | 3cfbf21 | 2011-11-21 16:02:09 +0100 | [diff] [blame] | 138 | DeviceAdaptorInterface *adaptor() const { return adaptor_.get(); } |
| 139 | |
Paul Stewart | d584377 | 2011-05-11 15:40:42 -0700 | [diff] [blame] | 140 | protected: |
Paul Stewart | 2bf1d35 | 2011-12-06 15:02:55 -0800 | [diff] [blame] | 141 | FRIEND_TEST(DeviceTest, AcquireIPConfig); |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 142 | FRIEND_TEST(DeviceTest, DestroyIPConfig); |
| 143 | FRIEND_TEST(DeviceTest, DestroyIPConfigNULL); |
Chris Masone | 95207da | 2011-06-29 16:50:49 -0700 | [diff] [blame] | 144 | FRIEND_TEST(DeviceTest, GetProperties); |
Chris Masone | 5dec5f4 | 2011-07-22 14:07:55 -0700 | [diff] [blame] | 145 | FRIEND_TEST(DeviceTest, Save); |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 146 | FRIEND_TEST(DeviceTest, SelectedService); |
Paul Stewart | c681fa0 | 2012-03-02 19:40:04 -0800 | [diff] [blame] | 147 | FRIEND_TEST(DeviceTest, SetServiceConnectedState); |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 148 | FRIEND_TEST(DeviceTest, Stop); |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 149 | FRIEND_TEST(ManagerTest, DeviceRegistrationAndStart); |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 150 | FRIEND_TEST(ManagerTest, ConnectedTechnologies); |
| 151 | FRIEND_TEST(ManagerTest, DefaultTechnology); |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 152 | FRIEND_TEST(WiFiMainTest, Connect); |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 153 | |
| 154 | // If there's an IP configuration in |ipconfig_|, releases the IP address and |
| 155 | // destroys the configuration instance. |
| 156 | void DestroyIPConfig(); |
| 157 | |
| 158 | // Creates a new DHCP IP configuration instance, stores it in |ipconfig_| and |
| 159 | // requests a new IP configuration. Registers a callback to |
| 160 | // IPConfigUpdatedCallback on IP configuration changes. Returns true if the IP |
| 161 | // request was successfully sent. |
Paul Stewart | 2bf1d35 | 2011-12-06 15:02:55 -0800 | [diff] [blame] | 162 | bool AcquireIPConfig(); |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 163 | |
Darin Petkov | 79d74c9 | 2012-03-07 17:20:32 +0100 | [diff] [blame] | 164 | // Callback invoked on every IP configuration update. |
| 165 | void OnIPConfigUpdated(const IPConfigRefPtr &ipconfig, bool success); |
| 166 | |
Paul Stewart | e613202 | 2011-08-16 09:11:02 -0700 | [diff] [blame] | 167 | // Maintain connection state (Routes, IP Addresses and DNS) in the OS. |
| 168 | void CreateConnection(); |
| 169 | |
| 170 | // Remove connection state |
| 171 | void DestroyConnection(); |
| 172 | |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 173 | // Selects a service to be "current" -- i.e. link-state or configuration |
| 174 | // events that happen to the device are attributed to this service. |
| 175 | void SelectService(const ServiceRefPtr &service); |
| 176 | |
| 177 | // Set the state of the selected service |
| 178 | void SetServiceState(Service::ConnectState state); |
| 179 | |
| 180 | // Set the failure of the selected service (implicitly sets the state to |
| 181 | // "failure") |
| 182 | void SetServiceFailure(Service::ConnectFailure failure_state); |
| 183 | |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 184 | // Called by the Portal Detector whenever a trial completes. Device |
| 185 | // subclasses that choose unique mappings from portal results to connected |
| 186 | // states can override this method in order to do so. |
| 187 | virtual void PortalDetectorCallback(const PortalDetector::Result &result); |
| 188 | |
| 189 | // Initiate portal detection, if enabled for this device type. |
| 190 | bool StartPortalDetection(); |
| 191 | |
| 192 | // Stop portal detection if it is running. |
| 193 | void StopPortalDetection(); |
| 194 | |
| 195 | // Set the state of the selected service, with checks to make sure |
| 196 | // the service is already in a connected state before doing so. |
| 197 | void SetServiceConnectedState(Service::ConnectState state); |
| 198 | |
Jason Glasgow | b579005 | 2012-01-27 01:03:52 -0500 | [diff] [blame] | 199 | void HelpRegisterDerivedString( |
| 200 | const std::string &name, |
| 201 | std::string(Device::*get)(Error *), |
| 202 | void(Device::*set)(const std::string&, Error *)); |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 203 | void HelpRegisterDerivedStrings(const std::string &name, |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 204 | Strings(Device::*get)(Error *), |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 205 | void(Device::*set)(const Strings&, Error *)); |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 206 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 207 | // Property getters reserved for subclasses |
| 208 | ControlInterface *control_interface() const { return control_interface_; } |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 209 | Metrics *metrics() const { return metrics_; } |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 210 | Manager *manager() const { return manager_; } |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 211 | bool running() const { return running_; } |
Paul Stewart | d584377 | 2011-05-11 15:40:42 -0700 | [diff] [blame] | 212 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 213 | private: |
Chris Masone | 413a319 | 2011-05-09 17:10:05 -0700 | [diff] [blame] | 214 | friend class DeviceAdaptorInterface; |
Paul Stewart | c681fa0 | 2012-03-02 19:40:04 -0800 | [diff] [blame] | 215 | friend class DevicePortalDetectionTest; |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 216 | friend class DeviceTest; |
| 217 | friend class CellularTest; |
| 218 | friend class WiFiMainTest; |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 219 | |
Paul Stewart | 2bf1d35 | 2011-12-06 15:02:55 -0800 | [diff] [blame] | 220 | static const char kIPFlagTemplate[]; |
| 221 | static const char kIPFlagVersion4[]; |
| 222 | static const char kIPFlagVersion6[]; |
| 223 | static const char kIPFlagDisableIPv6[]; |
| 224 | static const char kIPFlagUseTempAddr[]; |
| 225 | static const char kIPFlagUseTempAddrUsedAndDefault[]; |
Paul Stewart | c8f4bef | 2011-12-13 09:45:51 -0800 | [diff] [blame] | 226 | static const char kIPFlagReversePathFilter[]; |
| 227 | static const char kIPFlagReversePathFilterEnabled[]; |
| 228 | static const char kIPFlagReversePathFilterLooseMode[]; |
Chris Masone | 5dec5f4 | 2011-07-22 14:07:55 -0700 | [diff] [blame] | 229 | static const char kStoragePowered[]; |
| 230 | static const char kStorageIPConfigs[]; |
| 231 | |
Chris Masone | 5dec5f4 | 2011-07-22 14:07:55 -0700 | [diff] [blame] | 232 | // Right now, Devices reference IPConfigs directly when persisted to disk |
| 233 | // It's not clear that this makes sense long-term, but that's how it is now. |
| 234 | // This call generates a string in the right format for this persisting. |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 235 | // |suffix| is injected into the storage identifier used for the configs. |
| 236 | std::string SerializeIPConfigs(const std::string &suffix); |
Chris Masone | 5dec5f4 | 2011-07-22 14:07:55 -0700 | [diff] [blame] | 237 | |
Paul Stewart | 2bf1d35 | 2011-12-06 15:02:55 -0800 | [diff] [blame] | 238 | // Set an IP configuration flag on the device. |ip_version| should be |
| 239 | // "ipv6" or "ipv4". |flag| should be the name of the flag to be set |
| 240 | // and |value| is what this flag should be set to. |
| 241 | bool SetIPFlag(IPAddress::Family family, const std::string &flag, |
| 242 | const std::string &value); |
| 243 | |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 244 | std::vector<std::string> AvailableIPConfigs(Error *error); |
Chris Masone | 4e85161 | 2011-07-01 10:46:53 -0700 | [diff] [blame] | 245 | std::string GetRpcConnectionIdentifier(); |
| 246 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 247 | // Properties |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 248 | bool powered_; // indicates whether the device is configured to operate |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 249 | bool reconnect_; |
| 250 | const std::string hardware_address_; |
| 251 | |
| 252 | PropertyStore store_; |
| 253 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 254 | const int interface_index_; |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 255 | bool running_; // indicates whether the device is actually in operation |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 256 | const std::string link_name_; |
| 257 | const std::string unique_id_; |
| 258 | ControlInterface *control_interface_; |
| 259 | EventDispatcher *dispatcher_; |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 260 | Metrics *metrics_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 261 | Manager *manager_; |
| 262 | IPConfigRefPtr ipconfig_; |
| 263 | ConnectionRefPtr connection_; |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 264 | scoped_ptr<DeviceAdaptorInterface> adaptor_; |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 265 | scoped_ptr<PortalDetector> portal_detector_; |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 266 | base::Callback<void(const PortalDetector::Result &)> |
| 267 | portal_detector_callback_; |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 268 | Technology::Identifier technology_; |
Thieu Le | 85e050b | 2012-03-13 15:04:38 -0700 | [diff] [blame] | 269 | // The number of portal detection attempts from Connected to Online state. |
| 270 | // This includes all failure/timeout attempts and the final successful |
| 271 | // attempt. |
| 272 | int portal_attempts_to_online_; |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 273 | |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 274 | // Maintain a reference to the connected / connecting service |
| 275 | ServiceRefPtr selected_service_; |
| 276 | |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 277 | // Cache singleton pointers for performance and test purposes. |
Darin Petkov | 77cb681 | 2011-08-15 16:19:41 -0700 | [diff] [blame] | 278 | DHCPProvider *dhcp_provider_; |
Thieu Le | fb46caf | 2012-03-08 11:57:15 -0800 | [diff] [blame] | 279 | RoutingTable *routing_table_; |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 280 | RTNLHandler *rtnl_handler_; |
Darin Petkov | 77cb681 | 2011-08-15 16:19:41 -0700 | [diff] [blame] | 281 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 282 | DISALLOW_COPY_AND_ASSIGN(Device); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 283 | }; |
| 284 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 285 | } // namespace shill |
| 286 | |
| 287 | #endif // SHILL_DEVICE_ |