Merge "Using updated clatd's Dbus interface and Path values" into tizen
[platform/core/connectivity/net-config.git] / src / signal-handler.c
index 4fe67ad..93373ff 100755 (executable)
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <vconf.h>
 #include <vconf-keys.h>
+#include <sys/wait.h>
 
 #include "log.h"
 #include "util.h"
 #include "signal-handler.h"
 #include "wifi-background-scan.h"
 #include "wifi-tdls.h"
+#include "wifi-dpp.h"
 #include "ip-conflict-detect.h"
+#include "wifi-key-encryption.h"
+#include "clatd-handler.h"
 #if defined TIZEN_DEBUG_ENABLE
 #include "network-dump.h"
+#define NETWORK_LOG_DUMP_SCRIPT  "/opt/var/lib/net-config/network_log_dump.sh"
+#define MAX_SIZE_ERROR_BUFFER 256
 #endif
 
 #define DBUS_SERVICE_DBUS                      "org.freedesktop.DBus"
 #define SIGNAL_TDLS_DISCONNECTED                       "TDLSDisconnected"
 #define SIGNAL_TDLS_PEER_FOUND                         "TDLSPeerFound"
 
+#define SIGNAL_DPP_AUTH_SUCCESS "DPPAuthSuccess"
+#define SIGNAL_DPP_AUTH_FAILED "DPPAuthFailed"
+#define SIGNAL_DPP_NOT_COMPATIBLE "DPPNotCompatible"
+#define SIGNAL_DPP_CONF_FAILED "DPPConfFailed"
+#define SIGNAL_DPP_SCAN_PEER_QR "DPPScanPeerQrCode"
+#define SIGNAL_DPP_NETWORK_ID "DPPNetworkID"
+#define SIGNAL_DPP_CONF_SENT "DPPConfSent"
+#define SIGNAL_DPP_CONF_RECEIVED "DPPConfReceived"
+#define SIGNAL_DPP_CONF_OBJ "DPPConfObj"
+
 #define SIGNAL_WPS_CONNECTED                           "WPSConnected"
 #define SIGNAL_WPS_EVENT                                       "Event"
 #define SIGNAL_WPS_CREDENTIALS                         "Credentials"
 
 #define CONNMAN_SIGNAL_SERVICES_CHANGED                "ServicesChanged"
 #define CONNMAN_SIGNAL_PROPERTY_CHANGED                "PropertyChanged"
-#define CONNMAN_SIGNAL_NAME_CHANGED            "NameOwnerChanged"
+#define SIGNAL_NAME_OWNER_CHANGED              "NameOwnerChanged"
 
 #define MAX_SIG_LEN 64
