blob: c0f1272e1222bdd89a80dc9815d3109dfe2322c0 [file] [log] [blame]
Arman Uguray2717a102013-01-29 23:36:06 -08001// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
Paul Stewart75897df2011-04-27 09:05:53 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Ben Chan19f83972012-10-03 23:25:56 -07005#ifndef SHILL_SERVICE_H_
6#define SHILL_SERVICE_H_
Paul Stewart75897df2011-04-27 09:05:53 -07007
mukesh agrawal568b5c62012-02-28 14:44:47 -08008#include <time.h>
9
Darin Petkov385b9bc2012-12-03 15:25:05 +010010#include <deque>
Chris Masone8fe2c7e2011-06-09 15:51:19 -070011#include <map>
Paul Stewartcb59fed2012-03-21 21:14:46 -070012#include <set>
Darin Petkov385b9bc2012-12-03 15:25:05 +010013#include <string>
Chris Masone8fe2c7e2011-06-09 15:51:19 -070014#include <vector>
Chris Masone9be4a9d2011-05-16 15:44:09 -070015
Christopher Wiley0801d192012-09-24 11:57:15 -070016#include <base/cancelable_callback.h>
Chris Masone9be4a9d2011-05-16 15:44:09 -070017#include <base/memory/ref_counted.h>
Paul Stewartba41b992011-05-26 07:02:46 -070018#include <base/memory/scoped_ptr.h>
Christopher Wiley0801d192012-09-24 11:57:15 -070019#include <base/memory/weak_ptr.h>
Darin Petkovba40dd32011-07-11 20:06:39 -070020#include <gtest/gtest_prod.h> // for FRIEND_TEST
Paul Stewart75897df2011-04-27 09:05:53 -070021
Eric Shienbrood9a245532012-03-07 14:20:39 -050022#include "shill/adaptor_interfaces.h"
Chris Masone3bd3c8c2011-06-13 08:20:26 -070023#include "shill/accessor_interface.h"
Eric Shienbrood9a245532012-03-07 14:20:39 -050024#include "shill/callbacks.h"
Chris Masoneb925cc82011-06-22 15:39:57 -070025#include "shill/property_store.h"
Chris Masone7aa5f902011-07-11 11:13:35 -070026#include "shill/refptr_types.h"
Darin Petkov0c65bdd2012-12-05 13:42:41 +010027#include "shill/shill_time.h"
Paul Stewart1062d9d2012-04-27 10:42:27 -070028#include "shill/static_ip_parameters.h"
Paul Stewart22aa71b2011-09-16 12:15:11 -070029#include "shill/technology.h"
Chris Masonec1e50412011-06-07 13:04:53 -070030
Thieu Leb84ba342012-03-02 15:15:19 -080031namespace chromeos_metrics {
32class Timer;
33}
34
Paul Stewart75897df2011-04-27 09:05:53 -070035namespace shill {
36
Chris Masone9be4a9d2011-05-16 15:44:09 -070037class ControlInterface;
Darin Petkov385b9bc2012-12-03 15:25:05 +010038class DiagnosticsReporter;
Paul Stewart75897df2011-04-27 09:05:53 -070039class Endpoint;
Chris Masone8fe2c7e2011-06-09 15:51:19 -070040class Error;
Chris Masone9be4a9d2011-05-16 15:44:09 -070041class EventDispatcher;
Paul Stewartbe5f5b32011-12-07 17:11:11 -080042class HTTPProxy;
mukesh agrawal7a4e4002011-09-06 11:26:05 -070043class KeyValueStore;
Chris Masone6791a432011-07-12 13:23:19 -070044class Manager;
Thieu Le48e6d6d2011-12-06 00:40:27 +000045class Metrics;
Chris Masone9be4a9d2011-05-16 15:44:09 -070046class ServiceAdaptorInterface;
Darin Petkov5eb05422012-05-11 15:45:25 +020047class Sockets;
Darin Petkovba40dd32011-07-11 20:06:39 -070048class StoreInterface;
Paul Stewart75897df2011-04-27 09:05:53 -070049
Chris Masone7aa5f902011-07-11 11:13:35 -070050// A Service is a uniquely named entity, which the system can
51// connect in order to begin sending and receiving network traffic.
52// All Services are bound to an Entry, which represents the persistable
53// state of the Service. If the Entry is populated at the time of Service
54// creation, that information is used to prime the Service. If not, the Entry
55// becomes populated over time.
Chris Masone27c4aa52011-07-02 13:10:14 -070056class Service : public base::RefCounted<Service> {
Paul Stewart75897df2011-04-27 09:05:53 -070057 public:
Darin Petkovba40dd32011-07-11 20:06:39 -070058 static const char kCheckPortalAuto[];
59 static const char kCheckPortalFalse[];
60 static const char kCheckPortalTrue[];
61
Darin Petkovaba89322013-03-11 14:48:22 +010062 static const char kErrorDetailsNone[];
63
Paul Stewart0756db92012-01-27 08:34:47 -080064 // TODO(pstew): Storage constants shouldn't need to be public
65 // crosbug.com/25813
66 static const char kStorageAutoConnect[];
67 static const char kStorageCheckPortal[];
68 static const char kStorageEapAnonymousIdentity[];
69 static const char kStorageEapCACert[];
70 static const char kStorageEapCACertID[];
Paul Stewartecf4cd12012-04-17 11:08:39 -070071 static const char kStorageEapCACertNSS[];
Paul Stewart5baebb72013-03-14 11:43:29 -070072 static const char kStorageEapCACertPEM[];
Paul Stewart0756db92012-01-27 08:34:47 -080073 static const char kStorageEapCertID[];
74 static const char kStorageEapClientCert[];
75 static const char kStorageEapEap[];
76 static const char kStorageEapIdentity[];
77 static const char kStorageEapInnerEap[];
78 static const char kStorageEapKeyID[];
79 static const char kStorageEapKeyManagement[];
80 static const char kStorageEapPIN[];
81 static const char kStorageEapPassword[];
82 static const char kStorageEapPrivateKey[];
83 static const char kStorageEapPrivateKeyPassword[];
84 static const char kStorageEapUseSystemCAs[];
85 static const char kStorageError[];
86 static const char kStorageFavorite[];
87 static const char kStorageGUID[];
mukesh agrawalcf24a242012-05-21 16:46:11 -070088 static const char kStorageHasEverConnected[];
Paul Stewart0756db92012-01-27 08:34:47 -080089 static const char kStorageName[];
90 static const char kStoragePriority[];
91 static const char kStorageProxyConfig[];
92 static const char kStorageSaveCredentials[];
93 static const char kStorageType[];
94 static const char kStorageUIData[];
95
mukesh agrawal8f3f7752012-02-17 19:42:09 -080096 static const uint8 kStrengthMax;
97 static const uint8 kStrengthMin;
98
Paul Stewart75897df2011-04-27 09:05:53 -070099 enum ConnectFailure {
Paul Stewart03dba0b2011-08-22 16:32:45 -0700100 kFailureUnknown,
Paul Stewartf2d60912012-07-15 08:37:30 -0700101 kFailureAAA,
Darin Petkov1c049c72013-03-21 13:15:45 +0100102 kFailureActivation,
103 kFailureBadPassphrase,
Paul Stewartf2d60912012-07-15 08:37:30 -0700104 kFailureBadWEPKey,
105 kFailureConnect,
Darin Petkov1c049c72013-03-21 13:15:45 +0100106 kFailureDHCP,
Paul Stewartf2d60912012-07-15 08:37:30 -0700107 kFailureDNSLookup,
Paul Stewartdb0f9172012-11-30 16:48:09 -0800108 kFailureEAPAuthentication,
109 kFailureEAPLocalTLS,
110 kFailureEAPRemoteTLS,
Darin Petkov1c049c72013-03-21 13:15:45 +0100111 kFailureHTTPGet,
112 kFailureIPSecCertAuth,
113 kFailureIPSecPSKAuth,
114 kFailureInternal,
115 kFailureNeedEVDO,
116 kFailureNeedHomeNetwork,
117 kFailureOTASP,
118 kFailureOutOfRange,
119 kFailurePPPAuth,
120 kFailurePinMissing,
Thieu Le48e6d6d2011-12-06 00:40:27 +0000121 kFailureMax
Paul Stewart75897df2011-04-27 09:05:53 -0700122 };
Chris Masone9be4a9d2011-05-16 15:44:09 -0700123 enum ConnectState {
Paul Stewart03dba0b2011-08-22 16:32:45 -0700124 kStateUnknown,
125 kStateIdle,
126 kStateAssociating,
127 kStateConfiguring,
128 kStateConnected,
129 kStateDisconnected,
Thieu Le48e6d6d2011-12-06 00:40:27 +0000130 kStatePortal,
Gaurav Shahc6d6c722011-11-17 18:59:39 -0800131 kStateFailure,
132 kStateOnline
Chris Masone9be4a9d2011-05-16 15:44:09 -0700133 };
mukesh agrawal43970a22013-02-15 16:00:07 -0800134 enum CryptoAlgorithm {
135 kCryptoNone,
136 kCryptoRc4,
137 kCryptoAes
138 };
Dave Parker074bad62013-03-27 13:17:27 -0700139 struct EapCredentials {
140 EapCredentials() : use_system_cas(true) {}
141 // Who we identify ourselves as to the EAP authenticator.
142 std::string identity;
143 // The outer or only EAP authetnication type.
144 std::string eap;
145 // The inner EAP authentication type.
146 std::string inner_eap;
147 // When there is an inner EAP type, use this identity for the outer.
148 std::string anonymous_identity;
149 // Filename of the client certificate.
150 std::string client_cert;
151 // Locator for the client certificate within the security token.
152 std::string cert_id;
153 // Filename of the client private key.
154 std::string private_key;
155 // Password for decrypting the client private key file.
156 std::string private_key_password;
157 // Locator for the client private key within the security token.
158 std::string key_id;
159 // Filename of the certificate authority (CA) certificate.
160 std::string ca_cert;
161 // Locator for the CA certificate within the security token.
162 std::string ca_cert_id;
163 // Locator for the CA certificate within the user NSS database.
164 std::string ca_cert_nss;
165 // Raw PEM contents of the CA certificate.
166 std::string ca_cert_pem;
167 // If true, use the system-wide CA database to authenticate the remote.
168 bool use_system_cas;
169 // PIN code for accessing the security token.
170 std::string pin;
171 // Password to use for EAP methods which require one.
172 std::string password;
173 // Key management algorithm to use after EAP succeeds.
174 std::string key_management;
175 // If non-empty, string to match remote subject against before connecting.
176 std::string subject_match;
177 // List of subject names reported by remote entity during TLS setup.
178 std::vector<std::string> remote_certification;
179 };
Chris Masone9be4a9d2011-05-16 15:44:09 -0700180
Paul Stewartac4ac002011-08-26 12:04:26 -0700181 static const int kPriorityNone;
182
Chris Masone9be4a9d2011-05-16 15:44:09 -0700183 // A constructor for the Service object
184 Service(ControlInterface *control_interface,
185 EventDispatcher *dispatcher,
Thieu Le3426c8f2012-01-11 17:35:11 -0800186 Metrics *metrics,
mukesh agrawal7a4e4002011-09-06 11:26:05 -0700187 Manager *manager,
Gaurav Shah435de2c2011-11-17 19:01:07 -0800188 Technology::Identifier technology);
Darin Petkovba40dd32011-07-11 20:06:39 -0700189
mukesh agrawal8a3188d2011-12-01 20:56:44 +0000190 // AutoConnect MAY choose to ignore the connection request in some
191 // cases. For example, if the corresponding Device only supports one
192 // concurrent connection, and another Service is already connected
193 // or connecting.
194 //
195 // AutoConnect MAY issue RPCs immediately. So AutoConnect MUST NOT
196 // be called from a D-Bus signal handler context.
197 virtual void AutoConnect();
198 // Queue up a connection attempt.
mukesh agrawaladb68482012-01-17 16:31:51 -0800199 virtual void Connect(Error *error);
Christopher Wileyabd3b502012-09-26 13:08:52 -0700200 // Disconnect this service. Override this method to add your service specific
201 // disconnect logic, but call the super class's Disconnect() first.
mukesh agrawaladb68482012-01-17 16:31:51 -0800202 virtual void Disconnect(Error *error);
Christopher Wileyabd3b502012-09-26 13:08:52 -0700203 // Disconnects this service via Disconnect(). Marks the service as having
204 // failed with |failure|. Do not override this method.
205 virtual void DisconnectWithFailure(ConnectFailure failure, Error *error);
206 // Disconnects this service via Disconnect(). The service will not be eligible
207 // for auto-connect until a subsequent call to Connect, or Load. Do not
208 // override this method.
209 virtual void UserInitiatedDisconnect(Error *error);
Chris Masonea82b7112011-05-25 15:16:29 -0700210
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500211 // The default implementation returns the error kInvalidArguments.
212 virtual void ActivateCellularModem(const std::string &carrier,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500213 Error *error,
214 const ResultCallback &callback);
Ben Chan5d924542013-02-14 17:49:08 -0800215 // The default implementation returns the error kNotSupported.
216 virtual void CompleteCellularActivation(Error *error);
Darin Petkovc408e692011-08-17 13:47:15 -0700217
Gaurav Shah1b7a6162011-11-09 11:41:01 -0800218 virtual bool IsActive(Error *error);
Paul Stewart03dba0b2011-08-22 16:32:45 -0700219
Paul Stewart7fb09382012-07-18 17:32:27 -0700220 // Returns whether services of this type should be auto-connect by default.
221 virtual bool IsAutoConnectByDefault() const { return false; }
222
Paul Stewart03dba0b2011-08-22 16:32:45 -0700223 virtual ConnectState state() const { return state_; }
224 // Updates the state of the Service and alerts the manager. Also
225 // clears |failure_| if the new state isn't a failure.
226 virtual void SetState(ConnectState state);
Darin Petkov58f0b6d2012-06-12 12:52:30 +0200227 std::string GetStateString() const;
Paul Stewart03dba0b2011-08-22 16:32:45 -0700228
Paul Stewart22aa71b2011-09-16 12:15:11 -0700229 // State utility functions
Darin Petkovc8d91e52013-01-21 11:43:47 +0100230 static bool IsConnectedState(ConnectState state);
231 static bool IsConnectingState(ConnectState state);
232
233 virtual bool IsConnected() const;
234 virtual bool IsConnecting() const;
mukesh agrawal8a3188d2011-12-01 20:56:44 +0000235 virtual bool IsFailed() const {
mukesh agrawal568b5c62012-02-28 14:44:47 -0800236 // We sometimes lie about the failure state, to keep Chrome happy
237 // (see comment in WiFi::HandleDisconnect). Hence, we check both
238 // state and |failed_time_|.
239 return state() == kStateFailure || failed_time_ > 0;
mukesh agrawal8a3188d2011-12-01 20:56:44 +0000240 }
Paul Stewartdf3c0a82012-11-09 15:54:33 -0800241
242 // Returns true if the connection for |this| depends on service |b|.
243 virtual bool IsDependentOn(const ServiceRefPtr &b) const;
244
Paul Stewarta121c442012-06-09 14:12:58 -0700245 virtual bool IsPortalled() const {
246 return state() == kStatePortal;
247 }
Paul Stewart22aa71b2011-09-16 12:15:11 -0700248
Paul Stewart03dba0b2011-08-22 16:32:45 -0700249 virtual ConnectFailure failure() const { return failure_; }
mukesh agrawal568b5c62012-02-28 14:44:47 -0800250 // Records the failure mode and time. Sets the Service state to "Failure".
Paul Stewart03dba0b2011-08-22 16:32:45 -0700251 virtual void SetFailure(ConnectFailure failure);
mukesh agrawal568b5c62012-02-28 14:44:47 -0800252 // Records the failure mode and time. Sets the Service state to "Idle".
253 // Avoids showing a failure mole in the UI.
254 virtual void SetFailureSilent(ConnectFailure failure);
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700255
Darin Petkovba40dd32011-07-11 20:06:39 -0700256 // Returns a string that is guaranteed to uniquely identify this Service
257 // instance.
Darin Petkov457728b2013-01-09 09:49:08 +0100258 const std::string &unique_name() const { return unique_name_; }
Darin Petkovafa6fc42011-06-21 16:21:08 -0700259
Chris Masone6791a432011-07-12 13:23:19 -0700260 virtual std::string GetRpcIdentifier() const;
Chris Masone3c3f6a12011-07-01 10:01:41 -0700261
Darin Petkovba40dd32011-07-11 20:06:39 -0700262 // Returns the unique persistent storage identifier for the service.
Chris Masone6515aab2011-10-12 16:19:09 -0700263 virtual std::string GetStorageIdentifier() const = 0;
Darin Petkovba40dd32011-07-11 20:06:39 -0700264
Paul Stewartbba6a5b2011-11-02 18:45:59 -0700265 // Returns whether the service configuration can be loaded from |storage|.
266 virtual bool IsLoadableFrom(StoreInterface *storage) const;
267
Paul Stewart81426132012-05-16 10:05:10 -0700268 // Returns true if the service uses 802.1x for key management.
269 virtual bool Is8021x() const { return false; };
270
Darin Petkovba40dd32011-07-11 20:06:39 -0700271 // Loads the service from persistent |storage|. Returns true on success.
Chris Masone9d779932011-08-25 16:33:41 -0700272 virtual bool Load(StoreInterface *storage);
Darin Petkovba40dd32011-07-11 20:06:39 -0700273
Paul Stewarta41e38d2011-11-11 07:47:29 -0800274 // Indicate to service that it is no longer persisted to storage. It
Paul Stewart65512e12012-03-26 18:01:08 -0700275 // should purge any stored profile state (e.g., credentials). Returns
276 // true to indicate that this service should also be unregistered from
277 // the manager, false otherwise.
278 virtual bool Unload();
Paul Stewarta41e38d2011-11-11 07:47:29 -0800279
Albert Chaulk0e1cdea2013-02-27 15:32:55 -0800280 // Attempt to remove the service. On failure, no changes in state will occur.
281 virtual void Remove(Error *error);
282
Darin Petkovba40dd32011-07-11 20:06:39 -0700283 // Saves the service to persistent |storage|. Returns true on success.
Chris Masone9d779932011-08-25 16:33:41 -0700284 virtual bool Save(StoreInterface *storage);
Darin Petkovba40dd32011-07-11 20:06:39 -0700285
Thieu Led4e9e552012-02-16 16:26:07 -0800286 // Saves the service to the current profile.
Gary Moraind93615e2012-04-27 11:50:03 -0700287 virtual void SaveToCurrentProfile();
Thieu Led4e9e552012-02-16 16:26:07 -0800288
Paul Stewartcb59fed2012-03-21 21:14:46 -0700289 // Applies all the properties in |args| to this service object's mutable
290 // store, except for those in parameters_ignored_for_configure_.
291 // Returns an error in |error| if one or more parameter set attempts
292 // fails, but will only return the first error.
293 virtual void Configure(const KeyValueStore &args, Error *error);
294
Paul Stewart7a20aa42013-01-17 12:21:41 -0800295 // Iterate over all the properties in |args| and test for an identical
296 // value in this service object's store. Returns false if one or more
297 // keys in |args| do not exist or have different values, true otherwise.
298 virtual bool DoPropertiesMatch(const KeyValueStore &args) const;
299
Paul Stewartd215af62012-04-24 23:25:50 -0700300 // Returns whether portal detection is explicitly disabled on this service
301 // via a property set on it.
302 virtual bool IsPortalDetectionDisabled() const;
303
304 // Returns whether portal detection is set to follow the default setting
305 // of this service's technology via a property set on it.
306 virtual bool IsPortalDetectionAuto() const;
307
Paul Stewart10ccbb32012-04-26 15:59:30 -0700308 // Returns true if the service is persisted to a non-ephemeral profile.
309 virtual bool IsRemembered() const;
310
Paul Stewarta41e38d2011-11-11 07:47:29 -0800311 // Returns true if the service RPC identifier should be part of the
312 // manager's advertised services list, false otherwise.
313 virtual bool IsVisible() const { return true; }
314
Paul Stewart20088d82012-02-16 06:58:55 -0800315 // Returns true if there is a proxy configuration set on this service.
316 virtual bool HasProxyConfig() const { return !proxy_config_.empty(); }
317
Paul Stewarta47c3c62012-12-18 12:14:29 -0800318 // Returns whether this service has had recent connection issues.
319 virtual bool HasRecentConnectionIssues();
320
mukesh agrawal00917ce2011-11-22 23:56:55 +0000321 virtual void MakeFavorite();
322
Darin Petkov5eb05422012-05-11 15:45:25 +0200323 // Set the connection for this service. If the connection is non-NULL, create
324 // an HTTP Proxy that will utilize this service's connection to serve
325 // requests.
326 virtual void SetConnection(const ConnectionRefPtr &connection);
327 virtual const ConnectionRefPtr &connection() const { return connection_; }
Paul Stewartbe5f5b32011-12-07 17:11:11 -0800328
Gaurav Shah10109f22011-11-11 20:16:22 -0800329 // Examines the EAP credentials for the service and returns true if a
330 // connection attempt can be made.
331 bool Is8021xConnectable() const;
332
Paul Stewartbc6e7392012-05-24 07:07:48 -0700333 // Add an EAP certification id |name| at position |depth| in the stack.
334 // Returns true if entry was added, false otherwise.
335 virtual bool AddEAPCertification(const std::string &name, size_t depth);
336 // Clear all EAP certification elements.
337 void ClearEAPCertification();
338
Thieu Le48e6d6d2011-12-06 00:40:27 +0000339 // The inherited class should register any custom metrics in this method.
340 virtual void InitializeCustomMetrics() const {}
341
342 // The inherited class that needs to send metrics after the service has
Thieu Leb84ba342012-03-02 15:15:19 -0800343 // transitioned to the ready state should override this method.
344 // |time_resume_to_ready_milliseconds| holds the elapsed time from when
345 // the system was resumed until when the service transitioned to the
346 // connected state. This value is non-zero for the first service transition
347 // to the connected state after a resume.
348 virtual void SendPostReadyStateMetrics(
349 int64 /*time_resume_to_ready_milliseconds*/) const {}
Thieu Le48e6d6d2011-12-06 00:40:27 +0000350
Darin Petkovafa6fc42011-06-21 16:21:08 -0700351 bool auto_connect() const { return auto_connect_; }
352 void set_auto_connect(bool connect) { auto_connect_ = connect; }
Paul Stewart75897df2011-04-27 09:05:53 -0700353
Gaurav Shah435de2c2011-11-17 19:01:07 -0800354 bool connectable() const { return connectable_; }
Darin Petkovb2ba39f2012-06-06 10:33:43 +0200355 // TODO(petkov): Remove this method in favor of SetConnectable.
mukesh agrawal29c13a12011-11-24 00:09:19 +0000356 void set_connectable(bool connectable);
Darin Petkovb2ba39f2012-06-06 10:33:43 +0200357 // Sets the connectable property of the service. Broadcasts the new value and
358 // alerts the manager if necessary.
359 void SetConnectable(bool connectable);
Gaurav Shah435de2c2011-11-17 19:01:07 -0800360
Thieu Le67370f62012-02-14 23:01:42 +0000361 virtual bool explicitly_disconnected() const {
362 return explicitly_disconnected_;
363 }
364
Paul Stewart22aa71b2011-09-16 12:15:11 -0700365 bool favorite() const { return favorite_; }
mukesh agrawal00917ce2011-11-22 23:56:55 +0000366 // Setter is deliberately omitted; use MakeFavorite.
Paul Stewart22aa71b2011-09-16 12:15:11 -0700367
Arman Uguray2717a102013-01-29 23:36:06 -0800368 // Sets the flimflam::kNameProperty
369 void SetFriendlyName(const std::string &friendly_name);
Darin Petkov7f060332012-03-14 11:46:47 +0100370 void set_friendly_name(const std::string &n) { friendly_name_ = n; }
mukesh agrawal15908392011-11-16 18:29:25 +0000371
Paul Stewart4c561612012-03-21 12:49:01 -0700372 const std::string &guid() const { return guid_; }
373 void set_guid(const std::string &guid) { guid_ = guid; }
374
mukesh agrawalcf24a242012-05-21 16:46:11 -0700375 bool has_ever_connected() const { return has_ever_connected_; }
376
Paul Stewart22aa71b2011-09-16 12:15:11 -0700377 int32 priority() const { return priority_; }
378 void set_priority(int32 priority) { priority_ = priority; }
379
mukesh agrawal43970a22013-02-15 16:00:07 -0800380 size_t crypto_algorithm() const { return crypto_algorithm_; }
381 bool key_rotation() const { return key_rotation_; }
382 bool endpoint_auth() const { return endpoint_auth_; }
Paul Stewart22aa71b2011-09-16 12:15:11 -0700383
Darin Petkovd78ee7e2012-01-12 11:21:10 +0100384 void SetStrength(uint8 strength);
mukesh agrawale1d90e92012-02-15 17:36:08 -0800385
386 // uint8 streams out as a char. Coerce to a larger type, so that
387 // it prints as a number.
388 uint16 strength() const { return strength_; }
Paul Stewart22aa71b2011-09-16 12:15:11 -0700389
Gaurav Shah435de2c2011-11-17 19:01:07 -0800390 virtual Technology::Identifier technology() const { return technology_; }
Darin Petkov58f0b6d2012-06-12 12:52:30 +0200391 std::string GetTechnologyString() const;
Gaurav Shah435de2c2011-11-17 19:01:07 -0800392
Gaurav Shah10109f22011-11-11 20:16:22 -0800393 const EapCredentials &eap() const { return eap_; }
394 virtual void set_eap(const EapCredentials &eap);
395
Darin Petkovcb715292012-04-25 13:04:37 +0200396 bool save_credentials() const { return save_credentials_; }
397 void set_save_credentials(bool save) { save_credentials_ = save; }
398
Darin Petkov51489002011-08-18 13:13:20 -0700399 const std::string &error() const { return error_; }
400 void set_error(const std::string &error) { error_ = error; }
401
Darin Petkovaba89322013-03-11 14:48:22 +0100402 const std::string &error_details() const { return error_details_; }
403 void SetErrorDetails(const std::string &details);
404
Gaurav Shahc6d6c722011-11-17 18:59:39 -0800405 static const char *ConnectFailureToString(const ConnectFailure &state);
406 static const char *ConnectStateToString(const ConnectState &state);
407
Paul Stewart39db5ca2013-03-18 14:15:17 -0700408 // Compare two services. Returns true if Service |a| should be displayed
409 // above |b|. If |compare_connectivity_state| is true, the connectivity
410 // state of the service (service->state()) is used as the most significant
411 // criteria for comparsion, otherwise the service state is ignored. Use
412 // |tech_order| to rank services if more decisive criteria do not yield a
413 // difference. |reason| is populated with the exact criteria used for the
414 // ultimate comparison.
Paul Stewart22aa71b2011-09-16 12:15:11 -0700415 static bool Compare(ServiceRefPtr a,
416 ServiceRefPtr b,
Paul Stewart39db5ca2013-03-18 14:15:17 -0700417 bool compare_connectivity_state,
mukesh agrawalddc378f2012-02-17 18:26:20 -0800418 const std::vector<Technology::Identifier> &tech_order,
419 const char **reason);
Paul Stewart22aa71b2011-09-16 12:15:11 -0700420
Chris Masone34af2182011-08-22 11:59:36 -0700421 // These are defined in service.cc so that we don't have to include profile.h
Chris Masone9d779932011-08-25 16:33:41 -0700422 // TODO(cmasone): right now, these are here only so that we can get the
423 // profile name as a property. Can we store just the name, and then handle
424 // setting the profile for this service via |manager_|?
Chris Masone6791a432011-07-12 13:23:19 -0700425 const ProfileRefPtr &profile() const;
Philipp Neubeck79173602012-11-13 21:10:09 +0100426
427 // Sets the profile property of this service. Broadcasts the new value if it's
428 // not NULL. If the new value is NULL, the service will either be set to
429 // another profile afterwards or it will not be visible and not monitored
430 // anymore.
431 void SetProfile(const ProfileRefPtr &p);
432
433 // This is called from tests and shouldn't be called otherwise. Use SetProfile
434 // instead.
Chris Masone6791a432011-07-12 13:23:19 -0700435 void set_profile(const ProfileRefPtr &p);
436
Paul Stewart4357f4e2012-04-26 17:39:26 -0700437 // Notification that occurs when a service now has profile data saved
438 // on its behalf. Some service types like WiFi can choose to register
439 // themselves at this point.
440 virtual void OnProfileConfigured() {}
441
Paul Stewartff14b022012-04-24 20:06:23 -0700442 // Notification that occurs when a single property has been changed via
443 // the RPC adaptor.
Paul Stewart81426132012-05-16 10:05:10 -0700444 virtual void OnPropertyChanged(const std::string &property);
Paul Stewartff14b022012-04-24 20:06:23 -0700445
Christopher Wiley0801d192012-09-24 11:57:15 -0700446 // Called by the manager once after a resume.
447 virtual void OnAfterResume();
448
mukesh agrawalde29fa82011-09-16 16:16:36 -0700449 PropertyStore *mutable_store() { return &store_; }
450 const PropertyStore &store() const { return store_; }
Paul Stewartdef189e2012-08-02 20:12:09 -0700451 StaticIPParameters *mutable_static_ip_parameters() {
452 return &static_ip_parameters_;
453 }
Paul Stewart1062d9d2012-04-27 10:42:27 -0700454 const StaticIPParameters &static_ip_parameters() const {
455 return static_ip_parameters_;
456 }
Chris Masone27c4aa52011-07-02 13:10:14 -0700457
mukesh agrawalb54601c2011-06-07 17:39:22 -0700458 protected:
Darin Petkov5eb05422012-05-11 15:45:25 +0200459 friend class base::RefCounted<Service>;
460
mukesh agrawal03c15ce2012-11-29 17:36:21 -0800461 static const char kAutoConnBusy[];
462
Darin Petkov5eb05422012-05-11 15:45:25 +0200463 virtual ~Service();
464
Darin Petkov457728b2013-01-09 09:49:08 +0100465 const std::string &friendly_name() const { return friendly_name_; }
466
Chris Masone34af2182011-08-22 11:59:36 -0700467 // Returns true if a character is allowed to be in a service storage id.
468 static bool LegalChar(char a) { return isalnum(a) || a == '_'; }
469
Darin Petkov31332412012-01-28 01:50:02 +0100470 // Returns true if a character is disallowed to be in a service storage id.
471 static bool IllegalChar(char a) { return !LegalChar(a); }
472
Gaurav Shah1b7a6162011-11-09 11:41:01 -0800473 virtual std::string CalculateState(Error *error);
Darin Petkov58f0b6d2012-06-12 12:52:30 +0200474 std::string CalculateTechnology(Error *error);
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700475
mukesh agrawal8a3188d2011-12-01 20:56:44 +0000476 // Returns whether this service is in a state conducive to auto-connect.
477 // This should include any tests used for computing connectable(),
478 // as well as other critera such as whether the device associated with
479 // this service is busy with another connection.
mukesh agrawalbf14e942012-03-02 14:36:34 -0800480 //
481 // If the service is not auto-connectable, |*reason| will be set to
482 // point to C-string explaining why the service is not auto-connectable.
483 virtual bool IsAutoConnectable(const char **reason) const;
mukesh agrawal8a3188d2011-12-01 20:56:44 +0000484
mukesh agrawal292dc0f2012-01-26 18:02:46 -0800485 // HelpRegisterDerived*: Expose a property over RPC, with the name |name|.
486 //
487 // Reads of the property will be handled by invoking |get|.
488 // Writes to the property will be handled by invoking |set|.
489 // Clearing the property will be handled by PropertyStore.
mukesh agrawalffa3d042011-10-06 15:26:10 -0700490 void HelpRegisterDerivedBool(
491 const std::string &name,
Hristo Stefanoved2c28c2011-11-29 15:37:30 -0800492 bool(Service::*get)(Error *error),
493 void(Service::*set)(const bool &value, Error *error));
mukesh agrawalffa3d042011-10-06 15:26:10 -0700494 void HelpRegisterDerivedString(
495 const std::string &name,
Hristo Stefanoved2c28c2011-11-29 15:37:30 -0800496 std::string(Service::*get)(Error *error),
497 void(Service::*set)(const std::string &value, Error *error));
Paul Stewartbe5f5b32011-12-07 17:11:11 -0800498 void HelpRegisterDerivedUint16(
499 const std::string &name,
500 uint16(Service::*get)(Error *error),
501 void(Service::*set)(const uint16 &value, Error *error));
Jason Glasgowacdc11f2012-03-30 14:12:22 -0400502 void HelpRegisterDerivedRpcIdentifier(
503 const std::string &name,
504 std::string(Service::*get)(Error *),
505 void(Service::*set)(const RpcIdentifier&, Error *));
Darin Petkov0c65bdd2012-12-05 13:42:41 +0100506 void HelpRegisterConstDerivedStrings(
507 const std::string &name, Strings(Service::*get)(Error *error));
mukesh agrawal292dc0f2012-01-26 18:02:46 -0800508 // Expose a property over RPC, with the name |name|.
509 //
510 // Reads of the property will be handled by invoking |get|.
511 // Writes to the property will be handled by invoking |set|.
512 //
513 // Clearing the property will be handled by invoking |clear|, or
514 // calling |set| with |default_value| (whichever is non-NULL). It
515 // is an error to call this method with both |clear| and
516 // |default_value| non-NULL.
517 void HelpRegisterWriteOnlyDerivedString(
518 const std::string &name,
519 void(Service::*set)(const std::string &value, Error *error),
520 void(Service::*clear)(Error *error),
521 const std::string *default_value);
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700522
Darin Petkovb72cf402011-11-22 14:51:39 +0100523 ServiceAdaptorInterface *adaptor() const { return adaptor_.get(); }
524
Darin Petkovba40dd32011-07-11 20:06:39 -0700525 // Assigns |value| to |key| in |storage| if |value| is non-empty and |save| is
526 // true. Otherwise, removes |key| from |storage|. If |crypted| is true, the
527 // value is encrypted.
528 void SaveString(StoreInterface *storage,
Chris Masone34af2182011-08-22 11:59:36 -0700529 const std::string &id,
Darin Petkovba40dd32011-07-11 20:06:39 -0700530 const std::string &key,
531 const std::string &value,
532 bool crypted,
533 bool save);
534
Chris Masone34af2182011-08-22 11:59:36 -0700535 void LoadEapCredentials(StoreInterface *storage, const std::string &id);
536 void SaveEapCredentials(StoreInterface *storage, const std::string &id);
Paul Stewartd8ad3c42012-01-09 12:39:38 -0800537 void UnloadEapCredentials();
Darin Petkovba40dd32011-07-11 20:06:39 -0700538
Paul Stewartcb59fed2012-03-21 21:14:46 -0700539 // Ignore |parameter| when performing a Configure() operation.
540 void IgnoreParameterForConfigure(const std::string &parameter);
541
Paul Stewartf2d60912012-07-15 08:37:30 -0700542 // Update the service's string-based "Error" RPC property based on the
543 // failure_ enum.
544 void UpdateErrorProperty();
545
Paul Stewartcf199de2012-08-16 07:50:41 -0700546 // RPC setter for the the "AutoConnect" property.
547 virtual void SetAutoConnect(const bool &connect, Error *error);
548
Paul Stewartac4ac002011-08-26 12:04:26 -0700549 // Property accessors reserved for subclasses
550 EventDispatcher *dispatcher() const { return dispatcher_; }
551 const std::string &GetEAPKeyManagement() const;
mukesh agrawal43970a22013-02-15 16:00:07 -0800552 virtual void SetEAPKeyManagement(const std::string &key_management);
Paul Stewart9f32d192012-01-30 20:37:50 -0800553 void SetEAPPassword(const std::string &password, Error *error);
554 void SetEAPPrivateKeyPassword(const std::string &password, Error *error);
Paul Stewart65512e12012-03-26 18:01:08 -0700555 Manager *manager() const { return manager_; }
Thieu Le48e6d6d2011-12-06 00:40:27 +0000556 Metrics *metrics() const { return metrics_; }
mukesh agrawalb54601c2011-06-07 17:39:22 -0700557
Darin Petkov1d0080a2012-04-30 17:10:36 +0200558 void set_favorite(bool favorite) { favorite_ = favorite; }
mukesh agrawal43970a22013-02-15 16:00:07 -0800559 // Inform base class of the security properties for the service.
560 //
561 // NB: When adding a call to this function from a subclass, please check
562 // that the semantics of SecurityLevel() are appropriate for the subclass.
563 void SetSecurity(CryptoAlgorithm crypt, bool rotation, bool endpoint_auth);
Darin Petkov1d0080a2012-04-30 17:10:36 +0200564
Paul Stewart75897df2011-04-27 09:05:53 -0700565 private:
Paul Stewartcf199de2012-08-16 07:50:41 -0700566 friend class EthernetServiceTest;
Thieu Le48e6d6d2011-12-06 00:40:27 +0000567 friend class MetricsTest;
Paul Stewart0756db92012-01-27 08:34:47 -0800568 friend class ServiceAdaptorInterface;
Darin Petkov385b9bc2012-12-03 15:25:05 +0100569 friend class ServiceTest;
Darin Petkov457728b2013-01-09 09:49:08 +0100570 friend class VPNProviderTest;
Darin Petkov5eb05422012-05-11 15:45:25 +0200571 friend class VPNServiceTest;
mukesh agrawale1d90e92012-02-15 17:36:08 -0800572 friend class WiFiServiceTest;
Darin Petkov457728b2013-01-09 09:49:08 +0100573 friend class WiMaxProviderTest;
Darin Petkov6b9b2e12012-07-10 15:51:42 +0200574 friend class WiMaxServiceTest;
Christopher Wiley0801d192012-09-24 11:57:15 -0700575 FRIEND_TEST(AllMockServiceTest, AutoConnectWithFailures);
Darin Petkov457728b2013-01-09 09:49:08 +0100576 FRIEND_TEST(CellularCapabilityGSMTest, SetStorageIdentifier);
Liam McLoughlin0fec81c2013-02-28 10:31:47 -0500577 FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateStorageIdentifier);
Ben Chan19f83972012-10-03 23:25:56 -0700578 FRIEND_TEST(CellularServiceTest, IsAutoConnectable);
mukesh agrawalcc0fded2012-05-09 13:40:58 -0700579 FRIEND_TEST(DeviceTest, IPConfigUpdatedFailureWithStatic);
Paul Stewart39db5ca2013-03-18 14:15:17 -0700580 FRIEND_TEST(ManagerTest, ConnectToBestServices);
mukesh agrawal43970a22013-02-15 16:00:07 -0800581 // TODO(quiche): The SortServices test should probably move into
582 // service_unittest.cc. Then the following line should be removed.
583 // (crosbug.com/23370)
584 FRIEND_TEST(ManagerTest, SortServices);
mukesh agrawal03c15ce2012-11-29 17:36:21 -0800585 FRIEND_TEST(ServiceTest, AutoConnectLogging);
Darin Petkov58f0b6d2012-06-12 12:52:30 +0200586 FRIEND_TEST(ServiceTest, CalculateState);
587 FRIEND_TEST(ServiceTest, CalculateTechnology);
Paul Stewartbc6e7392012-05-24 07:07:48 -0700588 FRIEND_TEST(ServiceTest, Certification);
Paul Stewartcb59fed2012-03-21 21:14:46 -0700589 FRIEND_TEST(ServiceTest, ConfigureIgnoredProperty);
590 FRIEND_TEST(ServiceTest, ConfigureStringProperty);
Darin Petkovba40dd32011-07-11 20:06:39 -0700591 FRIEND_TEST(ServiceTest, Constructor);
Paul Stewart10241e32012-04-23 18:15:06 -0700592 FRIEND_TEST(ServiceTest, GetIPConfigRpcIdentifier);
Thieu Le284fe792012-01-31 17:53:19 -0800593 FRIEND_TEST(ServiceTest, GetProperties);
mukesh agrawal76d13882012-01-12 15:23:11 -0800594 FRIEND_TEST(ServiceTest, IsAutoConnectable);
Paul Stewartdf3c0a82012-11-09 15:54:33 -0800595 FRIEND_TEST(ServiceTest, IsDependentOn);
Paul Stewartd215af62012-04-24 23:25:50 -0700596 FRIEND_TEST(ServiceTest, RecheckPortal);
Darin Petkovba40dd32011-07-11 20:06:39 -0700597 FRIEND_TEST(ServiceTest, Save);
598 FRIEND_TEST(ServiceTest, SaveString);
599 FRIEND_TEST(ServiceTest, SaveStringCrypted);
600 FRIEND_TEST(ServiceTest, SaveStringDontSave);
601 FRIEND_TEST(ServiceTest, SaveStringEmpty);
mukesh agrawal43970a22013-02-15 16:00:07 -0800602 FRIEND_TEST(ServiceTest, SecurityLevel);
Paul Stewartd215af62012-04-24 23:25:50 -0700603 FRIEND_TEST(ServiceTest, SetCheckPortal);
Darin Petkovb2ba39f2012-06-06 10:33:43 +0200604 FRIEND_TEST(ServiceTest, SetConnectable);
Arman Uguray2717a102013-01-29 23:36:06 -0800605 FRIEND_TEST(ServiceTest, SetFriendlyName);
606 FRIEND_TEST(ServiceTest, SetProperty);
mukesh agrawal568b5c62012-02-28 14:44:47 -0800607 FRIEND_TEST(ServiceTest, State);
Paul Stewartd8ad3c42012-01-09 12:39:38 -0800608 FRIEND_TEST(ServiceTest, Unload);
Paul Stewart1369c2b2013-01-11 05:41:26 -0800609 FRIEND_TEST(WiFiMainTest, SuspectCredentialsEAPInProgress);
mukesh agrawalcf24a242012-05-21 16:46:11 -0700610 FRIEND_TEST(WiFiMainTest, SuspectCredentialsWPAPreviouslyConnected);
Christopher Wiley0801d192012-09-24 11:57:15 -0700611 FRIEND_TEST(WiFiTimerTest, ReconnectTimer);
Darin Petkovba40dd32011-07-11 20:06:39 -0700612
mukesh agrawalbf14e942012-03-02 14:36:34 -0800613 static const char kAutoConnConnected[];
614 static const char kAutoConnConnecting[];
615 static const char kAutoConnExplicitDisconnect[];
616 static const char kAutoConnNotConnectable[];
Darin Petkov4cbff5b2013-01-29 16:29:05 +0100617 static const char kAutoConnOffline[];
Christopher Wiley0801d192012-09-24 11:57:15 -0700618 static const char kAutoConnThrottled[];
mukesh agrawalbf14e942012-03-02 14:36:34 -0800619
Paul Stewartbc6e7392012-05-24 07:07:48 -0700620 static const size_t kEAPMaxCertificationElements;
621
Darin Petkov2f903b32012-04-18 12:56:43 +0200622 static const char kServiceSortAutoConnect[];
623 static const char kServiceSortConnectable[];
624 static const char kServiceSortFavorite[];
mukesh agrawalddc378f2012-02-17 18:26:20 -0800625 static const char kServiceSortIsConnected[];
Paul Stewartdf3c0a82012-11-09 15:54:33 -0800626 static const char kServiceSortDependency[];
mukesh agrawalddc378f2012-02-17 18:26:20 -0800627 static const char kServiceSortIsConnecting[];
628 static const char kServiceSortIsFailed[];
Paul Stewarta121c442012-06-09 14:12:58 -0700629 static const char kServiceSortIsPortalled[];
Darin Petkov2f903b32012-04-18 12:56:43 +0200630 static const char kServiceSortPriority[];
mukesh agrawalddc378f2012-02-17 18:26:20 -0800631 static const char kServiceSortSecurityEtc[];
Darin Petkov2f903b32012-04-18 12:56:43 +0200632 static const char kServiceSortTechnology[];
mukesh agrawalddc378f2012-02-17 18:26:20 -0800633 static const char kServiceSortUniqueName[];
634
Christopher Wiley0801d192012-09-24 11:57:15 -0700635 static const uint64 kMaxAutoConnectCooldownTimeMilliseconds;
636 static const uint64 kMinAutoConnectCooldownTimeMilliseconds;
637 static const uint64 kAutoConnectCooldownBackoffFactor;
638
Darin Petkov385b9bc2012-12-03 15:25:05 +0100639 static const int kDisconnectsMonitorSeconds;
640 static const int kMisconnectsMonitorSeconds;
641 static const int kReportDisconnectsThreshold;
642 static const int kReportMisconnectsThreshold;
643 static const int kMaxDisconnectEventHistory;
644
Thieu Le284fe792012-01-31 17:53:19 -0800645 bool GetAutoConnect(Error *error);
Thieu Le284fe792012-01-31 17:53:19 -0800646
Paul Stewartd215af62012-04-24 23:25:50 -0700647 std::string GetCheckPortal(Error *error);
648 void SetCheckPortal(const std::string &check_portal, Error *error);
649
Gaurav Shah1b7a6162011-11-09 11:41:01 -0800650 virtual std::string GetDeviceRpcId(Error *error) = 0;
Chris Masone95207da2011-06-29 16:50:49 -0700651
Paul Stewart10241e32012-04-23 18:15:06 -0700652 std::string GetIPConfigRpcIdentifier(Error *error);
653
Paul Stewart0c438332012-04-11 07:55:27 -0700654 std::string GetNameProperty(Error *error);
655 void AssertTrivialSetNameProperty(const std::string &name, Error *error);
656
Paul Stewart1b1a7f22012-01-06 16:24:06 -0800657 std::string GetProfileRpcId(Error *error);
658 void SetProfileRpcId(const std::string &profile, Error *error);
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700659
Paul Stewartbe5f5b32011-12-07 17:11:11 -0800660 // Returns TCP port of service's HTTP proxy in host order.
661 uint16 GetHTTPProxyPort(Error *error);
662
Philipp Neubeck79173602012-11-13 21:10:09 +0100663 std::string GetProxyConfig(Error *error);
664 void SetProxyConfig(const std::string &proxy_config, Error *error);
665
Darin Petkov0c65bdd2012-12-05 13:42:41 +0100666 static Strings ExtractWallClockToStrings(
667 const std::deque<Timestamp> &timestamps);
668 Strings GetDisconnectsProperty(Error *error);
669 Strings GetMisconnectsProperty(Error *error);
670
Christopher Wiley0801d192012-09-24 11:57:15 -0700671 void ReEnableAutoConnectTask();
672 // Disables autoconnect and posts a task to re-enable it after a cooldown.
673 // Note that autoconnect could be disabled for other reasons as well.
674 void ThrottleFutureAutoConnects();
675
mukesh agrawalcf24a242012-05-21 16:46:11 -0700676 // Saves settings to profile, if we have one. Unlike
677 // SaveServiceToProfile, SaveToProfile never assigns this service
678 // into a profile.
679 void SaveToProfile();
680
Paul Stewart483e4722012-12-18 10:23:17 -0800681 // Start at the head of |events| and remove all entries that occurred
682 // more than |seconds_ago| prior to |now|. Also, the size of |events|
683 // is unconditionally trimmed below kMaxDisconnectEventHistory.
684 static void ExpireEventsBefore(
685 int seconds_ago, const Timestamp &now, std::deque<Timestamp> *events);
686
687 // Qualify the conditions under which the most recent disconnect occurred.
688 // Make note ot the fact that there was a problem connecting / staying
689 // connected if the disconnection did not occur as a clear result of user
690 // action.
Darin Petkov385b9bc2012-12-03 15:25:05 +0100691 void NoteDisconnectEvent();
692
Paul Stewart22aa71b2011-09-16 12:15:11 -0700693 // Utility function that returns true if a is different from b. When they
694 // are, "decision" is populated with the boolean value of "a > b".
695 static bool DecideBetween(int a, int b, bool *decision);
696
mukesh agrawal43970a22013-02-15 16:00:07 -0800697 // Linearize security parameters (crypto algorithm, key rotation, endpoint
698 // authentication) for comparison.
699 uint16 SecurityLevel();
700
Paul Stewartac4ac002011-08-26 12:04:26 -0700701 ConnectState state_;
Darin Petkovc8d91e52013-01-21 11:43:47 +0100702 ConnectState previous_state_;
Paul Stewartac4ac002011-08-26 12:04:26 -0700703 ConnectFailure failure_;
704 bool auto_connect_;
705 std::string check_portal_;
706 bool connectable_;
707 std::string error_;
Darin Petkovaba89322013-03-11 14:48:22 +0100708 std::string error_details_;
mukesh agrawaladb68482012-01-17 16:31:51 -0800709 bool explicitly_disconnected_;
Paul Stewartac4ac002011-08-26 12:04:26 -0700710 bool favorite_;
711 int32 priority_;
mukesh agrawal43970a22013-02-15 16:00:07 -0800712 uint8 crypto_algorithm_;
713 bool key_rotation_;
714 bool endpoint_auth_;
715
Darin Petkovd78ee7e2012-01-12 11:21:10 +0100716 uint8 strength_;
Paul Stewartac4ac002011-08-26 12:04:26 -0700717 std::string proxy_config_;
Paul Stewart987e71e2011-12-05 09:45:06 -0800718 std::string ui_data_;
Paul Stewart4c561612012-03-21 12:49:01 -0700719 std::string guid_;
Paul Stewartac4ac002011-08-26 12:04:26 -0700720 bool save_credentials_;
721 EapCredentials eap_; // Only saved if |save_credentials_| is true.
Gaurav Shah435de2c2011-11-17 19:01:07 -0800722 Technology::Identifier technology_;
mukesh agrawal568b5c62012-02-28 14:44:47 -0800723 // The time of the most recent failure. Value is 0 if the service is
724 // not currently failed.
725 time_t failed_time_;
mukesh agrawalcf24a242012-05-21 16:46:11 -0700726 // Whether or not this service has ever reached kStateConnected.
727 bool has_ever_connected_;
Paul Stewartac4ac002011-08-26 12:04:26 -0700728
Darin Petkov0c65bdd2012-12-05 13:42:41 +0100729 std::deque<Timestamp> disconnects_; // Connection drops.
730 std::deque<Timestamp> misconnects_; // Failures to connect.
Darin Petkov385b9bc2012-12-03 15:25:05 +0100731
Christopher Wiley0801d192012-09-24 11:57:15 -0700732 base::CancelableClosure reenable_auto_connect_task_;
733 uint64 auto_connect_cooldown_milliseconds_ ;
734
Paul Stewartac4ac002011-08-26 12:04:26 -0700735 ProfileRefPtr profile_;
736 PropertyStore store_;
Paul Stewartcb59fed2012-03-21 21:14:46 -0700737 std::set<std::string> parameters_ignored_for_configure_;
Paul Stewartac4ac002011-08-26 12:04:26 -0700738
739 EventDispatcher *dispatcher_;
mukesh agrawal51a7e932011-07-27 16:18:26 -0700740 static unsigned int serial_number_;
mukesh agrawald835b202011-10-07 15:26:47 -0700741 std::string unique_name_; // MUST be unique amongst service instances
Darin Petkov457728b2013-01-09 09:49:08 +0100742
743 // Service's friendly name is presented through the UI. By default it's the
744 // same as |unique_name_| but normally Service subclasses override
745 // it. WARNING: Don't log the friendly name at the default logging level due
746 // to PII concerns.
747 std::string friendly_name_;
748
Paul Stewartba41b992011-05-26 07:02:46 -0700749 scoped_ptr<ServiceAdaptorInterface> adaptor_;
Paul Stewartbe5f5b32011-12-07 17:11:11 -0800750 scoped_ptr<HTTPProxy> http_proxy_;
Paul Stewartc1dec4d2011-12-08 15:25:28 -0800751 ConnectionRefPtr connection_;
Paul Stewart1062d9d2012-04-27 10:42:27 -0700752 StaticIPParameters static_ip_parameters_;
Thieu Le3426c8f2012-01-11 17:35:11 -0800753 Metrics *metrics_;
Chris Masone6791a432011-07-12 13:23:19 -0700754 Manager *manager_;
Darin Petkov5eb05422012-05-11 15:45:25 +0200755 scoped_ptr<Sockets> sockets_;
Christopher Wiley0801d192012-09-24 11:57:15 -0700756 base::WeakPtrFactory<Service> weak_ptr_factory_;
Darin Petkov385b9bc2012-12-03 15:25:05 +0100757 Time *time_;
758 DiagnosticsReporter *diagnostics_reporter_;
Chris Masone3bd3c8c2011-06-13 08:20:26 -0700759
mukesh agrawalb54601c2011-06-07 17:39:22 -0700760 DISALLOW_COPY_AND_ASSIGN(Service);
Paul Stewart75897df2011-04-27 09:05:53 -0700761};
762
763} // namespace shill
764
Ben Chan19f83972012-10-03 23:25:56 -0700765#endif // SHILL_SERVICE_H_