Add logic for Device Provisioning Protocol(DPP)
[platform/core/connectivity/net-config.git] / src / signal-handler.c
index 99620b8..93373ff 100755 (executable)
@@ -39,6 +39,7 @@
 #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"
 #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"
@@ -82,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;
 
@@ -96,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};
@@ -862,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;
@@ -1167,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();
 
@@ -1263,16 +1401,10 @@ void register_gdbus_signal(void)
        INFO("Successfully register clat 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;
-
                supp_subscription_ids[sig] = g_dbus_connection_signal_subscribe(
                                connection,
                                SUPPLICANT_SERVICE,
-                               interface,
+                               supplicant_iface_for_sig[sig],
                                supplicant_signals[sig],
                                NULL,
                                NULL,