Commit 9d85ada6 authored by stevenjb@chromium.org's avatar stevenjb@chromium.org

Parse and store Wifi bssid and frequency properites.

Change-Id: Iadd9a6202f0b09e7d3f4171ae7341b2cd8e6e63a

BUG=chromium-os:28616, chromium-os:19569
TEST=Will be tested with implementation of chromium-os:19569


Review URL: http://codereview.chromium.org/10169014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133541 0039d316-1c4b-4281-b951-d872f2087c98
parent 1f93da45
......@@ -1040,17 +1040,30 @@ bool NativeWifiNetworkParser::ParseValue(PropertyIndex index,
std::string ssid_hex;
if (!value.GetAsString(&ssid_hex))
return false;
wifi_network->SetHexSsid(ssid_hex);
return true;
}
case PROPERTY_INDEX_WIFI_BSSID:
case PROPERTY_INDEX_WIFI_AUTH_MODE:
case PROPERTY_INDEX_WIFI_PHY_MODE:
case PROPERTY_INDEX_WIFI_HIDDEN_SSID:
case PROPERTY_INDEX_WIFI_FREQUENCY:
// These properties are currently not used in the UI.
case PROPERTY_INDEX_WIFI_BSSID: {
std::string bssid;
if (!value.GetAsString(&bssid))
return false;
wifi_network->set_bssid(bssid);
return true;
}
case PROPERTY_INDEX_WIFI_HIDDEN_SSID: {
bool hidden_ssid;
if (!value.GetAsBoolean(&hidden_ssid))
return false;
wifi_network->set_hidden_ssid(hidden_ssid);
return true;
}
case PROPERTY_INDEX_WIFI_FREQUENCY: {
int frequency;
if (!value.GetAsInteger(&frequency))
return false;
wifi_network->set_frequency(frequency);
return true;
}
case PROPERTY_INDEX_NAME: {
// Does not change network name when it was already set by WiFi.HexSSID.
if (!wifi_network->name().empty())
......@@ -1084,7 +1097,6 @@ bool NativeWifiNetworkParser::ParseValue(PropertyIndex index,
}
case PROPERTY_INDEX_PASSPHRASE_REQUIRED: {
bool passphrase_required;
value.GetAsBoolean(&passphrase_required);
if (!value.GetAsBoolean(&passphrase_required))
break;
wifi_network->set_passphrase_required(passphrase_required);
......@@ -1161,6 +1173,8 @@ bool NativeWifiNetworkParser::ParseValue(PropertyIndex index,
wifi_network->set_eap_server_ca_cert_nss_nickname(eap_cert_nickname);
return true;
}
case PROPERTY_INDEX_WIFI_AUTH_MODE:
case PROPERTY_INDEX_WIFI_PHY_MODE:
case PROPERTY_INDEX_EAP_CLIENT_CERT:
case PROPERTY_INDEX_EAP_CLIENT_CERT_NSS:
case PROPERTY_INDEX_EAP_PRIVATE_KEY:
......
......@@ -1166,6 +1166,7 @@ WifiNetwork::WifiNetwork(const std::string& service_path)
encryption_(SECURITY_NONE),
passphrase_required_(false),
hidden_ssid_(false),
frequency_(0),
eap_method_(EAP_METHOD_UNKNOWN),
eap_phase_2_auth_(EAP_PHASE_2_AUTH_AUTO),
eap_use_system_cas_(true),
......
......@@ -966,6 +966,12 @@ class WifiNetwork : public WirelessNetwork {
void SetEncryption(ConnectionSecurity encryption) {
network_->set_encryption(encryption);
}
void SetSsid(const std::string& ssid) {
network_->SetSsid(ssid);
}
void SetHexSsid(const std::string& ssid_hex) {
network_->SetHexSsid(ssid_hex);
}
private:
WifiNetwork* network_;
};
......@@ -980,6 +986,8 @@ class WifiNetwork : public WirelessNetwork {
const std::string& identity() const { return identity_; }
bool passphrase_required() const { return passphrase_required_; }
bool hidden_ssid() const { return hidden_ssid_; }
const std::string& bssid() const { return bssid_; }
int frequency() const { return frequency_; }
EAPMethod eap_method() const { return eap_method_; }
EAPPhase2Auth eap_phase_2_auth() const { return eap_phase_2_auth_; }
......@@ -997,8 +1005,8 @@ class WifiNetwork : public WirelessNetwork {
const std::string& GetPassphrase() const;
bool SetSsid(const std::string& ssid);
bool SetHexSsid(const std::string& ssid_hex);
// Set property and call SetNetworkServiceProperty:
void SetPassphrase(const std::string& passphrase);
void SetIdentity(const std::string& identity);
void SetHiddenSSID(bool hidden_ssid);
......@@ -1042,6 +1050,10 @@ class WifiNetwork : public WirelessNetwork {
// parsers to set state, and really shouldn't be used by anything else
// because they don't do the error checking and sending to the
// network layer that the other setters do.
bool SetSsid(const std::string& ssid);
bool SetHexSsid(const std::string& ssid_hex);
void set_encryption(ConnectionSecurity encryption) {
encryption_ = encryption;
}
......@@ -1058,6 +1070,8 @@ class WifiNetwork : public WirelessNetwork {
void set_hidden_ssid(bool hidden_ssid) {
hidden_ssid_ = hidden_ssid;
}
void set_bssid(const std::string& bssid) { bssid_ = bssid; }
void set_frequency(int frequency) { frequency_ = frequency; }
void set_eap_method(EAPMethod eap_method) { eap_method_ = eap_method; }
void set_eap_phase_2_auth(EAPPhase2Auth eap_phase_2_auth) {
eap_phase_2_auth_ = eap_phase_2_auth;
......@@ -1104,6 +1118,8 @@ class WifiNetwork : public WirelessNetwork {
bool passphrase_required_;
std::string identity_;
bool hidden_ssid_;
std::string bssid_;
int frequency_;
EAPMethod eap_method_;
EAPPhase2Auth eap_phase_2_auth_;
......
......@@ -151,7 +151,8 @@ TEST(NetworkLibraryTest, DecodeNonAsciiSSID) {
std::string wifi_utf8 = "UTF-8 \u3042\u3044\u3046";
std::string wifi_utf8_result = "UTF-8 \xE3\x81\x82\xE3\x81\x84\xE3\x81\x86";
WifiNetwork* wifi = new WifiNetwork("fw");
wifi->SetSsid(wifi_utf8);
WifiNetwork::TestApi test_wifi(wifi);
test_wifi.SetSsid(wifi_utf8);
EXPECT_EQ(wifi->name(), wifi_utf8_result);
delete wifi;
}
......@@ -161,7 +162,8 @@ TEST(NetworkLibraryTest, DecodeNonAsciiSSID) {
std::string wifi_latin1 = "latin-1 \xc0\xcb\xcc\xd6\xfb";
std::string wifi_latin1_result = "latin-1 \u00c0\u00cb\u00cc\u00d6\u00fb";
WifiNetwork* wifi = new WifiNetwork("fw");
wifi->SetSsid(wifi_latin1);
WifiNetwork::TestApi test_wifi(wifi);
test_wifi.SetSsid(wifi_latin1);
EXPECT_EQ(wifi->name(), wifi_latin1_result);
delete wifi;
}
......@@ -171,7 +173,8 @@ TEST(NetworkLibraryTest, DecodeNonAsciiSSID) {
std::string wifi_hex = "5468697320697320484558205353494421";
std::string wifi_hex_result = "This is HEX SSID!";
WifiNetwork* wifi = new WifiNetwork("fw");
wifi->SetHexSsid(wifi_hex);
WifiNetwork::TestApi test_wifi(wifi);
test_wifi.SetHexSsid(wifi_hex);
EXPECT_EQ(wifi->name(), wifi_hex_result);
delete wifi;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment