2 * Network Configuration Module
4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
24 #include <vconf-keys.h>
31 #include "wifi-bssid-scan.h"
32 #include "wifi-agent.h"
33 #include "wifi-power.h"
34 #include "wifi-state.h"
35 #include "netsupplicant.h"
36 #include "network-state.h"
37 #include "cellular-state.h"
38 #include "signal-handler.h"
39 #include "wifi-background-scan.h"
40 #include "wifi-tdls.h"
41 #include "ip-conflict-detect.h"
43 #define DBUS_SERVICE_DBUS "org.freedesktop.DBus"
44 #define DBUS_INTERFACE_DBUS "org.freedesktop.DBus"
45 #define SIGNAL_INTERFACE_REMOVED "InterfaceRemoved"
46 #define SIGNAL_SCAN_DONE "ScanDone"
47 #define SIGNAL_BSS_ADDED "BSSAdded"
48 #define SIGNAL_PROPERTIES_CHANGED "PropertiesChanged"
49 #define SIGNAL_PROPERTIES_DRIVER_HANGED "DriverHanged"
50 #define SIGNAL_PROPERTIES_SESSION_OVERLAPPED "SessionOverlapped"
51 #define SIGNAL_TDLS_CONNECTED "TDLSConnected"
52 #define SIGNAL_TDLS_DISCONNECTED "TDLSDisconnected"
53 #define SIGNAL_TDLS_PEER_FOUND "TDLSPeerFound"
55 #define SIGNAL_WPS_CONNECTED "WPSConnected"
56 #define SIGNAL_WPS_EVENT "Event"
57 #define SIGNAL_WPS_CREDENTIALS "Credentials"
59 #define CONNMAN_SIGNAL_SERVICES_CHANGED "ServicesChanged"
60 #define CONNMAN_SIGNAL_PROPERTY_CHANGED "PropertyChanged"
61 #define CONNMAN_SIGNAL_NAME_CHANGED "NameOwnerChanged"
63 #define MAX_SIG_LEN 64
64 #define TOTAL_CONN_SIGNALS 5
65 #define MAX_SOCKET_OPEN_RETRY 5
68 SIG_INTERFACE_REMOVED = 0,
69 SIG_PROPERTIES_CHANGED,
73 SIG_SESSION_OVERLAPPED,
75 SIG_TDLS_DISCONNECTED,
80 static int conn_subscription_ids[TOTAL_CONN_SIGNALS] = {0};
81 static const char supplicant_signals[SIG_MAX][MAX_SIG_LEN] = {
82 SIGNAL_INTERFACE_REMOVED,
83 SIGNAL_PROPERTIES_CHANGED,
86 SIGNAL_PROPERTIES_DRIVER_HANGED,
87 SIGNAL_PROPERTIES_SESSION_OVERLAPPED,
88 SIGNAL_TDLS_CONNECTED,
89 SIGNAL_TDLS_DISCONNECTED,
90 SIGNAL_TDLS_PEER_FOUND,
93 static int supp_subscription_ids[SIG_MAX] = {0};
95 typedef void (*supplicant_signal_cb)(GDBusConnection *conn,
96 const gchar *name, const gchar *path, const gchar *interface,
97 const gchar *sig, GVariant *param, gpointer user_data);
98 typedef void (*connman_signal_cb)(GDBusConnection *conn,
99 const gchar *name, const gchar *path, const gchar *interface,
100 const gchar *sig, GVariant *param, gpointer user_data);
102 static void __netconfig_extract_ipv4_signal_data(GVariant *dictionary, const gchar *profile)
105 const gchar *value = NULL;
106 GVariant *var = NULL;
109 g_variant_iter_init(&iter, dictionary);
110 while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
111 if (g_strcmp0(key, "Address") == 0) {
112 g_variant_get(var, "&s", &value);
113 char *old_ip = vconf_get_str(VCONFKEY_NETWORK_IP);
115 DBG("Old IPv4.Address [%s] Received new IPv4.Address [%s]", old_ip, value);
116 if (g_strcmp0(old_ip, value) != 0) {
118 vconf_set_str(VCONFKEY_NETWORK_IP, value);
119 else if (old_ip != NULL && strlen(old_ip) > 0)
120 vconf_set_str(VCONFKEY_NETWORK_IP, "");
127 static void __netconfig_extract_ipv6_signal_data(GVariant *dictionary, const gchar *profile)
130 const gchar *value = NULL;
131 GVariant *var = NULL;
134 g_variant_iter_init(&iter, dictionary);
135 while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
136 if (g_strcmp0(key, "Address") == 0) {
137 g_variant_get(var, "&s", &value);
138 char *old_ip6 = vconf_get_str(VCONFKEY_NETWORK_IP6);
140 DBG("Old IPv6.Address [%s] Received new IPv6.Address [%s]", old_ip6, value);
141 if (g_strcmp0(old_ip6, value) != 0) {
143 vconf_set_str(VCONFKEY_NETWORK_IP6, value);
144 else if (old_ip6 != NULL && strlen(old_ip6) > 0)
145 vconf_set_str(VCONFKEY_NETWORK_IP6, "");
152 static void _technology_signal_cb(GDBusConnection *conn,
153 const gchar *name, const gchar *path, const gchar *interface,
154 const gchar *sig, GVariant *param, gpointer user_data)
157 gboolean value = FALSE;
158 GVariant *var = NULL;
163 if (g_str_has_prefix(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
164 g_variant_get(param, "(sv)", &key, &var);
165 if (g_strcmp0(key, "Powered") == 0) {
167 value = g_variant_get_boolean(var);
169 wifi_state_update_power_state(TRUE);
171 wifi_state_update_power_state(FALSE);
172 } else if (g_strcmp0(key, "Connected") == 0) {
173 /* Connection state */
174 value = g_variant_get_boolean(var);
176 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_CONNECTED);
178 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_POWERED);
179 } else if (g_strcmp0(key, "Tethering") == 0) {
180 /* Tethering state */
181 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_TETHERED);
186 g_variant_unref(var);
190 static void _service_signal_cb(GDBusConnection *conn,
191 const gchar *name, const gchar *path,
192 const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data)
194 gchar *sigvalue = NULL;
196 GVariant *variant = NULL, *var;
198 const gchar *value = NULL;
199 struct sock_data *sd = NULL;
202 if (path == NULL || param == NULL)
205 g_variant_get(param, "(sv)", &sigvalue, &variant);
206 if (sigvalue == NULL)
209 if (g_strcmp0(sig, CONNMAN_SIGNAL_PROPERTY_CHANGED) != 0)
212 if (g_strcmp0(sigvalue, "State") == 0) {
213 g_variant_get(variant, "s", &property);
215 if (g_strcmp0(property, "ready") == 0) {
216 for (idx = 0; idx < MAX_SOCKET_OPEN_RETRY; idx++) {
217 sd = start_ip_conflict_mon();
221 } else if (g_strcmp0(property, "online") == 0) {
224 stop_ip_conflict_mon();
227 DBG("[%s] %s", property, path);
228 if (netconfig_is_wifi_profile(path) == TRUE) {
231 netconfig_vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
232 if (wifi_state == VCONFKEY_WIFI_OFF) {
237 if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
238 if (wifi_state >= VCONFKEY_WIFI_CONNECTED) {
243 netconfig_update_default_profile(path);
245 wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTED);
247 } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
248 if (netconfig_get_default_profile() == NULL ||
249 netconfig_is_wifi_profile(netconfig_get_default_profile())
251 if (g_strcmp0(property, "failure") == 0)
252 wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
254 wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
259 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
264 netconfig_update_default_profile(NULL);
266 if (g_strcmp0(property, "failure") == 0)
267 wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
269 wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
271 } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
272 if (netconfig_get_default_profile() == NULL ||
273 netconfig_is_wifi_profile(netconfig_get_default_profile()) != TRUE) {
274 if (g_strcmp0(property, "association") == 0)
275 wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
277 wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
282 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
287 netconfig_update_default_profile(NULL);
289 if (g_strcmp0(property, "association") == 0)
290 wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
292 wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
296 if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
297 if (netconfig_get_default_profile() == NULL) {
298 if (!netconfig_is_cellular_profile(path))
299 netconfig_update_default_profile(path);
301 if (netconfig_is_cellular_internet_profile(path))
302 netconfig_update_default_profile(path);
306 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
307 cellular_state_set_service_state(NETCONFIG_CELLULAR_ONLINE);
309 } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
310 if (netconfig_get_default_profile() == NULL) {
315 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
316 cellular_state_set_service_state(NETCONFIG_CELLULAR_IDLE);
318 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
323 netconfig_update_default_profile(NULL);
324 } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
325 if (netconfig_get_default_profile() == NULL) {
330 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
331 cellular_state_set_service_state(NETCONFIG_CELLULAR_CONNECTING);
333 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
338 netconfig_update_default_profile(NULL);
342 } else if (g_strcmp0(sigvalue, "Proxy") == 0) {
343 if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0)
346 if (!g_variant_type_equal(variant, G_VARIANT_TYPE_ARRAY))
349 g_variant_get(variant, "a{sv}", &iter);
350 while (g_variant_iter_loop(iter, "{sv}", &property, &var)) {
351 if (g_strcmp0(property, "Servers") == 0) {
352 GVariantIter *iter_sub = NULL;
354 g_variant_get(var, "as", &iter_sub);
355 g_variant_iter_loop(iter_sub, "s", &value);
356 g_variant_iter_free(iter_sub);
358 DBG("Proxy - [%s]", value);
359 vconf_set_str(VCONFKEY_NETWORK_PROXY, value);
362 g_variant_unref(var);
364 } else if (g_strcmp0(property, "Method") == 0) {
365 value = g_variant_get_string(var, NULL);
366 DBG("Method - [%s]", value);
368 if (g_strcmp0(value, "direct") == 0)
369 vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
372 g_variant_unref(var);
377 g_variant_iter_free(iter);
378 } else if (g_strcmp0(sigvalue, "IPv4") == 0) {
379 __netconfig_extract_ipv4_signal_data(variant, path);
380 } else if (g_strcmp0(sigvalue, "IPv6") == 0) {
381 __netconfig_extract_ipv6_signal_data(variant, path);
382 } else if (g_strcmp0(sigvalue, "Error") == 0) {
383 g_variant_get(variant, "s", &property);
384 INFO("[%s] Property : %s", sigvalue, property);
392 g_variant_unref(variant);
397 static void _dbus_name_changed_cb(GDBusConnection *conn,
398 const gchar *Name, const gchar *path, const gchar *interface,
399 const gchar *sig, GVariant *param, gpointer user_data)
408 g_variant_get(param, "(sss)", &name, &old, &new);
410 if (g_strcmp0(name, CONNMAN_SERVICE) == 0 && *new == '\0') {
411 DBG("ConnMan destroyed: name %s, old %s, new %s", name, old, new);
413 connman_register_agent();
425 static void _services_changed_cb(GDBusConnection *conn, const gchar *name,
426 const gchar *path, const gchar *interface, const gchar *sig,
427 GVariant *param, gpointer user_data)
429 gchar *property, *value;
431 GVariant *variant = NULL;
432 GVariantIter *added = NULL, *removed = NULL, *next = NULL;
434 if (path == NULL || param == NULL)
437 if (g_strcmp0(sig, CONNMAN_SIGNAL_SERVICES_CHANGED) != 0)
440 if (netconfig_get_default_profile() != NULL)
443 g_variant_get(param, "(a(oa{sv})ao)", &added, &removed);
445 while (g_variant_iter_loop(added, "(oa{sv})", &service_path, &next)) {
446 gboolean is_wifi_prof, is_cell_prof, is_cell_internet_prof;
447 is_wifi_prof = netconfig_is_wifi_profile(service_path);
448 is_cell_prof = netconfig_is_cellular_profile(service_path);
449 is_cell_internet_prof = netconfig_is_cellular_internet_profile(
451 if (service_path != NULL) {
452 while (g_variant_iter_loop(next, "{sv}", &property,
454 if (g_strcmp0(property, "State") == 0) {
455 g_variant_get(variant, "s", &value);
456 DBG("Profile %s State %s", service_path,
458 if (g_strcmp0(value, "ready") != 0 &&
463 g_variant_unref(variant);
468 netconfig_update_default_profile(
470 else if (is_cell_internet_prof) {
471 netconfig_update_default_profile(
475 wifi_state_set_service_state(
476 NETCONFIG_WIFI_CONNECTED);
477 else if (is_cell_prof &&
478 is_cell_internet_prof)
479 cellular_state_set_service_state(
480 NETCONFIG_CELLULAR_ONLINE);
483 g_variant_unref(variant);
490 g_variant_iter_free(added);
493 g_variant_iter_free(next);
496 g_variant_iter_free(removed);
501 static void _supplicant_interface_removed(GDBusConnection *conn,
502 const gchar *name, const gchar *path, const gchar *interface,
503 const gchar *sig, GVariant *param, gpointer user_data)
505 DBG("Interface removed handling!");
506 if (netconfig_wifi_is_bssid_scan_started() == TRUE)
507 netconfig_wifi_bssid_signal_scanaborted();
512 static void _supplicant_properties_changed(GDBusConnection *conn,
513 const gchar *name, const gchar *path, const gchar *interface,
514 const gchar *sig, GVariant *param, gpointer user_data)
519 gboolean scanning = FALSE;
524 g_variant_get(param, "(a{sv})", &iter);
525 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
526 if (g_strcmp0(key, "Scanning") == 0) {
527 scanning = g_variant_get_boolean(variant);
528 DBG("setting scanning %s", scanning ? "TRUE" : "FALSE");
529 if (scanning == TRUE)
530 netconfig_wifi_set_scanning(TRUE);
532 netconfig_wifi_set_scanning(FALSE);
534 g_variant_unref(variant);
540 g_variant_iter_free(iter);
545 static void _supplicant_bss_added(GDBusConnection *conn,
546 const gchar *name, const gchar *path, const gchar *interface,
547 const gchar *sig, GVariant *param, gpointer user_data)
549 DBG("BSS added handling!");
550 wifi_state_set_bss_found(TRUE);
555 static void _supplicant_scan_done(GDBusConnection *conn,
556 const gchar *name, const gchar *path, const gchar *interface,
557 const gchar *sig, GVariant *param, gpointer user_data)
559 DBG("Scan Done handling!");
560 netconfig_wifi_set_scanning(FALSE);
562 if (netconfig_wifi_is_bssid_scan_started() == TRUE) {
563 netconfig_wifi_bssid_signal_scandone();
564 if (wifi_state_get_technology_state() < NETCONFIG_WIFI_TECH_POWERED)
568 if (netconfig_wifi_get_bgscan_state() == TRUE) {
569 if (wifi_state_get_technology_state() >=
570 NETCONFIG_WIFI_TECH_POWERED)
571 netconfig_wifi_bgscan_start(FALSE);
573 wifi_start_timer_network_notification();
579 static void _supplicant_driver_hanged(GDBusConnection *conn,
580 const gchar *name, const gchar *path, const gchar *interface,
581 const gchar *sig, GVariant *param, gpointer user_data)
583 DBG("Driver Hanged handling!");
584 ERR("Critical. Wi-Fi firmware crashed");
586 wifi_power_recover_firmware();
591 static void _supplicant_session_overlapped(GDBusConnection *conn,
592 const gchar *name, const gchar *path, const gchar *interface,
593 const gchar *sig, GVariant *param, gpointer user_data)
595 DBG("Driver session overlapped handling!");
596 ERR("WPS PBC SESSION OVERLAPPED");
597 #if defined TIZEN_WEARABLE
600 netconfig_send_message_to_net_popup("WPS Error",
601 "wps session overlapped", "popup", NULL);
605 static void _supplicant_tdls_connected(GDBusConnection *conn,
606 const gchar *name, const gchar *path, const gchar *interface,
607 const gchar *sig, GVariant *param, gpointer user_data)
609 DBG("Received TDLS Connected Signal");
610 netconfig_wifi_tdls_connected_event(param);
615 static void _supplicant_tdls_disconnected(GDBusConnection *conn,
616 const gchar *name, const gchar *path, const gchar *interface,
617 const gchar *sig, GVariant *param, gpointer user_data)
619 DBG("Received TDLS Disconnected Signal");
620 netconfig_wifi_tdls_disconnected_event(param);
625 static void _supplicant_tdls_peer_found(GDBusConnection *conn,
626 const gchar *name, const gchar *path, const gchar *interface,
627 const gchar *sig, GVariant *param, gpointer user_data)
629 DBG("Received TDLS Peer Found Signal");
630 netconfig_wifi_tdls_peer_found_event(param);
634 static void _supplicant_wifi_wps_connected(GVariant *param)
637 char ssid[32] = {0, };
641 int config_error = 0;
642 int error_indication = 0;
646 ERR("Param is NULL");
650 g_variant_get(param, "(sa{sv})", &name, &iter);
651 INFO("wps Result: %s", name);
652 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
653 INFO("wps Key is %s", key);
654 if (g_strcmp0(key, "SSID") == 0) {
655 const char *t_key = NULL;
656 t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar));
657 INFO("wps ssid_len is %d ", ssid_len);
660 g_variant_unref(variant);
661 ERR("WPS PBC Connection Failed");
664 if (ssid_len > 0 && ssid_len <= 32) {
665 memcpy(ssid, t_key, ssid_len);
667 memset(ssid, 0, sizeof(ssid));
670 INFO("WPS PBC Connection completed with AP %s", ssid);
671 netconfig_wifi_notify_wps_completed(ssid, ssid_len);
675 g_variant_iter_free(iter);
680 g_variant_iter_free(iter);
682 error_indication = WPS_EI_OPERATION_FAILED;
683 config_error = WPS_CFG_NO_ERROR;
684 ERR("Error Occured! Notifying Fail Event");
685 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
689 static void _supplicant_wifi_wps_event(GVariant *param)
695 gint32 config_error = 0;
696 gint32 error_indication = 0;
699 ERR("Param is NULL");
703 g_variant_get(param, "(sa{sv})", &name, &iter);
704 INFO("Event Result: %s", name);
705 if (g_strcmp0(name, "fail") == 0) {
706 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
709 INFO("Key is %s", key);
710 if (g_strcmp0(key, "config_error") == 0) {
711 config_error = g_variant_get_int32(variant);
712 ERR("Config Error %d", config_error);
713 } else if (g_strcmp0(key, "error_indication") == 0) {
714 error_indication = g_variant_get_int32(variant);
715 ERR("Error Indication %d", error_indication);
718 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
721 g_variant_iter_free(iter);
726 g_variant_iter_free(iter);
728 error_indication = WPS_EI_OPERATION_FAILED;
729 config_error = WPS_CFG_NO_ERROR;
730 ERR("Error Occured! Notifying Fail Event");
731 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
734 static void _supplicant_wifi_wps_credentials(GVariant *param)
741 int config_error = 0;
742 int error_indication = 0;
746 ERR("Param is NULL");
750 g_variant_get(param, "(a{sv})", &iter);
751 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
754 INFO("wps Key is %s", key);
755 if (g_strcmp0(key, "Key") == 0) {
757 const char *t_key = NULL;
758 key_len = g_variant_get_size(variant);
760 INFO("wps password len %d ", key_len);
762 t_key = g_variant_get_fixed_array(variant, &key_len, sizeof(guchar));
765 g_variant_unref(variant);
768 strncpy(wps_key, t_key, key_len);
769 wps_key[key_len] = '\0';
770 INFO("WPS Key in process credentials %s", wps_key);
772 SLOGI("WPS AP Security ->Open");
773 } else if (g_strcmp0(key, "SSID") == 0) {
774 const char *t_key = NULL;
775 t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar));
776 INFO("wps ssid_len is %d ", ssid_len);
779 g_variant_unref(variant);
782 if (ssid_len > 0 && ssid_len <= 32) {
783 memcpy(ssid, t_key, ssid_len);
785 memset(ssid, 0, sizeof(ssid));
788 INFO("SSID in process credentials %s", ssid);
792 g_variant_iter_free(iter);
796 * Notify WPS Credentials only when requested through WPS PBC
797 * In case of WPS PIN connman will take care of notification
799 if (netconfig_get_wps_field() == TRUE)
801 netconfig_wifi_notify_wps_credentials(ssid, ssid_len, wps_key);
805 g_variant_iter_free(iter);
806 error_indication = WPS_EI_OPERATION_FAILED;
807 config_error = WPS_CFG_NO_ERROR;
808 ERR("Error Occured! Notifying Fail Event");
809 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
812 static void __netconfig_wps_signal_filter_handler(GDBusConnection *conn,
813 const gchar *name, const gchar *path, const gchar *interface,
814 const gchar *sig, GVariant *param, gpointer user_data)
816 if (g_strcmp0(sig, SIGNAL_WPS_CREDENTIALS) == 0) {
817 INFO("Received wps CREDENTIALS Signal from Supplicant");
818 _supplicant_wifi_wps_credentials(param);
819 } else if (g_strcmp0(sig, SIGNAL_WPS_EVENT) == 0) {
820 INFO("Received wps EVENT Signal from Supplicant");
821 _supplicant_wifi_wps_event(param);
822 } else if (g_strcmp0(sig, SIGNAL_WPS_CONNECTED) == 0) {
823 INFO("Received WPSConnected Signal from Supplicant");
824 _supplicant_wifi_wps_connected(param);
830 static supplicant_signal_cb supplicant_cbs[SIG_MAX] = {
831 _supplicant_interface_removed,
832 _supplicant_properties_changed,
833 _supplicant_bss_added,
834 _supplicant_scan_done,
835 _supplicant_driver_hanged,
836 _supplicant_session_overlapped,
837 _supplicant_tdls_connected,
838 _supplicant_tdls_disconnected,
839 _supplicant_tdls_peer_found
842 void register_gdbus_signal(void)
844 GDBusConnection *connection = NULL;
845 const char *interface = NULL;
846 SuppSigArrayIndex sig;
847 connection = netdbus_get_connection();
849 if (connection == NULL) {
850 ERR("Failed to get GDbus Connection");
854 /* listening to messages from all objects as no path is specified */
855 /* see signals from the given interface */
856 conn_subscription_ids[0] = g_dbus_connection_signal_subscribe(
859 CONNMAN_TECHNOLOGY_INTERFACE,
863 G_DBUS_SIGNAL_FLAGS_NONE,
864 _technology_signal_cb,
868 conn_subscription_ids[1] = g_dbus_connection_signal_subscribe(
871 CONNMAN_SERVICE_INTERFACE,
872 CONNMAN_SIGNAL_PROPERTY_CHANGED,
875 G_DBUS_SIGNAL_FLAGS_NONE,
880 conn_subscription_ids[2] = g_dbus_connection_signal_subscribe(
884 CONNMAN_SIGNAL_NAME_CHANGED,
887 G_DBUS_SIGNAL_FLAGS_NONE,
888 _dbus_name_changed_cb,
892 conn_subscription_ids[3] = g_dbus_connection_signal_subscribe(
895 CONNMAN_MANAGER_INTERFACE,
896 CONNMAN_SIGNAL_SERVICES_CHANGED,
899 G_DBUS_SIGNAL_FLAGS_NONE,
900 _services_changed_cb,
904 INFO("Successfully register connman DBus signal filters");
906 conn_subscription_ids[4] = g_dbus_connection_signal_subscribe(
909 SUPPLICANT_INTERFACE ".Interface.WPS",
913 G_DBUS_SIGNAL_FLAGS_NONE,
914 __netconfig_wps_signal_filter_handler,
918 INFO("Successfully register Supplicant WPS DBus signal filters");
920 for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
922 * For SIG_INTERFACE_REMOVED INTERFACE_ADDED
924 interface = (sig == SIG_INTERFACE_REMOVED) ?
925 SUPPLICANT_INTERFACE : SUPPLICANT_IFACE_INTERFACE;
927 supp_subscription_ids[sig] = g_dbus_connection_signal_subscribe(
931 supplicant_signals[sig],
934 G_DBUS_SIGNAL_FLAGS_NONE,
940 INFO("Successfully register Supplicant DBus signal filters");
942 /* In case ConnMan precedes this signal register,
943 * net-config should update the default connected profile.
945 netconfig_update_default();
948 void deregister_gdbus_signal(void)
950 GDBusConnection *connection = NULL;
952 SuppSigArrayIndex sig;
953 connection = netdbus_get_connection();
955 ERR("Already de-registered. Nothing to be done");
959 for (signal = 0; signal < TOTAL_CONN_SIGNALS; signal++) {
960 if (conn_subscription_ids[signal]) {
961 g_dbus_connection_signal_unsubscribe(connection,
962 conn_subscription_ids[signal]);
966 for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
967 if (supp_subscription_ids[sig]) {
968 g_dbus_connection_signal_unsubscribe(connection,
969 supp_subscription_ids[sig]);