-#define TOTAL_CONN_SIGNALS 5
+#define TOTAL_CONN_SIGNALS 6
 #define MAX_SOCKET_OPEN_RETRY 5
 
 typedef enum {
@@ -77,6 +93,15 @@ typedef enum {
        SIG_TDLS_CONNECTED,
        SIG_TDLS_DISCONNECTED,
        SIG_TDLS_PEER_FOUND,
+       SIG_DPP_AUTH_SUCCESS,
+       SIG_DPP_AUTH_FAILED,
+       SIG_DPP_NOT_COMPATIBLE,
+       SIG_DPP_CONF_FAILED,
+       SIG_DPP_SCAN_PEER_QR,
+       SIG_DPP_NETWORK_ID,
+       SIG_DPP_CONF_SENT,
+       SIG_DPP_CONF_RECEIVED,
+       SIG_DPP_CONF_OBJ,
        SIG_MAX
 } SuppSigArrayIndex;
 
@@ -91,6 +116,35 @@ static const char supplicant_signals[SIG_MAX][MAX_SIG_LEN] = {
                SIGNAL_TDLS_CONNECTED,
                SIGNAL_TDLS_DISCONNECTED,
                SIGNAL_TDLS_PEER_FOUND,
+               SIGNAL_DPP_AUTH_SUCCESS,
+               SIGNAL_DPP_AUTH_FAILED,
+               SIGNAL_DPP_NOT_COMPATIBLE,
+               SIGNAL_DPP_CONF_FAILED,
+               SIGNAL_DPP_SCAN_PEER_QR,
+               SIGNAL_DPP_NETWORK_ID,
+               SIGNAL_DPP_CONF_SENT,
+               SIGNAL_DPP_CONF_RECEIVED,
+               SIGNAL_DPP_CONF_OBJ,
+};
+static const char *supplicant_iface_for_sig[SIG_MAX] = {
+               SUPPLICANT_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_INTERFACE,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
+               SUPPLICANT_IFACE_DPP,
 };
 
 static int supp_subscription_ids[SIG_MAX] = {0};
@@ -139,6 +193,8 @@ static void __netconfig_extract_ipv4_signal_data(GVariant *dictionary,
                                params = g_variant_new("(@a{sv})",
                                                                           g_variant_builder_end(builder));
 
+                               g_variant_builder_unref(builder);
+
                                netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
                                                   NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged",
                                                   params);
@@ -181,6 +237,7 @@ static void __netconfig_extract_ipv6_signal_data(GVariant *dictionary,
 
                                params = g_variant_new("(@a{sv})",
                                                                           g_variant_builder_end(builder));
+                               g_variant_builder_unref(builder);
 
                                netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
                                                   NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged",
@@ -191,6 +248,71 @@ static void __netconfig_extract_ipv6_signal_data(GVariant *dictionary,
        }
 }
 
+#if defined TIZEN_DEBUG_ENABLE
+static int __netconfig_handle_execute_file(const char *file_path,
+               char *const args[], char *const envs[])
+{
+       pid_t pid = 0;
+       int status = 0;
+       int rv = 0;
+       errno = 0;
+       register unsigned int index = 0;
+       char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
+
+       while (args[index] != NULL) {
+               DBG("%s", args[index]);
+               index++;
+       }
+
+       if (!(pid = fork())) {
+               DBG("pid(%d), ppid (%d)", getpid(), getppid());
+               DBG("Inside child, exec (%s) command", file_path);
+
+               errno = 0;
+               if (execve(file_path, args, envs) == -1) {
+                       DBG("Fail to execute command (%s)",
+                                       strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
+                       exit(1);
+               }
+       } else if (pid > 0) {
+               if (waitpid(pid, &status, 0) == -1)
+                       DBG("wait pid (%u) status (%d)", pid, status);
+
+               if (WIFEXITED(status)) {
+                       rv = WEXITSTATUS(status);
+                       DBG("exited, status=%d", rv);
+               } else if (WIFSIGNALED(status)) {
+                       DBG("killed by signal %d", WTERMSIG(status));
+               } else if (WIFSTOPPED(status)) {
+                       DBG("stopped by signal %d", WSTOPSIG(status));
+               } else if (WIFCONTINUED(status)) {
+                       DBG("continued");
+               }
+
+               return rv;
+       }
+
+       DBG("failed to fork(%s)",
+               strerror_r(errno, error_buf, MAX_SIZE_ERROR_BUFFER));
+       return -EIO;
+}
+
+static int _start_dump()
+{
+       int rv = 0;
+       gchar *path = NETWORK_LOG_DUMP_SCRIPT;
+       char *const args[] = { NETWORK_LOG_DUMP_SCRIPT, NULL };
+       char *const envs[] = { NULL };
+
+       rv = __netconfig_handle_execute_file(path, args, envs);
+       if (rv < 0) {
+               ERR("Fail to execute network log dump shell");
+               return -EIO;
+       }
+       return 0;
+}
+#endif
+
 static void _technology_signal_cb(GDBusConnection *conn,
                const gchar *name, const gchar *path, const gchar *interface,
                const gchar *sig, GVariant *param, gpointer user_data)
@@ -222,10 +344,8 @@ static void _technology_signal_cb(GDBusConnection *conn,
                        /* Tethering state */
                        wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_TETHERED);
                }
-               if (key)
-                       g_free(key);
-               if (var)
-                       g_variant_unref(var);
+               g_free(key);
+               g_variant_unref(var);
        }
 }
 
