shill: WiFiService: Connect to generic form of service
When connecting to a WPA/RSN/PSK service, use the generic form
when instructing wpa_supplicant to connect, so that it will connect
to either "RSN" or "WPA" networks. There was originally a thought
to restrict this to only the network type specified via the
|security_| field in the service, but since the |security_| field
of WiFi services have historically been created and saved based on
the security mode of the first observed endpoint, this can overly
constrain which APs wpa_supplicant should be allowed to connect to.
While doing this, make sure that connection metrics refer to the
security of the AP that we've connected to instead of the (possibly
generic) version of the security of the service.
BUG=chromium-os:39813
TEST=Unit tests, network_WiFiSecMat
Change-Id: I6c192a247f10f03f88d1ec04856fcdc7bf8e96b6
Reviewed-on: https://gerrit.chromium.org/gerrit/45122
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Ashok Nagarajan <asnagarajan@chromium.org>
Tested-by: Ashok Nagarajan <asnagarajan@chromium.org>
Commit-Queue: Paul Stewart <pstew@chromium.org>
diff --git a/wifi_service.cc b/wifi_service.cc
index 7f9f4f2..a86b1bd 100644
--- a/wifi_service.cc
+++ b/wifi_service.cc
@@ -344,8 +344,12 @@
static_cast<Metrics::WiFiNetworkPhyMode>(physical_mode_),
Metrics::kWiFiNetworkPhyModeMax);
+ string security_mode = security_;
+ if (current_endpoint_) {
+ security_mode = current_endpoint_->security_mode();
+ }
Metrics::WiFiSecurity security_uma =
- Metrics::WiFiSecurityStringToEnum(security_);
+ Metrics::WiFiSecurityStringToEnum(security_mode);
DCHECK(security_uma != Metrics::kWiFiSecurityUnknown);
metrics()->SendEnumToUMA(
metrics()->GetFullMetricName(Metrics::kMetricNetworkSecurity,
@@ -473,7 +477,9 @@
SetEAPKeyManagement("WPA-EAP");
Populate8021xProperties(¶ms);
ClearEAPCertification();
- } else if (security_ == flimflam::kSecurityPsk) {
+ } else if (security_ == flimflam::kSecurityPsk ||
+ security_ == flimflam::kSecurityRsn ||
+ security_ == flimflam::kSecurityWpa) {
const string psk_proto = StringPrintf("%s %s",
wpa_supplicant::kSecurityModeWPA,
wpa_supplicant::kSecurityModeRSN);
@@ -481,16 +487,6 @@
append_string(psk_proto.c_str());
params[wpa_supplicant::kPropertyPreSharedKey].writer().
append_string(passphrase_.c_str());
- } else if (security_ == flimflam::kSecurityRsn) {
- params[wpa_supplicant::kPropertySecurityProtocol].writer().
- append_string(wpa_supplicant::kSecurityModeRSN);
- params[wpa_supplicant::kPropertyPreSharedKey].writer().
- append_string(passphrase_.c_str());
- } else if (security_ == flimflam::kSecurityWpa) {
- params[wpa_supplicant::kPropertySecurityProtocol].writer().
- append_string(wpa_supplicant::kSecurityModeWPA);
- params[wpa_supplicant::kPropertyPreSharedKey].writer().
- append_string(passphrase_.c_str());
} else if (security_ == flimflam::kSecurityWep) {
params[wpa_supplicant::kPropertyAuthAlg].writer().
append_string(wpa_supplicant::kSecurityAuthAlg);