summaryrefslogtreecommitdiffstats
path: root/components/wifi/wifi_test.cc
diff options
context:
space:
mode:
authormef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-13 18:25:17 +0000
committermef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-13 18:25:17 +0000
commite425d0367f95faebf357a0bd38e6e15750512ca1 (patch)
tree798b51ee7e6900a2585eb7bee4fa8fcb39b71475 /components/wifi/wifi_test.cc
parent67675306efb33be9b362be04d6bf76ce8acff8c7 (diff)
downloadchromium_src-e425d0367f95faebf357a0bd38e6e15750512ca1.zip
chromium_src-e425d0367f95faebf357a0bd38e6e15750512ca1.tar.gz
chromium_src-e425d0367f95faebf357a0bd38e6e15750512ca1.tar.bz2
Implement Networking Private API CreateNetwork function on Windows. Allows connection to hidden WiFi networks.
Defaults to TKIP encryption for WAPPSK and AES encryption for WAP2PSK. Exact encryption to use will have to be determined during Connect. TBR=cpu@chromium.org for +third_party/libxml to DEPS. BUG=267667 Review URL: https://codereview.chromium.org/105153002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240703 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/wifi/wifi_test.cc')
-rw-r--r--components/wifi/wifi_test.cc48
1 files changed, 37 insertions, 11 deletions
diff --git a/components/wifi/wifi_test.cc b/components/wifi/wifi_test.cc
index eae084f..ff27b0d 100644
--- a/components/wifi/wifi_test.cc
+++ b/components/wifi/wifi_test.cc
@@ -67,10 +67,13 @@ WiFiTest::Result WiFiTest::Main(int argc, const char* argv[]) {
VLOG(0) << "Usage: " << argv[0] <<
" [--list]"
" [--get_properties]"
+ " [--create]"
" [--connect]"
" [--disconnect]"
" [--network_guid=<network_guid>]"
" [--frequency=0|2400|5000]"
+ " [--security=none|WEP-PSK|WPA-PSK|WPA2-PSK]"
+ " [--password=<wifi password>]"
" [<network_guid>]\n";
return RESULT_WRONG_USAGE;
}
@@ -88,6 +91,10 @@ bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) {
parsed_command_line.GetSwitchValueASCII("network_guid");
std::string frequency =
parsed_command_line.GetSwitchValueASCII("frequency");
+ std::string password =
+ parsed_command_line.GetSwitchValueASCII("password");
+ std::string security =
+ parsed_command_line.GetSwitchValueASCII("security");
if (parsed_command_line.GetArgs().size() == 1) {
#if defined(OS_WIN)
@@ -127,26 +134,45 @@ bool WiFiTest::ParseCommandLine(int argc, const char* argv[]) {
}
}
- // Optional properties (frequency, password) to use for connect.
- scoped_ptr<DictionaryValue> connect_properties(new DictionaryValue());
+ // Optional properties (frequency, password) to use for connect or create.
+ scoped_ptr<DictionaryValue> properties(new DictionaryValue());
- if (parsed_command_line.HasSwitch("frequency")) {
+ if (!frequency.empty()) {
int value = 0;
- if (!network_guid.empty() &&
- !frequency.empty() &&
- base::StringToInt(frequency, &value)) {
- connect_properties->SetInteger("WiFi.Frequency", value);
+ if (base::StringToInt(frequency, &value)) {
+ properties->SetInteger("WiFi.Frequency", value);
// fall through to connect.
}
}
+ if (!password.empty())
+ properties->SetString("WiFi.Passphrase", password);
+
+ if (!security.empty())
+ properties->SetString("WiFi.Security", security);
+
+ if (parsed_command_line.HasSwitch("create")) {
+ if (!network_guid.empty()) {
+ std::string error;
+ std::string new_network_guid;
+ properties->SetString("WiFi.SSID", network_guid);
+ VLOG(0) << "Creating Network: " << *properties;
+ wifi_service->CreateNetwork(false,
+ properties.Pass(),
+ &new_network_guid,
+ &error);
+ VLOG(0) << error << ":\n" << new_network_guid;
+ return true;
+ }
+ }
+
if (parsed_command_line.HasSwitch("connect")) {
- if (network_guid.length() > 0) {
+ if (!network_guid.empty()) {
std::string error;
- if (!connect_properties->empty()) {
- VLOG(0) << "Using connect properties: " << *connect_properties;
+ if (!properties->empty()) {
+ VLOG(0) << "Using connect properties: " << *properties;
wifi_service->SetProperties(network_guid,
- connect_properties.Pass(),
+ properties.Pass(),
&error);
}
wifi_service->StartConnect(network_guid, &error);