@@ -240,6 +360,7 @@ static void _service_signal_cb(GDBusConnection *conn,
        GVariantIter *iter;
        const gchar *value = NULL;
        struct sock_data *sd = NULL;
+       gchar *pf = NULL;
        int idx = 0;
 
        if (path == NULL || param == NULL)
@@ -255,20 +376,7 @@ static void _service_signal_cb(GDBusConnection *conn,
        if (g_strcmp0(sigvalue, "State") == 0) {
                g_variant_get(variant, "s", &property);
 
-       DBG("[%s] %s", property, path);
-       if (netconfig_is_wifi_profile(path) || netconfig_is_ethernet_profile(path)) {
-               if (g_strcmp0(property, "ready") == 0) {
-                       for (idx = 0; idx < MAX_SOCKET_OPEN_RETRY; idx++) {
-                               sd = start_ip_conflict_mon();
-                               if (sd != NULL)
-                                       break;
-                       }
-               } else if (g_strcmp0(property, "online") == 0) {
-                       // do nothing
-               } else {
-                       stop_ip_conflict_mon();
-               }
-       }
+               DBG("[%s] %s", property, path);
 
                if (netconfig_is_wifi_profile(path) == TRUE) {
                        int wifi_state = 0;
@@ -346,6 +454,16 @@ static void _service_signal_cb(GDBusConnection *conn,
                                                if (netconfig_is_cellular_internet_profile(path))
                                                        netconfig_update_default_profile(path);
                                        }
+                               } else {
+                                       pf = netconfig_get_connected_cellular_internet_ipv6only_profile(NULL);
+                                       if (pf)
+                                       {
+                                               g_free(pf);
+
+                                               /* Enable clatd if it is not in running state */
+                                               DBG("Connected to ipv6 only cellular, enable clatd");
+                                               netconfig_clatd_enable();
+                                       }
                                }
 
                                if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
@@ -357,9 +475,14 @@ static void _service_signal_cb(GDBusConnection *conn,
                                        goto done;
                                }
 
-                               if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path))
+                               if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path)) {
                                        cellular_state_set_service_state(NETCONFIG_CELLULAR_IDLE);
 
+                                       /* Disable clatd if it is in running state */
+                                       DBG("disable clatd");
+                                       netconfig_clatd_disable();
+                               }
+
                                if (g_strcmp0(path, netconfig_get_default_profile()) != 0) {
                                        g_free(property);
                                        goto done;
@@ -383,12 +506,27 @@ static void _service_signal_cb(GDBusConnection *conn,
                                netconfig_update_default_profile(NULL);
                        }
                }
+
+               if (netconfig_is_wifi_profile(path) || netconfig_is_ethernet_profile(path)) {
+                       if (g_strcmp0(property, "ready") == 0) {
+                               for (idx = 0; idx < MAX_SOCKET_OPEN_RETRY; idx++) {
+                                       sd = start_ip_conflict_mon();
+                                       if (sd != NULL)
+                                               break;
+                               }
+                       } else if (g_strcmp0(property, "online") == 0) {
+                               // do nothing
+                       } else {
+                               stop_ip_conflict_mon();
+                       }
+               }
+
                g_free(property);
        } else if (g_strcmp0(sigvalue, "Proxy") == 0) {
                if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0)
                        goto done;
 
-               if (!g_variant_type_equal(variant, G_VARIANT_TYPE_ARRAY))
+               if (!g_variant_is_of_type(variant, G_VARIANT_TYPE_ARRAY))
                        goto done;
 
                g_variant_get(variant, "a{sv}", &iter);
