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 | 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 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 5 | #ifndef SHILL_SERVICE_ |
| 6 | #define SHILL_SERVICE_ |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 7 | |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 8 | #include <time.h> |
| 9 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 10 | #include <string> |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 11 | #include <map> |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 12 | #include <set> |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 13 | #include <vector> |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 14 | |
| 15 | #include <base/memory/ref_counted.h> |
Paul Stewart | ba41b99 | 2011-05-26 07:02:46 -0700 | [diff] [blame] | 16 | #include <base/memory/scoped_ptr.h> |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 17 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 18 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 19 | #include "shill/adaptor_interfaces.h" |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 20 | #include "shill/accessor_interface.h" |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 21 | #include "shill/callbacks.h" |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 22 | #include "shill/property_store.h" |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 23 | #include "shill/refptr_types.h" |
Paul Stewart | 1062d9d | 2012-04-27 10:42:27 -0700 | [diff] [blame] | 24 | #include "shill/static_ip_parameters.h" |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 25 | #include "shill/technology.h" |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 26 | |
Thieu Le | b84ba34 | 2012-03-02 15:15:19 -0800 | [diff] [blame] | 27 | namespace chromeos_metrics { |
| 28 | class Timer; |
| 29 | } |
| 30 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 31 | namespace shill { |
| 32 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 33 | class Configuration; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 34 | class ControlInterface; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 35 | class Endpoint; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 36 | class Error; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 37 | class EventDispatcher; |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 38 | class HTTPProxy; |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 39 | class KeyValueStore; |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 40 | class Manager; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 41 | class Metrics; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 42 | class ServiceAdaptorInterface; |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 43 | class Sockets; |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 44 | class StoreInterface; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 45 | |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 46 | // A Service is a uniquely named entity, which the system can |
| 47 | // connect in order to begin sending and receiving network traffic. |
| 48 | // All Services are bound to an Entry, which represents the persistable |
| 49 | // state of the Service. If the Entry is populated at the time of Service |
| 50 | // creation, that information is used to prime the Service. If not, the Entry |
| 51 | // becomes populated over time. |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 52 | class Service : public base::RefCounted<Service> { |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 53 | public: |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 54 | static const char kCheckPortalAuto[]; |
| 55 | static const char kCheckPortalFalse[]; |
| 56 | static const char kCheckPortalTrue[]; |
| 57 | |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 58 | // TODO(pstew): Storage constants shouldn't need to be public |
| 59 | // crosbug.com/25813 |
| 60 | static const char kStorageAutoConnect[]; |
| 61 | static const char kStorageCheckPortal[]; |
| 62 | static const char kStorageEapAnonymousIdentity[]; |
| 63 | static const char kStorageEapCACert[]; |
| 64 | static const char kStorageEapCACertID[]; |
Paul Stewart | ecf4cd1 | 2012-04-17 11:08:39 -0700 | [diff] [blame] | 65 | static const char kStorageEapCACertNSS[]; |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 66 | static const char kStorageEapCertID[]; |
| 67 | static const char kStorageEapClientCert[]; |
| 68 | static const char kStorageEapEap[]; |
| 69 | static const char kStorageEapIdentity[]; |
| 70 | static const char kStorageEapInnerEap[]; |
| 71 | static const char kStorageEapKeyID[]; |
| 72 | static const char kStorageEapKeyManagement[]; |
| 73 | static const char kStorageEapPIN[]; |
| 74 | static const char kStorageEapPassword[]; |
| 75 | static const char kStorageEapPrivateKey[]; |
| 76 | static const char kStorageEapPrivateKeyPassword[]; |
| 77 | static const char kStorageEapUseSystemCAs[]; |
| 78 | static const char kStorageError[]; |
| 79 | static const char kStorageFavorite[]; |
| 80 | static const char kStorageGUID[]; |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 81 | static const char kStorageHasEverConnected[]; |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 82 | static const char kStorageName[]; |
| 83 | static const char kStoragePriority[]; |
| 84 | static const char kStorageProxyConfig[]; |
| 85 | static const char kStorageSaveCredentials[]; |
| 86 | static const char kStorageType[]; |
| 87 | static const char kStorageUIData[]; |
| 88 | |
mukesh agrawal | 8f3f775 | 2012-02-17 19:42:09 -0800 | [diff] [blame] | 89 | static const uint8 kStrengthMax; |
| 90 | static const uint8 kStrengthMin; |
| 91 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 92 | enum ConnectFailure { |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 93 | kFailureUnknown, |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 94 | kFailureActivation, |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 95 | kFailureOutOfRange, |
| 96 | kFailurePinMissing, |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 97 | kFailureDHCP, |
| 98 | kFailureBadPassphrase, |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 99 | kFailureNeedEVDO, |
| 100 | kFailureNeedHomeNetwork, |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 101 | kFailureOTASP, |
| 102 | kFailureAAA, |
| 103 | kFailureBadWEPKey, |
| 104 | kFailureConnect, |
| 105 | kFailureDNSLookup, |
| 106 | kFailureHTTPGet, |
| 107 | kFailurePPPAuth, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 108 | kFailureMax |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 109 | }; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 110 | enum ConnectState { |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 111 | kStateUnknown, |
| 112 | kStateIdle, |
| 113 | kStateAssociating, |
| 114 | kStateConfiguring, |
| 115 | kStateConnected, |
| 116 | kStateDisconnected, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 117 | kStatePortal, |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 118 | kStateFailure, |
| 119 | kStateOnline |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 120 | }; |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 121 | struct EapCredentials { |
Paul Stewart | 2055098 | 2012-04-16 12:16:11 -0700 | [diff] [blame] | 122 | EapCredentials() : use_system_cas(true) {} |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 123 | // Who we identify ourselves as to the EAP authenticator. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 124 | std::string identity; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 125 | // The outer or only EAP authetnication type. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 126 | std::string eap; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 127 | // The inner EAP authentication type. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 128 | std::string inner_eap; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 129 | // When there is an inner EAP type, use this identity for the outer. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 130 | std::string anonymous_identity; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 131 | // Filename of the client certificate. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 132 | std::string client_cert; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 133 | // Locator for the client certificate within the security token. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 134 | std::string cert_id; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 135 | // Filename of the client private key. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 136 | std::string private_key; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 137 | // Password for decrypting the client private key file. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 138 | std::string private_key_password; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 139 | // Locator for the client private key within the security token. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 140 | std::string key_id; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 141 | // Filename of the certificate authority (CA) certificate. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 142 | std::string ca_cert; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 143 | // Locator for the CA certificate within the security token. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 144 | std::string ca_cert_id; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 145 | // Locator for the CA certificate within the user NSS database. |
Paul Stewart | ecf4cd1 | 2012-04-17 11:08:39 -0700 | [diff] [blame] | 146 | std::string ca_cert_nss; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 147 | // If true, use the system-wide CA database to authenticate the remote. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 148 | bool use_system_cas; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 149 | // PIN code for accessing the security token. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 150 | std::string pin; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 151 | // Password to use for EAP methods which require one. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 152 | std::string password; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 153 | // Key management algorithm to use after EAP succeeds. |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 154 | std::string key_management; |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 155 | // If non-empty, string to match remote subject against before connecting. |
| 156 | std::string subject_match; |
| 157 | // List of subject names reported by remote entity during TLS setup. |
| 158 | std::vector<std::string> remote_certification; |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 159 | }; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 160 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 161 | static const int kPriorityNone; |
| 162 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 163 | // A constructor for the Service object |
| 164 | Service(ControlInterface *control_interface, |
| 165 | EventDispatcher *dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 166 | Metrics *metrics, |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 167 | Manager *manager, |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 168 | Technology::Identifier technology); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 169 | |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 170 | // AutoConnect MAY choose to ignore the connection request in some |
| 171 | // cases. For example, if the corresponding Device only supports one |
| 172 | // concurrent connection, and another Service is already connected |
| 173 | // or connecting. |
| 174 | // |
| 175 | // AutoConnect MAY issue RPCs immediately. So AutoConnect MUST NOT |
| 176 | // be called from a D-Bus signal handler context. |
| 177 | virtual void AutoConnect(); |
| 178 | // Queue up a connection attempt. |
mukesh agrawal | adb6848 | 2012-01-17 16:31:51 -0800 | [diff] [blame] | 179 | virtual void Connect(Error *error); |
| 180 | // Disconnect this service. The service will not be eligible for |
| 181 | // auto-connect until a subsequent call to Connect, or Load. |
| 182 | virtual void Disconnect(Error *error); |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 183 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 184 | // The default implementation returns the error kInvalidArguments. |
| 185 | virtual void ActivateCellularModem(const std::string &carrier, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 186 | Error *error, |
| 187 | const ResultCallback &callback); |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 188 | |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 189 | virtual bool IsActive(Error *error); |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 190 | |
Paul Stewart | 7fb0938 | 2012-07-18 17:32:27 -0700 | [diff] [blame] | 191 | // Returns whether services of this type should be auto-connect by default. |
| 192 | virtual bool IsAutoConnectByDefault() const { return false; } |
| 193 | |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 194 | virtual ConnectState state() const { return state_; } |
| 195 | // Updates the state of the Service and alerts the manager. Also |
| 196 | // clears |failure_| if the new state isn't a failure. |
| 197 | virtual void SetState(ConnectState state); |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 198 | std::string GetStateString() const; |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 199 | |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 200 | // State utility functions |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 201 | virtual bool IsConnected() const { |
| 202 | return state() == kStateConnected || state() == kStatePortal || |
| 203 | state() == kStateOnline; |
| 204 | } |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 205 | virtual bool IsConnecting() const { |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 206 | return state() == kStateAssociating || state() == kStateConfiguring; |
| 207 | } |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 208 | virtual bool IsFailed() const { |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 209 | // We sometimes lie about the failure state, to keep Chrome happy |
| 210 | // (see comment in WiFi::HandleDisconnect). Hence, we check both |
| 211 | // state and |failed_time_|. |
| 212 | return state() == kStateFailure || failed_time_ > 0; |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 213 | } |
Paul Stewart | a121c44 | 2012-06-09 14:12:58 -0700 | [diff] [blame] | 214 | virtual bool IsPortalled() const { |
| 215 | return state() == kStatePortal; |
| 216 | } |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 217 | |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 218 | virtual ConnectFailure failure() const { return failure_; } |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 219 | // Records the failure mode and time. Sets the Service state to "Failure". |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 220 | virtual void SetFailure(ConnectFailure failure); |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 221 | // Records the failure mode and time. Sets the Service state to "Idle". |
| 222 | // Avoids showing a failure mole in the UI. |
| 223 | virtual void SetFailureSilent(ConnectFailure failure); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 224 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 225 | // Returns a string that is guaranteed to uniquely identify this Service |
| 226 | // instance. |
mukesh agrawal | d835b20 | 2011-10-07 15:26:47 -0700 | [diff] [blame] | 227 | const std::string &UniqueName() const { return unique_name_; } |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 228 | |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 229 | virtual std::string GetRpcIdentifier() const; |
Chris Masone | 3c3f6a1 | 2011-07-01 10:01:41 -0700 | [diff] [blame] | 230 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 231 | // Returns the unique persistent storage identifier for the service. |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 232 | virtual std::string GetStorageIdentifier() const = 0; |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 233 | |
Paul Stewart | bba6a5b | 2011-11-02 18:45:59 -0700 | [diff] [blame] | 234 | // Returns whether the service configuration can be loaded from |storage|. |
| 235 | virtual bool IsLoadableFrom(StoreInterface *storage) const; |
| 236 | |
Paul Stewart | 8142613 | 2012-05-16 10:05:10 -0700 | [diff] [blame] | 237 | // Returns true if the service uses 802.1x for key management. |
| 238 | virtual bool Is8021x() const { return false; }; |
| 239 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 240 | // Loads the service from persistent |storage|. Returns true on success. |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 241 | virtual bool Load(StoreInterface *storage); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 242 | |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 243 | // Indicate to service that it is no longer persisted to storage. It |
Paul Stewart | 65512e1 | 2012-03-26 18:01:08 -0700 | [diff] [blame] | 244 | // should purge any stored profile state (e.g., credentials). Returns |
| 245 | // true to indicate that this service should also be unregistered from |
| 246 | // the manager, false otherwise. |
| 247 | virtual bool Unload(); |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 248 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 249 | // Saves the service to persistent |storage|. Returns true on success. |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 250 | virtual bool Save(StoreInterface *storage); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 251 | |
Thieu Le | d4e9e55 | 2012-02-16 16:26:07 -0800 | [diff] [blame] | 252 | // Saves the service to the current profile. |
Gary Morain | d93615e | 2012-04-27 11:50:03 -0700 | [diff] [blame] | 253 | virtual void SaveToCurrentProfile(); |
Thieu Le | d4e9e55 | 2012-02-16 16:26:07 -0800 | [diff] [blame] | 254 | |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 255 | // Applies all the properties in |args| to this service object's mutable |
| 256 | // store, except for those in parameters_ignored_for_configure_. |
| 257 | // Returns an error in |error| if one or more parameter set attempts |
| 258 | // fails, but will only return the first error. |
| 259 | virtual void Configure(const KeyValueStore &args, Error *error); |
| 260 | |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 261 | // Returns whether portal detection is explicitly disabled on this service |
| 262 | // via a property set on it. |
| 263 | virtual bool IsPortalDetectionDisabled() const; |
| 264 | |
| 265 | // Returns whether portal detection is set to follow the default setting |
| 266 | // of this service's technology via a property set on it. |
| 267 | virtual bool IsPortalDetectionAuto() const; |
| 268 | |
Paul Stewart | 10ccbb3 | 2012-04-26 15:59:30 -0700 | [diff] [blame] | 269 | // Returns true if the service is persisted to a non-ephemeral profile. |
| 270 | virtual bool IsRemembered() const; |
| 271 | |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 272 | // Returns true if the service RPC identifier should be part of the |
| 273 | // manager's advertised services list, false otherwise. |
| 274 | virtual bool IsVisible() const { return true; } |
| 275 | |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 276 | // Returns true if there is a proxy configuration set on this service. |
| 277 | virtual bool HasProxyConfig() const { return !proxy_config_.empty(); } |
| 278 | |
mukesh agrawal | 00917ce | 2011-11-22 23:56:55 +0000 | [diff] [blame] | 279 | virtual void MakeFavorite(); |
| 280 | |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 281 | // Set the connection for this service. If the connection is non-NULL, create |
| 282 | // an HTTP Proxy that will utilize this service's connection to serve |
| 283 | // requests. |
| 284 | virtual void SetConnection(const ConnectionRefPtr &connection); |
| 285 | virtual const ConnectionRefPtr &connection() const { return connection_; } |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 286 | |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 287 | // Examines the EAP credentials for the service and returns true if a |
| 288 | // connection attempt can be made. |
| 289 | bool Is8021xConnectable() const; |
| 290 | |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 291 | // Add an EAP certification id |name| at position |depth| in the stack. |
| 292 | // Returns true if entry was added, false otherwise. |
| 293 | virtual bool AddEAPCertification(const std::string &name, size_t depth); |
| 294 | // Clear all EAP certification elements. |
| 295 | void ClearEAPCertification(); |
| 296 | |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 297 | // The inherited class should register any custom metrics in this method. |
| 298 | virtual void InitializeCustomMetrics() const {} |
| 299 | |
| 300 | // The inherited class that needs to send metrics after the service has |
Thieu Le | b84ba34 | 2012-03-02 15:15:19 -0800 | [diff] [blame] | 301 | // transitioned to the ready state should override this method. |
| 302 | // |time_resume_to_ready_milliseconds| holds the elapsed time from when |
| 303 | // the system was resumed until when the service transitioned to the |
| 304 | // connected state. This value is non-zero for the first service transition |
| 305 | // to the connected state after a resume. |
| 306 | virtual void SendPostReadyStateMetrics( |
| 307 | int64 /*time_resume_to_ready_milliseconds*/) const {} |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 308 | |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 309 | bool auto_connect() const { return auto_connect_; } |
| 310 | void set_auto_connect(bool connect) { auto_connect_ = connect; } |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 311 | |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 312 | bool connectable() const { return connectable_; } |
Darin Petkov | b2ba39f | 2012-06-06 10:33:43 +0200 | [diff] [blame] | 313 | // TODO(petkov): Remove this method in favor of SetConnectable. |
mukesh agrawal | 29c13a1 | 2011-11-24 00:09:19 +0000 | [diff] [blame] | 314 | void set_connectable(bool connectable); |
Darin Petkov | b2ba39f | 2012-06-06 10:33:43 +0200 | [diff] [blame] | 315 | // Sets the connectable property of the service. Broadcasts the new value and |
| 316 | // alerts the manager if necessary. |
| 317 | void SetConnectable(bool connectable); |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 318 | |
Thieu Le | 67370f6 | 2012-02-14 23:01:42 +0000 | [diff] [blame] | 319 | virtual bool explicitly_disconnected() const { |
| 320 | return explicitly_disconnected_; |
| 321 | } |
| 322 | |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 323 | bool favorite() const { return favorite_; } |
mukesh agrawal | 00917ce | 2011-11-22 23:56:55 +0000 | [diff] [blame] | 324 | // Setter is deliberately omitted; use MakeFavorite. |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 325 | |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 326 | const std::string &friendly_name() const { return friendly_name_; } |
Darin Petkov | 7f06033 | 2012-03-14 11:46:47 +0100 | [diff] [blame] | 327 | void set_friendly_name(const std::string &n) { friendly_name_ = n; } |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 328 | |
Paul Stewart | 4c56161 | 2012-03-21 12:49:01 -0700 | [diff] [blame] | 329 | const std::string &guid() const { return guid_; } |
| 330 | void set_guid(const std::string &guid) { guid_ = guid; } |
| 331 | |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 332 | bool has_ever_connected() const { return has_ever_connected_; } |
| 333 | |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 334 | int32 priority() const { return priority_; } |
| 335 | void set_priority(int32 priority) { priority_ = priority; } |
| 336 | |
Paul Stewart | 1ca3e85 | 2011-11-04 07:50:49 -0700 | [diff] [blame] | 337 | int32 security_level() const { return security_level_; } |
| 338 | void set_security_level(int32 security) { security_level_ = security; } |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 339 | |
Darin Petkov | d78ee7e | 2012-01-12 11:21:10 +0100 | [diff] [blame] | 340 | void SetStrength(uint8 strength); |
mukesh agrawal | e1d90e9 | 2012-02-15 17:36:08 -0800 | [diff] [blame] | 341 | |
| 342 | // uint8 streams out as a char. Coerce to a larger type, so that |
| 343 | // it prints as a number. |
| 344 | uint16 strength() const { return strength_; } |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 345 | |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 346 | virtual Technology::Identifier technology() const { return technology_; } |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 347 | std::string GetTechnologyString() const; |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 348 | |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 349 | const EapCredentials &eap() const { return eap_; } |
| 350 | virtual void set_eap(const EapCredentials &eap); |
| 351 | |
Darin Petkov | cb71529 | 2012-04-25 13:04:37 +0200 | [diff] [blame] | 352 | bool save_credentials() const { return save_credentials_; } |
| 353 | void set_save_credentials(bool save) { save_credentials_ = save; } |
| 354 | |
Darin Petkov | 5148900 | 2011-08-18 13:13:20 -0700 | [diff] [blame] | 355 | const std::string &error() const { return error_; } |
| 356 | void set_error(const std::string &error) { error_ = error; } |
| 357 | |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 358 | static const char *ConnectFailureToString(const ConnectFailure &state); |
| 359 | static const char *ConnectStateToString(const ConnectState &state); |
| 360 | |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 361 | // Compare two services. Returns true if Service a should be displayed |
| 362 | // above Service b |
| 363 | static bool Compare(ServiceRefPtr a, |
| 364 | ServiceRefPtr b, |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 365 | const std::vector<Technology::Identifier> &tech_order, |
| 366 | const char **reason); |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 367 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 368 | // These are defined in service.cc so that we don't have to include profile.h |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 369 | // TODO(cmasone): right now, these are here only so that we can get the |
| 370 | // profile name as a property. Can we store just the name, and then handle |
| 371 | // setting the profile for this service via |manager_|? |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 372 | const ProfileRefPtr &profile() const; |
| 373 | void set_profile(const ProfileRefPtr &p); |
| 374 | |
Paul Stewart | 4357f4e | 2012-04-26 17:39:26 -0700 | [diff] [blame] | 375 | // Notification that occurs when a service now has profile data saved |
| 376 | // on its behalf. Some service types like WiFi can choose to register |
| 377 | // themselves at this point. |
| 378 | virtual void OnProfileConfigured() {} |
| 379 | |
Paul Stewart | ff14b02 | 2012-04-24 20:06:23 -0700 | [diff] [blame] | 380 | // Notification that occurs when a single property has been changed via |
| 381 | // the RPC adaptor. |
Paul Stewart | 8142613 | 2012-05-16 10:05:10 -0700 | [diff] [blame] | 382 | virtual void OnPropertyChanged(const std::string &property); |
Paul Stewart | ff14b02 | 2012-04-24 20:06:23 -0700 | [diff] [blame] | 383 | |
mukesh agrawal | de29fa8 | 2011-09-16 16:16:36 -0700 | [diff] [blame] | 384 | PropertyStore *mutable_store() { return &store_; } |
| 385 | const PropertyStore &store() const { return store_; } |
Paul Stewart | def189e | 2012-08-02 20:12:09 -0700 | [diff] [blame] | 386 | StaticIPParameters *mutable_static_ip_parameters() { |
| 387 | return &static_ip_parameters_; |
| 388 | } |
Paul Stewart | 1062d9d | 2012-04-27 10:42:27 -0700 | [diff] [blame] | 389 | const StaticIPParameters &static_ip_parameters() const { |
| 390 | return static_ip_parameters_; |
| 391 | } |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 392 | |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 393 | protected: |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 394 | friend class base::RefCounted<Service>; |
| 395 | |
| 396 | virtual ~Service(); |
| 397 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 398 | // Returns true if a character is allowed to be in a service storage id. |
| 399 | static bool LegalChar(char a) { return isalnum(a) || a == '_'; } |
| 400 | |
Darin Petkov | 3133241 | 2012-01-28 01:50:02 +0100 | [diff] [blame] | 401 | // Returns true if a character is disallowed to be in a service storage id. |
| 402 | static bool IllegalChar(char a) { return !LegalChar(a); } |
| 403 | |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 404 | virtual std::string CalculateState(Error *error); |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 405 | std::string CalculateTechnology(Error *error); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 406 | |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 407 | // Returns whether this service is in a state conducive to auto-connect. |
| 408 | // This should include any tests used for computing connectable(), |
| 409 | // as well as other critera such as whether the device associated with |
| 410 | // this service is busy with another connection. |
mukesh agrawal | bf14e94 | 2012-03-02 14:36:34 -0800 | [diff] [blame] | 411 | // |
| 412 | // If the service is not auto-connectable, |*reason| will be set to |
| 413 | // point to C-string explaining why the service is not auto-connectable. |
| 414 | virtual bool IsAutoConnectable(const char **reason) const; |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 415 | |
mukesh agrawal | 292dc0f | 2012-01-26 18:02:46 -0800 | [diff] [blame] | 416 | // HelpRegisterDerived*: Expose a property over RPC, with the name |name|. |
| 417 | // |
| 418 | // Reads of the property will be handled by invoking |get|. |
| 419 | // Writes to the property will be handled by invoking |set|. |
| 420 | // Clearing the property will be handled by PropertyStore. |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 421 | void HelpRegisterDerivedBool( |
| 422 | const std::string &name, |
Hristo Stefanov | ed2c28c | 2011-11-29 15:37:30 -0800 | [diff] [blame] | 423 | bool(Service::*get)(Error *error), |
| 424 | void(Service::*set)(const bool &value, Error *error)); |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 425 | void HelpRegisterDerivedString( |
| 426 | const std::string &name, |
Hristo Stefanov | ed2c28c | 2011-11-29 15:37:30 -0800 | [diff] [blame] | 427 | std::string(Service::*get)(Error *error), |
| 428 | void(Service::*set)(const std::string &value, Error *error)); |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 429 | void HelpRegisterDerivedUint16( |
| 430 | const std::string &name, |
| 431 | uint16(Service::*get)(Error *error), |
| 432 | void(Service::*set)(const uint16 &value, Error *error)); |
Jason Glasgow | acdc11f | 2012-03-30 14:12:22 -0400 | [diff] [blame] | 433 | void HelpRegisterDerivedRpcIdentifier( |
| 434 | const std::string &name, |
| 435 | std::string(Service::*get)(Error *), |
| 436 | void(Service::*set)(const RpcIdentifier&, Error *)); |
mukesh agrawal | 292dc0f | 2012-01-26 18:02:46 -0800 | [diff] [blame] | 437 | // Expose a property over RPC, with the name |name|. |
| 438 | // |
| 439 | // Reads of the property will be handled by invoking |get|. |
| 440 | // Writes to the property will be handled by invoking |set|. |
| 441 | // |
| 442 | // Clearing the property will be handled by invoking |clear|, or |
| 443 | // calling |set| with |default_value| (whichever is non-NULL). It |
| 444 | // is an error to call this method with both |clear| and |
| 445 | // |default_value| non-NULL. |
| 446 | void HelpRegisterWriteOnlyDerivedString( |
| 447 | const std::string &name, |
| 448 | void(Service::*set)(const std::string &value, Error *error), |
| 449 | void(Service::*clear)(Error *error), |
| 450 | const std::string *default_value); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 451 | |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 452 | ServiceAdaptorInterface *adaptor() const { return adaptor_.get(); } |
| 453 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 454 | // Assigns |value| to |key| in |storage| if |value| is non-empty and |save| is |
| 455 | // true. Otherwise, removes |key| from |storage|. If |crypted| is true, the |
| 456 | // value is encrypted. |
| 457 | void SaveString(StoreInterface *storage, |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 458 | const std::string &id, |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 459 | const std::string &key, |
| 460 | const std::string &value, |
| 461 | bool crypted, |
| 462 | bool save); |
| 463 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 464 | void LoadEapCredentials(StoreInterface *storage, const std::string &id); |
| 465 | void SaveEapCredentials(StoreInterface *storage, const std::string &id); |
Paul Stewart | d8ad3c4 | 2012-01-09 12:39:38 -0800 | [diff] [blame] | 466 | void UnloadEapCredentials(); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 467 | |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 468 | // Ignore |parameter| when performing a Configure() operation. |
| 469 | void IgnoreParameterForConfigure(const std::string ¶meter); |
| 470 | |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 471 | // Update the service's string-based "Error" RPC property based on the |
| 472 | // failure_ enum. |
| 473 | void UpdateErrorProperty(); |
| 474 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 475 | // Property accessors reserved for subclasses |
| 476 | EventDispatcher *dispatcher() const { return dispatcher_; } |
| 477 | const std::string &GetEAPKeyManagement() const; |
| 478 | void SetEAPKeyManagement(const std::string &key_management); |
Paul Stewart | 9f32d19 | 2012-01-30 20:37:50 -0800 | [diff] [blame] | 479 | void SetEAPPassword(const std::string &password, Error *error); |
| 480 | void SetEAPPrivateKeyPassword(const std::string &password, Error *error); |
Paul Stewart | 65512e1 | 2012-03-26 18:01:08 -0700 | [diff] [blame] | 481 | Manager *manager() const { return manager_; } |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 482 | Metrics *metrics() const { return metrics_; } |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 483 | |
Darin Petkov | 1d0080a | 2012-04-30 17:10:36 +0200 | [diff] [blame] | 484 | void set_favorite(bool favorite) { favorite_ = favorite; } |
| 485 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 486 | private: |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 487 | friend class MetricsTest; |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 488 | friend class ServiceAdaptorInterface; |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 489 | friend class VPNServiceTest; |
mukesh agrawal | e1d90e9 | 2012-02-15 17:36:08 -0800 | [diff] [blame] | 490 | friend class WiFiServiceTest; |
Darin Petkov | 6b9b2e1 | 2012-07-10 15:51:42 +0200 | [diff] [blame] | 491 | friend class WiMaxServiceTest; |
mukesh agrawal | cc0fded | 2012-05-09 13:40:58 -0700 | [diff] [blame] | 492 | FRIEND_TEST(DeviceTest, IPConfigUpdatedFailureWithStatic); |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 493 | FRIEND_TEST(ServiceTest, CalculateState); |
| 494 | FRIEND_TEST(ServiceTest, CalculateTechnology); |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 495 | FRIEND_TEST(ServiceTest, Certification); |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 496 | FRIEND_TEST(ServiceTest, ConfigureIgnoredProperty); |
| 497 | FRIEND_TEST(ServiceTest, ConfigureStringProperty); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 498 | FRIEND_TEST(ServiceTest, Constructor); |
Paul Stewart | 10241e3 | 2012-04-23 18:15:06 -0700 | [diff] [blame] | 499 | FRIEND_TEST(ServiceTest, GetIPConfigRpcIdentifier); |
Thieu Le | 284fe79 | 2012-01-31 17:53:19 -0800 | [diff] [blame] | 500 | FRIEND_TEST(ServiceTest, GetProperties); |
mukesh agrawal | 76d1388 | 2012-01-12 15:23:11 -0800 | [diff] [blame] | 501 | FRIEND_TEST(ServiceTest, IsAutoConnectable); |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 502 | FRIEND_TEST(ServiceTest, RecheckPortal); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 503 | FRIEND_TEST(ServiceTest, Save); |
| 504 | FRIEND_TEST(ServiceTest, SaveString); |
| 505 | FRIEND_TEST(ServiceTest, SaveStringCrypted); |
| 506 | FRIEND_TEST(ServiceTest, SaveStringDontSave); |
| 507 | FRIEND_TEST(ServiceTest, SaveStringEmpty); |
mukesh agrawal | 6bb9e7c | 2012-01-30 14:57:54 -0800 | [diff] [blame] | 508 | FRIEND_TEST(ServiceTest, SetProperty); |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 509 | FRIEND_TEST(ServiceTest, SetCheckPortal); |
Darin Petkov | b2ba39f | 2012-06-06 10:33:43 +0200 | [diff] [blame] | 510 | FRIEND_TEST(ServiceTest, SetConnectable); |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 511 | FRIEND_TEST(ServiceTest, State); |
Paul Stewart | d8ad3c4 | 2012-01-09 12:39:38 -0800 | [diff] [blame] | 512 | FRIEND_TEST(ServiceTest, Unload); |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 513 | FRIEND_TEST(WiFiMainTest, SuspectCredentialsWPAPreviouslyConnected); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 514 | |
mukesh agrawal | bf14e94 | 2012-03-02 14:36:34 -0800 | [diff] [blame] | 515 | static const char kAutoConnConnected[]; |
| 516 | static const char kAutoConnConnecting[]; |
| 517 | static const char kAutoConnExplicitDisconnect[]; |
| 518 | static const char kAutoConnNotConnectable[]; |
| 519 | |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 520 | static const size_t kEAPMaxCertificationElements; |
| 521 | |
Darin Petkov | 2f903b3 | 2012-04-18 12:56:43 +0200 | [diff] [blame] | 522 | static const char kServiceSortAutoConnect[]; |
| 523 | static const char kServiceSortConnectable[]; |
| 524 | static const char kServiceSortFavorite[]; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 525 | static const char kServiceSortIsConnected[]; |
| 526 | static const char kServiceSortIsConnecting[]; |
| 527 | static const char kServiceSortIsFailed[]; |
Paul Stewart | a121c44 | 2012-06-09 14:12:58 -0700 | [diff] [blame] | 528 | static const char kServiceSortIsPortalled[]; |
Darin Petkov | 2f903b3 | 2012-04-18 12:56:43 +0200 | [diff] [blame] | 529 | static const char kServiceSortPriority[]; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 530 | static const char kServiceSortSecurityEtc[]; |
Darin Petkov | 2f903b3 | 2012-04-18 12:56:43 +0200 | [diff] [blame] | 531 | static const char kServiceSortTechnology[]; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 532 | static const char kServiceSortUniqueName[]; |
| 533 | |
Thieu Le | 284fe79 | 2012-01-31 17:53:19 -0800 | [diff] [blame] | 534 | bool GetAutoConnect(Error *error); |
| 535 | void SetAutoConnect(const bool &connect, Error *error); |
| 536 | |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 537 | std::string GetCheckPortal(Error *error); |
| 538 | void SetCheckPortal(const std::string &check_portal, Error *error); |
| 539 | |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 540 | virtual std::string GetDeviceRpcId(Error *error) = 0; |
Chris Masone | 95207da | 2011-06-29 16:50:49 -0700 | [diff] [blame] | 541 | |
Paul Stewart | 10241e3 | 2012-04-23 18:15:06 -0700 | [diff] [blame] | 542 | std::string GetIPConfigRpcIdentifier(Error *error); |
| 543 | |
Paul Stewart | 0c43833 | 2012-04-11 07:55:27 -0700 | [diff] [blame] | 544 | std::string GetNameProperty(Error *error); |
| 545 | void AssertTrivialSetNameProperty(const std::string &name, Error *error); |
| 546 | |
Paul Stewart | 1b1a7f2 | 2012-01-06 16:24:06 -0800 | [diff] [blame] | 547 | std::string GetProfileRpcId(Error *error); |
| 548 | void SetProfileRpcId(const std::string &profile, Error *error); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 549 | |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 550 | // Returns TCP port of service's HTTP proxy in host order. |
| 551 | uint16 GetHTTPProxyPort(Error *error); |
| 552 | |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 553 | // Saves settings to profile, if we have one. Unlike |
| 554 | // SaveServiceToProfile, SaveToProfile never assigns this service |
| 555 | // into a profile. |
| 556 | void SaveToProfile(); |
| 557 | |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 558 | // Utility function that returns true if a is different from b. When they |
| 559 | // are, "decision" is populated with the boolean value of "a > b". |
| 560 | static bool DecideBetween(int a, int b, bool *decision); |
| 561 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 562 | ConnectState state_; |
| 563 | ConnectFailure failure_; |
| 564 | bool auto_connect_; |
| 565 | std::string check_portal_; |
| 566 | bool connectable_; |
| 567 | std::string error_; |
mukesh agrawal | adb6848 | 2012-01-17 16:31:51 -0800 | [diff] [blame] | 568 | bool explicitly_disconnected_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 569 | bool favorite_; |
| 570 | int32 priority_; |
Paul Stewart | 1ca3e85 | 2011-11-04 07:50:49 -0700 | [diff] [blame] | 571 | int32 security_level_; |
Darin Petkov | d78ee7e | 2012-01-12 11:21:10 +0100 | [diff] [blame] | 572 | uint8 strength_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 573 | std::string proxy_config_; |
Paul Stewart | 987e71e | 2011-12-05 09:45:06 -0800 | [diff] [blame] | 574 | std::string ui_data_; |
Paul Stewart | 4c56161 | 2012-03-21 12:49:01 -0700 | [diff] [blame] | 575 | std::string guid_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 576 | bool save_credentials_; |
| 577 | EapCredentials eap_; // Only saved if |save_credentials_| is true. |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 578 | Technology::Identifier technology_; |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 579 | // The time of the most recent failure. Value is 0 if the service is |
| 580 | // not currently failed. |
| 581 | time_t failed_time_; |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 582 | // Whether or not this service has ever reached kStateConnected. |
| 583 | bool has_ever_connected_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 584 | |
| 585 | ProfileRefPtr profile_; |
| 586 | PropertyStore store_; |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 587 | std::set<std::string> parameters_ignored_for_configure_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 588 | |
| 589 | EventDispatcher *dispatcher_; |
mukesh agrawal | 51a7e93 | 2011-07-27 16:18:26 -0700 | [diff] [blame] | 590 | static unsigned int serial_number_; |
mukesh agrawal | d835b20 | 2011-10-07 15:26:47 -0700 | [diff] [blame] | 591 | std::string unique_name_; // MUST be unique amongst service instances |
| 592 | std::string friendly_name_; // MAY be same as |unique_name_| |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 593 | bool available_; |
| 594 | bool configured_; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 595 | Configuration *configuration_; |
Paul Stewart | ba41b99 | 2011-05-26 07:02:46 -0700 | [diff] [blame] | 596 | scoped_ptr<ServiceAdaptorInterface> adaptor_; |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 597 | scoped_ptr<HTTPProxy> http_proxy_; |
Paul Stewart | c1dec4d | 2011-12-08 15:25:28 -0800 | [diff] [blame] | 598 | ConnectionRefPtr connection_; |
Paul Stewart | 1062d9d | 2012-04-27 10:42:27 -0700 | [diff] [blame] | 599 | StaticIPParameters static_ip_parameters_; |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 600 | Metrics *metrics_; |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 601 | Manager *manager_; |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 602 | scoped_ptr<Sockets> sockets_; |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 603 | |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 604 | DISALLOW_COPY_AND_ASSIGN(Service); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 605 | }; |
| 606 | |
| 607 | } // namespace shill |
| 608 | |
| 609 | #endif // SHILL_SERVICE_ |