Merge "Using updated clatd's Dbus interface and Path values" into tizen
authorJaehyun Kim <jeik01.kim@samsung.com>
Mon, 14 Oct 2019 07:22:37 +0000 (07:22 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Mon, 14 Oct 2019 07:22:37 +0000 (07:22 +0000)
18 files changed:
CMakeLists.txt
include/netsupplicant.h
include/util.h
include/wifi-config.h
include/wifi-dpp.h [new file with mode: 0644]
include/wifi-indicator.h
include/wifi-key-encryption.h
interfaces/netconfig-iface-wifi.xml
resources/etc/dbus-1/system.d/net-config.conf
src/dbus/netsupplicant.c
src/signal-handler.c
src/utils/util.c
src/wifi-config.c
src/wifi-dpp.c [new file with mode: 0644]
src/wifi-indicator.c
src/wifi-key-encryption.c
src/wifi-tdls.c
src/wifi.c

index 71d17c9..8abfbac 100755 (executable)
@@ -45,6 +45,7 @@ SET(SRCS
        src/wifi-extension.c
        src/ip-conflict-detect.c
        src/clatd-handler.c
+       src/wifi-dpp.c
        )
 
 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
index 67ea9ba..d64da19 100755 (executable)
@@ -27,12 +27,15 @@ extern "C" {
 #endif
 
 #define         WIFI_IFNAME                                    "wlan0"
+/* Adhoc solution to use P2P interface */
+#define         WIFI_P2P_IFNAME                                "p2p0"
 
 #define SUPPLICANT_SERVICE                             "fi.w1.wpa_supplicant1"
 #define SUPPLICANT_INTERFACE                   "fi.w1.wpa_supplicant1"
 #define SUPPLICANT_IFACE_INTERFACE             SUPPLICANT_INTERFACE ".Interface"
 #define SUPPLICANT_IFACE_BSS                   SUPPLICANT_INTERFACE ".BSS"
 #define SUPPLICANT_IFACE_WPS                   SUPPLICANT_INTERFACE ".Interface.WPS"
+#define SUPPLICANT_IFACE_DPP                   SUPPLICANT_INTERFACE ".Interface.DPP"
 #define SUPPLICANT_PATH                                        "/fi/w1/wpa_supplicant1"
 
 struct dbus_input_arguments {
@@ -43,6 +46,8 @@ struct dbus_input_arguments {
 /* Returns Supplicant interface.
  * Need to release interface using g_free */
 char *netconfig_wifi_get_supplicant_interface(void);
+/* Adhoc solution to use P2P interface */
+char *netconfig_wifi_get_supplicant_p2p_interface(void);
 
 GList *setup_input_args(GList *list, struct dbus_input_arguments *items);
 GVariant *netconfig_supplicant_invoke_dbus_method(const char *dest, const char *path,
index 6e9b936..18ad640 100755 (executable)
@@ -96,6 +96,9 @@ int netconfig_vconf_get_int(const char * key, int *value);
 int netconfig_vconf_get_bool(const char * key, int *value);
 char* netconfig_get_env(const char *key);
 void netconfig_set_mac_address_from_file(void);
+char *netconfig_get_mac_address_from_file(const char *ifname);
+int netconfig_freq_to_channel(int freq);
+int netconfig_get_operating_class(int freq);
 void __netconfig_pop_wifi_connected_poppup(const char *ssid);
 
 void netconfig_get_telephony_network_type(int *svctype, int *pstype);
@@ -115,6 +118,8 @@ void netconfig_plugin_deinit();
 gboolean netconfig_get_headed_plugin_flag();
 gboolean netconfig_get_telephony_plugin_flag();
 
+void netconfig_convert_bytes_to_hexstr(const char* bin, int blen, gchar* hexstr);
+
 #ifdef __cplusplus
 }
 #endif
index 97f2740..b0a8f30 100755 (executable)
@@ -72,6 +72,8 @@ typedef enum {
 
 gboolean       wifi_config_get_config_id(const gchar *service_profile, gchar **config_id);
 gboolean       wifi_config_remove_configuration(const gchar *config_id);
+gboolean       wifi_config_save_configuration(const gchar *config_id, GKeyFile *keyfile);
+gboolean       wifi_config_get_group_name(const gchar *prefix, const gchar *config_id, gchar **group_name);
 int __netconfig_hex_str_to_bin(const char *hex, unsigned char *buf, size_t len);
 int __netconfig_hex_to_byte(const char *hex);
 int __netconfig_hex_char_to_num(char c);
diff --git a/include/wifi-dpp.h b/include/wifi-dpp.h
new file mode 100644 (file)
index 0000000..21fd355
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __NETCONFIG_WIFI_DPP_H__
+#define __NETCONFIG_WIFI_DPP_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "wifi.h"
+
+void netconfig_wifi_dpp_auth_success_event(GVariant *message);
+void netconfig_wifi_dpp_auth_failed_event(GVariant *message);
+void netconfig_wifi_dpp_not_compatible_event(GVariant *message);
+void netconfig_wifi_dpp_conf_failed_event(GVariant *message);
+void netconfig_wifi_dpp_scan_peer_qr_event(GVariant *message);
+void netconfig_wifi_dpp_network_id_event(GVariant *message);
+void netconfig_wifi_dpp_conf_sent_event(GVariant *message);
+void netconfig_wifi_dpp_conf_received_event(GVariant *message);
+void netconfig_wifi_dpp_conf_obj_event(GVariant *message);
+
+gboolean handle_dpp_enter_peer_uri(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info);
+gboolean handle_dpp_generate_uri(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info);
+gboolean handle_dpp_start_configurator_initiator(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info);
+gboolean handle_dpp_start_enrollee_initiator(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info);
+gboolean handle_dpp_start_configurator_responder(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info);
+gboolean handle_dpp_start_enrollee_responder(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info);
+gboolean handle_dpp_stop(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_WPS_H__ */
index 8bbbd06..46e13e2 100755 (executable)
@@ -25,6 +25,7 @@ extern "C" {
 #endif
 
 int netconfig_wifi_get_rssi(void);
+unsigned int netconfig_wifi_get_freq(void);
 int netconfig_wifi_rssi_level(const int rssi_dbm);
 
 void netconfig_wifi_indicator_start(void);
index 8c20687..3b60483 100755 (executable)
@@ -28,6 +28,10 @@ extern "C" {
 
 gboolean handle_encrypt_passphrase(Wifi *wifi, GDBusMethodInvocation *context, const gchar *passphrase);
 gboolean handle_decrypt_passphrase(Wifi *wifi, GDBusMethodInvocation *context, const gchar *enc_data);
+gboolean handle_decrypt_conf_obj(Wifi *wifi, GDBusMethodInvocation *context,
+               const gchar *enc_connector,
+               const gchar *enc_c_sign_key,
+               const gchar *enc_net_access_key);
 gchar* _netconfig_encrypt_passphrase(const gchar *passphrase);
 
 #ifdef __cplusplus
index 92f7170..75ed86b 100755 (executable)
                        <arg type="s" name="enc_data" direction="in"/>
                        <arg type="s" name="passphrase" direction="out"/>
                </method>
+               <method name="DecryptConfObj">
+                       <arg type="s" name="enc_connector" direction="in"/>
+                       <arg type="s" name="enc_c_sign_key" direction="in"/>
+                       <arg type="s" name="enc_net_access_key" direction="in"/>
+                       <arg type="a{sv}" name="dec_data" direction="out"/>
+               </method>
+
+               <method name="DppEnterPeerUri">
+                       <arg type="a{sv}" name="dpp_info" direction="in"/>
+               </method>
+               <method name="DppGenerateUri">
+                       <arg type="a{sv}" name="dpp_info" direction="in"/>
+               </method>
+               <method name="DppStartConfiguratorInitiator">
+                       <arg type="a{sv}" name="dpp_info" direction="in"/>
+               </method>
+               <method name="DppStartEnrolleeInitiator">
+                       <arg type="a{sv}" name="dpp_info" direction="in"/>
+               </method>
+               <method name="DppStartConfiguratorResponder">
+                       <arg type="a{sv}" name="dpp_info" direction="in"/>
+               </method>
+               <method name="DppStartEnrolleeResponder">
+                       <arg type="a{sv}" name="dpp_info" direction="in"/>
+               </method>
+               <method name="DppStop">
+                       <arg type="a{sv}" name="dpp_info" direction="in"/>
+               </method>
+
                <signal name="PowerOnCompleted"></signal>
                <signal name="PowerOffCompleted"></signal>
                <signal name="PowerOperationFailed"></signal>
                <signal name="IpConflictEvent">
                        <arg type="a{sv}" name="Fields" direction="out"/>
                </signal>
+               <signal name="DppUriGenerated">
+                       <arg type="a{sv}" name="Fields" direction="out"/>
+               </signal>
+               <signal name="DppBootstrapped">
+                       <arg type="a{sv}" name="Fields" direction="out"/>
+               </signal>
+               <signal name="DppAwaiting">
+                       <arg type="a{sv}" name="Fields" direction="out"/>
+               </signal>
+               <signal name="DppAuthenticating">
+                       <arg type="a{sv}" name="Fields" direction="out"/>
+               </signal>
+               <signal name="DppAuthSuccess">
+                       <arg type="a{sv}" name="Fields" direction="out"/>
+               </signal>
+               <signal name="DppAuthFailed">
+                       <arg type="a{sv}" name="Fields" direction="out"/>
+               </signal>
+               <signal name="DppNotCompatible">
+                       <arg type="a{sv}" name="Fields" direction="out"/>
+               </signal>
+               <signal name="DppConfFailed">
+                       <arg type="a{sv}" name="Fields" direction="out"/>
+               </signal>
+               <signal name="DppScanPeerQr">
+                       <arg type="a{sv}" name="Fields" direction="out"/>
+               </signal>
+               <signal name="DppNetworkID">
+                       <arg type="a{sv}" name="Fields" direction="out"/>
+               </signal>
+               <signal name="DppConfSent">
+                       <arg type="a{sv}" name="Fields" direction="out"/>
+               </signal>
+               <signal name="DppConfReceived">
+                       <arg type="a{sv}" name="Fields" direction="out"/>
+               </signal>
+               <signal name="DppFailed">
+               </signal>
+               <signal name="DppRemoved">
+                       <arg type="a{sv}" name="Fields" direction="out"/>
+               </signal>
        </interface>
        <interface name="net.connman.Agent">
                <method name="SetField">
index caee724..d126725 100755 (executable)
                <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="AddVsie" privilege="http://tizen.org/privilege/network.set" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="GetVsie" privilege="http://tizen.org/privilege/network.get" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="RemoveVsie" privilege="http://tizen.org/privilege/network.set" />
+               <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="DppEnterPeerUri" privilege="http://tizen.org/privilege/network.set" />
+               <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="DppGenerateUri" privilege="http://tizen.org/privilege/network.set" />
+               <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="DppStartConfiguratorInitiator" privilege="http://tizen.org/privilege/network.set" />
+               <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="DppStartEnrolleeInitiator" privilege="http://tizen.org/privilege/network.set" />
+               <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="DppStartConfiguratorResponder" privilege="http://tizen.org/privilege/network.set" />
+               <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="DppStartEnrolleeResponder" privilege="http://tizen.org/privilege/network.set" />
+               <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="DppStop" privilege="http://tizen.org/privilege/network.set" />
 
                <check send_destination="net.netconfig" send_interface="net.connman.Agent" send_member="SetField" privilege="http://tizen.org/privilege/network.profile" />
 
index f31e19e..e422128 100755 (executable)
@@ -45,6 +45,27 @@ char *netconfig_wifi_get_supplicant_interface(void)
        return (char *)path;
 }
 
+char *netconfig_wifi_get_supplicant_p2p_interface(void)
+{
+       GVariant *message = NULL;
+       gchar *path = NULL;
+
+       message = netconfig_supplicant_invoke_dbus_method(
+                       SUPPLICANT_SERVICE, SUPPLICANT_PATH,
+                       SUPPLICANT_INTERFACE, "GetP2PInterface", NULL);
+
+       if (message == NULL) {
+               ERR("Failed to get object path");
+               return NULL;
+       }
+
+       g_variant_get(message, "(o)", &path);
+
+       g_variant_unref(message);
+
+       return (char *)path;
+}
+
 GVariant *netconfig_supplicant_invoke_dbus_method(const char *dest, const char *path,
                const char *interface_name, const char *method, GVariant *params)
 {
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,
index 996b2e7..dc31b6d 100755 (executable)
@@ -30,6 +30,7 @@
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+#include <linux/limits.h>
 #include <ctype.h>
 #include <vconf-keys.h>
 #include <tzplatform_config.h>
@@ -1249,6 +1250,85 @@ void netconfig_set_mac_address_from_file(void)
        fclose(file);
 }
 
+char *netconfig_get_mac_address_from_file(const char *ifname)
+{
+       FILE *file = NULL;
+       char file_path[PATH_MAX] = {0, };
+       char mac_str[MAC_ADDRESS_MAX_LEN];
+       int mac_len = 0;
+
+       if (!ifname)
+               return NULL;
+
+       g_snprintf(file_path, sizeof(file_path),
+                       "/sys/class/net/%s/address", ifname);
+
+       DBG("ifname: %s", ifname);
+       DBG("file_path: %s", file_path);
+       file = fopen(file_path, "r");
+       if (file == NULL) {
+               ERR("Fail to open %s", file_path);
+               return NULL;
+       }
+       if (fgets(mac_str, sizeof(mac_str), file) == NULL) {
+               ERR("Fail to read mac address");
+               fclose(file);
+               return NULL;
+       }
+
+       mac_len = strlen(mac_str);
+       if (mac_len < 17) {
+               ERR("mac is empty");
+               fclose(file);
+               return NULL;
+       }
+       DBG("address: %s", mac_str);
+
+       fclose(file);
+       return g_strdup(mac_str);
+}
+
+int netconfig_freq_to_channel(int freq)
+{
+       if (freq < 2412 || freq > 5825 ||
+               (freq > 2484 && freq < 5180)) {
+               ERR("Invalid Frequence Range");
+               return 0;
+       }
+       if (freq >= 5180)
+               return 36 + (freq - 5180)/5;
+       else if (freq <= 2472)
+               return 1 + (freq - 2412)/5;
+       else if (freq == 2484)
+               return 14;
+       else
+               return 0;
+}
+
+int netconfig_get_operating_class(int freq)
+{
+       int channel = 0;
+       int oper_class = 0;
+
+       channel = netconfig_freq_to_channel(freq);
+
+       if (channel) {
+               /* Operating class 81 - 2.4 GHz band channels 1..13 */
+               if (channel >= 1 && channel <= 13)
+                       oper_class = 81;
+               /* Operating class 115 - 5 GHz, channels 36-48 */
+               else if (channel >= 36 && channel <= 48)
+                       oper_class = 115;
+               /* Operating class 124 - 5 GHz, channels 149,153,157,161 */
+               else
+                       oper_class = 124;
+
+               INFO("Operating Class  is [%d]", oper_class);
+               return oper_class;
+       }
+       return 0;
+}
+
 tizen_profile_t _get_tizen_profile()
 {
        static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
@@ -1365,3 +1445,32 @@ bool netconfig_check_feature_supported(netconfig_supported_feature_e feature)
        }
        return feature_supported[feature];
 }
+
+void netconfig_convert_bytes_to_hexstr(const char *bin, int blen, gchar* hexstr)
+{
+       char t;
+
+       while (blen) {
+               t = (*bin >> 4) & 0x0f;
+
+               if (t <= 9)
+                       *hexstr = t + '0';
+               else if (t >= 10 && t <= 16)
+                       *hexstr = (t - 10) + 'a';
+
+               hexstr++;
+
+               t = *bin & 0x0f;
+
+               if (t <= 9)
+                       *hexstr = t + '0';
+               else if (t >= 10 && t <= 16)
+                       *hexstr = (t - 10) + 'a';
+
+               hexstr++;
+               bin++;
+               blen--;
+       }
+
+       *hexstr = '\0';
+}
index 5c5082b..48b898d 100755 (executable)
@@ -193,7 +193,7 @@ static gboolean __get_mac_address(gchar **mac_address)
        return TRUE;
 }
 
-static gboolean __get_group_name(const gchar *prefix, const gchar *config_id, gchar **group_name)
+gboolean wifi_config_get_group_name(const gchar *prefix, const gchar *config_id, gchar **group_name)
 {
        gchar *mac_address = NULL;
        gchar *g_name = NULL;
@@ -312,7 +312,7 @@ static gboolean _load_configuration(const gchar *config_id, struct wifi_config *
        gboolean hidden = FALSE;
        gboolean ret = FALSE;
 
-       ret = __get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+       ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
        if (ret != TRUE) {
                ERR("Fail to get_wifi_config_group_name");
                return FALSE;
@@ -453,14 +453,14 @@ static gboolean _load_configuration(const gchar *config_id, struct wifi_config *
        return TRUE;
 }
 
-static gboolean _save_configuration(const gchar *config_id, GKeyFile *keyfile)
+gboolean wifi_config_save_configuration(const gchar *config_id, GKeyFile *keyfile)
 {
        gchar *dir;
        gchar *path;
        gchar *group_name;
        gboolean ret = FALSE;
 
-       ret = __get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+       ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
        if (ret != TRUE) {
                ERR("Fail to get_wifi_config_group_name");
                return FALSE;
@@ -498,7 +498,7 @@ static gboolean _remove_configuration(const gchar *config_id)
        gchar *dir;
        gchar *group_name;
 
-       ret = __get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+       ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
        if (ret != TRUE) {
                ERR("Fail to get_wifi_config_group_name");
                return FALSE;
@@ -530,7 +530,7 @@ static gboolean _set_field(const gchar *config_id, const gchar *key, const gchar
        GKeyFile *keyfile;
        gchar *group_name;
 
-       ret = __get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+       ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
        if (ret != TRUE) {
                ERR("Fail to get_wifi_config_group_name");
                return FALSE;
@@ -574,7 +574,7 @@ static gboolean _set_field(const gchar *config_id, const gchar *key, const gchar
                ret = FALSE;
        }
 
-       _save_configuration(config_id, keyfile);
+       wifi_config_save_configuration(config_id, keyfile);
 
        g_key_file_free(keyfile);
        g_free(group_name);
@@ -590,7 +590,7 @@ static gboolean _get_field(const gchar *config_id, const gchar *key, gchar **val
        gboolean hidden = FALSE;
        gboolean ret = FALSE;
 
-       ret = __get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+       ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
        if (ret != TRUE) {
                ERR("Fail to get_wifi_config_group_name");
                return FALSE;
@@ -1267,7 +1267,7 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
        conf->favorite = TRUE;
        conf->autoconnect = TRUE;
 
-       ret = __get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+       ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
        if (ret != TRUE) {
                __free_wifi_configuration(conf);
                ERR("Fail to get_wifi_config_group_name");
@@ -1351,7 +1351,7 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
                i += 1;
        }
 
-       ret = _save_configuration(config_id, keyfile);
+       ret = wifi_config_save_configuration(config_id, keyfile);
        if (ret == TRUE) {
                INFO("Success to save configuration [%s]", config_id);
                wifi_complete_save_configuration(wifi, context);
@@ -1592,7 +1592,7 @@ gboolean handle_save_eap_configuration(Wifi *wifi, GDBusMethodInvocation *contex
        conf->favorite = TRUE;
        conf->autoconnect = TRUE;
 
-       ret = __get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
+       ret = wifi_config_get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
        if (ret != TRUE) {
                __free_wifi_configuration(conf);
                ERR("Fail to get_wifi_config_group_name");
@@ -1672,7 +1672,7 @@ gboolean handle_save_eap_configuration(Wifi *wifi, GDBusMethodInvocation *contex
                g_key_file_set_string(keyfile, group_name,
                        WIFI_CONFIG_EAP_SUBJECT_MATCH, conf->eap_config->subject_match);
 
-       ret = _save_configuration(config_id, keyfile);
+       ret = wifi_config_save_configuration(config_id, keyfile);
        if (ret == TRUE) {
                INFO("Success to save eap configuration [%s]", config_id);
                wifi_complete_save_eap_configuration(wifi, context);
diff --git a/src/wifi-dpp.c b/src/wifi-dpp.c
new file mode 100644 (file)
index 0000000..5d70239
--- /dev/null
@@ -0,0 +1,1990 @@
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <string.h>
+#include <glib.h>
+
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include "log.h"
+#include "util.h"
+#include "netdbus.h"
+#include "netsupplicant.h"
+#include "neterror.h"
+#include "wifi-config.h"
+#include "wifi-dpp.h"
+#include "wifi-key-encryption.h"
+
+#define DEFAULT_BOOTSTRAP_TYPE "qrcode"
+#define DEFAULT_DPP_CHANNEL "81/6"
+#define DEFAULT_DPP_FREQ 2437
+
+#define DEFAULT_DPP_CONFIG_PROCESSING_TYPE "0"
+
+#define MACADDR_LEN 6
+#define MACSTR_LEN 18
+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+
+typedef enum {
+       WIFI_DPP_AKM_UNKNOWN,
+       WIFI_DPP_AKM_PSK,
+       WIFI_DPP_AKM_SAE,
+       WIFI_DPP_AKM_DPP,
+} wifi_dpp_akm_e;
+
+typedef enum {
+       WIFI_DPP_STATE_NONE,
+       WIFI_DPP_STATE_AWAITING,
+       WIFI_DPP_STATE_PEER_QR_REQUESTED,
+       WIFI_DPP_STATE_BOOTSTRAPPED,
+       WIFI_DPP_STATE_AUTHENTICATING,
+       WIFI_DPP_STATE_AUTHENTICATED,
+       WIFI_DPP_STATE_CONFIGURED,
+       WIFI_DPP_STATE_CONNECTING,
+       WIFI_DPP_STATE_CONNECTED,
+} wifi_dpp_state_e;
+
+typedef struct {
+       gchar *ssid;
+       gchar *akm;
+       gchar *passphrase;
+       gchar *connector;
+       gchar *c_sign_key;
+       gchar *net_access_key;
+} wifi_dpp_conf_obj;
+
+typedef struct {
+       guint32 peer_id;
+       guint32 own_id;
+       guint32 configurator_id;
+       gboolean is_initiator;
+       wifi_dpp_state_e state;
+} wifi_dpp_s;
+
+gboolean g_in_progress = FALSE;
+static GSList *dpp_info_list = NULL;
+
+static wifi_dpp_s *_get_dpp_info(guint32 peer_id, guint32 own_id)
+{
+       wifi_dpp_s *ret = NULL;
+       GSList *list = NULL;
+
+       for (list = dpp_info_list; list; list = list->next) {
+               ret = list->data;
+               if (ret->own_id == own_id && ret->peer_id == peer_id)
+                       break;
+               ret = NULL;
+       }
+       return ret;
+}
+
+static wifi_dpp_s *_get_dpp_in_progress()
+{
+       wifi_dpp_s *ret = NULL;
+       GSList *list = NULL;
+
+       for (list = dpp_info_list; list; list = list->next) {
+               ret = list->data;
+               if (ret->state > WIFI_DPP_STATE_NONE)
+                       break;
+               ret = NULL;
+       }
+       return ret;
+}
+
+static wifi_dpp_s *__create_dpp_info(gboolean is_initiator)
+{
+       wifi_dpp_s *ret = g_try_malloc0(sizeof(wifi_dpp_s));
+       if (ret)
+               ret->is_initiator = is_initiator;
+
+       return ret;
+}
+
+static void __add_to_dpp_info_list(wifi_dpp_s * p_dpp)
+{
+       dpp_info_list = g_slist_prepend(dpp_info_list, p_dpp);
+}
+
+static void __remove_from_dpp_info_list(wifi_dpp_s * p_dpp)
+{
+       dpp_info_list = g_slist_remove(dpp_info_list, p_dpp);
+}
+
+static void __destroy_dpp_info(wifi_dpp_s *p_dpp)
+{
+       g_free(p_dpp);
+}
+
+
+static void __free_critical(char *critical)
+{
+       size_t length = 0;
+       if (!critical)
+               return;
+
+       length = strlen(critical);
+       memset((void *)critical, 0x0, length);
+       g_free(critical);
+}
+
+static void __netconfig_wifi_notify_dpp_uri_generated(guint32 own_id, const gchar *own_uri)
+{
+       GVariantBuilder *builder = NULL;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "own_id", g_variant_new_uint32(own_id));
+       g_variant_builder_add(builder, "{sv}", "own_uri", g_variant_new_string(own_uri));
+
+       wifi_emit_dpp_uri_generated((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       return;
+}
+
+static void __netconfig_wifi_notify_dpp_bootstrapped(guint32 peer_id)
+{
+       GVariantBuilder *builder = NULL;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "peer_id", g_variant_new_uint32(peer_id));
+
+       wifi_emit_dpp_bootstrapped((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       return;
+}
+
+static void __netconfig_wifi_notify_dpp_awaiting(guint32 own_id)
+{
+       GVariantBuilder *builder = NULL;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "own_id", g_variant_new_uint32(own_id));
+
+       wifi_emit_dpp_awaiting((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       return;
+}
+
+static void __netconfig_wifi_notify_dpp_authenticating(guint32 peer_id, guint32 own_id)
+{
+       GVariantBuilder *builder = NULL;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "peer_id", g_variant_new_uint32(peer_id));
+       g_variant_builder_add(builder, "{sv}", "own_id", g_variant_new_uint32(own_id));
+
+       wifi_emit_dpp_authenticating((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       return;
+}
+
+static void __netconfig_wifi_notify_dpp_failed()
+{
+       wifi_emit_dpp_failed((Wifi *)get_wifi_object());
+
+       return;
+}
+
+static void __netconfig_wifi_notify_dpp_removed(guint32 peer_id, guint32 own_id)
+{
+       GVariantBuilder *builder = NULL;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "peer_id", g_variant_new_uint32(peer_id));
+       g_variant_builder_add(builder, "{sv}", "own_id", g_variant_new_uint32(own_id));
+
+       wifi_emit_dpp_removed((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       return;
+}
+
+static char *__netconfig_dpp_get_supplicant_interface()
+{
+       char *if_path = NULL;
+
+       if_path = netconfig_wifi_get_supplicant_p2p_interface();
+       if (if_path)
+               return if_path;
+
+       if_path = netconfig_wifi_get_supplicant_interface();
+
+       return if_path;
+}
+
+static gboolean __netconfig_wifi_invoke_dpp_set_dpp_config_processing()
+{
+       char *if_path = NULL;
+       GVariant *message = NULL;
+       GVariant *params = NULL;
+
+       DBG("[TizenMW-->WPAS]: DPP Set config processing Request: ");
+
+       if_path = __netconfig_dpp_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus interface path");
+               return FALSE;
+       }
+
+       params = g_variant_new("(ssv)", SUPPLICANT_INTERFACE ".Interface",
+                       "DppConfigProcessing", g_variant_new_string(DEFAULT_DPP_CONFIG_PROCESSING_TYPE));
+
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path, DBUS_INTERFACE_PROPERTIES, "Set", params);
+       g_free(if_path);
+       if (message == NULL) {
+               ERR(" DPP : Failed to set DPP config processing !!!");
+               return FALSE;
+       }
+
+       g_variant_unref(message);
+       return TRUE;
+}
+
+static gboolean __netconfig_wifi_invoke_dpp_qr_code(const char *peer_uri, guint32 *peer_id)
+{
+       char *if_path = NULL;
+       GVariant *message = NULL;
+       GVariant *params = NULL;
+
+       DBG("[TizenMW-->WPAS]: DPP QrCode Request: ");
+
+       if_path = __netconfig_dpp_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus interface path");
+               return FALSE;
+       }
+
+       params = g_variant_new("(s)", peer_uri);
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path, SUPPLICANT_INTERFACE ".Interface.DPP", "QrCode", params);
+       g_free(if_path);
+       if (message == NULL) {
+               ERR(" DPP : Failed to set peer URI !!!");
+               return FALSE;
+       }
+
+       g_variant_get(message, "(u)", peer_id);
+       INFO("DPP reply: [%u]", *peer_id);
+
+       g_variant_unref(message);
+       return TRUE;
+}
+#define DEBUG_G_VARIANT(str, parameters)\
+       do {\
+               gchar *parameters_debug_str = NULL;\
+               if (parameters)\
+                       parameters_debug_str = g_variant_print(parameters, TRUE);\
+                       DBG("%s[%s]", str, parameters_debug_str ? parameters_debug_str : "NULL");\
+               g_free(parameters_debug_str);\
+       } while (0)
+
+
+static int __ws_unpack_ay(unsigned char *dst, GVariant *src, int size)
+{
+       GVariantIter *iter = NULL;
+       int length = 0;
+
+       if (!dst || !src || size == 0) {
+               DBG("Invalid parameter");
+               return -1;
+       }
+       g_variant_get(src, "ay", &iter);
+       if (iter == NULL) {
+               DBG("failed to get iterator");
+               return -1;
+       }
+
+       while (g_variant_iter_loop(iter, "y", &dst[length])) {
+               length++;
+               if (length >= size)
+                       break;
+       }
+       g_variant_iter_free(iter);
+
+       return length;
+}
+
+static gchar *__netconfig_get_p2p_address(const char *if_path)
+{
+       GVariant *params = NULL;
+       GVariant *message = NULL;
+       GVariant *temp1 = NULL;
+       GVariant *temp2 = NULL;
+       guchar p2p_addr[MACADDR_LEN] = {0,};
+       gchar address_str[MACSTR_LEN] = {0,};
+
+       params = g_variant_new("(ss)", SUPPLICANT_INTERFACE ".Interface", "P2PAddress");
+
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path,
+                       DBUS_INTERFACE_PROPERTIES,
+                       "Get",
+                       params);
+
+       if (message == NULL) {
+               ERR("netconfig_supplicant_invoke_dbus_method() failed.");
+               return NULL;
+       }
+       DEBUG_G_VARIANT("reply:", message);
+
+       temp1 = g_variant_get_child_value(message, 0);
+       temp2 = g_variant_get_child_value(temp1, 0);
+       DEBUG_G_VARIANT("temp2:", temp2);
+       __ws_unpack_ay(p2p_addr, temp2, MACADDR_LEN);
+       g_variant_unref(temp1);
+       g_variant_unref(temp2);
+
+       g_snprintf(address_str, MACSTR_LEN, MACSTR, MAC2STR(p2p_addr));
+
+       DBG("P2P address %s", address_str);
+
+       return g_strdup(address_str);
+}
+
+static gboolean __netconfig_wifi_invoke_dpp_add_bootstrap(const char *key, guint32 *id)
+{
+       char *if_path = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariant *params = NULL;
+       GVariant *message = NULL;
+       gchar *current_mac_addr = NULL;
+
+       DBG("[TizenMW-->WPAS]: DPP AddBootstrap Request: ");
+
+       if_path = __netconfig_dpp_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus interface path");
+               return FALSE;
+       }
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "type", g_variant_new_string("qrcode"));
+       g_variant_builder_add(builder, "{sv}", "channels", g_variant_new_string(DEFAULT_DPP_CHANNEL));
+       /* TODO: find more comfortable way */
+       current_mac_addr = __netconfig_get_p2p_address(if_path);
+       if (current_mac_addr)
+               g_variant_builder_add(builder, "{sv}", "mac", g_variant_new_string(current_mac_addr));
+       if (key)
+               g_variant_builder_add(builder, "{sv}", "key", g_variant_new_string(key));
+       params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path, SUPPLICANT_INTERFACE ".Interface.DPP", "AddBootstrap", params);
+       g_free(if_path);
+       g_free(current_mac_addr);
+       if (message == NULL) {
+               ERR(" DPP : Failed to add bootstrap !!!");
+               return FALSE;
+       }
+
+       g_variant_get(message, "(u)", id);
+       INFO("DPP reply: [%u]", *id);
+
+       g_variant_unref(message);
+       return TRUE;
+}
+
+static gboolean __netconfig_wifi_invoke_dpp_get_bootstrap_uri(guint32 id, gchar **uri)
+{
+       char *if_path = NULL;
+       GVariant *message = NULL;
+       GVariant *params = NULL;
+
+       if (id == 0) {
+               DBG("Invalid ID");
+               return FALSE;
+       }
+
+       DBG("[TizenMW-->WPAS]: DPP GetBootstrapUri Request: ");
+
+       if_path = __netconfig_dpp_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus interface path");
+               return FALSE;
+       }
+
+       params = g_variant_new("(u)", id);
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path, SUPPLICANT_INTERFACE ".Interface.DPP", "GetBootstrapUri", params);
+       g_free(if_path);
+       if (message == NULL) {
+               ERR(" DPP : Failed to get URI !!!");
+               return FALSE;
+       }
+
+       g_variant_get(message, "(s)", uri);
+       INFO("DPP reply: [%s]", *uri);
+
+       g_variant_unref(message);
+       return TRUE;
+}
+
+static gboolean __netconfig_wifi_invoke_dpp_add_configurator(const char *key, guint32 *id)
+{
+       char *if_path = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariant *params = NULL;
+       GVariant *message = NULL;
+
+       DBG("[TizenMW-->WPAS]: DPP AddConfigurator Request: ");
+
+       if_path = __netconfig_dpp_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus interface path");
+               return FALSE;
+       }
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       if (key)
+               g_variant_builder_add(builder, "{sv}", "key", g_variant_new_string(key));
+       params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path, SUPPLICANT_INTERFACE ".Interface.DPP", "AddConfigurator", params);
+       g_free(if_path);
+       if (message == NULL) {
+               ERR(" DPP : Failed to add configurator !!!");
+               return FALSE;
+       }
+
+       g_variant_get(message, "(u)", id);
+       INFO("DPP reply: [%u]", *id);
+
+       g_variant_unref(message);
+       return TRUE;
+}
+
+static gchar *__generate_configurator_params(guint32 configurator_id, const char *ssid,
+               const char *net_role, const char *akm, const char *pass)
+{
+       gchar ssid_hex[65] = {0,};
+       gchar pass_hex[129] = {0,};
+       gchar *ret = NULL;
+
+       gchar *conf_str = NULL;
+
+       netconfig_convert_bytes_to_hexstr(ssid, strlen(ssid), ssid_hex);
+       conf_str = g_strdup_printf(" ssid=%s conf=%s-%s", ssid_hex, net_role, akm);
+
+       if (pass) {
+               netconfig_convert_bytes_to_hexstr(pass, strlen(pass), pass_hex);
+               ret = g_strdup_printf("%s pass=%s", conf_str, pass_hex);
+       } else {
+               ret = g_strdup_printf(" configurator=%u%s", configurator_id, conf_str);
+       }
+       g_free(conf_str);
+
+       return ret;
+}
+
+static gboolean __netconfig_wifi_invoke_dpp_set_configurator_params(guint configurator_id,
+               const char *ssid, const char *net_role, const char *akm, const char *pass)
+{
+       char *if_path = NULL;
+       GVariant *message = NULL;
+       GVariant *params = NULL;
+       gchar *configurator_param_str = NULL;
+
+       DBG("[TizenMW-->WPAS]: DPP Set configurator params Request: ");
+
+       if_path = __netconfig_dpp_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus interface path");
+               return FALSE;
+       }
+
+       configurator_param_str = __generate_configurator_params(
+                       configurator_id, ssid, net_role, akm, pass);
+       if (!configurator_param_str) {
+               ERR(" DPP : Failed to gen conf params");
+               g_free(if_path);
+               return FALSE;
+       }
+       params = g_variant_new("(ssv)", SUPPLICANT_INTERFACE ".Interface",
+                       "DPPConfiguratorParams", g_variant_new_string(configurator_param_str));
+
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path, DBUS_INTERFACE_PROPERTIES, "Set", params);
+       g_free(if_path);
+       g_free(configurator_param_str);
+       if (message == NULL) {
+               ERR(" DPP : Failed to set configurator params !!!");
+               return FALSE;
+       }
+
+       g_variant_unref(message);
+       return TRUE;
+}
+
+static gboolean __netconfig_wifi_invoke_dpp_listen(guint32 freq, const gchar *dev_role)
+{
+       char *if_path = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariant *params = NULL;
+       GVariant *message = NULL;
+
+       DBG("[TizenMW-->WPAS]: DPP Listen Request: ");
+
+       if_path = __netconfig_dpp_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus interface path");
+               return FALSE;
+       }
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "freq", g_variant_new_uint32(freq));
+       g_variant_builder_add(builder, "{sv}", "role", g_variant_new_string(dev_role));
+       params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path, SUPPLICANT_INTERFACE ".Interface.DPP", "Listen", params);
+       g_free(if_path);
+       if (message == NULL) {
+               ERR(" DPP : Failed to start DPP listen !!!");
+               return FALSE;
+       }
+
+       g_variant_unref(message);
+       return TRUE;
+}
+
+static gboolean __netconfig_wifi_invoke_auth_init_enrollee(guint32 peer_id)
+{
+       char *if_path = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariant *params = NULL;
+       GVariant *message = NULL;
+
+       DBG("[TizenMW-->WPAS]: DPP AuthInit Request: ");
+
+       if_path = __netconfig_dpp_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus interface path");
+               return FALSE;
+       }
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "peer", g_variant_new_uint32(peer_id));
+       g_variant_builder_add(builder, "{sv}", "role", g_variant_new_string("enrollee"));
+       params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path, SUPPLICANT_INTERFACE ".Interface.DPP", "AuthInit", params);
+       g_free(if_path);
+       if (message == NULL) {
+               ERR(" DPP : Failed to start DPP AuthInit !!!");
+               return FALSE;
+       }
+
+       g_variant_unref(message);
+       return TRUE;
+}
+
+static gboolean __netconfig_wifi_invoke_auth_init_configurator(guint32 peer_id,
+               guint32 configurator_id, const char *conf, const char *ssid, const char *pass)
+{
+       char *if_path = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariant *params = NULL;
+       GVariant *message = NULL;
+       gchar ssid_hex[65] = {0,};
+       gchar pass_hex[129] = {0,};
+
+       DBG("[TizenMW-->WPAS]: DPP AuthInit Request: ");
+
+       if_path = __netconfig_dpp_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus interface path");
+               return FALSE;
+       }
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "peer", g_variant_new_uint32(peer_id));
+       g_variant_builder_add(builder, "{sv}", "configurator", g_variant_new_uint32(configurator_id));
+       g_variant_builder_add(builder, "{sv}", "role", g_variant_new_string("configurator"));
+       g_variant_builder_add(builder, "{sv}", "conf", g_variant_new_string(conf));
+       if (ssid) {
+               netconfig_convert_bytes_to_hexstr(ssid, strlen(ssid), ssid_hex);
+               g_variant_builder_add(builder, "{sv}", "ssid", g_variant_new_string(ssid_hex));
+       }
+       if (pass) {
+               netconfig_convert_bytes_to_hexstr(pass, strlen(pass), pass_hex);
+               g_variant_builder_add(builder, "{sv}", "passphrase", g_variant_new_string(pass_hex));
+       }
+       params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path, SUPPLICANT_INTERFACE ".Interface.DPP", "AuthInit", params);
+       g_free(if_path);
+       if (message == NULL) {
+               ERR(" DPP : Failed to start DPP AuthInit !!!");
+               return FALSE;
+       }
+
+       g_variant_unref(message);
+       return TRUE;
+}
+
+static void __netconfig_wifi_invoke_dpp_stop_listen()
+{
+       char *if_path = NULL;
+       GVariant *message = NULL;
+
+       DBG("[TizenMW-->WPAS]: DPP StopListen Request: ");
+
+       if_path = __netconfig_dpp_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus interface path");
+               return;
+       }
+
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path, SUPPLICANT_INTERFACE ".Interface.DPP", "StopListen", NULL);
+       g_free(if_path);
+       if (message == NULL) {
+               ERR(" DPP : Failed to stop listen !!!");
+               return;
+       }
+
+       g_variant_unref(message);
+       return;
+}
+
+static void __netconfig_wifi_invoke_dpp_remove_bootstrap(guint32 uri_id)
+{
+       char *if_path = NULL;
+       GVariant *message = NULL;
+       GVariant *params = NULL;
+
+       if (uri_id == 0) {
+               DBG("Invalid ID");
+               return;
+       }
+
+       DBG("[TizenMW-->WPAS]: DPP RemoveBootstrap Request: ");
+
+       if_path = __netconfig_dpp_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus interface path");
+               return;
+       }
+
+       params = g_variant_new("(u)", uri_id);
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path, SUPPLICANT_INTERFACE ".Interface.DPP", "RemoveBootstrap", params);
+       g_free(if_path);
+       if (message == NULL) {
+               ERR(" DPP : Failed to remove URI !!!");
+               return;
+       }
+
+       g_variant_unref(message);
+       return;
+}
+
+static void __netconfig_wifi_invoke_dpp_remove_configurator(guint32 configurator_id)
+{
+       char *if_path = NULL;
+       GVariant *message = NULL;
+       GVariant *params = NULL;
+
+       if (configurator_id == 0) {
+               DBG("Invalid ID");
+               return;
+       }
+
+       DBG("[TizenMW-->WPAS]: DPP RemoveConfigurator Request: ");
+
+       if_path = __netconfig_dpp_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus interface path");
+               return;
+       }
+
+       params = g_variant_new("(u)", configurator_id);
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path, SUPPLICANT_INTERFACE ".Interface.DPP", "RemoveConfigurator", params);
+       g_free(if_path);
+       if (message == NULL) {
+               ERR(" DPP : Failed to remove configurator !!!");
+               return;
+       }
+
+       g_variant_unref(message);
+       return;
+}
+/*
+static void __wifi_dpp_connman_specific_scan_request_reply(GObject *source_object, GAsyncResult *res,
+               gpointer user_data)
+{
+       GDBusConnection *conn = NULL;
+       GError *error = NULL;
+       GVariant *reply;
+
+       conn = G_DBUS_CONNECTION(source_object);
+       reply = g_dbus_connection_call_finish(conn, res, &error);
+       if (error != NULL) {
+               ERR("Scan failed. Error [%s]\n", error->message);
+               g_error_free(error);
+       } else {
+               DBG("Specific Scan Request success\n");
+       }
+
+       if (reply)
+               g_variant_unref(reply);
+}
+
+static gboolean __netconfig_wifi_dpp_invoke_connman_specific_scan(gchar *ssid)
+{
+       GVariant *params = NULL;
+       GVariantBuilder *builder;
+       gboolean ret;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "SSID", g_variant_new_string(ssid));
+
+       params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       ret = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
+                       CONNMAN_WIFI_TECHNOLOGY_PREFIX,
+                       CONNMAN_TECHNOLOGY_INTERFACE, "SpecificScan", params,
+                       __wifi_dpp_connman_specific_scan_request_reply);
+
+       return ret;
+}
+*/
+static void __wifi_dpp_connman_scan_request_reply(GObject *source_object, GAsyncResult *res,
+               gpointer user_data)
+{
+       GDBusConnection *conn = NULL;
+       GError *error = NULL;
+       GVariant *reply;
+
+       conn = G_DBUS_CONNECTION(source_object);
+       reply = g_dbus_connection_call_finish(conn, res, &error);
+       if (error != NULL) {
+               ERR("Scan failed. Error [%s]\n", error->message);
+               g_error_free(error);
+       } else {
+               DBG("Scan Request success\n");
+       }
+
+       if (reply)
+               g_variant_unref(reply);
+}
+
+static gboolean __netconfig_wifi_dpp_invoke_connman_scan()
+{
+       return netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
+                       CONNMAN_WIFI_TECHNOLOGY_PREFIX,
+                       CONNMAN_TECHNOLOGY_INTERFACE, "Scan", NULL,
+                       __wifi_dpp_connman_scan_request_reply);
+}
+
+
+
+static gboolean __netconfig_wifi_invoke_flush_bss()
+{
+       GVariant *message = NULL;
+       char *if_path = NULL;
+       GVariant *params = NULL;
+
+       DBG("[TizenMW-->WPAS]: Wi-Fi Flush BSS Request: ");
+
+       if_path = netconfig_wifi_get_supplicant_interface();
+       if (if_path == NULL) {
+               ERR("Fail to get wpa_supplicant DBus path");
+               return FALSE;
+       }
+
+       params = g_variant_new("(u)", 0);
+       message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE,
+                       if_path, SUPPLICANT_INTERFACE ".Interface", "FlushBSS", params);
+
+       g_free(if_path);
+       if (message == NULL) {
+               ERR(" Failed to flush BSS !!!");
+               return FALSE;
+       }
+
+       g_variant_unref(message);
+       return TRUE;
+}
+
+static gboolean __netconfig_wifi_dpp_enter_peer_uri(GDBusMethodInvocation *context,
+               guint32 peer_id, guint32 own_id, gboolean is_initiator, gchar *peer_uri)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       gboolean ret;
+
+       p_dpp_info = _get_dpp_info(peer_id, own_id);
+       if (!p_dpp_info) {
+               ERR("Invalid parameter");
+               return FALSE;
+       }
+
+       ret = __netconfig_wifi_invoke_dpp_qr_code(peer_uri, &(p_dpp_info->peer_id));
+       if (!ret)
+               return FALSE;
+
+       __netconfig_wifi_notify_dpp_bootstrapped(p_dpp_info->peer_id);
+
+       return TRUE;
+}
+
+static gboolean __netconfig_wifi_dpp_generate_uri(GDBusMethodInvocation *context,
+               guint32 peer_id, guint32 own_id, gboolean is_initiator, const gchar *key)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       guint32 id = 0;
+       gchar *generated_uri = NULL;
+       gboolean ret;
+
+       p_dpp_info = _get_dpp_info(peer_id, own_id);
+       if (!p_dpp_info) {
+               ERR("Invalid parameter");
+               return FALSE;
+       }
+
+       ret = __netconfig_wifi_invoke_dpp_add_bootstrap(key, &id);
+       if (!ret)
+               return FALSE;
+
+       ret = __netconfig_wifi_invoke_dpp_get_bootstrap_uri(id, &generated_uri);
+       if (!ret) {
+               __netconfig_wifi_invoke_dpp_remove_bootstrap(id);
+               return FALSE;
+       }
+
+       p_dpp_info->own_id = id;
+       __netconfig_wifi_notify_dpp_uri_generated(id, generated_uri);
+       g_free(generated_uri);
+
+       return TRUE;
+}
+
+static gboolean __netconfig_wifi_dpp_start_configurator_initiator(GDBusMethodInvocation *context,
+               const char *group_id, const char *ssid, const char *peer_uri, guint32 peer_id,
+               const char *net_role, const char *akm, const char *configurator_key,
+               const char *pass)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       guint32 id = 0;
+       char *conf_str = NULL;
+       gboolean ret = FALSE;
+
+       p_dpp_info = __create_dpp_info(TRUE);
+       if (!p_dpp_info) {
+               INFO("Failed to create DPP info");
+               return FALSE;
+       }
+
+       ret = __netconfig_wifi_invoke_dpp_qr_code(peer_uri, &(id));
+       if (!ret) {
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+
+       ret = __netconfig_wifi_invoke_dpp_add_configurator(configurator_key, &(p_dpp_info->configurator_id));
+       if (!ret) {
+               __netconfig_wifi_invoke_dpp_remove_bootstrap(id);
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+       p_dpp_info->state = WIFI_DPP_STATE_BOOTSTRAPPED;
+       __netconfig_wifi_notify_dpp_bootstrapped(id);
+
+       conf_str = g_strdup_printf("%s-%s", net_role, akm);
+       ret = __netconfig_wifi_invoke_auth_init_configurator(id,
+                       p_dpp_info->configurator_id, conf_str, ssid, pass);
+       if (!ret) {
+               __netconfig_wifi_invoke_dpp_remove_bootstrap(id);
+               __destroy_dpp_info(p_dpp_info);
+               g_free(conf_str);
+               return FALSE;
+       }
+
+       p_dpp_info->is_initiator = TRUE;
+       p_dpp_info->peer_id = id;
+       __add_to_dpp_info_list(p_dpp_info);
+       p_dpp_info->state = WIFI_DPP_STATE_AUTHENTICATING;
+       __netconfig_wifi_notify_dpp_authenticating(id, p_dpp_info->own_id);
+
+       g_free(conf_str);
+
+       return TRUE;
+}
+
+static gboolean __netconfig_wifi_dpp_start_configurator_responder(GDBusMethodInvocation *context,
+               const char *group_id, const char *ssid, const char *net_role,
+               const char *akm, const char *auth_key, const char *configurator_key,
+               const char *pass)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       gboolean ret = FALSE;
+       guint32 id = 0;
+       gchar *generated_uri = NULL;
+
+       p_dpp_info = __create_dpp_info(FALSE);
+       if (!p_dpp_info) {
+               INFO("Failed to create DPP info");
+               return FALSE;
+       }
+
+       ret = __netconfig_wifi_invoke_dpp_add_configurator(configurator_key, &(p_dpp_info->configurator_id));
+       if (!ret) {
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+
+       ret = __netconfig_wifi_invoke_dpp_set_configurator_params(p_dpp_info->configurator_id, ssid, net_role, akm, pass);
+       if (!ret) {
+               __netconfig_wifi_invoke_dpp_remove_configurator(p_dpp_info->configurator_id);
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+
+       ret = __netconfig_wifi_invoke_dpp_add_bootstrap(auth_key, &id);
+       if (!ret) {
+               __netconfig_wifi_invoke_dpp_remove_configurator(p_dpp_info->configurator_id);
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+
+       ret = __netconfig_wifi_invoke_dpp_get_bootstrap_uri(id, &generated_uri);
+       if (!ret) {
+               __netconfig_wifi_invoke_dpp_remove_configurator(p_dpp_info->configurator_id);
+               __netconfig_wifi_invoke_dpp_remove_bootstrap(id);
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+
+       __netconfig_wifi_notify_dpp_uri_generated(id, generated_uri);
+
+       ret = __netconfig_wifi_invoke_dpp_listen(DEFAULT_DPP_FREQ, "configurator");
+       if (!ret) {
+               __netconfig_wifi_invoke_dpp_remove_configurator(p_dpp_info->configurator_id);
+               __netconfig_wifi_invoke_dpp_remove_bootstrap(id);
+               g_free(generated_uri);
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+
+       p_dpp_info->is_initiator = FALSE;
+       p_dpp_info->own_id = id;
+       __add_to_dpp_info_list(p_dpp_info);
+       p_dpp_info->state = WIFI_DPP_STATE_AWAITING;
+       __netconfig_wifi_notify_dpp_awaiting(id);
+
+       g_free(generated_uri);
+
+       return TRUE;
+}
+
+static gboolean __netconfig_wifi_dpp_start_enrollee_initiator(GDBusMethodInvocation *context,
+               const char *peer_uri, guint32 peer_id)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       guint32 id = 0;
+       gboolean ret = FALSE;
+
+       p_dpp_info = __create_dpp_info(TRUE);
+       if (!p_dpp_info) {
+               INFO("Failed to create DPP info");
+               return FALSE;
+       }
+
+       ret = __netconfig_wifi_invoke_dpp_set_dpp_config_processing();
+       if (!ret) {
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+
+       ret = __netconfig_wifi_invoke_dpp_qr_code(peer_uri, &id);
+       if (!ret) {
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+       p_dpp_info->state = WIFI_DPP_STATE_BOOTSTRAPPED;
+       __netconfig_wifi_notify_dpp_bootstrapped(id);
+
+       ret = __netconfig_wifi_invoke_auth_init_enrollee(id);
+       if (!ret) {
+               __netconfig_wifi_invoke_dpp_remove_bootstrap(id);
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+
+       p_dpp_info->is_initiator = TRUE;
+       p_dpp_info->peer_id = id;
+       __add_to_dpp_info_list(p_dpp_info);
+       p_dpp_info->state = WIFI_DPP_STATE_AUTHENTICATING;
+       __netconfig_wifi_notify_dpp_authenticating(id, p_dpp_info->own_id);
+
+       return TRUE;
+}
+
+static gboolean __netconfig_wifi_dpp_start_enrollee_responder(GDBusMethodInvocation *context,
+               const char *auth_key)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       gboolean ret = FALSE;
+       guint32 id = 0;
+       gchar *generated_uri = NULL;
+
+       p_dpp_info = __create_dpp_info(FALSE);
+       if (!p_dpp_info) {
+               INFO("Failed to create DPP info");
+               return FALSE;
+       }
+
+       ret = __netconfig_wifi_invoke_dpp_set_dpp_config_processing();
+       if (!ret) {
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+
+       ret = __netconfig_wifi_invoke_dpp_add_bootstrap(auth_key, &id);
+       if (!ret) {
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+
+       ret = __netconfig_wifi_invoke_dpp_get_bootstrap_uri(id, &generated_uri);
+       if (!ret) {
+               __netconfig_wifi_invoke_dpp_remove_bootstrap(id);
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+
+       __netconfig_wifi_notify_dpp_uri_generated(id, generated_uri);
+
+       ret = __netconfig_wifi_invoke_dpp_listen(DEFAULT_DPP_FREQ, "enrollee");
+       if (!ret) {
+               __netconfig_wifi_invoke_dpp_remove_bootstrap(id);
+               __destroy_dpp_info(p_dpp_info);
+               return FALSE;
+       }
+
+       p_dpp_info->is_initiator = FALSE;
+       p_dpp_info->own_id = id;
+       __add_to_dpp_info_list(p_dpp_info);
+       p_dpp_info->state = WIFI_DPP_STATE_AWAITING;
+       __netconfig_wifi_notify_dpp_awaiting(id);
+
+       g_free(generated_uri);
+
+       return TRUE;
+}
+
+static gboolean __netconfig_wifi_dpp_stop(GDBusMethodInvocation *context,
+               guint32 peer_id, guint32 own_id)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+
+       p_dpp_info = _get_dpp_info(peer_id, own_id);
+       if (!p_dpp_info) {
+               ERR("Invalid parameter");
+               return FALSE;
+       }
+
+       __netconfig_wifi_invoke_dpp_stop_listen();
+       __netconfig_wifi_invoke_dpp_remove_bootstrap(p_dpp_info->peer_id);
+
+       if (p_dpp_info->own_id != 0)
+               __netconfig_wifi_invoke_dpp_remove_bootstrap(p_dpp_info->own_id);
+
+       if (p_dpp_info->configurator_id != 0)
+               __netconfig_wifi_invoke_dpp_remove_configurator(p_dpp_info->configurator_id);
+
+       __remove_from_dpp_info_list(p_dpp_info);
+       __destroy_dpp_info(p_dpp_info);
+       __netconfig_wifi_notify_dpp_removed(peer_id, own_id);
+
+       return TRUE;
+}
+
+
+void netconfig_wifi_dpp_auth_success_event(GVariant *message)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       GVariantBuilder *builder = NULL;
+
+       p_dpp_info = _get_dpp_in_progress();
+       if (!p_dpp_info) {
+               ERR("DPP :there's no DPP in progress");
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "peer_id", g_variant_new_uint32(p_dpp_info->peer_id));
+       g_variant_builder_add(builder, "{sv}", "own_id", g_variant_new_uint32(p_dpp_info->own_id));
+
+       p_dpp_info->state = WIFI_DPP_STATE_AUTHENTICATED;
+       wifi_emit_dpp_auth_success((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+
+       return;
+}
+
+static void __clear_dpp_process(wifi_dpp_s *p_dpp_info)
+{
+       g_in_progress = FALSE;
+       __netconfig_wifi_invoke_dpp_stop_listen();
+
+       __netconfig_wifi_invoke_dpp_remove_bootstrap(p_dpp_info->peer_id);
+
+       if (p_dpp_info->own_id != 0)
+               __netconfig_wifi_invoke_dpp_remove_bootstrap(p_dpp_info->own_id);
+
+       if (p_dpp_info->configurator_id != 0)
+               __netconfig_wifi_invoke_dpp_remove_configurator(p_dpp_info->configurator_id);
+
+       __remove_from_dpp_info_list(p_dpp_info);
+       __netconfig_wifi_notify_dpp_removed(p_dpp_info->peer_id, p_dpp_info->own_id);
+       __destroy_dpp_info(p_dpp_info);
+}
+
+static void __resume_dpp_responder(wifi_dpp_s *p_dpp_info)
+{
+       gchar *device_role = NULL;
+       gboolean ret;
+
+       __netconfig_wifi_invoke_dpp_stop_listen();
+
+       if (p_dpp_info->configurator_id)
+               device_role = "configurator";
+       else
+               device_role = "enrollee";
+
+       ret = __netconfig_wifi_invoke_dpp_listen(DEFAULT_DPP_FREQ, device_role);
+       if (!ret) {
+               __clear_dpp_process(p_dpp_info);
+       } else {
+               p_dpp_info->state = WIFI_DPP_STATE_AWAITING;
+               __netconfig_wifi_notify_dpp_awaiting(p_dpp_info->own_id);
+       }
+}
+
+static void __netconfig_wifi_dpp_wrap_up(wifi_dpp_s *p_dpp_info)
+{
+       if (p_dpp_info->is_initiator)
+               __clear_dpp_process(p_dpp_info);
+       else
+               __resume_dpp_responder(p_dpp_info);
+}
+
+static void __netconfig_wifi_dpp_notify_dpp_failed(wifi_dpp_s *p_dpp_info)
+{
+       GVariantBuilder *builder = NULL;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "peer_id", g_variant_new_uint32(p_dpp_info->peer_id));
+       g_variant_builder_add(builder, "{sv}", "own_id", g_variant_new_uint32(p_dpp_info->own_id));
+
+       wifi_emit_dpp_auth_failed((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       __netconfig_wifi_dpp_wrap_up(p_dpp_info);
+}
+
+void netconfig_wifi_dpp_auth_failed_event(GVariant *message)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       p_dpp_info = _get_dpp_in_progress();
+       if (!p_dpp_info) {
+               ERR("DPP :there's no DPP in progress");
+               return;
+       }
+
+       __netconfig_wifi_dpp_notify_dpp_failed(p_dpp_info);
+
+       return;
+}
+
+void netconfig_wifi_dpp_not_compatible_event(GVariant *message)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       GVariantBuilder *builder = NULL;
+
+       p_dpp_info = _get_dpp_in_progress();
+       if (!p_dpp_info) {
+               ERR("DPP :there's no DPP in progress");
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "peer_id", g_variant_new_uint32(p_dpp_info->peer_id));
+       g_variant_builder_add(builder, "{sv}", "own_id", g_variant_new_uint32(p_dpp_info->own_id));
+
+       wifi_emit_dpp_not_compatible((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       __netconfig_wifi_dpp_wrap_up(p_dpp_info);
+
+       return;
+}
+
+void netconfig_wifi_dpp_conf_failed_event(GVariant *message)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       GVariantBuilder *builder = NULL;
+
+       p_dpp_info = _get_dpp_in_progress();
+       if (!p_dpp_info) {
+               ERR("DPP :there's no DPP in progress");
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "peer_id", g_variant_new_uint32(p_dpp_info->peer_id));
+       g_variant_builder_add(builder, "{sv}", "own_id", g_variant_new_uint32(p_dpp_info->own_id));
+
+       wifi_emit_dpp_conf_failed((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       __netconfig_wifi_dpp_wrap_up(p_dpp_info);
+
+       return;
+}
+
+void netconfig_wifi_dpp_scan_peer_qr_event(GVariant *message)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       GVariantBuilder *builder = NULL;
+
+       p_dpp_info = _get_dpp_in_progress();
+       if (!p_dpp_info) {
+               ERR("DPP :there's no DPP in progress");
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "peer_id", g_variant_new_uint32(p_dpp_info->peer_id));
+       g_variant_builder_add(builder, "{sv}", "own_id", g_variant_new_uint32(p_dpp_info->own_id));
+
+       wifi_emit_dpp_scan_peer_qr((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       p_dpp_info->state = WIFI_DPP_STATE_PEER_QR_REQUESTED;
+
+       return;
+}
+
+void netconfig_wifi_dpp_network_id_event(GVariant *message)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       GVariantBuilder *builder = NULL;
+
+       p_dpp_info = _get_dpp_in_progress();
+       if (!p_dpp_info) {
+               ERR("DPP :there's no DPP in progress");
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "peer_id", g_variant_new_uint32(p_dpp_info->peer_id));
+       g_variant_builder_add(builder, "{sv}", "own_id", g_variant_new_uint32(p_dpp_info->own_id));
+
+       wifi_emit_dpp_network_id((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       return;
+}
+
+void netconfig_wifi_dpp_conf_sent_event(GVariant *message)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       GVariantBuilder *builder = NULL;
+
+       p_dpp_info = _get_dpp_in_progress();
+       if (!p_dpp_info) {
+               ERR("DPP :there's no DPP in progress");
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "peer_id", g_variant_new_uint32(p_dpp_info->peer_id));
+       g_variant_builder_add(builder, "{sv}", "own_id", g_variant_new_uint32(p_dpp_info->own_id));
+
+       wifi_emit_dpp_conf_sent((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       __netconfig_wifi_dpp_wrap_up(p_dpp_info);
+
+       return;
+}
+
+void netconfig_wifi_dpp_conf_received_event(GVariant *message)
+{
+       wifi_dpp_s *p_dpp_info = NULL;
+       GVariantBuilder *builder = NULL;
+
+       p_dpp_info = _get_dpp_in_progress();
+       if (!p_dpp_info) {
+               ERR("DPP :there's no DPP in progress");
+               return;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "peer_id", g_variant_new_uint32(p_dpp_info->peer_id));
+       g_variant_builder_add(builder, "{sv}", "own_id", g_variant_new_uint32(p_dpp_info->own_id));
+
+       wifi_emit_dpp_conf_received((Wifi *)get_wifi_object(), g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+
+       p_dpp_info->state = WIFI_DPP_STATE_CONFIGURED;
+
+       return;
+}
+
+static wifi_dpp_akm_e __get_dpp_akm(const gchar *akm_str)
+{
+       if (g_strcmp0(akm_str, "psk") == 0)
+               return WIFI_DPP_AKM_PSK;
+       else if (g_strcmp0(akm_str, "sae") == 0)
+               return WIFI_DPP_AKM_SAE;
+       else if (g_strcmp0(akm_str, "dpp") == 0)
+               return WIFI_DPP_AKM_DPP;
+
+       return WIFI_DPP_AKM_UNKNOWN;
+}
+
+static gboolean __is_configuration_valid(wifi_dpp_akm_e akm, const gchar *passphrase,
+               const gchar *connector, const gchar *c_sign_key, const gchar *net_access_key)
+{
+       if ((akm == WIFI_DPP_AKM_PSK || akm == WIFI_DPP_AKM_SAE) && passphrase)
+               return TRUE;
+       else if (akm == WIFI_DPP_AKM_DPP && connector && c_sign_key && net_access_key)
+               return TRUE;
+       return FALSE;
+}
+
+gboolean __save_passphrase(GKeyFile *keyfile, gchar *group_name, gchar *key, gchar *value)
+{
+       gchar *enc_data = NULL;
+       gboolean ret = TRUE;
+
+       if (!value)
+               return ret;
+
+       enc_data = _netconfig_encrypt_passphrase(value);
+       if (!enc_data) {
+               ERR("Failed to encrypt the passphrase");
+               ret = FALSE;
+       } else {
+               g_key_file_set_string(keyfile, group_name, key, enc_data);
+               g_free(enc_data);
+       }
+
+       return ret;
+}
+
+gboolean __save_credentials(GKeyFile *keyfile, gchar *group_name, wifi_dpp_conf_obj *conf_obj)
+{
+       gboolean ret;
+
+       ret = __save_passphrase(keyfile, group_name,
+                       "Passphrase", conf_obj->passphrase);
+       if (!ret)
+               return FALSE;
+
+       ret = __save_passphrase(keyfile, group_name,
+                       "Connector", conf_obj->connector);
+       if (!ret)
+               return FALSE;
+
+       ret = __save_passphrase(keyfile, group_name,
+                       "CSignKey", conf_obj->c_sign_key);
+       if (!ret)
+               return FALSE;
+
+       ret = __save_passphrase(keyfile, group_name,
+                       "NetAccessKey", conf_obj->net_access_key);
+       if (!ret)
+               return FALSE;
+
+       return TRUE;
+}
+
+
+static gboolean __save_configuration_object(wifi_dpp_conf_obj *conf_obj)
+{
+       gchar ssid_hex[65] = {0,};
+       gchar *config_id = NULL;
+       gchar *group_name = NULL;
+       GKeyFile *keyfile = NULL;
+       gboolean ret;
+
+       if (!conf_obj->ssid) {
+               ERR("DPP :there's no SSID in configuration");
+               return FALSE;
+       }
+
+       if (!__is_configuration_valid(__get_dpp_akm(conf_obj->akm),
+                       conf_obj->passphrase,
+                       conf_obj->connector,
+                       conf_obj->c_sign_key,
+                       conf_obj->net_access_key)) {
+               ERR("DPP :Invalid AKM information in configuration");
+               return FALSE;
+       }
+
+       netconfig_convert_bytes_to_hexstr(conf_obj->ssid, strlen(conf_obj->ssid), ssid_hex);
+       config_id = g_strdup_printf("%s_managed_%s", ssid_hex, conf_obj->akm);
+       ret = wifi_config_get_group_name("wifi_", config_id, &group_name);
+       if (!ret) {
+               ERR("Failed to get Wi-Fi config group name");
+               g_free(config_id);
+               return FALSE;
+       }
+
+       keyfile = g_key_file_new();
+       g_key_file_set_string(keyfile, group_name, "Name", conf_obj->ssid);
+       g_key_file_set_string(keyfile, group_name, "SSID", ssid_hex);
+
+       if (!__save_credentials(keyfile, group_name, conf_obj)) {
+               g_key_file_free(keyfile);
+               g_free(config_id);
+               g_free(group_name);
+               return FALSE;
+       }
+
+       g_key_file_set_boolean(keyfile, group_name, "Favorite", TRUE);
+       g_key_file_set_boolean(keyfile, group_name, "AutoConnect", TRUE);
+
+       ret = wifi_config_save_configuration(config_id, keyfile);
+       if (ret == TRUE)
+               INFO("Success to save configuration [%s]", config_id);
+       else
+               INFO("Fail to save configuration [%s]", config_id);
+
+       g_key_file_free(keyfile);
+       g_free(config_id);
+       g_free(group_name);
+
+       return ret;
+
+}
+
+void netconfig_wifi_dpp_conf_obj_event(GVariant *message)
+{
+       GVariantIter *iter = NULL;
+       gchar *key = NULL;
+       GVariant *value = NULL;
+       wifi_dpp_s *p_dpp_info = NULL;
+       wifi_dpp_conf_obj conf_obj = {0,};
+
+       p_dpp_info = _get_dpp_in_progress();
+       if (!p_dpp_info) {
+               ERR("DPP :there's no DPP in progress");
+               return;
+       }
+
+       g_variant_get(message, "(a{sv})", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+               if (g_strcmp0(key, "ssid") == 0)
+                       g_variant_get(value, "&s", &conf_obj.ssid);
+               else if (g_strcmp0(key, "akm") == 0)
+                       g_variant_get(value, "&s", &conf_obj.akm);
+               else if (g_strcmp0(key, "passphrase") == 0)
+                       g_variant_get(value, "&s", &conf_obj.passphrase);
+               else if (g_strcmp0(key, "connector") == 0)
+                       g_variant_get(value, "&s", &conf_obj.connector);
+               else if (g_strcmp0(key, "c_sign_key") == 0)
+                       g_variant_get(value, "&s", &conf_obj.c_sign_key);
+               else if (g_strcmp0(key, "net_access_key") == 0)
+                       g_variant_get(value, "&s", &conf_obj.net_access_key);
+       }
+
+       if (!__save_configuration_object(&conf_obj) || !__netconfig_wifi_invoke_flush_bss()) {
+               g_variant_iter_free(iter);
+               __netconfig_wifi_dpp_notify_dpp_failed(p_dpp_info);
+               return;
+       }
+
+       g_variant_iter_free(iter);
+       __clear_dpp_process(p_dpp_info);
+       __netconfig_wifi_dpp_invoke_connman_scan();
+       return;
+}
+
+gboolean handle_dpp_enter_peer_uri(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info)
+{
+       gboolean ret = FALSE;
+       GVariantIter *iter;
+       GVariant *value;
+       gchar *field;
+       guint32 peer_id = 0;
+       guint32 own_id = 0;
+       gboolean is_initiator = FALSE;
+       gchar *uri = NULL;
+
+       INFO("Received DPP enter peer uri Request");
+       if ((wifi == NULL) || (dpp_info == NULL)) {
+               ERR("Invalid arguments");
+               netconfig_error_dbus_method_return(context,
+                               NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
+               return TRUE;
+       }
+
+       g_variant_get(dpp_info, "a{sv}", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
+               if (g_strcmp0(field, "peer_id") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) {
+                       peer_id = g_variant_get_uint32(value);
+               } else if (g_strcmp0(field, "own_id") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) {
+                       own_id = g_variant_get_uint32(value);
+
+               } else if (g_strcmp0(field, "uri") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       g_free(uri);
+                       uri = g_strdup(g_variant_get_string(value, NULL));
+               }
+       }
+
+       if (!own_id || !uri){
+               g_variant_iter_free(iter);
+               g_free(uri);
+               ERR("Invalid arguments");
+               netconfig_error_dbus_method_return(context,
+                               NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
+               return TRUE;
+       }
+       wifi_complete_dpp_enter_peer_uri(wifi, context);
+
+       ret = __netconfig_wifi_dpp_enter_peer_uri(context, peer_id, own_id,
+                       is_initiator, uri);
+       if (ret == TRUE)
+               INFO("Success to enter peer uri");
+       else
+               __netconfig_wifi_notify_dpp_failed();
+
+       g_variant_iter_free(iter);
+       g_free(uri);
+
+       return TRUE;
+}
+
+gboolean handle_dpp_generate_uri(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info)
+{
+       gboolean ret = FALSE;
+       GVariantIter *iter;
+       GVariant *value;
+       gchar *field;
+       guint32 peer_id = 0;
+       guint32 own_id = 0;
+       gboolean is_initiator = FALSE;
+       gchar *key = NULL;
+
+       INFO("Received DPP gen own uri Request");
+       if ((wifi == NULL) || (dpp_info == NULL)) {
+               ERR("Invalid arguments");
+               netconfig_error_dbus_method_return(context,
+                               NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
+               return TRUE;
+       }
+
+       g_variant_get(dpp_info, "a{sv}", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
+               if (g_strcmp0(field, "peer_id") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) {
+                       peer_id = g_variant_get_uint32(value);
+               } else if (g_strcmp0(field, "own_id") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) {
+                       own_id = g_variant_get_uint32(value);
+
+               } else if (g_strcmp0(field, "is_initiator") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN)) {
+                       is_initiator = g_variant_get_boolean(value);
+               } else if (g_strcmp0(field, "key") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       __free_critical(key);
+                       key = g_strdup(g_variant_get_string(value, NULL));
+               }
+       }
+
+       if (!peer_id){
+               __free_critical(key);
+               g_variant_iter_free(iter);
+               ERR("Invalid arguments");
+               netconfig_error_dbus_method_return(context,
+                               NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
+               return TRUE;
+       }
+       wifi_complete_dpp_generate_uri(wifi, context);
+
+       ret = __netconfig_wifi_dpp_generate_uri(context, peer_id, own_id,
+                       is_initiator, key);
+       if (ret == TRUE)
+               INFO("Success to generate uri");
+       else
+               __netconfig_wifi_notify_dpp_failed();
+
+       g_variant_iter_free(iter);
+       __free_critical(key);
+
+       return TRUE;
+}
+
+gboolean handle_dpp_start_configurator_initiator(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info)
+{
+       GVariantIter *iter;
+       GVariant *value;
+       gchar *field;
+       gchar *group_id = NULL;
+       gchar *ssid = NULL;
+       gchar *peer_uri = NULL;
+       guint32 peer_id = 0;
+       gchar *net_role = NULL;
+       gchar *akm = NULL;
+       gchar *configurator_key = NULL;
+       gchar *pass = NULL;
+
+       INFO("Received DPP start configurator initiator");
+       if ((wifi == NULL) || (dpp_info == NULL)) {
+               ERR("Invalid arguments");
+               netconfig_error_dbus_method_return(context,
+                               NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
+               return TRUE;
+       }
+       if (g_in_progress) {
+               ERR("DPP in progress");;
+               netconfig_error_inprogress(context);
+               return TRUE;
+       }
+
+       g_variant_get(dpp_info, "a{sv}", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
+               if (g_strcmp0(field, "group_id") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       g_free(group_id);
+                       group_id = g_strdup(g_variant_get_string(value, NULL));
+               } else if (g_strcmp0(field, "ssid") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       g_free(ssid);
+                       ssid = g_strdup(g_variant_get_string(value, NULL));
+               } else if (g_strcmp0(field, "peer_uri") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       g_free(peer_uri);
+                       peer_uri = g_strdup(g_variant_get_string(value, NULL));
+               } else if (g_strcmp0(field, "peer_id") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) {
+                       peer_id = g_variant_get_uint32(value);
+               } else if (g_strcmp0(field, "net_role") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       g_free(net_role);
+                       net_role = g_strdup(g_variant_get_string(value, NULL));
+               } else if (g_strcmp0(field, "akm") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       g_free(akm);
+                       akm = g_strdup(g_variant_get_string(value, NULL));
+               } else if (g_strcmp0(field, "configurator_key") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       __free_critical(configurator_key);
+                       configurator_key = g_strdup(g_variant_get_string(value, NULL));
+               } else if (g_strcmp0(field, "pass") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       __free_critical(pass);
+                       pass = g_strdup(g_variant_get_string(value, NULL));
+               }
+       }
+
+       if (!ssid || !akm || !net_role || !peer_uri){
+               g_variant_iter_free(iter);
+               g_free(group_id);
+               g_free(ssid);
+               g_free(peer_uri);
+               g_free(net_role);
+               g_free(akm);
+               __free_critical(configurator_key);
+               __free_critical(pass);
+               ERR("Invalid arguments");
+               netconfig_error_dbus_method_return(context,
+                               NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
+               return TRUE;
+       }
+
+       wifi_complete_dpp_start_configurator_initiator(wifi, context);
+
+       g_in_progress = __netconfig_wifi_dpp_start_configurator_initiator(context, group_id,
+                       ssid, peer_uri, peer_id, net_role, akm, configurator_key, pass);
+       if (g_in_progress)
+               INFO("Success to dpp start configurator initiator");
+       else
+               __netconfig_wifi_notify_dpp_failed();
+
+       g_variant_iter_free(iter);
+       g_free(group_id);
+       g_free(ssid);
+       g_free(peer_uri);
+       g_free(net_role);
+       g_free(akm);
+       __free_critical(configurator_key);
+       __free_critical(pass);
+       return TRUE;
+}
+
+gboolean handle_dpp_start_enrollee_initiator(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info)
+{
+       GVariantIter *iter;
+       GVariant *value;
+       gchar *field;
+       gchar *peer_uri = NULL;
+       guint32 peer_id = 0;
+
+       INFO("Received DPP start enrollee initiator");
+       if ((wifi == NULL) || (dpp_info == NULL)) {
+               ERR("Invalid arguments");
+               netconfig_error_dbus_method_return(context,
+                               NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
+               return TRUE;
+       }
+       if (g_in_progress) {
+               ERR("DPP in progress");;
+               netconfig_error_inprogress(context);
+               return TRUE;
+       }
+
+       g_variant_get(dpp_info, "a{sv}", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
+
+               if (g_strcmp0(field, "peer_uri") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       g_free(peer_uri);
+                       peer_uri = g_strdup(g_variant_get_string(value, NULL));
+               } else if (g_strcmp0(field, "peer_id") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) {
+                       peer_id = g_variant_get_uint32(value);
+               }
+       }
+
+       if (!peer_uri){
+               g_variant_iter_free(iter);
+               ERR("Invalid arguments");
+               netconfig_error_dbus_method_return(context,
+                               NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
+               return FALSE;
+       }
+       wifi_complete_dpp_start_enrollee_initiator(wifi, context);
+
+       g_in_progress = __netconfig_wifi_dpp_start_enrollee_initiator(context, peer_uri, peer_id);
+       if (g_in_progress)
+               INFO("Success to dpp start enrollee initiator");
+       else
+               __netconfig_wifi_notify_dpp_failed();
+
+       g_variant_iter_free(iter);
+       g_free(peer_uri);
+
+       return TRUE;
+}
+
+gboolean handle_dpp_start_configurator_responder(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info)
+{
+       GVariantIter *iter;
+       GVariant *value;
+       gchar *field;
+       gchar *group_id = NULL;
+       gchar *ssid = NULL;
+       gchar *net_role = NULL;
+       gchar *akm = NULL;
+       gchar *auth_key = NULL;
+       gchar *configurator_key = NULL;
+       gchar *pass = NULL;
+
+       INFO("Received DPP start configurator responder");
+       if ((wifi == NULL) || (dpp_info == NULL)) {
+               ERR("Invalid arguments");
+               netconfig_error_dbus_method_return(context,
+                               NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
+               return TRUE;
+       }
+       if (g_in_progress) {
+               ERR("DPP in progress");;
+               netconfig_error_inprogress(context);
+               return TRUE;
+       }
+
+       g_variant_get(dpp_info, "a{sv}", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
+               if (g_strcmp0(field, "group_id") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       g_free(group_id);
+                       group_id = g_strdup(g_variant_get_string(value, NULL));
+               } else if (g_strcmp0(field, "ssid") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       g_free(ssid);
+                       ssid = g_strdup(g_variant_get_string(value, NULL));
+               } else if (g_strcmp0(field, "net_role") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       g_free(net_role);
+                       net_role = g_strdup(g_variant_get_string(value, NULL));
+               } else if (g_strcmp0(field, "akm") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       g_free(akm);
+                       akm = g_strdup(g_variant_get_string(value, NULL));
+               } else if (g_strcmp0(field, "auth_key") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       __free_critical(auth_key);
+                       auth_key = g_strdup(g_variant_get_string(value, NULL));
+               } else if (g_strcmp0(field, "configurator_key") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       __free_critical(configurator_key);
+                       configurator_key = g_strdup(g_variant_get_string(value, NULL));
+               } else if (g_strcmp0(field, "pass") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       __free_critical(pass);
+                       pass = g_strdup(g_variant_get_string(value, NULL));
+               }
+       }
+
+       if (!ssid || !akm || !net_role){
+               g_variant_iter_free(iter);
+               g_free(group_id);
+               g_free(ssid);
+               g_free(net_role);
+               g_free(akm);
+               __free_critical(auth_key);
+               __free_critical(configurator_key);
+               __free_critical(pass);
+               ERR("Invalid arguments");
+               netconfig_error_dbus_method_return(context,
+                               NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
+               return FALSE;
+       }
+       wifi_complete_dpp_start_configurator_responder(wifi, context);
+
+       g_in_progress = __netconfig_wifi_dpp_start_configurator_responder(context, group_id,
+                       ssid, net_role, akm, auth_key, configurator_key, pass);
+       if (g_in_progress)
+               INFO("Success to dpp start configurator responder");
+       else
+               __netconfig_wifi_notify_dpp_failed();
+
+       g_variant_iter_free(iter);
+       g_free(group_id);
+       g_free(ssid);
+       g_free(net_role);
+       g_free(akm);
+       __free_critical(auth_key);
+       __free_critical(configurator_key);
+       __free_critical(pass);
+
+       return TRUE;
+}
+
+gboolean handle_dpp_start_enrollee_responder(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info)
+{
+       GVariantIter *iter;
+       GVariant *value;
+       gchar *field;
+       gchar *auth_key = NULL;
+
+       INFO("Received DPP start enrollee responder");
+       if ((wifi == NULL) || (dpp_info == NULL)) {
+               ERR("Invalid arguments");
+               netconfig_error_dbus_method_return(context,
+                               NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
+               return TRUE;
+       }
+       if (g_in_progress) {
+               ERR("DPP in progress");;
+               netconfig_error_inprogress(context);
+               return TRUE;
+       }
+
+       g_variant_get(dpp_info, "a{sv}", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
+               if (g_strcmp0(field, "auth_key") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       __free_critical(auth_key);
+                       auth_key = g_strdup(g_variant_get_string(value, NULL));
+               }
+       }
+       wifi_complete_dpp_start_enrollee_responder(wifi, context);
+
+       g_in_progress = __netconfig_wifi_dpp_start_enrollee_responder(context, auth_key);
+       if (g_in_progress)
+               INFO("Success to dpp start enrolee responder");
+       else
+               __netconfig_wifi_notify_dpp_failed();
+
+       g_variant_iter_free(iter);
+       __free_critical(auth_key);
+
+       return TRUE;
+}
+
+gboolean handle_dpp_stop(Wifi *wifi, GDBusMethodInvocation *context, GVariant *dpp_info)
+{
+       GVariantIter *iter;
+       GVariant *value;
+       gchar *field;
+       guint32 peer_id = 0;
+       guint32 own_id = 0;
+
+       INFO("Received DPP stop Request");
+       if ((wifi == NULL) || (dpp_info == NULL)) {
+               ERR("Invalid arguments");
+               netconfig_error_dbus_method_return(context,
+                               NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
+               return TRUE;
+       }
+
+       g_variant_get(dpp_info, "a{sv}", &iter);
+
+       g_variant_get(dpp_info, "a{sv}", &iter);
+       while (g_variant_iter_loop(iter, "{sv}", &field, &value)) {
+               if (g_strcmp0(field, "peer_id") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) {
+                       peer_id = g_variant_get_uint32(value);
+               } else if (g_strcmp0(field, "own_id") == 0 &&
+                               g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) {
+                       own_id = g_variant_get_uint32(value);
+               }
+       }
+       if (!peer_id && !own_id){
+               g_variant_iter_free(iter);
+               ERR("Invalid arguments");
+               netconfig_error_dbus_method_return(context,
+                               NETCONFIG_ERROR_INVALID_PARAMETER, "InvalidArguments");
+               return FALSE;
+       }
+       wifi_complete_dpp_stop(wifi, context);
+
+       g_in_progress = !(__netconfig_wifi_dpp_stop(context, peer_id, own_id));
+       if (!g_in_progress)
+               INFO("Success to dpp stop");
+       else
+               __netconfig_wifi_notify_dpp_failed();
+
+       g_variant_iter_free(iter);
+
+       return TRUE;
+}
index dd6c7b5..4bc18c6 100755 (executable)
@@ -57,6 +57,7 @@
 #define NETCONFIG_PROCWIRELESS                                 "/proc/net/wireless"
 
 static int netconfig_wifi_rssi = VCONFKEY_WIFI_SNR_MIN;
+static guint32 netconfig_wifi_freq = 0;
 static guint netconfig_wifi_indicator_timer = 0;
 
 int netconfig_wifi_get_rssi(void)
@@ -64,6 +65,11 @@ int netconfig_wifi_get_rssi(void)
        return netconfig_wifi_rssi;
 }
 
+unsigned int netconfig_wifi_get_freq(void)
+{
+       return netconfig_wifi_freq;
+}
+
 static int __netconfig_wifi_update_and_get_rssi(void)
 {
        char *if_path = NULL;
@@ -93,22 +99,19 @@ static int __netconfig_wifi_update_and_get_rssi(void)
 
        g_variant_get(value, "a{sv}", &iter);
        while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) {
-               key_value = g_variant_get_int32(variant);
 
                if (g_strcmp0(key, "rssi") == 0) {
+                       key_value = g_variant_get_int32(variant);
                        rssi_dbm = (int)key_value;
                        DBG("Currently signal dbm value [%d]", rssi_dbm);
-                       g_variant_unref(variant);
-                       g_free(key);
-                       break;
+               } else if (g_strcmp0(key, "frequency") == 0) {
+                       netconfig_wifi_freq = g_variant_get_uint32(variant);
+                       DBG("Currently frequency [%u]", netconfig_wifi_freq);
                }
        }
 
        g_variant_iter_free(iter);
 
-       if (value)
-               g_variant_unref(value);
-
        g_variant_unref(message);
 
        g_free(if_path);
@@ -368,6 +371,7 @@ void netconfig_wifi_indicator_start(void)
        INFO("Start Wi-Fi indicator");
 
        netconfig_set_vconf_int(VCONFKEY_WIFI_STRENGTH, VCONFKEY_WIFI_STRENGTH_MAX);
+       __wifi_indicator_monitor(&netconfig_wifi_indicator_timer);
        netconfig_start_timer_seconds(WIFI_INDICATOR_INTERVAL, __wifi_indicator_monitor, NULL, &netconfig_wifi_indicator_timer);
 }
 
@@ -378,4 +382,5 @@ void netconfig_wifi_indicator_stop(void)
        netconfig_stop_timer(&netconfig_wifi_indicator_timer);
 
        netconfig_wifi_rssi = VCONFKEY_WIFI_SNR_MIN;
+       netconfig_wifi_freq = 0;
 }
index 03b5da3..8797213 100755 (executable)
@@ -81,35 +81,6 @@ static void __netconfig_convert_hexstr_to_bytes(gchar* hexstr, int hlen, gchar*
        }
 }
 
-static void __netconfig_convert_bytes_to_hexstr(char* bin, int blen, gchar* hexstr)
-{
-       char t;
-
-       while (blen) {
-               t = (*bin >> 4) & 0x0f;
-
-               if (t >= 0 && t <= 9)
-                       *hexstr = t + '0';
-               else if (t >= 10 && t <= 16)
-                       *hexstr = (t - 10) + 'a';
-
-               hexstr++;
-
-               t = *bin & 0x0f;
-
-               if (t >= 0 && t <= 9)
-                       *hexstr = t + '0';
-               else if (t >= 10 && t <= 16)
-                       *hexstr = (t - 10) + 'a';
-
-               hexstr++;
-               bin++;
-               blen--;
-       }
-
-       *hexstr = '\0';
-}
-
 static int __netconfig_generate_aes_key()
 {
        ckmc_policy_s pol;
@@ -231,7 +202,7 @@ gchar* _netconfig_encrypt_passphrase(const gchar *passphrase)
                return NULL;
        }
 
-       __netconfig_convert_bytes_to_hexstr((char*)ctext->data, ctext->size, encrypted_value);
+       netconfig_convert_bytes_to_hexstr((const char *)ctext->data, ctext->size, encrypted_value);
 
        g_free(origin_value);
 
@@ -349,3 +320,50 @@ gboolean handle_decrypt_passphrase(Wifi *wifi, GDBusMethodInvocation *context, c
        return TRUE;
 }
 
+gboolean handle_decrypt_conf_obj(Wifi *wifi, GDBusMethodInvocation *context,
+               const gchar *enc_connector,
+               const gchar *enc_c_sign_key,
+               const gchar *enc_net_access_key)
+{
+       GVariantBuilder *builder = NULL;
+       gchar *connector = NULL;
+       gchar *c_sign_key = NULL;
+       gchar *net_access_key = NULL;
+
+       DBG("");
+       if (!wifi || !enc_connector || !enc_c_sign_key || !enc_net_access_key) {
+               ERR("Invalid parameter");
+               netconfig_error_invalid_parameter(context);
+               return TRUE;
+       }
+
+       connector = _netconfig_decrypt_passphrase(enc_connector);
+       c_sign_key = _netconfig_decrypt_passphrase(enc_c_sign_key);
+       net_access_key = _netconfig_decrypt_passphrase(enc_net_access_key);
+
+       if (!connector || !c_sign_key || !net_access_key) {
+               ERR("Failed to decrypt the configuration object");
+               netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "OperationFailed");
+               g_free(connector);
+               g_free(c_sign_key);
+               g_free(net_access_key);
+               return TRUE;
+       }
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", "connector",
+                       g_variant_new_string(connector));
+       g_variant_builder_add(builder, "{sv}", "c_sign_key",
+                       g_variant_new_string(c_sign_key));
+       g_variant_builder_add(builder, "{sv}", "net_access_key",
+                       g_variant_new_string(net_access_key));
+
+       wifi_complete_decrypt_conf_obj(wifi, context, g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+       g_free(connector);
+       g_free(c_sign_key);
+       g_free(net_access_key);
+
+       return TRUE;
+}
+
index 7b301fb..60e3a62 100755 (executable)
@@ -129,47 +129,6 @@ static GVariant * __netconfig_wifi_tdls_send_dbus_str(const char* method, const
        return message;
 }
 
-static unsigned char _netconfig_freq_to_channel(int freq)
-{
-       if (freq < 2412 || freq > 5825 ||
-               (freq > 2484 && freq < 5180)) {
-               ERR("Invalid Frequence Range");
-               return 0;
-       }
-       if (freq >= 5180)
-               return 36 + (freq - 5180)/5;
-       else if (freq <= 2472)
-               return 1 + (freq - 2412)/5;
-       else if (freq == 2484)
-               return 14;
-       else
-               return 0;
-}
-
-static unsigned char _netconfig_get_operating_class(int freq)
-{
-       unsigned char channel = 0;
-       unsigned char oper_class = 0;
-
-       channel = _netconfig_freq_to_channel(freq);
-
-       if (channel) {
-               /* Operating class 81 - 2.4 GHz band channels 1..13 */
-               if (channel >= 1 && channel <= 13)
-                       oper_class = 81;
-               /* Operating class 115 - 5 GHz, channels 36-48 */
-               else if (channel >= 36 && channel <= 48)
-                       oper_class = 115;
-               /* Operating class 124 - 5 GHz, channels 149,153,157,161 */
-               else
-                       oper_class = 124;
-
-               INFO("TDLS: Operating Class  is [%d]", oper_class);
-               return oper_class;
-       }
-       return 0;
-}
-
 gboolean handle_tdls_connect(Wifi *wifi, GDBusMethodInvocation *context,
                        gchar *peer_mac_Addr)
 {
@@ -319,7 +278,7 @@ gboolean handle_tdls_channel_switch(Wifi *wifi, GDBusMethodInvocation *context,
                return TRUE;
        }
 
-       oper_class = _netconfig_get_operating_class(freq);
+       oper_class = (unsigned char)netconfig_get_operating_class(freq);
 
        if (!oper_class) {
                ERR("TDLS: Invalid Parameter");
index 8d3303a..2623fbd 100755 (executable)
@@ -46,6 +46,7 @@
 #include "wifi-tdls.h"
 #include "wifi-key-encryption.h"
 #include "wifi-extension.h"
+#include "wifi-dpp.h"
 
 #define SPRD_CP2_FIRMWARE_PATH "/usr/bin/cp2-downloader"
 #define SPRD_CP2_FIRMWARE_STATE_PATH "/tmp/.wifi-firmware-loaded"
@@ -315,6 +316,24 @@ void wifi_object_create_and_init(void)
                        G_CALLBACK(handle_encrypt_passphrase), NULL);
        g_signal_connect(wifi_object, "handle-decrypt-passphrase",
                        G_CALLBACK(handle_decrypt_passphrase), NULL);
+       g_signal_connect(wifi_object, "handle-decrypt-conf-obj",
+                       G_CALLBACK(handle_decrypt_conf_obj), NULL);
+
+       /* DPP */
+       g_signal_connect(wifi_object, "handle-dpp-enter-peer-uri",
+                       G_CALLBACK(handle_dpp_enter_peer_uri), NULL);
+       g_signal_connect(wifi_object, "handle-dpp-generate-uri",
+                       G_CALLBACK(handle_dpp_generate_uri), NULL);
+       g_signal_connect(wifi_object, "handle-dpp-start-configurator-initiator",
+                       G_CALLBACK(handle_dpp_start_configurator_initiator), NULL);
+       g_signal_connect(wifi_object, "handle-dpp-start-enrollee-initiator",
+                       G_CALLBACK(handle_dpp_start_enrollee_initiator), NULL);
+       g_signal_connect(wifi_object, "handle-dpp-start-configurator-responder",
+                       G_CALLBACK(handle_dpp_start_configurator_responder), NULL);
+       g_signal_connect(wifi_object, "handle-dpp-start-enrollee-responder",
+                       G_CALLBACK(handle_dpp_start_enrollee_responder), NULL);
+       g_signal_connect(wifi_object, "handle-dpp-stop",
+                       G_CALLBACK(handle_dpp_stop), NULL);
 
        if (!g_dbus_interface_skeleton_export(interface_wifi, connection,
                        NETCONFIG_WIFI_PATH, NULL)) {