Modify send_arp
[platform/core/connectivity/net-config.git] / src / signal-handler.c
1 /*
2  * Network Configuration Module
3  *
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <vconf.h>
24 #include <vconf-keys.h>
25 #include <sys/wait.h>
26
27 #include "log.h"
28 #include "util.h"
29 #include "netdbus.h"
30 #include "neterror.h"
31 #include "wifi-wps.h"
32 #include "wifi-bssid-scan.h"
33 #include "wifi-agent.h"
34 #include "wifi-power.h"
35 #include "wifi-state.h"
36 #include "netsupplicant.h"
37 #include "network-state.h"
38 #include "cellular-state.h"
39 #include "signal-handler.h"
40 #include "wifi-background-scan.h"
41 #include "wifi-tdls.h"
42 #include "ip-conflict-detect.h"
43 #include "wifi-key-encryption.h"
44 #if defined TIZEN_DEBUG_ENABLE
45 #include "network-dump.h"
46 #define NETWORK_LOG_DUMP_SCRIPT  "/opt/var/lib/net-config/network_log_dump.sh"
47 #define MAX_SIZE_ERROR_BUFFER 256
48 #endif
49
50 #define DBUS_SERVICE_DBUS                       "org.freedesktop.DBus"
51 #define DBUS_INTERFACE_DBUS                     "org.freedesktop.DBus"
52 #define SIGNAL_INTERFACE_REMOVED                "InterfaceRemoved"
53 #define SIGNAL_SCAN_DONE                        "ScanDone"
54 #define SIGNAL_BSS_ADDED                        "BSSAdded"
55 #define SIGNAL_PROPERTIES_CHANGED               "PropertiesChanged"
56 #define SIGNAL_PROPERTIES_DRIVER_HANGED         "DriverHanged"
57 #define SIGNAL_PROPERTIES_SESSION_OVERLAPPED    "SessionOverlapped"
58 #define SIGNAL_TDLS_CONNECTED                           "TDLSConnected"
59 #define SIGNAL_TDLS_DISCONNECTED                        "TDLSDisconnected"
60 #define SIGNAL_TDLS_PEER_FOUND                          "TDLSPeerFound"
61
62 #define SIGNAL_WPS_CONNECTED                            "WPSConnected"
63 #define SIGNAL_WPS_EVENT                                        "Event"
64 #define SIGNAL_WPS_CREDENTIALS                          "Credentials"
65
66 #define CONNMAN_SIGNAL_SERVICES_CHANGED         "ServicesChanged"
67 #define CONNMAN_SIGNAL_PROPERTY_CHANGED         "PropertyChanged"
68 #define CONNMAN_SIGNAL_NAME_CHANGED             "NameOwnerChanged"
69
70 #define MAX_SIG_LEN 64
71 #define TOTAL_CONN_SIGNALS 5
72 #define MAX_SOCKET_OPEN_RETRY 5
73
74 typedef enum {
75         SIG_INTERFACE_REMOVED = 0,
76         SIG_PROPERTIES_CHANGED,
77         SIG_BSS_ADDED,
78         SIG_SCAN_DONE,
79         SIG_DRIVER_HANGED,
80         SIG_SESSION_OVERLAPPED,
81         SIG_TDLS_CONNECTED,
82         SIG_TDLS_DISCONNECTED,
83         SIG_TDLS_PEER_FOUND,
84         SIG_MAX
85 } SuppSigArrayIndex;
86
87 static int conn_subscription_ids[TOTAL_CONN_SIGNALS] = {0};
88 static const char supplicant_signals[SIG_MAX][MAX_SIG_LEN] = {
89                 SIGNAL_INTERFACE_REMOVED,
90                 SIGNAL_PROPERTIES_CHANGED,
91                 SIGNAL_BSS_ADDED,
92                 SIGNAL_SCAN_DONE,
93                 SIGNAL_PROPERTIES_DRIVER_HANGED,
94                 SIGNAL_PROPERTIES_SESSION_OVERLAPPED,
95                 SIGNAL_TDLS_CONNECTED,
96                 SIGNAL_TDLS_DISCONNECTED,
97                 SIGNAL_TDLS_PEER_FOUND,
98 };
99
100 static int supp_subscription_ids[SIG_MAX] = {0};
101 #if defined TIZEN_DEBUG_ENABLE
102 static int dumpservice_subscription_id = 0;
103 #endif
104
105 typedef void (*supplicant_signal_cb)(GDBusConnection *conn,
106                 const gchar *name, const gchar *path, const gchar *interface,
107                 const gchar *sig, GVariant *param, gpointer user_data);
108 typedef void (*connman_signal_cb)(GDBusConnection *conn,
109                 const gchar *name, const gchar *path, const gchar *interface,
110                 const gchar *sig, GVariant *param, gpointer user_data);
111
112 static void __netconfig_extract_ipv4_signal_data(GVariant *dictionary,
113                 const gchar *profile)
114 {
115         gchar *key = NULL;
116         const gchar *value = NULL;
117         GVariant *var = NULL;
118         GVariantIter iter;
119         GVariantBuilder *builder;
120         GVariant *params;
121
122         g_variant_iter_init(&iter, dictionary);
123         while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
124                 if (g_strcmp0(key, "Address") == 0)  {
125                         g_variant_get(var, "&s", &value);
126                         char *old_ip = vconf_get_str(VCONFKEY_NETWORK_IP);
127
128                         DBG("Old IPv4.Address [%s] Received new IPv4.Address [%s]", old_ip,
129                                                   value);
130                         if (g_strcmp0(old_ip, value) != 0) {
131                                 builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
132
133                                 if (value != NULL) {
134                                         vconf_set_str(VCONFKEY_NETWORK_IP, value);
135                                         g_variant_builder_add(builder, "{sv}", "IPv4Address",
136                                                                   g_variant_new_string(value));
137                                 } else if (old_ip != NULL && strlen(old_ip) > 0) {
138                                         vconf_set_str(VCONFKEY_NETWORK_IP, "");
139                                         g_variant_builder_add(builder, "{sv}", "IPv4Address",
140                                                                   g_variant_new_string(""));
141                                 }
142
143                                 params = g_variant_new("(@a{sv})",
144                                                                            g_variant_builder_end(builder));
145
146                                 g_variant_builder_unref(builder);
147
148                                 netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
149                                                    NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged",
150                                                    params);
151                         }
152                         free(old_ip);
153                 }
154         }
155 }
156
157 static void __netconfig_extract_ipv6_signal_data(GVariant *dictionary,
158                                                                                                  const gchar *profile)
159 {
160         gchar *key = NULL;
161         const gchar *value = NULL;
162         GVariant *var = NULL;
163         GVariantIter iter;
164         GVariantBuilder *builder;
165         GVariant *params;
166
167         g_variant_iter_init(&iter, dictionary);
168         while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
169                 if (g_strcmp0(key, "Address") == 0)  {
170                         g_variant_get(var, "&s", &value);
171                         char *old_ip6 = vconf_get_str(VCONFKEY_NETWORK_IP6);
172
173                         DBG("Old IPv6.Address [%s] Received new IPv6.Address [%s]", old_ip6,
174                                                         value);
175                         if (g_strcmp0(old_ip6, value) != 0) {
176                                 builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
177
178                                 if (value != NULL) {
179                                         vconf_set_str(VCONFKEY_NETWORK_IP6, value);
180                                         g_variant_builder_add(builder, "{sv}", "IPv6Address",
181                                                                   g_variant_new_string(value));
182                                 } else if (old_ip6 != NULL && strlen(old_ip6) > 0) {
183                                         vconf_set_str(VCONFKEY_NETWORK_IP6, "");
184                                         g_variant_builder_add(builder, "{sv}", "IPv6Address",
185                                                                   g_variant_new_string(""));
186                                 }
187
188                                 params = g_variant_new("(@a{sv})",
189                                                                            g_variant_builder_end(builder));
190                                 g_variant_builder_unref(builder);
191
192                                 netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
193                                                    NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged",
194                                                    params);
195                         }
196                         free(old_ip6);
197                 }
198         }
199 }
200
201 #if defined TIZEN_DEBUG_ENABLE
202 static int __netconfig_handle_execute_file(const char *file_path,
203                 char *const args[], char *const envs[])
204 {
205         pid_t pid = 0;
206         int status = 0;
207         int rv = 0;
208         errno = 0;
209         register unsigned int index = 0;
210         char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
211
212         while (args[index] != NULL) {
213                 DBG("%s", args[index]);
214                 index++;
215         }
216
217         if (!(pid = fork())) {
218                 DBG("pid(%d), ppid (%d)", getpid(), getppid());
219                 DBG("Inside child, exec (%s) command", file_path);
220
221                 errno = 0;
222                 if (execve(file_path, args, envs) == -1) {
223                         DBG("Fail to execute command (%s)",
224                                         strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
225                         exit(1);
226                 }
227         } else if (pid > 0) {
228                 if (waitpid(pid, &status, 0) == -1)
229                         DBG("wait pid (%u) status (%d)", pid, status);
230
231                 if (WIFEXITED(status)) {
232                         rv = WEXITSTATUS(status);
233                         DBG("exited, status=%d", rv);
234                 } else if (WIFSIGNALED(status)) {
235                         DBG("killed by signal %d", WTERMSIG(status));
236                 } else if (WIFSTOPPED(status)) {
237                         DBG("stopped by signal %d", WSTOPSIG(status));
238                 } else if (WIFCONTINUED(status)) {
239                         DBG("continued");
240                 }
241
242                 return rv;
243         }
244
245         DBG("failed to fork(%s)",
246                 strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
247         return -EIO;
248 }
249
250 static int _start_dump()
251 {
252         int rv = 0;
253         gchar *path = NETWORK_LOG_DUMP_SCRIPT;
254         char *const args[] = { NETWORK_LOG_DUMP_SCRIPT, NULL };
255         char *const envs[] = { NULL };
256
257         rv = __netconfig_handle_execute_file(path, args, envs);
258         if (rv < 0) {
259                 ERR("Fail to execute network log dump shell");
260                 return -EIO;
261         }
262         return 0;
263 }
264 #endif
265
266 static void _technology_signal_cb(GDBusConnection *conn,
267                 const gchar *name, const gchar *path, const gchar *interface,
268                 const gchar *sig, GVariant *param, gpointer user_data)
269 {
270         gchar *key = NULL;
271         gboolean value = FALSE;
272         GVariant *var = NULL;
273
274         if (param == NULL)
275                 return;
276
277         if (g_str_has_prefix(path, CONNMAN_WIFI_TECHNOLOGY_PREFIX) == TRUE) {
278                 g_variant_get(param, "(sv)", &key, &var);
279                 if (g_strcmp0(key, "Powered") == 0) {
280                         /* Power state */
281                         value = g_variant_get_boolean(var);
282                         if (value == TRUE)
283                                 wifi_state_update_power_state(TRUE);
284                         else
285                                 wifi_state_update_power_state(FALSE);
286                 } else if (g_strcmp0(key, "Connected") == 0) {
287                         /* Connection state */
288                         value = g_variant_get_boolean(var);
289                         if (value == TRUE)
290                                 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_CONNECTED);
291                         else
292                                 wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_POWERED);
293                 } else if (g_strcmp0(key, "Tethering") == 0) {
294                         /* Tethering state */
295                         wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_TETHERED);
296                 }
297                 g_free(key);
298                 g_variant_unref(var);
299         }
300 }
301
302 static void _service_signal_cb(GDBusConnection *conn,
303                 const gchar *name, const gchar *path,
304                 const gchar *interface, const gchar *sig,
305                 GVariant *param, gpointer user_data)
306 {
307         gchar *sigvalue = NULL;
308         gchar *property;
309         GVariant *variant = NULL, *var;
310         GVariantIter *iter;
311         const gchar *value = NULL;
312         struct sock_data *sd = NULL;
313         int idx = 0;
314
315         if (path == NULL || param == NULL)
316                 goto done;
317
318         g_variant_get(param, "(sv)", &sigvalue, &variant);
319         if (sigvalue == NULL)
320                 goto done;
321
322         if (g_strcmp0(sig, CONNMAN_SIGNAL_PROPERTY_CHANGED) != 0)
323                 goto done;
324
325         if (g_strcmp0(sigvalue, "State") == 0) {
326                 g_variant_get(variant, "s", &property);
327
328                 DBG("[%s] %s", property, path);
329
330                 if (netconfig_is_wifi_profile(path) == TRUE) {
331                         int wifi_state = 0;
332
333                         netconfig_vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
334                         if (wifi_state == VCONFKEY_WIFI_OFF) {
335                                 g_free(property);
336                                 goto done;
337                         }
338
339                         if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
340                                 if (wifi_state >= VCONFKEY_WIFI_CONNECTED) {
341                                         g_free(property);
342                                         goto done;
343                                 }
344
345                                 netconfig_update_default_profile(path);
346
347                                 wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTED);
348
349                         } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
350                                 if (netconfig_get_default_profile() == NULL ||
351                                                 netconfig_is_wifi_profile(netconfig_get_default_profile())
352                                                 != TRUE) {
353                                         if (g_strcmp0(property, "failure") == 0)
354                                                 wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
355                                         else
356                                                 wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
357                                         g_free(property);
358                                         goto done;
359                                 }
360
361                                 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
362                                         g_free(property);
363                                         goto done;
364                                 }
365
366                                 netconfig_update_default_profile(NULL);
367
368                                 if (g_strcmp0(property, "failure") == 0)
369                                         wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE);
370                                 else
371                                         wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
372
373                         } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
374                                 if (netconfig_get_default_profile() == NULL ||
375                                                 netconfig_is_wifi_profile(netconfig_get_default_profile()) != TRUE) {
376                                         if (g_strcmp0(property, "association") == 0)
377                                                 wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
378                                         else
379                                                 wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
380                                         g_free(property);
381                                         goto done;
382                                 }
383
384                                 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
385                                         g_free(property);
386                                         goto done;
387                                 }
388
389                                 netconfig_update_default_profile(NULL);
390
391                                 if (g_strcmp0(property, "association") == 0)
392                                         wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION);
393                                 else
394                                         wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION);
395
396                         }
397                 } else {
398                         if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) {
399                                 if (netconfig_get_default_profile() == NULL) {
400                                         if (!netconfig_is_cellular_profile(path))
401                                                 netconfig_update_default_profile(path);
402                                         else {
403                                                 if (netconfig_is_cellular_internet_profile(path))
404                                                         netconfig_update_default_profile(path);
405                                         }
406                                 }
407
408                                 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
409                                         cellular_state_set_service_state(NETCONFIG_CELLULAR_ONLINE);
410
411                         } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) {
412                                 if (netconfig_get_default_profile() == NULL) {
413                                         g_free(property);
414                                         goto done;
415                                 }
416
417                                 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
418                                         cellular_state_set_service_state(NETCONFIG_CELLULAR_IDLE);
419
420                                 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
421                                         g_free(property);
422                                         goto done;
423                                 }
424
425                                 netconfig_update_default_profile(NULL);
426                         } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) {
427                                 if (netconfig_get_default_profile() == NULL) {
428                                         g_free(property);
429                                         goto done;
430                                 }
431
432                                 if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
433                                         cellular_state_set_service_state(NETCONFIG_CELLULAR_CONNECTING);
434
435                                 if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
436                                         g_free(property);
437                                         goto done;
438                                 }
439
440                                 netconfig_update_default_profile(NULL);
441                         }
442                 }
443
444                 if (netconfig_is_wifi_profile(path) || netconfig_is_ethernet_profile(path)) {
445                         if (g_strcmp0(property, "ready") == 0) {
446                                 for (idx = 0; idx < MAX_SOCKET_OPEN_RETRY; idx++) {
447                                         sd = start_ip_conflict_mon();
448                                         if (sd != NULL)
449                                                 break;
450                                 }
451                         } else if (g_strcmp0(property, "online") == 0) {
452                                 // do nothing
453                         } else {
454                                 stop_ip_conflict_mon();
455                         }
456                 }
457
458                 g_free(property);
459         } else if (g_strcmp0(sigvalue, "Proxy") == 0) {
460                 if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0)
461                         goto done;
462
463                 if (!g_variant_is_of_type(variant, G_VARIANT_TYPE_ARRAY))
464                         goto done;
465
466                 g_variant_get(variant, "a{sv}", &iter);
467                 while (g_variant_iter_loop(iter, "{sv}", &property, &var)) {
468                         GVariantBuilder *builder;
469                         GVariant *sig_params;
470                         if (g_strcmp0(property, "Servers") == 0) {
471                                 GVariantIter *iter_sub = NULL;
472
473                                 builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
474
475                                 g_variant_get(var, "as", &iter_sub);
476                                 g_variant_iter_loop(iter_sub, "s", &value);
477                                 g_variant_iter_free(iter_sub);
478
479                                 DBG("Proxy - [%s]", value);
480                                 vconf_set_str(VCONFKEY_NETWORK_PROXY, value);
481
482                                 g_variant_builder_add(builder, "{sv}", "ProxyAddress",
483                                                                 g_variant_new_string(value));
484
485                                 sig_params = g_variant_new("(@a{sv})",
486                                                                 g_variant_builder_end(builder));
487                                 g_variant_builder_unref(builder);
488
489                                 netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
490                                                    NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged",
491                                                    sig_params);
492
493                                 g_free(property);
494                                 g_variant_unref(var);
495                                 break;
496                         } else if (g_strcmp0(property, "Method") == 0) {
497                                 value = g_variant_get_string(var, NULL);
498                                 DBG("Method - [%s]", value);
499
500                                 if (g_strcmp0(value, "direct") == 0) {
501                                         builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
502
503                                         vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
504                                         g_variant_builder_add(builder, "{sv}", "ProxyAddress",
505                                                                 g_variant_new_string(""));
506
507                                         sig_params = g_variant_new("(@a{sv})",
508                                                                 g_variant_builder_end(builder));
509                                         g_variant_builder_unref(builder);
510
511                                         netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
512                                                            NETCONFIG_NETWORK_INTERFACE,
513                                                            "NetworkConfigChanged", sig_params);
514                                 }
515
516                                 g_free(property);
517                                 g_variant_unref(var);
518                                 break;
519                         }
520                 }
521
522                 g_variant_iter_free(iter);
523         } else if (g_strcmp0(sigvalue, "IPv4") == 0) {
524                 __netconfig_extract_ipv4_signal_data(variant, path);
525         } else if (g_strcmp0(sigvalue, "IPv6") == 0) {
526                 __netconfig_extract_ipv6_signal_data(variant, path);
527         } else if (g_strcmp0(sigvalue, "Error") == 0) {
528                 g_variant_get(variant, "s", &property);
529                 INFO("[%s] Property : %s", sigvalue, property);
530 #if defined TIZEN_DEBUG_ENABLE
531                 if (g_strcmp0(property, "dhcp-failed") == 0
532                         || g_strcmp0(property, "connect-failed") == 0
533                         || g_strcmp0(property, "login-failed") == 0
534                         || g_strcmp0(property, "auth-failed") == 0
535                         || g_strcmp0(property, "invalid-key") == 0) {
536
537                         INFO("start dump");
538                         _start_dump();
539                 }
540 #endif
541                 g_free(property);
542         }
543 done:
544         g_free(sigvalue);
545
546         if (variant)
547                 g_variant_unref(variant);
548
549         return;
550 }
551
552 static void _dbus_name_changed_cb(GDBusConnection *conn,
553                 const gchar *Name, const gchar *path, const gchar *interface,
554                 const gchar *sig, GVariant *param, gpointer user_data)
555 {
556         gchar *name = NULL;
557         gchar *old = NULL;
558         gchar *new = NULL;
559
560         if (param == NULL)
561                 return;
562
563         g_variant_get(param, "(sss)", &name, &old, &new);
564
565         if (g_strcmp0(name, CONNMAN_SERVICE) == 0 && *new == '\0') {
566                 DBG("ConnMan destroyed: name %s, old %s, new %s", name, old, new);
567
568                 connman_register_agent();
569         }
570         g_free(name);
571         g_free(old);
572         g_free(new);
573
574         return;
575 }
576
577 static void _services_changed_cb(GDBusConnection *conn, const gchar *name,
578                 const gchar *path, const gchar *interface, const gchar *sig,
579                 GVariant *param, gpointer user_data)
580 {
581         gchar *property, *value;
582         gchar *service_path;
583         GVariant *variant = NULL;
584         GVariantIter *added = NULL, *removed = NULL, *next = NULL;
585
586         if (path == NULL || param == NULL)
587                 return;
588
589         if (g_strcmp0(sig, CONNMAN_SIGNAL_SERVICES_CHANGED) != 0)
590                 return;
591
592         if (netconfig_get_default_profile() != NULL)
593                 return;
594
595         g_variant_get(param, "(a(oa{sv})ao)", &added, &removed);
596
597         while (g_variant_iter_loop(added, "(oa{sv})", &service_path, &next)) {
598                 gboolean is_wifi_prof, is_cell_prof, is_cell_internet_prof;
599                 is_wifi_prof = netconfig_is_wifi_profile(service_path);
600                 is_cell_prof = netconfig_is_cellular_profile(service_path);
601                 is_cell_internet_prof = netconfig_is_cellular_internet_profile(
602                                 service_path);
603                 if (service_path != NULL) {
604                         while (next && g_variant_iter_loop(next, "{sv}", &property,
605                                                 &variant)) {
606                                 if (g_strcmp0(property, "State") == 0) {
607                                         g_variant_get(variant, "s", &value);
608                                         DBG("Profile %s State %s", service_path,
609                                                         value);
610                                         if (g_strcmp0(value, "ready") != 0 &&
611                                                         g_strcmp0(value,
612                                                                 "online") != 0) {
613                                                 g_free(property);
614                                                 g_free(value);
615                                                 g_variant_unref(variant);
616                                                 break;
617                                         }
618
619                                         if (!is_cell_prof)
620                                                 netconfig_update_default_profile(
621                                                                 service_path);
622                                         else if (is_cell_internet_prof) {
623                                                 netconfig_update_default_profile(
624                                                                 service_path);
625                                         }
626                                         if (is_wifi_prof)
627                                                 wifi_state_set_service_state(
628                                                         NETCONFIG_WIFI_CONNECTED);
629                                         else if (is_cell_prof &&
630                                                         is_cell_internet_prof)
631                                                 cellular_state_set_service_state(
632                                                         NETCONFIG_CELLULAR_ONLINE);
633                                         g_free(property);
634                                         g_free(value);
635                                         g_variant_unref(variant);
636                                         break;
637                                 }
638                         }
639                 }
640         }
641
642         g_variant_iter_free(added);
643
644         if (next)
645                 g_variant_iter_free(next);
646
647         if (removed)
648                 g_variant_iter_free(removed);
649
650         return;
651 }
652
653 static void _supplicant_interface_removed(GDBusConnection *conn,
654                 const gchar *name, const gchar *path, const gchar *interface,
655                 const gchar *sig, GVariant *param, gpointer user_data)
656 {
657         DBG("Interface removed handling!");
658         if (netconfig_wifi_is_bssid_scan_started() == TRUE)
659                 netconfig_wifi_bssid_signal_scanaborted();
660
661         return;
662 }
663
664 static void _supplicant_properties_changed(GDBusConnection *conn,
665                 const gchar *name, const gchar *path, const gchar *interface,
666                 const gchar *sig, GVariant *param, gpointer user_data)
667 {
668         DBG("Properties changed handling!");
669         gchar *key = NULL;
670         const gchar *state = NULL;
671         GVariantIter *iter = NULL;
672         GVariant *variant = NULL;
673         gboolean scanning = FALSE;
674
675         if (param == NULL)
676                 return;
677
678         g_variant_get(param, "(a{sv})", &iter);
679         while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
680                 if (g_strcmp0(key, "Scanning") == 0) {
681                         scanning = g_variant_get_boolean(variant);
682                         DBG("setting scanning %s", scanning ? "TRUE" : "FALSE");
683                         if (scanning == TRUE)
684                                 netconfig_wifi_set_scanning(TRUE);
685                         else
686                                 netconfig_wifi_set_scanning(FALSE);
687
688                         g_variant_unref(variant);
689                         g_free(key);
690                         variant = NULL;
691                         key = NULL;
692                         break;
693                 } else if (g_strcmp0(key, "State") == 0) {
694                         state = g_variant_get_string(variant, NULL);
695                         if (state != NULL)
696                                 ERR("Supplicant state : %s", state);
697
698                         g_variant_unref(variant);
699                         g_free(key);
700                         variant = NULL;
701                         key = NULL;
702                         break;
703                 } else if (g_strcmp0(key, "DisconnectReason") == 0) {
704                         int reason = g_variant_get_int32(variant);
705                         ERR("Supplicant DisconnReason : %d", reason);
706
707                         g_variant_unref(variant);
708                         g_free(key);
709                         variant = NULL;
710                         key = NULL;
711                         break;
712                 } else {
713                         gchar *value;
714                         value = g_variant_print(variant, TRUE);
715                         DBG("Supplicant %s : %s", key, value);
716
717                         g_free(value);
718                 }
719         }
720
721         g_variant_iter_free(iter);
722
723         return;
724 }
725
726 static void _supplicant_bss_added(GDBusConnection *conn,
727                 const gchar *name, const gchar *path, const gchar *interface,
728                 const gchar *sig, GVariant *param, gpointer user_data)
729 {
730         DBG("BSS added handling!");
731         wifi_state_set_bss_found(TRUE);
732
733         return;
734 }
735
736 static void _supplicant_scan_done(GDBusConnection *conn,
737                 const gchar *name, const gchar *path, const gchar *interface,
738                 const gchar *sig, GVariant *param, gpointer user_data)
739 {
740         DBG("Scan Done handling!");
741         netconfig_wifi_set_scanning(FALSE);
742
743         if (netconfig_wifi_is_bssid_scan_started() == TRUE) {
744                 netconfig_wifi_bssid_signal_scandone();
745                 if (wifi_state_get_technology_state() < NETCONFIG_WIFI_TECH_POWERED)
746                         return;
747         }
748
749         if (netconfig_wifi_get_bgscan_state() == TRUE) {
750                 if (wifi_state_get_technology_state() >=
751                                 NETCONFIG_WIFI_TECH_POWERED)
752                         netconfig_wifi_bgscan_start(FALSE);
753
754                 wifi_start_timer_network_notification();
755         }
756
757         return;
758 }
759
760 static void _supplicant_driver_hanged(GDBusConnection *conn,
761                 const gchar *name, const gchar *path, const gchar *interface,
762                 const gchar *sig, GVariant *param, gpointer user_data)
763 {
764         DBG("Driver Hanged handling!");
765         ERR("Critical. Wi-Fi firmware crashed");
766
767 #if !defined TIZEN_WEARABLE
768         netconfig_send_message_to_net_popup("Wi-Fi Error",
769                 "Wi-Fi Driver Hanged. Please get log dump and report", "popup", NULL);
770 #endif
771         wifi_power_recover_firmware();
772
773         return;
774
775 }
776
777 static void _supplicant_session_overlapped(GDBusConnection *conn,
778                 const gchar *name, const gchar *path, const gchar *interface,
779                 const gchar *sig, GVariant *param, gpointer user_data)
780 {
781         DBG("Driver session overlapped handling!");
782         ERR("WPS PBC SESSION OVERLAPPED");
783 #if defined TIZEN_WEARABLE
784         return;
785 #else
786         netconfig_send_message_to_net_popup("WPS Error",
787                                         "wps session overlapped", "popup", NULL);
788 #endif
789 }
790
791 #if defined TIZEN_DEBUG_ENABLE
792 static void __netconfig_dumpservice_handler(GDBusConnection *conn,
793                 const gchar *name, const gchar *path, const gchar *interface,
794                 const gchar *sig, GVariant *param, gpointer user_data)
795 {
796         int mode;
797         gchar *signal_path = NULL;
798
799         if (param == NULL)
800                 return;
801
802         g_variant_get(param, "(is)", &mode, &signal_path);
803         DBG("Path: %s and mode: %d", signal_path, mode);
804
805         netconfig_dump_log(signal_path);
806         if (signal_path)
807                 g_free(signal_path);
808
809         return;
810 }
811 #endif
812
813 static void _supplicant_tdls_connected(GDBusConnection *conn,
814                 const gchar *name, const gchar *path, const gchar *interface,
815                 const gchar *sig, GVariant *param, gpointer user_data)
816 {
817         DBG("Received TDLS Connected Signal");
818         netconfig_wifi_tdls_connected_event(param);
819
820         return;
821 }
822
823 static void _supplicant_tdls_disconnected(GDBusConnection *conn,
824                 const gchar *name, const gchar *path, const gchar *interface,
825                 const gchar *sig, GVariant *param, gpointer user_data)
826 {
827         DBG("Received TDLS Disconnected Signal");
828         netconfig_wifi_tdls_disconnected_event(param);
829
830         return;
831 }
832
833 static void _supplicant_tdls_peer_found(GDBusConnection *conn,
834                 const gchar *name, const gchar *path, const gchar *interface,
835                 const gchar *sig, GVariant *param, gpointer user_data)
836 {
837         DBG("Received TDLS Peer Found Signal");
838         netconfig_wifi_tdls_peer_found_event(param);
839         return;
840 }
841
842 static void _supplicant_wifi_wps_connected(GVariant *param)
843 {
844         gchar *key;
845         char ssid[32] = {0, };
846         gchar *name;
847         GVariantIter *iter;
848         GVariant *variant;
849         int config_error = 0;
850         int error_indication = 0;
851         gsize ssid_len = 0;
852
853         if (param == NULL) {
854                 ERR("Param is NULL");
855                 return;
856         }
857
858         g_variant_get(param, "(sa{sv})", &name, &iter);
859         INFO("wps Result: %s", name);
860         while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
861                 INFO("wps Key is %s", key);
862                 if (g_strcmp0(key, "SSID") == 0) {
863                         const char *t_key = NULL;
864                         t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar));
865                         INFO("wps ssid_len is %zd ", ssid_len);
866                         if (t_key == NULL) {
867                                 g_free(key);
868                                 g_variant_unref(variant);
869                                 ERR("WPS PBC Connection Failed");
870                                 goto error;
871                         }
872                         if (ssid_len > 0 && ssid_len <= 32) {
873                                 memcpy(ssid, t_key, ssid_len);
874                         } else {
875                                 memset(ssid, 0, sizeof(ssid));
876                                 ssid_len = 0;
877                         }
878                         INFO("WPS PBC Connection completed with AP %s", ssid);
879                         netconfig_wifi_notify_wps_completed(ssid, ssid_len);
880                 }
881         }
882
883         g_variant_iter_free(iter);
884         g_free(name);
885         return;
886
887 error:
888         g_variant_iter_free(iter);
889         g_free(name);
890         error_indication = WPS_EI_OPERATION_FAILED;
891         config_error = WPS_CFG_NO_ERROR;
892         ERR("Error Occured! Notifying Fail Event");
893         netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
894
895 }
896
897 static void _supplicant_wifi_wps_event(GVariant *param)
898 {
899         gchar *key;
900         gchar *name;
901         GVariantIter *iter;
902         GVariant *variant;
903         gint32 config_error = 0;
904         gint32 error_indication = 0;
905
906         if (param == NULL) {
907                 ERR("Param is NULL");
908                 return;
909         }
910
911         g_variant_get(param, "(sa{sv})", &name, &iter);
912         INFO("Event Result: %s", name);
913         if (g_strcmp0(name, "fail") == 0) {
914                 while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
915                         if (key == NULL)
916                                 goto error;
917                         INFO("Key is %s", key);
918                         if (g_strcmp0(key, "config_error") == 0) {
919                                 config_error = g_variant_get_int32(variant);
920                                 ERR("Config Error %d", config_error);
921                         } else if (g_strcmp0(key, "error_indication") == 0) {
922                                 error_indication = g_variant_get_int32(variant);
923                                 ERR("Error Indication %d", error_indication);
924                         }
925                 }
926                 netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
927         }
928
929         g_variant_iter_free(iter);
930         g_free(name);
931         return;
932
933 error:
934         g_variant_iter_free(iter);
935         g_free(name);
936         error_indication = WPS_EI_OPERATION_FAILED;
937         config_error = WPS_CFG_NO_ERROR;
938         ERR("Error Occured! Notifying Fail Event");
939         netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
940 }
941
942 static void _find_service_and_set_passphrase(char *ssid, char *key)
943 {
944         GString *str;
945         GVariant *reply = NULL;
946         int i, j, ssid_len;
947         char *service_path;
948         char *dev_mac_addr;
949         char ident[13];
950         gchar *enc_passphrase;
951
952         ssid_len = strlen(ssid);
953
954         str = g_string_sized_new((ssid_len * 2) + 55);
955         if (!str)
956                 return;
957
958         dev_mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
959         if (!dev_mac_addr) {
960                 ERR("Failed to get mac address from vconf key");
961                 g_string_free(str, TRUE);
962                 return;
963         }
964
965         j = 0;
966         for (i = 0; dev_mac_addr[i]; i++) {
967                 if (dev_mac_addr[i] != ':')
968                         ident[j++] = dev_mac_addr[i];
969         }
970         ident[j] = '\0';
971
972         g_string_append_printf(str, "%s%s_", CONNMAN_WIFI_SERVICE_PROFILE_PREFIX,
973                                                    ident);
974         free(dev_mac_addr);
975
976         for (i = 0; i < ssid_len; i++) {
977                 if (ssid[i] != '"')
978                         g_string_append_printf(str, "%02x", ssid[i]);
979         }
980
981         g_string_append_printf(str, "_managed_psk");
982
983         service_path = g_string_free(str, FALSE);
984
985         enc_passphrase = _netconfig_encrypt_passphrase(key);
986         if (!enc_passphrase) {
987                 ERR("Failed to encrypt passphrase");
988                 g_free(service_path);
989                 return;
990         }
991
992         INFO("wps service_path %s Passphrase %s", service_path, enc_passphrase);
993
994         reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE, service_path,
995                                          CONNMAN_SERVICE_INTERFACE, "SetProperty",
996                                          g_variant_new("(sv)", "Passphrase",
997                                                                    g_variant_new_string(enc_passphrase)));
998         if (reply != NULL)
999                 g_variant_unref(reply);
1000         else
1001                 ERR("Failed to set passphrase");
1002
1003         g_free(service_path);
1004
1005         return;
1006 }
1007
1008 static void _supplicant_wifi_wps_credentials(GVariant *param)
1009 {
1010         gchar *key;
1011         char ssid[32] = {0, };
1012         char wps_key[100] = {0, };
1013         GVariantIter *iter;
1014         GVariant *variant;
1015         int config_error = 0;
1016         int error_indication = 0;
1017         gsize ssid_len = 0;
1018         char *key_mgmt = NULL;
1019
1020         if (param == NULL) {
1021                 ERR("Param is NULL");
1022                 return;
1023         }
1024
1025         g_variant_get(param, "(a{sv})", &iter);
1026         while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
1027                 if (key == NULL)
1028                         goto error;
1029                 INFO("wps Key is %s", key);
1030                 if (g_strcmp0(key, "Key") == 0) {
1031                         gsize key_len = 0;
1032                         const char *t_key = NULL;
1033                         key_len = g_variant_get_size(variant);
1034
1035                         INFO("wps password len %zd ", key_len);
1036                         if (key_len > 0) {
1037                                 t_key = g_variant_get_fixed_array(variant, &key_len,
1038                                                   sizeof(guchar));
1039                                 if (!t_key) {
1040                                         g_free(key);
1041                                         g_variant_unref(variant);
1042                                         goto error;
1043                                 }
1044                                 strncpy(wps_key, t_key, key_len);
1045                                 wps_key[key_len] = '\0';
1046                                 INFO("WPS Key in process credentials %s", wps_key);
1047                         } else
1048                                 SLOGI("WPS AP Security ->Open");
1049                 } else if (g_strcmp0(key, "SSID") == 0) {
1050                         const char *t_key = NULL;
1051                         t_key = g_variant_get_fixed_array(variant, &ssid_len,
1052                                                   sizeof(guchar));
1053                         INFO("wps ssid_len is %zd ", ssid_len);
1054                         if (!t_key) {
1055                                 g_free(key);
1056                                 g_variant_unref(variant);
1057                                 goto error;
1058                         }
1059                         if (ssid_len > 0 && ssid_len <= 32) {
1060                                 memcpy(ssid, t_key, ssid_len);
1061                         } else {
1062                                 memset(ssid, 0, sizeof(ssid));
1063                                 ssid_len = 0;
1064                         }
1065                         INFO("SSID in process credentials %s", ssid);
1066                 } else if (g_strcmp0(key, "AuthType") == 0) {
1067                         gchar *auth_type;
1068                         GVariantIter *var_iter;
1069                         g_variant_get(variant, "as", &var_iter);
1070                         while (g_variant_iter_loop(var_iter, "s", &auth_type)) {
1071                                 INFO("wps auth_type %s", auth_type);
1072                                 if (g_strcmp0(auth_type, "wpa-psk") == 0 ||
1073                                         g_strcmp0(auth_type, "wpa2-psk") == 0)
1074                                         key_mgmt = "psk";
1075                                 else if (g_strcmp0(auth_type, "open") == 0)
1076                                         key_mgmt = "none";
1077                         }
1078                         g_variant_iter_free(var_iter);
1079                 } else if (g_strcmp0(key, "EncrType") == 0) {
1080                         gchar *encr_type;
1081                         GVariantIter *var_iter;
1082                         g_variant_get(variant, "as", &var_iter);
1083                         while (g_variant_iter_loop(var_iter, "s", &encr_type))
1084                                 INFO("wps encr_type %s", encr_type);
1085                         g_variant_iter_free(var_iter);
1086                 } else if (g_strcmp0(key, "BSSID") == 0) {
1087                         const guchar *bssid;
1088                         gsize bssid_len;
1089                         bssid = g_variant_get_fixed_array(variant, &bssid_len,
1090                                                                 sizeof(guchar));
1091                         if (bssid && bssid_len == 6)
1092                                 INFO("wps BSSID %2x:%2x:%2x:%2x:%2x:%2x", bssid[0], bssid[1],
1093                                          bssid[2], bssid[3], bssid[4], bssid[5]);
1094                 }
1095         }
1096
1097         g_variant_iter_free(iter);
1098
1099         if (g_strcmp0(key_mgmt, "psk") == 0)
1100                 _find_service_and_set_passphrase(ssid, wps_key);
1101
1102 #if 0
1103         /*
1104          * Notify WPS Credentials only when requested through WPS PBC
1105          * In case of WPS PIN connman will take care of notification
1106          */
1107         if (netconfig_get_wps_field() == TRUE)
1108 #endif
1109         netconfig_wifi_notify_wps_credentials(ssid, ssid_len, wps_key);
1110         return;
1111
1112 error:
1113         g_variant_iter_free(iter);
1114         error_indication = WPS_EI_OPERATION_FAILED;
1115         config_error = WPS_CFG_NO_ERROR;
1116         ERR("Error Occured! Notifying Fail Event");
1117         netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
1118 }
1119
1120 static void __netconfig_wps_signal_filter_handler(GDBusConnection *conn,
1121                 const gchar *name, const gchar *path, const gchar *interface,
1122                 const gchar *sig, GVariant *param, gpointer user_data)
1123 {
1124         if (g_strcmp0(sig, SIGNAL_WPS_CREDENTIALS) == 0) {
1125                 INFO("Received wps CREDENTIALS Signal from Supplicant");
1126                 _supplicant_wifi_wps_credentials(param);
1127         } else if (g_strcmp0(sig, SIGNAL_WPS_EVENT) == 0) {
1128                 INFO("Received wps EVENT Signal from Supplicant");
1129                 _supplicant_wifi_wps_event(param);
1130         } else if (g_strcmp0(sig, SIGNAL_WPS_CONNECTED) == 0) {
1131                 INFO("Received WPSConnected Signal from Supplicant");
1132                 _supplicant_wifi_wps_connected(param);
1133         }
1134
1135         return;
1136 }
1137
1138 static supplicant_signal_cb supplicant_cbs[SIG_MAX] = {
1139                 _supplicant_interface_removed,
1140                 _supplicant_properties_changed,
1141                 _supplicant_bss_added,
1142                 _supplicant_scan_done,
1143                 _supplicant_driver_hanged,
1144                 _supplicant_session_overlapped,
1145                 _supplicant_tdls_connected,
1146                 _supplicant_tdls_disconnected,
1147                 _supplicant_tdls_peer_found
1148 };
1149
1150 void register_gdbus_signal(void)
1151 {
1152         GDBusConnection *connection = NULL;
1153         const char *interface = NULL;
1154         SuppSigArrayIndex sig;
1155         connection = netdbus_get_connection();
1156
1157         if (connection == NULL) {
1158                 ERR("Failed to get GDbus Connection");
1159                 return;
1160         }
1161
1162         /* listening to messages from all objects as no path is specified */
1163         /* see signals from the given interface */
1164         conn_subscription_ids[0] = g_dbus_connection_signal_subscribe(
1165                         connection,
1166                         CONNMAN_SERVICE,
1167                         CONNMAN_TECHNOLOGY_INTERFACE,
1168                         NULL,
1169                         NULL,
1170                         NULL,
1171                         G_DBUS_SIGNAL_FLAGS_NONE,
1172                         _technology_signal_cb,
1173                         NULL,
1174                         NULL);
1175
1176         conn_subscription_ids[1] = g_dbus_connection_signal_subscribe(
1177                         connection,
1178                         CONNMAN_SERVICE,
1179                         CONNMAN_SERVICE_INTERFACE,
1180                         CONNMAN_SIGNAL_PROPERTY_CHANGED,
1181                         NULL,
1182                         NULL,
1183                         G_DBUS_SIGNAL_FLAGS_NONE,
1184                         _service_signal_cb,
1185                         NULL,
1186                         NULL);
1187
1188         conn_subscription_ids[2] = g_dbus_connection_signal_subscribe(
1189                         connection,
1190                         DBUS_SERVICE_DBUS,
1191                         DBUS_INTERFACE_DBUS,
1192                         CONNMAN_SIGNAL_NAME_CHANGED,
1193                         NULL,
1194                         CONNMAN_SERVICE,
1195                         G_DBUS_SIGNAL_FLAGS_NONE,
1196                         _dbus_name_changed_cb,
1197                         NULL,
1198                         NULL);
1199
1200         conn_subscription_ids[3] = g_dbus_connection_signal_subscribe(
1201                         connection,
1202                         CONNMAN_SERVICE,
1203                         CONNMAN_MANAGER_INTERFACE,
1204                         CONNMAN_SIGNAL_SERVICES_CHANGED,
1205                         NULL,
1206                         NULL,
1207                         G_DBUS_SIGNAL_FLAGS_NONE,
1208                         _services_changed_cb,
1209                         NULL,
1210                         NULL);
1211
1212         INFO("Successfully register connman DBus signal filters");
1213
1214         conn_subscription_ids[4] = g_dbus_connection_signal_subscribe(
1215                         connection,
1216                         SUPPLICANT_SERVICE,
1217                         SUPPLICANT_INTERFACE ".Interface.WPS",
1218                         NULL,
1219                         NULL,
1220                         NULL,
1221                         G_DBUS_SIGNAL_FLAGS_NONE,
1222                         __netconfig_wps_signal_filter_handler,
1223                         NULL,
1224                         NULL);
1225
1226         INFO("Successfully register Supplicant WPS DBus signal filters");
1227
1228         for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
1229                 /*
1230                  * For SIG_INTERFACE_REMOVED INTERFACE_ADDED
1231                  */
1232                 interface = (sig == SIG_INTERFACE_REMOVED) ?
1233                                 SUPPLICANT_INTERFACE : SUPPLICANT_IFACE_INTERFACE;
1234
1235                 supp_subscription_ids[sig] = g_dbus_connection_signal_subscribe(
1236                                 connection,
1237                                 SUPPLICANT_SERVICE,
1238                                 interface,
1239                                 supplicant_signals[sig],
1240                                 NULL,
1241                                 NULL,
1242                                 G_DBUS_SIGNAL_FLAGS_NONE,
1243                                 supplicant_cbs[sig],
1244                                 NULL,
1245                                 NULL);
1246         }
1247
1248         INFO("Successfully register Supplicant DBus signal filters");
1249
1250 #if defined TIZEN_DEBUG_ENABLE
1251         dumpservice_subscription_id = g_dbus_connection_signal_subscribe(
1252                         connection,
1253                         NULL,
1254                         DUMP_SERVICE_INTERFACE,
1255                         DUMP_SIGNAL,
1256                         NULL,
1257                         NULL,
1258                         G_DBUS_SIGNAL_FLAGS_NONE,
1259                         __netconfig_dumpservice_handler,
1260                         NULL,
1261                         NULL);
1262
1263         INFO("Successfully registered Dumpservice DBus signal filter");
1264 #endif
1265
1266         /* In case ConnMan precedes this signal register,
1267          * net-config should update the default connected profile.
1268          */
1269         netconfig_update_default();
1270 }
1271
1272 void deregister_gdbus_signal(void)
1273 {
1274         GDBusConnection *connection = NULL;
1275         int signal;
1276         SuppSigArrayIndex sig;
1277         connection = netdbus_get_connection();
1278         if (!connection) {
1279                 ERR("Already de-registered. Nothing to be done");
1280                 return;
1281         }
1282
1283         for (signal = 0; signal < TOTAL_CONN_SIGNALS; signal++) {
1284                 if (conn_subscription_ids[signal]) {
1285                         g_dbus_connection_signal_unsubscribe(connection,
1286                                                 conn_subscription_ids[signal]);
1287                 }
1288         }
1289
1290         for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
1291                 if (supp_subscription_ids[sig]) {
1292                         g_dbus_connection_signal_unsubscribe(connection,
1293                                                 supp_subscription_ids[sig]);
1294                 }
1295         }
1296
1297 #if defined TIZEN_DEBUG_ENABLE
1298         g_dbus_connection_signal_unsubscribe(connection,
1299                         dumpservice_subscription_id);
1300 #endif
1301 }