Replace usage of enum 'TETHERING_TYPE_WIFI_SHARING'
[platform/core/api/tethering.git] / src / tethering.c
index 45817c6..0fca757 100755 (executable)
@@ -14,6 +14,7 @@
 * limitations under the License.
 */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -26,8 +27,6 @@
 #include <dbus/dbus.h>
 #include <gio/gio.h>
 #include <vconf.h>
-#include <openssl/evp.h>
-#include <openssl/sha.h>
 #include <ckmc/ckmc-manager.h>
 #include <tzplatform_config.h>
 #include "tethering_private.h"
 #define MAC_ADDR_LEN   18
 #define MAX_BUF_SIZE   80
 
+#ifdef TIZEN_TV_EXT
+#define VCONFKEY_WIFI_TXPOWER  "db/dnet/txpower" /**< VCONFKEY for TX Power */
+#define VCONFKEY_WIFI_CHANNEL  "db/dnet/channel" /**< VCONFKEY for Channel */
+#define VCONFKEY_WIFI_SSID     "db/dnet/ssid"        /**< VCONFKEY for ssid */
+
+#define DBUS_DEFAULT_REPLY_TIMEOUT 15000
+#endif /* TIZEN_TV_EXT */
+
 #define IPTABLES        "/usr/sbin/iptables"
 #define TABLE_NAT       "nat"
 #define TETH_NAT_PRE        "teth_nat_pre"
 #define FILTERING_MULTIPORT_RULE_STR    "-t %s -A %s -p %s -m multiport --dport %d,%d -j %s"
 #define FILTERING_RULE_STR  "-t %s -A %s -p %s --dport %d -j %s"
 
+typedef enum {
+       DUAL_BAND_NONE = 0,                     //0
+       DUAL_BAND_2G = 1 << 0,                  //1
+       DUAL_BAND_5G = 1 << 1,                  //2
+       DUAL_BAND_MIN_INTERFACE = 1 << 2,       //4
+       DUAL_BAND_ALL = 7,                      //7
+} supported_band_e;
+
 static GSList *allowed_list = NULL;
 static GSList *blocked_list = NULL;
 static GSList *port_forwarding = NULL;
@@ -128,11 +143,27 @@ static __tethering_sig_t sigs[] = {
        {0, SIGNAL_NAME_DHCP_STATUS, __handle_dhcp} };
 
 static int retry = 0;
+static int is_dualband_support = DUAL_BAND_NONE;
+
+static void  __reset_dualband_support(void)
+{
+       is_dualband_support = DUAL_BAND_NONE;
+}
+
+static void  __set_dualband_support(int band)
+{
+       is_dualband_support |= band;
+       return;
+}
 
