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 #include <connman/log.h>
33 #include <connman/dbus.h>
36 #include "supplicant.h"
40 #define IEEE80211_CAP_ESS 0x0001
41 #define IEEE80211_CAP_IBSS 0x0002
42 #define IEEE80211_CAP_PRIVACY 0x0010
44 struct supplicant_task {
47 struct connman_device *device;
48 struct supplicant_callback *callback;
52 enum supplicant_state state;
55 static GSList *task_list = NULL;
57 static DBusConnection *connection;
59 static struct supplicant_task *find_task_by_index(int index)
63 for (list = task_list; list; list = list->next) {
64 struct supplicant_task *task = list->data;
66 if (task->ifindex == index)
73 static struct supplicant_task *find_task_by_path(const char *path)
77 for (list = task_list; list; list = list->next) {
78 struct supplicant_task *task = list->data;
80 if (g_str_equal(task->path, path) == TRUE)
87 static int get_interface(struct supplicant_task *task)
89 DBusMessage *message, *reply;
95 message = dbus_message_new_method_call(SUPPLICANT_NAME, SUPPLICANT_PATH,
96 SUPPLICANT_INTF, "getInterface");
100 dbus_message_append_args(message, DBUS_TYPE_STRING, &task->ifname,
103 dbus_error_init(&error);
105 reply = dbus_connection_send_with_reply_and_block(connection,
106 message, -1, &error);
108 if (dbus_error_is_set(&error) == TRUE) {
109 connman_error("%s", error.message);
110 dbus_error_free(&error);
112 connman_error("Failed to get interface");
113 dbus_message_unref(message);
117 dbus_message_unref(message);
119 dbus_error_init(&error);
121 if (dbus_message_get_args(reply, &error, DBUS_TYPE_OBJECT_PATH, &path,
122 DBUS_TYPE_INVALID) == FALSE) {
123 if (dbus_error_is_set(&error) == TRUE) {
124 connman_error("%s", error.message);
125 dbus_error_free(&error);
127 connman_error("Wrong arguments for interface");
128 dbus_message_unref(reply);
132 DBG("path %s", path);
134 task->path = g_strdup(path);
135 task->created = FALSE;
137 dbus_message_unref(reply);
142 static int add_interface(struct supplicant_task *task)
144 DBusMessage *message, *reply;
148 DBG("task %p", task);
150 message = dbus_message_new_method_call(SUPPLICANT_NAME, SUPPLICANT_PATH,
151 SUPPLICANT_INTF, "addInterface");
155 dbus_error_init(&error);
157 dbus_message_append_args(message, DBUS_TYPE_STRING, &task->ifname,
160 reply = dbus_connection_send_with_reply_and_block(connection,
161 message, -1, &error);
163 if (dbus_error_is_set(&error) == TRUE) {
164 connman_error("%s", error.message);
165 dbus_error_free(&error);
167 connman_error("Failed to add interface");
168 dbus_message_unref(message);
172 dbus_message_unref(message);
174 dbus_error_init(&error);
176 if (dbus_message_get_args(reply, &error, DBUS_TYPE_OBJECT_PATH, &path,
177 DBUS_TYPE_INVALID) == FALSE) {
178 if (dbus_error_is_set(&error) == TRUE) {
179 connman_error("%s", error.message);
180 dbus_error_free(&error);
182 connman_error("Wrong arguments for interface");
183 dbus_message_unref(reply);
187 DBG("path %s", path);
189 task->path = g_strdup(path);
190 task->created = TRUE;
192 dbus_message_unref(reply);
197 static int remove_interface(struct supplicant_task *task)
199 DBusMessage *message, *reply;
202 DBG("task %p", task);
204 if (task->created == FALSE)
207 message = dbus_message_new_method_call(SUPPLICANT_NAME, SUPPLICANT_PATH,
208 SUPPLICANT_INTF, "removeInterface");
212 dbus_message_append_args(message, DBUS_TYPE_OBJECT_PATH, &task->path,
215 dbus_error_init(&error);
217 reply = dbus_connection_send_with_reply_and_block(connection,
218 message, -1, &error);
220 if (dbus_error_is_set(&error) == TRUE) {
221 connman_error("%s", error.message);
222 dbus_error_free(&error);
224 connman_error("Failed to remove interface");
225 dbus_message_unref(message);
229 dbus_message_unref(message);
231 dbus_message_unref(reply);
236 static int set_ap_scan(struct supplicant_task *task)
238 DBusMessage *message, *reply;
242 DBG("task %p", task);
244 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->path,
245 SUPPLICANT_INTF ".Interface", "setAPScan");
249 dbus_message_append_args(message, DBUS_TYPE_UINT32, &ap_scan,
252 dbus_error_init(&error);
254 reply = dbus_connection_send_with_reply_and_block(connection,
255 message, -1, &error);
257 if (dbus_error_is_set(&error) == TRUE) {
258 connman_error("%s", error.message);
259 dbus_error_free(&error);
261 connman_error("Failed to set AP scan");
262 dbus_message_unref(message);
266 dbus_message_unref(message);
268 dbus_message_unref(reply);
273 static int add_network(struct supplicant_task *task)
275 DBusMessage *message, *reply;
279 DBG("task %p", task);
281 if (task->network != NULL)
284 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->path,
285 SUPPLICANT_INTF ".Interface", "addNetwork");
289 dbus_error_init(&error);
291 reply = dbus_connection_send_with_reply_and_block(connection,
292 message, -1, &error);
294 if (dbus_error_is_set(&error) == TRUE) {
295 connman_error("%s", error.message);
296 dbus_error_free(&error);
298 connman_error("Failed to add network");
299 dbus_message_unref(message);
303 dbus_message_unref(message);
305 dbus_error_init(&error);
307 if (dbus_message_get_args(reply, &error, DBUS_TYPE_OBJECT_PATH, &path,
308 DBUS_TYPE_INVALID) == FALSE) {
309 if (dbus_error_is_set(&error) == TRUE) {
310 connman_error("%s", error.message);
311 dbus_error_free(&error);
313 connman_error("Wrong arguments for network");
314 dbus_message_unref(reply);
318 DBG("path %s", path);
320 task->network = g_strdup(path);
322 dbus_message_unref(reply);
327 static int remove_network(struct supplicant_task *task)
329 DBusMessage *message, *reply;
332 DBG("task %p", task);
334 if (task->network == NULL)
337 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->path,
338 SUPPLICANT_INTF ".Interface", "removeNetwork");
342 dbus_message_append_args(message, DBUS_TYPE_OBJECT_PATH, &task->network,
345 dbus_error_init(&error);
347 reply = dbus_connection_send_with_reply_and_block(connection,
348 message, -1, &error);
350 if (dbus_error_is_set(&error) == TRUE) {
351 connman_error("%s", error.message);
352 dbus_error_free(&error);
354 connman_error("Failed to remove network");
355 dbus_message_unref(message);
359 dbus_message_unref(message);
361 dbus_message_unref(reply);
363 g_free(task->network);
364 task->network = NULL;
369 static int select_network(struct supplicant_task *task)
371 DBusMessage *message, *reply;
374 DBG("task %p", task);
376 if (task->network == NULL)
379 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->path,
380 SUPPLICANT_INTF ".Interface", "selectNetwork");
384 dbus_message_append_args(message, DBUS_TYPE_OBJECT_PATH, &task->network,
387 dbus_error_init(&error);
389 reply = dbus_connection_send_with_reply_and_block(connection,
390 message, -1, &error);
392 if (dbus_error_is_set(&error) == TRUE) {
393 connman_error("%s", error.message);
394 dbus_error_free(&error);
396 connman_error("Failed to select network");
397 dbus_message_unref(message);
401 dbus_message_unref(message);
403 dbus_message_unref(reply);
408 static int enable_network(struct supplicant_task *task)
410 DBusMessage *message, *reply;
413 DBG("task %p", task);
415 if (task->network == NULL)
418 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->network,
419 SUPPLICANT_INTF ".Network", "enable");
423 dbus_error_init(&error);
425 reply = dbus_connection_send_with_reply_and_block(connection,
426 message, -1, &error);
428 if (dbus_error_is_set(&error) == TRUE) {
429 connman_error("%s", error.message);
430 dbus_error_free(&error);
432 connman_error("Failed to enable network");
433 dbus_message_unref(message);
437 dbus_message_unref(message);
439 dbus_message_unref(reply);
444 static int disable_network(struct supplicant_task *task)
446 DBusMessage *message, *reply;
449 DBG("task %p", task);
451 if (task->network == NULL)
454 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->network,
455 SUPPLICANT_INTF ".Network", "disable");
459 dbus_error_init(&error);
461 reply = dbus_connection_send_with_reply_and_block(connection,
462 message, -1, &error);
464 if (dbus_error_is_set(&error) == TRUE) {
465 connman_error("%s", error.message);
466 dbus_error_free(&error);
468 connman_error("Failed to disable network");
469 dbus_message_unref(message);
473 dbus_message_unref(message);
475 dbus_message_unref(reply);
480 static int set_network(struct supplicant_task *task,
481 const unsigned char *network, int len,
482 const char *security, const char *passphrase)
484 DBusMessage *message, *reply;
485 DBusMessageIter array, dict;
488 DBG("task %p", task);
490 if (task->network == NULL)
493 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->network,
494 SUPPLICANT_INTF ".Network", "set");
498 dbus_message_iter_init_append(message, &array);
500 dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY,
501 DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
502 DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
503 DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
505 connman_dbus_dict_append_array(&dict, "ssid",
506 DBUS_TYPE_BYTE, &network, len);
508 if (g_ascii_strcasecmp(security, "wpa") == 0 ||
509 g_ascii_strcasecmp(security, "wpa2") == 0) {
510 const char *key_mgmt = "WPA-PSK";
511 connman_dbus_dict_append_variant(&dict, "key_mgmt",
512 DBUS_TYPE_STRING, &key_mgmt);
514 if (passphrase && strlen(passphrase) > 0)
515 connman_dbus_dict_append_variant(&dict, "psk",
516 DBUS_TYPE_STRING, &passphrase);
517 } else if (g_ascii_strcasecmp(security, "wep") == 0) {
518 const char *key_mgmt = "NONE", *index = "0";
519 connman_dbus_dict_append_variant(&dict, "key_mgmt",
520 DBUS_TYPE_STRING, &key_mgmt);
523 int size = strlen(passphrase);
524 if (size == 10 || size == 26) {
525 unsigned char *key = malloc(13);
528 memset(tmp, 0, sizeof(tmp));
531 for (i = 0; i < size / 2; i++) {
532 memcpy(tmp, passphrase + (i * 2), 2);
533 key[i] = (unsigned char) strtol(tmp,
536 connman_dbus_dict_append_array(&dict,
537 "wep_key0", DBUS_TYPE_BYTE,
541 connman_dbus_dict_append_variant(&dict,
542 "wep_key0", DBUS_TYPE_STRING,
544 connman_dbus_dict_append_variant(&dict, "wep_tx_keyidx",
545 DBUS_TYPE_STRING, &index);
548 const char *key_mgmt = "NONE";
549 connman_dbus_dict_append_variant(&dict, "key_mgmt",
550 DBUS_TYPE_STRING, &key_mgmt);
553 dbus_message_iter_close_container(&array, &dict);
555 dbus_error_init(&error);
557 reply = dbus_connection_send_with_reply_and_block(connection,
558 message, -1, &error);
560 if (dbus_error_is_set(&error) == TRUE) {
561 connman_error("%s", error.message);
562 dbus_error_free(&error);
564 connman_error("Failed to set network options");
565 dbus_message_unref(message);
569 dbus_message_unref(message);
571 dbus_message_unref(reply);
576 static int initiate_scan(struct supplicant_task *task)
578 DBusMessage *message;
579 DBusPendingCall *call;
581 DBG("task %p", task);
583 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->path,
584 SUPPLICANT_INTF ".Interface", "scan");
588 if (dbus_connection_send_with_reply(connection, message,
589 &call, TIMEOUT) == FALSE) {
590 connman_error("Failed to initiate scan");
591 dbus_message_unref(message);
595 dbus_message_unref(message);
600 static void extract_ssid(struct supplicant_network *network,
601 DBusMessageIter *value)
603 DBusMessageIter array;
607 dbus_message_iter_recurse(value, &array);
608 dbus_message_iter_get_fixed_array(&array, &ssid, &ssid_len);
613 network->ssid = g_try_malloc(ssid_len);
614 if (network->ssid == NULL)
617 memcpy(network->ssid, ssid, ssid_len);
618 network->ssid_len = ssid_len;
620 network->identifier = g_try_malloc0(ssid_len + 1);
621 if (network->identifier == NULL)
624 memcpy(network->identifier, ssid, ssid_len);
627 static void extract_wpaie(struct supplicant_network *network,
628 DBusMessageIter *value)
630 DBusMessageIter array;
634 dbus_message_iter_recurse(value, &array);
635 dbus_message_iter_get_fixed_array(&array, &ie, &ie_len);
638 network->has_wpa = TRUE;
641 static void extract_rsnie(struct supplicant_network *network,
642 DBusMessageIter *value)
644 DBusMessageIter array;
648 dbus_message_iter_recurse(value, &array);
649 dbus_message_iter_get_fixed_array(&array, &ie, &ie_len);
652 network->has_rsn = TRUE;
655 static void extract_capabilites(struct supplicant_network *network,
656 DBusMessageIter *value)
658 dbus_message_iter_get_basic(value, &network->capabilities);
660 if (network->capabilities & IEEE80211_CAP_ESS)
661 network->adhoc = FALSE;
662 else if (network->capabilities & IEEE80211_CAP_IBSS)
663 network->adhoc = TRUE;
665 if (network->capabilities & IEEE80211_CAP_PRIVACY)
666 network->has_wep = TRUE;
669 static void properties_reply(DBusPendingCall *call, void *user_data)
671 struct supplicant_task *task = user_data;
672 struct supplicant_network *network;
674 DBusMessageIter array, dict;
676 DBG("task %p", task);
678 reply = dbus_pending_call_steal_reply(call);
680 network = g_try_new0(struct supplicant_network, 1);
684 dbus_message_iter_init(reply, &array);
686 dbus_message_iter_recurse(&array, &dict);
688 while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
689 DBusMessageIter entry, value;
692 dbus_message_iter_recurse(&dict, &entry);
693 dbus_message_iter_get_basic(&entry, &key);
695 dbus_message_iter_next(&entry);
697 dbus_message_iter_recurse(&entry, &value);
699 //type = dbus_message_iter_get_arg_type(&value);
700 //dbus_message_iter_get_basic(&value, &val);
707 * frequency : i (105)
708 * capabilities : q (113)
715 if (g_str_equal(key, "ssid") == TRUE)
716 extract_ssid(network, &value);
717 else if (g_str_equal(key, "wpaie") == TRUE)
718 extract_wpaie(network, &value);
719 else if (g_str_equal(key, "rsnie") == TRUE)
720 extract_rsnie(network, &value);
721 else if (g_str_equal(key, "capabilities") == TRUE)
722 extract_capabilites(network, &value);
723 else if (g_str_equal(key, "quality") == TRUE)
724 dbus_message_iter_get_basic(&value, &network->quality);
725 else if (g_str_equal(key, "noise") == TRUE)
726 dbus_message_iter_get_basic(&value, &network->noise);
727 else if (g_str_equal(key, "level") == TRUE)
728 dbus_message_iter_get_basic(&value, &network->level);
729 else if (g_str_equal(key, "maxrate") == TRUE)
730 dbus_message_iter_get_basic(&value, &network->maxrate);
733 dbus_message_iter_next(&dict);
736 if (task->callback && task->callback->scan_result)
737 task->callback->scan_result(task->device, network);
739 g_free(network->identifier);
740 g_free(network->ssid);
744 dbus_message_unref(reply);
747 static int get_network_properties(struct supplicant_task *task,
750 DBusMessage *message;
751 DBusPendingCall *call;
753 message = dbus_message_new_method_call(SUPPLICANT_NAME, path,
754 SUPPLICANT_INTF ".BSSID",
759 if (dbus_connection_send_with_reply(connection, message,
760 &call, TIMEOUT) == FALSE) {
761 connman_error("Failed to get network properties");
762 dbus_message_unref(message);
766 dbus_pending_call_set_notify(call, properties_reply, task, NULL);
768 dbus_message_unref(message);
773 static void scan_results_reply(DBusPendingCall *call, void *user_data)
775 struct supplicant_task *task = user_data;
781 DBG("task %p", task);
783 reply = dbus_pending_call_steal_reply(call);
785 dbus_error_init(&error);
787 if (dbus_message_get_args(reply, &error,
788 DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH,
789 &results, &num_results,
790 DBUS_TYPE_INVALID) == FALSE) {
791 if (dbus_error_is_set(&error) == TRUE) {
792 connman_error("%s", error.message);
793 dbus_error_free(&error);
795 connman_error("Wrong arguments for scan result");
799 if (task->callback && task->callback->clear_results)
800 task->callback->clear_results(task->device);
802 for (i = 0; i < num_results; i++)
803 get_network_properties(task, results[i]);
808 dbus_message_unref(reply);
811 static int scan_results_available(struct supplicant_task *task)
813 DBusMessage *message;
814 DBusPendingCall *call;
816 DBG("task %p", task);
818 message = dbus_message_new_method_call(SUPPLICANT_NAME, task->path,
819 SUPPLICANT_INTF ".Interface",
824 if (dbus_connection_send_with_reply(connection, message,
825 &call, TIMEOUT) == FALSE) {
826 connman_error("Failed to request scan result");
827 dbus_message_unref(message);
831 dbus_pending_call_set_notify(call, scan_results_reply, task, NULL);
833 dbus_message_unref(message);
838 static void state_change(struct supplicant_task *task, DBusMessage *msg)
841 const char *state, *previous;
843 dbus_error_init(&error);
845 if (dbus_message_get_args(msg, &error, DBUS_TYPE_STRING, &state,
846 DBUS_TYPE_STRING, &previous,
847 DBUS_TYPE_INVALID) == FALSE) {
848 if (dbus_error_is_set(&error) == TRUE) {
849 connman_error("%s", error.message);
850 dbus_error_free(&error);
852 connman_error("Wrong arguments for state change");
856 DBG("state %s ==> %s", previous, state);
858 if (g_str_equal(state, "INACTIVE") == TRUE)
859 task->state = STATE_INACTIVE;
860 else if (g_str_equal(state, "SCANNING") == TRUE)
861 task->state = STATE_SCANNING;
862 else if (g_str_equal(state, "ASSOCIATING") == TRUE)
863 task->state = STATE_ASSOCIATING;
864 else if (g_str_equal(state, "ASSOCIATED") == TRUE)
865 task->state = STATE_ASSOCIATED;
866 else if (g_str_equal(state, "GROUP_HANDSHAKE") == TRUE)
867 task->state = STATE_4WAY_HANDSHAKE;
868 else if (g_str_equal(state, "4WAY_HANDSHAKE") == TRUE)
869 task->state = STATE_4WAY_HANDSHAKE;
870 else if (g_str_equal(state, "COMPLETED") == TRUE)
871 task->state = STATE_COMPLETED;
872 else if (g_str_equal(state, "DISCONNECTED") == TRUE)
873 task->state = STATE_DISCONNECTED;
875 if (task->callback && task->callback->state_change)
876 task->callback->state_change(task->device, task->state);
878 switch (task->state) {
879 case STATE_COMPLETED:
882 case STATE_DISCONNECTED:
890 static DBusHandlerResult supplicant_filter(DBusConnection *conn,
891 DBusMessage *msg, void *data)
893 struct supplicant_task *task;
894 const char *member, *path;
896 if (dbus_message_has_interface(msg,
897 SUPPLICANT_INTF ".Interface") == FALSE)
898 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
900 member = dbus_message_get_member(msg);
902 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
904 path = dbus_message_get_path(msg);
906 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
908 task = find_task_by_path(path);
910 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
912 DBG("task %p member %s", task, member);
914 if (g_str_equal(member, "ScanResultsAvailable") == TRUE)
915 scan_results_available(task);
916 else if (g_str_equal(member, "StateChange") == TRUE)
917 state_change(task, msg);
919 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
922 static int add_filter(struct supplicant_task *task)
927 filter = g_strdup_printf("type=signal,interface=%s.Interface,path=%s",
928 SUPPLICANT_INTF, task->path);
930 DBG("filter %s", filter);
932 dbus_error_init(&error);
934 dbus_bus_add_match(connection, filter, &error);
938 if (dbus_error_is_set(&error) == TRUE) {
939 connman_error("Can't add match: %s", error.message);
940 dbus_error_free(&error);
946 static int remove_filter(struct supplicant_task *task)
951 filter = g_strdup_printf("type=signal,interface=%s.Interface,path=%s",
952 SUPPLICANT_INTF, task->path);
954 DBG("filter %s", filter);
956 dbus_error_init(&error);
958 dbus_bus_remove_match(connection, filter, &error);
962 if (dbus_error_is_set(&error) == TRUE) {
963 connman_error("Can't add match: %s", error.message);
964 dbus_error_free(&error);
970 int __supplicant_start(struct connman_device *device,
971 struct supplicant_callback *callback)
973 struct supplicant_task *task;
976 DBG("device %p", device);
978 task = g_try_new0(struct supplicant_task, 1);
982 task->ifindex = connman_device_get_index(device);
983 task->ifname = inet_index2name(task->ifindex);
984 task->device = device;
985 task->callback = callback;
987 if (task->ifname == NULL) {
992 task->created = FALSE;
993 task->state = STATE_INACTIVE;
995 task_list = g_slist_append(task_list, task);
997 err = get_interface(task);
999 err = add_interface(task);
1013 int __supplicant_stop(struct connman_device *device)
1015 int index = connman_device_get_index(device);
1016 struct supplicant_task *task;
1018 DBG("device %p", device);
1020 task = find_task_by_index(index);
1024 task_list = g_slist_remove(task_list, task);
1026 disable_network(task);
1028 remove_network(task);
1030 remove_filter(task);
1032 remove_interface(task);
1034 g_free(task->ifname);
1041 int __supplicant_scan(struct connman_device *device)
1043 int index = connman_device_get_index(device);
1044 struct supplicant_task *task;
1047 DBG("device %p", device);
1049 task = find_task_by_index(index);
1053 switch (task->state) {
1054 case STATE_SCANNING:
1056 case STATE_ASSOCIATING:
1057 case STATE_ASSOCIATED:
1058 case STATE_4WAY_HANDSHAKE:
1059 case STATE_GROUP_HANDSHAKE:
1065 err = initiate_scan(task);
1070 int __supplicant_connect(struct connman_element *element,
1071 const unsigned char *ssid, int ssid_len,
1072 const char *security, const char *passphrase)
1074 struct supplicant_task *task;
1076 DBG("element %p", element);
1078 task = find_task_by_index(element->index);
1084 select_network(task);
1085 disable_network(task);
1087 set_network(task, ssid, ssid_len, security, passphrase);
1089 enable_network(task);
1094 int __supplicant_disconnect(struct connman_element *element)
1096 struct supplicant_task *task;
1098 DBG("element %p", element);
1100 task = find_task_by_index(element->index);
1104 disable_network(task);
1106 remove_network(task);
1111 void __supplicant_activate(DBusConnection *conn)
1113 DBusMessage *message;
1115 DBG("conn %p", conn);
1117 message = dbus_message_new_method_call(SUPPLICANT_NAME, "/",
1118 DBUS_INTERFACE_INTROSPECTABLE, "Introspect");
1119 if (message == NULL)
1122 dbus_message_set_no_reply(message, TRUE);
1124 dbus_connection_send(conn, message, NULL);
1126 dbus_message_unref(message);
1129 int __supplicant_init(DBusConnection *conn)
1131 DBG("conn %p", conn);
1135 if (dbus_connection_add_filter(connection,
1136 supplicant_filter, NULL, NULL) == FALSE) {
1137 dbus_connection_unref(connection);
1144 void __supplicant_exit(void)
1146 DBG("conn %p", connection);
1148 dbus_connection_remove_filter(connection, supplicant_filter, NULL);