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 | b50f0b9 | 2011-05-16 16:31:42 -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 | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 5 | #include "shill/wifi.h" |
| 6 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 7 | #include <stdio.h> |
mukesh agrawal | c7426a4 | 2011-06-03 13:04:28 -0700 | [diff] [blame] | 8 | #include <string.h> |
mukesh agrawal | f2f68a5 | 2011-09-01 12:15:48 -0700 | [diff] [blame] | 9 | #include <netinet/ether.h> |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 10 | #include <linux/if.h> // Needs definitions from netinet/ether.h |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 11 | |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 12 | #include <algorithm> |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 13 | #include <map> |
Paul Stewart | ced6a0b | 2011-11-08 15:32:04 -0800 | [diff] [blame] | 14 | #include <set> |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 15 | #include <string> |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 16 | #include <vector> |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 17 | |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 18 | #include <base/bind.h> |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 19 | #include <base/logging.h> |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 20 | #include <base/stringprintf.h> |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 21 | #include <base/string_number_conversions.h> |
| 22 | #include <base/string_util.h> |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 23 | #include <chromeos/dbus/service_constants.h> |
mukesh agrawal | 16bc1b8 | 2012-02-09 18:38:26 -0800 | [diff] [blame] | 24 | #include <glib.h> |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 25 | |
| 26 | #include "shill/control_interface.h" |
Paul Stewart | ced6a0b | 2011-11-08 15:32:04 -0800 | [diff] [blame] | 27 | #include "shill/dbus_adaptor.h" |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 28 | #include "shill/device.h" |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 29 | #include "shill/error.h" |
Paul Stewart | 26b327e | 2011-10-19 11:38:09 -0700 | [diff] [blame] | 30 | #include "shill/event_dispatcher.h" |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 31 | #include "shill/key_value_store.h" |
| 32 | #include "shill/ieee80211.h" |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 33 | #include "shill/manager.h" |
Thieu Le | 67370f6 | 2012-02-14 23:01:42 +0000 | [diff] [blame] | 34 | #include "shill/metrics.h" |
Gary Morain | ac1bdb4 | 2012-02-16 17:42:29 -0800 | [diff] [blame] | 35 | #include "shill/power_manager.h" |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 36 | #include "shill/profile.h" |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 37 | #include "shill/property_accessor.h" |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 38 | #include "shill/proxy_factory.h" |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 39 | #include "shill/rtnl_handler.h" |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 40 | #include "shill/scope_logger.h" |
mukesh agrawal | 5c05b29 | 2012-03-07 10:12:52 -0800 | [diff] [blame] | 41 | #include "shill/shill_time.h" |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 42 | #include "shill/store_interface.h" |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 43 | #include "shill/supplicant_interface_proxy_interface.h" |
| 44 | #include "shill/supplicant_process_proxy_interface.h" |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 45 | #include "shill/technology.h" |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 46 | #include "shill/wifi_endpoint.h" |
| 47 | #include "shill/wifi_service.h" |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 48 | #include "shill/wpa_supplicant.h" |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 49 | |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 50 | using base::Bind; |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 51 | using base::StringPrintf; |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 52 | using std::map; |
Paul Stewart | ced6a0b | 2011-11-08 15:32:04 -0800 | [diff] [blame] | 53 | using std::set; |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 54 | using std::string; |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 55 | using std::vector; |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 56 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 57 | namespace shill { |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 58 | |
| 59 | // statics |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 60 | const char *WiFi::kDefaultBgscanMethod = |
| 61 | wpa_supplicant::kNetworkBgscanMethodSimple; |
| 62 | const uint16 WiFi::kDefaultBgscanShortIntervalSeconds = 30; |
| 63 | const int32 WiFi::kDefaultBgscanSignalThresholdDbm = -50; |
| 64 | const uint16 WiFi::kDefaultScanIntervalSeconds = 180; |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 65 | // Note that WiFi generates some manager-level errors, because it implements |
| 66 | // the Manager.GetWiFiService flimflam API. The API is implemented here, |
| 67 | // rather than in manager, to keep WiFi-specific logic in the right place. |
| 68 | const char WiFi::kManagerErrorPassphraseRequired[] = "must specify passphrase"; |
| 69 | const char WiFi::kManagerErrorSSIDRequired[] = "must specify SSID"; |
| 70 | const char WiFi::kManagerErrorSSIDTooLong[] = "SSID is too long"; |
| 71 | const char WiFi::kManagerErrorSSIDTooShort[] = "SSID is too short"; |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 72 | const char WiFi::kManagerErrorUnsupportedSecurityMode[] = |
| 73 | "security mode is unsupported"; |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 74 | const char WiFi::kManagerErrorUnsupportedServiceMode[] = |
| 75 | "service mode is unsupported"; |
mukesh agrawal | 5c05b29 | 2012-03-07 10:12:52 -0800 | [diff] [blame] | 76 | // Age (in seconds) beyond which a BSS cache entry will not be preserved, |
| 77 | // across a suspend/resume. |
| 78 | const time_t WiFi::kMaxBSSResumeAgeSeconds = 10; |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 79 | const char WiFi::kInterfaceStateUnknown[] = "shill-unknown"; |
mukesh agrawal | f202817 | 2012-03-13 14:20:22 -0700 | [diff] [blame] | 80 | const time_t WiFi::kRescanIntervalSeconds = 1; |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 81 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 82 | WiFi::WiFi(ControlInterface *control_interface, |
| 83 | EventDispatcher *dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 84 | Metrics *metrics, |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 85 | Manager *manager, |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 86 | const string& link, |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 87 | const string &address, |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 88 | int interface_index) |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 89 | : Device(control_interface, |
| 90 | dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 91 | metrics, |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 92 | manager, |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 93 | link, |
Chris Masone | 626719f | 2011-08-18 16:58:48 -0700 | [diff] [blame] | 94 | address, |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 95 | interface_index, |
| 96 | Technology::kWifi), |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 97 | weak_ptr_factory_(this), |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 98 | proxy_factory_(ProxyFactory::GetInstance()), |
mukesh agrawal | 5c05b29 | 2012-03-07 10:12:52 -0800 | [diff] [blame] | 99 | time_(Time::GetInstance()), |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 100 | supplicant_state_(kInterfaceStateUnknown), |
| 101 | supplicant_bss_("(unknown)"), |
Paul Stewart | 66c8600 | 2012-01-30 18:00:52 -0800 | [diff] [blame] | 102 | clear_cached_credentials_pending_(false), |
mukesh agrawal | 5c05b29 | 2012-03-07 10:12:52 -0800 | [diff] [blame] | 103 | need_bss_flush_(false), |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 104 | bgscan_method_(kDefaultBgscanMethod), |
| 105 | bgscan_short_interval_seconds_(kDefaultBgscanShortIntervalSeconds), |
| 106 | bgscan_signal_threshold_dbm_(kDefaultBgscanSignalThresholdDbm), |
Chris Masone | 853b81b | 2011-06-24 14:11:41 -0700 | [diff] [blame] | 107 | scan_pending_(false), |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 108 | scan_interval_seconds_(kDefaultScanIntervalSeconds) { |
mukesh agrawal | de29fa8 | 2011-09-16 16:16:36 -0700 | [diff] [blame] | 109 | PropertyStore *store = this->mutable_store(); |
mukesh agrawal | 5c05b29 | 2012-03-07 10:12:52 -0800 | [diff] [blame] | 110 | resumed_at_.tv_sec = 0; |
| 111 | resumed_at_.tv_usec = 0; |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 112 | HelpRegisterDerivedString(store, |
| 113 | flimflam::kBgscanMethodProperty, |
| 114 | &WiFi::GetBgscanMethod, |
| 115 | &WiFi::SetBgscanMethod); |
| 116 | HelpRegisterDerivedUint16(store, |
| 117 | flimflam::kBgscanShortIntervalProperty, |
| 118 | &WiFi::GetBgscanShortInterval, |
| 119 | &WiFi::SetBgscanShortInterval); |
| 120 | HelpRegisterDerivedInt32(store, |
| 121 | flimflam::kBgscanSignalThresholdProperty, |
| 122 | &WiFi::GetBgscanSignalThreshold, |
| 123 | &WiFi::SetBgscanSignalThreshold); |
Chris Masone | 853b81b | 2011-06-24 14:11:41 -0700 | [diff] [blame] | 124 | |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 125 | // TODO(quiche): Decide if scan_pending_ is close enough to |
| 126 | // "currently scanning" that we don't care, or if we want to track |
| 127 | // scan pending/currently scanning/no scan scheduled as a tri-state |
| 128 | // kind of thing. |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 129 | store->RegisterConstBool(flimflam::kScanningProperty, &scan_pending_); |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 130 | HelpRegisterDerivedUint16(store, |
| 131 | flimflam::kScanIntervalProperty, |
| 132 | &WiFi::GetScanInterval, |
| 133 | &WiFi::SetScanInterval); |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 134 | SLOG(WiFi, 2) << "WiFi device " << link_name() << " initialized."; |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 135 | } |
| 136 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 137 | WiFi::~WiFi() {} |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 138 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 139 | void WiFi::Start(Error *error, const EnabledStateChangedCallback &callback) { |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 140 | ::DBus::Path interface_path; |
| 141 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 142 | supplicant_process_proxy_.reset( |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 143 | proxy_factory_->CreateSupplicantProcessProxy( |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 144 | wpa_supplicant::kDBusPath, wpa_supplicant::kDBusAddr)); |
mukesh agrawal | c7426a4 | 2011-06-03 13:04:28 -0700 | [diff] [blame] | 145 | try { |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 146 | map<string, DBus::Variant> create_interface_args; |
Paul Stewart | 2055098 | 2012-04-16 12:16:11 -0700 | [diff] [blame] | 147 | create_interface_args[wpa_supplicant::kInterfacePropertyName].writer(). |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 148 | append_string(link_name().c_str()); |
Paul Stewart | 2055098 | 2012-04-16 12:16:11 -0700 | [diff] [blame] | 149 | create_interface_args[wpa_supplicant::kInterfacePropertyDriver].writer(). |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 150 | append_string(wpa_supplicant::kDriverNL80211); |
Paul Stewart | 2055098 | 2012-04-16 12:16:11 -0700 | [diff] [blame] | 151 | create_interface_args[ |
| 152 | wpa_supplicant::kInterfacePropertyConfigFile].writer(). |
| 153 | append_string(SCRIPTDIR "/wpa_supplicant.conf"); |
mukesh agrawal | c7426a4 | 2011-06-03 13:04:28 -0700 | [diff] [blame] | 154 | interface_path = |
| 155 | supplicant_process_proxy_->CreateInterface(create_interface_args); |
| 156 | } catch (const DBus::Error e) { // NOLINT |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 157 | if (!strcmp(e.name(), wpa_supplicant::kErrorInterfaceExists)) { |
mukesh agrawal | c7426a4 | 2011-06-03 13:04:28 -0700 | [diff] [blame] | 158 | interface_path = |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 159 | supplicant_process_proxy_->GetInterface(link_name()); |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 160 | // TODO(quiche): Is it okay to crash here, if device is missing? |
mukesh agrawal | c7426a4 | 2011-06-03 13:04:28 -0700 | [diff] [blame] | 161 | } else { |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 162 | // TODO(quiche): Log error. |
mukesh agrawal | c7426a4 | 2011-06-03 13:04:28 -0700 | [diff] [blame] | 163 | } |
| 164 | } |
| 165 | |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 166 | supplicant_interface_proxy_.reset( |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 167 | proxy_factory_->CreateSupplicantInterfaceProxy( |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 168 | this, interface_path, wpa_supplicant::kDBusAddr)); |
mukesh agrawal | c7426a4 | 2011-06-03 13:04:28 -0700 | [diff] [blame] | 169 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 170 | RTNLHandler::GetInstance()->SetInterfaceFlags(interface_index(), IFF_UP, |
| 171 | IFF_UP); |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 172 | // TODO(quiche) Set ApScan=1 and BSSExpireAge=190, like flimflam does? |
mukesh agrawal | c7426a4 | 2011-06-03 13:04:28 -0700 | [diff] [blame] | 173 | |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 174 | // Clear out any networks that might previously have been configured |
mukesh agrawal | c7426a4 | 2011-06-03 13:04:28 -0700 | [diff] [blame] | 175 | // for this interface. |
| 176 | supplicant_interface_proxy_->RemoveAllNetworks(); |
| 177 | |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 178 | // Flush interface's BSS cache, so that we get BSSAdded signals for |
mukesh agrawal | c7426a4 | 2011-06-03 13:04:28 -0700 | [diff] [blame] | 179 | // all BSSes (not just new ones since the last scan). |
| 180 | supplicant_interface_proxy_->FlushBSS(0); |
| 181 | |
mukesh agrawal | 23e9f28 | 2012-02-17 15:36:36 -0800 | [diff] [blame] | 182 | try { |
| 183 | // TODO(pstew): Disable fast_reauth until supplicant can properly deal |
| 184 | // with RADIUS servers that respond strangely to such requests. |
| 185 | // crosbug.com/25630 |
| 186 | supplicant_interface_proxy_->SetFastReauth(false); |
| 187 | } catch (const DBus::Error e) { // NOLINT |
mukesh agrawal | f202817 | 2012-03-13 14:20:22 -0700 | [diff] [blame] | 188 | LOG(INFO) << "Failed to disable fast_reauth." |
| 189 | << "May be running an older version of wpa_supplicant."; |
| 190 | } |
| 191 | |
| 192 | try { |
| 193 | // Helps with passing WiFiRomaing.001SSIDSwitchBack. |
| 194 | supplicant_interface_proxy_->SetScanInterval(kRescanIntervalSeconds); |
| 195 | } catch (const DBus::Error e) { // NOLINT |
| 196 | LOG(INFO) << "Failed to set scan_interval. " |
mukesh agrawal | 23e9f28 | 2012-02-17 15:36:36 -0800 | [diff] [blame] | 197 | << "May be running an older version of wpa_supplicant."; |
| 198 | } |
Paul Stewart | 2987dcf | 2012-01-30 15:47:42 -0800 | [diff] [blame] | 199 | |
Gary Morain | ac1bdb4 | 2012-02-16 17:42:29 -0800 | [diff] [blame] | 200 | // Register for power state changes. HandlePowerStateChange() will be called |
| 201 | // when the power state changes. |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 202 | manager()->power_manager()->AddStateChangeCallback( |
| 203 | UniqueName(), |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 204 | Bind(&WiFi::HandlePowerStateChange, weak_ptr_factory_.GetWeakPtr())); |
Gary Morain | ac1bdb4 | 2012-02-16 17:42:29 -0800 | [diff] [blame] | 205 | |
Darin Petkov | c086531 | 2011-09-16 15:31:20 -0700 | [diff] [blame] | 206 | Scan(NULL); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 207 | OnEnabledStateChanged(EnabledStateChangedCallback(), Error()); |
| 208 | if (error) |
| 209 | error->Reset(); // indicate immediate completion |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 212 | void WiFi::Stop(Error *error, const EnabledStateChangedCallback &callback) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 213 | SLOG(WiFi, 2) << "WiFi " << link_name() << " stopping."; |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 214 | // TODO(quiche): Remove interface from supplicant. |
mukesh agrawal | 3195024 | 2011-07-14 11:53:38 -0700 | [diff] [blame] | 215 | supplicant_interface_proxy_.reset(); // breaks a reference cycle |
| 216 | supplicant_process_proxy_.reset(); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 217 | endpoint_by_rpcid_.clear(); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 218 | rpcid_by_service_.clear(); |
Gary Morain | 9100112 | 2012-02-29 16:22:26 -0800 | [diff] [blame] | 219 | manager()->power_manager()->RemoveStateChangeCallback(UniqueName()); |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 220 | |
Paul Stewart | ced6a0b | 2011-11-08 15:32:04 -0800 | [diff] [blame] | 221 | for (vector<WiFiServiceRefPtr>::const_iterator it = services_.begin(); |
| 222 | it != services_.end(); |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 223 | ++it) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 224 | SLOG(WiFi, 3) << "WiFi " << link_name() << " deregistering service " |
| 225 | << (*it)->friendly_name(); |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 226 | manager()->DeregisterService(*it); |
| 227 | } |
Paul Stewart | ced6a0b | 2011-11-08 15:32:04 -0800 | [diff] [blame] | 228 | services_.clear(); // breaks reference cycles |
mukesh agrawal | b20776f | 2012-02-10 16:00:36 -0800 | [diff] [blame] | 229 | current_service_ = NULL; // breaks a reference cycle |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 230 | pending_service_ = NULL; // breaks a reference cycle |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 231 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 232 | OnEnabledStateChanged(EnabledStateChangedCallback(), Error()); |
| 233 | if (error) |
| 234 | error->Reset(); // indicate immediate completion |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 235 | // TODO(quiche): Anything else to do? |
mukesh agrawal | 5c4dd0b | 2011-09-14 13:53:14 -0700 | [diff] [blame] | 236 | |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 237 | SLOG(WiFi, 3) << "WiFi " << link_name() << " supplicant_process_proxy_ " |
| 238 | << (supplicant_process_proxy_.get() ? |
| 239 | "is set." : "is not set."); |
| 240 | SLOG(WiFi, 3) << "WiFi " << link_name() << " supplicant_interface_proxy_ " |
| 241 | << (supplicant_interface_proxy_.get() ? |
| 242 | "is set." : "is not set."); |
| 243 | SLOG(WiFi, 3) << "WiFi " << link_name() << " pending_service_ " |
| 244 | << (pending_service_.get() ? "is set." : "is not set."); |
| 245 | SLOG(WiFi, 3) << "WiFi " << link_name() << " has " |
| 246 | << endpoint_by_rpcid_.size() << " EndpointMap entries."; |
| 247 | SLOG(WiFi, 3) << "WiFi " << link_name() << " has " << services_.size() |
| 248 | << " Services."; |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 251 | bool WiFi::Load(StoreInterface *storage) { |
| 252 | LoadHiddenServices(storage); |
| 253 | return Device::Load(storage); |
| 254 | } |
| 255 | |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 256 | void WiFi::Scan(Error */*error*/) { |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 257 | LOG(INFO) << __func__; |
| 258 | |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 259 | // Needs to send a D-Bus message, but may be called from D-Bus |
| 260 | // signal handler context (via Manager::RequestScan). So defer work |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 261 | // to event loop. |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 262 | dispatcher()->PostTask(Bind(&WiFi::ScanTask, weak_ptr_factory_.GetWeakPtr())); |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 263 | } |
| 264 | |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 265 | bool WiFi::TechnologyIs(const Technology::Identifier type) const { |
| 266 | return type == Technology::kWifi; |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 267 | } |
| 268 | |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 269 | bool WiFi::IsConnectingTo(const WiFiService &service) const { |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 270 | return pending_service_ == &service || |
| 271 | (current_service_ == &service && |
| 272 | service.state() != Service::kStateConnected); |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 273 | } |
| 274 | |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 275 | void WiFi::BSSAdded(const ::DBus::Path &path, |
| 276 | const map<string, ::DBus::Variant> &properties) { |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 277 | // Called from a D-Bus signal handler, and may need to send a D-Bus |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 278 | // message. So defer work to event loop. |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 279 | dispatcher()->PostTask(Bind(&WiFi::BSSAddedTask, |
| 280 | weak_ptr_factory_.GetWeakPtr(), |
| 281 | path, properties)); |
mukesh agrawal | 261daca | 2011-12-02 18:56:56 +0000 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | void WiFi::BSSRemoved(const ::DBus::Path &path) { |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 285 | // Called from a D-Bus signal handler, and may need to send a D-Bus |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 286 | // message. So defer work to event loop. |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 287 | dispatcher()->PostTask(Bind(&WiFi::BSSRemovedTask, |
| 288 | weak_ptr_factory_.GetWeakPtr(), path)); |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 289 | } |
| 290 | |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 291 | void WiFi::PropertiesChanged(const map<string, ::DBus::Variant> &properties) { |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 292 | LOG(INFO) << "In " << __func__ << "(): called"; |
| 293 | // Called from D-Bus signal handler, but may need to send a D-Bus |
| 294 | // message. So defer work to event loop. |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 295 | dispatcher()->PostTask(Bind(&WiFi::PropertiesChangedTask, |
| 296 | weak_ptr_factory_.GetWeakPtr(), properties)); |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 297 | } |
| 298 | |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 299 | void WiFi::ScanDone() { |
| 300 | LOG(INFO) << __func__; |
| 301 | |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 302 | // Defer handling of scan result processing, because that processing |
| 303 | // may require the the registration of new D-Bus objects. And such |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 304 | // registration can't be done in the context of a D-Bus signal |
| 305 | // handler. |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 306 | dispatcher()->PostTask(Bind(&WiFi::ScanDoneTask, |
| 307 | weak_ptr_factory_.GetWeakPtr())); |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 308 | } |
| 309 | |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 310 | void WiFi::ConnectTo(WiFiService *service, |
mukesh agrawal | 6489632 | 2011-12-01 01:13:10 +0000 | [diff] [blame] | 311 | map<string, DBus::Variant> service_params) { |
mukesh agrawal | e9adda1 | 2012-02-09 18:33:48 -0800 | [diff] [blame] | 312 | CHECK(service) << "Can't connect to NULL service."; |
mukesh agrawal | 445e72c | 2011-06-22 11:13:50 -0700 | [diff] [blame] | 313 | DBus::Path network_path; |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 314 | |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 315 | // TODO(quiche): Handle cases where already connected. |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 316 | if (pending_service_ && pending_service_ == service) { |
| 317 | // TODO(quiche): Return an error to the caller. crosbug.com/23832 |
| 318 | LOG(INFO) << "WiFi " << link_name() << " ignoring ConnectTo " |
| 319 | << service->friendly_name() |
| 320 | << ", which is already pending."; |
| 321 | return; |
| 322 | } |
| 323 | |
| 324 | if (pending_service_ && pending_service_ != service) { |
| 325 | DisconnectFrom(pending_service_); |
| 326 | } |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 327 | |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 328 | try { |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 329 | // TODO(quiche): Set a timeout here. In the normal case, we expect |
| 330 | // that, if wpa_supplicant fails to connect, it will eventually send |
| 331 | // a signal that its CurrentBSS has changed. But there may be cases |
| 332 | // where the signal is not sent. (crosbug.com/23206) |
mukesh agrawal | 6489632 | 2011-12-01 01:13:10 +0000 | [diff] [blame] | 333 | const uint32_t scan_ssid = 1; // "True": Use directed probe. |
| 334 | service_params[wpa_supplicant::kNetworkPropertyScanSSID].writer(). |
| 335 | append_uint32(scan_ssid); |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 336 | service_params[wpa_supplicant::kNetworkPropertyBgscan].writer(). |
| 337 | append_string(CreateBgscanConfigString().c_str()); |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 338 | network_path = |
| 339 | supplicant_interface_proxy_->AddNetwork(service_params); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 340 | rpcid_by_service_[service] = network_path; |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 341 | } catch (const DBus::Error e) { // NOLINT |
| 342 | LOG(ERROR) << "exception while adding network: " << e.what(); |
| 343 | return; |
| 344 | } |
mukesh agrawal | 445e72c | 2011-06-22 11:13:50 -0700 | [diff] [blame] | 345 | |
mukesh agrawal | 445e72c | 2011-06-22 11:13:50 -0700 | [diff] [blame] | 346 | supplicant_interface_proxy_->SelectNetwork(network_path); |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 347 | pending_service_ = service; |
| 348 | CHECK(current_service_.get() != pending_service_.get()); |
| 349 | |
mukesh agrawal | f2f68a5 | 2011-09-01 12:15:48 -0700 | [diff] [blame] | 350 | // SelectService here (instead of in LinkEvent, like Ethernet), so |
| 351 | // that, if we fail to bring up L2, we can attribute failure correctly. |
| 352 | // |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 353 | // TODO(quiche): When we add code for dealing with connection failures, |
mukesh agrawal | f2f68a5 | 2011-09-01 12:15:48 -0700 | [diff] [blame] | 354 | // reconsider if this is the right place to change the selected service. |
| 355 | // see discussion in crosbug.com/20191. |
| 356 | SelectService(service); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 357 | } |
| 358 | |
mukesh agrawal | 0ed0f2e | 2011-12-05 20:36:17 +0000 | [diff] [blame] | 359 | void WiFi::DisconnectFrom(WiFiService *service) { |
| 360 | if (service != current_service_ && service != pending_service_) { |
| 361 | // TODO(quiche): Once we have asynchronous reply support, we should |
| 362 | // generate a D-Bus error here. (crosbug.com/23832) |
| 363 | LOG(WARNING) << "In " << __func__ << "(): " |
| 364 | << " ignoring request to disconnect from service " |
| 365 | << service->friendly_name() |
| 366 | << " which is neither current nor pending"; |
| 367 | return; |
| 368 | } |
| 369 | |
| 370 | if (pending_service_ && service != pending_service_) { |
| 371 | // TODO(quiche): Once we have asynchronous reply support, we should |
| 372 | // generate a D-Bus error here. (crosbug.com/23832) |
| 373 | LOG(WARNING) << "In " << __func__ << "(): " |
| 374 | << " ignoring request to disconnect from service " |
| 375 | << service->friendly_name() |
| 376 | << " which is not the pending service."; |
| 377 | return; |
| 378 | } |
| 379 | |
| 380 | if (!pending_service_ && service != current_service_) { |
| 381 | // TODO(quiche): Once we have asynchronous reply support, we should |
| 382 | // generate a D-Bus error here. (crosbug.com/23832) |
| 383 | LOG(WARNING) << "In " << __func__ << "(): " |
| 384 | << " ignoring request to disconnect from service " |
| 385 | << service->friendly_name() |
| 386 | << " which is not the current service."; |
| 387 | return; |
| 388 | } |
| 389 | |
| 390 | pending_service_ = NULL; |
| 391 | try { |
| 392 | supplicant_interface_proxy_->Disconnect(); |
| 393 | // We'll call RemoveNetwork and reset |current_service_| after |
| 394 | // supplicant notifies us that the CurrentBSS has changed. |
| 395 | } catch (const DBus::Error e) { // NOLINT |
| 396 | // Can't depend on getting a notification of CurrentBSS change. |
| 397 | // So effect changes immediately. |
| 398 | ReverseServiceMap::const_iterator rpcid_it = |
| 399 | rpcid_by_service_.find(service); |
| 400 | DCHECK(rpcid_it != rpcid_by_service_.end()); |
| 401 | if (rpcid_it == rpcid_by_service_.end()) { |
| 402 | LOG(WARNING) << "WiFi " << link_name() << " can not disconnect from " |
| 403 | << service->friendly_name() << ": " |
| 404 | << "could not find supplicant network to disable."; |
| 405 | } else { |
| 406 | supplicant_interface_proxy_->RemoveNetwork(rpcid_it->second); |
| 407 | } |
| 408 | current_service_ = NULL; |
| 409 | } |
| 410 | |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 411 | CHECK(current_service_ == NULL || |
| 412 | current_service_.get() != pending_service_.get()); |
mukesh agrawal | 0ed0f2e | 2011-12-05 20:36:17 +0000 | [diff] [blame] | 413 | } |
| 414 | |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 415 | bool WiFi::IsIdle() const { |
Paul Stewart | 3d9bcf5 | 2011-12-12 15:02:22 -0800 | [diff] [blame] | 416 | return !current_service_ && !pending_service_; |
| 417 | } |
| 418 | |
Paul Stewart | 66c8600 | 2012-01-30 18:00:52 -0800 | [diff] [blame] | 419 | void WiFi::ClearCachedCredentials() { |
| 420 | LOG(INFO) << __func__; |
| 421 | |
| 422 | // Needs to send a D-Bus message, but may be called from D-Bus |
| 423 | // caller context (via Manager::PopProfile). So defer work |
| 424 | // to event loop. |
| 425 | if (!clear_cached_credentials_pending_) { |
| 426 | clear_cached_credentials_pending_ = true; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 427 | dispatcher()->PostTask(Bind(&WiFi::ClearCachedCredentialsTask, |
| 428 | weak_ptr_factory_.GetWeakPtr())); |
Paul Stewart | 66c8600 | 2012-01-30 18:00:52 -0800 | [diff] [blame] | 429 | } |
| 430 | } |
| 431 | |
mukesh agrawal | b20776f | 2012-02-10 16:00:36 -0800 | [diff] [blame] | 432 | void WiFi::NotifyEndpointChanged(const WiFiEndpoint &endpoint) { |
| 433 | WiFiService *service = FindServiceForEndpoint(endpoint); |
| 434 | DCHECK(service); |
| 435 | if (service) { |
| 436 | service->NotifyEndpointUpdated(endpoint); |
| 437 | return; |
| 438 | } |
| 439 | } |
| 440 | |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 441 | string WiFi::CreateBgscanConfigString() { |
| 442 | return StringPrintf("%s:%d:%d:%d", |
| 443 | bgscan_method_.c_str(), |
| 444 | bgscan_short_interval_seconds_, |
| 445 | bgscan_signal_threshold_dbm_, |
| 446 | scan_interval_seconds_); |
| 447 | } |
| 448 | |
| 449 | void WiFi::SetBgscanMethod(const string &method, Error *error) { |
| 450 | if (method != wpa_supplicant::kNetworkBgscanMethodSimple && |
| 451 | method != wpa_supplicant::kNetworkBgscanMethodLearn) { |
| 452 | const string error_message = |
| 453 | StringPrintf("Unrecognized bgscan method %s", method.c_str()); |
| 454 | LOG(WARNING) << error_message; |
| 455 | error->Populate(Error::kInvalidArguments, error_message); |
| 456 | return; |
| 457 | } |
| 458 | |
| 459 | bgscan_method_ = method; |
| 460 | // We do not update kNetworkPropertyBgscan for |pending_service_| or |
| 461 | // |current_service_|, because supplicant does not allow for |
| 462 | // reconfiguration without disconnect and reconnect. |
| 463 | } |
| 464 | |
| 465 | void WiFi::SetBgscanShortInterval(const uint16 &seconds, Error */*error*/) { |
| 466 | bgscan_short_interval_seconds_ = seconds; |
| 467 | // We do not update kNetworkPropertyBgscan for |pending_service_| or |
| 468 | // |current_service_|, because supplicant does not allow for |
| 469 | // reconfiguration without disconnect and reconnect. |
| 470 | } |
| 471 | |
| 472 | void WiFi::SetBgscanSignalThreshold(const int32 &dbm, Error */*error*/) { |
| 473 | bgscan_signal_threshold_dbm_ = dbm; |
| 474 | // We do not update kNetworkPropertyBgscan for |pending_service_| or |
| 475 | // |current_service_|, because supplicant does not allow for |
| 476 | // reconfiguration without disconnect and reconnect. |
| 477 | } |
| 478 | |
| 479 | void WiFi::SetScanInterval(const uint16 &seconds, Error */*error*/) { |
| 480 | scan_interval_seconds_ = seconds; |
| 481 | // We do not update |pending_service_| or |current_service_|, because |
| 482 | // supplicant does not allow for reconfiguration without disconnect |
| 483 | // and reconnect. |
| 484 | |
| 485 | // TODO(quiche): Update scan timer. crosbug.com/24337 |
| 486 | } |
| 487 | |
mukesh agrawal | 165e614 | 2011-11-22 02:22:56 +0000 | [diff] [blame] | 488 | // To avoid creating duplicate services, call FindServiceForEndpoint |
| 489 | // before calling this method. |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 490 | WiFiServiceRefPtr WiFi::CreateServiceForEndpoint(const WiFiEndpoint &endpoint, |
| 491 | bool hidden_ssid) { |
| 492 | WiFiServiceRefPtr service = |
| 493 | new WiFiService(control_interface(), |
| 494 | dispatcher(), |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 495 | metrics(), |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 496 | manager(), |
| 497 | this, |
| 498 | endpoint.ssid(), |
| 499 | endpoint.network_mode(), |
| 500 | endpoint.security_mode(), |
| 501 | hidden_ssid); |
mukesh agrawal | 165e614 | 2011-11-22 02:22:56 +0000 | [diff] [blame] | 502 | services_.push_back(service); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 503 | return service; |
| 504 | } |
| 505 | |
| 506 | void WiFi::CurrentBSSChanged(const ::DBus::Path &new_bss) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 507 | SLOG(WiFi, 3) << "WiFi " << link_name() << " CurrentBSS " |
| 508 | << supplicant_bss_ << " -> " << new_bss; |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 509 | supplicant_bss_ = new_bss; |
| 510 | if (new_bss == wpa_supplicant::kCurrentBSSNull) { |
| 511 | HandleDisconnect(); |
| 512 | } else { |
| 513 | HandleRoam(new_bss); |
| 514 | } |
| 515 | |
| 516 | SelectService(current_service_); |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 517 | // Invariant check: a Service can either be current, or pending, but |
| 518 | // not both. |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 519 | CHECK(current_service_.get() != pending_service_.get() || |
| 520 | current_service_.get() == NULL); |
| 521 | |
| 522 | // TODO(quiche): Update BSSID property on the Service |
| 523 | // (crosbug.com/22377). |
| 524 | } |
| 525 | |
| 526 | void WiFi::HandleDisconnect() { |
| 527 | // Identify the affected service. We expect to get a disconnect |
| 528 | // event when we fall off a Service that we were connected |
| 529 | // to. However, we also allow for the case where we get a disconnect |
| 530 | // event while attempting to connect from a disconnected state. |
| 531 | WiFiService *affected_service = |
| 532 | current_service_.get() ? current_service_.get() : pending_service_.get(); |
| 533 | |
| 534 | current_service_ = NULL; |
| 535 | if (!affected_service) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 536 | SLOG(WiFi, 2) << "WiFi " << link_name() |
| 537 | << " disconnected while not connected or connecting"; |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 538 | return; |
| 539 | } |
| 540 | |
| 541 | ReverseServiceMap::const_iterator rpcid_it = |
| 542 | rpcid_by_service_.find(affected_service); |
| 543 | if (rpcid_it == rpcid_by_service_.end()) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 544 | SLOG(WiFi, 2) << "WiFi " << link_name() << " disconnected from " |
| 545 | << " (or failed to connect to) " |
| 546 | << affected_service->friendly_name() << ", " |
| 547 | << "but could not find supplicant network to disable."; |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 548 | return; |
| 549 | } |
| 550 | |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 551 | SLOG(WiFi, 2) << "WiFi " << link_name() << " disconnected from " |
| 552 | << " (or failed to connect to) " |
| 553 | << affected_service->friendly_name(); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 554 | // TODO(quiche): Reconsider giving up immediately. Maybe give |
| 555 | // wpa_supplicant some time to retry, first. |
| 556 | supplicant_interface_proxy_->RemoveNetwork(rpcid_it->second); |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 557 | // TOOD(quiche): In the event that the disconnect was deliberate, we |
| 558 | // might want to go to SetState(kStateIdle), rather than reporting a |
| 559 | // failure. crosbug.com/24700. |
| 560 | // TODO(quiche): In the event that we suspect a password failure, |
| 561 | // we should not be silent. crosbug.com/23211. |
| 562 | affected_service->SetFailureSilent(Service::kFailureUnknown); |
mukesh agrawal | e1d90e9 | 2012-02-15 17:36:08 -0800 | [diff] [blame] | 563 | affected_service->NotifyCurrentEndpoint(NULL); |
Thieu Le | 67370f6 | 2012-02-14 23:01:42 +0000 | [diff] [blame] | 564 | metrics()->NotifyServiceDisconnect(affected_service); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 565 | |
| 566 | if (affected_service == pending_service_.get()) { |
| 567 | // The attempt to connect to |pending_service_| failed. Clear |
| 568 | // |pending_service_|, to indicate we're no longer in the middle |
| 569 | // of a connect request. |
| 570 | pending_service_ = NULL; |
| 571 | } else if (pending_service_.get()) { |
| 572 | // We've attributed the disconnection to what was the |
| 573 | // |current_service_|, rather than the |pending_service_|. |
| 574 | // |
| 575 | // If we're wrong about that (i.e. supplicant reported this |
| 576 | // CurrentBSS change after attempting to connect to |
| 577 | // |pending_service_|), we're depending on supplicant to retry |
| 578 | // connecting to |pending_service_|, and delivering another |
| 579 | // CurrentBSS change signal in the future. |
| 580 | // |
| 581 | // Log this fact, to help us debug (in case our assumptions are |
| 582 | // wrong). |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 583 | SLOG(WiFi, 2) << "WiFi " << link_name() << " pending connection to " |
| 584 | << pending_service_->friendly_name() |
| 585 | << " after disconnect"; |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 586 | } |
| 587 | } |
| 588 | |
| 589 | // We use the term "Roam" loosely. In particular, we include the case |
| 590 | // where we "Roam" to a BSS from the disconnected state. |
| 591 | void WiFi::HandleRoam(const ::DBus::Path &new_bss) { |
| 592 | EndpointMap::iterator endpoint_it = endpoint_by_rpcid_.find(new_bss); |
| 593 | if (endpoint_it == endpoint_by_rpcid_.end()) { |
| 594 | LOG(WARNING) << "WiFi " << link_name() << " connected to unknown BSS " |
| 595 | << new_bss; |
| 596 | return; |
| 597 | } |
| 598 | |
| 599 | const WiFiEndpoint &endpoint(*endpoint_it->second); |
mukesh agrawal | 165e614 | 2011-11-22 02:22:56 +0000 | [diff] [blame] | 600 | WiFiServiceRefPtr service = FindServiceForEndpoint(endpoint); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 601 | if (!service.get()) { |
| 602 | LOG(WARNING) << "WiFi " << link_name() |
| 603 | << " could not find Service for Endpoint " |
| 604 | << endpoint.bssid_string() |
| 605 | << " (service will be unchanged)"; |
| 606 | return; |
| 607 | } |
| 608 | |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 609 | SLOG(WiFi, 2) << "WiFi " << link_name() |
| 610 | << " roamed to Endpoint " << endpoint.bssid_string() |
| 611 | << " (SSID " << endpoint.ssid_string() << ")"; |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 612 | |
mukesh agrawal | e1d90e9 | 2012-02-15 17:36:08 -0800 | [diff] [blame] | 613 | service->NotifyCurrentEndpoint(&endpoint); |
Thieu Le | e41a72d | 2012-02-06 20:46:51 +0000 | [diff] [blame] | 614 | |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 615 | if (pending_service_.get() && |
| 616 | service.get() != pending_service_.get()) { |
| 617 | // The Service we've roamed on to is not the one we asked for. |
| 618 | // We assume that this is transient, and that wpa_supplicant |
| 619 | // is trying / will try to connect to |pending_service_|. |
| 620 | // |
| 621 | // If it succeeds, we'll end up back here, but with |service| |
| 622 | // pointing at the same service as |pending_service_|. |
| 623 | // |
| 624 | // If it fails, we'll process things in HandleDisconnect. |
| 625 | // |
| 626 | // So we leave |pending_service_| untouched. |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 627 | SLOG(WiFi, 2) << "WiFi " << link_name() |
| 628 | << " new current Endpoint " |
| 629 | << endpoint.bssid_string() |
| 630 | << " is not part of pending service " |
| 631 | << pending_service_->friendly_name(); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 632 | |
| 633 | // Sanity check: if we didn't roam onto |pending_service_|, we |
| 634 | // should still be on |current_service_|. |
| 635 | if (service.get() != current_service_.get()) { |
| 636 | LOG(WARNING) << "WiFi " << link_name() |
| 637 | << " new current Endpoint " |
| 638 | << endpoint.bssid_string() |
| 639 | << " is neither part of pending service " |
| 640 | << pending_service_->friendly_name() |
| 641 | << " nor part of current service " |
| 642 | << (current_service_.get() ? |
| 643 | current_service_->friendly_name() : |
| 644 | "(NULL)"); |
| 645 | // Although we didn't expect to get here, we should keep |
| 646 | // |current_service_| in sync with what supplicant has done. |
| 647 | current_service_ = service; |
| 648 | } |
| 649 | return; |
| 650 | } |
| 651 | |
| 652 | if (pending_service_.get()) { |
| 653 | // We assume service.get() == pending_service_.get() here, because |
| 654 | // of the return in the previous if clause. |
| 655 | // |
| 656 | // Boring case: we've connected to the service we asked |
| 657 | // for. Simply update |current_service_| and |pending_service_|. |
| 658 | current_service_ = service; |
| 659 | pending_service_ = NULL; |
| 660 | return; |
| 661 | } |
| 662 | |
| 663 | // |pending_service_| was NULL, so we weren't attempting to connect |
| 664 | // to a new Service. Sanity check that we're still on |
| 665 | // |current_service_|. |
| 666 | if (service.get() != current_service_.get()) { |
| 667 | LOG(WARNING) |
| 668 | << "WiFi " << link_name() |
| 669 | << " new current Endpoint " |
| 670 | << endpoint.bssid_string() |
| 671 | << (current_service_.get() ? |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 672 | StringPrintf(" is not part of current service %s", |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 673 | current_service_->friendly_name().c_str()) : |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 674 | " with no current service"); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 675 | // We didn't expect to be here, but let's cope as well as we |
| 676 | // can. Update |current_service_| to keep it in sync with |
| 677 | // supplicant. |
| 678 | current_service_ = service; |
| 679 | return; |
| 680 | } |
| 681 | |
| 682 | // At this point, we know that |pending_service_| was NULL, and that |
| 683 | // we're still on |current_service_|. This is the most boring case |
| 684 | // of all, because there's no state to update here. |
| 685 | return; |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 686 | } |
| 687 | |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 688 | WiFiServiceRefPtr WiFi::FindService(const vector<uint8_t> &ssid, |
| 689 | const string &mode, |
| 690 | const string &security) const { |
Paul Stewart | 6ab23a9 | 2011-11-09 17:17:47 -0800 | [diff] [blame] | 691 | for (vector<WiFiServiceRefPtr>::const_iterator it = services_.begin(); |
| 692 | it != services_.end(); |
| 693 | ++it) { |
| 694 | if ((*it)->ssid() == ssid && (*it)->mode() == mode && |
| 695 | (*it)->IsSecurityMatch(security)) { |
| 696 | return *it; |
| 697 | } |
| 698 | } |
| 699 | return NULL; |
| 700 | } |
| 701 | |
mukesh agrawal | 165e614 | 2011-11-22 02:22:56 +0000 | [diff] [blame] | 702 | WiFiServiceRefPtr WiFi::FindServiceForEndpoint(const WiFiEndpoint &endpoint) { |
| 703 | return FindService(endpoint.ssid(), |
| 704 | endpoint.network_mode(), |
| 705 | endpoint.security_mode()); |
| 706 | } |
| 707 | |
Paul Stewart | ced6a0b | 2011-11-08 15:32:04 -0800 | [diff] [blame] | 708 | ByteArrays WiFi::GetHiddenSSIDList() { |
| 709 | // Create a unique set of hidden SSIDs. |
| 710 | set<ByteArray> hidden_ssids_set; |
| 711 | for (vector<WiFiServiceRefPtr>::const_iterator it = services_.begin(); |
| 712 | it != services_.end(); |
| 713 | ++it) { |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 714 | if ((*it)->hidden_ssid() && (*it)->favorite()) { |
Paul Stewart | ced6a0b | 2011-11-08 15:32:04 -0800 | [diff] [blame] | 715 | hidden_ssids_set.insert((*it)->ssid()); |
| 716 | } |
| 717 | } |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 718 | SLOG(WiFi, 2) << "Found " << hidden_ssids_set.size() << " hidden services"; |
Paul Stewart | ced6a0b | 2011-11-08 15:32:04 -0800 | [diff] [blame] | 719 | ByteArrays hidden_ssids(hidden_ssids_set.begin(), hidden_ssids_set.end()); |
| 720 | if (!hidden_ssids.empty()) { |
| 721 | // TODO(pstew): Devise a better method for time-sharing with SSIDs that do |
| 722 | // not fit in. |
| 723 | if (hidden_ssids.size() >= wpa_supplicant::kScanMaxSSIDsPerScan) { |
| 724 | hidden_ssids.erase( |
| 725 | hidden_ssids.begin() + wpa_supplicant::kScanMaxSSIDsPerScan - 1, |
| 726 | hidden_ssids.end()); |
| 727 | } |
| 728 | // Add Broadcast SSID, signified by an empty ByteArray. If we specify |
| 729 | // SSIDs to wpa_supplicant, we need to explicitly specify the default |
| 730 | // behavior of doing a broadcast probe. |
| 731 | hidden_ssids.push_back(ByteArray()); |
| 732 | } |
| 733 | return hidden_ssids; |
| 734 | } |
| 735 | |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 736 | bool WiFi::LoadHiddenServices(StoreInterface *storage) { |
| 737 | bool created_hidden_service = false; |
| 738 | set<string> groups = storage->GetGroupsWithKey(flimflam::kWifiHiddenSsid); |
| 739 | for (set<string>::iterator it = groups.begin(); it != groups.end(); ++it) { |
| 740 | bool is_hidden = false; |
| 741 | if (!storage->GetBool(*it, flimflam::kWifiHiddenSsid, &is_hidden)) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 742 | SLOG(WiFi, 2) << "Storage group " << *it << " returned by " |
| 743 | << "GetGroupsWithKey failed for GetBool(" |
| 744 | << flimflam::kWifiHiddenSsid |
| 745 | << ") -- possible non-bool key"; |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 746 | continue; |
| 747 | } |
| 748 | if (!is_hidden) { |
| 749 | continue; |
| 750 | } |
| 751 | string ssid_hex; |
| 752 | vector<uint8_t> ssid_bytes; |
| 753 | if (!storage->GetString(*it, flimflam::kSSIDProperty, &ssid_hex) || |
| 754 | !base::HexStringToBytes(ssid_hex, &ssid_bytes)) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 755 | SLOG(WiFi, 2) << "Hidden network is missing/invalid \"" |
| 756 | << flimflam::kSSIDProperty << "\" property"; |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 757 | continue; |
| 758 | } |
| 759 | string device_address; |
| 760 | string network_mode; |
| 761 | string security; |
| 762 | // It is gross that we have to do this, but the only place we can |
| 763 | // get information about the service is from its storage name. |
| 764 | if (!WiFiService::ParseStorageIdentifier(*it, &device_address, |
| 765 | &network_mode, &security) || |
| 766 | device_address != address()) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 767 | SLOG(WiFi, 2) << "Hidden network has unparsable storage identifier \"" |
| 768 | << *it << "\""; |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 769 | continue; |
| 770 | } |
| 771 | if (FindService(ssid_bytes, network_mode, security).get()) { |
| 772 | // If service already exists, we have nothing to do, since the |
| 773 | // service has already loaded its configuration from storage. |
| 774 | // This is guaranteed to happen in both cases where Load() is |
| 775 | // called on a device (via a ConfigureDevice() call on the |
| 776 | // profile): |
| 777 | // - In RegisterDevice() the Device hasn't been started yet, |
| 778 | // so it has no services registered, except for those |
| 779 | // created by previous iterations of LoadHiddenService(). |
| 780 | // The latter can happen if another profile in the Manager's |
| 781 | // stack defines the same ssid/mode/security. Even this |
| 782 | // case is okay, since even if the profiles differ |
| 783 | // materially on configuration and credentials, the "right" |
| 784 | // one will be configured in the course of the |
| 785 | // RegisterService() call below. |
| 786 | // - In PushProfile(), all registered services have been |
| 787 | // introduced to the profile via ConfigureService() prior |
| 788 | // to calling ConfigureDevice() on the profile. |
| 789 | continue; |
| 790 | } |
| 791 | WiFiServiceRefPtr service(new WiFiService(control_interface(), |
| 792 | dispatcher(), |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 793 | metrics(), |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 794 | manager(), |
| 795 | this, |
| 796 | ssid_bytes, |
| 797 | network_mode, |
| 798 | security, |
| 799 | true)); |
| 800 | services_.push_back(service); |
| 801 | |
| 802 | // By registering the service, the rest of the configuration |
| 803 | // will be loaded from the profile into the service via ConfigureService(). |
| 804 | manager()->RegisterService(service); |
| 805 | |
| 806 | created_hidden_service = true; |
| 807 | } |
| 808 | |
| 809 | // If we are idle and we created a service as a result of opening the |
| 810 | // profile, we should initiate a scan for our new hidden SSID. |
| 811 | if (running() && created_hidden_service && |
| 812 | supplicant_state_ == wpa_supplicant::kInterfaceStateInactive) { |
| 813 | Scan(NULL); |
| 814 | } |
| 815 | |
| 816 | return created_hidden_service; |
| 817 | } |
| 818 | |
Paul Stewart | 66c8600 | 2012-01-30 18:00:52 -0800 | [diff] [blame] | 819 | void WiFi::ClearCachedCredentialsTask() { |
Paul Stewart | 57f3d9d | 2012-04-11 18:21:41 -0700 | [diff] [blame] | 820 | try { |
| 821 | supplicant_interface_proxy_->ClearCachedCredentials(); |
| 822 | } catch (const DBus::Error e) { // NOLINT |
| 823 | LOG(WARNING) << "Clear of cached credentials failed."; |
| 824 | } |
Paul Stewart | 66c8600 | 2012-01-30 18:00:52 -0800 | [diff] [blame] | 825 | clear_cached_credentials_pending_ = false; |
| 826 | } |
| 827 | |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 828 | void WiFi::BSSAddedTask( |
| 829 | const ::DBus::Path &path, |
| 830 | const map<string, ::DBus::Variant> &properties) { |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 831 | // Note: we assume that BSSIDs are unique across endpoints. This |
| 832 | // means that if an AP reuses the same BSSID for multiple SSIDs, we |
| 833 | // lose. |
mukesh agrawal | b20776f | 2012-02-10 16:00:36 -0800 | [diff] [blame] | 834 | WiFiEndpointRefPtr endpoint( |
| 835 | new WiFiEndpoint(proxy_factory_, this, path, properties)); |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 836 | LOG(INFO) << "Found endpoint. " |
mukesh agrawal | e9adda1 | 2012-02-09 18:33:48 -0800 | [diff] [blame] | 837 | << "RPC path: " << path << ", " |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 838 | << "ssid: " << endpoint->ssid_string() << ", " |
| 839 | << "bssid: " << endpoint->bssid_string() << ", " |
| 840 | << "signal: " << endpoint->signal_strength() << ", " |
Thieu Le | e41a72d | 2012-02-06 20:46:51 +0000 | [diff] [blame] | 841 | << "security: " << endpoint->security_mode() << ", " |
| 842 | << "frequency: " << endpoint->frequency(); |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 843 | |
| 844 | if (endpoint->ssid_string().empty()) { |
| 845 | // Don't bother trying to find or create a Service for an Endpoint |
| 846 | // without an SSID. We wouldn't be able to connect to it anyway. |
| 847 | return; |
| 848 | } |
| 849 | |
mukesh agrawal | b385761 | 2012-01-18 16:23:29 -0800 | [diff] [blame] | 850 | if (endpoint->ssid()[0] == 0) { |
| 851 | // Assume that an SSID starting with NULL is bogus/misconfigured, |
| 852 | // and filter it out. |
| 853 | return; |
| 854 | } |
| 855 | |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 856 | WiFiServiceRefPtr service = FindServiceForEndpoint(*endpoint); |
| 857 | if (service) { |
| 858 | LOG(INFO) << "Assigned endpoint " << endpoint->bssid_string() |
| 859 | << " to service " << service->friendly_name() << "."; |
| 860 | service->AddEndpoint(endpoint); |
| 861 | |
| 862 | if (manager()->HasService(service)) { |
| 863 | manager()->UpdateService(service); |
| 864 | } else { |
| 865 | DCHECK_EQ(1, service->NumEndpoints()); // Expect registered by now if >1. |
| 866 | manager()->RegisterService(service); |
| 867 | } |
mukesh agrawal | e9adda1 | 2012-02-09 18:33:48 -0800 | [diff] [blame] | 868 | } else { |
| 869 | const bool hidden_ssid = false; |
| 870 | service = CreateServiceForEndpoint(*endpoint, hidden_ssid); |
| 871 | LOG(INFO) << "New service " << service->GetRpcIdentifier() |
| 872 | << " (" << service->friendly_name() << ")"; |
| 873 | service->AddEndpoint(endpoint); |
| 874 | manager()->RegisterService(service); |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 875 | } |
| 876 | |
mukesh agrawal | e9adda1 | 2012-02-09 18:33:48 -0800 | [diff] [blame] | 877 | // Do this last, to maintain the invariant that any Endpoint we |
| 878 | // know about has a corresponding Service. |
mukesh agrawal | b20776f | 2012-02-10 16:00:36 -0800 | [diff] [blame] | 879 | // |
| 880 | // TODO(quiche): Write test to verify correct behavior in the case |
| 881 | // where we get multiple BSSAdded events for a single endpoint. |
| 882 | // (Old Endpoint's refcount should fall to zero, and old Endpoint |
| 883 | // should be destroyed.) |
mukesh agrawal | e9adda1 | 2012-02-09 18:33:48 -0800 | [diff] [blame] | 884 | endpoint_by_rpcid_[path] = endpoint; |
mukesh agrawal | b20776f | 2012-02-10 16:00:36 -0800 | [diff] [blame] | 885 | endpoint->Start(); |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 886 | } |
| 887 | |
| 888 | void WiFi::BSSRemovedTask(const ::DBus::Path &path) { |
| 889 | EndpointMap::iterator i = endpoint_by_rpcid_.find(path); |
| 890 | if (i == endpoint_by_rpcid_.end()) { |
| 891 | LOG(WARNING) << "WiFi " << link_name() |
| 892 | << " could not find BSS " << path |
| 893 | << " to remove."; |
| 894 | return; |
| 895 | } |
| 896 | |
| 897 | WiFiEndpointRefPtr endpoint = i->second; |
| 898 | CHECK(endpoint); |
| 899 | endpoint_by_rpcid_.erase(i); |
| 900 | |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 901 | WiFiServiceRefPtr service = FindServiceForEndpoint(*endpoint); |
mukesh agrawal | e9adda1 | 2012-02-09 18:33:48 -0800 | [diff] [blame] | 902 | CHECK(service) << "Can't find Service for Endpoint " |
| 903 | << path << " " |
| 904 | << "(with BSSID " << endpoint->bssid_string() << ")."; |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 905 | SLOG(WiFi, 2) << "Removing Endpoint " << endpoint->bssid_string() |
| 906 | << " from Service " << service->friendly_name(); |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 907 | service->RemoveEndpoint(endpoint); |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 908 | |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 909 | bool disconnect_service = !service->HasEndpoints() && |
| 910 | (service->IsConnecting() || service->IsConnected()); |
| 911 | bool forget_service = |
| 912 | // Forget Services without Endpoints, except that we always keep |
| 913 | // hidden services around. (We need them around to populate the |
| 914 | // hidden SSIDs list.) |
| 915 | !service->HasEndpoints() && !service->hidden_ssid(); |
| 916 | bool deregister_service = |
| 917 | // Only deregister a Service if we're forgetting it. Otherwise, |
| 918 | // Manager can't keep our configuration up-to-date (as Profiles |
| 919 | // change). |
| 920 | forget_service; |
| 921 | |
| 922 | if (disconnect_service) { |
| 923 | DisconnectFrom(service); |
| 924 | } |
| 925 | |
| 926 | if (deregister_service) { |
| 927 | manager()->DeregisterService(service); |
| 928 | } else { |
| 929 | manager()->UpdateService(service); |
| 930 | } |
| 931 | |
| 932 | if (forget_service) { |
| 933 | vector<WiFiServiceRefPtr>::iterator it; |
| 934 | it = std::find(services_.begin(), services_.end(), service); |
| 935 | if (it != services_.end()) { |
| 936 | services_.erase(it); |
| 937 | } |
| 938 | } |
mukesh agrawal | b4bc57d | 2011-12-07 01:07:47 +0000 | [diff] [blame] | 939 | } |
| 940 | |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 941 | void WiFi::PropertiesChangedTask( |
| 942 | const map<string, ::DBus::Variant> &properties) { |
| 943 | // TODO(quiche): Handle changes in other properties (e.g. signal |
| 944 | // strength). |
| 945 | |
| 946 | // Note that order matters here. In particular, we want to process |
| 947 | // changes in the current BSS before changes in state. This is so |
| 948 | // that we update the state of the correct Endpoint/Service. |
| 949 | |
| 950 | map<string, ::DBus::Variant>::const_iterator properties_it = |
| 951 | properties.find(wpa_supplicant::kInterfacePropertyCurrentBSS); |
| 952 | if (properties_it != properties.end()) { |
| 953 | CurrentBSSChanged(properties_it->second.reader().get_path()); |
| 954 | } |
| 955 | |
| 956 | properties_it = properties.find(wpa_supplicant::kInterfacePropertyState); |
| 957 | if (properties_it != properties.end()) { |
| 958 | StateChanged(properties_it->second.reader().get_string()); |
| 959 | } |
| 960 | } |
| 961 | |
mukesh agrawal | dc42bb3 | 2011-07-28 10:40:26 -0700 | [diff] [blame] | 962 | void WiFi::ScanDoneTask() { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 963 | SLOG(WiFi, 2) << __func__ << " need_bss_flush_ " << need_bss_flush_; |
mukesh agrawal | 5c05b29 | 2012-03-07 10:12:52 -0800 | [diff] [blame] | 964 | if (need_bss_flush_) { |
| 965 | CHECK(supplicant_interface_proxy_ != NULL); |
| 966 | // Compute |max_age| relative to |resumed_at_|, to account for the |
| 967 | // time taken to scan. |
| 968 | struct timeval now; |
| 969 | uint32_t max_age; |
| 970 | time_->GetTimeMonotonic(&now); |
| 971 | max_age = kMaxBSSResumeAgeSeconds + (now.tv_sec - resumed_at_.tv_sec); |
| 972 | supplicant_interface_proxy_->FlushBSS(max_age); |
| 973 | need_bss_flush_ = false; |
| 974 | } |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 975 | scan_pending_ = false; |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 976 | } |
| 977 | |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 978 | void WiFi::ScanTask() { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 979 | SLOG(WiFi, 2) << "WiFi " << link_name() << " scan requested."; |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 980 | map<string, DBus::Variant> scan_args; |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 981 | scan_args[wpa_supplicant::kPropertyScanType].writer(). |
| 982 | append_string(wpa_supplicant::kScanTypeActive); |
Paul Stewart | ced6a0b | 2011-11-08 15:32:04 -0800 | [diff] [blame] | 983 | |
| 984 | ByteArrays hidden_ssids = GetHiddenSSIDList(); |
| 985 | if (!hidden_ssids.empty()) { |
| 986 | scan_args[wpa_supplicant::kPropertyScanSSIDs] = |
| 987 | DBusAdaptor::ByteArraysToVariant(hidden_ssids); |
| 988 | } |
| 989 | |
Gaurav Shah | f8721ee | 2011-11-07 09:12:46 -0800 | [diff] [blame] | 990 | // TODO(quiche): Indicate scanning in UI. crosbug.com/14887 |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 991 | // FIXME(gauravsh): A scan can fail if, for example, wpa_supplicant |
| 992 | // was restarted. This is done by a few of the 802.1x tests. |
| 993 | // crosbug.com/25657 |
| 994 | try { |
| 995 | supplicant_interface_proxy_->Scan(scan_args); |
| 996 | scan_pending_ = true; |
| 997 | } catch (const DBus::Error e) { // NOLINT |
| 998 | LOG(WARNING) << "Scan failed. Attempting to re-connect to the supplicant."; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 999 | EnabledStateChangedCallback null_callback; |
| 1000 | Stop(NULL, null_callback); |
| 1001 | Start(NULL, null_callback); |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 1002 | } |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 1003 | } |
| 1004 | |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 1005 | void WiFi::StateChanged(const string &new_state) { |
| 1006 | const string old_state = supplicant_state_; |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 1007 | supplicant_state_ = new_state; |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 1008 | LOG(INFO) << "WiFi " << link_name() << " " << __func__ << " " |
| 1009 | << old_state << " -> " << new_state; |
| 1010 | |
| 1011 | WiFiService *affected_service; |
| 1012 | // Identify the service to which the state change applies. If |
| 1013 | // |pending_service_| is non-NULL, then the state change applies to |
| 1014 | // |pending_service_|. Otherwise, it applies to |current_service_|. |
| 1015 | // |
| 1016 | // This policy is driven by the fact that the |pending_service_| |
| 1017 | // doesn't become the |current_service_| until wpa_supplicant |
| 1018 | // reports a CurrentBSS change to the |pending_service_|. And the |
mukesh agrawal | c01f398 | 2012-01-24 13:48:39 -0800 | [diff] [blame] | 1019 | // CurrentBSS change won't be reported until the |pending_service_| |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 1020 | // reaches the wpa_supplicant::kInterfaceStateCompleted state. |
| 1021 | affected_service = |
| 1022 | pending_service_.get() ? pending_service_.get() : current_service_.get(); |
| 1023 | if (!affected_service) { |
Ben Chan | fad4a0b | 2012-04-18 15:49:59 -0700 | [diff] [blame] | 1024 | SLOG(WiFi, 2) << "WiFi " << link_name() << " " << __func__ |
| 1025 | << " with no service"; |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 1026 | return; |
| 1027 | } |
| 1028 | |
mukesh agrawal | c01f398 | 2012-01-24 13:48:39 -0800 | [diff] [blame] | 1029 | if (new_state == wpa_supplicant::kInterfaceStateCompleted && |
| 1030 | !affected_service->IsConnected()) { |
| 1031 | if (AcquireIPConfig()) { |
| 1032 | LOG(INFO) << link_name() << " is up; should start L3!"; |
| 1033 | affected_service->SetState(Service::kStateConfiguring); |
| 1034 | } else { |
| 1035 | LOG(ERROR) << "Unable to acquire DHCP config."; |
| 1036 | } |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 1037 | } else if (new_state == wpa_supplicant::kInterfaceStateAssociated) { |
| 1038 | affected_service->SetState(Service::kStateAssociating); |
| 1039 | } else if (new_state == wpa_supplicant::kInterfaceStateAuthenticating || |
| 1040 | new_state == wpa_supplicant::kInterfaceStateAssociating || |
| 1041 | new_state == wpa_supplicant::kInterfaceState4WayHandshake || |
| 1042 | new_state == wpa_supplicant::kInterfaceStateGroupHandshake) { |
| 1043 | // Ignore transitions into these states from Completed, to avoid |
| 1044 | // bothering the user when roaming, or re-keying. |
| 1045 | if (old_state != wpa_supplicant::kInterfaceStateCompleted) |
| 1046 | affected_service->SetState(Service::kStateAssociating); |
| 1047 | // TOOD(quiche): On backwards transitions, we should probably set |
| 1048 | // a timeout for getting back into the completed state. At present, |
| 1049 | // we depend on wpa_supplicant eventually reporting that CurrentBSS |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 1050 | // has changed. But there may be cases where that signal is not sent. |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 1051 | // (crosbug.com/23207) |
| 1052 | } else { |
| 1053 | // Other transitions do not affect Service state. |
| 1054 | // |
| 1055 | // Note in particular that we ignore a State change into |
| 1056 | // kInterfaceStateDisconnected, in favor of observing the corresponding |
| 1057 | // change in CurrentBSS. |
| 1058 | } |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 1059 | } |
| 1060 | |
| 1061 | // Used by Manager. |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 1062 | WiFiServiceRefPtr WiFi::GetService(const KeyValueStore &args, Error *error) { |
Darin Petkov | b65c245 | 2012-02-23 15:17:06 +0100 | [diff] [blame] | 1063 | CHECK_EQ(args.GetString(flimflam::kTypeProperty), flimflam::kTypeWifi); |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 1064 | |
| 1065 | if (args.ContainsString(flimflam::kModeProperty) && |
| 1066 | args.GetString(flimflam::kModeProperty) != |
| 1067 | flimflam::kModeManaged) { |
| 1068 | error->Populate(Error::kNotSupported, kManagerErrorUnsupportedServiceMode); |
| 1069 | return NULL; |
| 1070 | } |
| 1071 | |
| 1072 | if (!args.ContainsString(flimflam::kSSIDProperty)) { |
| 1073 | error->Populate(Error::kInvalidArguments, kManagerErrorSSIDRequired); |
| 1074 | return NULL; |
| 1075 | } |
| 1076 | |
| 1077 | string ssid = args.GetString(flimflam::kSSIDProperty); |
| 1078 | if (ssid.length() < 1) { |
| 1079 | error->Populate(Error::kInvalidNetworkName, kManagerErrorSSIDTooShort); |
| 1080 | return NULL; |
| 1081 | } |
| 1082 | |
| 1083 | if (ssid.length() > IEEE_80211::kMaxSSIDLen) { |
| 1084 | error->Populate(Error::kInvalidNetworkName, kManagerErrorSSIDTooLong); |
| 1085 | return NULL; |
| 1086 | } |
| 1087 | |
| 1088 | string security_method; |
| 1089 | if (args.ContainsString(flimflam::kSecurityProperty)) { |
| 1090 | security_method = args.GetString(flimflam::kSecurityProperty); |
| 1091 | } else { |
| 1092 | security_method = flimflam::kSecurityNone; |
| 1093 | } |
| 1094 | |
| 1095 | if (security_method != flimflam::kSecurityNone && |
| 1096 | security_method != flimflam::kSecurityWep && |
| 1097 | security_method != flimflam::kSecurityPsk && |
| 1098 | security_method != flimflam::kSecurityWpa && |
| 1099 | security_method != flimflam::kSecurityRsn && |
| 1100 | security_method != flimflam::kSecurity8021x) { |
| 1101 | error->Populate(Error::kNotSupported, |
| 1102 | kManagerErrorUnsupportedSecurityMode); |
| 1103 | return NULL; |
| 1104 | } |
| 1105 | |
| 1106 | if ((security_method == flimflam::kSecurityWep || |
| 1107 | security_method == flimflam::kSecurityPsk || |
| 1108 | security_method == flimflam::kSecurityWpa || |
| 1109 | security_method == flimflam::kSecurityRsn) && |
| 1110 | !args.ContainsString(flimflam::kPassphraseProperty)) { |
| 1111 | error->Populate(Error::kInvalidArguments, |
| 1112 | kManagerErrorPassphraseRequired); |
| 1113 | return NULL; |
| 1114 | } |
| 1115 | |
Paul Stewart | 6ab23a9 | 2011-11-09 17:17:47 -0800 | [diff] [blame] | 1116 | bool hidden_ssid; |
Paul Stewart | ced6a0b | 2011-11-08 15:32:04 -0800 | [diff] [blame] | 1117 | if (args.ContainsBool(flimflam::kWifiHiddenSsid)) { |
| 1118 | hidden_ssid = args.GetBool(flimflam::kWifiHiddenSsid); |
Paul Stewart | 6ab23a9 | 2011-11-09 17:17:47 -0800 | [diff] [blame] | 1119 | } else { |
| 1120 | // If the service is not found, and the caller hasn't specified otherwise, |
| 1121 | // we assume this is is a hidden network. |
| 1122 | hidden_ssid = true; |
Paul Stewart | ced6a0b | 2011-11-08 15:32:04 -0800 | [diff] [blame] | 1123 | } |
| 1124 | |
Paul Stewart | 6ab23a9 | 2011-11-09 17:17:47 -0800 | [diff] [blame] | 1125 | vector<uint8_t> ssid_bytes(ssid.begin(), ssid.end()); |
| 1126 | WiFiServiceRefPtr service(FindService(ssid_bytes, flimflam::kModeManaged, |
| 1127 | security_method)); |
| 1128 | if (!service.get()) { |
mukesh agrawal | 1a05626 | 2011-10-05 14:36:54 -0700 | [diff] [blame] | 1129 | service = new WiFiService(control_interface(), |
| 1130 | dispatcher(), |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 1131 | metrics(), |
mukesh agrawal | 1a05626 | 2011-10-05 14:36:54 -0700 | [diff] [blame] | 1132 | manager(), |
| 1133 | this, |
Paul Stewart | 6ab23a9 | 2011-11-09 17:17:47 -0800 | [diff] [blame] | 1134 | ssid_bytes, |
mukesh agrawal | 1a05626 | 2011-10-05 14:36:54 -0700 | [diff] [blame] | 1135 | flimflam::kModeManaged, |
Paul Stewart | ced6a0b | 2011-11-08 15:32:04 -0800 | [diff] [blame] | 1136 | security_method, |
| 1137 | hidden_ssid); |
| 1138 | services_.push_back(service); |
mukesh agrawal | 261daca | 2011-12-02 18:56:56 +0000 | [diff] [blame] | 1139 | // NB: We do not register the newly created Service with the Manager. |
| 1140 | // The Service will be registered if/when we find Endpoints for it. |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 1141 | } |
| 1142 | |
mukesh agrawal | 1a05626 | 2011-10-05 14:36:54 -0700 | [diff] [blame] | 1143 | if (security_method == flimflam::kSecurityWep || |
| 1144 | security_method == flimflam::kSecurityPsk || |
| 1145 | security_method == flimflam::kSecurityWpa || |
| 1146 | security_method == flimflam::kSecurityRsn) { |
| 1147 | service->SetPassphrase(args.GetString(flimflam::kPassphraseProperty), |
| 1148 | error); |
| 1149 | if (error->IsFailure()) { |
| 1150 | return NULL; |
| 1151 | } |
| 1152 | } |
| 1153 | |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 1154 | service->Configure(args, error); |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 1155 | |
Paul Stewart | 7f61e52 | 2012-03-22 11:13:45 -0700 | [diff] [blame] | 1156 | // TODO(pstew): Schedule a task to forget up all non-hidden services that |
| 1157 | // have no endpoints like the one we may have just created. crosbug.com/28224 |
| 1158 | |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 1159 | return service; |
| 1160 | } |
| 1161 | |
mukesh agrawal | 16bc1b8 | 2012-02-09 18:38:26 -0800 | [diff] [blame] | 1162 | // static |
| 1163 | bool WiFi::SanitizeSSID(string *ssid) { |
| 1164 | CHECK(ssid); |
| 1165 | |
| 1166 | size_t ssid_len = ssid->length(); |
| 1167 | size_t i; |
| 1168 | bool changed = false; |
| 1169 | |
Gary Morain | ac1bdb4 | 2012-02-16 17:42:29 -0800 | [diff] [blame] | 1170 | for (i = 0; i < ssid_len; ++i) { |
mukesh agrawal | 16bc1b8 | 2012-02-09 18:38:26 -0800 | [diff] [blame] | 1171 | if (!g_ascii_isprint((*ssid)[i])) { |
| 1172 | (*ssid)[i] = '?'; |
| 1173 | changed = true; |
| 1174 | } |
| 1175 | } |
| 1176 | |
| 1177 | return changed; |
| 1178 | } |
| 1179 | |
mukesh agrawal | 4d0401c | 2012-01-06 16:05:31 -0800 | [diff] [blame] | 1180 | void WiFi::HelpRegisterDerivedInt32( |
| 1181 | PropertyStore *store, |
| 1182 | const string &name, |
| 1183 | int32(WiFi::*get)(Error *error), |
| 1184 | void(WiFi::*set)(const int32 &value, Error *error)) { |
| 1185 | store->RegisterDerivedInt32( |
| 1186 | name, |
| 1187 | Int32Accessor(new CustomAccessor<WiFi, int32>(this, get, set))); |
| 1188 | } |
| 1189 | |
| 1190 | void WiFi::HelpRegisterDerivedString( |
| 1191 | PropertyStore *store, |
| 1192 | const string &name, |
| 1193 | string(WiFi::*get)(Error *error), |
| 1194 | void(WiFi::*set)(const string &value, Error *error)) { |
| 1195 | store->RegisterDerivedString( |
| 1196 | name, |
| 1197 | StringAccessor(new CustomAccessor<WiFi, string>(this, get, set))); |
| 1198 | } |
| 1199 | |
| 1200 | void WiFi::HelpRegisterDerivedUint16( |
| 1201 | PropertyStore *store, |
| 1202 | const string &name, |
| 1203 | uint16(WiFi::*get)(Error *error), |
| 1204 | void(WiFi::*set)(const uint16 &value, Error *error)) { |
| 1205 | store->RegisterDerivedUint16( |
| 1206 | name, |
| 1207 | Uint16Accessor(new CustomAccessor<WiFi, uint16>(this, get, set))); |
| 1208 | } |
| 1209 | |
Gary Morain | ac1bdb4 | 2012-02-16 17:42:29 -0800 | [diff] [blame] | 1210 | void WiFi::HandlePowerStateChange(PowerManager::SuspendState new_state) { |
mukesh agrawal | 5c05b29 | 2012-03-07 10:12:52 -0800 | [diff] [blame] | 1211 | LOG(INFO) << __func__; |
| 1212 | if (new_state == PowerManagerProxyDelegate::kOn) { |
| 1213 | // We want to flush the BSS cache, but we don't want to conflict |
| 1214 | // with a running scan or an active connection attempt. So record |
| 1215 | // the need to flush, and take care of flushing when the next scan |
| 1216 | // completes. |
| 1217 | // |
| 1218 | // Note that supplicant will automatically expire old cache |
| 1219 | // entries (after, e.g., a BSS is not found in two consecutive |
| 1220 | // scans). However, our explicit flush accelerates re-association |
| 1221 | // in cases where a BSS disappeared while we were asleep. (See, |
| 1222 | // e.g. WiFiRoaming.005SuspendRoam.) |
| 1223 | time_->GetTimeMonotonic(&resumed_at_); |
| 1224 | need_bss_flush_ = true; |
| 1225 | |
| 1226 | if (!scan_pending_ && IsIdle()) { |
| 1227 | // Not scanning/connecting/connected, so let's get things rolling. |
| 1228 | Scan(NULL); |
| 1229 | } |
Gary Morain | ac1bdb4 | 2012-02-16 17:42:29 -0800 | [diff] [blame] | 1230 | } |
| 1231 | } |
| 1232 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 1233 | } // namespace shill |