5 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 #include <dbus/dbus.h>
32 #define CONNMAN_API_SUBJECT_TO_CHANGE
33 #include <connman/log.h>
34 #include <connman/dbus.h>
37 #include "supplicant.h"
41 #define IEEE80211_CAP_ESS 0x0001
42 #define IEEE80211_CAP_IBSS 0x0002
43 #define IEEE80211_CAP_PRIVACY 0x0010
45 struct supplicant_task {
48 struct connman_device *device;
49 struct supplicant_callback *callback;
53 enum supplicant_state state;
56 static GSList *task_list = NULL;
58 static DBusConnection *connection;
60 static struct supplicant_task *find_task_by_index(int index)
64 for (list = task_list; list; list = list->next) {
65 struct supplicant_task *task = list->data;
67 if (task->ifindex == index)
74 static struct supplicant_task *find_task_by_path(const char *path)
78 for (list = task_list; list; list = list->next) {
79 struct supplicant_task *task = list->data;
81 if (g_str_equal(task->path, path) == TRUE)
88 static int get_interface(struct supplicant_task *task)
90 DBusMessage *message, *reply;
96 message = dbus_message_new_method_call(SUPPLICANT_NAME, SUPPLICANT_PATH,
97 SUPPLICANT_INTF, "getInterface");
101 dbus_message_append_args(message, DBUS_TYPE_STRING, &task->ifname,
104 dbus_error_init(&error);
106 reply = dbus_connection_send_with_reply_and_block(connection,
107 message, -1, &error);
109 if (dbus_error_is_set(&error) == TRUE) {
110 connman_error("%s", error.message);
111 dbus_error_free(&error);
113 connman_error("Failed to get interface");
114 dbus_message_unref(message);
118 dbus_message_unref(message);
120 dbus_error_init(&error);
122 if (dbus_message_get_args(reply, &error, DBUS_TYPE_OBJECT_PATH, &path,
123 DBUS_TYPE_INVALID) == FALSE) {
124 if (dbus_error_is_set(&error) == TRUE) {
125 connman_error("%s", error.message);
126 dbus_error_free(&error);
128 connman_error("Wrong arguments for interface");
129 dbus_message_unref(reply);
133 DBG("path %s", path);
135 task->path = g_strdup(path);
136 task->created = FALSE;
138 dbus_message_unref(reply);
143 static int add_interface(struct supplicant_task *task)
145 DBusMessage *message, *reply;
149 DBG("task %p", task);
151 message = dbus_message_new_method_call(SUPPLICANT_NAME, SUPPLICANT_PATH,
152 SUPPLICANT_INTF, "addInterface");
156 dbus_error_init(&error);
158 dbus_message_append_args(message, DBUS_TYPE_STRING, &task->ifname,
161 reply = dbus_connection_send_with_reply_and_block(connection,
162 message, -1, &error);
164 if (dbus_error_is_set(&error) == TRUE) {
165 connman_error("%s", error.message);
166 dbus_error_free(&error);
168 connman_error("Failed to add interface");
169 dbus_message_unref(message);
173 dbus_message_unref(message);
175 dbus_error_init(&error);
177 if (dbus_message_get_args(reply, &error, DBUS_TYPE_OBJECT_PATH, &path,
178 DBUS_TYPE_INVALID) == FALSE) {
179 if (dbus_error_is_set(&error) == TRUE) {
180 connman_error("%s", error.message);
181 dbus_error_free(&error);
183 connman_error("Wrong arguments for interface");
184 dbus_message_unref(reply);
188 DBG("path %s", path);
190 task->path = g_strdup(path);
191 task->created = TRUE;
193 dbus_message_unref(reply);
198 static int remove_interface(struct supplicant_task *task)
200 DBusMessage *message, *reply;
203 DBG("task %p", task);
205 if (task->created == FALSE)
208 message = dbus_message_new_method_call(SUPPLICANT_NAME, SUPPLICANT_PATH,
209 SUPPLICANT_INTF, "removeInterface");
213 dbus_message_append_args(message, DBUS_TYPE_OBJECT_PATH, &task->path,
216 dbus_error_init(&error);
218 reply = dbus_connection_send_with_reply_and_block(connection,
219 message, -1, &error);
221 if (dbus_error_is_set(&error) == TRUE) {
222 connman_error("%s", error.message);
223 dbus_error_free(&error);
225 connman_error("Failed to remove interface");
226 dbus_message_unref(message);
230 dbus_message_unref(message);
232 dbus_message_unref(reply);
237 static int set_ap_scan(struct supplicant_task *task)
239 DBusMessage *message, *reply;
243 DBG("task %p", task);
245 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->path,
246 SUPPLICANT_INTF ".Interface", "setAPScan");
250 dbus_message_append_args(message, DBUS_TYPE_UINT32, &ap_scan,
253 dbus_error_init(&error);
255 reply = dbus_connection_send_with_reply_and_block(connection,
256 message, -1, &error);
258 if (dbus_error_is_set(&error) == TRUE) {
259 connman_error("%s", error.message);
260 dbus_error_free(&error);
262 connman_error("Failed to set AP scan");
263 dbus_message_unref(message);
267 dbus_message_unref(message);
269 dbus_message_unref(reply);
274 static int add_network(struct supplicant_task *task)
276 DBusMessage *message, *reply;
280 DBG("task %p", task);
282 if (task->network != NULL)
285 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->path,
286 SUPPLICANT_INTF ".Interface", "addNetwork");
290 dbus_error_init(&error);
292 reply = dbus_connection_send_with_reply_and_block(connection,
293 message, -1, &error);
295 if (dbus_error_is_set(&error) == TRUE) {
296 connman_error("%s", error.message);
297 dbus_error_free(&error);
299 connman_error("Failed to add network");
300 dbus_message_unref(message);
304 dbus_message_unref(message);
306 dbus_error_init(&error);
308 if (dbus_message_get_args(reply, &error, DBUS_TYPE_OBJECT_PATH, &path,
309 DBUS_TYPE_INVALID) == FALSE) {
310 if (dbus_error_is_set(&error) == TRUE) {
311 connman_error("%s", error.message);
312 dbus_error_free(&error);
314 connman_error("Wrong arguments for network");
315 dbus_message_unref(reply);
319 DBG("path %s", path);
321 task->network = g_strdup(path);
323 dbus_message_unref(reply);
328 static int remove_network(struct supplicant_task *task)
330 DBusMessage *message, *reply;
333 DBG("task %p", task);
335 if (task->network == NULL)
338 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->path,
339 SUPPLICANT_INTF ".Interface", "removeNetwork");
343 dbus_message_append_args(message, DBUS_TYPE_OBJECT_PATH, &task->network,
346 dbus_error_init(&error);
348 reply = dbus_connection_send_with_reply_and_block(connection,
349 message, -1, &error);
351 if (dbus_error_is_set(&error) == TRUE) {
352 connman_error("%s", error.message);
353 dbus_error_free(&error);
355 connman_error("Failed to remove network");
356 dbus_message_unref(message);
360 dbus_message_unref(message);
362 dbus_message_unref(reply);
364 g_free(task->network);
365 task->network = NULL;
370 static int select_network(struct supplicant_task *task)
372 DBusMessage *message, *reply;
375 DBG("task %p", task);
377 if (task->network == NULL)
380 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->path,
381 SUPPLICANT_INTF ".Interface", "selectNetwork");
385 dbus_message_append_args(message, DBUS_TYPE_OBJECT_PATH, &task->network,
388 dbus_error_init(&error);
390 reply = dbus_connection_send_with_reply_and_block(connection,
391 message, -1, &error);
393 if (dbus_error_is_set(&error) == TRUE) {
394 connman_error("%s", error.message);
395 dbus_error_free(&error);
397 connman_error("Failed to select network");
398 dbus_message_unref(message);
402 dbus_message_unref(message);
404 dbus_message_unref(reply);
409 static int enable_network(struct supplicant_task *task)
411 DBusMessage *message, *reply;
414 DBG("task %p", task);
416 if (task->network == NULL)
419 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->network,
420 SUPPLICANT_INTF ".Network", "enable");
424 dbus_error_init(&error);
426 reply = dbus_connection_send_with_reply_and_block(connection,
427 message, -1, &error);
429 if (dbus_error_is_set(&error) == TRUE) {
430 connman_error("%s", error.message);
431 dbus_error_free(&error);
433 connman_error("Failed to enable network");
434 dbus_message_unref(message);
438 dbus_message_unref(message);
440 dbus_message_unref(reply);
445 static int disable_network(struct supplicant_task *task)
447 DBusMessage *message, *reply;
450 DBG("task %p", task);
452 if (task->network == NULL)
455 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->network,
456 SUPPLICANT_INTF ".Network", "disable");
460 dbus_error_init(&error);
462 reply = dbus_connection_send_with_reply_and_block(connection,
463 message, -1, &error);
465 if (dbus_error_is_set(&error) == TRUE) {
466 connman_error("%s", error.message);
467 dbus_error_free(&error);
469 connman_error("Failed to disable network");
470 dbus_message_unref(message);
474 dbus_message_unref(message);
476 dbus_message_unref(reply);
481 static int set_network(struct supplicant_task *task,
482 const unsigned char *network, int len,
483 const char *security, const char *passphrase)
485 DBusMessage *message, *reply;
486 DBusMessageIter array, dict;
489 DBG("task %p", task);
491 if (task->network == NULL)
494 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->network,
495 SUPPLICANT_INTF ".Network", "set");
499 dbus_message_iter_init_append(message, &array);
501 dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY,
502 DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
503 DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
504 DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
506 connman_dbus_dict_append_array(&dict, "ssid",
507 DBUS_TYPE_BYTE, &network, len);
509 if (g_ascii_strcasecmp(security, "wpa") == 0 ||
510 g_ascii_strcasecmp(security, "wpa2") == 0) {
511 const char *key_mgmt = "WPA-PSK";
512 connman_dbus_dict_append_variant(&dict, "key_mgmt",
513 DBUS_TYPE_STRING, &key_mgmt);
515 if (passphrase && strlen(passphrase) > 0)
516 connman_dbus_dict_append_variant(&dict, "psk",
517 DBUS_TYPE_STRING, &passphrase);
518 } else if (g_ascii_strcasecmp(security, "wep") == 0) {
519 const char *key_mgmt = "NONE", *index = "0";
520 connman_dbus_dict_append_variant(&dict, "key_mgmt",
521 DBUS_TYPE_STRING, &key_mgmt);
524 int size = strlen(passphrase);
525 if (size == 10 || size == 26) {
526 unsigned char *key = malloc(13);
529 memset(tmp, 0, sizeof(tmp));
532 for (i = 0; i < size / 2; i++) {
533 memcpy(tmp, passphrase + (i * 2), 2);
534 key[i] = (unsigned char) strtol(tmp,
537 connman_dbus_dict_append_array(&dict,
538 "wep_key0", DBUS_TYPE_BYTE,
542 connman_dbus_dict_append_variant(&dict,
543 "wep_key0", DBUS_TYPE_STRING,
545 connman_dbus_dict_append_variant(&dict, "wep_tx_keyidx",
546 DBUS_TYPE_STRING, &index);
549 const char *key_mgmt = "NONE";
550 connman_dbus_dict_append_variant(&dict, "key_mgmt",
551 DBUS_TYPE_STRING, &key_mgmt);
554 dbus_message_iter_close_container(&array, &dict);
556 dbus_error_init(&error);
558 reply = dbus_connection_send_with_reply_and_block(connection,
559 message, -1, &error);
561 if (dbus_error_is_set(&error) == TRUE) {
562 connman_error("%s", error.message);
563 dbus_error_free(&error);
565 connman_error("Failed to set network options");
566 dbus_message_unref(message);
570 dbus_message_unref(message);
572 dbus_message_unref(reply);
577 static int initiate_scan(struct supplicant_task *task)
579 DBusMessage *message;
580 DBusPendingCall *call;
582 DBG("task %p", task);
584 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->path,
585 SUPPLICANT_INTF ".Interface", "scan");
589 if (dbus_connection_send_with_reply(connection, message,
590 &call, TIMEOUT) == FALSE) {
591 connman_error("Failed to initiate scan");
592 dbus_message_unref(message);
596 dbus_message_unref(message);
601 static void extract_ssid(struct supplicant_network *network,
602 DBusMessageIter *value)
604 DBusMessageIter array;
608 dbus_message_iter_recurse(value, &array);
609 dbus_message_iter_get_fixed_array(&array, &ssid, &ssid_len);
614 network->ssid = g_try_malloc(ssid_len);
615 if (network->ssid == NULL)
618 memcpy(network->ssid, ssid, ssid_len);
619 network->ssid_len = ssid_len;
621 network->identifier = g_try_malloc0(ssid_len + 1);
622 if (network->identifier == NULL)
625 memcpy(network->identifier, ssid, ssid_len);
628 static void extract_wpaie(struct supplicant_network *network,
629 DBusMessageIter *value)
631 DBusMessageIter array;
635 dbus_message_iter_recurse(value, &array);
636 dbus_message_iter_get_fixed_array(&array, &ie, &ie_len);
639 network->has_wpa = TRUE;
642 static void extract_rsnie(struct supplicant_network *network,
643 DBusMessageIter *value)
645 DBusMessageIter array;
649 dbus_message_iter_recurse(value, &array);
650 dbus_message_iter_get_fixed_array(&array, &ie, &ie_len);
653 network->has_rsn = TRUE;
656 static void extract_capabilites(struct supplicant_network *network,
657 DBusMessageIter *value)
659 dbus_message_iter_get_basic(value, &network->capabilities);
661 if (network->capabilities & IEEE80211_CAP_ESS)
662 network->adhoc = FALSE;
663 else if (network->capabilities & IEEE80211_CAP_IBSS)
664 network->adhoc = TRUE;
666 if (network->capabilities & IEEE80211_CAP_PRIVACY)
667 network->has_wep = TRUE;
670 static void properties_reply(DBusPendingCall *call, void *user_data)
672 struct supplicant_task *task = user_data;
673 struct supplicant_network *network;
675 DBusMessageIter array, dict;
677 DBG("task %p", task);
679 reply = dbus_pending_call_steal_reply(call);
681 network = g_try_new0(struct supplicant_network, 1);
685 dbus_message_iter_init(reply, &array);
687 dbus_message_iter_recurse(&array, &dict);
689 while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
690 DBusMessageIter entry, value;
693 dbus_message_iter_recurse(&dict, &entry);
694 dbus_message_iter_get_basic(&entry, &key);
696 dbus_message_iter_next(&entry);
698 dbus_message_iter_recurse(&entry, &value);
700 //type = dbus_message_iter_get_arg_type(&value);
701 //dbus_message_iter_get_basic(&value, &val);
708 * frequency : i (105)
709 * capabilities : q (113)
716 if (g_str_equal(key, "ssid") == TRUE)
717 extract_ssid(network, &value);
718 else if (g_str_equal(key, "wpaie") == TRUE)
719 extract_wpaie(network, &value);
720 else if (g_str_equal(key, "rsnie") == TRUE)
721 extract_rsnie(network, &value);
722 else if (g_str_equal(key, "capabilities") == TRUE)
723 extract_capabilites(network, &value);
724 else if (g_str_equal(key, "quality") == TRUE)
725 dbus_message_iter_get_basic(&value, &network->quality);
726 else if (g_str_equal(key, "noise") == TRUE)
727 dbus_message_iter_get_basic(&value, &network->noise);
728 else if (g_str_equal(key, "level") == TRUE)
729 dbus_message_iter_get_basic(&value, &network->level);
730 else if (g_str_equal(key, "maxrate") == TRUE)
731 dbus_message_iter_get_basic(&value, &network->maxrate);
734 dbus_message_iter_next(&dict);
737 if (task->callback && task->callback->scan_result)
738 task->callback->scan_result(task->device, network);
740 g_free(network->identifier);
741 g_free(network->ssid);
745 dbus_message_unref(reply);
748 static int get_network_properties(struct supplicant_task *task,
751 DBusMessage *message;
752 DBusPendingCall *call;
754 message = dbus_message_new_method_call(SUPPLICANT_NAME, path,
755 SUPPLICANT_INTF ".BSSID",
760 if (dbus_connection_send_with_reply(connection, message,
761 &call, TIMEOUT) == FALSE) {
762 connman_error("Failed to get network properties");
763 dbus_message_unref(message);
767 dbus_pending_call_set_notify(call, properties_reply, task, NULL);
769 dbus_message_unref(message);
774 static void scan_results_reply(DBusPendingCall *call, void *user_data)
776 struct supplicant_task *task = user_data;
782 DBG("task %p", task);
784 reply = dbus_pending_call_steal_reply(call);
786 dbus_error_init(&error);
788 if (dbus_message_get_args(reply, &error,
789 DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH,
790 &results, &num_results,
791 DBUS_TYPE_INVALID) == FALSE) {
792 if (dbus_error_is_set(&error) == TRUE) {
793 connman_error("%s", error.message);
794 dbus_error_free(&error);
796 connman_error("Wrong arguments for scan result");
800 if (task->callback && task->callback->clear_results)
801 task->callback->clear_results(task->device);
803 for (i = 0; i < num_results; i++)
804 get_network_properties(task, results[i]);
809 dbus_message_unref(reply);
812 static int scan_results_available(struct supplicant_task *task)
814 DBusMessage *message;
815 DBusPendingCall *call;
817 DBG("task %p", task);
819 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->path,
820 SUPPLICANT_INTF ".Interface",
825 if (dbus_connection_send_with_reply(connection, message,
826 &call, TIMEOUT) == FALSE) {
827 connman_error("Failed to request scan result");
828 dbus_message_unref(message);
832 dbus_pending_call_set_notify(call, scan_results_reply, task, NULL);
834 dbus_message_unref(message);
839 static void state_change(struct supplicant_task *task, DBusMessage *msg)
842 const char *state, *previous;
844 dbus_error_init(&error);
846 if (dbus_message_get_args(msg, &error, DBUS_TYPE_STRING, &state,
847 DBUS_TYPE_STRING, &previous,
848 DBUS_TYPE_INVALID) == FALSE) {
849 if (dbus_error_is_set(&error) == TRUE) {
850 connman_error("%s", error.message);
851 dbus_error_free(&error);
853 connman_error("Wrong arguments for state change");
857 DBG("state %s ==> %s", previous, state);
859 if (g_str_equal(state, "INACTIVE") == TRUE)
860 task->state = STATE_INACTIVE;
861 else if (g_str_equal(state, "SCANNING") == TRUE)
862 task->state = STATE_SCANNING;
863 else if (g_str_equal(state, "ASSOCIATING") == TRUE)
864 task->state = STATE_ASSOCIATING;
865 else if (g_str_equal(state, "ASSOCIATED") == TRUE)
866 task->state = STATE_ASSOCIATED;
867 else if (g_str_equal(state, "GROUP_HANDSHAKE") == TRUE)
868 task->state = STATE_4WAY_HANDSHAKE;
869 else if (g_str_equal(state, "4WAY_HANDSHAKE") == TRUE)
870 task->state = STATE_4WAY_HANDSHAKE;
871 else if (g_str_equal(state, "COMPLETED") == TRUE)
872 task->state = STATE_COMPLETED;
873 else if (g_str_equal(state, "DISCONNECTED") == TRUE)
874 task->state = STATE_DISCONNECTED;
876 if (task->callback && task->callback->state_change)
877 task->callback->state_change(task->device, task->state);
879 switch (task->state) {
880 case STATE_COMPLETED:
883 case STATE_DISCONNECTED:
891 static DBusHandlerResult supplicant_filter(DBusConnection *conn,
892 DBusMessage *msg, void *data)
894 struct supplicant_task *task;
895 const char *member, *path;
897 if (dbus_message_has_interface(msg,
898 SUPPLICANT_INTF ".Interface") == FALSE)
899 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
901 member = dbus_message_get_member(msg);
903 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
905 path = dbus_message_get_path(msg);
907 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
909 task = find_task_by_path(path);
911 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
913 DBG("task %p member %s", task, member);
915 if (g_str_equal(member, "ScanResultsAvailable") == TRUE)
916 scan_results_available(task);
917 else if (g_str_equal(member, "StateChange") == TRUE)
918 state_change(task, msg);
920 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
923 static int add_filter(struct supplicant_task *task)
928 filter = g_strdup_printf("type=signal,interface=%s.Interface,path=%s",
929 SUPPLICANT_INTF, task->path);
931 DBG("filter %s", filter);
933 dbus_error_init(&error);
935 dbus_bus_add_match(connection, filter, &error);
939 if (dbus_error_is_set(&error) == TRUE) {
940 connman_error("Can't add match: %s", error.message);
941 dbus_error_free(&error);
947 static int remove_filter(struct supplicant_task *task)
952 filter = g_strdup_printf("type=signal,interface=%s.Interface,path=%s",
953 SUPPLICANT_INTF, task->path);
955 DBG("filter %s", filter);
957 dbus_error_init(&error);
959 dbus_bus_remove_match(connection, filter, &error);
963 if (dbus_error_is_set(&error) == TRUE) {
964 connman_error("Can't add match: %s", error.message);
965 dbus_error_free(&error);
971 int __supplicant_start(struct connman_device *device,
972 struct supplicant_callback *callback)
974 struct supplicant_task *task;
977 DBG("device %p", device);
979 task = g_try_new0(struct supplicant_task, 1);
983 task->ifindex = connman_device_get_index(device);
984 task->ifname = inet_index2name(task->ifindex);
985 task->device = device;
986 task->callback = callback;
988 if (task->ifname == NULL) {
993 task->created = FALSE;
994 task->state = STATE_INACTIVE;
996 task_list = g_slist_append(task_list, task);
998 err = get_interface(task);
1000 err = add_interface(task);
1014 int __supplicant_stop(struct connman_device *device)
1016 int index = connman_device_get_index(device);
1017 struct supplicant_task *task;
1019 DBG("device %p", device);
1021 task = find_task_by_index(index);
1025 task_list = g_slist_remove(task_list, task);
1027 disable_network(task);
1029 remove_network(task);
1031 remove_filter(task);
1033 remove_interface(task);
1035 g_free(task->ifname);
1042 int __supplicant_scan(struct connman_device *device)
1044 int index = connman_device_get_index(device);
1045 struct supplicant_task *task;
1048 DBG("device %p", device);
1050 task = find_task_by_index(index);
1054 switch (task->state) {
1055 case STATE_SCANNING:
1057 case STATE_ASSOCIATING:
1058 case STATE_ASSOCIATED:
1059 case STATE_4WAY_HANDSHAKE:
1060 case STATE_GROUP_HANDSHAKE:
1066 err = initiate_scan(task);
1071 int __supplicant_connect(struct connman_element *element,
1072 const unsigned char *ssid, int ssid_len,
1073 const char *security, const char *passphrase)
1075 struct supplicant_task *task;
1077 DBG("element %p", element);
1079 task = find_task_by_index(element->index);
1085 select_network(task);
1086 disable_network(task);
1088 set_network(task, ssid, ssid_len, security, passphrase);
1090 enable_network(task);
1095 int __supplicant_disconnect(struct connman_element *element)
1097 struct supplicant_task *task;
1099 DBG("element %p", element);
1101 task = find_task_by_index(element->index);
1105 disable_network(task);
1107 remove_network(task);
1112 void __supplicant_activate(DBusConnection *conn)
1114 DBusMessage *message;
1116 DBG("conn %p", conn);
1118 message = dbus_message_new_method_call(SUPPLICANT_NAME, "/",
1119 DBUS_INTERFACE_INTROSPECTABLE, "Introspect");
1120 if (message == NULL)
1123 dbus_message_set_no_reply(message, TRUE);
1125 dbus_connection_send(conn, message, NULL);
1127 dbus_message_unref(message);
1130 int __supplicant_init(DBusConnection *conn)
1132 DBG("conn %p", conn);
1136 if (dbus_connection_add_filter(connection,
1137 supplicant_filter, NULL, NULL) == FALSE) {
1138 dbus_connection_unref(connection);
1145 void __supplicant_exit(void)
1147 DBG("conn %p", connection);
1149 dbus_connection_remove_filter(connection, supplicant_filter, NULL);