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 DBG("[%s] %s", property, path);
216 if (netconfig_is_wifi_profile(path) || netconfig_is_ethernet_profile(path)) {
217 if (g_strcmp0(property, "ready") == 0) {
218 for (idx = 0; idx < MAX_SOCKET_OPEN_RETRY; idx++) {
219 sd = start_ip_conflict_mon();
223 } else if (g_strcmp0(property, "online") == 0) {
226 stop_ip_conflict_mon();
230 if (netconfig_is_wifi_profile(path) == TRUE) {
233 netconfig_vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
234 if (wifi_state == VCONFKEY_WIFI_OFF) {
239 if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
240 if (wifi_state >= VCONFKEY_WIFI_CONNECTED) {
245 netconfig_update_default_profile(path);
247 wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTED);
249 } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
250 if (netconfig_get_default_profile() == NULL ||
251 netconfig_is_wifi_profile(netconfig_get_default_profile())
253 if (g_strcmp0(property, "failure") == 0)
254 wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
256 wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
261 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
266 netconfig_update_default_profile(NULL);
268 if (g_strcmp0(property, "failure") == 0)
269 wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
271 wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
273 } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
274 if (netconfig_get_default_profile() == NULL ||
275 netconfig_is_wifi_profile(netconfig_get_default_profile()) != TRUE) {
276 if (g_strcmp0(property, "association") == 0)
277 wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
279 wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
284 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
289 netconfig_update_default_profile(NULL);
291 if (g_strcmp0(property, "association") == 0)
292 wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
294 wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
298 if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
299 if (netconfig_get_default_profile() == NULL) {
300 if (!netconfig_is_cellular_profile(path))
301 netconfig_update_default_profile(path);
303 if (netconfig_is_cellular_internet_profile(path))
304 netconfig_update_default_profile(path);
308 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
309 cellular_state_set_service_state(NETCONFIG_CELLULAR_ONLINE);
311 } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
312 if (netconfig_get_default_profile() == NULL) {
317 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
318 cellular_state_set_service_state(NETCONFIG_CELLULAR_IDLE);
320 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
325 netconfig_update_default_profile(NULL);
326 } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
327 if (netconfig_get_default_profile() == NULL) {
332 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
333 cellular_state_set_service_state(NETCONFIG_CELLULAR_CONNECTING);
335 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
340 netconfig_update_default_profile(NULL);
344 } else if (g_strcmp0(sigvalue, "Proxy") == 0) {
345 if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0)
348 if (!g_variant_type_equal(variant, G_VARIANT_TYPE_ARRAY))
351 g_variant_get(variant, "a{sv}", &iter);
352 while (g_variant_iter_loop(iter, "{sv}", &property, &var)) {
353 if (g_strcmp0(property, "Servers") == 0) {
354 GVariantIter *iter_sub = NULL;
356 g_variant_get(var, "as", &iter_sub);
357 g_variant_iter_loop(iter_sub, "s", &value);
358 g_variant_iter_free(iter_sub);
360 DBG("Proxy - [%s]", value);
361 vconf_set_str(VCONFKEY_NETWORK_PROXY, value);
364 g_variant_unref(var);
366 } else if (g_strcmp0(property, "Method") == 0) {
367 value = g_variant_get_string(var, NULL);
368 DBG("Method - [%s]", value);
370 if (g_strcmp0(value, "direct") == 0)
371 vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
374 g_variant_unref(var);
379 g_variant_iter_free(iter);
380 } else if (g_strcmp0(sigvalue, "IPv4") == 0) {
381 __netconfig_extract_ipv4_signal_data(variant, path);
382 } else if (g_strcmp0(sigvalue, "IPv6") == 0) {
383 __netconfig_extract_ipv6_signal_data(variant, path);
384 } else if (g_strcmp0(sigvalue, "Error") == 0) {
385 g_variant_get(variant, "s", &property);
386 INFO("[%s] Property : %s", sigvalue, property);
394 g_variant_unref(variant);
399 static void _dbus_name_changed_cb(GDBusConnection *conn,
400 const gchar *Name, const gchar *path, const gchar *interface,
401 const gchar *sig, GVariant *param, gpointer user_data)
410 g_variant_get(param, "(sss)", &name, &old, &new);
412 if (g_strcmp0(name, CONNMAN_SERVICE) == 0 && *new == '\0') {
413 DBG("ConnMan destroyed: name %s, old %s, new %s", name, old, new);
415 connman_register_agent();
427 static void _services_changed_cb(GDBusConnection *conn, const gchar *name,
428 const gchar *path, const gchar *interface, const gchar *sig,
429 GVariant *param, gpointer user_data)
431 gchar *property, *value;
433 GVariant *variant = NULL;
434 GVariantIter *added = NULL, *removed = NULL, *next = NULL;
436 if (path == NULL || param == NULL)
439 if (g_strcmp0(sig, CONNMAN_SIGNAL_SERVICES_CHANGED) != 0)
442 if (netconfig_get_default_profile() != NULL)
445 g_variant_get(param, "(a(oa{sv})ao)", &added, &removed);
447 while (g_variant_iter_loop(added, "(oa{sv})", &service_path, &next)) {
448 gboolean is_wifi_prof, is_cell_prof, is_cell_internet_prof;
449 is_wifi_prof = netconfig_is_wifi_profile(service_path);
450 is_cell_prof = netconfig_is_cellular_profile(service_path);
451 is_cell_internet_prof = netconfig_is_cellular_internet_profile(
453 if (service_path != NULL) {
454 while (next && g_variant_iter_loop(next, "{sv}", &property,
456 if (g_strcmp0(property, "State") == 0) {
457 g_variant_get(variant, "s", &value);
458 DBG("Profile %s State %s", service_path,
460 if (g_strcmp0(value, "ready") != 0 &&
465 g_variant_unref(variant);
470 netconfig_update_default_profile(
472 else if (is_cell_internet_prof) {
473 netconfig_update_default_profile(
477 wifi_state_set_service_state(
478 NETCONFIG_WIFI_CONNECTED);
479 else if (is_cell_prof &&
480 is_cell_internet_prof)
481 cellular_state_set_service_state(
482 NETCONFIG_CELLULAR_ONLINE);
485 g_variant_unref(variant);
492 g_variant_iter_free(added);
495 g_variant_iter_free(next);
498 g_variant_iter_free(removed);
503 static void _supplicant_interface_removed(GDBusConnection *conn,
504 const gchar *name, const gchar *path, const gchar *interface,
505 const gchar *sig, GVariant *param, gpointer user_data)
507 DBG("Interface removed handling!");
508 if (netconfig_wifi_is_bssid_scan_started() == TRUE)
509 netconfig_wifi_bssid_signal_scanaborted();
514 static void _supplicant_properties_changed(GDBusConnection *conn,
515 const gchar *name, const gchar *path, const gchar *interface,
516 const gchar *sig, GVariant *param, gpointer user_data)
521 gboolean scanning = FALSE;
526 g_variant_get(param, "(a{sv})", &iter);
527 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
528 if (g_strcmp0(key, "Scanning") == 0) {
529 scanning = g_variant_get_boolean(variant);
530 DBG("setting scanning %s", scanning ? "TRUE" : "FALSE");
531 if (scanning == TRUE)
532 netconfig_wifi_set_scanning(TRUE);
534 netconfig_wifi_set_scanning(FALSE);
536 g_variant_unref(variant);
542 g_variant_iter_free(iter);
547 static void _supplicant_bss_added(GDBusConnection *conn,
548 const gchar *name, const gchar *path, const gchar *interface,
549 const gchar *sig, GVariant *param, gpointer user_data)
551 DBG("BSS added handling!");
552 wifi_state_set_bss_found(TRUE);
557 static void _supplicant_scan_done(GDBusConnection *conn,
558 const gchar *name, const gchar *path, const gchar *interface,
559 const gchar *sig, GVariant *param, gpointer user_data)
561 DBG("Scan Done handling!");
562 netconfig_wifi_set_scanning(FALSE);
564 if (netconfig_wifi_is_bssid_scan_started() == TRUE) {
565 netconfig_wifi_bssid_signal_scandone();
566 if (wifi_state_get_technology_state() < NETCONFIG_WIFI_TECH_POWERED)
570 if (netconfig_wifi_get_bgscan_state() == TRUE) {
571 if (wifi_state_get_technology_state() >=
572 NETCONFIG_WIFI_TECH_POWERED)
573 netconfig_wifi_bgscan_start(FALSE);
575 wifi_start_timer_network_notification();
581 static void _supplicant_driver_hanged(GDBusConnection *conn,
582 const gchar *name, const gchar *path, const gchar *interface,
583 const gchar *sig, GVariant *param, gpointer user_data)
585 DBG("Driver Hanged handling!");
586 ERR("Critical. Wi-Fi firmware crashed");
588 wifi_power_recover_firmware();
593 static void _supplicant_session_overlapped(GDBusConnection *conn,
594 const gchar *name, const gchar *path, const gchar *interface,
595 const gchar *sig, GVariant *param, gpointer user_data)
597 DBG("Driver session overlapped handling!");
598 ERR("WPS PBC SESSION OVERLAPPED");
599 #if defined TIZEN_WEARABLE
602 netconfig_send_message_to_net_popup("WPS Error",
603 "wps session overlapped", "popup", NULL);
607 static void _supplicant_tdls_connected(GDBusConnection *conn,
608 const gchar *name, const gchar *path, const gchar *interface,
609 const gchar *sig, GVariant *param, gpointer user_data)
611 DBG("Received TDLS Connected Signal");
612 netconfig_wifi_tdls_connected_event(param);
617 static void _supplicant_tdls_disconnected(GDBusConnection *conn,
618 const gchar *name, const gchar *path, const gchar *interface,
619 const gchar *sig, GVariant *param, gpointer user_data)
621 DBG("Received TDLS Disconnected Signal");
622 netconfig_wifi_tdls_disconnected_event(param);
627 static void _supplicant_tdls_peer_found(GDBusConnection *conn,
628 const gchar *name, const gchar *path, const gchar *interface,
629 const gchar *sig, GVariant *param, gpointer user_data)
631 DBG("Received TDLS Peer Found Signal");
632 netconfig_wifi_tdls_peer_found_event(param);
636 static void _supplicant_wifi_wps_connected(GVariant *param)
639 char ssid[32] = {0, };
643 int config_error = 0;
644 int error_indication = 0;
648 ERR("Param is NULL");
652 g_variant_get(param, "(sa{sv})", &name, &iter);
653 INFO("wps Result: %s", name);
654 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
655 INFO("wps Key is %s", key);
656 if (g_strcmp0(key, "SSID") == 0) {
657 const char *t_key = NULL;
658 t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar));
659 INFO("wps ssid_len is %d ", ssid_len);
662 g_variant_unref(variant);
663 ERR("WPS PBC Connection Failed");
666 if (ssid_len > 0 && ssid_len <= 32) {
667 memcpy(ssid, t_key, ssid_len);
669 memset(ssid, 0, sizeof(ssid));
672 INFO("WPS PBC Connection completed with AP %s", ssid);
673 netconfig_wifi_notify_wps_completed(ssid, ssid_len);
677 g_variant_iter_free(iter);
682 g_variant_iter_free(iter);
684 error_indication = WPS_EI_OPERATION_FAILED;
685 config_error = WPS_CFG_NO_ERROR;
686 ERR("Error Occured! Notifying Fail Event");
687 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
691 static void _supplicant_wifi_wps_event(GVariant *param)
697 gint32 config_error = 0;
698 gint32 error_indication = 0;
701 ERR("Param is NULL");
705 g_variant_get(param, "(sa{sv})", &name, &iter);
706 INFO("Event Result: %s", name);
707 if (g_strcmp0(name, "fail") == 0) {
708 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
711 INFO("Key is %s", key);
712 if (g_strcmp0(key, "config_error") == 0) {
713 config_error = g_variant_get_int32(variant);
714 ERR("Config Error %d", config_error);
715 } else if (g_strcmp0(key, "error_indication") == 0) {
716 error_indication = g_variant_get_int32(variant);
717 ERR("Error Indication %d", error_indication);
720 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
723 g_variant_iter_free(iter);
728 g_variant_iter_free(iter);
730 error_indication = WPS_EI_OPERATION_FAILED;
731 config_error = WPS_CFG_NO_ERROR;
732 ERR("Error Occured! Notifying Fail Event");
733 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
736 static void _supplicant_wifi_wps_credentials(GVariant *param)
743 int config_error = 0;
744 int error_indication = 0;
748 ERR("Param is NULL");
752 g_variant_get(param, "(a{sv})", &iter);
753 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
756 INFO("wps Key is %s", key);
757 if (g_strcmp0(key, "Key") == 0) {
759 const char *t_key = NULL;
760 key_len = g_variant_get_size(variant);
762 INFO("wps password len %d ", key_len);
764 t_key = g_variant_get_fixed_array(variant, &key_len, sizeof(guchar));
767 g_variant_unref(variant);
770 strncpy(wps_key, t_key, key_len);
771 wps_key[key_len] = '\0';
772 INFO("WPS Key in process credentials %s", wps_key);
774 SLOGI("WPS AP Security ->Open");
775 } else if (g_strcmp0(key, "SSID") == 0) {
776 const char *t_key = NULL;
777 t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar));
778 INFO("wps ssid_len is %d ", ssid_len);
781 g_variant_unref(variant);
784 if (ssid_len > 0 && ssid_len <= 32) {
785 memcpy(ssid, t_key, ssid_len);
787 memset(ssid, 0, sizeof(ssid));
790 INFO("SSID in process credentials %s", ssid);
794 g_variant_iter_free(iter);
798 * Notify WPS Credentials only when requested through WPS PBC
799 * In case of WPS PIN connman will take care of notification
801 if (netconfig_get_wps_field() == TRUE)
803 netconfig_wifi_notify_wps_credentials(ssid, ssid_len, wps_key);
807 g_variant_iter_free(iter);
808 error_indication = WPS_EI_OPERATION_FAILED;
809 config_error = WPS_CFG_NO_ERROR;
810 ERR("Error Occured! Notifying Fail Event");
811 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
814 static void __netconfig_wps_signal_filter_handler(GDBusConnection *conn,
815 const gchar *name, const gchar *path, const gchar *interface,
816 const gchar *sig, GVariant *param, gpointer user_data)
818 if (g_strcmp0(sig, SIGNAL_WPS_CREDENTIALS) == 0) {
819 INFO("Received wps CREDENTIALS Signal from Supplicant");
820 _supplicant_wifi_wps_credentials(param);
821 } else if (g_strcmp0(sig, SIGNAL_WPS_EVENT) == 0) {
822 INFO("Received wps EVENT Signal from Supplicant");
823 _supplicant_wifi_wps_event(param);
824 } else if (g_strcmp0(sig, SIGNAL_WPS_CONNECTED) == 0) {
825 INFO("Received WPSConnected Signal from Supplicant");
826 _supplicant_wifi_wps_connected(param);
832 static supplicant_signal_cb supplicant_cbs[SIG_MAX] = {
833 _supplicant_interface_removed,
834 _supplicant_properties_changed,
835 _supplicant_bss_added,
836 _supplicant_scan_done,
837 _supplicant_driver_hanged,
838 _supplicant_session_overlapped,
839 _supplicant_tdls_connected,
840 _supplicant_tdls_disconnected,
841 _supplicant_tdls_peer_found
844 void register_gdbus_signal(void)
846 GDBusConnection *connection = NULL;
847 const char *interface = NULL;
848 SuppSigArrayIndex sig;
849 connection = netdbus_get_connection();
851 if (connection == NULL) {
852 ERR("Failed to get GDbus Connection");
856 /* listening to messages from all objects as no path is specified */
857 /* see signals from the given interface */
858 conn_subscription_ids[0] = g_dbus_connection_signal_subscribe(
861 CONNMAN_TECHNOLOGY_INTERFACE,
865 G_DBUS_SIGNAL_FLAGS_NONE,
866 _technology_signal_cb,
870 conn_subscription_ids[1] = g_dbus_connection_signal_subscribe(
873 CONNMAN_SERVICE_INTERFACE,
874 CONNMAN_SIGNAL_PROPERTY_CHANGED,
877 G_DBUS_SIGNAL_FLAGS_NONE,
882 conn_subscription_ids[2] = g_dbus_connection_signal_subscribe(
886 CONNMAN_SIGNAL_NAME_CHANGED,
889 G_DBUS_SIGNAL_FLAGS_NONE,
890 _dbus_name_changed_cb,
894 conn_subscription_ids[3] = g_dbus_connection_signal_subscribe(
897 CONNMAN_MANAGER_INTERFACE,
898 CONNMAN_SIGNAL_SERVICES_CHANGED,
901 G_DBUS_SIGNAL_FLAGS_NONE,
902 _services_changed_cb,
906 INFO("Successfully register connman DBus signal filters");
908 conn_subscription_ids[4] = g_dbus_connection_signal_subscribe(
911 SUPPLICANT_INTERFACE ".Interface.WPS",
915 G_DBUS_SIGNAL_FLAGS_NONE,
916 __netconfig_wps_signal_filter_handler,
920 INFO("Successfully register Supplicant WPS DBus signal filters");
922 for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
924 * For SIG_INTERFACE_REMOVED INTERFACE_ADDED
926 interface = (sig == SIG_INTERFACE_REMOVED) ?
927 SUPPLICANT_INTERFACE : SUPPLICANT_IFACE_INTERFACE;
929 supp_subscription_ids[sig] = g_dbus_connection_signal_subscribe(
933 supplicant_signals[sig],
936 G_DBUS_SIGNAL_FLAGS_NONE,
942 INFO("Successfully register Supplicant DBus signal filters");
944 /* In case ConnMan precedes this signal register,
945 * net-config should update the default connected profile.
947 netconfig_update_default();
950 void deregister_gdbus_signal(void)
952 GDBusConnection *connection = NULL;
954 SuppSigArrayIndex sig;
955 connection = netdbus_get_connection();
957 ERR("Already de-registered. Nothing to be done");
961 for (signal = 0; signal < TOTAL_CONN_SIGNALS; signal++) {
962 if (conn_subscription_ids[signal]) {
963 g_dbus_connection_signal_unsubscribe(connection,
964 conn_subscription_ids[signal]);
968 for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
969 if (supp_subscription_ids[sig]) {
970 g_dbus_connection_signal_unsubscribe(connection,
971 supp_subscription_ids[sig]);