1c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// 2c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// Copyright (C) 2013 The Android Open Source Project 3c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// 4c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// Licensed under the Apache License, Version 2.0 (the "License"); 5c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// you may not use this file except in compliance with the License. 6c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// You may obtain a copy of the License at 7c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// 8c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// http://www.apache.org/licenses/LICENSE-2.0 9c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// 10c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// Unless required by applicable law or agreed to in writing, software 11c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// distributed under the License is distributed on an "AS IS" BASIS, 12c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// See the License for the specific language governing permissions and 14c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// limitations under the License. 15c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// 1675897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart 1719f83971a35d7f2c7b08aae6eb0abdc8e52ba057Ben Chan#ifndef SHILL_SERVICE_H_ 1819f83971a35d7f2c7b08aae6eb0abdc8e52ba057Ben Chan#define SHILL_SERVICE_H_ 1975897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart 20568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal#include <time.h> 21568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal 228fe2c7eea92541b5282929361a19ad519e0608a9Chris Masone#include <map> 23cd47732488cd101eaf0d3558dde5a7d4e4fc260bBen Chan#include <memory> 24cb59fed9326dc91c93b817dcd9eaca363d8313fePaul Stewart#include <set> 25385b9bccbcdb5395e1fc8903a0f14cb6016b01c3Darin Petkov#include <string> 268fe2c7eea92541b5282929361a19ad519e0608a9Chris Masone#include <vector> 279be4a9d1e87d64f850f15061123b2a4334477fa2Chris Masone 280801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley#include <base/cancelable_callback.h> 299be4a9d1e87d64f850f15061123b2a4334477fa2Chris Masone#include <base/memory/ref_counted.h> 300801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley#include <base/memory/weak_ptr.h> 31ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov#include <gtest/gtest_prod.h> // for FRIEND_TEST 3275897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart 333bd3c8c33917221d1074f1aa19272e45c0ce2793Chris Masone#include "shill/accessor_interface.h" 34a41ab517725d036b63420f8445550246f8f50b99Alex Vakulenko#include "shill/adaptor_interfaces.h" 359a24553461df7036755060423f90804011612249Eric Shienbrood#include "shill/callbacks.h" 3615d5431798155cc83a3fcb8abe0d1a2d5128f7b6Rebecca Silberstein#include "shill/dhcp_properties.h" 3707dfabcb55d74e254f4722926a997959dc4c6393Samuel Tan#include "shill/net/event_history.h" 388d6b59704591ba9fad57751858835dc332dbdd37Peter Qiu#include "shill/net/shill_time.h" 39b925cc8f481d21fddd9569fc68861f6e5b6e3eaeChris Masone#include "shill/property_store.h" 407aa5f90848b530999d8b6788ecb40aa30871c7aeChris Masone#include "shill/refptr_types.h" 411062d9deedace1cf4b3b374c5d40c53047fd6778Paul Stewart#include "shill/static_ip_parameters.h" 4222aa71b334c716f20999c2e08e5b797207b0afaePaul Stewart#include "shill/technology.h" 43c1e50412f45518e23d51ba8bb8694c366943d945Chris Masone 44b84ba34aec59d083980d840fb845a3e2bea893cbThieu Lenamespace chromeos_metrics { 45b84ba34aec59d083980d840fb845a3e2bea893cbThieu Leclass Timer; 46b84ba34aec59d083980d840fb845a3e2bea893cbThieu Le} 47b84ba34aec59d083980d840fb845a3e2bea893cbThieu Le 4875897df1154ac38b7a4512a687241ad6a197ee40Paul Stewartnamespace shill { 4975897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart 509be4a9d1e87d64f850f15061123b2a4334477fa2Chris Masoneclass ControlInterface; 5115d5431798155cc83a3fcb8abe0d1a2d5128f7b6Rebecca Silbersteinclass DhcpProperties; 52385b9bccbcdb5395e1fc8903a0f14cb6016b01c3Darin Petkovclass DiagnosticsReporter; 5375897df1154ac38b7a4512a687241ad6a197ee40Paul Stewartclass Endpoint; 548fe2c7eea92541b5282929361a19ad519e0608a9Chris Masoneclass Error; 559be4a9d1e87d64f850f15061123b2a4334477fa2Chris Masoneclass EventDispatcher; 56be5f5b341ba4b85d45ffb6c0430ef5ab84c7b961Paul Stewartclass HTTPProxy; 577a4e4008dc09effe39c94a5f9575644a79ee1388mukesh agrawalclass KeyValueStore; 586791a43add38926966bd420e89541717fb2cb2b5Chris Masoneclass Manager; 5948e6d6d0ec0f90d9b2206f60c1ff2a825c5ce9c1Thieu Leclass Metrics; 60bebf1b8bce52b88c2cc2d93200b9405f9c19cf21mukesh agrawalclass MockManager; 619be4a9d1e87d64f850f15061123b2a4334477fa2Chris Masoneclass ServiceAdaptorInterface; 62cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawalclass ServiceMockAdaptor; 6345170bcb5e3b5e076e9307c695faf25faac395c8Paul Stewartclass ServicePropertyChangeNotifier; 645eb0542cb67358d9030367498a4ad741fc42af4fDarin Petkovclass Sockets; 65ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkovclass StoreInterface; 6675897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart 671a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) 681a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiuclass EapCredentials; 691a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#endif // DISABLE_WIFI || DISABLE_WIRED_8021X 701a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu 717aa5f90848b530999d8b6788ecb40aa30871c7aeChris Masone// A Service is a uniquely named entity, which the system can 727aa5f90848b530999d8b6788ecb40aa30871c7aeChris Masone// connect in order to begin sending and receiving network traffic. 737aa5f90848b530999d8b6788ecb40aa30871c7aeChris Masone// All Services are bound to an Entry, which represents the persistable 747aa5f90848b530999d8b6788ecb40aa30871c7aeChris Masone// state of the Service. If the Entry is populated at the time of Service 757aa5f90848b530999d8b6788ecb40aa30871c7aeChris Masone// creation, that information is used to prime the Service. If not, the Entry 767aa5f90848b530999d8b6788ecb40aa30871c7aeChris Masone// becomes populated over time. 7727c4aa55b33d3a3836cf70c8f7094bce1c5ead8cChris Masoneclass Service : public base::RefCounted<Service> { 7875897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart public: 79ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov static const char kCheckPortalAuto[]; 80ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov static const char kCheckPortalFalse[]; 81ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov static const char kCheckPortalTrue[]; 82ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov 83aba893217c9cf1dd0d39c4dee89a23d3b1a3f4c1Darin Petkov static const char kErrorDetailsNone[]; 84aba893217c9cf1dd0d39c4dee89a23d3b1a3f4c1Darin Petkov 850756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart // TODO(pstew): Storage constants shouldn't need to be public 86ee6b3d7f9d49fa52072a352fbb59f06127b1ba4cPaul Stewart // crbug.com/208736 870756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart static const char kStorageAutoConnect[]; 880756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart static const char kStorageCheckPortal[]; 89a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu static const char kStorageDNSAutoFallback[]; 900756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart static const char kStorageError[]; 910756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart static const char kStorageFavorite[]; 920756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart static const char kStorageGUID[]; 93cf24a2465a3e7b5a11fa97be282f0af47aa3ef6emukesh agrawal static const char kStorageHasEverConnected[]; 940756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart static const char kStorageName[]; 950756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart static const char kStoragePriority[]; 96d9c7cfc904504447c3478f42c1cffc768c772020Paul Stewart static const char kStoragePriorityWithinTechnology[]; 970756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart static const char kStorageProxyConfig[]; 980756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart static const char kStorageSaveCredentials[]; 990756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart static const char kStorageType[]; 1000756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart static const char kStorageUIData[]; 1019d58193108f55edf0f06cd54f44464da633cb8aaPeter Qiu static const char kStorageConnectionId[]; 102d49760e19d137f43df29e00265259d395b07994cPeter Qiu static const char kStorageLinkMonitorDisabled[]; 1033fee7e38845bc9512a84c311c7bfcc21e19cda19Paul Stewart static const char kStorageManagedCredentials[]; 1040756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart 1057fab89734d88724a288e96a9996b15548c5294c7Ben Chan static const uint8_t kStrengthMax; 1067fab89734d88724a288e96a9996b15548c5294c7Ben Chan static const uint8_t kStrengthMin; 1078f3f775cc511815300fec4e67cf30a329c975e56mukesh agrawal 10875897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart enum ConnectFailure { 10903dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart kFailureUnknown, 1101c049c794175356e5b6c2b6bbb5ef4a12fbfe9a3Darin Petkov kFailureAAA, 111f2d609103916861ea8a9377ef93a72cc998bdf80Paul Stewart kFailureActivation, 112f2d609103916861ea8a9377ef93a72cc998bdf80Paul Stewart kFailureBadPassphrase, 113f2d609103916861ea8a9377ef93a72cc998bdf80Paul Stewart kFailureBadWEPKey, 114f2d609103916861ea8a9377ef93a72cc998bdf80Paul Stewart kFailureConnect, 1151c049c794175356e5b6c2b6bbb5ef4a12fbfe9a3Darin Petkov kFailureDHCP, 116f2d609103916861ea8a9377ef93a72cc998bdf80Paul Stewart kFailureDNSLookup, 1171c049c794175356e5b6c2b6bbb5ef4a12fbfe9a3Darin Petkov kFailureEAPAuthentication, 1181c049c794175356e5b6c2b6bbb5ef4a12fbfe9a3Darin Petkov kFailureEAPLocalTLS, 1191c049c794175356e5b6c2b6bbb5ef4a12fbfe9a3Darin Petkov kFailureEAPRemoteTLS, 120f2d609103916861ea8a9377ef93a72cc998bdf80Paul Stewart kFailureHTTPGet, 12185d5317bed668c1fb0e4225de614c7b386e3de25Darin Petkov kFailureIPSecCertAuth, 12285d5317bed668c1fb0e4225de614c7b386e3de25Darin Petkov kFailureIPSecPSKAuth, 1231c049c794175356e5b6c2b6bbb5ef4a12fbfe9a3Darin Petkov kFailureInternal, 1241c049c794175356e5b6c2b6bbb5ef4a12fbfe9a3Darin Petkov kFailureNeedEVDO, 1251c049c794175356e5b6c2b6bbb5ef4a12fbfe9a3Darin Petkov kFailureNeedHomeNetwork, 1261c049c794175356e5b6c2b6bbb5ef4a12fbfe9a3Darin Petkov kFailureOTASP, 1271c049c794175356e5b6c2b6bbb5ef4a12fbfe9a3Darin Petkov kFailureOutOfRange, 128f2d609103916861ea8a9377ef93a72cc998bdf80Paul Stewart kFailurePPPAuth, 1291c049c794175356e5b6c2b6bbb5ef4a12fbfe9a3Darin Petkov kFailurePinMissing, 13048e6d6d0ec0f90d9b2206f60c1ff2a825c5ce9c1Thieu Le kFailureMax 13175897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart }; 1329be4a9d1e87d64f850f15061123b2a4334477fa2Chris Masone enum ConnectState { 13303dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart kStateUnknown, 13403dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart kStateIdle, 13503dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart kStateAssociating, 13603dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart kStateConfiguring, 13703dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart kStateConnected, 13848e6d6d0ec0f90d9b2206f60c1ff2a825c5ce9c1Thieu Le kStatePortal, 139c6d6c72920d32299e8ae1cb3a7dbbb13a0741b13Gaurav Shah kStateFailure, 140c6d6c72920d32299e8ae1cb3a7dbbb13a0741b13Gaurav Shah kStateOnline 1419be4a9d1e87d64f850f15061123b2a4334477fa2Chris Masone }; 14243970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal enum CryptoAlgorithm { 14343970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal kCryptoNone, 14443970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal kCryptoRc4, 14543970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal kCryptoAes 14643970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal }; 1477b5cee92f29791ebd3867b858fc1d301b39d26bdPaul Stewart 1485777690fb2291a468715eabfcc6f7aac6f1678cdRebecca Silberstein enum UpdateCredentialsReason{ 1495777690fb2291a468715eabfcc6f7aac6f1678cdRebecca Silberstein kReasonCredentialsLoaded, 1505777690fb2291a468715eabfcc6f7aac6f1678cdRebecca Silberstein kReasonPropertyUpdate 1515777690fb2291a468715eabfcc6f7aac6f1678cdRebecca Silberstein }; 1525777690fb2291a468715eabfcc6f7aac6f1678cdRebecca Silberstein 153ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart static const int kPriorityNone; 154ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart 1559be4a9d1e87d64f850f15061123b2a4334477fa2Chris Masone // A constructor for the Service object 1561a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart Service(ControlInterface* control_interface, 1571a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart EventDispatcher* dispatcher, 1581a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart Metrics* metrics, 1591a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart Manager* manager, 160435de2cd55a95836381b53acbce8cbbad98ec04dGaurav Shah Technology::Identifier technology); 161ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov 1628a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal // AutoConnect MAY choose to ignore the connection request in some 1638a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal // cases. For example, if the corresponding Device only supports one 1648a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal // concurrent connection, and another Service is already connected 1658a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal // or connecting. 1668a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal // 1678a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal // AutoConnect MAY issue RPCs immediately. So AutoConnect MUST NOT 1688a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal // be called from a D-Bus signal handler context. 1698a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal virtual void AutoConnect(); 170dc7b8447aa220fae51b73fd8610cbfed14ed57fcmukesh agrawal // Queue up a connection attempt. Derived classes SHOULD call the 171dc7b8447aa220fae51b73fd8610cbfed14ed57fcmukesh agrawal // base class implementation before beginning a connect. The base 172dc7b8447aa220fae51b73fd8610cbfed14ed57fcmukesh agrawal // class will log the connection attempt, and update base-class 173dc7b8447aa220fae51b73fd8610cbfed14ed57fcmukesh agrawal // state. 1741a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual void Connect(Error* error, const char* reason); 175abd3b50b0c3b6cde124892134091328d2b6dd5e3Christopher Wiley // Disconnect this service. Override this method to add your service specific 176abd3b50b0c3b6cde124892134091328d2b6dd5e3Christopher Wiley // disconnect logic, but call the super class's Disconnect() first. 1771a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual void Disconnect(Error* error, const char* reason); 178abd3b50b0c3b6cde124892134091328d2b6dd5e3Christopher Wiley // Disconnects this service via Disconnect(). Marks the service as having 179abd3b50b0c3b6cde124892134091328d2b6dd5e3Christopher Wiley // failed with |failure|. Do not override this method. 1800d06119be3224788ba1aa65ed24bc8e46b56b949Samuel Tan virtual void DisconnectWithFailure(ConnectFailure failure, 1811a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart Error* error, 1821a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const char* reason); 183abd3b50b0c3b6cde124892134091328d2b6dd5e3Christopher Wiley // Disconnects this service via Disconnect(). The service will not be eligible 184abd3b50b0c3b6cde124892134091328d2b6dd5e3Christopher Wiley // for auto-connect until a subsequent call to Connect, or Load. Do not 185abd3b50b0c3b6cde124892134091328d2b6dd5e3Christopher Wiley // override this method. 1861a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual void UserInitiatedDisconnect(Error* error); 187dc4e099103a56f0427ed0969fea2c46c88ab2e9ePeter Qiu // Connect to this service via Connect(). This function indicates that the 188dc4e099103a56f0427ed0969fea2c46c88ab2e9ePeter Qiu // connection attempt is user-initiated. 1891a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual void UserInitiatedConnect(Error* error); 190a82b7111f2b0515a8d79e6e8034836a5d1342468Chris Masone 1915de44ab664b7cbb7619e31431e346ec8309548a6Eric Shienbrood // The default implementation returns the error kInvalidArguments. 1921a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual void ActivateCellularModem(const std::string& carrier, 1931a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart Error* error, 1941a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const ResultCallback& callback); 1955d924544cf3bd1da5dff3204ca645f52427a6ff8Ben Chan // The default implementation returns the error kNotSupported. 1961a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual void CompleteCellularActivation(Error* error); 197c408e69059dc709408c1a51f4b757424d08b15f5Darin Petkov 1981a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual bool IsActive(Error* error); 19903dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart 2007fb0938c8485118e0b6684d5a696e58be7cf21c9Paul Stewart // Returns whether services of this type should be auto-connect by default. 2017fb0938c8485118e0b6684d5a696e58be7cf21c9Paul Stewart virtual bool IsAutoConnectByDefault() const { return false; } 2027fb0938c8485118e0b6684d5a696e58be7cf21c9Paul Stewart 20303dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart virtual ConnectState state() const { return state_; } 20403dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart // Updates the state of the Service and alerts the manager. Also 20503dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart // clears |failure_| if the new state isn't a failure. 20603dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart virtual void SetState(ConnectState state); 20758f0b6dbd71f52c3abdac91aed44024a35bc4898Darin Petkov std::string GetStateString() const; 20803dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart 2099b83c897f8e197ff7846e4fe7cec1d83d54e7b7bPeter Qiu // Set portal detection failure phase and status (reason). This function 2109b83c897f8e197ff7846e4fe7cec1d83d54e7b7bPeter Qiu // is called when portal detection failed for the Service. 2111a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual void SetPortalDetectionFailure(const std::string& phase, 2121a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& status); 2139b83c897f8e197ff7846e4fe7cec1d83d54e7b7bPeter Qiu 21422aa71b334c716f20999c2e08e5b797207b0afaePaul Stewart // State utility functions 215c8d91e54873d3490e01d9aa5dac83e7bd9192ff0Darin Petkov static bool IsConnectedState(ConnectState state); 216c8d91e54873d3490e01d9aa5dac83e7bd9192ff0Darin Petkov static bool IsConnectingState(ConnectState state); 217c8d91e54873d3490e01d9aa5dac83e7bd9192ff0Darin Petkov 218c8d91e54873d3490e01d9aa5dac83e7bd9192ff0Darin Petkov virtual bool IsConnected() const; 219c8d91e54873d3490e01d9aa5dac83e7bd9192ff0Darin Petkov virtual bool IsConnecting() const; 2208a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal virtual bool IsFailed() const { 221568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal // We sometimes lie about the failure state, to keep Chrome happy 222568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal // (see comment in WiFi::HandleDisconnect). Hence, we check both 223568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal // state and |failed_time_|. 224568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal return state() == kStateFailure || failed_time_ > 0; 2258a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal } 226df3c0a897bc74cb3a9800332b8359a364ca2f753Paul Stewart 2274943822214f823c2437aa32b0376414b3e60388dPeter Qiu virtual bool IsInFailState() const { 2284943822214f823c2437aa32b0376414b3e60388dPeter Qiu return state() == kStateFailure; 2294943822214f823c2437aa32b0376414b3e60388dPeter Qiu } 2304943822214f823c2437aa32b0376414b3e60388dPeter Qiu 231700de6400c18f8cba77821f8cd2a1935b96999a6Peter Qiu virtual bool IsOnline() const { 232700de6400c18f8cba77821f8cd2a1935b96999a6Peter Qiu return state() == kStateOnline; 233700de6400c18f8cba77821f8cd2a1935b96999a6Peter Qiu } 234700de6400c18f8cba77821f8cd2a1935b96999a6Peter Qiu 235df3c0a897bc74cb3a9800332b8359a364ca2f753Paul Stewart // Returns true if the connection for |this| depends on service |b|. 2361a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual bool IsDependentOn(const ServiceRefPtr& b) const; 237df3c0a897bc74cb3a9800332b8359a364ca2f753Paul Stewart 238a121c44fb8e620b572c2f8d260406729d10d339aPaul Stewart virtual bool IsPortalled() const { 239a121c44fb8e620b572c2f8d260406729d10d339aPaul Stewart return state() == kStatePortal; 240a121c44fb8e620b572c2f8d260406729d10d339aPaul Stewart } 24122aa71b334c716f20999c2e08e5b797207b0afaePaul Stewart 242a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu // Return true if service is allowed to automatically switch to fallback 243a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu // DNS server. 244a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu virtual bool is_dns_auto_fallback_allowed() const { 245a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu return is_dns_auto_fallback_allowed_; 246a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu } 247a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu 248d49760e19d137f43df29e00265259d395b07994cPeter Qiu virtual bool link_monitor_disabled() const { return link_monitor_disabled_; } 249d49760e19d137f43df29e00265259d395b07994cPeter Qiu 25003dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart virtual ConnectFailure failure() const { return failure_; } 251d7c09a5f2d7dc6f610e3162be392e349e9ceed8dPaul Stewart // Sets the |previous_error_| property based on the current |failure_|, and 252d7c09a5f2d7dc6f610e3162be392e349e9ceed8dPaul Stewart // sets a serial number for this failure. 253d7c09a5f2d7dc6f610e3162be392e349e9ceed8dPaul Stewart virtual void SaveFailure(); 254568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal // Records the failure mode and time. Sets the Service state to "Failure". 25503dba0bccc3a39cded5083212e56713a6d349e01Paul Stewart virtual void SetFailure(ConnectFailure failure); 256568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal // Records the failure mode and time. Sets the Service state to "Idle". 257568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal // Avoids showing a failure mole in the UI. 258568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal virtual void SetFailureSilent(ConnectFailure failure); 2593bd3c8c33917221d1074f1aa19272e45c0ce2793Chris Masone 260ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov // Returns a string that is guaranteed to uniquely identify this Service 261ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov // instance. 2621a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& unique_name() const { return unique_name_; } 263afa6fc4d31e884af8710deb14798c69b9c9a898eDarin Petkov 2646791a43add38926966bd420e89541717fb2cb2b5Chris Masone virtual std::string GetRpcIdentifier() const; 2653c3f6a1dcc0533545f7efb5ffed5a3edc089f240Chris Masone 266ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov // Returns the unique persistent storage identifier for the service. 2676515aabcd1fbbb9ff2090c9675c17eeef64e7474Chris Masone virtual std::string GetStorageIdentifier() const = 0; 268ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov 269e7de2942df36080268c1f296b40e28480479187cPaul Stewart // Returns the identifier within |storage| from which configuration for 270e7de2942df36080268c1f296b40e28480479187cPaul Stewart // this service can be loaded. Returns an empty string if no entry in 271e7de2942df36080268c1f296b40e28480479187cPaul Stewart // |storage| can be used. 272e7de2942df36080268c1f296b40e28480479187cPaul Stewart virtual std::string GetLoadableStorageIdentifier( 2731a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const StoreInterface& storage) const; 274e7de2942df36080268c1f296b40e28480479187cPaul Stewart 275bba6a5b87cb21424770228cd73e10574a2151568Paul Stewart // Returns whether the service configuration can be loaded from |storage|. 2761a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual bool IsLoadableFrom(const StoreInterface& storage) const; 277bba6a5b87cb21424770228cd73e10574a2151568Paul Stewart 27881426131e75bf214ab49162127fec60490d979fcPaul Stewart // Returns true if the service uses 802.1x for key management. 279be9abfd46f85280d2139d635190f72b792eb3efaPaul Stewart virtual bool Is8021x() const { return false; } 28081426131e75bf214ab49162127fec60490d979fcPaul Stewart 281ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov // Loads the service from persistent |storage|. Returns true on success. 2821a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual bool Load(StoreInterface* storage); 283ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov 284a41e38d57e4fa37bd2c8de6447890b4e1951acb7Paul Stewart // Indicate to service that it is no longer persisted to storage. It 28565512e10f0534c390b2ef027cc64f660658db6c0Paul Stewart // should purge any stored profile state (e.g., credentials). Returns 28665512e10f0534c390b2ef027cc64f660658db6c0Paul Stewart // true to indicate that this service should also be unregistered from 28765512e10f0534c390b2ef027cc64f660658db6c0Paul Stewart // the manager, false otherwise. 28865512e10f0534c390b2ef027cc64f660658db6c0Paul Stewart virtual bool Unload(); 289a41e38d57e4fa37bd2c8de6447890b4e1951acb7Paul Stewart 2900e1cdeae24dd678a5fe27c840802582c0ca45ec0Albert Chaulk // Attempt to remove the service. On failure, no changes in state will occur. 2911a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual void Remove(Error* error); 2920e1cdeae24dd678a5fe27c840802582c0ca45ec0Albert Chaulk 293ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov // Saves the service to persistent |storage|. Returns true on success. 2941a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual bool Save(StoreInterface* storage); 295ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov 296cb59fed9326dc91c93b817dcd9eaca363d8313fePaul Stewart // Applies all the properties in |args| to this service object's mutable 297cb59fed9326dc91c93b817dcd9eaca363d8313fePaul Stewart // store, except for those in parameters_ignored_for_configure_. 298cb59fed9326dc91c93b817dcd9eaca363d8313fePaul Stewart // Returns an error in |error| if one or more parameter set attempts 299cb59fed9326dc91c93b817dcd9eaca363d8313fePaul Stewart // fails, but will only return the first error. 3001a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual void Configure(const KeyValueStore& args, Error* error); 301cb59fed9326dc91c93b817dcd9eaca363d8313fePaul Stewart 3027a20aa492230e9e969c8853ad684be0c5b224479Paul Stewart // Iterate over all the properties in |args| and test for an identical 3037a20aa492230e9e969c8853ad684be0c5b224479Paul Stewart // value in this service object's store. Returns false if one or more 3047a20aa492230e9e969c8853ad684be0c5b224479Paul Stewart // keys in |args| do not exist or have different values, true otherwise. 3051a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual bool DoPropertiesMatch(const KeyValueStore& args) const; 3067a20aa492230e9e969c8853ad684be0c5b224479Paul Stewart 307d215af6f72d012f43057c34f17a12506baa21e66Paul Stewart // Returns whether portal detection is explicitly disabled on this service 308d215af6f72d012f43057c34f17a12506baa21e66Paul Stewart // via a property set on it. 309d215af6f72d012f43057c34f17a12506baa21e66Paul Stewart virtual bool IsPortalDetectionDisabled() const; 310d215af6f72d012f43057c34f17a12506baa21e66Paul Stewart 311d215af6f72d012f43057c34f17a12506baa21e66Paul Stewart // Returns whether portal detection is set to follow the default setting 312d215af6f72d012f43057c34f17a12506baa21e66Paul Stewart // of this service's technology via a property set on it. 313d215af6f72d012f43057c34f17a12506baa21e66Paul Stewart virtual bool IsPortalDetectionAuto() const; 314d215af6f72d012f43057c34f17a12506baa21e66Paul Stewart 31510ccbb3c6bc4f4246105743c8508fc9ce8759c17Paul Stewart // Returns true if the service is persisted to a non-ephemeral profile. 31610ccbb3c6bc4f4246105743c8508fc9ce8759c17Paul Stewart virtual bool IsRemembered() const; 31710ccbb3c6bc4f4246105743c8508fc9ce8759c17Paul Stewart 318a41e38d57e4fa37bd2c8de6447890b4e1951acb7Paul Stewart // Returns true if the service RPC identifier should be part of the 319a41e38d57e4fa37bd2c8de6447890b4e1951acb7Paul Stewart // manager's advertised services list, false otherwise. 320a41e38d57e4fa37bd2c8de6447890b4e1951acb7Paul Stewart virtual bool IsVisible() const { return true; } 321a41e38d57e4fa37bd2c8de6447890b4e1951acb7Paul Stewart 32220088d860631a67c151a12783fbbee63c708792fPaul Stewart // Returns true if there is a proxy configuration set on this service. 32320088d860631a67c151a12783fbbee63c708792fPaul Stewart virtual bool HasProxyConfig() const { return !proxy_config_.empty(); } 32420088d860631a67c151a12783fbbee63c708792fPaul Stewart 325a47c3c62552d33aa1f745097a5713c4f6f4cc325Paul Stewart // Returns whether this service has had recent connection issues. 326a47c3c62552d33aa1f745097a5713c4f6f4cc325Paul Stewart virtual bool HasRecentConnectionIssues(); 327a47c3c62552d33aa1f745097a5713c4f6f4cc325Paul Stewart 3282da34c038933eeac36a85550ff54e09611a1d828Paul Stewart // If the AutoConnect property has not already been marked as saved, set 3292da34c038933eeac36a85550ff54e09611a1d828Paul Stewart // its value to true and mark it saved. 3302da34c038933eeac36a85550ff54e09611a1d828Paul Stewart virtual void EnableAndRetainAutoConnect(); 33100917ceafbc28599391bfcdd5837faf6d63fec32mukesh agrawal 3325eb0542cb67358d9030367498a4ad741fc42af4fDarin Petkov // Set the connection for this service. If the connection is non-NULL, create 3335eb0542cb67358d9030367498a4ad741fc42af4fDarin Petkov // an HTTP Proxy that will utilize this service's connection to serve 3345eb0542cb67358d9030367498a4ad741fc42af4fDarin Petkov // requests. 3351a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual void SetConnection(const ConnectionRefPtr& connection); 3361a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual const ConnectionRefPtr& connection() const { return connection_; } 337be5f5b341ba4b85d45ffb6c0430ef5ab84c7b961Paul Stewart 338a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu // Emit service's IP config change event to chrome. 339a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu virtual void NotifyIPConfigChanges(); 340a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu 3411a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) 34210109f2c0dd33784d50c27f300f0780986d81effGaurav Shah // Examines the EAP credentials for the service and returns true if a 34310109f2c0dd33784d50c27f300f0780986d81effGaurav Shah // connection attempt can be made. 3449413bcc8c3576eeab8f232253264dce4347bbb0cPaul Stewart virtual bool Is8021xConnectable() const; 34510109f2c0dd33784d50c27f300f0780986d81effGaurav Shah 346bc6e7390c4401e171ede4dc83b79b316f3e71100Paul Stewart // Add an EAP certification id |name| at position |depth| in the stack. 347bc6e7390c4401e171ede4dc83b79b316f3e71100Paul Stewart // Returns true if entry was added, false otherwise. 3481a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual bool AddEAPCertification(const std::string& name, size_t depth); 349bc6e7390c4401e171ede4dc83b79b316f3e71100Paul Stewart // Clear all EAP certification elements. 3509413bcc8c3576eeab8f232253264dce4347bbb0cPaul Stewart virtual void ClearEAPCertification(); 3511a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#endif // DISABLE_WIFI || DISABLE_WIRED_8021X 352bc6e7390c4401e171ede4dc83b79b316f3e71100Paul Stewart 353316acef85ecfc128bf06cc2d2699f21880aa5a7ePaul Stewart // Returns true if this service contains a IP address in its static IP 354316acef85ecfc128bf06cc2d2699f21880aa5a7ePaul Stewart // parameters, false otherwise. 355316acef85ecfc128bf06cc2d2699f21880aa5a7ePaul Stewart virtual bool HasStaticIPAddress() const; 356316acef85ecfc128bf06cc2d2699f21880aa5a7ePaul Stewart 357d01b5cc35185e022b66e08832e12fe7f59b5aa24Garret Kelly // Returns true if this service contains nameservers in its static IP 358d01b5cc35185e022b66e08832e12fe7f59b5aa24Garret Kelly // parameters, false otherwise. 359d01b5cc35185e022b66e08832e12fe7f59b5aa24Garret Kelly virtual bool HasStaticNameServers() const; 360d01b5cc35185e022b66e08832e12fe7f59b5aa24Garret Kelly 36148e6d6d0ec0f90d9b2206f60c1ff2a825c5ce9c1Thieu Le // The inherited class that needs to send metrics after the service has 362b84ba34aec59d083980d840fb845a3e2bea893cbThieu Le // transitioned to the ready state should override this method. 363b84ba34aec59d083980d840fb845a3e2bea893cbThieu Le // |time_resume_to_ready_milliseconds| holds the elapsed time from when 364b84ba34aec59d083980d840fb845a3e2bea893cbThieu Le // the system was resumed until when the service transitioned to the 365b84ba34aec59d083980d840fb845a3e2bea893cbThieu Le // connected state. This value is non-zero for the first service transition 366b84ba34aec59d083980d840fb845a3e2bea893cbThieu Le // to the connected state after a resume. 367b84ba34aec59d083980d840fb845a3e2bea893cbThieu Le virtual void SendPostReadyStateMetrics( 3687fab89734d88724a288e96a9996b15548c5294c7Ben Chan int64_t /*time_resume_to_ready_milliseconds*/) const {} 36948e6d6d0ec0f90d9b2206f60c1ff2a825c5ce9c1Thieu Le 370afa6fc4d31e884af8710deb14798c69b9c9a898eDarin Petkov bool auto_connect() const { return auto_connect_; } 371cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawal void SetAutoConnect(bool connect); 37275897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart 373435de2cd55a95836381b53acbce8cbbad98ec04dGaurav Shah bool connectable() const { return connectable_; } 374cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawal // Sets the connectable property of the service, and broadcast the 375cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawal // new value. Does not update the manager. 376cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawal // TODO(petkov): Remove this method in favor of SetConnectableFull. 377b2ba39fb7b19ce331f6aadb3e6e9e61d70a2f0a1Darin Petkov void SetConnectable(bool connectable); 378cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawal // Sets the connectable property of the service, broadcasts the new 379cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawal // value, and alerts the manager if necessary. 380cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawal void SetConnectableFull(bool connectable); 381435de2cd55a95836381b53acbce8cbbad98ec04dGaurav Shah 38267370f6ebe6757f55249f6e87f4a96922d0c4518Thieu Le virtual bool explicitly_disconnected() const { 38367370f6ebe6757f55249f6e87f4a96922d0c4518Thieu Le return explicitly_disconnected_; 38467370f6ebe6757f55249f6e87f4a96922d0c4518Thieu Le } 38567370f6ebe6757f55249f6e87f4a96922d0c4518Thieu Le 3868e60d61b13fedf9cb75f1d4f1762605375837d98Peter Qiu // Return RPC identifier for device that's internal to this service, which is 3878e60d61b13fedf9cb75f1d4f1762605375837d98Peter Qiu // not registered with the manager. 3888e60d61b13fedf9cb75f1d4f1762605375837d98Peter Qiu virtual std::string GetInnerDeviceRpcIdentifier() const { return ""; } 3898e60d61b13fedf9cb75f1d4f1762605375837d98Peter Qiu 3902da34c038933eeac36a85550ff54e09611a1d828Paul Stewart bool retain_auto_connect() const { return retain_auto_connect_; } 3912da34c038933eeac36a85550ff54e09611a1d828Paul Stewart // Setter is deliberately omitted; use EnableAndRetainAutoConnect. 39222aa71b334c716f20999c2e08e5b797207b0afaePaul Stewart 3931a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart void set_friendly_name(const std::string& n) { friendly_name_ = n; } 3941a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& friendly_name() const { return friendly_name_; } 395923a5025a5e1138b052cbeffa60ea387d479696fBen Chan // Sets the kNameProperty and broadcasts the change. 3961a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart void SetFriendlyName(const std::string& friendly_name); 3971590839e44a0e922d4763003a35dbd493509b705mukesh agrawal 3981a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& guid() const { return guid_; } 3991a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool SetGuid(const std::string& guid, Error* error); 4004c56161d7f3801ea86bb2bbd3e2d667c1ab57607Paul Stewart 401cf24a2465a3e7b5a11fa97be282f0af47aa3ef6emukesh agrawal bool has_ever_connected() const { return has_ever_connected_; } 402e99f6643c3282317d2f381c463f46e59628c58c4Rebecca Silberstein // Sets the has_ever_connected_ property of the service 403e99f6643c3282317d2f381c463f46e59628c58c4Rebecca Silberstein // and broadcasts the new value 404e99f6643c3282317d2f381c463f46e59628c58c4Rebecca Silberstein void SetHasEverConnected(bool has_ever_connected); 405cf24a2465a3e7b5a11fa97be282f0af47aa3ef6emukesh agrawal 4067fab89734d88724a288e96a9996b15548c5294c7Ben Chan int32_t priority() const { return priority_; } 4071a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool SetPriority(const int32_t& priority, Error* error); 408d9c7cfc904504447c3478f42c1cffc768c772020Paul Stewart int32_t priority_within_technology() const { 409d9c7cfc904504447c3478f42c1cffc768c772020Paul Stewart return priority_within_technology_; 410d9c7cfc904504447c3478f42c1cffc768c772020Paul Stewart } 4111a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool SetPriorityWithinTechnology(const int32_t& priority, Error* error); 41222aa71b334c716f20999c2e08e5b797207b0afaePaul Stewart 41343970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal size_t crypto_algorithm() const { return crypto_algorithm_; } 41443970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal bool key_rotation() const { return key_rotation_; } 41543970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal bool endpoint_auth() const { return endpoint_auth_; } 41622aa71b334c716f20999c2e08e5b797207b0afaePaul Stewart 4177fab89734d88724a288e96a9996b15548c5294c7Ben Chan void SetStrength(uint8_t strength); 418e1d90e9f688406d47a1453eeac51b7faaebf9908mukesh agrawal 4197fab89734d88724a288e96a9996b15548c5294c7Ben Chan // uint8_t streams out as a char. Coerce to a larger type, so that 420e1d90e9f688406d47a1453eeac51b7faaebf9908mukesh agrawal // it prints as a number. 4217fab89734d88724a288e96a9996b15548c5294c7Ben Chan uint16_t strength() const { return strength_; } 42222aa71b334c716f20999c2e08e5b797207b0afaePaul Stewart 423435de2cd55a95836381b53acbce8cbbad98ec04dGaurav Shah virtual Technology::Identifier technology() const { return technology_; } 42458f0b6dbd71f52c3abdac91aed44024a35bc4898Darin Petkov std::string GetTechnologyString() const; 425435de2cd55a95836381b53acbce8cbbad98ec04dGaurav Shah 4261a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) 4271a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual const EapCredentials* eap() const { return eap_.get(); } 4281a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart void SetEapCredentials(EapCredentials* eap); 4291a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#endif // DISABLE_WIFI || DISABLE_WIRED_8021X 43010109f2c0dd33784d50c27f300f0780986d81effGaurav Shah 431cb71529cc0432935aff005726c81df109d1dc710Darin Petkov bool save_credentials() const { return save_credentials_; } 432cb71529cc0432935aff005726c81df109d1dc710Darin Petkov void set_save_credentials(bool save) { save_credentials_ = save; } 433cb71529cc0432935aff005726c81df109d1dc710Darin Petkov 4341a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& error() const { return error_; } 4351a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart void set_error(const std::string& error) { error_ = error; } 4365148900ad2eb60a07290697446825b16bdc04682Darin Petkov 4371a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& error_details() const { return error_details_; } 4381a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart void SetErrorDetails(const std::string& details); 439aba893217c9cf1dd0d39c4dee89a23d3b1a3f4c1Darin Petkov 4401a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart static const char* ConnectFailureToString(const ConnectFailure& state); 4411a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart static const char* ConnectStateToString(const ConnectState& state); 442c6d6c72920d32299e8ae1cb3a7dbbb13a0741b13Gaurav Shah 44339db5caaa3d07c3af9c575affcbb7313536de91dPaul Stewart // Compare two services. Returns true if Service |a| should be displayed 44439db5caaa3d07c3af9c575affcbb7313536de91dPaul Stewart // above |b|. If |compare_connectivity_state| is true, the connectivity 44539db5caaa3d07c3af9c575affcbb7313536de91dPaul Stewart // state of the service (service->state()) is used as the most significant 44639db5caaa3d07c3af9c575affcbb7313536de91dPaul Stewart // criteria for comparsion, otherwise the service state is ignored. Use 44739db5caaa3d07c3af9c575affcbb7313536de91dPaul Stewart // |tech_order| to rank services if more decisive criteria do not yield a 44839db5caaa3d07c3af9c575affcbb7313536de91dPaul Stewart // difference. |reason| is populated with the exact criteria used for the 44939db5caaa3d07c3af9c575affcbb7313536de91dPaul Stewart // ultimate comparison. 4501a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart static bool Compare(Manager* manager, 4516d4836bd3e385b8929597c366b4d5ba969f5cd04Rebecca Silberstein ServiceRefPtr a, 45222aa71b334c716f20999c2e08e5b797207b0afaePaul Stewart ServiceRefPtr b, 45339db5caaa3d07c3af9c575affcbb7313536de91dPaul Stewart bool compare_connectivity_state, 4541a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::vector<Technology::Identifier>& tech_order, 4551a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const char** reason); 45622aa71b334c716f20999c2e08e5b797207b0afaePaul Stewart 45734af218abe6a99144ffe01332ce36fbad94f2628Chris Masone // These are defined in service.cc so that we don't have to include profile.h 4589d779936d8f8c2d74b30883e2a2622c4207fe797Chris Masone // TODO(cmasone): right now, these are here only so that we can get the 4599d779936d8f8c2d74b30883e2a2622c4207fe797Chris Masone // profile name as a property. Can we store just the name, and then handle 4609d779936d8f8c2d74b30883e2a2622c4207fe797Chris Masone // setting the profile for this service via |manager_|? 4611a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const ProfileRefPtr& profile() const; 4627917360b71c6680de60b487b3630dc1a0f8cdca2Philipp Neubeck 4637917360b71c6680de60b487b3630dc1a0f8cdca2Philipp Neubeck // Sets the profile property of this service. Broadcasts the new value if it's 464cc225ef3b77b5e098cc12c661a947e1737480777Ben Chan // not nullptr. If the new value is nullptr, the service will either be set to 4657917360b71c6680de60b487b3630dc1a0f8cdca2Philipp Neubeck // another profile afterwards or it will not be visible and not monitored 4667917360b71c6680de60b487b3630dc1a0f8cdca2Philipp Neubeck // anymore. 4671a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart void SetProfile(const ProfileRefPtr& p); 4687917360b71c6680de60b487b3630dc1a0f8cdca2Philipp Neubeck 4697917360b71c6680de60b487b3630dc1a0f8cdca2Philipp Neubeck // This is called from tests and shouldn't be called otherwise. Use SetProfile 4707917360b71c6680de60b487b3630dc1a0f8cdca2Philipp Neubeck // instead. 4711a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart void set_profile(const ProfileRefPtr& p); 4726791a43add38926966bd420e89541717fb2cb2b5Chris Masone 4734357f4ea204e5d3e7632d67f26531e106dd211e2Paul Stewart // Notification that occurs when a service now has profile data saved 4744357f4ea204e5d3e7632d67f26531e106dd211e2Paul Stewart // on its behalf. Some service types like WiFi can choose to register 4754357f4ea204e5d3e7632d67f26531e106dd211e2Paul Stewart // themselves at this point. 4764357f4ea204e5d3e7632d67f26531e106dd211e2Paul Stewart virtual void OnProfileConfigured() {} 4774357f4ea204e5d3e7632d67f26531e106dd211e2Paul Stewart 478ff14b0261ac867f98b96db9ba39490fd70269fcdPaul Stewart // Notification that occurs when a single property has been changed via 479ff14b0261ac867f98b96db9ba39490fd70269fcdPaul Stewart // the RPC adaptor. 4801a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual void OnPropertyChanged(const std::string& property); 481ff14b0261ac867f98b96db9ba39490fd70269fcdPaul Stewart 482c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart // Notification that occurs when an EAP credential property has been 483c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart // changed. Some service subclasses can choose to respond to this 484c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart // event. 4855777690fb2291a468715eabfcc6f7aac6f1678cdRebecca Silberstein virtual void OnEapCredentialsChanged(UpdateCredentialsReason reason) {} 486c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart 4870801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley // Called by the manager once after a resume. 4880801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley virtual void OnAfterResume(); 4890801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley 49064ad2383c4555a99f4f09fe8f5faa088f99f5b90Prathmesh Prabhu // Called by the manager once when entering dark resume. 49164ad2383c4555a99f4f09fe8f5faa088f99f5b90Prathmesh Prabhu virtual void OnDarkResume(); 49264ad2383c4555a99f4f09fe8f5faa088f99f5b90Prathmesh Prabhu 4932eee613868307d04f9e5a0efbc8c72a7ffcd90bbPaul Stewart // Called by the manager to clear remembered state of being explicitly 4942eee613868307d04f9e5a0efbc8c72a7ffcd90bbPaul Stewart // disconnected. 4952eee613868307d04f9e5a0efbc8c72a7ffcd90bbPaul Stewart virtual void ClearExplicitlyDisconnected(); 4962eee613868307d04f9e5a0efbc8c72a7ffcd90bbPaul Stewart 4971a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) 4981a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart EapCredentials* mutable_eap() { return eap_.get(); } 4991a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#endif // DISABLE_WIFI || DISABLE_WIRED_8021X 500c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart 50115d5431798155cc83a3fcb8abe0d1a2d5128f7b6Rebecca Silberstein const DhcpProperties& dhcp_properties() const { 50215d5431798155cc83a3fcb8abe0d1a2d5128f7b6Rebecca Silberstein return *dhcp_properties_; 50315d5431798155cc83a3fcb8abe0d1a2d5128f7b6Rebecca Silberstein } 50415d5431798155cc83a3fcb8abe0d1a2d5128f7b6Rebecca Silberstein 5051a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart PropertyStore* mutable_store() { return &store_; } 5061a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const PropertyStore& store() const { return store_; } 5071a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart StaticIPParameters* mutable_static_ip_parameters() { 508def189ec3772bdc440b1c45c2b673122d3e2789ePaul Stewart return &static_ip_parameters_; 509def189ec3772bdc440b1c45c2b673122d3e2789ePaul Stewart } 5101a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const StaticIPParameters& static_ip_parameters() const { 5111062d9deedace1cf4b3b374c5d40c53047fd6778Paul Stewart return static_ip_parameters_; 5121062d9deedace1cf4b3b374c5d40c53047fd6778Paul Stewart } 51327c4aa55b33d3a3836cf70c8f7094bce1c5ead8cChris Masone 514c3dbff129c978e573d387aeb4685045851623e6dPaul Stewart // Retrieves |key| from |id| in |storage| to |value|. If this key does 515c3dbff129c978e573d387aeb4685045851623e6dPaul Stewart // not exist, assign |default_value| to |value|. 5161a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart static void LoadString(StoreInterface* storage, 5171a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& id, 5181a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& key, 5191a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& default_value, 5201a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart std::string* value); 521c3dbff129c978e573d387aeb4685045851623e6dPaul Stewart 522c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart // Assigns |value| to |key| in |storage| if |value| is non-empty and |save| is 523c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart // true. Otherwise, removes |key| from |storage|. If |crypted| is true, the 524c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart // value is encrypted. 5251a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart static void SaveString(StoreInterface* storage, 5261a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& id, 5271a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& key, 5281a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& value, 529c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart bool crypted, 530c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart bool save); 531c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart 532967eaebb63aac3b9679dc4b2dca0565292e3af03Paul Stewart // Called via RPC to get a dict containing profile-to-entry_name mappings 533967eaebb63aac3b9679dc4b2dca0565292e3af03Paul Stewart // of all the profile entires which contain configuration applicable to 534967eaebb63aac3b9679dc4b2dca0565292e3af03Paul Stewart // this service. 535967eaebb63aac3b9679dc4b2dca0565292e3af03Paul Stewart std::map<std::string, std::string> GetLoadableProfileEntries(); 536967eaebb63aac3b9679dc4b2dca0565292e3af03Paul Stewart 5379d58193108f55edf0f06cd54f44464da633cb8aaPeter Qiu void set_connection_id(int connection_id) { connection_id_ = connection_id; } 5389d58193108f55edf0f06cd54f44464da633cb8aaPeter Qiu int connection_id() const { return connection_id_; } 5399d58193108f55edf0f06cd54f44464da633cb8aaPeter Qiu 540a388fdb2e74717ba2440a605f208647dd7cd3e06Peter Qiu void set_unreliable(bool unreliable) { unreliable_ = unreliable; } 541a388fdb2e74717ba2440a605f208647dd7cd3e06Peter Qiu bool unreliable() const { return unreliable_; } 542a388fdb2e74717ba2440a605f208647dd7cd3e06Peter Qiu 543b54601c6f85577ab326da277356b88049d92ee2bmukesh agrawal protected: 5445eb0542cb67358d9030367498a4ad741fc42af4fDarin Petkov friend class base::RefCounted<Service>; 5455eb0542cb67358d9030367498a4ad741fc42af4fDarin Petkov 54603c15ce0583d0c89bbd762b1140ace8d537c7625mukesh agrawal static const char kAutoConnBusy[]; 54703c15ce0583d0c89bbd762b1140ace8d537c7625mukesh agrawal 5485eb0542cb67358d9030367498a4ad741fc42af4fDarin Petkov virtual ~Service(); 5495eb0542cb67358d9030367498a4ad741fc42af4fDarin Petkov 55034af218abe6a99144ffe01332ce36fbad94f2628Chris Masone // Returns true if a character is allowed to be in a service storage id. 55134af218abe6a99144ffe01332ce36fbad94f2628Chris Masone static bool LegalChar(char a) { return isalnum(a) || a == '_'; } 55234af218abe6a99144ffe01332ce36fbad94f2628Chris Masone 553313324136473f9120b1e485a408f51ae938dcb64Darin Petkov // Returns true if a character is disallowed to be in a service storage id. 554313324136473f9120b1e485a408f51ae938dcb64Darin Petkov static bool IllegalChar(char a) { return !LegalChar(a); } 555313324136473f9120b1e485a408f51ae938dcb64Darin Petkov 5561a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual std::string CalculateState(Error* error); 5571a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart std::string CalculateTechnology(Error* error); 5583bd3c8c33917221d1074f1aa19272e45c0ce2793Chris Masone 5591a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool GetVisibleProperty(Error* error); 560cca85b15c06b120ea3d17a4be2f24da06d62a1c4Paul Stewart 5618a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal // Returns whether this service is in a state conducive to auto-connect. 5628a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal // This should include any tests used for computing connectable(), 5638a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal // as well as other critera such as whether the device associated with 5648a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal // this service is busy with another connection. 565bf14e94cbd47d6320eec846f1ca4def026840e14mukesh agrawal // 566bf14e94cbd47d6320eec846f1ca4def026840e14mukesh agrawal // If the service is not auto-connectable, |*reason| will be set to 567bf14e94cbd47d6320eec846f1ca4def026840e14mukesh agrawal // point to C-string explaining why the service is not auto-connectable. 5681a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual bool IsAutoConnectable(const char** reason) const; 5698a3188dbc04245c17a4729d16a632547ce4bf585mukesh agrawal 570292dc0f18ce6ba7ea1419efc4d8ef909712bb7c2mukesh agrawal // HelpRegisterDerived*: Expose a property over RPC, with the name |name|. 571292dc0f18ce6ba7ea1419efc4d8ef909712bb7c2mukesh agrawal // 572292dc0f18ce6ba7ea1419efc4d8ef909712bb7c2mukesh agrawal // Reads of the property will be handled by invoking |get|. 573292dc0f18ce6ba7ea1419efc4d8ef909712bb7c2mukesh agrawal // Writes to the property will be handled by invoking |set|. 574292dc0f18ce6ba7ea1419efc4d8ef909712bb7c2mukesh agrawal // Clearing the property will be handled by PropertyStore. 575ffa3d0433d419aa9251f3768a0090a27b6b1c434mukesh agrawal void HelpRegisterDerivedBool( 5761a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& name, 5771a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool(Service::*get)(Error* error), 5781a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool(Service::*set)(const bool& value, Error* error), 5791a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart void(Service::*clear)(Error* error)); 580cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawal void HelpRegisterDerivedInt32( 5811a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& name, 5821a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart int32_t(Service::*get)(Error* error), 5831a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool(Service::*set)(const int32_t& value, Error* error)); 584ffa3d0433d419aa9251f3768a0090a27b6b1c434mukesh agrawal void HelpRegisterDerivedString( 5851a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& name, 5861a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart std::string(Service::*get)(Error* error), 5871a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool(Service::*set)(const std::string& value, Error* error)); 588bebf1b8bce52b88c2cc2d93200b9405f9c19cf21mukesh agrawal void HelpRegisterConstDerivedUint16( 5891a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& name, 5901a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart uint16_t(Service::*get)(Error* error) const); 591bebf1b8bce52b88c2cc2d93200b9405f9c19cf21mukesh agrawal void HelpRegisterConstDerivedRpcIdentifier( 5921a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& name, 5931a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart std::string(Service::*get)(Error*) const); 5940c65bdd97e8dc59102b9e9f4e1f63245311cbdcdDarin Petkov void HelpRegisterConstDerivedStrings( 5951a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& name, Strings(Service::*get)(Error* error) const); 5961cf7eb8dcb037d45b23ed85b777c227b7ab39069Paul Stewart void HelpRegisterConstDerivedString( 5971a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& name, std::string(Service::*get)(Error* error) const); 5983bd3c8c33917221d1074f1aa19272e45c0ce2793Chris Masone 59945170bcb5e3b5e076e9307c695faf25faac395c8Paul Stewart // HelpRegisterObservedDerived*: Expose an property over RPC, with the 60045170bcb5e3b5e076e9307c695faf25faac395c8Paul Stewart // name |name|, for which property changes are automatically generated. 60145170bcb5e3b5e076e9307c695faf25faac395c8Paul Stewart // 60245170bcb5e3b5e076e9307c695faf25faac395c8Paul Stewart void HelpRegisterObservedDerivedBool( 6031a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& name, 6041a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool(Service::*get)(Error* error), 6051a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool(Service::*set)(const bool& value, Error* error), 6061a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart void(Service::*clear)(Error* error)); 6071a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart ServiceAdaptorInterface* adaptor() const { return adaptor_.get(); } 608b72cf40dc315f9ae3537980f4fd85e737c125a03Darin Petkov 6091a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) 610d8ad3c4266195daeb440a9fb65c612e4f6bfc7f8Paul Stewart void UnloadEapCredentials(); 6111a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#endif // DISABLE_WIFI || DISABLE_WIRED_8021X 612ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov 613cb59fed9326dc91c93b817dcd9eaca363d8313fePaul Stewart // Ignore |parameter| when performing a Configure() operation. 6141a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart void IgnoreParameterForConfigure(const std::string& parameter); 615cb59fed9326dc91c93b817dcd9eaca363d8313fePaul Stewart 616f2d609103916861ea8a9377ef93a72cc998bdf80Paul Stewart // Update the service's string-based "Error" RPC property based on the 617f2d609103916861ea8a9377ef93a72cc998bdf80Paul Stewart // failure_ enum. 618f2d609103916861ea8a9377ef93a72cc998bdf80Paul Stewart void UpdateErrorProperty(); 619f2d609103916861ea8a9377ef93a72cc998bdf80Paul Stewart 620cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawal // RPC setter for the the "AutoConnect" property. Updates the |manager_|. 621cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawal // (cf. SetAutoConnect, which does not update the manager.) 6221a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual bool SetAutoConnectFull(const bool& connect, Error* error); 623cf199de9b7c813635b5247a1858a99ab1fc9e21bPaul Stewart 62443d8dc054417ea59a2c6507965196d5f46012f72Paul Stewart // RPC clear method for the "AutoConnect" property. Sets the AutoConnect 6252da34c038933eeac36a85550ff54e09611a1d828Paul Stewart // property back to its default value, and clears the retain_auto_connect_ 6262da34c038933eeac36a85550ff54e09611a1d828Paul Stewart // property to allow the AutoConnect property to be enabled automatically. 6271a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart void ClearAutoConnect(Error* error); 62843d8dc054417ea59a2c6507965196d5f46012f72Paul Stewart 629ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart // Property accessors reserved for subclasses 6301a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart EventDispatcher* dispatcher() const { return dispatcher_; } 631a92b0a0438803ebb3432d7b42672fbb7fb6bccf4Peter Qiu ControlInterface* control_interface() const { return control_interface_; } 6321a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) 6331a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart const std::string& GetEAPKeyManagement() const; 6341a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual void SetEAPKeyManagement(const std::string& key_management); 6351a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#endif // DISABLE_WIFI || DISABLE_WIRED_8021X 6361a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu 6371a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart Manager* manager() const { return manager_; } 6381a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart Metrics* metrics() const { return metrics_; } 639b54601c6f85577ab326da277356b88049d92ee2bmukesh agrawal 6402da34c038933eeac36a85550ff54e09611a1d828Paul Stewart // Save the serivce's auto_connect value, without affecting its auto_connect 6412da34c038933eeac36a85550ff54e09611a1d828Paul Stewart // property itself. (cf. EnableAndRetainAutoConnect) 6422da34c038933eeac36a85550ff54e09611a1d828Paul Stewart void RetainAutoConnect(); 6432da34c038933eeac36a85550ff54e09611a1d828Paul Stewart 64443970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal // Inform base class of the security properties for the service. 64543970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal // 64643970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal // NB: When adding a call to this function from a subclass, please check 64743970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal // that the semantics of SecurityLevel() are appropriate for the subclass. 64843970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal void SetSecurity(CryptoAlgorithm crypt, bool rotation, bool endpoint_auth); 6491d0080a0f39f03402cde853d832af976eb32852bDarin Petkov 650fa11e28ddb81dab93971d5433a5274a1dc5c8283Paul Stewart // Return whether this service is suspected or confirmed to be 651fa11e28ddb81dab93971d5433a5274a1dc5c8283Paul Stewart // provided by a mobile device, which is likely to be using a 652fa11e28ddb81dab93971d5433a5274a1dc5c8283Paul Stewart // metered backhaul for internet connectivity. 6531a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual std::string GetTethering(Error* error) const; 654fa11e28ddb81dab93971d5433a5274a1dc5c8283Paul Stewart 65545170bcb5e3b5e076e9307c695faf25faac395c8Paul Stewart // Emit property change notifications for all observed properties. 65645170bcb5e3b5e076e9307c695faf25faac395c8Paul Stewart void NotifyPropertyChanges(); 6577cc906803118d61ead47471f26eb1970a5851811Paul Stewart 65875897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart private: 65943ce4d428d619bda64eea6d37534f02c179a1756Thieu Le friend class ActivePassiveOutOfCreditsDetectorTest; 660bebf1b8bce52b88c2cc2d93200b9405f9c19cf21mukesh agrawal friend class EthernetEapServiceTest; 661cf199de9b7c813635b5247a1858a99ab1fc9e21bPaul Stewart friend class EthernetServiceTest; 66248e6d6d0ec0f90d9b2206f60c1ff2a825c5ce9c1Thieu Le friend class MetricsTest; 6639dd253ea215bd0d11be2038050c2d77217042e36Paul Stewart friend class ManagerTest; 6640756db95c9d39d6e6aa9a754e54b441eff46ff34Paul Stewart friend class ServiceAdaptorInterface; 665385b9bccbcdb5395e1fc8903a0f14cb6016b01c3Darin Petkov friend class ServiceTest; 66643ce4d428d619bda64eea6d37534f02c179a1756Thieu Le friend class SubscriptionStateOutOfCreditsDetectorTest; 667457728b3eeb2d67c980e0d20675f0a0f750903e1Darin Petkov friend class VPNProviderTest; 6685eb0542cb67358d9030367498a4ad741fc42af4fDarin Petkov friend class VPNServiceTest; 669e1d90e9f688406d47a1453eeac51b7faaebf9908mukesh agrawal friend class WiFiServiceTest; 670457728b3eeb2d67c980e0d20675f0a0f750903e1Darin Petkov friend class WiMaxProviderTest; 6716b9b2e18088f22b79ea5d87f575b67632fb5770aDarin Petkov friend class WiMaxServiceTest; 6721a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart friend void TestCommonPropertyChanges(ServiceRefPtr, ServiceMockAdaptor*); 6731a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart friend void TestCustomSetterNoopChange(ServiceRefPtr, MockManager*); 6741a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart friend void TestNamePropertyChange(ServiceRefPtr, ServiceMockAdaptor*); 6750801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley FRIEND_TEST(AllMockServiceTest, AutoConnectWithFailures); 676457728b3eeb2d67c980e0d20675f0a0f750903e1Darin Petkov FRIEND_TEST(CellularCapabilityGSMTest, SetStorageIdentifier); 67719f83971a35d7f2c7b08aae6eb0abdc8e52ba057Ben Chan FRIEND_TEST(CellularServiceTest, IsAutoConnectable); 67815d5431798155cc83a3fcb8abe0d1a2d5128f7b6Rebecca Silberstein FRIEND_TEST(DeviceTest, AcquireIPConfigWithoutSelectedService); 67915d5431798155cc83a3fcb8abe0d1a2d5128f7b6Rebecca Silberstein FRIEND_TEST(DeviceTest, AcquireIPConfigWithSelectedService); 680cc0fded2a80c2c6c7fb46cbd7eee578e7a78c50amukesh agrawal FRIEND_TEST(DeviceTest, IPConfigUpdatedFailureWithStatic); 68139db5caaa3d07c3af9c575affcbb7313536de91dPaul Stewart FRIEND_TEST(ManagerTest, ConnectToBestServices); 68203c15ce0583d0c89bbd762b1140ace8d537c7625mukesh agrawal FRIEND_TEST(ServiceTest, AutoConnectLogging); 68358f0b6dbd71f52c3abdac91aed44024a35bc4898Darin Petkov FRIEND_TEST(ServiceTest, CalculateState); 68458f0b6dbd71f52c3abdac91aed44024a35bc4898Darin Petkov FRIEND_TEST(ServiceTest, CalculateTechnology); 685bc6e7390c4401e171ede4dc83b79b316f3e71100Paul Stewart FRIEND_TEST(ServiceTest, Certification); 68622ce765226cfdcf267b7dc80c22892e6b29065eaPaul Stewart FRIEND_TEST(ServiceTest, Compare); 687c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart FRIEND_TEST(ServiceTest, ConfigureEapStringProperty); 688cb59fed9326dc91c93b817dcd9eaca363d8313fePaul Stewart FRIEND_TEST(ServiceTest, ConfigureIgnoredProperty); 689ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov FRIEND_TEST(ServiceTest, Constructor); 690bebf1b8bce52b88c2cc2d93200b9405f9c19cf21mukesh agrawal FRIEND_TEST(ServiceTest, CustomSetterNoopChange); 69110241e32c136ba99e7533ca1370e2e8eca241b7cPaul Stewart FRIEND_TEST(ServiceTest, GetIPConfigRpcIdentifier); 692284fe797377b574717e6f61196219fece1cbe85bThieu Le FRIEND_TEST(ServiceTest, GetProperties); 693fa11e28ddb81dab93971d5433a5274a1dc5c8283Paul Stewart FRIEND_TEST(ServiceTest, GetTethering); 69476d1388a4a0435f1586117b55674ad61f5a8e6c6mukesh agrawal FRIEND_TEST(ServiceTest, IsAutoConnectable); 695df3c0a897bc74cb3a9800332b8359a364ca2f753Paul Stewart FRIEND_TEST(ServiceTest, IsDependentOn); 696c3dbff129c978e573d387aeb4685045851623e6dPaul Stewart FRIEND_TEST(ServiceTest, Load); 69715d5431798155cc83a3fcb8abe0d1a2d5128f7b6Rebecca Silberstein FRIEND_TEST(ServiceTest, LoadAutoConnect); 6989b83c897f8e197ff7846e4fe7cec1d83d54e7b7bPeter Qiu FRIEND_TEST(ServiceTest, PortalDetectionFailure); 699d215af6f72d012f43057c34f17a12506baa21e66Paul Stewart FRIEND_TEST(ServiceTest, RecheckPortal); 700ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov FRIEND_TEST(ServiceTest, Save); 701ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov FRIEND_TEST(ServiceTest, SaveString); 702ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov FRIEND_TEST(ServiceTest, SaveStringCrypted); 703ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov FRIEND_TEST(ServiceTest, SaveStringDontSave); 704ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov FRIEND_TEST(ServiceTest, SaveStringEmpty); 70543970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal FRIEND_TEST(ServiceTest, SecurityLevel); 706d215af6f72d012f43057c34f17a12506baa21e66Paul Stewart FRIEND_TEST(ServiceTest, SetCheckPortal); 707cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawal FRIEND_TEST(ServiceTest, SetConnectableFull); 7082717a10096e12e46413adf47b39c5b19cd33bce7Arman Uguray FRIEND_TEST(ServiceTest, SetFriendlyName); 7092717a10096e12e46413adf47b39c5b19cd33bce7Arman Uguray FRIEND_TEST(ServiceTest, SetProperty); 710568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal FRIEND_TEST(ServiceTest, State); 711af471414b5ccb0dfbfd030e7baffd55dfdf51fe7Thieu Le FRIEND_TEST(ServiceTest, StateResetAfterFailure); 712e37ad321159eb4d7898c1a2f4a64f14f9fc32e15mukesh agrawal FRIEND_TEST(ServiceTest, UniqueAttributes); 713d8ad3c4266195daeb440a9fb65c612e4f6bfc7f8Paul Stewart FRIEND_TEST(ServiceTest, Unload); 714dc4e099103a56f0427ed0969fea2c46c88ab2e9ePeter Qiu FRIEND_TEST(ServiceTest, UserInitiatedConnectionResult); 715e99f6643c3282317d2f381c463f46e59628c58c4Rebecca Silberstein FRIEND_TEST(WiFiServiceTest, SetPassphraseResetHasEverConnected); 716bca08f806803aa8f78dc563c9d1a3acf8e1ebe97Paul Stewart FRIEND_TEST(WiFiServiceTest, SuspectedCredentialFailure); 717b6df8b11a3eff18acdc3e9128af73c62ef39aa1aRebecca Silberstein FRIEND_TEST(WiFiServiceTest, SetPassphraseRemovesCachedCredentials); 7185777690fb2291a468715eabfcc6f7aac6f1678cdRebecca Silberstein FRIEND_TEST(WiFiServiceTest, LoadPassphraseClearCredentials); 7190801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley FRIEND_TEST(WiFiTimerTest, ReconnectTimer); 72011c224b7054a3f0dc5a34c2903e13f74376db27ePaul Stewart FRIEND_TEST(WiFiMainTest, EAPEvent); // For eap_. 721b6df8b11a3eff18acdc3e9128af73c62ef39aa1aRebecca Silberstein FRIEND_TEST(WiMaxServiceTest, ChangeCredResetHasEverConnected); 722b6df8b11a3eff18acdc3e9128af73c62ef39aa1aRebecca Silberstein FRIEND_TEST(EthernetEapServiceTest, OnEapCredentialsChanged); 723ba40dd302d1f6f4c38b9449a4e83c3d470159ea1Darin Petkov 724bf14e94cbd47d6320eec846f1ca4def026840e14mukesh agrawal static const char kAutoConnConnected[]; 725bf14e94cbd47d6320eec846f1ca4def026840e14mukesh agrawal static const char kAutoConnConnecting[]; 726bf14e94cbd47d6320eec846f1ca4def026840e14mukesh agrawal static const char kAutoConnExplicitDisconnect[]; 727bf14e94cbd47d6320eec846f1ca4def026840e14mukesh agrawal static const char kAutoConnNotConnectable[]; 7284cbff5b5897593f7a2e6de48a98abe72356075afDarin Petkov static const char kAutoConnOffline[]; 7298e6b8ef22e185310480c13aa3a6e89184cce62d1Ben Chan static const char kAutoConnTechnologyNotConnectable[]; 7300801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley static const char kAutoConnThrottled[]; 731bf14e94cbd47d6320eec846f1ca4def026840e14mukesh agrawal 7321a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) 733bc6e7390c4401e171ede4dc83b79b316f3e71100Paul Stewart static const size_t kEAPMaxCertificationElements; 7341a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#endif // DISABLE_WIFI || DISABLE_WIRED_8021X 735bc6e7390c4401e171ede4dc83b79b316f3e71100Paul Stewart 7362f903b3842af547e062fbf7b21a04e103211dec3Darin Petkov static const char kServiceSortAutoConnect[]; 7372f903b3842af547e062fbf7b21a04e103211dec3Darin Petkov static const char kServiceSortConnectable[]; 7382da34c038933eeac36a85550ff54e09611a1d828Paul Stewart static const char kServiceSortHasEverConnected[]; 739ddc378f1b63b842cc691ecd2274c3674525a7639mukesh agrawal static const char kServiceSortIsConnected[]; 740df3c0a897bc74cb3a9800332b8359a364ca2f753Paul Stewart static const char kServiceSortDependency[]; 741ddc378f1b63b842cc691ecd2274c3674525a7639mukesh agrawal static const char kServiceSortIsConnecting[]; 742ddc378f1b63b842cc691ecd2274c3674525a7639mukesh agrawal static const char kServiceSortIsFailed[]; 743778c986f85ffb3e91ccf3bf0382372853888fd07Paul Stewart static const char kServiceSortIsOnline[]; 744a121c44fb8e620b572c2f8d260406729d10d339aPaul Stewart static const char kServiceSortIsPortalled[]; 7452f903b3842af547e062fbf7b21a04e103211dec3Darin Petkov static const char kServiceSortPriority[]; 746d9c7cfc904504447c3478f42c1cffc768c772020Paul Stewart static const char kServiceSortPriorityWithinTechnology[]; 7476d4836bd3e385b8929597c366b4d5ba969f5cd04Rebecca Silberstein static const char kServiceSortSecurity[]; 7486d4836bd3e385b8929597c366b4d5ba969f5cd04Rebecca Silberstein static const char kServiceSortProfileOrder[]; 7496d4836bd3e385b8929597c366b4d5ba969f5cd04Rebecca Silberstein static const char kServiceSortEtc[]; 750e37ad321159eb4d7898c1a2f4a64f14f9fc32e15mukesh agrawal static const char kServiceSortSerialNumber[]; 7512f903b3842af547e062fbf7b21a04e103211dec3Darin Petkov static const char kServiceSortTechnology[]; 752ddc378f1b63b842cc691ecd2274c3674525a7639mukesh agrawal 7537fab89734d88724a288e96a9996b15548c5294c7Ben Chan static const uint64_t kMaxAutoConnectCooldownTimeMilliseconds; 7547fab89734d88724a288e96a9996b15548c5294c7Ben Chan static const uint64_t kMinAutoConnectCooldownTimeMilliseconds; 7557fab89734d88724a288e96a9996b15548c5294c7Ben Chan static const uint64_t kAutoConnectCooldownBackoffFactor; 7560801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley 757385b9bccbcdb5395e1fc8903a0f14cb6016b01c3Darin Petkov static const int kDisconnectsMonitorSeconds; 758385b9bccbcdb5395e1fc8903a0f14cb6016b01c3Darin Petkov static const int kMisconnectsMonitorSeconds; 759385b9bccbcdb5395e1fc8903a0f14cb6016b01c3Darin Petkov static const int kReportDisconnectsThreshold; 760385b9bccbcdb5395e1fc8903a0f14cb6016b01c3Darin Petkov static const int kReportMisconnectsThreshold; 761385b9bccbcdb5395e1fc8903a0f14cb6016b01c3Darin Petkov static const int kMaxDisconnectEventHistory; 76207dfabcb55d74e254f4722926a997959dc4c6393Samuel Tan static const int kMaxMisconnectEventHistory; 763385b9bccbcdb5395e1fc8903a0f14cb6016b01c3Darin Petkov 7641a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool GetAutoConnect(Error* error); 765284fe797377b574717e6f61196219fece1cbe85bThieu Le 7661a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart std::string GetCheckPortal(Error* error); 7671a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool SetCheckPortal(const std::string& check_portal, Error* error); 768d215af6f72d012f43057c34f17a12506baa21e66Paul Stewart 7691a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart std::string GetGuid(Error* error); 770cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawal 7711a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual std::string GetDeviceRpcId(Error* error) const = 0; 77295207da4b896bd0a4186163f6f9ebda044a5a7b9Chris Masone 7731a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart std::string GetIPConfigRpcIdentifier(Error* error) const; 77410241e32c136ba99e7533ca1370e2e8eca241b7cPaul Stewart 7751a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart std::string GetNameProperty(Error* error); 7769c6e9818cd1337ee06a218db83ee577ac977c7d9Darin Petkov // The base implementation asserts that |name| matches the current Name 7779c6e9818cd1337ee06a218db83ee577ac977c7d9Darin Petkov // property value. 7781a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart virtual bool SetNameProperty(const std::string& name, Error* error); 779cbfb34e699532f62eb5b381d0ea3a15d39e00b7cmukesh agrawal 7801a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart int32_t GetPriority(Error* error); 7811a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart int32_t GetPriorityWithinTechnology(Error* error); 7820c43833150ce2b5cd408c12e0f96ce6903dee8a5Paul Stewart 7831a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart std::string GetProfileRpcId(Error* error); 7841a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool SetProfileRpcId(const std::string& profile, Error* error); 7853bd3c8c33917221d1074f1aa19272e45c0ce2793Chris Masone 786be5f5b341ba4b85d45ffb6c0430ef5ab84c7b961Paul Stewart // Returns TCP port of service's HTTP proxy in host order. 7871a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart uint16_t GetHTTPProxyPort(Error* error) const; 788be5f5b341ba4b85d45ffb6c0430ef5ab84c7b961Paul Stewart 7891a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart std::string GetProxyConfig(Error* error); 7901a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart bool SetProxyConfig(const std::string& proxy_config, Error* error); 7917917360b71c6680de60b487b3630dc1a0f8cdca2Philipp Neubeck 7921a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart Strings GetDisconnectsProperty(Error* error) const; 7931a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart Strings GetMisconnectsProperty(Error* error) const; 7940c65bdd97e8dc59102b9e9f4e1f63245311cbdcdDarin Petkov 7950801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley void ReEnableAutoConnectTask(); 7960801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley // Disables autoconnect and posts a task to re-enable it after a cooldown. 7970801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley // Note that autoconnect could be disabled for other reasons as well. 7980801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley void ThrottleFutureAutoConnects(); 7990801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley 800cf24a2465a3e7b5a11fa97be282f0af47aa3ef6emukesh agrawal // Saves settings to profile, if we have one. Unlike 801cf24a2465a3e7b5a11fa97be282f0af47aa3ef6emukesh agrawal // SaveServiceToProfile, SaveToProfile never assigns this service 802cf24a2465a3e7b5a11fa97be282f0af47aa3ef6emukesh agrawal // into a profile. 803cf24a2465a3e7b5a11fa97be282f0af47aa3ef6emukesh agrawal void SaveToProfile(); 804cf24a2465a3e7b5a11fa97be282f0af47aa3ef6emukesh agrawal 805483e4720a875953f07497fd59856156e212cac56Paul Stewart // Qualify the conditions under which the most recent disconnect occurred. 806483e4720a875953f07497fd59856156e212cac56Paul Stewart // Make note ot the fact that there was a problem connecting / staying 807483e4720a875953f07497fd59856156e212cac56Paul Stewart // connected if the disconnection did not occur as a clear result of user 808483e4720a875953f07497fd59856156e212cac56Paul Stewart // action. 809385b9bccbcdb5395e1fc8903a0f14cb6016b01c3Darin Petkov void NoteDisconnectEvent(); 810385b9bccbcdb5395e1fc8903a0f14cb6016b01c3Darin Petkov 81122aa71b334c716f20999c2e08e5b797207b0afaePaul Stewart // Utility function that returns true if a is different from b. When they 81222aa71b334c716f20999c2e08e5b797207b0afaePaul Stewart // are, "decision" is populated with the boolean value of "a > b". 8131a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart static bool DecideBetween(int a, int b, bool* decision); 81422aa71b334c716f20999c2e08e5b797207b0afaePaul Stewart 815dc4e099103a56f0427ed0969fea2c46c88ab2e9ePeter Qiu // Report the result of user-initiated connection attempt to UMA stats. 816dc4e099103a56f0427ed0969fea2c46c88ab2e9ePeter Qiu // Currently only report stats for wifi service. 817dc4e099103a56f0427ed0969fea2c46c88ab2e9ePeter Qiu void ReportUserInitiatedConnectionResult(ConnectState state); 818dc4e099103a56f0427ed0969fea2c46c88ab2e9ePeter Qiu 81943970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal // Linearize security parameters (crypto algorithm, key rotation, endpoint 82043970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal // authentication) for comparison. 8217fab89734d88724a288e96a9996b15548c5294c7Ben Chan uint16_t SecurityLevel(); 82243970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal 823bebf1b8bce52b88c2cc2d93200b9405f9c19cf21mukesh agrawal // WeakPtrFactory comes first, so that other fields can use it. 824bebf1b8bce52b88c2cc2d93200b9405f9c19cf21mukesh agrawal base::WeakPtrFactory<Service> weak_ptr_factory_; 825bebf1b8bce52b88c2cc2d93200b9405f9c19cf21mukesh agrawal 826ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart ConnectState state_; 827c8d91e54873d3490e01d9aa5dac83e7bd9192ff0Darin Petkov ConnectState previous_state_; 828ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart ConnectFailure failure_; 829ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart bool auto_connect_; 8302da34c038933eeac36a85550ff54e09611a1d828Paul Stewart 8312da34c038933eeac36a85550ff54e09611a1d828Paul Stewart // Denotes whether the value of auto_connect_ property value should be 8322da34c038933eeac36a85550ff54e09611a1d828Paul Stewart // retained, i.e. only be allowed to change via explicit property changes 8332da34c038933eeac36a85550ff54e09611a1d828Paul Stewart // from the UI. 8342da34c038933eeac36a85550ff54e09611a1d828Paul Stewart bool retain_auto_connect_; 8352da34c038933eeac36a85550ff54e09611a1d828Paul Stewart 836ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart std::string check_portal_; 837ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart bool connectable_; 838ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart std::string error_; 839aba893217c9cf1dd0d39c4dee89a23d3b1a3f4c1Darin Petkov std::string error_details_; 840d7c09a5f2d7dc6f610e3162be392e349e9ceed8dPaul Stewart std::string previous_error_; 8417fab89734d88724a288e96a9996b15548c5294c7Ben Chan int32_t previous_error_serial_number_; 842adb6848a27f0eb449527fa3aa0440002f2be6800mukesh agrawal bool explicitly_disconnected_; 843dc4e099103a56f0427ed0969fea2c46c88ab2e9ePeter Qiu bool is_in_user_connect_; 8447fab89734d88724a288e96a9996b15548c5294c7Ben Chan int32_t priority_; 845d9c7cfc904504447c3478f42c1cffc768c772020Paul Stewart int32_t priority_within_technology_; 8467fab89734d88724a288e96a9996b15548c5294c7Ben Chan uint8_t crypto_algorithm_; 84743970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal bool key_rotation_; 84843970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal bool endpoint_auth_; 8499b83c897f8e197ff7846e4fe7cec1d83d54e7b7bPeter Qiu std::string portal_detection_failure_phase_; 8509b83c897f8e197ff7846e4fe7cec1d83d54e7b7bPeter Qiu std::string portal_detection_failure_status_; 85143970a2573b7c8fea9f4c2010e7bef7785ca0e82mukesh agrawal 8527fab89734d88724a288e96a9996b15548c5294c7Ben Chan uint8_t strength_; 853ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart std::string proxy_config_; 854987e71e21e4f71226e75b564e14cb2b09d070411Paul Stewart std::string ui_data_; 8554c56161d7f3801ea86bb2bbd3e2d667c1ab57607Paul Stewart std::string guid_; 856ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart bool save_credentials_; 8571a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X) 858cd47732488cd101eaf0d3558dde5a7d4e4fc260bBen Chan std::unique_ptr<EapCredentials> eap_; 8591a72f5444e077ed21b8e085b17d7f9f1bc44fa5ePeter Qiu#endif // DISABLE_WIFI || DISABLE_WIRED_8021X 86015d5431798155cc83a3fcb8abe0d1a2d5128f7b6Rebecca Silberstein std::unique_ptr<DhcpProperties> dhcp_properties_; 861435de2cd55a95836381b53acbce8cbbad98ec04dGaurav Shah Technology::Identifier technology_; 862568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal // The time of the most recent failure. Value is 0 if the service is 863568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal // not currently failed. 864568b5c6b093d5605a40216711d3291376394dd0fmukesh agrawal time_t failed_time_; 865cf24a2465a3e7b5a11fa97be282f0af47aa3ef6emukesh agrawal // Whether or not this service has ever reached kStateConnected. 866cf24a2465a3e7b5a11fa97be282f0af47aa3ef6emukesh agrawal bool has_ever_connected_; 867ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart 86807dfabcb55d74e254f4722926a997959dc4c6393Samuel Tan EventHistory disconnects_; // Connection drops. 86907dfabcb55d74e254f4722926a997959dc4c6393Samuel Tan EventHistory misconnects_; // Failures to connect. 870385b9bccbcdb5395e1fc8903a0f14cb6016b01c3Darin Petkov 8710801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley base::CancelableClosure reenable_auto_connect_task_; 8727fab89734d88724a288e96a9996b15548c5294c7Ben Chan uint64_t auto_connect_cooldown_milliseconds_; 8730801d1962dae6af189858f5ab727b5cfc490726fChristopher Wiley 874ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart ProfileRefPtr profile_; 875ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart PropertyStore store_; 876cb59fed9326dc91c93b817dcd9eaca363d8313fePaul Stewart std::set<std::string> parameters_ignored_for_configure_; 877ac4ac00189acd22ce95098712c74e1c2c23ede53Paul Stewart 8781a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart EventDispatcher* dispatcher_; 879a92b0a0438803ebb3432d7b42672fbb7fb6bccf4Peter Qiu ControlInterface* control_interface_; 880e37ad321159eb4d7898c1a2f4a64f14f9fc32e15mukesh agrawal unsigned int serial_number_; 881d835b2079b1b0f67338d48f528d61f882fa77693mukesh agrawal std::string unique_name_; // MUST be unique amongst service instances 882457728b3eeb2d67c980e0d20675f0a0f750903e1Darin Petkov 883457728b3eeb2d67c980e0d20675f0a0f750903e1Darin Petkov // Service's friendly name is presented through the UI. By default it's the 884457728b3eeb2d67c980e0d20675f0a0f750903e1Darin Petkov // same as |unique_name_| but normally Service subclasses override 885457728b3eeb2d67c980e0d20675f0a0f750903e1Darin Petkov // it. WARNING: Don't log the friendly name at the default logging level due 886457728b3eeb2d67c980e0d20675f0a0f750903e1Darin Petkov // to PII concerns. 887457728b3eeb2d67c980e0d20675f0a0f750903e1Darin Petkov std::string friendly_name_; 888457728b3eeb2d67c980e0d20675f0a0f750903e1Darin Petkov 889c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart // List of subject names reported by remote entity during TLS setup. 890c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart std::vector<std::string> remote_certification_; 891c43cbbe5b33a7afe1b1250bef87fb8e9223cb764Paul Stewart 892cd47732488cd101eaf0d3558dde5a7d4e4fc260bBen Chan std::unique_ptr<ServiceAdaptorInterface> adaptor_; 893cd47732488cd101eaf0d3558dde5a7d4e4fc260bBen Chan std::unique_ptr<ServicePropertyChangeNotifier> property_change_notifier_; 894cd47732488cd101eaf0d3558dde5a7d4e4fc260bBen Chan std::unique_ptr<HTTPProxy> http_proxy_; 895c1dec4d5cad7c6ee2cd8dbc4f47e4d30403dcca1Paul Stewart ConnectionRefPtr connection_; 8961062d9deedace1cf4b3b374c5d40c53047fd6778Paul Stewart StaticIPParameters static_ip_parameters_; 8971a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart Metrics* metrics_; 8981a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart Manager* manager_; 899cd47732488cd101eaf0d3558dde5a7d4e4fc260bBen Chan std::unique_ptr<Sockets> sockets_; 9001a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart Time* time_; 9011a212a6b98b22ad1d69652bb26a9e94138635476Paul Stewart DiagnosticsReporter* diagnostics_reporter_; 9023bd3c8c33917221d1074f1aa19272e45c0ce2793Chris Masone 903e37ad321159eb4d7898c1a2f4a64f14f9fc32e15mukesh agrawal // The |serial_number_| for the next Service. 904e37ad321159eb4d7898c1a2f4a64f14f9fc32e15mukesh agrawal static unsigned int next_serial_number_; 905e37ad321159eb4d7898c1a2f4a64f14f9fc32e15mukesh agrawal 9069d58193108f55edf0f06cd54f44464da633cb8aaPeter Qiu // Network identifier indicating the network (gateway) the service is 9079d58193108f55edf0f06cd54f44464da633cb8aaPeter Qiu // connected to. 9089d58193108f55edf0f06cd54f44464da633cb8aaPeter Qiu int connection_id_; 909a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu // When set to true, this service will automatically fallback to Google's DNS 910a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu // servers if the portal detection failed due to DNS failure and Google's DNS 911a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu // servers are working. 912a89154bfedfd8872242083ffe4f084fdc774c078Peter Qiu bool is_dns_auto_fallback_allowed_; 913d49760e19d137f43df29e00265259d395b07994cPeter Qiu // When set to true, will not start link monitor when the connection to this 914d49760e19d137f43df29e00265259d395b07994cPeter Qiu // service is established. 915d49760e19d137f43df29e00265259d395b07994cPeter Qiu bool link_monitor_disabled_; 9163fee7e38845bc9512a84c311c7bfcc21e19cda19Paul Stewart // When set to true, the credentials for this service will be considered 9173fee7e38845bc9512a84c311c7bfcc21e19cda19Paul Stewart // valid, and will not require an initial connection to rank it highly for 9183fee7e38845bc9512a84c311c7bfcc21e19cda19Paul Stewart // auto-connect. 9193fee7e38845bc9512a84c311c7bfcc21e19cda19Paul Stewart bool managed_credentials_; 920a388fdb2e74717ba2440a605f208647dd7cd3e06Peter Qiu // Flag indicating if this service is unreliable (experiencing multiple 921a388fdb2e74717ba2440a605f208647dd7cd3e06Peter Qiu // link monitor failures in a short period of time). 922a388fdb2e74717ba2440a605f208647dd7cd3e06Peter Qiu bool unreliable_; 9239d58193108f55edf0f06cd54f44464da633cb8aaPeter Qiu 924b54601c6f85577ab326da277356b88049d92ee2bmukesh agrawal DISALLOW_COPY_AND_ASSIGN(Service); 92575897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart}; 92675897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart 92775897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart} // namespace shill 92875897df1154ac38b7a4512a687241ad6a197ee40Paul Stewart 92919f83971a35d7f2c7b08aae6eb0abdc8e52ba057Ben Chan#endif // SHILL_SERVICE_H_ 930