Arman Uguray | 2717a10 | 2013-01-29 23:36:06 -0800 | [diff] [blame] | 1 | // Copyright (c) 2013 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 | |
Ben Chan | 19f8397 | 2012-10-03 23:25:56 -0700 | [diff] [blame] | 5 | #ifndef SHILL_SERVICE_H_ |
| 6 | #define SHILL_SERVICE_H_ |
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 | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 10 | #include <map> |
Ben Chan | cd47732 | 2014-10-17 14:19:30 -0700 | [diff] [blame] | 11 | #include <memory> |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 12 | #include <set> |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 13 | #include <string> |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 14 | #include <vector> |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 15 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 16 | #include <base/cancelable_callback.h> |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 17 | #include <base/memory/ref_counted.h> |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 18 | #include <base/memory/weak_ptr.h> |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 19 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 20 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 21 | #include "shill/accessor_interface.h" |
Alex Vakulenko | a41ab51 | 2014-07-23 14:24:23 -0700 | [diff] [blame] | 22 | #include "shill/adaptor_interfaces.h" |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 23 | #include "shill/callbacks.h" |
Samuel Tan | 07dfabc | 2015-01-20 15:10:39 -0800 | [diff] [blame] | 24 | #include "shill/net/event_history.h" |
Peter Qiu | 8d6b597 | 2014-10-28 15:33:34 -0700 | [diff] [blame] | 25 | #include "shill/net/shill_time.h" |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 26 | #include "shill/property_store.h" |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 27 | #include "shill/refptr_types.h" |
Paul Stewart | 1062d9d | 2012-04-27 10:42:27 -0700 | [diff] [blame] | 28 | #include "shill/static_ip_parameters.h" |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 29 | #include "shill/technology.h" |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 30 | |
Thieu Le | b84ba34 | 2012-03-02 15:15:19 -0800 | [diff] [blame] | 31 | namespace chromeos_metrics { |
| 32 | class Timer; |
| 33 | } |
| 34 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 35 | namespace shill { |
| 36 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 37 | class ControlInterface; |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 38 | class DiagnosticsReporter; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 39 | class Endpoint; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 40 | class Error; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 41 | class EventDispatcher; |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 42 | class HTTPProxy; |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 43 | class KeyValueStore; |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 44 | class Manager; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 45 | class Metrics; |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 46 | class MockManager; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 47 | class ServiceAdaptorInterface; |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 48 | class ServiceMockAdaptor; |
Paul Stewart | 45170bc | 2014-06-02 15:49:34 -0700 | [diff] [blame] | 49 | class ServicePropertyChangeNotifier; |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 50 | class Sockets; |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 51 | class StoreInterface; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 52 | |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 53 | #if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) |
| 54 | class EapCredentials; |
| 55 | #endif // DISABLE_WIFI || DISABLE_WIRED_8021X |
| 56 | |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 57 | // A Service is a uniquely named entity, which the system can |
| 58 | // connect in order to begin sending and receiving network traffic. |
| 59 | // All Services are bound to an Entry, which represents the persistable |
| 60 | // state of the Service. If the Entry is populated at the time of Service |
| 61 | // creation, that information is used to prime the Service. If not, the Entry |
| 62 | // becomes populated over time. |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 63 | class Service : public base::RefCounted<Service> { |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 64 | public: |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 65 | static const char kCheckPortalAuto[]; |
| 66 | static const char kCheckPortalFalse[]; |
| 67 | static const char kCheckPortalTrue[]; |
| 68 | |
Darin Petkov | aba8932 | 2013-03-11 14:48:22 +0100 | [diff] [blame] | 69 | static const char kErrorDetailsNone[]; |
| 70 | |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 71 | // TODO(pstew): Storage constants shouldn't need to be public |
Paul Stewart | ee6b3d7 | 2013-07-12 16:07:51 -0700 | [diff] [blame] | 72 | // crbug.com/208736 |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 73 | static const char kStorageAutoConnect[]; |
| 74 | static const char kStorageCheckPortal[]; |
Peter Qiu | a89154b | 2014-05-23 15:45:42 -0700 | [diff] [blame] | 75 | static const char kStorageDNSAutoFallback[]; |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 76 | static const char kStorageError[]; |
| 77 | static const char kStorageFavorite[]; |
| 78 | static const char kStorageGUID[]; |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 79 | static const char kStorageHasEverConnected[]; |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 80 | static const char kStorageName[]; |
| 81 | static const char kStoragePriority[]; |
Paul Stewart | d9c7cfc | 2015-01-06 14:26:22 -0800 | [diff] [blame] | 82 | static const char kStoragePriorityWithinTechnology[]; |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 83 | static const char kStorageProxyConfig[]; |
| 84 | static const char kStorageSaveCredentials[]; |
| 85 | static const char kStorageType[]; |
| 86 | static const char kStorageUIData[]; |
Peter Qiu | 9d58193 | 2014-04-14 16:37:37 -0700 | [diff] [blame] | 87 | static const char kStorageConnectionId[]; |
Peter Qiu | d49760e | 2014-09-19 16:13:42 -0700 | [diff] [blame] | 88 | static const char kStorageLinkMonitorDisabled[]; |
Paul Stewart | 3fee7e3 | 2014-10-15 21:39:29 -0700 | [diff] [blame] | 89 | static const char kStorageManagedCredentials[]; |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 90 | |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 91 | static const uint8_t kStrengthMax; |
| 92 | static const uint8_t kStrengthMin; |
mukesh agrawal | 8f3f775 | 2012-02-17 19:42:09 -0800 | [diff] [blame] | 93 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 94 | enum ConnectFailure { |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 95 | kFailureUnknown, |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 96 | kFailureAAA, |
Darin Petkov | 1c049c7 | 2013-03-21 13:15:45 +0100 | [diff] [blame] | 97 | kFailureActivation, |
| 98 | kFailureBadPassphrase, |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 99 | kFailureBadWEPKey, |
| 100 | kFailureConnect, |
Darin Petkov | 1c049c7 | 2013-03-21 13:15:45 +0100 | [diff] [blame] | 101 | kFailureDHCP, |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 102 | kFailureDNSLookup, |
Paul Stewart | db0f917 | 2012-11-30 16:48:09 -0800 | [diff] [blame] | 103 | kFailureEAPAuthentication, |
| 104 | kFailureEAPLocalTLS, |
| 105 | kFailureEAPRemoteTLS, |
Darin Petkov | 1c049c7 | 2013-03-21 13:15:45 +0100 | [diff] [blame] | 106 | kFailureHTTPGet, |
| 107 | kFailureIPSecCertAuth, |
| 108 | kFailureIPSecPSKAuth, |
| 109 | kFailureInternal, |
| 110 | kFailureNeedEVDO, |
| 111 | kFailureNeedHomeNetwork, |
| 112 | kFailureOTASP, |
| 113 | kFailureOutOfRange, |
| 114 | kFailurePPPAuth, |
| 115 | kFailurePinMissing, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 116 | kFailureMax |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 117 | }; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 118 | enum ConnectState { |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 119 | kStateUnknown, |
| 120 | kStateIdle, |
| 121 | kStateAssociating, |
| 122 | kStateConfiguring, |
| 123 | kStateConnected, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 124 | kStatePortal, |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 125 | kStateFailure, |
| 126 | kStateOnline |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 127 | }; |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 128 | enum CryptoAlgorithm { |
| 129 | kCryptoNone, |
| 130 | kCryptoRc4, |
| 131 | kCryptoAes |
| 132 | }; |
Paul Stewart | 7b5cee9 | 2014-06-25 02:03:34 -0700 | [diff] [blame] | 133 | |
Rebecca Silberstein | 5777690 | 2014-09-15 21:43:02 -0700 | [diff] [blame] | 134 | enum UpdateCredentialsReason{ |
| 135 | kReasonCredentialsLoaded, |
| 136 | kReasonPropertyUpdate |
| 137 | }; |
| 138 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 139 | static const int kPriorityNone; |
| 140 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 141 | // A constructor for the Service object |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 142 | Service(ControlInterface* control_interface, |
| 143 | EventDispatcher* dispatcher, |
| 144 | Metrics* metrics, |
| 145 | Manager* manager, |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 146 | Technology::Identifier technology); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 147 | |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 148 | // AutoConnect MAY choose to ignore the connection request in some |
| 149 | // cases. For example, if the corresponding Device only supports one |
| 150 | // concurrent connection, and another Service is already connected |
| 151 | // or connecting. |
| 152 | // |
| 153 | // AutoConnect MAY issue RPCs immediately. So AutoConnect MUST NOT |
| 154 | // be called from a D-Bus signal handler context. |
| 155 | virtual void AutoConnect(); |
mukesh agrawal | dc7b844 | 2012-09-27 13:48:14 -0700 | [diff] [blame] | 156 | // Queue up a connection attempt. Derived classes SHOULD call the |
| 157 | // base class implementation before beginning a connect. The base |
| 158 | // class will log the connection attempt, and update base-class |
| 159 | // state. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 160 | virtual void Connect(Error* error, const char* reason); |
Christopher Wiley | abd3b50 | 2012-09-26 13:08:52 -0700 | [diff] [blame] | 161 | // Disconnect this service. Override this method to add your service specific |
| 162 | // disconnect logic, but call the super class's Disconnect() first. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 163 | virtual void Disconnect(Error* error, const char* reason); |
Christopher Wiley | abd3b50 | 2012-09-26 13:08:52 -0700 | [diff] [blame] | 164 | // Disconnects this service via Disconnect(). Marks the service as having |
| 165 | // failed with |failure|. Do not override this method. |
Samuel Tan | 0d06119 | 2014-07-07 15:45:15 -0700 | [diff] [blame] | 166 | virtual void DisconnectWithFailure(ConnectFailure failure, |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 167 | Error* error, |
| 168 | const char* reason); |
Christopher Wiley | abd3b50 | 2012-09-26 13:08:52 -0700 | [diff] [blame] | 169 | // Disconnects this service via Disconnect(). The service will not be eligible |
| 170 | // for auto-connect until a subsequent call to Connect, or Load. Do not |
| 171 | // override this method. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 172 | virtual void UserInitiatedDisconnect(Error* error); |
Peter Qiu | dc4e099 | 2014-05-01 10:02:52 -0700 | [diff] [blame] | 173 | // Connect to this service via Connect(). This function indicates that the |
| 174 | // connection attempt is user-initiated. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 175 | virtual void UserInitiatedConnect(Error* error); |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 176 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 177 | // The default implementation returns the error kInvalidArguments. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 178 | virtual void ActivateCellularModem(const std::string& carrier, |
| 179 | Error* error, |
| 180 | const ResultCallback& callback); |
Ben Chan | 5d92454 | 2013-02-14 17:49:08 -0800 | [diff] [blame] | 181 | // The default implementation returns the error kNotSupported. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 182 | virtual void CompleteCellularActivation(Error* error); |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 183 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 184 | virtual bool IsActive(Error* error); |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 185 | |
Paul Stewart | 7fb0938 | 2012-07-18 17:32:27 -0700 | [diff] [blame] | 186 | // Returns whether services of this type should be auto-connect by default. |
| 187 | virtual bool IsAutoConnectByDefault() const { return false; } |
| 188 | |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 189 | virtual ConnectState state() const { return state_; } |
| 190 | // Updates the state of the Service and alerts the manager. Also |
| 191 | // clears |failure_| if the new state isn't a failure. |
| 192 | virtual void SetState(ConnectState state); |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 193 | std::string GetStateString() const; |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 194 | |
Peter Qiu | 9b83c89 | 2014-08-09 23:06:02 -0700 | [diff] [blame] | 195 | // Set portal detection failure phase and status (reason). This function |
| 196 | // is called when portal detection failed for the Service. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 197 | virtual void SetPortalDetectionFailure(const std::string& phase, |
| 198 | const std::string& status); |
Peter Qiu | 9b83c89 | 2014-08-09 23:06:02 -0700 | [diff] [blame] | 199 | |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 200 | // State utility functions |
Darin Petkov | c8d91e5 | 2013-01-21 11:43:47 +0100 | [diff] [blame] | 201 | static bool IsConnectedState(ConnectState state); |
| 202 | static bool IsConnectingState(ConnectState state); |
| 203 | |
| 204 | virtual bool IsConnected() const; |
| 205 | virtual bool IsConnecting() const; |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 206 | virtual bool IsFailed() const { |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 207 | // We sometimes lie about the failure state, to keep Chrome happy |
| 208 | // (see comment in WiFi::HandleDisconnect). Hence, we check both |
| 209 | // state and |failed_time_|. |
| 210 | return state() == kStateFailure || failed_time_ > 0; |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 211 | } |
Paul Stewart | df3c0a8 | 2012-11-09 15:54:33 -0800 | [diff] [blame] | 212 | |
Peter Qiu | 4943822 | 2014-03-14 14:21:09 -0700 | [diff] [blame] | 213 | virtual bool IsInFailState() const { |
| 214 | return state() == kStateFailure; |
| 215 | } |
| 216 | |
Peter Qiu | 700de64 | 2014-07-14 16:31:30 -0700 | [diff] [blame] | 217 | virtual bool IsOnline() const { |
| 218 | return state() == kStateOnline; |
| 219 | } |
| 220 | |
Paul Stewart | df3c0a8 | 2012-11-09 15:54:33 -0800 | [diff] [blame] | 221 | // Returns true if the connection for |this| depends on service |b|. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 222 | virtual bool IsDependentOn(const ServiceRefPtr& b) const; |
Paul Stewart | df3c0a8 | 2012-11-09 15:54:33 -0800 | [diff] [blame] | 223 | |
Paul Stewart | a121c44 | 2012-06-09 14:12:58 -0700 | [diff] [blame] | 224 | virtual bool IsPortalled() const { |
| 225 | return state() == kStatePortal; |
| 226 | } |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 227 | |
Peter Qiu | a89154b | 2014-05-23 15:45:42 -0700 | [diff] [blame] | 228 | // Return true if service is allowed to automatically switch to fallback |
| 229 | // DNS server. |
| 230 | virtual bool is_dns_auto_fallback_allowed() const { |
| 231 | return is_dns_auto_fallback_allowed_; |
| 232 | } |
| 233 | |
Peter Qiu | d49760e | 2014-09-19 16:13:42 -0700 | [diff] [blame] | 234 | virtual bool link_monitor_disabled() const { return link_monitor_disabled_; } |
| 235 | |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 236 | virtual ConnectFailure failure() const { return failure_; } |
Paul Stewart | d7c09a5 | 2014-02-19 12:50:29 -0800 | [diff] [blame] | 237 | // Sets the |previous_error_| property based on the current |failure_|, and |
| 238 | // sets a serial number for this failure. |
| 239 | virtual void SaveFailure(); |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 240 | // Records the failure mode and time. Sets the Service state to "Failure". |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 241 | virtual void SetFailure(ConnectFailure failure); |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 242 | // Records the failure mode and time. Sets the Service state to "Idle". |
| 243 | // Avoids showing a failure mole in the UI. |
| 244 | virtual void SetFailureSilent(ConnectFailure failure); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 245 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 246 | // Returns a string that is guaranteed to uniquely identify this Service |
| 247 | // instance. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 248 | const std::string& unique_name() const { return unique_name_; } |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 249 | |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 250 | virtual std::string GetRpcIdentifier() const; |
Chris Masone | 3c3f6a1 | 2011-07-01 10:01:41 -0700 | [diff] [blame] | 251 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 252 | // Returns the unique persistent storage identifier for the service. |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 253 | virtual std::string GetStorageIdentifier() const = 0; |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 254 | |
Paul Stewart | e7de294 | 2013-04-25 17:07:31 -0700 | [diff] [blame] | 255 | // Returns the identifier within |storage| from which configuration for |
| 256 | // this service can be loaded. Returns an empty string if no entry in |
| 257 | // |storage| can be used. |
| 258 | virtual std::string GetLoadableStorageIdentifier( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 259 | const StoreInterface& storage) const; |
Paul Stewart | e7de294 | 2013-04-25 17:07:31 -0700 | [diff] [blame] | 260 | |
Paul Stewart | bba6a5b | 2011-11-02 18:45:59 -0700 | [diff] [blame] | 261 | // Returns whether the service configuration can be loaded from |storage|. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 262 | virtual bool IsLoadableFrom(const StoreInterface& storage) const; |
Paul Stewart | bba6a5b | 2011-11-02 18:45:59 -0700 | [diff] [blame] | 263 | |
Paul Stewart | 8142613 | 2012-05-16 10:05:10 -0700 | [diff] [blame] | 264 | // Returns true if the service uses 802.1x for key management. |
Paul Stewart | be9abfd | 2013-04-22 12:18:48 -0700 | [diff] [blame] | 265 | virtual bool Is8021x() const { return false; } |
Paul Stewart | 8142613 | 2012-05-16 10:05:10 -0700 | [diff] [blame] | 266 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 267 | // Loads the service from persistent |storage|. Returns true on success. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 268 | virtual bool Load(StoreInterface* storage); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 269 | |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 270 | // Indicate to service that it is no longer persisted to storage. It |
Paul Stewart | 65512e1 | 2012-03-26 18:01:08 -0700 | [diff] [blame] | 271 | // should purge any stored profile state (e.g., credentials). Returns |
| 272 | // true to indicate that this service should also be unregistered from |
| 273 | // the manager, false otherwise. |
| 274 | virtual bool Unload(); |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 275 | |
Albert Chaulk | 0e1cdea | 2013-02-27 15:32:55 -0800 | [diff] [blame] | 276 | // Attempt to remove the service. On failure, no changes in state will occur. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 277 | virtual void Remove(Error* error); |
Albert Chaulk | 0e1cdea | 2013-02-27 15:32:55 -0800 | [diff] [blame] | 278 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 279 | // Saves the service to persistent |storage|. Returns true on success. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 280 | virtual bool Save(StoreInterface* storage); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 281 | |
Thieu Le | d4e9e55 | 2012-02-16 16:26:07 -0800 | [diff] [blame] | 282 | // Saves the service to the current profile. |
Gary Morain | d93615e | 2012-04-27 11:50:03 -0700 | [diff] [blame] | 283 | virtual void SaveToCurrentProfile(); |
Thieu Le | d4e9e55 | 2012-02-16 16:26:07 -0800 | [diff] [blame] | 284 | |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 285 | // Applies all the properties in |args| to this service object's mutable |
| 286 | // store, except for those in parameters_ignored_for_configure_. |
| 287 | // Returns an error in |error| if one or more parameter set attempts |
| 288 | // fails, but will only return the first error. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 289 | virtual void Configure(const KeyValueStore& args, Error* error); |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 290 | |
Paul Stewart | 7a20aa4 | 2013-01-17 12:21:41 -0800 | [diff] [blame] | 291 | // Iterate over all the properties in |args| and test for an identical |
| 292 | // value in this service object's store. Returns false if one or more |
| 293 | // keys in |args| do not exist or have different values, true otherwise. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 294 | virtual bool DoPropertiesMatch(const KeyValueStore& args) const; |
Paul Stewart | 7a20aa4 | 2013-01-17 12:21:41 -0800 | [diff] [blame] | 295 | |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 296 | // Returns whether portal detection is explicitly disabled on this service |
| 297 | // via a property set on it. |
| 298 | virtual bool IsPortalDetectionDisabled() const; |
| 299 | |
| 300 | // Returns whether portal detection is set to follow the default setting |
| 301 | // of this service's technology via a property set on it. |
| 302 | virtual bool IsPortalDetectionAuto() const; |
| 303 | |
Paul Stewart | 10ccbb3 | 2012-04-26 15:59:30 -0700 | [diff] [blame] | 304 | // Returns true if the service is persisted to a non-ephemeral profile. |
| 305 | virtual bool IsRemembered() const; |
| 306 | |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 307 | // Returns true if the service RPC identifier should be part of the |
| 308 | // manager's advertised services list, false otherwise. |
| 309 | virtual bool IsVisible() const { return true; } |
| 310 | |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 311 | // Returns true if there is a proxy configuration set on this service. |
| 312 | virtual bool HasProxyConfig() const { return !proxy_config_.empty(); } |
| 313 | |
Paul Stewart | a47c3c6 | 2012-12-18 12:14:29 -0800 | [diff] [blame] | 314 | // Returns whether this service has had recent connection issues. |
| 315 | virtual bool HasRecentConnectionIssues(); |
| 316 | |
Paul Stewart | 2da34c0 | 2013-10-17 15:28:56 -0700 | [diff] [blame] | 317 | // If the AutoConnect property has not already been marked as saved, set |
| 318 | // its value to true and mark it saved. |
| 319 | virtual void EnableAndRetainAutoConnect(); |
mukesh agrawal | 00917ce | 2011-11-22 23:56:55 +0000 | [diff] [blame] | 320 | |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 321 | // Set the connection for this service. If the connection is non-NULL, create |
| 322 | // an HTTP Proxy that will utilize this service's connection to serve |
| 323 | // requests. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 324 | virtual void SetConnection(const ConnectionRefPtr& connection); |
| 325 | virtual const ConnectionRefPtr& connection() const { return connection_; } |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 326 | |
Peter Qiu | a89154b | 2014-05-23 15:45:42 -0700 | [diff] [blame] | 327 | // Emit service's IP config change event to chrome. |
| 328 | virtual void NotifyIPConfigChanges(); |
| 329 | |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 330 | #if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 331 | // Examines the EAP credentials for the service and returns true if a |
| 332 | // connection attempt can be made. |
Paul Stewart | 9413bcc | 2013-04-04 16:12:43 -0700 | [diff] [blame] | 333 | virtual bool Is8021xConnectable() const; |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 334 | |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 335 | // Add an EAP certification id |name| at position |depth| in the stack. |
| 336 | // Returns true if entry was added, false otherwise. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 337 | virtual bool AddEAPCertification(const std::string& name, size_t depth); |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 338 | // Clear all EAP certification elements. |
Paul Stewart | 9413bcc | 2013-04-04 16:12:43 -0700 | [diff] [blame] | 339 | virtual void ClearEAPCertification(); |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 340 | #endif // DISABLE_WIFI || DISABLE_WIRED_8021X |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 341 | |
Paul Stewart | 316acef | 2014-05-29 18:40:48 -0700 | [diff] [blame] | 342 | // Returns true if this service contains a IP address in its static IP |
| 343 | // parameters, false otherwise. |
| 344 | virtual bool HasStaticIPAddress() const; |
| 345 | |
Garret Kelly | d01b5cc | 2015-03-12 16:20:55 -0400 | [diff] [blame] | 346 | // Returns true if this service contains nameservers in its static IP |
| 347 | // parameters, false otherwise. |
| 348 | virtual bool HasStaticNameServers() const; |
| 349 | |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 350 | // The inherited class that needs to send metrics after the service has |
Thieu Le | b84ba34 | 2012-03-02 15:15:19 -0800 | [diff] [blame] | 351 | // transitioned to the ready state should override this method. |
| 352 | // |time_resume_to_ready_milliseconds| holds the elapsed time from when |
| 353 | // the system was resumed until when the service transitioned to the |
| 354 | // connected state. This value is non-zero for the first service transition |
| 355 | // to the connected state after a resume. |
| 356 | virtual void SendPostReadyStateMetrics( |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 357 | int64_t /*time_resume_to_ready_milliseconds*/) const {} |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 358 | |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 359 | bool auto_connect() const { return auto_connect_; } |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 360 | void SetAutoConnect(bool connect); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 361 | |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 362 | bool connectable() const { return connectable_; } |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 363 | // Sets the connectable property of the service, and broadcast the |
| 364 | // new value. Does not update the manager. |
| 365 | // TODO(petkov): Remove this method in favor of SetConnectableFull. |
Darin Petkov | b2ba39f | 2012-06-06 10:33:43 +0200 | [diff] [blame] | 366 | void SetConnectable(bool connectable); |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 367 | // Sets the connectable property of the service, broadcasts the new |
| 368 | // value, and alerts the manager if necessary. |
| 369 | void SetConnectableFull(bool connectable); |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 370 | |
Thieu Le | 67370f6 | 2012-02-14 23:01:42 +0000 | [diff] [blame] | 371 | virtual bool explicitly_disconnected() const { |
| 372 | return explicitly_disconnected_; |
| 373 | } |
| 374 | |
Paul Stewart | 2da34c0 | 2013-10-17 15:28:56 -0700 | [diff] [blame] | 375 | bool retain_auto_connect() const { return retain_auto_connect_; } |
| 376 | // Setter is deliberately omitted; use EnableAndRetainAutoConnect. |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 377 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 378 | void set_friendly_name(const std::string& n) { friendly_name_ = n; } |
| 379 | const std::string& friendly_name() const { return friendly_name_; } |
Ben Chan | 923a502 | 2013-09-20 11:23:23 -0700 | [diff] [blame] | 380 | // Sets the kNameProperty and broadcasts the change. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 381 | void SetFriendlyName(const std::string& friendly_name); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 382 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 383 | const std::string& guid() const { return guid_; } |
| 384 | bool SetGuid(const std::string& guid, Error* error); |
Paul Stewart | 4c56161 | 2012-03-21 12:49:01 -0700 | [diff] [blame] | 385 | |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 386 | bool has_ever_connected() const { return has_ever_connected_; } |
Rebecca Silberstein | e99f664 | 2014-07-09 14:04:31 -0700 | [diff] [blame] | 387 | // Sets the has_ever_connected_ property of the service |
| 388 | // and broadcasts the new value |
| 389 | void SetHasEverConnected(bool has_ever_connected); |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 390 | |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 391 | int32_t priority() const { return priority_; } |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 392 | bool SetPriority(const int32_t& priority, Error* error); |
Paul Stewart | d9c7cfc | 2015-01-06 14:26:22 -0800 | [diff] [blame] | 393 | int32_t priority_within_technology() const { |
| 394 | return priority_within_technology_; |
| 395 | } |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 396 | bool SetPriorityWithinTechnology(const int32_t& priority, Error* error); |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 397 | |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 398 | size_t crypto_algorithm() const { return crypto_algorithm_; } |
| 399 | bool key_rotation() const { return key_rotation_; } |
| 400 | bool endpoint_auth() const { return endpoint_auth_; } |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 401 | |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 402 | void SetStrength(uint8_t strength); |
mukesh agrawal | e1d90e9 | 2012-02-15 17:36:08 -0800 | [diff] [blame] | 403 | |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 404 | // uint8_t streams out as a char. Coerce to a larger type, so that |
mukesh agrawal | e1d90e9 | 2012-02-15 17:36:08 -0800 | [diff] [blame] | 405 | // it prints as a number. |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 406 | uint16_t strength() const { return strength_; } |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 407 | |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 408 | virtual Technology::Identifier technology() const { return technology_; } |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 409 | std::string GetTechnologyString() const; |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 410 | |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 411 | #if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 412 | virtual const EapCredentials* eap() const { return eap_.get(); } |
| 413 | void SetEapCredentials(EapCredentials* eap); |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 414 | #endif // DISABLE_WIFI || DISABLE_WIRED_8021X |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 415 | |
Darin Petkov | cb71529 | 2012-04-25 13:04:37 +0200 | [diff] [blame] | 416 | bool save_credentials() const { return save_credentials_; } |
| 417 | void set_save_credentials(bool save) { save_credentials_ = save; } |
| 418 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 419 | const std::string& error() const { return error_; } |
| 420 | void set_error(const std::string& error) { error_ = error; } |
Darin Petkov | 5148900 | 2011-08-18 13:13:20 -0700 | [diff] [blame] | 421 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 422 | const std::string& error_details() const { return error_details_; } |
| 423 | void SetErrorDetails(const std::string& details); |
Darin Petkov | aba8932 | 2013-03-11 14:48:22 +0100 | [diff] [blame] | 424 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 425 | static const char* ConnectFailureToString(const ConnectFailure& state); |
| 426 | static const char* ConnectStateToString(const ConnectState& state); |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 427 | |
Paul Stewart | 39db5ca | 2013-03-18 14:15:17 -0700 | [diff] [blame] | 428 | // Compare two services. Returns true if Service |a| should be displayed |
| 429 | // above |b|. If |compare_connectivity_state| is true, the connectivity |
| 430 | // state of the service (service->state()) is used as the most significant |
| 431 | // criteria for comparsion, otherwise the service state is ignored. Use |
| 432 | // |tech_order| to rank services if more decisive criteria do not yield a |
| 433 | // difference. |reason| is populated with the exact criteria used for the |
| 434 | // ultimate comparison. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 435 | static bool Compare(Manager* manager, |
Rebecca Silberstein | 6d4836b | 2014-07-16 14:28:28 -0700 | [diff] [blame] | 436 | ServiceRefPtr a, |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 437 | ServiceRefPtr b, |
Paul Stewart | 39db5ca | 2013-03-18 14:15:17 -0700 | [diff] [blame] | 438 | bool compare_connectivity_state, |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 439 | const std::vector<Technology::Identifier>& tech_order, |
| 440 | const char** reason); |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 441 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 442 | // 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] | 443 | // TODO(cmasone): right now, these are here only so that we can get the |
| 444 | // profile name as a property. Can we store just the name, and then handle |
| 445 | // setting the profile for this service via |manager_|? |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 446 | const ProfileRefPtr& profile() const; |
Philipp Neubeck | 7917360 | 2012-11-13 21:10:09 +0100 | [diff] [blame] | 447 | |
| 448 | // Sets the profile property of this service. Broadcasts the new value if it's |
Ben Chan | cc225ef | 2014-09-30 13:26:51 -0700 | [diff] [blame] | 449 | // not nullptr. If the new value is nullptr, the service will either be set to |
Philipp Neubeck | 7917360 | 2012-11-13 21:10:09 +0100 | [diff] [blame] | 450 | // another profile afterwards or it will not be visible and not monitored |
| 451 | // anymore. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 452 | void SetProfile(const ProfileRefPtr& p); |
Philipp Neubeck | 7917360 | 2012-11-13 21:10:09 +0100 | [diff] [blame] | 453 | |
| 454 | // This is called from tests and shouldn't be called otherwise. Use SetProfile |
| 455 | // instead. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 456 | void set_profile(const ProfileRefPtr& p); |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 457 | |
Paul Stewart | 4357f4e | 2012-04-26 17:39:26 -0700 | [diff] [blame] | 458 | // Notification that occurs when a service now has profile data saved |
| 459 | // on its behalf. Some service types like WiFi can choose to register |
| 460 | // themselves at this point. |
| 461 | virtual void OnProfileConfigured() {} |
| 462 | |
Paul Stewart | ff14b02 | 2012-04-24 20:06:23 -0700 | [diff] [blame] | 463 | // Notification that occurs when a single property has been changed via |
| 464 | // the RPC adaptor. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 465 | virtual void OnPropertyChanged(const std::string& property); |
Paul Stewart | ff14b02 | 2012-04-24 20:06:23 -0700 | [diff] [blame] | 466 | |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 467 | // Notification that occurs when an EAP credential property has been |
| 468 | // changed. Some service subclasses can choose to respond to this |
| 469 | // event. |
Rebecca Silberstein | 5777690 | 2014-09-15 21:43:02 -0700 | [diff] [blame] | 470 | virtual void OnEapCredentialsChanged(UpdateCredentialsReason reason) {} |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 471 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 472 | // Called by the manager once after a resume. |
| 473 | virtual void OnAfterResume(); |
| 474 | |
Prathmesh Prabhu | 64ad238 | 2014-08-26 11:19:30 -0700 | [diff] [blame] | 475 | // Called by the manager once when entering dark resume. |
| 476 | virtual void OnDarkResume(); |
| 477 | |
Paul Stewart | 2eee613 | 2014-05-09 13:33:26 -0700 | [diff] [blame] | 478 | // Called by the manager to clear remembered state of being explicitly |
| 479 | // disconnected. |
| 480 | virtual void ClearExplicitlyDisconnected(); |
| 481 | |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 482 | #if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 483 | EapCredentials* mutable_eap() { return eap_.get(); } |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 484 | #endif // DISABLE_WIFI || DISABLE_WIRED_8021X |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 485 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 486 | PropertyStore* mutable_store() { return &store_; } |
| 487 | const PropertyStore& store() const { return store_; } |
| 488 | StaticIPParameters* mutable_static_ip_parameters() { |
Paul Stewart | def189e | 2012-08-02 20:12:09 -0700 | [diff] [blame] | 489 | return &static_ip_parameters_; |
| 490 | } |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 491 | const StaticIPParameters& static_ip_parameters() const { |
Paul Stewart | 1062d9d | 2012-04-27 10:42:27 -0700 | [diff] [blame] | 492 | return static_ip_parameters_; |
| 493 | } |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 494 | |
Paul Stewart | c3dbff1 | 2013-07-17 10:32:48 -0700 | [diff] [blame] | 495 | // Retrieves |key| from |id| in |storage| to |value|. If this key does |
| 496 | // not exist, assign |default_value| to |value|. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 497 | static void LoadString(StoreInterface* storage, |
| 498 | const std::string& id, |
| 499 | const std::string& key, |
| 500 | const std::string& default_value, |
| 501 | std::string* value); |
Paul Stewart | c3dbff1 | 2013-07-17 10:32:48 -0700 | [diff] [blame] | 502 | |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 503 | // Assigns |value| to |key| in |storage| if |value| is non-empty and |save| is |
| 504 | // true. Otherwise, removes |key| from |storage|. If |crypted| is true, the |
| 505 | // value is encrypted. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 506 | static void SaveString(StoreInterface* storage, |
| 507 | const std::string& id, |
| 508 | const std::string& key, |
| 509 | const std::string& value, |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 510 | bool crypted, |
| 511 | bool save); |
| 512 | |
Paul Stewart | 967eaeb | 2013-04-25 19:53:07 -0700 | [diff] [blame] | 513 | // Called via RPC to get a dict containing profile-to-entry_name mappings |
| 514 | // of all the profile entires which contain configuration applicable to |
| 515 | // this service. |
| 516 | std::map<std::string, std::string> GetLoadableProfileEntries(); |
| 517 | |
Peter Qiu | 9d58193 | 2014-04-14 16:37:37 -0700 | [diff] [blame] | 518 | void set_connection_id(int connection_id) { connection_id_ = connection_id; } |
| 519 | int connection_id() const { return connection_id_; } |
| 520 | |
Peter Qiu | a388fdb | 2015-04-03 10:31:22 -0700 | [diff] [blame] | 521 | void set_unreliable(bool unreliable) { unreliable_ = unreliable; } |
| 522 | bool unreliable() const { return unreliable_; } |
| 523 | |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 524 | protected: |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 525 | friend class base::RefCounted<Service>; |
| 526 | |
mukesh agrawal | 03c15ce | 2012-11-29 17:36:21 -0800 | [diff] [blame] | 527 | static const char kAutoConnBusy[]; |
| 528 | |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 529 | virtual ~Service(); |
| 530 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 531 | // Returns true if a character is allowed to be in a service storage id. |
| 532 | static bool LegalChar(char a) { return isalnum(a) || a == '_'; } |
| 533 | |
Darin Petkov | 3133241 | 2012-01-28 01:50:02 +0100 | [diff] [blame] | 534 | // Returns true if a character is disallowed to be in a service storage id. |
| 535 | static bool IllegalChar(char a) { return !LegalChar(a); } |
| 536 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 537 | virtual std::string CalculateState(Error* error); |
| 538 | std::string CalculateTechnology(Error* error); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 539 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 540 | bool GetVisibleProperty(Error* error); |
Paul Stewart | cca85b1 | 2014-05-30 13:56:35 -0700 | [diff] [blame] | 541 | |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 542 | // Returns whether this service is in a state conducive to auto-connect. |
| 543 | // This should include any tests used for computing connectable(), |
| 544 | // as well as other critera such as whether the device associated with |
| 545 | // this service is busy with another connection. |
mukesh agrawal | bf14e94 | 2012-03-02 14:36:34 -0800 | [diff] [blame] | 546 | // |
| 547 | // If the service is not auto-connectable, |*reason| will be set to |
| 548 | // point to C-string explaining why the service is not auto-connectable. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 549 | virtual bool IsAutoConnectable(const char** reason) const; |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 550 | |
mukesh agrawal | 292dc0f | 2012-01-26 18:02:46 -0800 | [diff] [blame] | 551 | // HelpRegisterDerived*: Expose a property over RPC, with the name |name|. |
| 552 | // |
| 553 | // Reads of the property will be handled by invoking |get|. |
| 554 | // Writes to the property will be handled by invoking |set|. |
| 555 | // Clearing the property will be handled by PropertyStore. |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 556 | void HelpRegisterDerivedBool( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 557 | const std::string& name, |
| 558 | bool(Service::*get)(Error* error), |
| 559 | bool(Service::*set)(const bool& value, Error* error), |
| 560 | void(Service::*clear)(Error* error)); |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 561 | void HelpRegisterDerivedInt32( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 562 | const std::string& name, |
| 563 | int32_t(Service::*get)(Error* error), |
| 564 | bool(Service::*set)(const int32_t& value, Error* error)); |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 565 | void HelpRegisterDerivedString( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 566 | const std::string& name, |
| 567 | std::string(Service::*get)(Error* error), |
| 568 | bool(Service::*set)(const std::string& value, Error* error)); |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 569 | void HelpRegisterConstDerivedUint16( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 570 | const std::string& name, |
| 571 | uint16_t(Service::*get)(Error* error) const); |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 572 | void HelpRegisterConstDerivedRpcIdentifier( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 573 | const std::string& name, |
| 574 | std::string(Service::*get)(Error*) const); |
Darin Petkov | 0c65bdd | 2012-12-05 13:42:41 +0100 | [diff] [blame] | 575 | void HelpRegisterConstDerivedStrings( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 576 | const std::string& name, Strings(Service::*get)(Error* error) const); |
Paul Stewart | 1cf7eb8 | 2013-12-03 19:34:36 -0800 | [diff] [blame] | 577 | void HelpRegisterConstDerivedString( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 578 | const std::string& name, std::string(Service::*get)(Error* error) const); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 579 | |
Paul Stewart | 45170bc | 2014-06-02 15:49:34 -0700 | [diff] [blame] | 580 | // HelpRegisterObservedDerived*: Expose an property over RPC, with the |
| 581 | // name |name|, for which property changes are automatically generated. |
| 582 | // |
| 583 | void HelpRegisterObservedDerivedBool( |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 584 | const std::string& name, |
| 585 | bool(Service::*get)(Error* error), |
| 586 | bool(Service::*set)(const bool& value, Error* error), |
| 587 | void(Service::*clear)(Error* error)); |
| 588 | ServiceAdaptorInterface* adaptor() const { return adaptor_.get(); } |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 589 | |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 590 | #if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) |
Paul Stewart | d8ad3c4 | 2012-01-09 12:39:38 -0800 | [diff] [blame] | 591 | void UnloadEapCredentials(); |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 592 | #endif // DISABLE_WIFI || DISABLE_WIRED_8021X |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 593 | |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 594 | // Ignore |parameter| when performing a Configure() operation. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 595 | void IgnoreParameterForConfigure(const std::string& parameter); |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 596 | |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 597 | // Update the service's string-based "Error" RPC property based on the |
| 598 | // failure_ enum. |
| 599 | void UpdateErrorProperty(); |
| 600 | |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 601 | // RPC setter for the the "AutoConnect" property. Updates the |manager_|. |
| 602 | // (cf. SetAutoConnect, which does not update the manager.) |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 603 | virtual bool SetAutoConnectFull(const bool& connect, Error* error); |
Paul Stewart | cf199de | 2012-08-16 07:50:41 -0700 | [diff] [blame] | 604 | |
Paul Stewart | 43d8dc0 | 2013-10-17 10:32:53 -0700 | [diff] [blame] | 605 | // RPC clear method for the "AutoConnect" property. Sets the AutoConnect |
Paul Stewart | 2da34c0 | 2013-10-17 15:28:56 -0700 | [diff] [blame] | 606 | // property back to its default value, and clears the retain_auto_connect_ |
| 607 | // property to allow the AutoConnect property to be enabled automatically. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 608 | void ClearAutoConnect(Error* error); |
Paul Stewart | 43d8dc0 | 2013-10-17 10:32:53 -0700 | [diff] [blame] | 609 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 610 | // Property accessors reserved for subclasses |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 611 | EventDispatcher* dispatcher() const { return dispatcher_; } |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 612 | #if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 613 | const std::string& GetEAPKeyManagement() const; |
| 614 | virtual void SetEAPKeyManagement(const std::string& key_management); |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 615 | #endif // DISABLE_WIFI || DISABLE_WIRED_8021X |
| 616 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 617 | Manager* manager() const { return manager_; } |
| 618 | Metrics* metrics() const { return metrics_; } |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 619 | |
Paul Stewart | 2da34c0 | 2013-10-17 15:28:56 -0700 | [diff] [blame] | 620 | // Save the serivce's auto_connect value, without affecting its auto_connect |
| 621 | // property itself. (cf. EnableAndRetainAutoConnect) |
| 622 | void RetainAutoConnect(); |
| 623 | |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 624 | // Inform base class of the security properties for the service. |
| 625 | // |
| 626 | // NB: When adding a call to this function from a subclass, please check |
| 627 | // that the semantics of SecurityLevel() are appropriate for the subclass. |
| 628 | void SetSecurity(CryptoAlgorithm crypt, bool rotation, bool endpoint_auth); |
Darin Petkov | 1d0080a | 2012-04-30 17:10:36 +0200 | [diff] [blame] | 629 | |
Paul Stewart | fa11e28 | 2013-12-02 22:04:25 -0800 | [diff] [blame] | 630 | // Return whether this service is suspected or confirmed to be |
| 631 | // provided by a mobile device, which is likely to be using a |
| 632 | // metered backhaul for internet connectivity. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 633 | virtual std::string GetTethering(Error* error) const; |
Paul Stewart | fa11e28 | 2013-12-02 22:04:25 -0800 | [diff] [blame] | 634 | |
Paul Stewart | 45170bc | 2014-06-02 15:49:34 -0700 | [diff] [blame] | 635 | // Emit property change notifications for all observed properties. |
| 636 | void NotifyPropertyChanges(); |
Paul Stewart | 7cc9068 | 2014-05-30 17:01:56 -0700 | [diff] [blame] | 637 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 638 | private: |
Thieu Le | 43ce4d4 | 2013-10-04 16:08:55 -0700 | [diff] [blame] | 639 | friend class ActivePassiveOutOfCreditsDetectorTest; |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 640 | friend class EthernetEapServiceTest; |
Paul Stewart | cf199de | 2012-08-16 07:50:41 -0700 | [diff] [blame] | 641 | friend class EthernetServiceTest; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 642 | friend class MetricsTest; |
Paul Stewart | 9dd253e | 2013-04-22 08:32:59 -0700 | [diff] [blame] | 643 | friend class ManagerTest; |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 644 | friend class ServiceAdaptorInterface; |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 645 | friend class ServiceTest; |
Thieu Le | 43ce4d4 | 2013-10-04 16:08:55 -0700 | [diff] [blame] | 646 | friend class SubscriptionStateOutOfCreditsDetectorTest; |
Darin Petkov | 457728b | 2013-01-09 09:49:08 +0100 | [diff] [blame] | 647 | friend class VPNProviderTest; |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 648 | friend class VPNServiceTest; |
mukesh agrawal | e1d90e9 | 2012-02-15 17:36:08 -0800 | [diff] [blame] | 649 | friend class WiFiServiceTest; |
Darin Petkov | 457728b | 2013-01-09 09:49:08 +0100 | [diff] [blame] | 650 | friend class WiMaxProviderTest; |
Darin Petkov | 6b9b2e1 | 2012-07-10 15:51:42 +0200 | [diff] [blame] | 651 | friend class WiMaxServiceTest; |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 652 | friend void TestCommonPropertyChanges(ServiceRefPtr, ServiceMockAdaptor*); |
| 653 | friend void TestCustomSetterNoopChange(ServiceRefPtr, MockManager*); |
| 654 | friend void TestNamePropertyChange(ServiceRefPtr, ServiceMockAdaptor*); |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 655 | FRIEND_TEST(AllMockServiceTest, AutoConnectWithFailures); |
Darin Petkov | 457728b | 2013-01-09 09:49:08 +0100 | [diff] [blame] | 656 | FRIEND_TEST(CellularCapabilityGSMTest, SetStorageIdentifier); |
Ben Chan | 19f8397 | 2012-10-03 23:25:56 -0700 | [diff] [blame] | 657 | FRIEND_TEST(CellularServiceTest, IsAutoConnectable); |
mukesh agrawal | cc0fded | 2012-05-09 13:40:58 -0700 | [diff] [blame] | 658 | FRIEND_TEST(DeviceTest, IPConfigUpdatedFailureWithStatic); |
Paul Stewart | 39db5ca | 2013-03-18 14:15:17 -0700 | [diff] [blame] | 659 | FRIEND_TEST(ManagerTest, ConnectToBestServices); |
mukesh agrawal | 03c15ce | 2012-11-29 17:36:21 -0800 | [diff] [blame] | 660 | FRIEND_TEST(ServiceTest, AutoConnectLogging); |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 661 | FRIEND_TEST(ServiceTest, CalculateState); |
| 662 | FRIEND_TEST(ServiceTest, CalculateTechnology); |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 663 | FRIEND_TEST(ServiceTest, Certification); |
Paul Stewart | 22ce765 | 2014-10-15 21:26:44 -0700 | [diff] [blame] | 664 | FRIEND_TEST(ServiceTest, Compare); |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 665 | FRIEND_TEST(ServiceTest, ConfigureEapStringProperty); |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 666 | FRIEND_TEST(ServiceTest, ConfigureIgnoredProperty); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 667 | FRIEND_TEST(ServiceTest, Constructor); |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 668 | FRIEND_TEST(ServiceTest, CustomSetterNoopChange); |
Paul Stewart | 10241e3 | 2012-04-23 18:15:06 -0700 | [diff] [blame] | 669 | FRIEND_TEST(ServiceTest, GetIPConfigRpcIdentifier); |
Thieu Le | 284fe79 | 2012-01-31 17:53:19 -0800 | [diff] [blame] | 670 | FRIEND_TEST(ServiceTest, GetProperties); |
Paul Stewart | fa11e28 | 2013-12-02 22:04:25 -0800 | [diff] [blame] | 671 | FRIEND_TEST(ServiceTest, GetTethering); |
mukesh agrawal | 76d1388 | 2012-01-12 15:23:11 -0800 | [diff] [blame] | 672 | FRIEND_TEST(ServiceTest, IsAutoConnectable); |
Paul Stewart | df3c0a8 | 2012-11-09 15:54:33 -0800 | [diff] [blame] | 673 | FRIEND_TEST(ServiceTest, IsDependentOn); |
Paul Stewart | c3dbff1 | 2013-07-17 10:32:48 -0700 | [diff] [blame] | 674 | FRIEND_TEST(ServiceTest, Load); |
Peter Qiu | 9b83c89 | 2014-08-09 23:06:02 -0700 | [diff] [blame] | 675 | FRIEND_TEST(ServiceTest, PortalDetectionFailure); |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 676 | FRIEND_TEST(ServiceTest, RecheckPortal); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 677 | FRIEND_TEST(ServiceTest, Save); |
| 678 | FRIEND_TEST(ServiceTest, SaveString); |
| 679 | FRIEND_TEST(ServiceTest, SaveStringCrypted); |
| 680 | FRIEND_TEST(ServiceTest, SaveStringDontSave); |
| 681 | FRIEND_TEST(ServiceTest, SaveStringEmpty); |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 682 | FRIEND_TEST(ServiceTest, SecurityLevel); |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 683 | FRIEND_TEST(ServiceTest, SetCheckPortal); |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 684 | FRIEND_TEST(ServiceTest, SetConnectableFull); |
Arman Uguray | 2717a10 | 2013-01-29 23:36:06 -0800 | [diff] [blame] | 685 | FRIEND_TEST(ServiceTest, SetFriendlyName); |
| 686 | FRIEND_TEST(ServiceTest, SetProperty); |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 687 | FRIEND_TEST(ServiceTest, State); |
Thieu Le | af47141 | 2013-06-27 14:12:37 -0700 | [diff] [blame] | 688 | FRIEND_TEST(ServiceTest, StateResetAfterFailure); |
mukesh agrawal | e37ad32 | 2013-10-08 16:33:56 -0700 | [diff] [blame] | 689 | FRIEND_TEST(ServiceTest, UniqueAttributes); |
Paul Stewart | d8ad3c4 | 2012-01-09 12:39:38 -0800 | [diff] [blame] | 690 | FRIEND_TEST(ServiceTest, Unload); |
Peter Qiu | dc4e099 | 2014-05-01 10:02:52 -0700 | [diff] [blame] | 691 | FRIEND_TEST(ServiceTest, UserInitiatedConnectionResult); |
Rebecca Silberstein | e99f664 | 2014-07-09 14:04:31 -0700 | [diff] [blame] | 692 | FRIEND_TEST(WiFiServiceTest, SetPassphraseResetHasEverConnected); |
Paul Stewart | bca08f8 | 2013-07-09 16:32:37 -0700 | [diff] [blame] | 693 | FRIEND_TEST(WiFiServiceTest, SuspectedCredentialFailure); |
Rebecca Silberstein | b6df8b1 | 2014-07-10 16:07:08 -0700 | [diff] [blame] | 694 | FRIEND_TEST(WiFiServiceTest, SetPassphraseRemovesCachedCredentials); |
Rebecca Silberstein | 5777690 | 2014-09-15 21:43:02 -0700 | [diff] [blame] | 695 | FRIEND_TEST(WiFiServiceTest, LoadPassphraseClearCredentials); |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 696 | FRIEND_TEST(WiFiTimerTest, ReconnectTimer); |
Paul Stewart | 11c224b | 2013-10-22 19:04:40 -0700 | [diff] [blame] | 697 | FRIEND_TEST(WiFiMainTest, EAPEvent); // For eap_. |
Rebecca Silberstein | b6df8b1 | 2014-07-10 16:07:08 -0700 | [diff] [blame] | 698 | FRIEND_TEST(WiMaxServiceTest, ChangeCredResetHasEverConnected); |
| 699 | FRIEND_TEST(EthernetEapServiceTest, OnEapCredentialsChanged); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 700 | |
mukesh agrawal | bf14e94 | 2012-03-02 14:36:34 -0800 | [diff] [blame] | 701 | static const char kAutoConnConnected[]; |
| 702 | static const char kAutoConnConnecting[]; |
| 703 | static const char kAutoConnExplicitDisconnect[]; |
| 704 | static const char kAutoConnNotConnectable[]; |
Darin Petkov | 4cbff5b | 2013-01-29 16:29:05 +0100 | [diff] [blame] | 705 | static const char kAutoConnOffline[]; |
Ben Chan | 8e6b8ef | 2014-07-14 21:50:18 -0700 | [diff] [blame] | 706 | static const char kAutoConnTechnologyNotConnectable[]; |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 707 | static const char kAutoConnThrottled[]; |
mukesh agrawal | bf14e94 | 2012-03-02 14:36:34 -0800 | [diff] [blame] | 708 | |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 709 | #if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 710 | static const size_t kEAPMaxCertificationElements; |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 711 | #endif // DISABLE_WIFI || DISABLE_WIRED_8021X |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 712 | |
Darin Petkov | 2f903b3 | 2012-04-18 12:56:43 +0200 | [diff] [blame] | 713 | static const char kServiceSortAutoConnect[]; |
| 714 | static const char kServiceSortConnectable[]; |
Paul Stewart | 2da34c0 | 2013-10-17 15:28:56 -0700 | [diff] [blame] | 715 | static const char kServiceSortHasEverConnected[]; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 716 | static const char kServiceSortIsConnected[]; |
Paul Stewart | df3c0a8 | 2012-11-09 15:54:33 -0800 | [diff] [blame] | 717 | static const char kServiceSortDependency[]; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 718 | static const char kServiceSortIsConnecting[]; |
| 719 | static const char kServiceSortIsFailed[]; |
Paul Stewart | a121c44 | 2012-06-09 14:12:58 -0700 | [diff] [blame] | 720 | static const char kServiceSortIsPortalled[]; |
Darin Petkov | 2f903b3 | 2012-04-18 12:56:43 +0200 | [diff] [blame] | 721 | static const char kServiceSortPriority[]; |
Paul Stewart | d9c7cfc | 2015-01-06 14:26:22 -0800 | [diff] [blame] | 722 | static const char kServiceSortPriorityWithinTechnology[]; |
Rebecca Silberstein | 6d4836b | 2014-07-16 14:28:28 -0700 | [diff] [blame] | 723 | static const char kServiceSortSecurity[]; |
| 724 | static const char kServiceSortProfileOrder[]; |
| 725 | static const char kServiceSortEtc[]; |
mukesh agrawal | e37ad32 | 2013-10-08 16:33:56 -0700 | [diff] [blame] | 726 | static const char kServiceSortSerialNumber[]; |
Darin Petkov | 2f903b3 | 2012-04-18 12:56:43 +0200 | [diff] [blame] | 727 | static const char kServiceSortTechnology[]; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 728 | |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 729 | static const uint64_t kMaxAutoConnectCooldownTimeMilliseconds; |
| 730 | static const uint64_t kMinAutoConnectCooldownTimeMilliseconds; |
| 731 | static const uint64_t kAutoConnectCooldownBackoffFactor; |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 732 | |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 733 | static const int kDisconnectsMonitorSeconds; |
| 734 | static const int kMisconnectsMonitorSeconds; |
| 735 | static const int kReportDisconnectsThreshold; |
| 736 | static const int kReportMisconnectsThreshold; |
| 737 | static const int kMaxDisconnectEventHistory; |
Samuel Tan | 07dfabc | 2015-01-20 15:10:39 -0800 | [diff] [blame] | 738 | static const int kMaxMisconnectEventHistory; |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 739 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 740 | bool GetAutoConnect(Error* error); |
Thieu Le | 284fe79 | 2012-01-31 17:53:19 -0800 | [diff] [blame] | 741 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 742 | std::string GetCheckPortal(Error* error); |
| 743 | bool SetCheckPortal(const std::string& check_portal, Error* error); |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 744 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 745 | std::string GetGuid(Error* error); |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 746 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 747 | virtual std::string GetDeviceRpcId(Error* error) const = 0; |
Chris Masone | 95207da | 2011-06-29 16:50:49 -0700 | [diff] [blame] | 748 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 749 | std::string GetIPConfigRpcIdentifier(Error* error) const; |
Paul Stewart | 10241e3 | 2012-04-23 18:15:06 -0700 | [diff] [blame] | 750 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 751 | std::string GetNameProperty(Error* error); |
Darin Petkov | 9c6e981 | 2013-03-26 13:49:07 +0100 | [diff] [blame] | 752 | // The base implementation asserts that |name| matches the current Name |
| 753 | // property value. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 754 | virtual bool SetNameProperty(const std::string& name, Error* error); |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 755 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 756 | int32_t GetPriority(Error* error); |
| 757 | int32_t GetPriorityWithinTechnology(Error* error); |
Paul Stewart | 0c43833 | 2012-04-11 07:55:27 -0700 | [diff] [blame] | 758 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 759 | std::string GetProfileRpcId(Error* error); |
| 760 | bool SetProfileRpcId(const std::string& profile, Error* error); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 761 | |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 762 | // Returns TCP port of service's HTTP proxy in host order. |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 763 | uint16_t GetHTTPProxyPort(Error* error) const; |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 764 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 765 | std::string GetProxyConfig(Error* error); |
| 766 | bool SetProxyConfig(const std::string& proxy_config, Error* error); |
Philipp Neubeck | 7917360 | 2012-11-13 21:10:09 +0100 | [diff] [blame] | 767 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 768 | Strings GetDisconnectsProperty(Error* error) const; |
| 769 | Strings GetMisconnectsProperty(Error* error) const; |
Darin Petkov | 0c65bdd | 2012-12-05 13:42:41 +0100 | [diff] [blame] | 770 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 771 | void ReEnableAutoConnectTask(); |
| 772 | // Disables autoconnect and posts a task to re-enable it after a cooldown. |
| 773 | // Note that autoconnect could be disabled for other reasons as well. |
| 774 | void ThrottleFutureAutoConnects(); |
| 775 | |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 776 | // Saves settings to profile, if we have one. Unlike |
| 777 | // SaveServiceToProfile, SaveToProfile never assigns this service |
| 778 | // into a profile. |
| 779 | void SaveToProfile(); |
| 780 | |
Paul Stewart | 483e472 | 2012-12-18 10:23:17 -0800 | [diff] [blame] | 781 | // Qualify the conditions under which the most recent disconnect occurred. |
| 782 | // Make note ot the fact that there was a problem connecting / staying |
| 783 | // connected if the disconnection did not occur as a clear result of user |
| 784 | // action. |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 785 | void NoteDisconnectEvent(); |
| 786 | |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 787 | // Utility function that returns true if a is different from b. When they |
| 788 | // are, "decision" is populated with the boolean value of "a > b". |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 789 | static bool DecideBetween(int a, int b, bool* decision); |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 790 | |
Peter Qiu | dc4e099 | 2014-05-01 10:02:52 -0700 | [diff] [blame] | 791 | // Report the result of user-initiated connection attempt to UMA stats. |
| 792 | // Currently only report stats for wifi service. |
| 793 | void ReportUserInitiatedConnectionResult(ConnectState state); |
| 794 | |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 795 | // Linearize security parameters (crypto algorithm, key rotation, endpoint |
| 796 | // authentication) for comparison. |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 797 | uint16_t SecurityLevel(); |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 798 | |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 799 | // WeakPtrFactory comes first, so that other fields can use it. |
| 800 | base::WeakPtrFactory<Service> weak_ptr_factory_; |
| 801 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 802 | ConnectState state_; |
Darin Petkov | c8d91e5 | 2013-01-21 11:43:47 +0100 | [diff] [blame] | 803 | ConnectState previous_state_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 804 | ConnectFailure failure_; |
| 805 | bool auto_connect_; |
Paul Stewart | 2da34c0 | 2013-10-17 15:28:56 -0700 | [diff] [blame] | 806 | |
| 807 | // Denotes whether the value of auto_connect_ property value should be |
| 808 | // retained, i.e. only be allowed to change via explicit property changes |
| 809 | // from the UI. |
| 810 | bool retain_auto_connect_; |
| 811 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 812 | std::string check_portal_; |
| 813 | bool connectable_; |
| 814 | std::string error_; |
Darin Petkov | aba8932 | 2013-03-11 14:48:22 +0100 | [diff] [blame] | 815 | std::string error_details_; |
Paul Stewart | d7c09a5 | 2014-02-19 12:50:29 -0800 | [diff] [blame] | 816 | std::string previous_error_; |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 817 | int32_t previous_error_serial_number_; |
mukesh agrawal | adb6848 | 2012-01-17 16:31:51 -0800 | [diff] [blame] | 818 | bool explicitly_disconnected_; |
Peter Qiu | dc4e099 | 2014-05-01 10:02:52 -0700 | [diff] [blame] | 819 | bool is_in_user_connect_; |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 820 | int32_t priority_; |
Paul Stewart | d9c7cfc | 2015-01-06 14:26:22 -0800 | [diff] [blame] | 821 | int32_t priority_within_technology_; |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 822 | uint8_t crypto_algorithm_; |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 823 | bool key_rotation_; |
| 824 | bool endpoint_auth_; |
Peter Qiu | 9b83c89 | 2014-08-09 23:06:02 -0700 | [diff] [blame] | 825 | std::string portal_detection_failure_phase_; |
| 826 | std::string portal_detection_failure_status_; |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 827 | |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 828 | uint8_t strength_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 829 | std::string proxy_config_; |
Paul Stewart | 987e71e | 2011-12-05 09:45:06 -0800 | [diff] [blame] | 830 | std::string ui_data_; |
Paul Stewart | 4c56161 | 2012-03-21 12:49:01 -0700 | [diff] [blame] | 831 | std::string guid_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 832 | bool save_credentials_; |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 833 | #if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) |
Ben Chan | cd47732 | 2014-10-17 14:19:30 -0700 | [diff] [blame] | 834 | std::unique_ptr<EapCredentials> eap_; |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 835 | #endif // DISABLE_WIFI || DISABLE_WIRED_8021X |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 836 | Technology::Identifier technology_; |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 837 | // The time of the most recent failure. Value is 0 if the service is |
| 838 | // not currently failed. |
| 839 | time_t failed_time_; |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 840 | // Whether or not this service has ever reached kStateConnected. |
| 841 | bool has_ever_connected_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 842 | |
Samuel Tan | 07dfabc | 2015-01-20 15:10:39 -0800 | [diff] [blame] | 843 | EventHistory disconnects_; // Connection drops. |
| 844 | EventHistory misconnects_; // Failures to connect. |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 845 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 846 | base::CancelableClosure reenable_auto_connect_task_; |
Ben Chan | 7fab897 | 2014-08-10 17:14:46 -0700 | [diff] [blame] | 847 | uint64_t auto_connect_cooldown_milliseconds_; |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 848 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 849 | ProfileRefPtr profile_; |
| 850 | PropertyStore store_; |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 851 | std::set<std::string> parameters_ignored_for_configure_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 852 | |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 853 | EventDispatcher* dispatcher_; |
mukesh agrawal | e37ad32 | 2013-10-08 16:33:56 -0700 | [diff] [blame] | 854 | unsigned int serial_number_; |
mukesh agrawal | d835b20 | 2011-10-07 15:26:47 -0700 | [diff] [blame] | 855 | std::string unique_name_; // MUST be unique amongst service instances |
Darin Petkov | 457728b | 2013-01-09 09:49:08 +0100 | [diff] [blame] | 856 | |
| 857 | // Service's friendly name is presented through the UI. By default it's the |
| 858 | // same as |unique_name_| but normally Service subclasses override |
| 859 | // it. WARNING: Don't log the friendly name at the default logging level due |
| 860 | // to PII concerns. |
| 861 | std::string friendly_name_; |
| 862 | |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 863 | // List of subject names reported by remote entity during TLS setup. |
| 864 | std::vector<std::string> remote_certification_; |
| 865 | |
Ben Chan | cd47732 | 2014-10-17 14:19:30 -0700 | [diff] [blame] | 866 | std::unique_ptr<ServiceAdaptorInterface> adaptor_; |
| 867 | std::unique_ptr<ServicePropertyChangeNotifier> property_change_notifier_; |
| 868 | std::unique_ptr<HTTPProxy> http_proxy_; |
Paul Stewart | c1dec4d | 2011-12-08 15:25:28 -0800 | [diff] [blame] | 869 | ConnectionRefPtr connection_; |
Paul Stewart | 1062d9d | 2012-04-27 10:42:27 -0700 | [diff] [blame] | 870 | StaticIPParameters static_ip_parameters_; |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 871 | Metrics* metrics_; |
| 872 | Manager* manager_; |
Ben Chan | cd47732 | 2014-10-17 14:19:30 -0700 | [diff] [blame] | 873 | std::unique_ptr<Sockets> sockets_; |
Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 874 | Time* time_; |
| 875 | DiagnosticsReporter* diagnostics_reporter_; |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 876 | |
mukesh agrawal | e37ad32 | 2013-10-08 16:33:56 -0700 | [diff] [blame] | 877 | // The |serial_number_| for the next Service. |
| 878 | static unsigned int next_serial_number_; |
| 879 | |
Peter Qiu | 9d58193 | 2014-04-14 16:37:37 -0700 | [diff] [blame] | 880 | // Network identifier indicating the network (gateway) the service is |
| 881 | // connected to. |
| 882 | int connection_id_; |
Peter Qiu | a89154b | 2014-05-23 15:45:42 -0700 | [diff] [blame] | 883 | // When set to true, this service will automatically fallback to Google's DNS |
| 884 | // servers if the portal detection failed due to DNS failure and Google's DNS |
| 885 | // servers are working. |
| 886 | bool is_dns_auto_fallback_allowed_; |
Peter Qiu | d49760e | 2014-09-19 16:13:42 -0700 | [diff] [blame] | 887 | // When set to true, will not start link monitor when the connection to this |
| 888 | // service is established. |
| 889 | bool link_monitor_disabled_; |
Paul Stewart | 3fee7e3 | 2014-10-15 21:39:29 -0700 | [diff] [blame] | 890 | // When set to true, the credentials for this service will be considered |
| 891 | // valid, and will not require an initial connection to rank it highly for |
| 892 | // auto-connect. |
| 893 | bool managed_credentials_; |
Peter Qiu | a388fdb | 2015-04-03 10:31:22 -0700 | [diff] [blame] | 894 | // Flag indicating if this service is unreliable (experiencing multiple |
| 895 | // link monitor failures in a short period of time). |
| 896 | bool unreliable_; |
Peter Qiu | 9d58193 | 2014-04-14 16:37:37 -0700 | [diff] [blame] | 897 | |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 898 | DISALLOW_COPY_AND_ASSIGN(Service); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 899 | }; |
| 900 | |
| 901 | } // namespace shill |
| 902 | |
Ben Chan | 19f8397 | 2012-10-03 23:25:56 -0700 | [diff] [blame] | 903 | #endif // SHILL_SERVICE_H_ |