summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMartin Xu <martin.xu@intel.com>2009-07-10 12:29:21 +0800
committerMarcel Holtmann <marcel@holtmann.org>2009-07-09 22:27:27 -0700
commit50362b15a291893ec4a79168a24c6b2be3e6558a (patch)
tree0ba07c6307144d853998a167df0166951fd1efbf /plugins
parent1d08cedd8acf8fcce4a8201e204c08922299557a (diff)
downloadconnman-50362b15a291893ec4a79168a24c6b2be3e6558a.tar.gz
connman-50362b15a291893ec4a79168a24c6b2be3e6558a.tar.bz2
connman-50362b15a291893ec4a79168a24c6b2be3e6558a.zip
Add task_connect() function to WiFi supplicant
Diffstat (limited to 'plugins')
-rw-r--r--plugins/supplicant.c64
1 files changed, 34 insertions, 30 deletions
diff --git a/plugins/supplicant.c b/plugins/supplicant.c
index 945223bc..82f9ebeb 100644
--- a/plugins/supplicant.c
+++ b/plugins/supplicant.c
@@ -1388,6 +1388,39 @@ static enum supplicant_state string2state(const char *state)
return WPA_INVALID;
}
+static int task_connect(struct supplicant_task *task)
+{
+ const char *address, *security, *passphrase;
+ const void *ssid;
+ unsigned int ssid_len;
+
+ address = connman_network_get_string(task->network, "Address");
+ security = connman_network_get_string(task->network, "WiFi.Security");
+ passphrase = connman_network_get_string(task->network, "WiFi.Passphrase");
+
+ ssid = connman_network_get_blob(task->network, "WiFi.SSID", &ssid_len);
+
+ DBG("address %s security %s passphrase %s",
+ address, security, passphrase);
+
+ if (security == NULL && passphrase == NULL)
+ return -EINVAL;
+
+ if (g_str_equal(security, "none") == FALSE && passphrase == NULL)
+ return -EINVAL;
+
+ add_network(task);
+
+ select_network(task);
+ disable_network(task);
+
+ set_network(task, ssid, ssid_len, address, security, passphrase);
+
+ enable_network(task);
+
+ return 0;
+}
+
static void state_change(struct supplicant_task *task, DBusMessage *msg)
{
DBusError error;
@@ -1615,28 +1648,10 @@ int supplicant_scan(struct connman_device *device)
int supplicant_connect(struct connman_network *network)
{
struct supplicant_task *task;
- const char *address, *security, *passphrase;
- const void *ssid;
- unsigned int ssid_len;
int index;
DBG("network %p", network);
- address = connman_network_get_string(network, "Address");
- security = connman_network_get_string(network, "WiFi.Security");
- passphrase = connman_network_get_string(network, "WiFi.Passphrase");
-
- ssid = connman_network_get_blob(network, "WiFi.SSID", &ssid_len);
-
- DBG("address %s security %s passphrase %s",
- address, security, passphrase);
-
- if (security == NULL && passphrase == NULL)
- return -EINVAL;
-
- if (g_str_equal(security, "none") == FALSE && passphrase == NULL)
- return -EINVAL;
-
index = connman_network_get_index(network);
task = find_task_by_index(index);
@@ -1645,18 +1660,7 @@ int supplicant_connect(struct connman_network *network)
task->network = connman_network_ref(network);
- add_network(task);
-
- select_network(task);
- disable_network(task);
-
- set_network(task, ssid, ssid_len, address, security, passphrase);
-
- enable_network(task);
-
- connman_network_set_associating(task->network, TRUE);
-
- return 0;
+ return task_connect(task);
}
int supplicant_disconnect(struct connman_network *network)