+static gboolean  __is_dualband_support(void)
+{
+       return (is_dualband_support ==  DUAL_BAND_ALL) ? TRUE : FALSE;
+}
 static void __send_dbus_signal(GDBusConnection *conn, const char *signal_name, const char *arg)
 {
        if (conn == NULL || signal_name == NULL)
-               return; //LCOV_EXCL_LINE
+               return;
 
        GVariant *message = NULL;
        GError *error = NULL;
@@ -143,10 +174,9 @@ static void __send_dbus_signal(GDBusConnection *conn, const char *signal_name, c
        g_dbus_connection_emit_signal(conn, NULL, TETHERING_SERVICE_OBJECT_PATH,
                                        TETHERING_SERVICE_INTERFACE, signal_name, message, &error);
        if (error) {
-               ERR("g_dbus_connection_emit_signal is failed because  %s\n", error->message); //LCOV_EXCL_LINE
-               g_error_free(error); //LCOV_EXCL_LINE
+               ERR("g_dbus_connection_emit_signal is failed because  %s\n", error->message);
+               g_error_free(error);
        }
-       g_variant_unref(message);
 }
 
 static bool __any_tethering_is_enabled(tethering_h tethering)
@@ -164,13 +194,14 @@ static tethering_error_e __set_security_type(const tethering_wifi_security_type_
 {
        if (security_type != TETHERING_WIFI_SECURITY_TYPE_NONE &&
                        security_type != TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK &&
-                       security_type != TETHERING_WIFI_SECURITY_TYPE_WPS) {
-               ERR("Invalid param\n"); //LCOV_EXCL_LINE
+                       security_type != TETHERING_WIFI_SECURITY_TYPE_WPS &&
+                       security_type != TETHERING_WIFI_SECURITY_TYPE_SAE) {
+               ERR("Invalid param\n");
                return TETHERING_ERROR_INVALID_PARAMETER;
        }
 
        if (vconf_set_int(VCONFKEY_MOBILE_HOTSPOT_SECURITY, security_type) < 0) {
-               ERR("vconf_set_int is failed\n"); //LCOV_EXCL_LINE
+               ERR("vconf_set_int is failed\n");
                return TETHERING_ERROR_OPERATION_FAILED;
        }
 
@@ -180,13 +211,13 @@ static tethering_error_e __set_security_type(const tethering_wifi_security_type_
 static tethering_error_e __get_security_type(tethering_wifi_security_type_e *security_type)
 {
        if (security_type == NULL) {
-               ERR("Invalid param\n"); //LCOV_EXCL_LINE
+               ERR("Invalid param\n");
                return TETHERING_ERROR_INVALID_PARAMETER;
        }
 
        if (vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_SECURITY,
                                (int *)security_type) < 0) {
-               ERR("vconf_get_int is failed\n"); //LCOV_EXCL_LINE
+               ERR("vconf_get_int is failed\n");
                return TETHERING_ERROR_OPERATION_FAILED;
        }
 
@@ -205,6 +236,9 @@ static bool __get_ssid_from_vconf(const char *path, char *ssid, unsigned int siz
        if (ptr == NULL)
                return false;
 
+       if (!g_strcmp0(ptr, ""))
+               return false;
+
        if (!g_utf8_validate(ptr, -1, (const char **)&ptr_tmp))
                *ptr_tmp = '\0';
 
@@ -217,7 +251,7 @@ static bool __get_ssid_from_vconf(const char *path, char *ssid, unsigned int siz
 static tethering_error_e __set_visible(const bool visible)
 {
        if (vconf_set_int(VCONFKEY_MOBILE_HOTSPOT_HIDE, visible ? 0 : 1) < 0) {
-               ERR("vconf_set_int is failed\n"); //LCOV_EXCL_LINE
+               ERR("vconf_set_int is failed\n");
                return TETHERING_ERROR_OPERATION_FAILED;
        }
 
@@ -227,14 +261,14 @@ static tethering_error_e __set_visible(const bool visible)
 static tethering_error_e __get_visible(bool *visible)
 {
        if (visible == NULL) {
-               ERR("Invalid param\n"); //LCOV_EXCL_LINE
+               ERR("Invalid param\n");
                return TETHERING_ERROR_INVALID_PARAMETER;
        }
 
        int hide = 0;
 
        if (vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_HIDE, &hide) < 0) {
-               ERR("vconf_get_int is failed\n"); //LCOV_EXCL_LINE
+               ERR("vconf_get_int is failed\n");
                return TETHERING_ERROR_OPERATION_FAILED;
        }
 
@@ -272,11 +306,9 @@ static tethering_error_e __get_error(int agent_error)
                err = TETHERING_ERROR_NONE;
                break;
 
-       //LCOV_EXCL_START
        case MOBILE_AP_ERROR_RESOURCE:
                err = TETHERING_ERROR_OUT_OF_MEMORY;
                break;
-       //LCOV_EXCL_STOP
 
        case MOBILE_AP_ERROR_INTERNAL:
                err = TETHERING_ERROR_OPERATION_FAILED;
@@ -286,7 +318,6 @@ static tethering_error_e __get_error(int agent_error)
                err = TETHERING_ERROR_INVALID_PARAMETER;
                break;
 
-       //LCOV_EXCL_START
        case MOBILE_AP_ERROR_ALREADY_ENABLED:
                err = TETHERING_ERROR_OPERATION_FAILED;
                break;
@@ -318,7 +349,6 @@ static tethering_error_e __get_error(int agent_error)
        case MOBILE_AP_ERROR_PERMISSION_DENIED:
                err = TETHERING_ERROR_PERMISSION_DENIED;
                break;
-       //LCOV_EXCL_STOP
        default:
                ERR("Not defined error : %d\n", agent_error);
                err = TETHERING_ERROR_OPERATION_FAILED;
@@ -328,7 +358,6 @@ static tethering_error_e __get_error(int agent_error)
        return err;
 }
 
-//LCOV_EXCL_START
 static void __handle_dhcp(GDBusConnection *connection, const gchar *sender_name,
                const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
                GVariant *parameters, gpointer user_data)
@@ -375,6 +404,9 @@ static void __handle_dhcp(GDBusConnection *connection, const gchar *sender_name,
                goto DONE;
        }
 
+       SINFO("[%s] type %d, ip %s, mac %s, name %s, timestamp %d",
+                buf, ap_type, ip, mac, name, timestamp);
+
        ccb = th->changed_cb[type];
        if (ccb == NULL)
                goto DONE;
@@ -411,6 +443,8 @@ static void __handle_net_closed(GDBusConnection *connection, const gchar *sender
        void *data = NULL;
        tethering_disabled_cause_e code = TETHERING_DISABLED_BY_NETWORK_CLOSE;
 
+       SINFO("Tethering Disabled by network close !");
+
        for (type = TETHERING_TYPE_USB; type <= TETHERING_TYPE_BT; type++) {
                dcb = th->disabled_cb[type];
                if (dcb == NULL)
@@ -422,7 +456,6 @@ static void __handle_net_closed(GDBusConnection *connection, const gchar *sender
 
        DBG("-\n");
 }
-//LCOV_EXCL_STOP
 
 static void __handle_wifi_tether_on(GDBusConnection *connection, const gchar *sender_name,
                        const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
@@ -478,7 +511,6 @@ static void __handle_wifi_tether_off(GDBusConnection *connection, const gchar *s
        DBG("-\n");
 }
 
-//LCOV_EXCL_START
 static void __handle_usb_tether_on(GDBusConnection *connection, const gchar *sender_name,
                        const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
                        GVariant *parameters, gpointer user_data)
@@ -530,7 +562,6 @@ static void __handle_usb_tether_off(GDBusConnection *connection, const gchar *se
        g_free(buf);
        DBG("-\n");
 }
-//LCOV_EXCL_STOP
 
 static void __handle_bt_tether_on(GDBusConnection *connection, const gchar *sender_name,
                        const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
@@ -586,7 +617,6 @@ static void __handle_bt_tether_off(GDBusConnection *connection, const gchar *sen
        DBG("-\n");
 }
 
-//LCOV_EXCL_START
 static void __handle_no_data_timeout(GDBusConnection *connection, const gchar *sender_name,
                        const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
                        GVariant *parameters, gpointer user_data)
@@ -661,7 +691,6 @@ static void __handle_flight_mode(GDBusConnection *connection, const gchar *sende
        }
        DBG("-\n");
 }
-//LCOV_EXCL_STOP
 
 static void __handle_security_type_changed(GDBusConnection *connection, const gchar *sender_name,
                const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
@@ -690,8 +719,10 @@ static void __handle_security_type_changed(GDBusConnection *connection, const gc
                security_type = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
        else if (g_strcmp0(buf, TETHERING_WIFI_SECURITY_TYPE_WPS_STR) == 0)
                security_type = TETHERING_WIFI_SECURITY_TYPE_WPS;
+       else if (g_strcmp0(buf, TETHERING_WIFI_SECURITY_TYPE_SAE_STR) == 0)
+               security_type = TETHERING_WIFI_SECURITY_TYPE_SAE;
        else {
-               SERR("Unknown type : %s\n", buf); //LCOV_EXCL_LINE
+               SERR("Unknown type : %s\n", buf);
                g_free(buf);
                return;
        }
@@ -705,7 +736,7 @@ static void __handle_ssid_visibility_changed(GDBusConnection *connection, const
                const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
                GVariant *parameters, gpointer user_data)
 {
-       DBG("+\n"); //LCOV_EXCL_LINE
+       DBG("+\n");
 
        _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
        __tethering_h *th = (__tethering_h *)user_data;
@@ -717,7 +748,7 @@ static void __handle_ssid_visibility_changed(GDBusConnection *connection, const
 
        scb = th->ssid_visibility_changed_cb;
        if (scb == NULL) {
-               DBG("-\n"); //LCOV_EXCL_LINE
+               DBG("-\n");
                return;
        }
        g_variant_get(parameters, "(s)", &buf);
@@ -727,14 +758,14 @@ static void __handle_ssid_visibility_changed(GDBusConnection *connection, const
 
        scb(visible, data);
        g_free(buf);
-       DBG("-\n"); //LCOV_EXCL_LINE
+       DBG("-\n");
 }
 
 static void __handle_passphrase_changed(GDBusConnection *connection, const gchar *sender_name,
                const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
                GVariant *parameters, gpointer user_data)
 {
-       DBG("+\n"); //LCOV_EXCL_LINE
+       DBG("+\n");
 
        _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
        __tethering_h *th = (__tethering_h *)user_data;
@@ -749,67 +780,69 @@ static void __handle_passphrase_changed(GDBusConnection *connection, const gchar
        data = th->passphrase_user_data;
 
        pcb(data);
-       DBG("-\n"); //LCOV_EXCL_LINE
+       DBG("-\n");
 }
 
 static void __wifi_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
                gpointer user_data)
 {
-       INFO("+\n"); //LCOV_EXCL_LINE
+       INFO("+\n");
 
        _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
        GError *g_error = NULL;
        GVariant *g_var;
        guint info;
+       tethering_type_e type = TETHERING_TYPE_WIFI;
        tethering_error_e error;
        __tethering_h *th = (__tethering_h *)user_data;
-       tethering_enabled_cb ecb = th->enabled_cb[TETHERING_TYPE_WIFI];
-       void *data = th->enabled_user_data[TETHERING_TYPE_WIFI];
+
+       tethering_enabled_cb ecb = th->enabled_cb[type];
+       void *data = th->enabled_user_data[type];
 
        if (!_tethering_check_handle((tethering_h)user_data))
                return;
 
        g_var  = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
        if (g_error) {
-               //LCOV_EXCL_START
                ERR("DBus error [%s]\n", g_error->message);
                if (g_error->code == G_DBUS_ERROR_NO_REPLY &&
                                ++retry < TETHERING_ERROR_RECOVERY_MAX) {
                        g_error_free(g_error);
-                       tethering_enable((tethering_h)th, TETHERING_TYPE_WIFI);
+                       tethering_enable((tethering_h)th, type);
                        return;
                } else if (g_error->code == G_DBUS_ERROR_ACCESS_DENIED)
                        error = TETHERING_ERROR_PERMISSION_DENIED;
                else
                        error = TETHERING_ERROR_OPERATION_FAILED;
                g_error_free(g_error);
-               //LCOV_EXCL_STOP
        } else {
                g_variant_get(g_var, "(u)", &info);
                error = __get_error(info);
        }
        retry = 0;
 
-       INFO("cfm event : wifi tethering enable info : %d\n", error); //LCOV_EXCL_LINE
+       INFO("cfm event : wifi tethering enable info : %d\n", error);
 
        sigs[E_SIGNAL_WIFI_TETHER_ON].sig_id = g_dbus_connection_signal_subscribe(th->client_bus,
                        NULL, TETHERING_SERVICE_INTERFACE, sigs[E_SIGNAL_WIFI_TETHER_ON].name,
                        TETHERING_SERVICE_OBJECT_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
                        sigs[E_SIGNAL_WIFI_TETHER_ON].cb, (gpointer)th, NULL);
 
+       SINFO("Tethering enabled event ! error(%d)", error);
+
        if (!ecb) {
-               INFO("-\n"); //LCOV_EXCL_LINE
+               INFO("-\n");
                return;
        }
-       ecb(error, TETHERING_TYPE_WIFI, true, data);
+       ecb(error, type, true, data);
        g_variant_unref(g_var);
-       INFO("-\n"); //LCOV_EXCL_LINE
+       INFO("-\n");
 }
 
 static void __bt_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
                gpointer user_data)
 {
-       DBG("+\n"); //LCOV_EXCL_LINE
+       DBG("+\n");
        _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
        GError *g_error = NULL;
        GVariant *g_var;
@@ -825,7 +858,6 @@ static void __bt_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
 
        g_var  = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
        if (g_error) {
-               //LCOV_EXCL_START
                ERR("DBus error [%s]\n", g_error->message);
                if (g_error->code == G_DBUS_ERROR_NO_REPLY &&
                                ++retry < TETHERING_ERROR_RECOVERY_MAX) {
@@ -839,7 +871,6 @@ static void __bt_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
                else
                        error = TETHERING_ERROR_OPERATION_FAILED;
                g_error_free(g_error);
-               //LCOV_EXCL_STOP
        } else {
                g_variant_get(g_var, "(u)", &info);
                g_variant_unref(g_var);
@@ -853,7 +884,7 @@ static void __bt_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
                        sigs[E_SIGNAL_BT_TETHER_ON].cb, (gpointer)th, NULL);
 
        if (!ecb) {
-               DBG("-\n"); //LCOV_EXCL_LINE
+               DBG("-\n");
                return;
        }
 
@@ -861,7 +892,6 @@ static void __bt_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        DBG("-\n");
 }
 
-//LCOV_EXCL_START
 static void __usb_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
                                        gpointer user_data)
 {
@@ -962,12 +992,11 @@ static void __p2p_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        ecb(error, TETHERING_TYPE_P2P, true, data);
        DBG("-\n");
 }
-//LCOV_EXCL_STOP
 
 static void __disabled_cfm_cb(GObject *source_object, GAsyncResult *res,
                gpointer user_data)
 {
-       INFO("+\n"); //LCOV_EXCL_LINE
+       INFO("+\n");
 
        _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
        GError *g_error = NULL;
@@ -986,11 +1015,9 @@ static void __disabled_cfm_cb(GObject *source_object, GAsyncResult *res,
 
        g_var  = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
        if (g_error) {
-               //LCOV_EXCL_START
                ERR("DBus error [%s]\n", g_error->message);
                g_error_free(g_error);
                return;
-               //LCOV_EXCL_STOP
        }
        g_variant_get(g_var, "(uu)", &event_type, &info);
        INFO("cfm event : %d info : %d\n", event_type, info);
@@ -1024,7 +1051,6 @@ static void __disabled_cfm_cb(GObject *source_object, GAsyncResult *res,
                        dcb(error, type, code, data);
                break;
 
-       //LCOV_EXCL_START
        case MOBILE_AP_DISABLE_USB_TETHERING_CFM:
                sigs[E_SIGNAL_USB_TETHER_OFF].sig_id = g_dbus_connection_signal_subscribe(th->client_bus,
                                NULL, TETHERING_SERVICE_INTERFACE, sigs[E_SIGNAL_USB_TETHER_OFF].name,
@@ -1074,9 +1100,8 @@ static void __disabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        default:
                ERR("Invalid event\n");
                break;
-       //LCOV_EXCL_STOP
        }
-       INFO("-\n"); //LCOV_EXCL_LINE
+       INFO("-\n");
 }
 
 static void __get_data_usage_cb(GObject *source_object, GAsyncResult *res,
@@ -1096,7 +1121,6 @@ static void __get_data_usage_cb(GObject *source_object, GAsyncResult *res,
 
        g_var = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
        if (g_error) {
-               //LCOV_EXCL_START
                ERR("DBus fail [%s]\n", g_error->message);
                if (g_error->code == G_DBUS_ERROR_ACCESS_DENIED)
                        tethering_error = TETHERING_ERROR_PERMISSION_DENIED;
@@ -1104,10 +1128,9 @@ static void __get_data_usage_cb(GObject *source_object, GAsyncResult *res,
                        tethering_error = TETHERING_ERROR_OPERATION_FAILED;
 
                flag = true;
-               //LCOV_EXCL_STOP
        }
        if (th->data_usage_cb == NULL) {
-               ERR("There is no data_usage_cb\n"); //LCOV_EXCL_LINE
+               ERR("There is no data_usage_cb\n");
                return;
        }
        if (flag) {
@@ -1138,21 +1161,23 @@ static void __settings_reloaded_cb(GObject *source_object, GAsyncResult *res,
 
        g_var  = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
        if (g_error) {
-               ERR("DBus fail [%s]\n", g_error->message); //LCOV_EXCL_LINE
+               ERR("DBus fail [%s]\n", g_error->message);
                if (g_error->code == G_DBUS_ERROR_ACCESS_DENIED)
                        tethering_error = TETHERING_ERROR_PERMISSION_DENIED;
                else
                        tethering_error = TETHERING_ERROR_OPERATION_FAILED;
                g_error_free(g_error);
+       } else {
+               g_variant_get(g_var, "(u)", &info);
+               if (tethering_error == TETHERING_ERROR_NONE)
+                       tethering_error = __get_error(info);
+               g_variant_unref(g_var);
        }
+
        if (th->settings_reloaded_cb == NULL) {
                DBG("There is no settings_reloaded_cb\n-\n");
                return;
        }
-       g_variant_get(g_var, "(u)", &info);
-       if (tethering_error == TETHERING_ERROR_NONE)
-               tethering_error = __get_error(info);
-       g_variant_unref(g_var);
 
        th->settings_reloaded_cb(tethering_error,
                        th->settings_reloaded_user_data);
@@ -1203,24 +1228,21 @@ static bool __get_intf_name(tethering_type_e type, char *buf, unsigned int len)
        _retvm_if(buf == NULL, false, "parameter(buf) is NULL\n");
 
        switch (type) {
-       //LCOV_EXCL_START
        case TETHERING_TYPE_USB:
                g_strlcpy(buf, TETHERING_USB_IF, len);
                break;
-       //LCOV_EXCL_STOP
        case TETHERING_TYPE_WIFI:
                g_strlcpy(buf, TETHERING_WIFI_IF, len);
                break;
-
        case TETHERING_TYPE_BT:
                g_strlcpy(buf, TETHERING_BT_IF, len);
                break;
-
-       //LCOV_EXCL_START
+       case TETHERING_TYPE_P2P:
+               g_strlcpy(buf, TETHERING_P2P_IF, len);
+               break;
        default:
                ERR("Not supported type : %d\n", type);
                return false;
-       //LCOV_EXCL_STOP
        }
        return true;
 }
@@ -1230,23 +1252,21 @@ static bool __get_gateway_addr(tethering_type_e type, char *buf, unsigned int le
        _retvm_if(buf == NULL, false, "parameter(buf) is NULL\n");
 
        switch (type) {
-       //LCOV_EXCL_START
        case TETHERING_TYPE_USB:
                g_strlcpy(buf, TETHERING_USB_GATEWAY, len);
                break;
-       //LCOV_EXCL_STOP
        case TETHERING_TYPE_WIFI:
                g_strlcpy(buf, TETHERING_WIFI_GATEWAY, len);
                break;
-
        case TETHERING_TYPE_BT:
                g_strlcpy(buf, TETHERING_BT_GATEWAY, len);
                break;
-       //LCOV_EXCL_START
+       case TETHERING_TYPE_P2P:
+               g_strlcpy(buf, TETHERING_P2P_GATEWAY, len);
+               break;
        default:
                ERR("Not supported type : %d\n", type);
                return false;
-       //LCOV_EXCL_STOP
        }
        return true;
 }
@@ -1254,24 +1274,22 @@ static bool __get_gateway_addr(tethering_type_e type, char *buf, unsigned int le
 static int __get_common_ssid(char *ssid, unsigned int size)
 {
        if (ssid == NULL) {
-               ERR("ssid is null\n"); //LCOV_EXCL_LINE
+               ERR("ssid is null\n");
                return TETHERING_ERROR_INVALID_PARAMETER;
        }
 
-       char *ptr = NULL;
-       char *ptr_tmp = NULL;
+#ifdef TIZEN_TV_EXT
+       if (__get_ssid_from_vconf(VCONFKEY_WIFI_SSID, ssid, size))
+               return TETHERING_ERROR_NONE;
+       else
+               ERR("vconf key get failed for ssid or invalid ssid is found");
+#endif /* TIZEN_TV_EXT */
 
-       ptr = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
-       if (ptr == NULL) {
+       if (__get_ssid_from_vconf(VCONFKEY_SETAPPL_DEVICE_NAME_STR,
+                               ssid, size) == false) {
                ERR("vconf_get_str is failed and set default ssid");
                g_strlcpy(ssid, TETHERING_DEFAULT_SSID, size);
-       } else
-               g_strlcpy(ssid, ptr, size);
-
-       free(ptr);
-
-       if (!g_utf8_validate(ssid, -1, (const char **)&ptr_tmp))
-               *ptr_tmp = '\0';
+       }
 
        return TETHERING_ERROR_NONE;
 }
@@ -1309,7 +1327,7 @@ static int __prepare_wifi_settings(tethering_h tethering, _softap_settings_t *se
        char *ptr = NULL;
 
        if (th == NULL || set == NULL) {
-               ERR("null parameter\n-\n"); //LCOV_EXCL_LINE
+               ERR("null parameter\n-\n");
                return TETHERING_ERROR_INVALID_PARAMETER;
        }
 
@@ -1329,6 +1347,7 @@ static int __prepare_wifi_settings(tethering_h tethering, _softap_settings_t *se
        set->mac_filter = th->mac_filter;
        set->max_connected = th->wifi_max_connected;
        set->channel = th->channel;
+       set->txpower = th->txpower;
 
        __get_wifi_mode_type(th->mode_type, &ptr);
        if (ptr == NULL) {
@@ -1351,7 +1370,6 @@ static int __prepare_wifi_settings(tethering_h tethering, _softap_settings_t *se
                                NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
 
                if (error) {
-                       //LCOV_EXCL_START
                        ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                        if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -1361,7 +1379,6 @@ static int __prepare_wifi_settings(tethering_h tethering, _softap_settings_t *se
 
                        g_error_free(error);
                        return ret;
-                       //LCOV_EXCL_STOP
                }
 
                if (parameters != NULL) {
@@ -1379,7 +1396,7 @@ static int __prepare_wifi_settings(tethering_h tethering, _softap_settings_t *se
        return TETHERING_ERROR_NONE;
 }
 
-static bool __check_precondition(tethering_type_e type)
+static bool __check_precondition(__tethering_h *th, tethering_type_e type)
 {
        int dnet_status = 0;
        int cellular_state = 0;
@@ -1395,6 +1412,8 @@ static bool __check_precondition(tethering_type_e type)
        vconf_get_int(VCONFKEY_NETWORK_STATUS, &dnet_status);
        if ((dnet_status == VCONFKEY_NETWORK_WIFI
                        && type != TETHERING_TYPE_WIFI)
+               || (th->wifi_sharing && dnet_status == VCONFKEY_NETWORK_WIFI
+                       && type == TETHERING_TYPE_WIFI)
                || dnet_status == VCONFKEY_NETWORK_ETHERNET)
                return TRUE;
 
@@ -1402,6 +1421,32 @@ static bool __check_precondition(tethering_type_e type)
        return FALSE;
 }
 
+#ifdef TIZEN_TV_EXT
+static void __set_vconf_values_for_tv(__tethering_h *tethering)
+{
+       int ret, channel, txpower;
+       __tethering_h *th = tethering;
+
+       if (th == NULL)
+               return;
+
+       ret = vconf_get_int(VCONFKEY_WIFI_CHANNEL, &channel);
+       if (ret < 0) {
+               ERR("vconf key get failed for channel !!");
+               channel = TETHERING_WIFI_CHANNEL;
+       }
+
+       ret = vconf_get_int(VCONFKEY_WIFI_TXPOWER, &txpower);
+       if (ret < 0) {
+               ERR("vconf key get failed for txpower !!");
+               txpower = TETHERING_WIFI_MAX_TXPOWER;
+       }
+
+       th->channel = channel;
+       th->txpower = txpower;
+}
+#endif /* TIZEN_TV_EXT */
+
 /**
  * @internal
  * @brief  Creates the handle of tethering.
@@ -1436,41 +1481,44 @@ API int tethering_create(tethering_h *tethering)
        th->sec_type = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
        th->visibility = true;
        th->mac_filter = false;
+       th->wifi_sharing = false;
        th->channel = TETHERING_WIFI_CHANNEL;
        th->mode_type = TETHERING_WIFI_MODE_TYPE_G;
        th->wifi_max_connected = TETHERING_WIFI_MAX_STA;
+       th->txpower = TETHERING_WIFI_MAX_TXPOWER;
 
        if (__generate_initial_passphrase(th->passphrase,
                        sizeof(th->passphrase)) == 0) {
-               //LCOV_EXCL_START
                ERR("random passphrase generation failed\n");
                free(th);
                return TETHERING_ERROR_OPERATION_FAILED;
-               //LCOV_EXCL_STOP
        }
 
        if (__get_common_ssid(ssid, sizeof(ssid)) != TETHERING_ERROR_NONE) {
-               //LCOV_EXCL_START
                ERR("common ssid get failed\n");
                free(th);
                return TETHERING_ERROR_OPERATION_FAILED;
-               //LCOV_EXCL_STOP
        }
 
+#ifdef TIZEN_TV_EXT
+       __set_vconf_values_for_tv(th);
+#endif /* TIZEN_TV_EXT */
+       SINFO("ssid: %s, key: %s, channel: %d, mode: %d, txpower: %d, security: %d max_device: %d\n",
+                ssid, th->passphrase, th->channel, th->mode_type, th->txpower, th->sec_type,
+                th->wifi_max_connected);
+
 #if !GLIB_CHECK_VERSION(2, 36, 0)
        g_type_init();
 #endif
        GCancellable *cancellable = g_cancellable_new();
        th->client_bus = g_bus_get_sync(DBUS_BUS_SYSTEM, cancellable, &error);
        if (error) {
-               //LCOV_EXCL_START
                ERR("Couldn't connect to the System bus[%s]", error->message);
                g_error_free(error);
                g_cancellable_cancel(cancellable);
                g_object_unref(cancellable);
                free(th);
                return TETHERING_ERROR_OPERATION_FAILED;
-               //LCOV_EXCL_STOP
        }
        th->cancellable = cancellable;
 
@@ -1478,7 +1526,6 @@ API int tethering_create(tethering_h *tethering)
                        NULL, TETHERING_SERVICE_NAME, TETHERING_SERVICE_OBJECT_PATH,
                        TETHERING_SERVICE_INTERFACE, th->cancellable, &error);
        if (!th->client_bus_proxy) {
-               //LCOV_EXCL_START
                if (error)
                        ERR("Couldn't create the proxy object because of %s\n", error->message);
                g_cancellable_cancel(th->cancellable);
@@ -1486,7 +1533,6 @@ API int tethering_create(tethering_h *tethering)
                g_object_unref(th->client_bus);
                free(th);
                return TETHERING_ERROR_OPERATION_FAILED;
-               //LCOV_EXCL_STOP
        }
 
        __connect_signals((tethering_h)th);
@@ -1569,18 +1615,19 @@ API int tethering_enable(tethering_h tethering, tethering_type_e type)
        GDBusProxy *proxy = th->client_bus_proxy;
        GDBusConnection *connection = th->client_bus;
 
+#ifdef TIZEN_TV_EXT
+       g_dbus_proxy_set_default_timeout(proxy, DBUS_DEFAULT_REPLY_TIMEOUT);
+#else /* TIZEN_TV_EXT */
        g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_INFINITE);
+#endif /* TIZEN_TV_EXT */
 
-       if (__check_precondition(type) == FALSE) {
-               //LCOV_EXCL_START
+       if (__check_precondition(th, type) == FALSE) {
                INFO("-\n");
                g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_USE_DEFAULT);
                return TETHERING_ERROR_OPERATION_FAILED;
-               //LCOV_EXCL_STOP
        }
 
        switch (type) {
-       //LCOV_EXCL_START
        case TETHERING_TYPE_USB:
                g_dbus_connection_signal_unsubscribe(connection,
                                sigs[E_SIGNAL_USB_TETHER_ON].sig_id);
@@ -1590,24 +1637,32 @@ API int tethering_enable(tethering_h tethering, tethering_type_e type)
                                G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                                (GAsyncReadyCallback) __usb_enabled_cfm_cb, (gpointer)tethering);
                break;
-       //LCOV_EXCL_STOP
 
        case TETHERING_TYPE_WIFI: {
                _softap_settings_t set = {"", "", "", 0, false};
 
                ret = __prepare_wifi_settings(tethering, &set);
                if (ret != TETHERING_ERROR_NONE) {
-                       //LCOV_EXCL_START
                        ERR("softap settings initialization failed\n");
                        DBG("-\n");
                        return TETHERING_ERROR_OPERATION_FAILED;
-                       //LCOV_EXCL_STOP
                }
                g_dbus_connection_signal_unsubscribe(connection,
                                sigs[E_SIGNAL_WIFI_TETHER_ON].sig_id);
 
+               SINFO("ssid %s, key %s, channel %d, mode %s, txpower %d, security %d max_device %d\n",
+                        set.ssid, set.key, set.channel, set.mode, set.txpower, set.sec_type,
+                        set.max_connected);
+
+               char key[TETHERING_WIFI_KEY_MAX_LEN + 1] = "wifi_tether";
+               if (th->wifi_sharing)
+                       g_strlcpy(key, "wifi_sharing", TETHERING_WIFI_KEY_MAX_LEN + 1);
+
+               SINFO("enable_wifi_tethering key: %s", key);
                g_dbus_proxy_call(proxy, "enable_wifi_tethering",
-                               g_variant_new("(sssiiiiii)", set.ssid, set.key, set.mode, set.channel, set.visibility, set.mac_filter, set.max_connected, set.sec_type, TETHERING_ADDRESS_FAMILY_IPV4),
+                               g_variant_new("(ssssiiiiiii)", key, set.ssid, set.key, set.mode,
+                               set.channel, set.visibility, set.mac_filter, set.max_connected,
+                               set.sec_type, set.txpower, TETHERING_ADDRESS_FAMILY_IPV4),
                                G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                                (GAsyncReadyCallback) __wifi_enabled_cfm_cb, (gpointer)tethering);
                break;
@@ -1624,7 +1679,6 @@ API int tethering_enable(tethering_h tethering, tethering_type_e type)
 
                break;
 
-       //LCOV_EXCL_START
        case TETHERING_TYPE_P2P: {
                _softap_settings_t p2p_set = {"", "", "", 0, false};
                ret = __prepare_wifi_settings(tethering, &p2p_set);
@@ -1666,9 +1720,9 @@ API int tethering_enable(tethering_h tethering, tethering_type_e type)
                                sigs[E_SIGNAL_WIFI_TETHER_ON].sig_id);
 
                g_dbus_proxy_call(proxy, "enable_wifi_tethering",
-                               g_variant_new("(sssiiiiii)", set.ssid, set.key, set.mode,
+                               g_variant_new("(ssssiiiiiii)", "wifi_tether", set.ssid, set.key, set.mode,
                                set.channel, set.visibility, set.mac_filter, set.max_connected,
-                               set.sec_type, TETHERING_ADDRESS_FAMILY_IPV4),
+                               set.sec_type, set.txpower, TETHERING_ADDRESS_FAMILY_IPV4),
                                G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                                (GAsyncReadyCallback) __wifi_enabled_cfm_cb, (gpointer)tethering);
 
@@ -1690,7 +1744,6 @@ API int tethering_enable(tethering_h tethering, tethering_type_e type)
                DBG("-\n");
                return TETHERING_ERROR_INVALID_PARAMETER;
        }
-       //LCOV_EXCL_STOP
 
        g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_USE_DEFAULT);
        INFO("-\n");
@@ -1715,12 +1768,10 @@ API int tethering_ipv6_enable(tethering_h tethering, tethering_type_e type)
 
        g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_INFINITE);
 
-       if (__check_precondition(type) == FALSE) {
-               //LCOV_EXCL_START
+       if (__check_precondition(th, type) == FALSE) {
                DBG("-\n");
                g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_USE_DEFAULT);
                return TETHERING_ERROR_OPERATION_FAILED;
-               //LCOV_EXCL_STOP
        }
 
        switch (type) {
@@ -1747,8 +1798,20 @@ API int tethering_ipv6_enable(tethering_h tethering, tethering_type_e type)
                }
                g_dbus_connection_signal_unsubscribe(connection,
                                sigs[E_SIGNAL_WIFI_TETHER_ON].sig_id);
-                       g_dbus_proxy_call(proxy, "enable_wifi_tethering",
-                               g_variant_new("(sssiiiiii)", set.ssid, set.key, set.mode, set.channel, set.visibility, set.mac_filter, set.max_connected, set.sec_type, TETHERING_ADDRESS_FAMILY_IPV6),
+
+               SINFO("ssid %s, key %s, channel %d, mode %s, txpower %d, security %d max_device %d\n",
+                       set.ssid, set.key, set.channel, set.mode, set.txpower, set.sec_type,
+                       set.max_connected);
+
+               char key[TETHERING_WIFI_KEY_MAX_LEN + 1] = "wifi_tether";
+               if (th->wifi_sharing)
+                       g_strlcpy(key, "wifi_sharing", TETHERING_WIFI_KEY_MAX_LEN + 1);
+
+               SINFO("enable_wifi_tethering key: %s", key);
+               g_dbus_proxy_call(proxy, "enable_wifi_tethering",
+                               g_variant_new("(ssssiiiiiii)", key, set.ssid, set.key, set.mode,
+                               set.channel, set.visibility, set.mac_filter, set.max_connected,
+                               set.sec_type, set.txpower, TETHERING_ADDRESS_FAMILY_IPV6),
                                G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                                (GAsyncReadyCallback) __wifi_enabled_cfm_cb, (gpointer)tethering);
                break;
@@ -1867,7 +1930,6 @@ API int tethering_disable(tethering_h tethering, tethering_type_e type)
        GDBusConnection *connection = th->client_bus;
 
        switch (type) {
-       //LCOV_EXCL_START
        case TETHERING_TYPE_USB:
                g_dbus_connection_signal_unsubscribe(connection,
                                sigs[E_SIGNAL_USB_TETHER_OFF].sig_id);
@@ -1878,15 +1940,15 @@ API int tethering_disable(tethering_h tethering, tethering_type_e type)
                                (GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
 
                break;
-       //LCOV_EXCL_STOP
 
        case TETHERING_TYPE_WIFI:
-
                g_dbus_connection_signal_unsubscribe(connection,
                                sigs[E_SIGNAL_WIFI_TETHER_OFF].sig_id);
 
+               SINFO("Disable Wi-Fi Tethering !");
+
                g_dbus_proxy_call(proxy, "disable_wifi_tethering",
-                               g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV4),
+                               g_variant_new("(ii)", TETHERING_ADDRESS_FAMILY_IPV4, th->mode_type),
                                G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                                (GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
                break;
@@ -1902,7 +1964,6 @@ API int tethering_disable(tethering_h tethering, tethering_type_e type)
                                (GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
                break;
 
-       //LCOV_EXCL_START
        case TETHERING_TYPE_P2P:
                g_dbus_proxy_call(proxy, "disable_p2p_tethering",
                                NULL, G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
@@ -1939,7 +2000,6 @@ API int tethering_disable(tethering_h tethering, tethering_type_e type)
                ERR("Not supported tethering type [%d]\n", type);
                DBG("-\n");
                return TETHERING_ERROR_INVALID_PARAMETER;
-       //LCOV_EXCL_STOP
        }
        INFO("-\n");
        return TETHERING_ERROR_NONE;
@@ -2014,9 +2074,9 @@ API bool tethering_is_enabled(tethering_h tethering, tethering_type_e type)
 API int tethering_get_mac_address(tethering_h tethering, tethering_type_e type, char **mac_address)
 {
        CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
-       if (type == TETHERING_TYPE_USB) CHECK_FEATURE_SUPPORTED(TETHERING_USB_FEATURE); //LCOV_EXCL_LINE
+       if (type == TETHERING_TYPE_USB) CHECK_FEATURE_SUPPORTED(TETHERING_USB_FEATURE);
        else if (type == TETHERING_TYPE_WIFI) CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
-       else if (type == TETHERING_TYPE_BT) CHECK_FEATURE_SUPPORTED(TETHERING_BT_FEATURE); //LCOV_EXCL_LINE
+       else if (type == TETHERING_TYPE_BT) CHECK_FEATURE_SUPPORTED(TETHERING_BT_FEATURE);
 
        _retvm_if(tethering_is_enabled(tethering, type) == false,
                        TETHERING_ERROR_NOT_ENABLED,
@@ -2038,11 +2098,9 @@ API int tethering_get_mac_address(tethering_h tethering, tethering_type_e type,
        _retvm_if(s < 0, TETHERING_ERROR_OPERATION_FAILED,
                        "getting socket is failed\n");
        if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) {
-               //LCOV_EXCL_START
                ERR("getting mac is failed\n");
                close(s);
                return TETHERING_ERROR_OPERATION_FAILED;
-               //LCOV_EXCL_STOP
        }
        close(s);
 
@@ -2133,9 +2191,9 @@ API int tethering_get_network_interface_name(tethering_h tethering, tethering_ty
 API int tethering_get_ip_address(tethering_h tethering, tethering_type_e type, tethering_address_family_e address_family, char **ip_address)
 {
        CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
-       if (type == TETHERING_TYPE_USB) CHECK_FEATURE_SUPPORTED(TETHERING_USB_FEATURE); //LCOV_EXCL_LINE
+       if (type == TETHERING_TYPE_USB) CHECK_FEATURE_SUPPORTED(TETHERING_USB_FEATURE);
        else if (type == TETHERING_TYPE_WIFI) CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
-       else if (type == TETHERING_TYPE_BT) CHECK_FEATURE_SUPPORTED(TETHERING_BT_FEATURE); //LCOV_EXCL_LINE
+       else if (type == TETHERING_TYPE_BT) CHECK_FEATURE_SUPPORTED(TETHERING_BT_FEATURE);
 
        _retvm_if(tethering_is_enabled(tethering, type) == false,
                        TETHERING_ERROR_NOT_ENABLED,
@@ -2321,6 +2379,72 @@ API int tethering_get_data_usage(tethering_h tethering, tethering_data_usage_cb
  * @see  tethering_is_enabled()
  * @see  tethering_enable()
  */
+
+API int tethering_is_dualband_supported(tethering_h tethering, tethering_type_e type, bool *supported)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+       CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+
+       __tethering_h *th = (__tethering_h *)tethering;
+       gchar *if_name = NULL;
+       gboolean Is2GBandSupported = FALSE;
+       gboolean Is5GBandSupported = FALSE;
+       GError *error = NULL;
+       GVariant *result = NULL;
+       GVariantIter *outer_iter = NULL;
+       GVariantIter *inner_iter = NULL;
+       GVariant *station = NULL;
+       GVariant *value = NULL;
+       gchar *key = NULL;
+       int count = 0;
+
+       DBG("+");
+       __reset_dualband_support();
+       result = g_dbus_proxy_call_sync(th->client_bus_proxy, "get_wifi_interfaces",
+                       NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+       if (error) {
+               ERR("g_dbus_proxy_call_sync is failed and error is %s\n", error->message);
+               g_error_free(error);
+               return TETHERING_ERROR_OPERATION_FAILED;
+       }
+       g_variant_get(result, "(a(a{sv}))", &outer_iter);
+       while (g_variant_iter_loop(outer_iter, "(@a{sv})", &station)) {
+               g_variant_get(station, "a{sv}", &inner_iter);
+               while (g_variant_iter_loop(inner_iter, "{sv}", &key, &value)) {
+                       if (g_strcmp0(key, "IfName") == 0) {
+                               g_variant_get(value, "s", &if_name);
+                               SDBG("Interface Name is %s\n", if_name);
+                       } else if (g_strcmp0(key, "Is2GBandSupported") == 0) {
+                               Is2GBandSupported = g_variant_get_boolean(value);
+                               SDBG("Is2GBandSupported  is %d\n", Is2GBandSupported);
+                               if (Is2GBandSupported)
+                                       __set_dualband_support(DUAL_BAND_2G);
+                       } else if (g_strcmp0(key, "Is5GBandSupported") == 0) {
+                               Is5GBandSupported = g_variant_get_boolean(value);
+                               SDBG("Is5GBandSupported  is %d\n", Is5GBandSupported);
+                               if (Is5GBandSupported)
+                                       __set_dualband_support(DUAL_BAND_5G);
+                       } else {
+                               ERR("Key %s not required\n", key);
+                       }
+               }
+               count++;
+
+               g_variant_iter_free(inner_iter);
+       }
+       if (count >= 2)
+               __set_dualband_support(DUAL_BAND_MIN_INTERFACE);
+       *supported =  __is_dualband_support();
+       DBG("count:%d is dualband suppport: %d", count, *supported);
+       g_variant_iter_free(outer_iter);
+       g_variant_unref(result);
+       DBG("-\n");
+       return TETHERING_ERROR_NONE;
+}
 API int tethering_foreach_connected_clients(tethering_h tethering, tethering_type_e type, tethering_connected_client_cb callback, void *user_data)
 {
        CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
@@ -2337,6 +2461,7 @@ API int tethering_foreach_connected_clients(tethering_h tethering, tethering_typ
                        "tethering is not enabled\n");
 
        mobile_ap_type_e interface;
+       tethering_band_e band;
        __tethering_h *th = (__tethering_h *)tethering;
        __tethering_client_h client = {0, };
        gchar *ip = NULL;
@@ -2354,10 +2479,14 @@ API int tethering_foreach_connected_clients(tethering_h tethering, tethering_typ
        result = g_dbus_proxy_call_sync(th->client_bus_proxy, "get_station_info",
                        NULL, G_DBUS_CALL_FLAGS_NONE,
                        -1, th->cancellable, &error);
-       if (error)
-               ERR("g_dbus_proxy_call_sync is failed and error is %s\n", error->message); //LCOV_EXCL_LINE
+
+       if (error) {
+               ERR("g_dbus_proxy_call_sync is failed and error is %s\n", error->message);
+               g_error_free(error);
+               return TETHERING_ERROR_OPERATION_FAILED;
+       }
+
        g_variant_get(result, "(a(a{sv}))", &outer_iter);
-       //LCOV_EXCL_START
        while (g_variant_iter_loop(outer_iter, "(@a{sv})", &station)) {
                g_variant_get(station, "a{sv}", &inner_iter);
                while (g_variant_iter_loop(inner_iter, "{sv}", &key, &value)) {
@@ -2400,6 +2529,10 @@ API int tethering_foreach_connected_clients(tethering_h tethering, tethering_typ
                                timestamp = g_variant_get_int32(value);
                                DBG("timestamp is %d\n", timestamp);
                                client.tm = (time_t)timestamp;
+                       } else if (g_strcmp0(key, "Band") == 0) {
+                               band = g_variant_get_int32(value);
+                               client.band = (!band) ? TETHERING_WIFI_BAND_2G : TETHERING_WIFI_BAND_5G;
+                               SDBG("band type %d\n", band);
                        } else {
                                ERR("Key %s not required\n", key);
                        }
@@ -2413,12 +2546,16 @@ API int tethering_foreach_connected_clients(tethering_h tethering, tethering_typ
                mac = NULL;
 
                g_variant_iter_free(inner_iter);
+               if ((th->mode_type == 0 || th->mode_type == 1) && client.band != TETHERING_WIFI_BAND_2G) //if band is not for 2g continue
+                       continue;
+               if ((th->mode_type == 2 || th->mode_type == 3) && client.band != TETHERING_WIFI_BAND_5G) //if band is not for 5g continue
+                       continue;
+               SDBG("mode_type: %d and client.band: %d ", th->mode_type, client.band);
                if (callback((tethering_client_h)&client, user_data) == false) {
                        DBG("iteration is stopped\n");
                        g_free(client.hostname);
                        client.hostname = NULL;
                        g_variant_iter_free(outer_iter);
-                       g_variant_unref(station);
                        g_variant_unref(result);
                        DBG("-\n");
                        return TETHERING_ERROR_OPERATION_FAILED;
@@ -2426,9 +2563,7 @@ API int tethering_foreach_connected_clients(tethering_h tethering, tethering_typ
                g_free(client.hostname);
                client.hostname = NULL;
        }
-       //LCOV_EXCL_STOP
        g_variant_iter_free(outer_iter);
-       g_variant_unref(station);
        g_variant_unref(result);
        DBG("-\n");
        return TETHERING_ERROR_NONE;
@@ -2472,7 +2607,7 @@ API int tethering_set_enabled_cb(tethering_h tethering, tethering_type_e type, t
        }
 
        /* TETHERING_TYPE_ALL */
-       for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_P2P; ti++) {
+       for (ti = TETHERING_TYPE_USB; ti < TETHERING_TYPE_MAX; ti++) {
                th->enabled_cb[ti] = callback;
                th->enabled_user_data[ti] = user_data;
        }
@@ -2514,7 +2649,7 @@ API int tethering_unset_enabled_cb(tethering_h tethering, tethering_type_e type)
        }
 
        /* TETHERING_TYPE_ALL */
-       for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_P2P; ti++) {
+       for (ti = TETHERING_TYPE_USB; ti < TETHERING_TYPE_MAX; ti++) {
                th->enabled_cb[ti] = NULL;
                th->enabled_user_data[ti] = NULL;
        }
@@ -2560,7 +2695,7 @@ API int tethering_set_disabled_cb(tethering_h tethering, tethering_type_e type,
        }
 
        /* TETHERING_TYPE_ALL */
-       for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_P2P; ti++) {
+       for (ti = TETHERING_TYPE_USB; ti < TETHERING_TYPE_MAX; ti++) {
                th->disabled_cb[ti] = callback;
                th->disabled_user_data[ti] = user_data;
        }
@@ -2601,7 +2736,7 @@ API int tethering_unset_disabled_cb(tethering_h tethering, tethering_type_e type
        }
 
        /* TETHERING_TYPE_ALL */
-       for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_P2P; ti++) {
+       for (ti = TETHERING_TYPE_USB; ti < TETHERING_TYPE_MAX; ti++) {
                th->disabled_cb[ti] = NULL;
                th->disabled_user_data[ti] = NULL;
        }
@@ -2647,7 +2782,7 @@ API int tethering_set_connection_state_changed_cb(tethering_h tethering, tetheri
        }
 
        /* TETHERING_TYPE_ALL */
-       for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_P2P; ti++) {
+       for (ti = TETHERING_TYPE_USB; ti < TETHERING_TYPE_MAX; ti++) {
                th->changed_cb[ti] = callback;
                th->changed_user_data[ti] = user_data;
        }
@@ -2688,7 +2823,7 @@ API int tethering_unset_connection_state_changed_cb(tethering_h tethering, tethe
        }
 
        /* TETHERING_TYPE_ALL */
-       for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_P2P; ti++) {
+       for (ti = TETHERING_TYPE_USB; ti < TETHERING_TYPE_MAX; ti++) {
                th->changed_cb[ti] = NULL;
                th->changed_user_data[ti] = NULL;
        }
@@ -2901,7 +3036,6 @@ API int tethering_wifi_set_security_type(tethering_h tethering, tethering_wifi_s
 
        ret = __set_security_type(type);
        if (ret == TETHERING_ERROR_NONE) {
-
                switch (type) {
                case TETHERING_WIFI_SECURITY_TYPE_NONE:
                        sec_str = TETHERING_WIFI_SECURITY_TYPE_OPEN_STR;
@@ -2912,6 +3046,9 @@ API int tethering_wifi_set_security_type(tethering_h tethering, tethering_wifi_s
                case TETHERING_WIFI_SECURITY_TYPE_WPS:
                        sec_str = TETHERING_WIFI_SECURITY_TYPE_WPS_STR;
                        break;
+               case TETHERING_WIFI_SECURITY_TYPE_SAE:
+                       sec_str = TETHERING_WIFI_SECURITY_TYPE_SAE_STR;
+                       break;
                }
 
                __send_dbus_signal(th->client_bus,
@@ -2939,6 +3076,8 @@ API int tethering_wifi_get_security_type(tethering_h tethering, tethering_wifi_s
        CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
        CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
 
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
        _retvm_if(type == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "parameter(type) is NULL\n");
 
@@ -2984,6 +3123,35 @@ API int tethering_wifi_set_ssid(tethering_h tethering, const char *ssid)
        _retvm_if(p_ssid == NULL, TETHERING_ERROR_OUT_OF_MEMORY,
                        "strdup is failed\n");
 
+#ifdef TIZEN_TV_EXT
+       GDBusProxy *proxy = th->client_bus_proxy;
+       GVariant *parameters;
+       GError *error = NULL;
+       tethering_error_e ret = TETHERING_ERROR_NONE;
+
+       parameters = g_dbus_proxy_call_sync(proxy, "set_wifi_tethering_ssid",
+                       g_variant_new("(s)", ssid), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+       if (error) {
+               ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
+
+               if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
+                       ret = TETHERING_ERROR_PERMISSION_DENIED;
+               else
+                       ret = TETHERING_ERROR_OPERATION_FAILED;
+
+               g_error_free(error);
+               return ret;
+       }
+
+       if (parameters != NULL) {
+               g_variant_get(parameters, "(u)", &ret);
+               g_variant_unref(parameters);
+       }
+
+       SINFO("set tethering ssid : %s", ssid);
+#endif /* TIZEN_TV_EXT */
+
        if (th->ssid)
                free(th->ssid);
        th->ssid = p_ssid;
@@ -3020,6 +3188,15 @@ API int tethering_wifi_get_ssid(tethering_h tethering, char **ssid)
        __tethering_h *th = (__tethering_h *)tethering;
        char val[TETHERING_WIFI_SSID_MAX_LEN + 1] = {0, };
 
+#ifdef TIZEN_TV_EXT
+       if (__get_ssid_from_vconf(VCONFKEY_WIFI_SSID,
+                                       val, sizeof(val)) == true) {
+               *ssid = strdup(val);
+               SINFO("get tethering ssid : %s", *ssid);
+               return TETHERING_ERROR_NONE;
+       }
+#endif /* TIZEN_TV_EXT */
+
        if (!tethering_is_enabled(NULL, TETHERING_TYPE_WIFI)) {
                if (th->ssid != NULL) {
                        DBG("Private SSID is set\n");
@@ -3040,7 +3217,7 @@ API int tethering_wifi_get_ssid(tethering_h tethering, char **ssid)
        }
 
        if (*ssid == NULL) {
-               ERR("strdup is failed\n"); //LCOV_EXCL_LINE
+               ERR("strdup is failed\n");
                return TETHERING_ERROR_OUT_OF_MEMORY;
        }
 
@@ -3104,6 +3281,8 @@ API int tethering_wifi_get_ssid_visibility(tethering_h tethering, bool *visible)
        CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
        CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
 
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
        _retvm_if(visible == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "parameter(visible) is NULL\n");
 
@@ -3154,7 +3333,6 @@ API int tethering_wifi_set_passphrase(tethering_h tethering, const char *passphr
                        g_variant_new("(s)", passphrase), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
 
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -3164,7 +3342,6 @@ API int tethering_wifi_set_passphrase(tethering_h tethering, const char *passphr
 
                g_error_free(error);
                return ret;
-               //LCOV_EXCL_STOP
        }
 
        g_variant_get(parameters, "(u)", &ret);
@@ -3216,7 +3393,6 @@ API int tethering_wifi_get_passphrase(tethering_h tethering, char **passphrase)
                        NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
 
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -3226,7 +3402,6 @@ API int tethering_wifi_get_passphrase(tethering_h tethering, char **passphrase)
 
                g_error_free(error);
                return ret;
-               //LCOV_EXCL_STOP
        }
 
        if (parameters != NULL) {
@@ -3246,6 +3421,36 @@ API int tethering_wifi_set_channel(tethering_h tethering, int channel)
                        "parameter(tethering) is NULL\n");
 
        __tethering_h *th = (__tethering_h *)tethering;
+
+#ifdef TIZEN_TV_EXT
+       GDBusProxy *proxy = th->client_bus_proxy;
+       GVariant *parameters;
+       GError *error = NULL;
+       tethering_error_e ret = TETHERING_ERROR_NONE;
+
+       parameters = g_dbus_proxy_call_sync(proxy, "set_wifi_tethering_channel",
+                       g_variant_new("(i)", channel), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+       if (error) {
+               ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
+
+               if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
+                       ret = TETHERING_ERROR_PERMISSION_DENIED;
+               else
+                       ret = TETHERING_ERROR_OPERATION_FAILED;
+
+               g_error_free(error);
+               return ret;
+       }
+
+       if (parameters != NULL) {
+               g_variant_get(parameters, "(u)", &ret);
+               g_variant_unref(parameters);
+       }
+
+       SINFO("set channel : %d", channel);
+#endif /* TIZEN_TV_EXT */
+
        th->channel = channel;
 
        return TETHERING_ERROR_NONE;
@@ -3263,7 +3468,48 @@ API int tethering_wifi_get_channel(tethering_h tethering, int *channel)
                        "parameter(channel) is NULL\n");
 
        __tethering_h *th = (__tethering_h *)tethering;
+#ifdef TIZEN_TV_EXT
+       GDBusProxy *proxy = th->client_bus_proxy;
+       GVariant *parameters;
+       GError *error = NULL;
+       int ch, vconf_channel;
+       tethering_error_e ret = TETHERING_ERROR_NONE;
+
+       parameters = g_dbus_proxy_call_sync(proxy, "get_wifi_tethering_channel",
+                       NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+       if (error) {
+               ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
+
+               if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
+                       ret = TETHERING_ERROR_PERMISSION_DENIED;
+               else
+                       ret = TETHERING_ERROR_OPERATION_FAILED;
+
+               g_error_free(error);
+               return ret;
+       }
+
+       if (parameters != NULL) {
+               g_variant_get(parameters, "(iu)", &ch, &ret);
+               g_variant_unref(parameters);
+       }
+
+       if (ch < 0) {
+               ERR("failed to get Hostapd channel, set th->channel");
+               *channel = th->channel;
+       } else
+               *channel = ch;
+
+       if (vconf_get_int(VCONFKEY_WIFI_CHANNEL, &vconf_channel) < 0)
+               ERR("Failed to get vconf key for channel");
+       else
+               *channel = vconf_channel;
+
+       SINFO("get tethering channel : %d", *channel);
+#else /* TIZEN_TV_EXT */
        *channel = th->channel;
+#endif /* TIZEN_TV_EXT */
 
        return TETHERING_ERROR_NONE;
 }
@@ -3334,21 +3580,25 @@ API int tethering_wifi_reload_settings(tethering_h tethering, tethering_wifi_set
        DBG("+\n");
 
        if (th->settings_reloaded_cb) {
-               ERR("Operation in progress\n"); //LCOV_EXCL_LINE
+               ERR("Operation in progress\n");
                return TETHERING_ERROR_OPERATION_FAILED;
        }
 
        ret = __prepare_wifi_settings(tethering, &set);
        if (ret != TETHERING_ERROR_NONE) {
-               ERR("softap settings initialization failed\n"); //LCOV_EXCL_LINE
+               ERR("softap settings initialization failed\n");
                return TETHERING_ERROR_OPERATION_FAILED;
        }
 
        th->settings_reloaded_cb = callback;
        th->settings_reloaded_user_data = user_data;
 
+       SINFO("ssid %s, key %s, channel %d, mode %s, txpower %d, security %d max_device %d\n",
+                set.ssid, set.key, set.channel, set.mode, set.txpower, set.sec_type,
+                set.max_connected);
+
        g_dbus_proxy_call(proxy, "reload_wifi_settings",
-                       g_variant_new("(sssiiiii)", set.ssid, set.key, set.mode, set.channel, set.visibility, set.mac_filter, set.max_connected, set.sec_type),
+                       g_variant_new("(sssiiiiii)", set.ssid, set.key, set.mode, set.channel, set.visibility, set.mac_filter, set.max_connected, set.sec_type, set.txpower),
                        G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                        (GAsyncReadyCallback) __settings_reloaded_cb, (gpointer)tethering);
 
@@ -3392,33 +3642,36 @@ static int __add_mac_to_file(const char *filepath, const char *mac)
        bool mac_exist = false;
        char *p_mac = NULL;
 
-       p_mac = strdup(mac);
-       if (p_mac == NULL) {
-               ERR("strdup failed\n"); //LCOV_EXCL_LINE
-               return TETHERING_ERROR_OUT_OF_MEMORY;
-       }
-
        fp = fopen(filepath, "a+");
        if (!fp) {
-               ERR("fopen is failed\n"); //LCOV_EXCL_LINE
+               ERR("fopen is failed\n");
                return TETHERING_ERROR_OPERATION_FAILED;
        }
 
        while (fgets(line, MAX_BUF_SIZE, fp) != NULL) {
                if (strncmp(mac, line, 17) == 0) {
-                       DBG("MAC %s already exist in the list\n", mac); //LCOV_EXCL_LINE
+                       DBG("MAC %s already exist in the list\n", mac);
                        mac_exist = true;
                        break;
                }
        }
 
        if (!mac_exist) {
+               p_mac = strdup(mac);
+               if (p_mac == NULL) {
+                       ERR("strdup failed\n");
+                       fclose(fp);
+                       return TETHERING_ERROR_OUT_OF_MEMORY;
+               }
+
                fprintf(fp, "%s\n", mac);
 
                if ((strcmp(filepath, ALLOWED_LIST) == 0))
                        allowed_list = g_slist_append(allowed_list, p_mac);
                else if ((strcmp(filepath, BLOCKED_LIST) == 0))
                        blocked_list = g_slist_append(blocked_list, p_mac);
+               else
+                       free(p_mac);
        }
 
        fclose(fp);
@@ -3588,7 +3841,6 @@ API int tethering_wifi_enable_dhcp(tethering_h tethering, bool enable)
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
 
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
                        result = TETHERING_ERROR_PERMISSION_DENIED;
@@ -3599,7 +3851,6 @@ API int tethering_wifi_enable_dhcp(tethering_h tethering, bool enable)
                th->dhcp_enabled = false;
 
                return result;
-               //LCOV_EXCL_STOP
        }
 
        g_variant_get(parameters, "(u)", &result);
@@ -3637,7 +3888,6 @@ API int tethering_wifi_set_dhcp_range(tethering_h tethering, char *rangestart, c
                        g_variant_new("(ss)", rangestart, rangestop),
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -3649,7 +3899,6 @@ API int tethering_wifi_set_dhcp_range(tethering_h tethering, char *rangestart, c
                th->dhcp_enabled = false;
 
                return result;
-               //LCOV_EXCL_STOP
        }
 
        g_variant_get(parameters, "(u)", &result);
@@ -3689,17 +3938,16 @@ API int tethering_wifi_set_txpower(tethering_h tethering, unsigned int txpower)
                        TETHERING_ERROR_NOT_ENABLED,
                        "tethering type[%d] is not enabled\n", TETHERING_TYPE_WIFI);
        __tethering_h *th = (__tethering_h *)tethering;
+       th->txpower = txpower;
 
        g_dbus_proxy_call_sync(th->client_bus_proxy, "hostapd_set_txpower",
                        g_variant_new("(u)", txpower),
                        G_DBUS_CALL_FLAGS_NONE,
                        -1, th->cancellable, &error);
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync is failed and error is %s\n", error->message);
                g_clear_error(&error);
                return TETHERING_ERROR_OPERATION_FAILED;
-               //LCOV_EXCL_STOP
        }
        return TETHERING_ERROR_NONE;
 }
@@ -3714,6 +3962,8 @@ API int tethering_wifi_get_txpower(tethering_h tethering, unsigned int *txpower)
 
        _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "parameter(tethering) is NULL\n");
+       _retvm_if(txpower == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(txpower) is NULL\n");
        _retvm_if(tethering_is_enabled(tethering, TETHERING_TYPE_WIFI) == false,
                        TETHERING_ERROR_NOT_ENABLED,
                        "tethering type[%d] is not enabled\n", TETHERING_TYPE_WIFI);
@@ -3729,12 +3979,10 @@ API int tethering_wifi_get_txpower(tethering_h tethering, unsigned int *txpower)
                g_variant_get(result, "(u)", txpower);
                g_variant_unref(result);
        } else {
-               //LCOV_EXCL_START
                if (error)
                        ERR("g_dbus_proxy_call_sync is failed and error is %s\n", error->message);
                g_clear_error(&error);
                return TETHERING_ERROR_OPERATION_FAILED;
-               //LCOV_EXCL_STOP
        }
        g_clear_error(&error);
        return TETHERING_ERROR_NONE;
@@ -3760,7 +4008,6 @@ API int tethering_wifi_set_mtu(tethering_h tethering, unsigned int mtu)
                        g_variant_new("(u)", mtu),
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -3770,7 +4017,6 @@ API int tethering_wifi_set_mtu(tethering_h tethering, unsigned int mtu)
 
                g_error_free(error);
                return result;
-               //LCOV_EXCL_STOP
        }
 
        g_variant_get(parameters, "(u)", &result);
@@ -3802,7 +4048,6 @@ API int tethering_wifi_change_mac(tethering_h tethering, char *mac)
                        g_variant_new("(s)", mac),
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -3812,7 +4057,6 @@ API int tethering_wifi_change_mac(tethering_h tethering, char *mac)
 
                g_error_free(error);
                return result;
-               //LCOV_EXCL_STOP
        }
 
        g_variant_get(parameters, "(u)", &result);
@@ -3875,7 +4119,6 @@ API int tethering_wifi_enable_port_forwarding(tethering_h tethering, bool enable
                        g_variant_new("(b)", enable),
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -3885,7 +4128,6 @@ API int tethering_wifi_enable_port_forwarding(tethering_h tethering, bool enable
 
                g_error_free(error);
                return result;
-               //LCOV_EXCL_STOP
        }
 
        g_variant_get(parameters, "(u)", &result);
@@ -3903,8 +4145,14 @@ API int tethering_wifi_add_port_forwarding_rule(tethering_h tethering, char *ifn
 
        _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "parameter(tethering) is NULL\n");
+       _retvm_if(ifname == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(ifname) is NULL\n");
        _retvm_if(protocol == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "parameter(protocol) is NULL\n");
+       _retvm_if(org_ip == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(org_ip) is NULL\n");
+       _retvm_if(final_ip == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(final_ip) is NULL\n");
 
        GVariant *parameters;
        GError *error = NULL;
@@ -3920,7 +4168,6 @@ API int tethering_wifi_add_port_forwarding_rule(tethering_h tethering, char *ifn
                        g_variant_new("(sssisi)", ifname, protocol, org_ip, org_port, final_ip, final_port),
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -3930,7 +4177,6 @@ API int tethering_wifi_add_port_forwarding_rule(tethering_h tethering, char *ifn
 
                g_error_free(error);
                return result;
-               //LCOV_EXCL_STOP
        }
 
        g_variant_get(parameters, "(u)", &result);
@@ -3940,7 +4186,7 @@ API int tethering_wifi_add_port_forwarding_rule(tethering_h tethering, char *ifn
 
        list = strdup(cmd);
        if (list == NULL) {
-               ERR("strdup failed\n"); //LCOV_EXCL_LINE
+               ERR("strdup failed\n");
                return TETHERING_ERROR_OUT_OF_MEMORY;
        }
 
@@ -3968,7 +4214,6 @@ API int tethering_wifi_reset_port_forwarding_rule(tethering_h tethering)
        parameters = g_dbus_proxy_call_sync(proxy, "reset_port_forwarding_rule",
                        NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -3978,7 +4223,6 @@ API int tethering_wifi_reset_port_forwarding_rule(tethering_h tethering)
 
                g_error_free(error);
                return result;
-               //LCOV_EXCL_STOP
        }
 
        g_variant_get(parameters, "(u)", &result);
@@ -3988,7 +4232,7 @@ API int tethering_wifi_reset_port_forwarding_rule(tethering_h tethering)
        return TETHERING_ERROR_NONE;
 }
 
-API int tethering_wifi_is_port_forwarding_enabled(tethering_h tethering, boolforwarding_enabled)
+API int tethering_wifi_is_port_forwarding_enabled(tethering_h tethering, bool *forwarding_enabled)
 {
        CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
        CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
@@ -4039,7 +4283,6 @@ API int tethering_wifi_enable_port_filtering(tethering_h tethering, bool enable)
                        g_variant_new("(b)", enable),
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -4049,7 +4292,6 @@ API int tethering_wifi_enable_port_filtering(tethering_h tethering, bool enable)
 
                g_error_free(error);
                return result;
-               //LCOV_EXCL_STOP
        }
 
        g_variant_get(parameters, "(u)", &result);
@@ -4073,8 +4315,8 @@ API int tethering_wifi_add_port_filtering_rule(tethering_h tethering, int port,
        GVariant *parameters;
        GError *error = NULL;
        guint result;
-       char cmd[MAX_BUF_SIZE] = { 0, };
        char *list = NULL;
+       int ret;
 
        __tethering_h *th = (__tethering_h *)tethering;
 
@@ -4084,7 +4326,6 @@ API int tethering_wifi_add_port_filtering_rule(tethering_h tethering, int port,
                        g_variant_new("(isb)", port, protocol, allow),
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -4094,25 +4335,23 @@ API int tethering_wifi_add_port_filtering_rule(tethering_h tethering, int port,
 
                g_error_free(error);
                return result;
-               //LCOV_EXCL_STOP
        }
 
        g_variant_get(parameters, "(u)", &result);
        g_variant_unref(parameters);
 
        if (allow)
-               snprintf(cmd, sizeof(cmd), "%s "FILTERING_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port, ACTION_ACCEPT);
+               ret = asprintf(&list, "%s "FILTERING_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port, ACTION_ACCEPT);
        else
-               snprintf(cmd, sizeof(cmd), "%s "FILTERING_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port, ACTION_DROP);
+               ret = asprintf(&list, "%s "FILTERING_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port, ACTION_DROP);
 
-       DBG("cmd:%s", cmd);
-
-       list = strdup(cmd);
-       if (list == NULL) {
-               ERR("strdup failed\n"); //LCOV_EXCL_LINE
+       if (ret == -1 || list == NULL) {
+               ERR("asprintf failed\n");
                return TETHERING_ERROR_OUT_OF_MEMORY;
        }
 
+       DBG("cmd:%s", list);
+
        port_filtering = g_slist_append(port_filtering, list);
 
        return TETHERING_ERROR_NONE;
@@ -4131,8 +4370,8 @@ API int tethering_wifi_add_custom_port_filtering_rule(tethering_h tethering, int
        GVariant *parameters;
        GError *error = NULL;
        guint result;
-       char cmd[MAX_BUF_SIZE] = { 0, };
        char *list = NULL;
+       int ret;
 
        __tethering_h *th = (__tethering_h *)tethering;
 
@@ -4142,7 +4381,6 @@ API int tethering_wifi_add_custom_port_filtering_rule(tethering_h tethering, int
                        g_variant_new("(iisb)", port1, port2, protocol, allow),
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -4152,25 +4390,23 @@ API int tethering_wifi_add_custom_port_filtering_rule(tethering_h tethering, int
 
                g_error_free(error);
                return result;
-               //LCOV_EXCL_STOP
        }
 
        g_variant_get(parameters, "(u)", &result);
        g_variant_unref(parameters);
 
        if (allow)
-               snprintf(cmd, sizeof(cmd), "%s "FILTERING_MULTIPORT_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port1, port2, ACTION_ACCEPT);
+               ret = asprintf(&list, "%s "FILTERING_MULTIPORT_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port1, port2, ACTION_ACCEPT);
        else
-               snprintf(cmd, sizeof(cmd), "%s "FILTERING_MULTIPORT_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port1, port2, ACTION_DROP);
+               ret = asprintf(&list, "%s "FILTERING_MULTIPORT_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port1, port2, ACTION_DROP);
 
-       DBG("cmd:%s", cmd);
-
-       list = strdup(cmd);
-       if (list == NULL) {
-               ERR("strdup failed\n"); //LCOV_EXCL_LINE
+       if (ret == -1 || list == NULL) {
+               ERR("asprintf failed\n");
                return TETHERING_ERROR_OUT_OF_MEMORY;
        }
 
+       DBG("cmd:%s", list);
+
        custom_port_filtering = g_slist_append(custom_port_filtering, list);
 
        return TETHERING_ERROR_NONE;
@@ -4204,7 +4440,7 @@ API int tethering_wifi_get_custom_port_filtering_rule(tethering_h tethering, voi
        return TETHERING_ERROR_NONE;
 }
 
-API int tethering_wifi_is_port_filtering_enabled(tethering_h tethering, boolfiltering_enabled)
+API int tethering_wifi_is_port_filtering_enabled(tethering_h tethering, bool *filtering_enabled)
 {
        CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
        CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
@@ -4241,7 +4477,6 @@ API int tethering_wifi_set_vpn_passthrough_rule(tethering_h tethering, tethering
                        g_variant_new("(ib)", type, enable),
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -4251,7 +4486,6 @@ API int tethering_wifi_set_vpn_passthrough_rule(tethering_h tethering, tethering
 
                g_error_free(error);
                return result;
-               //LCOV_EXCL_STOP
        }
 
        g_variant_get(parameters, "(u)", &result);
@@ -4278,7 +4512,6 @@ API int tethering_wifi_push_wps_button(tethering_h tethering)
                        NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
 
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -4288,7 +4521,6 @@ API int tethering_wifi_push_wps_button(tethering_h tethering)
 
                g_error_free(error);
                return ret;
-               //LCOV_EXCL_STOP
        }
 
        if (parameters != NULL) {
@@ -4306,6 +4538,9 @@ API int tethering_wifi_set_wps_pin(tethering_h tethering, const char *wps_pin)
 
        _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "parameter(tethering) is NULL");
+       _retvm_if(wps_pin == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(wps_pin) is NULL");
+
        __tethering_h *th = (__tethering_h *)tethering;
        GDBusProxy *proxy = th->client_bus_proxy;
        GVariant *parameters = NULL;
@@ -4316,7 +4551,6 @@ API int tethering_wifi_set_wps_pin(tethering_h tethering, const char *wps_pin)
                        g_variant_new("(s)", wps_pin), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
 
        if (error) {
-               //LCOV_EXCL_START
                ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
 
                if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
@@ -4326,7 +4560,6 @@ API int tethering_wifi_set_wps_pin(tethering_h tethering, const char *wps_pin)
 
                g_error_free(error);
                return ret;
-               //LCOV_EXCL_STOP
        }
 
        if (parameters != NULL) {
@@ -4337,4 +4570,98 @@ API int tethering_wifi_set_wps_pin(tethering_h tethering, const char *wps_pin)
        return TETHERING_ERROR_NONE;
 }
 
+API int tethering_wifi_is_sharing_supported(tethering_h tethering, bool *supported)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+       CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+       _retvm_if(supported == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(supported) is NULL\n");
+
+       /** Check if wifi-sharing is supported */
+       __tethering_h *th = (__tethering_h *)tethering;
+       GDBusProxy *proxy = th->client_bus_proxy;
+
+       int ret = TETHERING_ERROR_NONE;
+       int count = 0;
+       gchar *key = NULL;
+       GVariant *value = NULL;
+       GVariantIter *iter = NULL;
+       GVariantIter *sub_iter = NULL;
+       GVariant *parameters = NULL;
+       GError *error = NULL;
+
+       parameters = g_dbus_proxy_call_sync(proxy, "get_wifi_interfaces",
+                       NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
 
+       if (!parameters && error) {
+               ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
+
+               if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
+                       ret = TETHERING_ERROR_PERMISSION_DENIED;
+               else
+                       ret = TETHERING_ERROR_OPERATION_FAILED;
+
+               g_error_free(error);
+               goto error;
+       }
+
+       g_variant_get(parameters, "(a(a{sv}))", &iter);
+       if (iter == NULL) {
+               g_variant_unref(parameters);
+               ret = TETHERING_ERROR_OPERATION_FAILED;
+               goto error;
+       }
+
+       while (g_variant_iter_loop(iter, "(a{sv})", &sub_iter)) {
+               while (g_variant_iter_loop(sub_iter, "{sv}", &key, &value)) {
+                       if (g_strcmp0(key, "IfName") == 0) {
+                               const gchar *interface = g_variant_get_string(value, NULL);
+                               ERR("interface: %s\n", interface);
+                               if (strncmp(interface, "wlan", 4) == 0)
+                                       count++;
+                       }
+               }
+       }
+       g_variant_unref(parameters);
+
+       if (count > 1)
+               *supported = true;
+       else
+               *supported = false;
+
+error:
+       return ret;
+}
+
+API int tethering_wifi_set_sharing(tethering_h tethering, bool sharing)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+       CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+
+       __tethering_h *th = (__tethering_h *)tethering;
+       th->wifi_sharing = sharing;
+
+       return TETHERING_ERROR_NONE;
+}
+
+API int tethering_wifi_get_sharing(tethering_h tethering, bool *sharing)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+       CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+       _retvm_if(sharing == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(sharing) is NULL\n");
+
+       __tethering_h *th = (__tethering_h *)tethering;
+       *sharing = th->wifi_sharing;
+
+       return TETHERING_ERROR_NONE;
+}