mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 5 | #include "shill/service.h" |
| 6 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 7 | #include <time.h> |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 8 | #include <stdio.h> |
Chris Masone | ee929b7 | 2011-05-10 10:02:18 -0700 | [diff] [blame] | 9 | |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 10 | #include <map> |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 11 | #include <string> |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 12 | #include <vector> |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 13 | |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 14 | #include <base/memory/scoped_ptr.h> |
mukesh agrawal | 51a7e93 | 2011-07-27 16:18:26 -0700 | [diff] [blame] | 15 | #include <base/string_number_conversions.h> |
Paul Stewart | 2bf424f | 2012-04-11 18:59:39 -0700 | [diff] [blame] | 16 | #include <base/stringprintf.h> |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 17 | #include <chromeos/dbus/service_constants.h> |
Chris Masone | ee929b7 | 2011-05-10 10:02:18 -0700 | [diff] [blame] | 18 | |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 19 | #include "shill/connection.h" |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 20 | #include "shill/control_interface.h" |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 21 | #include "shill/error.h" |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 22 | #include "shill/http_proxy.h" |
Christopher Wiley | b691efd | 2012-08-09 13:51:51 -0700 | [diff] [blame] | 23 | #include "shill/logging.h" |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 24 | #include "shill/manager.h" |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 25 | #include "shill/metrics.h" |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 26 | #include "shill/profile.h" |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 27 | #include "shill/property_accessor.h" |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 28 | #include "shill/refptr_types.h" |
Chris Masone | d7732e4 | 2011-05-20 11:08:56 -0700 | [diff] [blame] | 29 | #include "shill/service_dbus_adaptor.h" |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 30 | #include "shill/sockets.h" |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 31 | #include "shill/store_interface.h" |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 32 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 33 | using base::Bind; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 34 | using std::map; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 35 | using std::string; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 36 | using std::vector; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 37 | |
| 38 | namespace shill { |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 39 | |
mukesh agrawal | bf14e94 | 2012-03-02 14:36:34 -0800 | [diff] [blame] | 40 | const char Service::kAutoConnConnected[] = "connected"; |
| 41 | const char Service::kAutoConnConnecting[] = "connecting"; |
| 42 | const char Service::kAutoConnExplicitDisconnect[] = "explicitly disconnected"; |
| 43 | const char Service::kAutoConnNotConnectable[] = "not connectable"; |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 44 | const char Service::kAutoConnThrottled[] = "throttled"; |
mukesh agrawal | bf14e94 | 2012-03-02 14:36:34 -0800 | [diff] [blame] | 45 | |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 46 | const size_t Service::kEAPMaxCertificationElements = 10; |
| 47 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 48 | const char Service::kCheckPortalAuto[] = "auto"; |
| 49 | const char Service::kCheckPortalFalse[] = "false"; |
| 50 | const char Service::kCheckPortalTrue[] = "true"; |
| 51 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 52 | const int Service::kPriorityNone = 0; |
| 53 | |
Darin Petkov | 2f903b3 | 2012-04-18 12:56:43 +0200 | [diff] [blame] | 54 | const char Service::kServiceSortAutoConnect[] = "AutoConnect"; |
| 55 | const char Service::kServiceSortConnectable[] = "Connectable"; |
| 56 | const char Service::kServiceSortFavorite[] = "Favorite"; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 57 | const char Service::kServiceSortIsConnected[] = "IsConnected"; |
| 58 | const char Service::kServiceSortIsConnecting[] = "IsConnecting"; |
| 59 | const char Service::kServiceSortIsFailed[] = "IsFailed"; |
Paul Stewart | a121c44 | 2012-06-09 14:12:58 -0700 | [diff] [blame] | 60 | const char Service::kServiceSortIsPortalled[] = "IsPortal"; |
Darin Petkov | 2f903b3 | 2012-04-18 12:56:43 +0200 | [diff] [blame] | 61 | const char Service::kServiceSortPriority[] = "Priority"; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 62 | const char Service::kServiceSortSecurityEtc[] = "SecurityEtc"; |
Darin Petkov | 2f903b3 | 2012-04-18 12:56:43 +0200 | [diff] [blame] | 63 | const char Service::kServiceSortTechnology[] = "Technology"; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 64 | const char Service::kServiceSortUniqueName[] = "UniqueName"; |
| 65 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 66 | const char Service::kStorageAutoConnect[] = "AutoConnect"; |
| 67 | const char Service::kStorageCheckPortal[] = "CheckPortal"; |
| 68 | const char Service::kStorageEapAnonymousIdentity[] = "EAP.AnonymousIdentity"; |
| 69 | const char Service::kStorageEapCACert[] = "EAP.CACert"; |
| 70 | const char Service::kStorageEapCACertID[] = "EAP.CACertID"; |
Paul Stewart | ecf4cd1 | 2012-04-17 11:08:39 -0700 | [diff] [blame] | 71 | const char Service::kStorageEapCACertNSS[] = "EAP.CACertNSS"; |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 72 | const char Service::kStorageEapCertID[] = "EAP.CertID"; |
| 73 | const char Service::kStorageEapClientCert[] = "EAP.ClientCert"; |
| 74 | const char Service::kStorageEapEap[] = "EAP.EAP"; |
| 75 | const char Service::kStorageEapIdentity[] = "EAP.Identity"; |
| 76 | const char Service::kStorageEapInnerEap[] = "EAP.InnerEAP"; |
| 77 | const char Service::kStorageEapKeyID[] = "EAP.KeyID"; |
| 78 | const char Service::kStorageEapKeyManagement[] = "EAP.KeyMgmt"; |
| 79 | const char Service::kStorageEapPIN[] = "EAP.PIN"; |
| 80 | const char Service::kStorageEapPassword[] = "EAP.Password"; |
| 81 | const char Service::kStorageEapPrivateKey[] = "EAP.PrivateKey"; |
| 82 | const char Service::kStorageEapPrivateKeyPassword[] = "EAP.PrivateKeyPassword"; |
| 83 | const char Service::kStorageEapUseSystemCAs[] = "EAP.UseSystemCAs"; |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 84 | const char Service::kStorageError[] = "Error"; |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 85 | const char Service::kStorageFavorite[] = "Favorite"; |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 86 | const char Service::kStorageGUID[] = "GUID"; |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 87 | const char Service::kStorageHasEverConnected[] = "HasEverConnected"; |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 88 | const char Service::kStorageName[] = "Name"; |
| 89 | const char Service::kStoragePriority[] = "Priority"; |
| 90 | const char Service::kStorageProxyConfig[] = "ProxyConfig"; |
| 91 | const char Service::kStorageSaveCredentials[] = "SaveCredentials"; |
Paul Stewart | 2706aaf | 2011-12-14 16:44:04 -0800 | [diff] [blame] | 92 | const char Service::kStorageType[] = "Type"; |
Paul Stewart | 987e71e | 2011-12-05 09:45:06 -0800 | [diff] [blame] | 93 | const char Service::kStorageUIData[] = "UIData"; |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 94 | |
mukesh agrawal | 8f3f775 | 2012-02-17 19:42:09 -0800 | [diff] [blame] | 95 | const uint8 Service::kStrengthMax = 100; |
| 96 | const uint8 Service::kStrengthMin = 0; |
| 97 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 98 | const uint64 Service::kMaxAutoConnectCooldownTimeMilliseconds = 30 * 60 * 1000; |
| 99 | const uint64 Service::kMinAutoConnectCooldownTimeMilliseconds = 1000; |
| 100 | const uint64 Service::kAutoConnectCooldownBackoffFactor = 2; |
| 101 | |
mukesh agrawal | 51a7e93 | 2011-07-27 16:18:26 -0700 | [diff] [blame] | 102 | // static |
| 103 | unsigned int Service::serial_number_ = 0; |
| 104 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 105 | Service::Service(ControlInterface *control_interface, |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 106 | EventDispatcher *dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 107 | Metrics *metrics, |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 108 | Manager *manager, |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 109 | Technology::Identifier technology) |
Eric Shienbrood | cc95c5d | 2012-03-30 15:25:49 -0400 | [diff] [blame] | 110 | : state_(kStateIdle), |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 111 | failure_(kFailureUnknown), |
| 112 | auto_connect_(false), |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 113 | check_portal_(kCheckPortalAuto), |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 114 | connectable_(false), |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 115 | error_(ConnectFailureToString(failure_)), |
mukesh agrawal | adb6848 | 2012-01-17 16:31:51 -0800 | [diff] [blame] | 116 | explicitly_disconnected_(false), |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 117 | favorite_(false), |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 118 | priority_(kPriorityNone), |
Paul Stewart | 1ca3e85 | 2011-11-04 07:50:49 -0700 | [diff] [blame] | 119 | security_level_(0), |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 120 | strength_(0), |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 121 | save_credentials_(true), |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 122 | technology_(technology), |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 123 | failed_time_(0), |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 124 | has_ever_connected_(false), |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 125 | auto_connect_cooldown_milliseconds_(0), |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 126 | dispatcher_(dispatcher), |
mukesh agrawal | d835b20 | 2011-10-07 15:26:47 -0700 | [diff] [blame] | 127 | unique_name_(base::UintToString(serial_number_++)), |
| 128 | friendly_name_(unique_name_), |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 129 | adaptor_(control_interface->CreateServiceAdaptor(this)), |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 130 | metrics_(metrics), |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 131 | manager_(manager), |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 132 | sockets_(new Sockets()), |
| 133 | weak_ptr_factory_(this) { |
Thieu Le | 284fe79 | 2012-01-31 17:53:19 -0800 | [diff] [blame] | 134 | HelpRegisterDerivedBool(flimflam::kAutoConnectProperty, |
| 135 | &Service::GetAutoConnect, |
| 136 | &Service::SetAutoConnect); |
Chris Masone | 4d42df8 | 2011-07-02 17:09:39 -0700 | [diff] [blame] | 137 | |
| 138 | // flimflam::kActivationStateProperty: Registered in CellularService |
| 139 | // flimflam::kCellularApnProperty: Registered in CellularService |
| 140 | // flimflam::kCellularLastGoodApnProperty: Registered in CellularService |
| 141 | // flimflam::kNetworkTechnologyProperty: Registered in CellularService |
Darin Petkov | 3335b37 | 2011-08-22 11:05:32 -0700 | [diff] [blame] | 142 | // flimflam::kOperatorNameProperty: DEPRECATED |
| 143 | // flimflam::kOperatorCodeProperty: DEPRECATED |
Chris Masone | 4d42df8 | 2011-07-02 17:09:39 -0700 | [diff] [blame] | 144 | // flimflam::kRoamingStateProperty: Registered in CellularService |
Darin Petkov | 3335b37 | 2011-08-22 11:05:32 -0700 | [diff] [blame] | 145 | // flimflam::kServingOperatorProperty: Registered in CellularService |
Chris Masone | 4d42df8 | 2011-07-02 17:09:39 -0700 | [diff] [blame] | 146 | // flimflam::kPaymentURLProperty: Registered in CellularService |
| 147 | |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 148 | HelpRegisterDerivedString(flimflam::kCheckPortalProperty, |
| 149 | &Service::GetCheckPortal, |
| 150 | &Service::SetCheckPortal); |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 151 | store_.RegisterConstBool(flimflam::kConnectableProperty, &connectable_); |
Jason Glasgow | acdc11f | 2012-03-30 14:12:22 -0400 | [diff] [blame] | 152 | HelpRegisterDerivedRpcIdentifier(flimflam::kDeviceProperty, |
| 153 | &Service::GetDeviceRpcId, |
| 154 | NULL); |
Paul Stewart | 4c56161 | 2012-03-21 12:49:01 -0700 | [diff] [blame] | 155 | store_.RegisterString(flimflam::kGuidProperty, &guid_); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 156 | |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 157 | store_.RegisterString(flimflam::kEapIdentityProperty, &eap_.identity); |
| 158 | store_.RegisterString(flimflam::kEAPEAPProperty, &eap_.eap); |
| 159 | store_.RegisterString(flimflam::kEapPhase2AuthProperty, &eap_.inner_eap); |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 160 | store_.RegisterString(flimflam::kEapAnonymousIdentityProperty, |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 161 | &eap_.anonymous_identity); |
| 162 | store_.RegisterString(flimflam::kEAPClientCertProperty, &eap_.client_cert); |
| 163 | store_.RegisterString(flimflam::kEAPCertIDProperty, &eap_.cert_id); |
| 164 | store_.RegisterString(flimflam::kEapPrivateKeyProperty, &eap_.private_key); |
mukesh agrawal | 292dc0f | 2012-01-26 18:02:46 -0800 | [diff] [blame] | 165 | HelpRegisterWriteOnlyDerivedString(flimflam::kEapPrivateKeyPasswordProperty, |
| 166 | &Service::SetEAPPrivateKeyPassword, |
| 167 | NULL, |
| 168 | &eap_.private_key_password); |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 169 | store_.RegisterString(flimflam::kEAPKeyIDProperty, &eap_.key_id); |
| 170 | store_.RegisterString(flimflam::kEapCaCertProperty, &eap_.ca_cert); |
| 171 | store_.RegisterString(flimflam::kEapCaCertIDProperty, &eap_.ca_cert_id); |
Paul Stewart | ecf4cd1 | 2012-04-17 11:08:39 -0700 | [diff] [blame] | 172 | store_.RegisterString(flimflam::kEapCaCertNssProperty, &eap_.ca_cert_nss); |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 173 | store_.RegisterString(flimflam::kEAPPINProperty, &eap_.pin); |
mukesh agrawal | 292dc0f | 2012-01-26 18:02:46 -0800 | [diff] [blame] | 174 | HelpRegisterWriteOnlyDerivedString(flimflam::kEapPasswordProperty, |
| 175 | &Service::SetEAPPassword, |
| 176 | NULL, |
| 177 | &eap_.password); |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 178 | store_.RegisterString(flimflam::kEapKeyMgmtProperty, &eap_.key_management); |
| 179 | store_.RegisterBool(flimflam::kEapUseSystemCAsProperty, &eap_.use_system_cas); |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 180 | store_.RegisterConstStrings(shill::kEapRemoteCertificationProperty, |
| 181 | &eap_.remote_certification); |
| 182 | store_.RegisterString(shill::kEapSubjectMatchProperty, |
| 183 | &eap_.subject_match); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 184 | |
Eric Shienbrood | cc95c5d | 2012-03-30 15:25:49 -0400 | [diff] [blame] | 185 | // TODO(ers): in flimflam clearing Error has the side-effect of |
| 186 | // setting the service state to IDLE. Is this important? I could |
| 187 | // see an autotest depending on it. |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 188 | store_.RegisterConstString(flimflam::kErrorProperty, &error_); |
| 189 | store_.RegisterConstBool(flimflam::kFavoriteProperty, &favorite_); |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 190 | HelpRegisterDerivedUint16(shill::kHTTPProxyPortProperty, |
| 191 | &Service::GetHTTPProxyPort, |
| 192 | NULL); |
Paul Stewart | 10241e3 | 2012-04-23 18:15:06 -0700 | [diff] [blame] | 193 | HelpRegisterDerivedRpcIdentifier(shill::kIPConfigProperty, |
| 194 | &Service::GetIPConfigRpcIdentifier, |
| 195 | NULL); |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 196 | HelpRegisterDerivedBool(flimflam::kIsActiveProperty, |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 197 | &Service::IsActive, |
| 198 | NULL); |
Chris Masone | 4d42df8 | 2011-07-02 17:09:39 -0700 | [diff] [blame] | 199 | // flimflam::kModeProperty: Registered in WiFiService |
Paul Stewart | 0c43833 | 2012-04-11 07:55:27 -0700 | [diff] [blame] | 200 | |
| 201 | // Although this is a read-only property, some callers want to blindly |
| 202 | // set this value to its current value. |
| 203 | HelpRegisterDerivedString(flimflam::kNameProperty, |
| 204 | &Service::GetNameProperty, |
| 205 | &Service::AssertTrivialSetNameProperty); |
Chris Masone | 4d42df8 | 2011-07-02 17:09:39 -0700 | [diff] [blame] | 206 | // flimflam::kPassphraseProperty: Registered in WiFiService |
| 207 | // flimflam::kPassphraseRequiredProperty: Registered in WiFiService |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 208 | store_.RegisterInt32(flimflam::kPriorityProperty, &priority_); |
| 209 | HelpRegisterDerivedString(flimflam::kProfileProperty, |
| 210 | &Service::GetProfileRpcId, |
Paul Stewart | 1b1a7f2 | 2012-01-06 16:24:06 -0800 | [diff] [blame] | 211 | &Service::SetProfileRpcId); |
Chris Masone | 4d42df8 | 2011-07-02 17:09:39 -0700 | [diff] [blame] | 212 | store_.RegisterString(flimflam::kProxyConfigProperty, &proxy_config_); |
Chris Masone | b2e326b | 2011-07-12 13:28:51 -0700 | [diff] [blame] | 213 | store_.RegisterBool(flimflam::kSaveCredentialsProperty, &save_credentials_); |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 214 | HelpRegisterDerivedString(flimflam::kTypeProperty, |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 215 | &Service::CalculateTechnology, |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 216 | NULL); |
Chris Masone | 4d42df8 | 2011-07-02 17:09:39 -0700 | [diff] [blame] | 217 | // flimflam::kSecurityProperty: Registered in WiFiService |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 218 | HelpRegisterDerivedString(flimflam::kStateProperty, |
| 219 | &Service::CalculateState, |
| 220 | NULL); |
Darin Petkov | d78ee7e | 2012-01-12 11:21:10 +0100 | [diff] [blame] | 221 | store_.RegisterConstUint8(flimflam::kSignalStrengthProperty, &strength_); |
Paul Stewart | 987e71e | 2011-12-05 09:45:06 -0800 | [diff] [blame] | 222 | store_.RegisterString(flimflam::kUIDataProperty, &ui_data_); |
Chris Masone | 4d42df8 | 2011-07-02 17:09:39 -0700 | [diff] [blame] | 223 | // flimflam::kWifiAuthMode: Registered in WiFiService |
| 224 | // flimflam::kWifiHiddenSsid: Registered in WiFiService |
| 225 | // flimflam::kWifiFrequency: Registered in WiFiService |
| 226 | // flimflam::kWifiPhyMode: Registered in WiFiService |
| 227 | // flimflam::kWifiHexSsid: Registered in WiFiService |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 228 | |
| 229 | metrics_->RegisterService(this); |
| 230 | |
Paul Stewart | 1062d9d | 2012-04-27 10:42:27 -0700 | [diff] [blame] | 231 | static_ip_parameters_.PlumbPropertyStore(&store_); |
| 232 | |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 233 | IgnoreParameterForConfigure(flimflam::kTypeProperty); |
Paul Stewart | 7f61e52 | 2012-03-22 11:13:45 -0700 | [diff] [blame] | 234 | IgnoreParameterForConfigure(flimflam::kProfileProperty); |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 235 | |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 236 | SLOG(Service, 2) << "Service initialized."; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 239 | Service::~Service() { |
Darin Petkov | 9cd7ca1 | 2012-07-03 11:06:40 +0200 | [diff] [blame] | 240 | LOG(INFO) << "Service destroyed: " << friendly_name_; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 241 | metrics_->DeregisterService(this); |
| 242 | } |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 243 | |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 244 | void Service::AutoConnect() { |
Darin Petkov | 3abc3be | 2012-06-27 10:48:23 +0200 | [diff] [blame] | 245 | const char *reason = NULL; |
| 246 | if (IsAutoConnectable(&reason)) { |
Darin Petkov | 9cd7ca1 | 2012-07-03 11:06:40 +0200 | [diff] [blame] | 247 | LOG(INFO) << "Auto-connecting to " << friendly_name_; |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 248 | ThrottleFutureAutoConnects(); |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 249 | Error error; |
| 250 | Connect(&error); |
mukesh agrawal | 76d1388 | 2012-01-12 15:23:11 -0800 | [diff] [blame] | 251 | } else { |
Darin Petkov | 9cd7ca1 | 2012-07-03 11:06:40 +0200 | [diff] [blame] | 252 | LOG(INFO) << "Suppressed autoconnect to " << friendly_name_ << " " |
mukesh agrawal | bf14e94 | 2012-03-02 14:36:34 -0800 | [diff] [blame] | 253 | << "(" << reason << ")"; |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 254 | } |
| 255 | } |
| 256 | |
mukesh agrawal | adb6848 | 2012-01-17 16:31:51 -0800 | [diff] [blame] | 257 | void Service::Connect(Error */*error*/) { |
| 258 | explicitly_disconnected_ = false; |
Eric Shienbrood | cc95c5d | 2012-03-30 15:25:49 -0400 | [diff] [blame] | 259 | // clear any failure state from a previous connect attempt |
| 260 | SetState(kStateIdle); |
mukesh agrawal | adb6848 | 2012-01-17 16:31:51 -0800 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | void Service::Disconnect(Error */*error*/) { |
Christopher Wiley | 3e7635e | 2012-08-15 09:46:17 -0700 | [diff] [blame] | 264 | MemoryLog::GetInstance()->FlushToDisk(); |
mukesh agrawal | adb6848 | 2012-01-17 16:31:51 -0800 | [diff] [blame] | 265 | } |
| 266 | |
Christopher Wiley | abd3b50 | 2012-09-26 13:08:52 -0700 | [diff] [blame] | 267 | void Service::DisconnectWithFailure(ConnectFailure failure, Error *error) { |
| 268 | Disconnect(error); |
| 269 | SetFailure(failure); |
| 270 | } |
| 271 | |
| 272 | void Service::UserInitiatedDisconnect(Error *error) { |
| 273 | Disconnect(error); |
| 274 | explicitly_disconnected_ = true; |
| 275 | } |
| 276 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 277 | void Service::ActivateCellularModem(const string &/*carrier*/, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 278 | Error *error, |
| 279 | const ResultCallback &/*callback*/) { |
| 280 | Error::PopulateAndLog(error, Error::kNotSupported, |
| 281 | "Service doesn't support cellular modem activation."); |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 282 | } |
| 283 | |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 284 | bool Service::IsActive(Error */*error*/) { |
Paul Stewart | bfb8255 | 2012-10-24 16:48:48 -0700 | [diff] [blame] | 285 | return state() != kStateUnknown && |
| 286 | state() != kStateIdle && |
| 287 | state() != kStateFailure; |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | void Service::SetState(ConnectState state) { |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 291 | LOG(INFO) << "In " << __func__ << "(): Service " << friendly_name_ |
| 292 | << " state " << ConnectStateToString(state_) << " -> " |
| 293 | << ConnectStateToString(state); |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 294 | |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 295 | if (state == state_) { |
| 296 | return; |
| 297 | } |
| 298 | |
| 299 | state_ = state; |
| 300 | if (state != kStateFailure) { |
| 301 | failure_ = kFailureUnknown; |
| 302 | } |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 303 | if (state == kStateConnected) { |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 304 | failed_time_ = 0; |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 305 | has_ever_connected_ = true; |
| 306 | SaveToProfile(); |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 307 | // When we succeed in connecting, forget that connects failed in the past. |
| 308 | // Give services one chance at a fast autoconnect retry by resetting the |
| 309 | // cooldown to 0 to indicate that the last connect was successful. |
| 310 | auto_connect_cooldown_milliseconds_ = 0; |
| 311 | reenable_auto_connect_task_.Cancel(); |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 312 | } |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 313 | UpdateErrorProperty(); |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 314 | manager_->UpdateService(this); |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 315 | metrics_->NotifyServiceStateChanged(this, state); |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 316 | adaptor_->EmitStringChanged(flimflam::kStateProperty, GetStateString()); |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 317 | } |
| 318 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 319 | void Service::ReEnableAutoConnectTask() { |
| 320 | // Kill the thing blocking AutoConnect(). |
| 321 | reenable_auto_connect_task_.Cancel(); |
| 322 | // Post to the manager, giving it an opportunity to AutoConnect again. |
| 323 | manager_->UpdateService(this); |
| 324 | } |
| 325 | |
| 326 | void Service::ThrottleFutureAutoConnects() { |
| 327 | if (auto_connect_cooldown_milliseconds_ > 0) { |
| 328 | LOG(INFO) << "Throttling autoconnect to " << friendly_name_ << " for " |
| 329 | << auto_connect_cooldown_milliseconds_ << " milliseconds."; |
| 330 | reenable_auto_connect_task_.Reset(Bind(&Service::ReEnableAutoConnectTask, |
| 331 | weak_ptr_factory_.GetWeakPtr())); |
| 332 | dispatcher_->PostDelayedTask(reenable_auto_connect_task_.callback(), |
| 333 | auto_connect_cooldown_milliseconds_); |
| 334 | } |
| 335 | auto_connect_cooldown_milliseconds_ = |
| 336 | std::min(kMaxAutoConnectCooldownTimeMilliseconds, |
| 337 | std::max(kMinAutoConnectCooldownTimeMilliseconds, |
| 338 | auto_connect_cooldown_milliseconds_ * |
| 339 | kAutoConnectCooldownBackoffFactor)); |
| 340 | } |
| 341 | |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 342 | void Service::SetFailure(ConnectFailure failure) { |
| 343 | failure_ = failure; |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 344 | failed_time_ = time(NULL); |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 345 | UpdateErrorProperty(); |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 346 | SetState(kStateFailure); |
| 347 | } |
| 348 | |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 349 | void Service::SetFailureSilent(ConnectFailure failure) { |
| 350 | // Note that order matters here, since SetState modifies |failure_| and |
| 351 | // |failed_time_|. |
| 352 | SetState(kStateIdle); |
| 353 | failure_ = failure; |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 354 | UpdateErrorProperty(); |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 355 | failed_time_ = time(NULL); |
| 356 | } |
| 357 | |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 358 | string Service::GetRpcIdentifier() const { |
Chris Masone | 3c3f6a1 | 2011-07-01 10:01:41 -0700 | [diff] [blame] | 359 | return adaptor_->GetRpcIdentifier(); |
| 360 | } |
| 361 | |
Paul Stewart | bba6a5b | 2011-11-02 18:45:59 -0700 | [diff] [blame] | 362 | bool Service::IsLoadableFrom(StoreInterface *storage) const { |
| 363 | return storage->ContainsGroup(GetStorageIdentifier()); |
| 364 | } |
| 365 | |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 366 | bool Service::Load(StoreInterface *storage) { |
| 367 | const string id = GetStorageIdentifier(); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 368 | if (!storage->ContainsGroup(id)) { |
| 369 | LOG(WARNING) << "Service is not available in the persistent store: " << id; |
| 370 | return false; |
| 371 | } |
| 372 | storage->GetBool(id, kStorageAutoConnect, &auto_connect_); |
| 373 | storage->GetString(id, kStorageCheckPortal, &check_portal_); |
| 374 | storage->GetBool(id, kStorageFavorite, &favorite_); |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 375 | storage->GetString(id, kStorageGUID, &guid_); |
| 376 | storage->GetBool(id, kStorageHasEverConnected, &has_ever_connected_); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 377 | storage->GetInt(id, kStoragePriority, &priority_); |
| 378 | storage->GetString(id, kStorageProxyConfig, &proxy_config_); |
| 379 | storage->GetBool(id, kStorageSaveCredentials, &save_credentials_); |
Paul Stewart | 987e71e | 2011-12-05 09:45:06 -0800 | [diff] [blame] | 380 | storage->GetString(id, kStorageUIData, &ui_data_); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 381 | |
| 382 | LoadEapCredentials(storage, id); |
Paul Stewart | 1062d9d | 2012-04-27 10:42:27 -0700 | [diff] [blame] | 383 | static_ip_parameters_.Load(storage, id); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 384 | // TODO(petkov): Load these: |
| 385 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 386 | // "Failure" |
| 387 | // "Modified" |
| 388 | // "LastAttempt" |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 389 | |
mukesh agrawal | adb6848 | 2012-01-17 16:31:51 -0800 | [diff] [blame] | 390 | explicitly_disconnected_ = false; |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 391 | favorite_ = true; |
| 392 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 393 | return true; |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 394 | } |
| 395 | |
Paul Stewart | 65512e1 | 2012-03-26 18:01:08 -0700 | [diff] [blame] | 396 | bool Service::Unload() { |
Paul Stewart | 7fb0938 | 2012-07-18 17:32:27 -0700 | [diff] [blame] | 397 | auto_connect_ = IsAutoConnectByDefault(); |
Paul Stewart | d8ad3c4 | 2012-01-09 12:39:38 -0800 | [diff] [blame] | 398 | check_portal_ = kCheckPortalAuto; |
Christopher Wiley | abd3b50 | 2012-09-26 13:08:52 -0700 | [diff] [blame] | 399 | explicitly_disconnected_ = false; |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 400 | favorite_ = false; |
Paul Stewart | e7cce8f | 2012-09-11 10:56:38 -0700 | [diff] [blame] | 401 | guid_ = ""; |
Paul Stewart | 88769de | 2012-09-21 13:14:36 -0700 | [diff] [blame] | 402 | has_ever_connected_ = false; |
Paul Stewart | d8ad3c4 | 2012-01-09 12:39:38 -0800 | [diff] [blame] | 403 | priority_ = kPriorityNone; |
| 404 | proxy_config_ = ""; |
| 405 | save_credentials_ = true; |
| 406 | ui_data_ = ""; |
| 407 | |
| 408 | UnloadEapCredentials(); |
Wade Guthrie | 9e0c250 | 2012-04-19 15:26:40 -0700 | [diff] [blame] | 409 | Error error; // Ignored. |
| 410 | Disconnect(&error); |
Paul Stewart | 65512e1 | 2012-03-26 18:01:08 -0700 | [diff] [blame] | 411 | return false; |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 412 | } |
| 413 | |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 414 | bool Service::Save(StoreInterface *storage) { |
| 415 | const string id = GetStorageIdentifier(); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 416 | |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 417 | storage->SetString(id, kStorageType, GetTechnologyString()); |
Paul Stewart | 2706aaf | 2011-12-14 16:44:04 -0800 | [diff] [blame] | 418 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 419 | // TODO(petkov): We could choose to simplify the saving code by removing most |
| 420 | // conditionals thus saving even default values. |
Wade Guthrie | 4f28e8b | 2012-04-11 10:52:07 -0700 | [diff] [blame] | 421 | storage->SetBool(id, kStorageAutoConnect, auto_connect_); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 422 | if (check_portal_ == kCheckPortalAuto) { |
| 423 | storage->DeleteKey(id, kStorageCheckPortal); |
| 424 | } else { |
| 425 | storage->SetString(id, kStorageCheckPortal, check_portal_); |
| 426 | } |
| 427 | storage->SetBool(id, kStorageFavorite, favorite_); |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 428 | SaveString(storage, id, kStorageGUID, guid_, false, true); |
| 429 | storage->SetBool(id, kStorageHasEverConnected, has_ever_connected_); |
mukesh agrawal | d835b20 | 2011-10-07 15:26:47 -0700 | [diff] [blame] | 430 | storage->SetString(id, kStorageName, friendly_name_); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 431 | if (priority_ != kPriorityNone) { |
| 432 | storage->SetInt(id, kStoragePriority, priority_); |
| 433 | } else { |
| 434 | storage->DeleteKey(id, kStoragePriority); |
| 435 | } |
Paul Stewart | 987e71e | 2011-12-05 09:45:06 -0800 | [diff] [blame] | 436 | SaveString(storage, id, kStorageProxyConfig, proxy_config_, false, true); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 437 | if (save_credentials_) { |
| 438 | storage->DeleteKey(id, kStorageSaveCredentials); |
| 439 | } else { |
| 440 | storage->SetBool(id, kStorageSaveCredentials, false); |
| 441 | } |
Paul Stewart | 987e71e | 2011-12-05 09:45:06 -0800 | [diff] [blame] | 442 | SaveString(storage, id, kStorageUIData, ui_data_, false, true); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 443 | |
| 444 | SaveEapCredentials(storage, id); |
Paul Stewart | 1062d9d | 2012-04-27 10:42:27 -0700 | [diff] [blame] | 445 | static_ip_parameters_.Save(storage, id); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 446 | |
| 447 | // TODO(petkov): Save these: |
| 448 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 449 | // "Failure" |
| 450 | // "Modified" |
| 451 | // "LastAttempt" |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 452 | |
| 453 | return true; |
| 454 | } |
| 455 | |
Gary Morain | d93615e | 2012-04-27 11:50:03 -0700 | [diff] [blame] | 456 | void Service::SaveToCurrentProfile() { |
| 457 | // Some unittests do not specify a manager. |
| 458 | if (manager()) { |
| 459 | manager()->SaveServiceToProfile(this); |
| 460 | } |
Thieu Le | d4e9e55 | 2012-02-16 16:26:07 -0800 | [diff] [blame] | 461 | } |
| 462 | |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 463 | void Service::Configure(const KeyValueStore &args, Error *error) { |
| 464 | map<string, bool>::const_iterator bool_it; |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 465 | SLOG(Service, 5) << "Configuring bool properties:"; |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 466 | for (bool_it = args.bool_properties().begin(); |
| 467 | bool_it != args.bool_properties().end(); |
| 468 | ++bool_it) { |
| 469 | if (ContainsKey(parameters_ignored_for_configure_, bool_it->first)) { |
| 470 | continue; |
| 471 | } |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 472 | SLOG(Service, 5) << " " << bool_it->first; |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 473 | Error set_error; |
| 474 | store_.SetBoolProperty(bool_it->first, bool_it->second, &set_error); |
| 475 | if (error->IsSuccess() && set_error.IsFailure()) { |
| 476 | error->CopyFrom(set_error); |
| 477 | } |
| 478 | } |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 479 | SLOG(Service, 5) << "Configuring string properties:"; |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 480 | map<string, string>::const_iterator string_it; |
| 481 | for (string_it = args.string_properties().begin(); |
| 482 | string_it != args.string_properties().end(); |
| 483 | ++string_it) { |
| 484 | if (ContainsKey(parameters_ignored_for_configure_, string_it->first)) { |
| 485 | continue; |
| 486 | } |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 487 | SLOG(Service, 5) << " " << string_it->first; |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 488 | Error set_error; |
| 489 | store_.SetStringProperty(string_it->first, string_it->second, &set_error); |
| 490 | if (error->IsSuccess() && set_error.IsFailure()) { |
| 491 | error->CopyFrom(set_error); |
| 492 | } |
| 493 | } |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 494 | SLOG(Service, 5) << "Configuring uint32 properties:"; |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 495 | map<string, uint32>::const_iterator int_it; |
| 496 | for (int_it = args.uint_properties().begin(); |
| 497 | int_it != args.uint_properties().end(); |
| 498 | ++int_it) { |
| 499 | if (ContainsKey(parameters_ignored_for_configure_, int_it->first)) { |
| 500 | continue; |
| 501 | } |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 502 | SLOG(Service, 5) << " " << int_it->first; |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 503 | Error set_error; |
| 504 | store_.SetUint32Property(int_it->first, int_it->second, &set_error); |
| 505 | if (error->IsSuccess() && set_error.IsFailure()) { |
| 506 | error->CopyFrom(set_error); |
| 507 | } |
| 508 | } |
| 509 | } |
| 510 | |
Paul Stewart | 10ccbb3 | 2012-04-26 15:59:30 -0700 | [diff] [blame] | 511 | bool Service::IsRemembered() const { |
| 512 | return profile_ && !manager_->IsServiceEphemeral(this); |
| 513 | } |
| 514 | |
mukesh agrawal | 00917ce | 2011-11-22 23:56:55 +0000 | [diff] [blame] | 515 | void Service::MakeFavorite() { |
| 516 | if (favorite_) { |
| 517 | // We do not want to clobber the value of auto_connect_ (it may |
| 518 | // be user-set). So return early. |
| 519 | return; |
| 520 | } |
| 521 | |
| 522 | auto_connect_ = true; |
| 523 | favorite_ = true; |
| 524 | } |
| 525 | |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 526 | void Service::SetConnection(const ConnectionRefPtr &connection) { |
Paul Stewart | c1dec4d | 2011-12-08 15:25:28 -0800 | [diff] [blame] | 527 | if (connection.get()) { |
Paul Stewart | 1e3bc496 | 2012-09-14 12:20:22 -0700 | [diff] [blame] | 528 | // TODO(pstew): Make this function testable by using a factory here. |
| 529 | // http://crosbug.com/34528 |
Paul Stewart | c8f4bef | 2011-12-13 09:45:51 -0800 | [diff] [blame] | 530 | http_proxy_.reset(new HTTPProxy(connection)); |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 531 | http_proxy_->Start(dispatcher_, sockets_.get()); |
Paul Stewart | c1dec4d | 2011-12-08 15:25:28 -0800 | [diff] [blame] | 532 | } else { |
| 533 | http_proxy_.reset(); |
Paul Stewart | def189e | 2012-08-02 20:12:09 -0700 | [diff] [blame] | 534 | static_ip_parameters_.ClearSavedParameters(); |
Paul Stewart | c1dec4d | 2011-12-08 15:25:28 -0800 | [diff] [blame] | 535 | } |
| 536 | connection_ = connection; |
Paul Stewart | 1e3bc496 | 2012-09-14 12:20:22 -0700 | [diff] [blame] | 537 | Error error; |
| 538 | string ipconfig = GetIPConfigRpcIdentifier(&error); |
| 539 | if (error.IsSuccess()) { |
| 540 | adaptor_->EmitRpcIdentifierChanged(shill::kIPConfigProperty, ipconfig); |
| 541 | } |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 542 | } |
| 543 | |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 544 | bool Service::Is8021xConnectable() const { |
| 545 | // We mirror all the flimflam checks (see service.c:is_connectable()). |
| 546 | |
| 547 | // Identity is required. |
| 548 | if (eap_.identity.empty()) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 549 | SLOG(Service, 2) << "Not connectable: Identity is empty."; |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 550 | return false; |
| 551 | } |
| 552 | |
| 553 | if (!eap_.client_cert.empty() || !eap_.cert_id.empty()) { |
| 554 | // If a client certificate is being used, we must have a private key. |
| 555 | if (eap_.private_key.empty() && eap_.key_id.empty()) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 556 | SLOG(Service, 2) |
| 557 | << "Not connectable. Client certificate but no private key."; |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 558 | return false; |
| 559 | } |
| 560 | } |
| 561 | if (!eap_.cert_id.empty() || !eap_.key_id.empty() || |
| 562 | !eap_.ca_cert_id.empty()) { |
| 563 | // If PKCS#11 data is needed, a PIN is required. |
| 564 | if (eap_.pin.empty()) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 565 | SLOG(Service, 2) << "Not connectable. PKCS#11 data but no PIN."; |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 566 | return false; |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | // For EAP-TLS, a client certificate is required. |
| 571 | if (eap_.eap.empty() || eap_.eap == "TLS") { |
Paul Stewart | 8142613 | 2012-05-16 10:05:10 -0700 | [diff] [blame] | 572 | if ((!eap_.client_cert.empty() || !eap_.cert_id.empty()) && |
| 573 | (!eap_.private_key.empty() || !eap_.key_id.empty())) { |
| 574 | SLOG(Service, 2) << "Connectable. EAP-TLS with a client cert and key."; |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 575 | return true; |
| 576 | } |
| 577 | } |
| 578 | |
| 579 | // For EAP types other than TLS (e.g. EAP-TTLS or EAP-PEAP, password is the |
| 580 | // minimum requirement), at least an identity + password is required. |
| 581 | if (eap_.eap.empty() || eap_.eap != "TLS") { |
| 582 | if (!eap_.password.empty()) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 583 | SLOG(Service, 2) << "Connectable. !EAP-TLS and has a password."; |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 584 | return true; |
| 585 | } |
| 586 | } |
| 587 | |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 588 | SLOG(Service, 2) |
| 589 | << "Not connectable. No suitable EAP configuration was found."; |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 590 | return false; |
| 591 | } |
| 592 | |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 593 | bool Service::AddEAPCertification(const string &name, size_t depth) { |
| 594 | if (depth >= kEAPMaxCertificationElements) { |
| 595 | LOG(WARNING) << "Ignoring certification " << name |
| 596 | << " because depth " << depth |
| 597 | << " exceeds our maximum of " |
| 598 | << kEAPMaxCertificationElements; |
| 599 | return false; |
| 600 | } |
| 601 | |
| 602 | if (depth >= eap_.remote_certification.size()) { |
| 603 | eap_.remote_certification.resize(depth + 1); |
| 604 | } else if (name == eap_.remote_certification[depth]) { |
| 605 | return true; |
| 606 | } |
| 607 | |
| 608 | eap_.remote_certification[depth] = name; |
| 609 | LOG(INFO) << "Received certification for " |
| 610 | << name |
| 611 | << " at depth " |
| 612 | << depth; |
| 613 | return true; |
| 614 | } |
| 615 | |
| 616 | void Service::ClearEAPCertification() { |
| 617 | eap_.remote_certification.clear(); |
| 618 | } |
| 619 | |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 620 | void Service::set_eap(const EapCredentials &eap) { |
| 621 | eap_ = eap; |
| 622 | // Note: Connectability can only be updated by a subclass of Service |
| 623 | // with knowledge of whether the service actually uses 802.1x credentials. |
| 624 | } |
| 625 | |
mukesh agrawal | 00917ce | 2011-11-22 23:56:55 +0000 | [diff] [blame] | 626 | // static |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 627 | const char *Service::ConnectFailureToString(const ConnectFailure &state) { |
| 628 | switch (state) { |
| 629 | case kFailureUnknown: |
| 630 | return "Unknown"; |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 631 | case kFailureAAA: |
| 632 | return flimflam::kErrorAaaFailed; |
| 633 | case kFailureActivation: |
| 634 | return flimflam::kErrorActivationFailed; |
| 635 | case kFailureBadPassphrase: |
| 636 | return flimflam::kErrorBadPassphrase; |
| 637 | case kFailureBadWEPKey: |
| 638 | return flimflam::kErrorBadWEPKey; |
| 639 | case kFailureConnect: |
| 640 | return flimflam::kErrorConnectFailed; |
| 641 | case kFailureDNSLookup: |
| 642 | return flimflam::kErrorDNSLookupFailed; |
| 643 | case kFailureDHCP: |
| 644 | return flimflam::kErrorDhcpFailed; |
| 645 | case kFailureHTTPGet: |
| 646 | return flimflam::kErrorHTTPGetFailed; |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 647 | case kFailureNeedEVDO: |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 648 | return flimflam::kErrorNeedEvdo; |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 649 | case kFailureNeedHomeNetwork: |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 650 | return flimflam::kErrorNeedHomeNetwork; |
| 651 | case kFailureOTASP: |
| 652 | return flimflam::kErrorOtaspFailed; |
| 653 | case kFailureOutOfRange: |
| 654 | return flimflam::kErrorOutOfRange; |
| 655 | case kFailurePinMissing: |
| 656 | return flimflam::kErrorPinMissing; |
| 657 | case kFailurePPPAuth: |
| 658 | return flimflam::kErrorPppAuthFailed; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 659 | case kFailureMax: |
| 660 | return "Max failure error code"; |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 661 | } |
| 662 | return "Invalid"; |
| 663 | } |
| 664 | |
| 665 | // static |
| 666 | const char *Service::ConnectStateToString(const ConnectState &state) { |
| 667 | switch (state) { |
| 668 | case kStateUnknown: |
| 669 | return "Unknown"; |
| 670 | case kStateIdle: |
| 671 | return "Idle"; |
| 672 | case kStateAssociating: |
| 673 | return "Associating"; |
| 674 | case kStateConfiguring: |
| 675 | return "Configuring"; |
| 676 | case kStateConnected: |
| 677 | return "Connected"; |
| 678 | case kStateDisconnected: |
| 679 | return "Disconnected"; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 680 | case kStatePortal: |
| 681 | return "Portal"; |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 682 | case kStateFailure: |
| 683 | return "Failure"; |
| 684 | case kStateOnline: |
| 685 | return "Online"; |
| 686 | } |
| 687 | return "Invalid"; |
| 688 | } |
| 689 | |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 690 | string Service::GetTechnologyString() const { |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 691 | return Technology::NameFromIdentifier(technology()); |
| 692 | } |
| 693 | |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 694 | string Service::CalculateTechnology(Error */*error*/) { |
| 695 | return GetTechnologyString(); |
| 696 | } |
| 697 | |
Jason Glasgow | b579005 | 2012-01-27 01:03:52 -0500 | [diff] [blame] | 698 | // static |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 699 | bool Service::DecideBetween(int a, int b, bool *decision) { |
| 700 | if (a == b) |
| 701 | return false; |
| 702 | *decision = (a > b); |
| 703 | return true; |
| 704 | } |
| 705 | |
mukesh agrawal | 00917ce | 2011-11-22 23:56:55 +0000 | [diff] [blame] | 706 | // static |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 707 | bool Service::Compare(ServiceRefPtr a, |
| 708 | ServiceRefPtr b, |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 709 | const vector<Technology::Identifier> &tech_order, |
| 710 | const char **reason) { |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 711 | bool ret; |
| 712 | |
| 713 | if (a->state() != b->state()) { |
| 714 | if (DecideBetween(a->IsConnected(), b->IsConnected(), &ret)) { |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 715 | *reason = kServiceSortIsConnected; |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 716 | return ret; |
| 717 | } |
| 718 | |
Paul Stewart | a121c44 | 2012-06-09 14:12:58 -0700 | [diff] [blame] | 719 | if (DecideBetween(!a->IsPortalled(), !b->IsPortalled(), &ret)) { |
| 720 | *reason = kServiceSortIsPortalled; |
| 721 | return ret; |
| 722 | } |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 723 | |
| 724 | if (DecideBetween(a->IsConnecting(), b->IsConnecting(), &ret)) { |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 725 | *reason = kServiceSortIsConnecting; |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 726 | return ret; |
| 727 | } |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 728 | |
| 729 | if (DecideBetween(!a->IsFailed(), !b->IsFailed(), &ret)) { |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 730 | *reason = kServiceSortIsFailed; |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 731 | return ret; |
| 732 | } |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 733 | } |
| 734 | |
Darin Petkov | 2f903b3 | 2012-04-18 12:56:43 +0200 | [diff] [blame] | 735 | if (DecideBetween(a->connectable(), b->connectable(), &ret)) { |
| 736 | *reason = kServiceSortConnectable; |
| 737 | return ret; |
| 738 | } |
| 739 | |
| 740 | // Ignore the auto-connect property if both services are connected |
| 741 | // already. This allows connected non-autoconnectable VPN services to be |
| 742 | // sorted higher than other connected services based on technology order. |
| 743 | if (!a->IsConnected() && |
| 744 | DecideBetween(a->auto_connect(), b->auto_connect(), &ret)) { |
| 745 | *reason = kServiceSortAutoConnect; |
| 746 | return ret; |
| 747 | } |
| 748 | |
| 749 | if (DecideBetween(a->favorite(), b->favorite(), &ret)) { |
| 750 | *reason = kServiceSortFavorite; |
| 751 | return ret; |
| 752 | } |
| 753 | |
| 754 | if (DecideBetween(a->priority(), b->priority(), &ret)) { |
| 755 | *reason = kServiceSortPriority; |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 756 | return ret; |
| 757 | } |
| 758 | |
| 759 | // TODO(pstew): Below this point we are making value judgements on |
| 760 | // services that are not related to anything intrinsic or |
| 761 | // user-specified. These heuristics should be richer (contain |
| 762 | // historical information, for example) and be subject to user |
| 763 | // customization. |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 764 | for (vector<Technology::Identifier>::const_iterator it = tech_order.begin(); |
| 765 | it != tech_order.end(); |
| 766 | ++it) { |
Joshua Kroll | 053fa82 | 2012-06-05 09:50:43 -0700 | [diff] [blame] | 767 | if (DecideBetween(a->technology() == *it, b->technology() == *it, &ret)) { |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 768 | *reason = kServiceSortTechnology; |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 769 | return ret; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 770 | } |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 771 | } |
| 772 | |
Paul Stewart | 1ca3e85 | 2011-11-04 07:50:49 -0700 | [diff] [blame] | 773 | if (DecideBetween(a->security_level(), b->security_level(), &ret) || |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 774 | DecideBetween(a->strength(), b->strength(), &ret)) { |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 775 | *reason = kServiceSortSecurityEtc; |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 776 | return ret; |
| 777 | } |
| 778 | |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 779 | *reason = kServiceSortUniqueName; |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 780 | return a->UniqueName() < b->UniqueName(); |
| 781 | } |
| 782 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 783 | const ProfileRefPtr &Service::profile() const { return profile_; } |
| 784 | |
| 785 | void Service::set_profile(const ProfileRefPtr &p) { profile_ = p; } |
| 786 | |
Paul Stewart | ff14b02 | 2012-04-24 20:06:23 -0700 | [diff] [blame] | 787 | void Service::OnPropertyChanged(const string &property) { |
Paul Stewart | 8142613 | 2012-05-16 10:05:10 -0700 | [diff] [blame] | 788 | if (Is8021x() && |
| 789 | (property == flimflam::kEAPCertIDProperty || |
| 790 | property == flimflam::kEAPClientCertProperty || |
| 791 | property == flimflam::kEAPKeyIDProperty || |
| 792 | property == flimflam::kEAPPINProperty || |
| 793 | property == flimflam::kEapCaCertIDProperty || |
| 794 | property == flimflam::kEapIdentityProperty || |
Paul Stewart | adf79d8 | 2012-07-18 16:09:56 -0700 | [diff] [blame] | 795 | property == flimflam::kEapKeyMgmtProperty || |
Paul Stewart | 8142613 | 2012-05-16 10:05:10 -0700 | [diff] [blame] | 796 | property == flimflam::kEapPasswordProperty || |
| 797 | property == flimflam::kEapPrivateKeyProperty)) { |
| 798 | // This notifies subclassess that EAP parameters have been changed. |
| 799 | set_eap(eap_); |
| 800 | } |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 801 | SaveToProfile(); |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 802 | if ((property == flimflam::kCheckPortalProperty || |
| 803 | property == flimflam::kProxyConfigProperty) && |
| 804 | (state_ == kStateConnected || |
| 805 | state_ == kStatePortal || |
| 806 | state_ == kStateOnline)) { |
| 807 | manager_->RecheckPortalOnService(this); |
| 808 | } |
Paul Stewart | ff14b02 | 2012-04-24 20:06:23 -0700 | [diff] [blame] | 809 | } |
| 810 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 811 | void Service::OnAfterResume() { |
| 812 | // Forget old autoconnect failures across suspend/resume. |
| 813 | auto_connect_cooldown_milliseconds_ = 0; |
| 814 | reenable_auto_connect_task_.Cancel(); |
Christopher Wiley | a4c61ae | 2012-10-01 11:04:30 -0700 | [diff] [blame] | 815 | // Forget if the user disconnected us, we might be able to connect now. |
| 816 | explicitly_disconnected_ = false; |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 817 | } |
| 818 | |
Paul Stewart | 10241e3 | 2012-04-23 18:15:06 -0700 | [diff] [blame] | 819 | string Service::GetIPConfigRpcIdentifier(Error *error) { |
| 820 | if (!connection_) { |
| 821 | error->Populate(Error::kNotFound); |
| 822 | return "/"; |
| 823 | } |
| 824 | |
| 825 | string id = connection_->ipconfig_rpc_identifier(); |
| 826 | |
| 827 | if (id.empty()) { |
| 828 | // Do not return an empty IPConfig. |
| 829 | error->Populate(Error::kNotFound); |
| 830 | return "/"; |
| 831 | } |
| 832 | |
| 833 | return id; |
| 834 | } |
| 835 | |
mukesh agrawal | 29c13a1 | 2011-11-24 00:09:19 +0000 | [diff] [blame] | 836 | void Service::set_connectable(bool connectable) { |
| 837 | connectable_ = connectable; |
| 838 | adaptor_->EmitBoolChanged(flimflam::kConnectableProperty, connectable_); |
| 839 | } |
| 840 | |
Darin Petkov | b2ba39f | 2012-06-06 10:33:43 +0200 | [diff] [blame] | 841 | void Service::SetConnectable(bool connectable) { |
| 842 | if (connectable_ == connectable) { |
| 843 | return; |
| 844 | } |
| 845 | connectable_ = connectable; |
| 846 | adaptor_->EmitBoolChanged(flimflam::kConnectableProperty, connectable_); |
| 847 | if (manager_->HasService(this)) { |
| 848 | manager_->UpdateService(this); |
| 849 | } |
| 850 | } |
| 851 | |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 852 | string Service::GetStateString() const { |
mukesh agrawal | f2f68a5 | 2011-09-01 12:15:48 -0700 | [diff] [blame] | 853 | switch (state_) { |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 854 | case kStateIdle: |
| 855 | return flimflam::kStateIdle; |
| 856 | case kStateAssociating: |
| 857 | return flimflam::kStateAssociation; |
| 858 | case kStateConfiguring: |
| 859 | return flimflam::kStateConfiguration; |
mukesh agrawal | f2f68a5 | 2011-09-01 12:15:48 -0700 | [diff] [blame] | 860 | case kStateConnected: |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 861 | return flimflam::kStateReady; |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 862 | case kStateDisconnected: |
| 863 | return flimflam::kStateDisconnect; |
| 864 | case kStateFailure: |
| 865 | return flimflam::kStateFailure; |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 866 | case kStatePortal: |
| 867 | return flimflam::kStatePortal; |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 868 | case kStateOnline: |
| 869 | return flimflam::kStateOnline; |
| 870 | case kStateUnknown: |
mukesh agrawal | f2f68a5 | 2011-09-01 12:15:48 -0700 | [diff] [blame] | 871 | default: |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 872 | return ""; |
mukesh agrawal | f2f68a5 | 2011-09-01 12:15:48 -0700 | [diff] [blame] | 873 | } |
| 874 | } |
| 875 | |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 876 | string Service::CalculateState(Error */*error*/) { |
| 877 | return GetStateString(); |
| 878 | } |
| 879 | |
mukesh agrawal | bf14e94 | 2012-03-02 14:36:34 -0800 | [diff] [blame] | 880 | bool Service::IsAutoConnectable(const char **reason) const { |
| 881 | if (!connectable()) { |
| 882 | *reason = kAutoConnNotConnectable; |
| 883 | return false; |
| 884 | } |
| 885 | |
| 886 | if (IsConnected()) { |
| 887 | *reason = kAutoConnConnected; |
| 888 | return false; |
| 889 | } |
| 890 | |
| 891 | if (IsConnecting()) { |
| 892 | *reason = kAutoConnConnecting; |
| 893 | return false; |
| 894 | } |
| 895 | |
| 896 | if (explicitly_disconnected_) { |
| 897 | *reason = kAutoConnExplicitDisconnect; |
| 898 | return false; |
| 899 | } |
| 900 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 901 | if (!reenable_auto_connect_task_.IsCancelled()) { |
| 902 | *reason = kAutoConnThrottled; |
| 903 | return false; |
| 904 | } |
| 905 | |
mukesh agrawal | bf14e94 | 2012-03-02 14:36:34 -0800 | [diff] [blame] | 906 | return true; |
mukesh agrawal | 76d1388 | 2012-01-12 15:23:11 -0800 | [diff] [blame] | 907 | } |
| 908 | |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 909 | bool Service::IsPortalDetectionDisabled() const { |
| 910 | return check_portal_ == kCheckPortalFalse; |
| 911 | } |
| 912 | |
| 913 | bool Service::IsPortalDetectionAuto() const { |
| 914 | return check_portal_ == kCheckPortalAuto; |
| 915 | } |
| 916 | |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 917 | void Service::HelpRegisterDerivedBool( |
| 918 | const string &name, |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 919 | bool(Service::*get)(Error *), |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 920 | void(Service::*set)(const bool&, Error *)) { |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 921 | store_.RegisterDerivedBool( |
| 922 | name, |
| 923 | BoolAccessor(new CustomAccessor<Service, bool>(this, get, set))); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 924 | } |
| 925 | |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 926 | void Service::HelpRegisterDerivedString( |
| 927 | const string &name, |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 928 | string(Service::*get)(Error *), |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 929 | void(Service::*set)(const string&, Error *)) { |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 930 | store_.RegisterDerivedString( |
| 931 | name, |
| 932 | StringAccessor(new CustomAccessor<Service, string>(this, get, set))); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 933 | } |
| 934 | |
Jason Glasgow | acdc11f | 2012-03-30 14:12:22 -0400 | [diff] [blame] | 935 | void Service::HelpRegisterDerivedRpcIdentifier( |
| 936 | const string &name, |
| 937 | RpcIdentifier(Service::*get)(Error *), |
| 938 | void(Service::*set)(const RpcIdentifier&, Error *)) { |
| 939 | store_.RegisterDerivedRpcIdentifier( |
| 940 | name, |
| 941 | RpcIdentifierAccessor(new CustomAccessor<Service, RpcIdentifier>( |
| 942 | this, get, set))); |
| 943 | } |
| 944 | |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 945 | void Service::HelpRegisterDerivedUint16( |
| 946 | const string &name, |
| 947 | uint16(Service::*get)(Error *), |
| 948 | void(Service::*set)(const uint16&, Error *)) { |
| 949 | store_.RegisterDerivedUint16( |
| 950 | name, |
| 951 | Uint16Accessor(new CustomAccessor<Service, uint16>(this, get, set))); |
| 952 | } |
| 953 | |
mukesh agrawal | 292dc0f | 2012-01-26 18:02:46 -0800 | [diff] [blame] | 954 | void Service::HelpRegisterWriteOnlyDerivedString( |
| 955 | const string &name, |
| 956 | void(Service::*set)(const string &, Error *), |
| 957 | void(Service::*clear)(Error *), |
| 958 | const string *default_value) { |
| 959 | store_.RegisterDerivedString( |
| 960 | name, |
| 961 | StringAccessor( |
| 962 | new CustomWriteOnlyAccessor<Service, string>( |
| 963 | this, set, clear, default_value))); |
| 964 | } |
| 965 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 966 | void Service::SaveString(StoreInterface *storage, |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 967 | const string &id, |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 968 | const string &key, |
| 969 | const string &value, |
| 970 | bool crypted, |
| 971 | bool save) { |
| 972 | if (value.empty() || !save) { |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 973 | storage->DeleteKey(id, key); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 974 | return; |
| 975 | } |
| 976 | if (crypted) { |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 977 | storage->SetCryptedString(id, key, value); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 978 | return; |
| 979 | } |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 980 | storage->SetString(id, key, value); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 981 | } |
| 982 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 983 | void Service::LoadEapCredentials(StoreInterface *storage, const string &id) { |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 984 | EapCredentials eap; |
| 985 | storage->GetCryptedString(id, kStorageEapIdentity, &eap.identity); |
| 986 | storage->GetString(id, kStorageEapEap, &eap.eap); |
| 987 | storage->GetString(id, kStorageEapInnerEap, &eap.inner_eap); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 988 | storage->GetCryptedString(id, |
| 989 | kStorageEapAnonymousIdentity, |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 990 | &eap.anonymous_identity); |
| 991 | storage->GetString(id, kStorageEapClientCert, &eap.client_cert); |
| 992 | storage->GetString(id, kStorageEapCertID, &eap.cert_id); |
| 993 | storage->GetString(id, kStorageEapPrivateKey, &eap.private_key); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 994 | storage->GetCryptedString(id, |
| 995 | kStorageEapPrivateKeyPassword, |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 996 | &eap.private_key_password); |
| 997 | storage->GetString(id, kStorageEapKeyID, &eap.key_id); |
| 998 | storage->GetString(id, kStorageEapCACert, &eap.ca_cert); |
| 999 | storage->GetString(id, kStorageEapCACertID, &eap.ca_cert_id); |
Paul Stewart | ecf4cd1 | 2012-04-17 11:08:39 -0700 | [diff] [blame] | 1000 | storage->GetString(id, kStorageEapCACertNSS, &eap.ca_cert_nss); |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 1001 | storage->GetBool(id, kStorageEapUseSystemCAs, &eap.use_system_cas); |
| 1002 | storage->GetString(id, kStorageEapPIN, &eap.pin); |
| 1003 | storage->GetCryptedString(id, kStorageEapPassword, &eap.password); |
| 1004 | storage->GetString(id, kStorageEapKeyManagement, &eap.key_management); |
| 1005 | set_eap(eap); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 1006 | } |
| 1007 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 1008 | void Service::SaveEapCredentials(StoreInterface *storage, const string &id) { |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 1009 | bool save = save_credentials_; |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 1010 | SaveString(storage, id, kStorageEapIdentity, eap_.identity, true, save); |
| 1011 | SaveString(storage, id, kStorageEapEap, eap_.eap, false, true); |
| 1012 | SaveString(storage, id, kStorageEapInnerEap, eap_.inner_eap, false, true); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 1013 | SaveString(storage, |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 1014 | id, |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 1015 | kStorageEapAnonymousIdentity, |
| 1016 | eap_.anonymous_identity, |
| 1017 | true, |
| 1018 | save); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 1019 | SaveString(storage, id, kStorageEapClientCert, eap_.client_cert, false, save); |
| 1020 | SaveString(storage, id, kStorageEapCertID, eap_.cert_id, false, save); |
| 1021 | SaveString(storage, id, kStorageEapPrivateKey, eap_.private_key, false, save); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 1022 | SaveString(storage, |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 1023 | id, |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 1024 | kStorageEapPrivateKeyPassword, |
| 1025 | eap_.private_key_password, |
| 1026 | true, |
| 1027 | save); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 1028 | SaveString(storage, id, kStorageEapKeyID, eap_.key_id, false, save); |
| 1029 | SaveString(storage, id, kStorageEapCACert, eap_.ca_cert, false, true); |
| 1030 | SaveString(storage, id, kStorageEapCACertID, eap_.ca_cert_id, false, true); |
Paul Stewart | ecf4cd1 | 2012-04-17 11:08:39 -0700 | [diff] [blame] | 1031 | SaveString(storage, id, kStorageEapCACertNSS, eap_.ca_cert_nss, false, true); |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 1032 | storage->SetBool(id, kStorageEapUseSystemCAs, eap_.use_system_cas); |
| 1033 | SaveString(storage, id, kStorageEapPIN, eap_.pin, false, save); |
| 1034 | SaveString(storage, id, kStorageEapPassword, eap_.password, true, save); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 1035 | SaveString(storage, |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 1036 | id, |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 1037 | kStorageEapKeyManagement, |
| 1038 | eap_.key_management, |
| 1039 | false, |
| 1040 | true); |
| 1041 | } |
| 1042 | |
Paul Stewart | d8ad3c4 | 2012-01-09 12:39:38 -0800 | [diff] [blame] | 1043 | void Service::UnloadEapCredentials() { |
| 1044 | eap_.identity = ""; |
| 1045 | eap_.eap = ""; |
| 1046 | eap_.inner_eap = ""; |
| 1047 | eap_.anonymous_identity = ""; |
| 1048 | eap_.client_cert = ""; |
| 1049 | eap_.cert_id = ""; |
| 1050 | eap_.private_key = ""; |
| 1051 | eap_.private_key_password = ""; |
| 1052 | eap_.key_id = ""; |
| 1053 | eap_.ca_cert = ""; |
| 1054 | eap_.ca_cert_id = ""; |
Paul Stewart | 2055098 | 2012-04-16 12:16:11 -0700 | [diff] [blame] | 1055 | eap_.use_system_cas = true; |
Paul Stewart | d8ad3c4 | 2012-01-09 12:39:38 -0800 | [diff] [blame] | 1056 | eap_.pin = ""; |
| 1057 | eap_.password = ""; |
Paul Stewart | d8ad3c4 | 2012-01-09 12:39:38 -0800 | [diff] [blame] | 1058 | } |
| 1059 | |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 1060 | void Service::IgnoreParameterForConfigure(const string ¶meter) { |
| 1061 | parameters_ignored_for_configure_.insert(parameter); |
| 1062 | } |
| 1063 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 1064 | const string &Service::GetEAPKeyManagement() const { |
| 1065 | return eap_.key_management; |
| 1066 | } |
| 1067 | |
| 1068 | void Service::SetEAPKeyManagement(const string &key_management) { |
| 1069 | eap_.key_management = key_management; |
| 1070 | } |
| 1071 | |
Thieu Le | 284fe79 | 2012-01-31 17:53:19 -0800 | [diff] [blame] | 1072 | bool Service::GetAutoConnect(Error */*error*/) { |
| 1073 | return auto_connect(); |
| 1074 | } |
| 1075 | |
| 1076 | void Service::SetAutoConnect(const bool &connect, Error *error) { |
Wade Guthrie | 4f28e8b | 2012-04-11 10:52:07 -0700 | [diff] [blame] | 1077 | set_auto_connect(connect); |
Thieu Le | 284fe79 | 2012-01-31 17:53:19 -0800 | [diff] [blame] | 1078 | } |
| 1079 | |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 1080 | string Service::GetCheckPortal(Error *error) { |
| 1081 | return check_portal_; |
| 1082 | } |
| 1083 | |
| 1084 | void Service::SetCheckPortal(const string &check_portal, Error *error) { |
| 1085 | if (check_portal == check_portal_) { |
| 1086 | return; |
| 1087 | } |
| 1088 | if (check_portal != kCheckPortalFalse && |
| 1089 | check_portal != kCheckPortalTrue && |
| 1090 | check_portal != kCheckPortalAuto) { |
| 1091 | Error::PopulateAndLog(error, Error::kInvalidArguments, |
| 1092 | base::StringPrintf( |
| 1093 | "Invalid Service CheckPortal property value: %s", |
| 1094 | check_portal.c_str())); |
| 1095 | return; |
| 1096 | } |
| 1097 | check_portal_ = check_portal; |
| 1098 | } |
| 1099 | |
Paul Stewart | 9f32d19 | 2012-01-30 20:37:50 -0800 | [diff] [blame] | 1100 | void Service::SetEAPPassword(const string &password, Error */*error*/) { |
| 1101 | eap_.password = password; |
| 1102 | } |
| 1103 | |
| 1104 | void Service::SetEAPPrivateKeyPassword(const string &password, |
| 1105 | Error */*error*/) { |
| 1106 | eap_.private_key_password = password; |
| 1107 | } |
| 1108 | |
Paul Stewart | 0c43833 | 2012-04-11 07:55:27 -0700 | [diff] [blame] | 1109 | string Service::GetNameProperty(Error *error) { |
| 1110 | return friendly_name_; |
| 1111 | } |
| 1112 | |
| 1113 | void Service::AssertTrivialSetNameProperty(const string &name, Error *error) { |
| 1114 | if (name != friendly_name_) { |
| 1115 | Error::PopulateAndLog(error, Error::kInvalidArguments, |
Paul Stewart | 2bf424f | 2012-04-11 18:59:39 -0700 | [diff] [blame] | 1116 | base::StringPrintf( |
| 1117 | "Service Name property cannot be modified " |
| 1118 | "(%s to %s)", friendly_name_.c_str(), |
| 1119 | name.c_str())); |
Paul Stewart | 0c43833 | 2012-04-11 07:55:27 -0700 | [diff] [blame] | 1120 | } |
| 1121 | } |
| 1122 | |
Paul Stewart | 1b1a7f2 | 2012-01-06 16:24:06 -0800 | [diff] [blame] | 1123 | string Service::GetProfileRpcId(Error *error) { |
| 1124 | if (!profile_) { |
| 1125 | // This happens in some unit tests where profile_ is not set. |
| 1126 | error->Populate(Error::kNotFound); |
| 1127 | return ""; |
| 1128 | } |
| 1129 | return profile_->GetRpcIdentifier(); |
| 1130 | } |
| 1131 | |
| 1132 | void Service::SetProfileRpcId(const string &profile, Error *error) { |
| 1133 | manager_->SetProfileForService(this, profile, error); |
| 1134 | } |
| 1135 | |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 1136 | uint16 Service::GetHTTPProxyPort(Error */*error*/) { |
| 1137 | if (http_proxy_.get()) { |
| 1138 | return static_cast<uint16>(http_proxy_->proxy_port()); |
| 1139 | } |
| 1140 | return 0; |
| 1141 | } |
| 1142 | |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 1143 | void Service::SaveToProfile() { |
| 1144 | if (profile_.get() && profile_->GetConstStorage()) { |
| 1145 | profile_->UpdateService(this); |
| 1146 | } |
| 1147 | } |
| 1148 | |
Darin Petkov | d78ee7e | 2012-01-12 11:21:10 +0100 | [diff] [blame] | 1149 | void Service::SetStrength(uint8 strength) { |
| 1150 | if (strength == strength_) { |
| 1151 | return; |
| 1152 | } |
| 1153 | strength_ = strength; |
| 1154 | adaptor_->EmitUint8Changed(flimflam::kSignalStrengthProperty, strength); |
| 1155 | } |
| 1156 | |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 1157 | void Service::UpdateErrorProperty() { |
| 1158 | const string error(ConnectFailureToString(failure_)); |
| 1159 | if (error == error_) { |
| 1160 | return; |
| 1161 | } |
| 1162 | error_ = error; |
| 1163 | adaptor_->EmitStringChanged(flimflam::kErrorProperty, error); |
| 1164 | } |
| 1165 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 1166 | } // namespace shill |