@@ -412,6 +550,7 @@ static void _service_signal_cb(GDBusConnection *conn,
 
                                sig_params = g_variant_new("(@a{sv})",
                                                                g_variant_builder_end(builder));
+                               g_variant_builder_unref(builder);
 
                                netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
                                                   NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged",
@@ -433,6 +572,7 @@ static void _service_signal_cb(GDBusConnection *conn,
 
                                        sig_params = g_variant_new("(@a{sv})",
                                                                g_variant_builder_end(builder));
+                                       g_variant_builder_unref(builder);
 
                                        netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH,
                                                           NETCONFIG_NETWORK_INTERFACE,
@@ -453,11 +593,21 @@ static void _service_signal_cb(GDBusConnection *conn,
        } else if (g_strcmp0(sigvalue, "Error") == 0) {
                g_variant_get(variant, "s", &property);
                INFO("[%s] Property : %s", sigvalue, property);
+#if defined TIZEN_DEBUG_ENABLE
+               if (g_strcmp0(property, "dhcp-failed") == 0
+                       || g_strcmp0(property, "connect-failed") == 0
+                       || g_strcmp0(property, "login-failed") == 0
+                       || g_strcmp0(property, "auth-failed") == 0
+                       || g_strcmp0(property, "invalid-key") == 0) {
+
+                       INFO("start dump");
+                       _start_dump();
+               }
+#endif
                g_free(property);
        }
 done:
-       if (sigvalue)
-               g_free(sigvalue);
+       g_free(sigvalue);
 
        if (variant)
                g_variant_unref(variant);
@@ -482,13 +632,16 @@ static void _dbus_name_changed_cb(GDBusConnection *conn,
                DBG("ConnMan destroyed: name %s, old %s, new %s", name, old, new);
 
                connman_register_agent();
+       } else if (g_strcmp0(name, CLATD_SERVICE) == 0 && *new == '\0') {
+               DBG("Clat destroyed: name %s, old %s, new %s", name, old, new);
+
+               /* If clatd is terminated unexpectedly, reset and enable clat service. */
+               if (NETCONFIG_CELLULAR_ONLINE == cellular_state_get_service_state())
+                       netconfig_clatd_reset();
        }
-       if (name)
-               g_free(name);
-       if (old)
-               g_free(old);
-       if (new)
-               g_free(new);
+       g_free(name);
+       g_free(old);
+       g_free(new);
 
        return;
 }
@@ -758,6 +911,87 @@ static void _supplicant_tdls_peer_found(GDBusConnection *conn,
        return;
 }
 
+static void _supplicant_dpp_auth_success(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Auth Success Signal");
+       netconfig_wifi_dpp_auth_success_event(param);
+       return;
+}
+
+static void _supplicant_dpp_auth_failed(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Auth Failed Signal");
+       netconfig_wifi_dpp_auth_failed_event(param);
+       return;
+}
+
+static void _supplicant_dpp_not_compatible(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Not Compatible Signal");
+       netconfig_wifi_dpp_not_compatible_event(param);
+       return;
+}
+
+static void _supplicant_dpp_conf_failed(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Conf Failed Signal");
+       netconfig_wifi_dpp_conf_failed_event(param);
+       return;
+}
+
+static void _supplicant_dpp_scan_peer_qr(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Scan Peer QR Signal");
+       netconfig_wifi_dpp_scan_peer_qr_event(param);
+       return;
+}
+
+static void _supplicant_dpp_network_id(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Network Id Signal");
+       netconfig_wifi_dpp_network_id_event(param);
+       return;
+}
+
+static void _supplicant_dpp_conf_sent(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Conf Sent Signal");
+       netconfig_wifi_dpp_conf_sent_event(param);
+       return;
+}
+
+static void _supplicant_dpp_conf_received(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Conf Received Signal");
+       netconfig_wifi_dpp_conf_received_event(param);
+       return;
+}
+
+static void _supplicant_dpp_conf_obj(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       DBG("Received DPP Conf Obj Signal");
+       netconfig_wifi_dpp_conf_obj_event(param);
+       return;
+}
+
 static void _supplicant_wifi_wps_connected(GVariant *param)
 {
        gchar *key;
@@ -781,7 +1015,7 @@ static void _supplicant_wifi_wps_connected(GVariant *param)
                if (g_strcmp0(key, "SSID") == 0) {
                        const char *t_key = NULL;
                        t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar));
-                       INFO("wps ssid_len is %d ", ssid_len);
+                       INFO("wps ssid_len is %zd ", ssid_len);
                        if (t_key == NULL) {
                                g_free(key);
                                g_variant_unref(variant);
@@ -858,6 +1092,72 @@ error:
        netconfig_wifi_notify_wps_fail_event(config_error, error_indication);
 }
 
+static void _find_service_and_set_passphrase(char *ssid, char *key)
+{
+       GString *str;
+       GVariant *reply = NULL;
+       int i, j, ssid_len;
+       char *service_path;
+       char *dev_mac_addr;
+       char ident[13];
+       gchar *enc_passphrase;
+
+       ssid_len = strlen(ssid);
+
+       str = g_string_sized_new((ssid_len * 2) + 55);
+       if (!str)
+               return;
+
+       dev_mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+       if (!dev_mac_addr) {
+               ERR("Failed to get mac address from vconf key");
+               g_string_free(str, TRUE);
+               return;
+       }
+
+       j = 0;
+       for (i = 0; dev_mac_addr[i]; i++) {
+               if (dev_mac_addr[i] != ':')
+                       ident[j++] = dev_mac_addr[i];
+       }
+       ident[j] = '\0';
+
+       g_string_append_printf(str, "%s%s_", CONNMAN_WIFI_SERVICE_PROFILE_PREFIX,
+                                                  ident);
+       free(dev_mac_addr);
+
+       for (i = 0; i < ssid_len; i++) {
+               if (ssid[i] != '"')
+                       g_string_append_printf(str, "%02x", ssid[i]);
+       }
+
+       g_string_append_printf(str, "_managed_psk");
+
+       service_path = g_string_free(str, FALSE);
+
+       enc_passphrase = _netconfig_encrypt_passphrase(key);
+       if (!enc_passphrase) {
+               ERR("Failed to encrypt passphrase");
+               g_free(service_path);
+               return;
+       }
+
+       INFO("wps service_path %s Passphrase %s", service_path, enc_passphrase);
+
+       reply = netconfig_invoke_dbus_method(CONNMAN_SERVICE, service_path,
+                                        CONNMAN_SERVICE_INTERFACE, "SetProperty",
+                                        g_variant_new("(sv)", "Passphrase",
+                                                                  g_variant_new_string(enc_passphrase)));
+       if (reply != NULL)
+               g_variant_unref(reply);
+       else
+               ERR("Failed to set passphrase");
+
+       g_free(service_path);
+
+       return;
+}
+
 static void _supplicant_wifi_wps_credentials(GVariant *param)
 {
        gchar *key;
@@ -868,6 +1168,7 @@ static void _supplicant_wifi_wps_credentials(GVariant *param)
        int config_error = 0;
        int error_indication = 0;
        gsize ssid_len = 0;
+       char *key_mgmt = NULL;
 
        if (param == NULL) {
                ERR("Param is NULL");
@@ -884,9 +1185,10 @@ static void _supplicant_wifi_wps_credentials(GVariant *param)
                        const char *t_key = NULL;
                        key_len = g_variant_get_size(variant);
 
-                       INFO("wps password len %d ", key_len);
+                       INFO("wps password len %zd ", key_len);
                        if (key_len > 0) {
-                               t_key = g_variant_get_fixed_array(variant, &key_len, sizeof(guchar));
+                               t_key = g_variant_get_fixed_array(variant, &key_len,
+                                                 sizeof(guchar));
                                if (!t_key) {
                                        g_free(key);
                                        g_variant_unref(variant);
@@ -899,8 +1201,9 @@ static void _supplicant_wifi_wps_credentials(GVariant *param)
                                SLOGI("WPS AP Security ->Open");
                } else if (g_strcmp0(key, "SSID") == 0) {
                        const char *t_key = NULL;
-                       t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar));
-                       INFO("wps ssid_len is %d ", ssid_len);
+                       t_key = g_variant_get_fixed_array(variant, &ssid_len,
+                                                 sizeof(guchar));
+                       INFO("wps ssid_len is %zd ", ssid_len);
                        if (!t_key) {
                                g_free(key);
                                g_variant_unref(variant);
@@ -913,11 +1216,42 @@ static void _supplicant_wifi_wps_credentials(GVariant *param)
                                ssid_len = 0;
                        }
                        INFO("SSID in process credentials %s", ssid);
+               } else if (g_strcmp0(key, "AuthType") == 0) {
+                       gchar *auth_type;
+                       GVariantIter *var_iter;
+                       g_variant_get(variant, "as", &var_iter);
+                       while (g_variant_iter_loop(var_iter, "s", &auth_type)) {
+                               INFO("wps auth_type %s", auth_type);
+                               if (g_strcmp0(auth_type, "wpa-psk") == 0 ||
+                                       g_strcmp0(auth_type, "wpa2-psk") == 0)
+                                       key_mgmt = "psk";
+                               else if (g_strcmp0(auth_type, "open") == 0)
+                                       key_mgmt = "none";
+                       }
+                       g_variant_iter_free(var_iter);
+               } else if (g_strcmp0(key, "EncrType") == 0) {
+                       gchar *encr_type;
+                       GVariantIter *var_iter;
+                       g_variant_get(variant, "as", &var_iter);
+                       while (g_variant_iter_loop(var_iter, "s", &encr_type))
+                               INFO("wps encr_type %s", encr_type);
+                       g_variant_iter_free(var_iter);
+               } else if (g_strcmp0(key, "BSSID") == 0) {
+                       const guchar *bssid;
+                       gsize bssid_len;
+                       bssid = g_variant_get_fixed_array(variant, &bssid_len,
+                                                               sizeof(guchar));
+                       if (bssid && bssid_len == 6)
+                               INFO("wps BSSID %2x:%2x:%2x:%2x:%2x:%2x", bssid[0], bssid[1],
+                                        bssid[2], bssid[3], bssid[4], bssid[5]);
                }
        }
 
        g_variant_iter_free(iter);
 
+       if (g_strcmp0(key_mgmt, "psk") == 0)
+               _find_service_and_set_passphrase(ssid, wps_key);
+
 #if 0
        /*
         * Notify WPS Credentials only when requested through WPS PBC
@@ -963,13 +1297,21 @@ static supplicant_signal_cb supplicant_cbs[SIG_MAX] = {
                _supplicant_session_overlapped,
                _supplicant_tdls_connected,
                _supplicant_tdls_disconnected,
-               _supplicant_tdls_peer_found
+               _supplicant_tdls_peer_found,
+               _supplicant_dpp_auth_success,
+               _supplicant_dpp_auth_failed,
+               _supplicant_dpp_not_compatible,
+               _supplicant_dpp_conf_failed,
+               _supplicant_dpp_scan_peer_qr,
+               _supplicant_dpp_network_id,
+               _supplicant_dpp_conf_sent,
+               _supplicant_dpp_conf_received,
+               _supplicant_dpp_conf_obj,
 };
 
 void register_gdbus_signal(void)
 {
        GDBusConnection *connection = NULL;
-       const char *interface = NULL;
        SuppSigArrayIndex sig;
        connection = netdbus_get_connection();
 
@@ -1008,7 +1350,7 @@ void register_gdbus_signal(void)
                        connection,
                        DBUS_SERVICE_DBUS,
                        DBUS_INTERFACE_DBUS,
-                       CONNMAN_SIGNAL_NAME_CHANGED,
+                       SIGNAL_NAME_OWNER_CHANGED,
                        NULL,
                        CONNMAN_SERVICE,
                        G_DBUS_SIGNAL_FLAGS_NONE,
@@ -1044,17 +1386,25 @@ void register_gdbus_signal(void)
 
        INFO("Successfully register Supplicant WPS DBus signal filters");
 
-       for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
-               /*
-                * For SIG_INTERFACE_REMOVED INTERFACE_ADDED
-                */
-               interface = (sig == SIG_INTERFACE_REMOVED) ?
-                               SUPPLICANT_INTERFACE : SUPPLICANT_IFACE_INTERFACE;
+       conn_subscription_ids[5] = g_dbus_connection_signal_subscribe(
+                       connection,
+                       DBUS_SERVICE_DBUS,
+                       DBUS_INTERFACE_DBUS,
+                       SIGNAL_NAME_OWNER_CHANGED,
+                       NULL,
+                       CLATD_SERVICE,
+                       G_DBUS_SIGNAL_FLAGS_NONE,
+                       _dbus_name_changed_cb,
+                       NULL,
+                       NULL);
 
+       INFO("Successfully register clat DBus signal filters");
+
+       for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) {
                supp_subscription_ids[sig] = g_dbus_connection_signal_subscribe(
                                connection,
                                SUPPLICANT_SERVICE,
-                               interface,
+                               supplicant_iface_for_sig[sig],
                                supplicant_signals[sig],
                                NULL,
                                NULL,