Fixed precondition check for the ethernet network
[platform/core/api/tethering.git] / src / tethering.c
index 9d55e54..422ac1e 100755 (executable)
@@ -125,8 +125,7 @@ static __tethering_sig_t sigs[] = {
        {0, SIGNAL_NAME_SECURITY_TYPE_CHANGED, __handle_security_type_changed},
        {0, SIGNAL_NAME_SSID_VISIBILITY_CHANGED, __handle_ssid_visibility_changed},
        {0, SIGNAL_NAME_PASSPHRASE_CHANGED, __handle_passphrase_changed},
-       {0, SIGNAL_NAME_DHCP_STATUS, __handle_dhcp},
-       {0, "", NULL} };
+       {0, SIGNAL_NAME_DHCP_STATUS, __handle_dhcp} };
 
 static int retry = 0;
 
@@ -165,12 +164,12 @@ 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");
+               ERR("Invalid param\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_INVALID_PARAMETER;
        }
 
        if (vconf_set_int(VCONFKEY_MOBILE_HOTSPOT_SECURITY, security_type) < 0) {
-               ERR("vconf_set_int is failed\n");
+               ERR("vconf_set_int is failed\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_OPERATION_FAILED;
        }
 
@@ -180,13 +179,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");
+               ERR("Invalid param\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_INVALID_PARAMETER;
        }
 
        if (vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_SECURITY,
                                (int *)security_type) < 0) {
-               ERR("vconf_get_int is failed\n");
+               ERR("vconf_get_int is failed\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_OPERATION_FAILED;
        }
 
@@ -217,7 +216,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");
+               ERR("vconf_set_int is failed\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_OPERATION_FAILED;
        }
 
@@ -227,14 +226,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");
+               ERR("Invalid param\n"); //LCOV_EXCL_LINE
                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");
+               ERR("vconf_get_int is failed\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_OPERATION_FAILED;
        }
 
@@ -286,6 +285,7 @@ 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;
@@ -310,7 +310,6 @@ static tethering_error_e __get_error(int agent_error)
                err = TETHERING_ERROR_OPERATION_FAILED;
                break;
 
-       //LCOV_EXCL_START
        case MOBILE_AP_ERROR_NOT_PERMITTED:
                err = TETHERING_ERROR_NOT_PERMITTED;
                break;
@@ -319,7 +318,7 @@ static tethering_error_e __get_error(int agent_error)
                err = TETHERING_ERROR_PERMISSION_DENIED;
                break;
        //LCOV_EXCL_STOP
-       default :
+       default:
                ERR("Not defined error : %d\n", agent_error);
                err = TETHERING_ERROR_OPERATION_FAILED;
                break;
@@ -394,9 +393,7 @@ DONE:
        g_free(name);
        DBG("-\n");
 }
-//LCOV_EXCL_STOP
 
-//LCOV_EXCL_START
 static void __handle_net_closed(GDBusConnection *connection, const gchar *sender_name,
                const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
                GVariant *parameters, gpointer user_data)
@@ -691,7 +688,7 @@ static void __handle_security_type_changed(GDBusConnection *connection, const gc
        else if (g_strcmp0(buf, TETHERING_WIFI_SECURITY_TYPE_WPS_STR) == 0)
                security_type = TETHERING_WIFI_SECURITY_TYPE_WPS;
        else {
-               SERR("Unknown type : %s\n", buf);
+               SERR("Unknown type : %s\n", buf); //LCOV_EXCL_LINE
                g_free(buf);
                return;
        }
@@ -705,7 +702,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");
+       DBG("+\n"); //LCOV_EXCL_LINE
 
        _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
        __tethering_h *th = (__tethering_h *)user_data;
@@ -717,7 +714,7 @@ static void __handle_ssid_visibility_changed(GDBusConnection *connection, const
 
        scb = th->ssid_visibility_changed_cb;
        if (scb == NULL) {
-               DBG("-\n");
+               DBG("-\n"); //LCOV_EXCL_LINE
                return;
        }
        g_variant_get(parameters, "(s)", &buf);
@@ -727,14 +724,14 @@ static void __handle_ssid_visibility_changed(GDBusConnection *connection, const
 
        scb(visible, data);
        g_free(buf);
-       DBG("-\n");
+       DBG("-\n"); //LCOV_EXCL_LINE
 }
 
 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");
+       DBG("+\n"); //LCOV_EXCL_LINE
 
        _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
        __tethering_h *th = (__tethering_h *)user_data;
@@ -749,13 +746,13 @@ static void __handle_passphrase_changed(GDBusConnection *connection, const gchar
        data = th->passphrase_user_data;
 
        pcb(data);
-       DBG("-\n");
+       DBG("-\n"); //LCOV_EXCL_LINE
 }
 
 static void __wifi_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
                gpointer user_data)
 {
-       INFO("+\n");
+       INFO("+\n"); //LCOV_EXCL_LINE
 
        _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
        GError *g_error = NULL;
@@ -766,6 +763,9 @@ static void __wifi_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        tethering_enabled_cb ecb = th->enabled_cb[TETHERING_TYPE_WIFI];
        void *data = th->enabled_user_data[TETHERING_TYPE_WIFI];
 
+       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
@@ -787,7 +787,7 @@ static void __wifi_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        }
        retry = 0;
 
-       INFO("cfm event : wifi tethering enable info : %d\n", error);
+       INFO("cfm event : wifi tethering enable info : %d\n", error); //LCOV_EXCL_LINE
 
        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,
@@ -795,18 +795,18 @@ static void __wifi_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
                        sigs[E_SIGNAL_WIFI_TETHER_ON].cb, (gpointer)th, NULL);
 
        if (!ecb) {
-               INFO("-\n");
+               INFO("-\n"); //LCOV_EXCL_LINE
                return;
        }
        ecb(error, TETHERING_TYPE_WIFI, true, data);
        g_variant_unref(g_var);
-       INFO("-\n");
+       INFO("-\n"); //LCOV_EXCL_LINE
 }
 
 static void __bt_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
                gpointer user_data)
 {
-       DBG("+\n");
+       DBG("+\n"); //LCOV_EXCL_LINE
        _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
        GError *g_error = NULL;
        GVariant *g_var;
@@ -817,6 +817,9 @@ static void __bt_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        tethering_enabled_cb ecb = th->enabled_cb[TETHERING_TYPE_BT];
        void *data = th->enabled_user_data[TETHERING_TYPE_BT];
 
+       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
@@ -847,7 +850,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");
+               DBG("-\n"); //LCOV_EXCL_LINE
                return;
        }
 
@@ -870,6 +873,9 @@ static void __usb_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        tethering_enabled_cb ecb = th->enabled_cb[TETHERING_TYPE_USB];
        void *data = th->enabled_user_data[TETHERING_TYPE_USB];
 
+       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) {
                ERR("DBus error [%s]\n", g_error->message);
@@ -905,12 +911,60 @@ static void __usb_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        ecb(error, TETHERING_TYPE_USB, true, data);
        DBG("-\n");
 }
+
+static void __p2p_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
+                                       gpointer user_data)
+{
+       DBG("+\n");
+
+       _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
+       __tethering_h *th = (__tethering_h *)user_data;
+       GError *g_error = NULL;
+       GVariant *g_var;
+       guint info;
+       tethering_error_e error;
+       tethering_enabled_cb ecb = th->enabled_cb[TETHERING_TYPE_P2P];
+       void *data = th->enabled_user_data[TETHERING_TYPE_P2P];
+
+       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) {
+               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_P2P);
+                       DBG("-\n");
+                       return;
+               }
+               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);
+       } else {
+               g_variant_get(g_var, "(u)", &info);
+               g_variant_unref(g_var);
+               error = __get_error(info);
+       }
+       retry = 0;
+
+       if (!ecb) {
+               DBG("-\n");
+               return;
+       }
+
+       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");
+       INFO("+\n"); //LCOV_EXCL_LINE
 
        _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
        GError *g_error = NULL;
@@ -924,6 +978,9 @@ static void __disabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        tethering_disabled_cb dcb = NULL;
        void *data = NULL;
 
+       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
@@ -977,7 +1034,14 @@ static void __disabled_cfm_cb(GObject *source_object, GAsyncResult *res,
                if (dcb)
                        dcb(error, type, code, data);
                break;
-       //LCOV_EXCL_STOP
+
+       case MOBILE_AP_DISABLE_P2P_TETHERING_CFM:
+               type = TETHERING_TYPE_P2P;
+               dcb = th->disabled_cb[type];
+               data = th->disabled_user_data[type];
+               if (dcb)
+                       dcb(error, type, code, data);
+               break;
 
        case MOBILE_AP_DISABLE_CFM:
 
@@ -1007,8 +1071,9 @@ static void __disabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        default:
                ERR("Invalid event\n");
                break;
+       //LCOV_EXCL_STOP
        }
-       INFO("-\n");
+       INFO("-\n"); //LCOV_EXCL_LINE
 }
 
 static void __get_data_usage_cb(GObject *source_object, GAsyncResult *res,
@@ -1039,7 +1104,7 @@ static void __get_data_usage_cb(GObject *source_object, GAsyncResult *res,
                //LCOV_EXCL_STOP
        }
        if (th->data_usage_cb == NULL) {
-               ERR("There is no data_usage_cb\n");
+               ERR("There is no data_usage_cb\n"); //LCOV_EXCL_LINE
                return;
        }
        if (flag) {
@@ -1070,7 +1135,7 @@ 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);
+               ERR("DBus fail [%s]\n", g_error->message); //LCOV_EXCL_LINE
                if (g_error->code == G_DBUS_ERROR_ACCESS_DENIED)
                        tethering_error = TETHERING_ERROR_PERMISSION_DENIED;
                else
@@ -1147,9 +1212,11 @@ static bool __get_intf_name(tethering_type_e type, char *buf, unsigned int len)
                g_strlcpy(buf, TETHERING_BT_IF, len);
                break;
 
+       //LCOV_EXCL_START
        default:
                ERR("Not supported type : %d\n", type);
                return false;
+       //LCOV_EXCL_STOP
        }
        return true;
 }
@@ -1159,10 +1226,11 @@ 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;
@@ -1170,10 +1238,11 @@ static bool __get_gateway_addr(tethering_type_e type, char *buf, unsigned int le
        case TETHERING_TYPE_BT:
                g_strlcpy(buf, TETHERING_BT_GATEWAY, len);
                break;
-
+       //LCOV_EXCL_START
        default:
                ERR("Not supported type : %d\n", type);
                return false;
+       //LCOV_EXCL_STOP
        }
        return true;
 }
@@ -1236,7 +1305,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");
+               ERR("null parameter\n-\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_INVALID_PARAMETER;
        }
 
@@ -1301,16 +1370,15 @@ static int __prepare_wifi_settings(tethering_h tethering, _softap_settings_t *se
 
        INFO("ssid: %s security: %d mode: %s channel: %d visibility: %s\n",
                 set->ssid, set->sec_type, set->mode, set->channel,
-                (set->visibility)?"true":"false");
+                (set->visibility) ? "true" : "false");
        INFO("-\n");
        return TETHERING_ERROR_NONE;
 }
 
 static bool __check_precondition(tethering_type_e type)
 {
-       int dnet_state = 0;
+       int dnet_status = 0;
        int cellular_state = 0;
-       int wifi_state = 0;
 
        /* data network through cellular */
        vconf_get_int(VCONFKEY_NETWORK_CELLULAR_STATE, &cellular_state);
@@ -1319,29 +1387,12 @@ static bool __check_precondition(tethering_type_e type)
                return TRUE;
        }
 
-#ifdef TIZEN_TV_EXT
-       /* data network through ethernet */
-       vconf_get_int(VCONFKEY_NETWORK_STATUS, &dnet_state);
-       if (dnet_state == VCONFKEY_NETWORK_ETHERNET) {
-               INFO("Data Network is connected");
-               return TRUE;
-       }
-#else
-       vconf_get_int(VCONFKEY_DNET_STATE, &dnet_state);
-       if (dnet_state > VCONFKEY_DNET_OFF) {
-               INFO("Data Network is connected");
+       /* data network status */
+       vconf_get_int(VCONFKEY_NETWORK_STATUS, &dnet_status);
+       if ((dnet_status == VCONFKEY_NETWORK_WIFI
+                       && type != TETHERING_TYPE_WIFI)
+               || dnet_status == VCONFKEY_NETWORK_ETHERNET)
                return TRUE;
-       }
-#endif/*TIZEN_TV_EXT*/
-
-       /* data network through wifi */
-       if (type != TETHERING_TYPE_WIFI) {
-               vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
-               if (wifi_state > VCONFKEY_WIFI_UNCONNECTED) {
-                       INFO("Wi-Fi is connected!");
-                       return TRUE;
-               }
-       }
 
        ERR("Network is not available!");
        return FALSE;
@@ -1384,19 +1435,22 @@ API int tethering_create(tethering_h *tethering)
        th->channel = 6;
        th->mode_type = TETHERING_WIFI_MODE_TYPE_G;
        th->wifi_max_connected = TETHERING_WIFI_MAX_STA;
-       th->change_mac = false;
 
        if (__generate_initial_passphrase(th->passphrase,
                        sizeof(th->passphrase)) == 0) {
-               ERR("random passphrase generation failed\n"); //LCOV_EXCL_LINE
+               //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) {
-               ERR("common ssid get failed\n"); //LCOV_EXCL_LINE
+               //LCOV_EXCL_START
+               ERR("common ssid get failed\n");
                free(th);
                return TETHERING_ERROR_OPERATION_FAILED;
+               //LCOV_EXCL_STOP
        }
 
 #if !GLIB_CHECK_VERSION(2, 36, 0)
@@ -1434,6 +1488,7 @@ API int tethering_create(tethering_h *tethering)
        __connect_signals((tethering_h)th);
 
        *tethering = (tethering_h)th;
+       _tethering_add_handle(th);
        INFO("Tethering Handle : 0x%X\n", th);
        INFO("-\n");
        return TETHERING_ERROR_NONE;
@@ -1458,18 +1513,12 @@ API int tethering_destroy(tethering_h tethering)
        _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
                        "parameter(tethering) is NULL\n");
 
-       GVariant *result = NULL;
        __tethering_h *th = (__tethering_h *)tethering;
 
        INFO("Tethering Handle : 0x%X\n", th);
 
-       if (th->change_mac) {
-               result = g_dbus_proxy_call_sync(th->client_bus_proxy, "reset_mac", NULL,
-                               G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
-               g_variant_unref(result);
-       }
-
        __disconnect_signals(tethering);
+       _tethering_remove_handle(th);
 
        if (th->ssid)
                free(th->ssid);
@@ -1478,6 +1527,7 @@ API int tethering_destroy(tethering_h tethering)
        g_object_unref(th->client_bus_proxy);
        g_object_unref(th->client_bus);
        memset(th, 0x00, sizeof(__tethering_h));
+
        free(th);
 
        INFO("-\n");
@@ -1541,15 +1591,17 @@ API int tethering_enable(tethering_h tethering, tethering_type_e type)
 
                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);
 
                g_dbus_proxy_call(proxy, "enable_wifi_tethering",
-                               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, TETHERING_ADDRESS_FAMILY_IPV4),
                                G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                                (GAsyncReadyCallback) __wifi_enabled_cfm_cb, (gpointer)tethering);
                break;
@@ -1559,13 +1611,30 @@ API int tethering_enable(tethering_h tethering, tethering_type_e type)
                g_dbus_connection_signal_unsubscribe(connection,
                                sigs[E_SIGNAL_BT_TETHER_ON].sig_id);
 
-               g_dbus_proxy_call(proxy, "enable_bt_tethering", NULL,
+               g_dbus_proxy_call(proxy, "enable_bt_tethering",
+                               g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV4),
                                G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                                (GAsyncReadyCallback) __bt_enabled_cfm_cb, (gpointer)tethering);
 
                break;
 
        //LCOV_EXCL_START
+       case TETHERING_TYPE_P2P: {
+               _softap_settings_t p2p_set = {"", "", "", 0, false};
+               ret = __prepare_wifi_settings(tethering, &p2p_set);
+               if (ret != TETHERING_ERROR_NONE) {
+                       ERR("p2p settings initialization failed\n");
+                       DBG("-\n");
+                       return TETHERING_ERROR_OPERATION_FAILED;
+               }
+
+               g_dbus_proxy_call(proxy, "enable_p2p_tethering",
+                               g_variant_new("(ssi)", p2p_set.ssid, p2p_set.key, p2p_set.channel),
+                               G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+                               (GAsyncReadyCallback) __p2p_enabled_cfm_cb, (gpointer)tethering);
+               break;
+       }
+
        case TETHERING_TYPE_ALL: {
                _softap_settings_t set = {"", "", "", 0, false};
 
@@ -1588,7 +1657,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("(ssii)", set.ssid, set.key, set.visibility, 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, TETHERING_ADDRESS_FAMILY_IPV4),
                                G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                                (GAsyncReadyCallback) __wifi_enabled_cfm_cb, (gpointer)tethering);
 
@@ -1596,11 +1667,11 @@ API int tethering_enable(tethering_h tethering, tethering_type_e type)
                g_dbus_connection_signal_unsubscribe(connection,
                                sigs[E_SIGNAL_BT_TETHER_ON].sig_id);
 
-               g_dbus_proxy_call(proxy, "enable_usb_tethering", NULL,
+               g_dbus_proxy_call(proxy, "enable_bt_tethering",
+                               g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV4),
                                G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                                (GAsyncReadyCallback) __bt_enabled_cfm_cb, (gpointer)tethering);
                break;
-               //LCOV_EXCL_STOP
        }
        default:
                ERR("Unknown type : %d\n", type);
@@ -1610,12 +1681,127 @@ 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");
        return TETHERING_ERROR_NONE;
 }
 
+API int tethering_ipv6_enable(tethering_h tethering, tethering_type_e type)
+{
+       DBG("+ type :  %d\n", type);
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+       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);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+
+       __tethering_h *th = (__tethering_h *)tethering;
+       GDBusProxy *proxy = th->client_bus_proxy;
+       GDBusConnection *connection = th->client_bus;
+       int ret = 0;
+
+       g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_INFINITE);
+
+       if (__check_precondition(type) == FALSE) {
+               //LCOV_EXCL_START
+               DBG("-\n");
+               return TETHERING_ERROR_OPERATION_FAILED;
+               //LCOV_EXCL_STOP
+       }
+
+       switch (type) {
+       case TETHERING_TYPE_WIFI: {
+               _softap_settings_t set = {"", "", "", 0, false, false, 0, 0};
+
+               ret = __prepare_wifi_settings(tethering, &set);
+               if (ret != TETHERING_ERROR_NONE) {
+                       ERR("softap settings initialization failed\n");
+                       DBG("-\n");
+                       return TETHERING_ERROR_OPERATION_FAILED;
+               }
+               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),
+                               G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+                               (GAsyncReadyCallback) __wifi_enabled_cfm_cb, (gpointer)tethering);
+               break;
+        }
+       case TETHERING_TYPE_BT: {
+               g_dbus_connection_signal_unsubscribe(connection,
+                               sigs[E_SIGNAL_BT_TETHER_ON].sig_id);
+
+               /* For TEST */
+               g_dbus_proxy_call(proxy, "enable_bt_tethering", g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV6),
+                               G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+                               (GAsyncReadyCallback) __bt_enabled_cfm_cb, (gpointer)tethering);
+
+               break;
+       }
+
+       default: {
+               ERR("Unknown type : %d\n", type);
+
+               g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_USE_DEFAULT);
+
+               DBG("-\n");
+               return TETHERING_ERROR_INVALID_PARAMETER;
+       }
+       }
+
+       g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_USE_DEFAULT);
+       DBG("-\n");
+       return TETHERING_ERROR_NONE;
+}
+
+API int tethering_ipv6_disable(tethering_h tethering, tethering_type_e type)
+{
+       DBG("+ type :  %d\n", type);
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+       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);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL\n");
+
+       __tethering_h *th = (__tethering_h *)tethering;
+       GDBusProxy *proxy = th->client_bus_proxy;
+       GDBusConnection *connection = th->client_bus;
+
+       switch (type) {
+       case TETHERING_TYPE_WIFI:
+               DBG("Disable wifi tethering..");
+               g_dbus_connection_signal_unsubscribe(connection,
+                               sigs[E_SIGNAL_WIFI_TETHER_OFF].sig_id);
+
+               g_dbus_proxy_call(proxy, "disable_wifi_tethering",
+                               g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV6),
+                               G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+                               (GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
+               break;
+       case TETHERING_TYPE_BT:
+               g_dbus_connection_signal_unsubscribe(connection,
+                               sigs[E_SIGNAL_BT_TETHER_OFF].sig_id);
+
+               g_dbus_proxy_call(proxy, "disable_bt_tethering",
+                               g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV6),
+                               G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+                               (GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
+               break;
+
+       default:
+               ERR("Not supported tethering type [%d]\n", type);
+               DBG("-\n");
+               return TETHERING_ERROR_INVALID_PARAMETER;
+       }
+       DBG("-\n");
+       return TETHERING_ERROR_NONE;
+}
 /**
  * @internal
  * @brief Disables the tethering, asynchronously.
@@ -1647,6 +1833,7 @@ 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);
@@ -1656,6 +1843,7 @@ 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:
 
@@ -1663,7 +1851,8 @@ API int tethering_disable(tethering_h tethering, tethering_type_e type)
                                sigs[E_SIGNAL_WIFI_TETHER_OFF].sig_id);
 
                g_dbus_proxy_call(proxy, "disable_wifi_tethering",
-                               NULL, G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+                               g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV4),
+                               G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                                (GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
                break;
 
@@ -1673,6 +1862,14 @@ API int tethering_disable(tethering_h tethering, tethering_type_e type)
                                sigs[E_SIGNAL_BT_TETHER_OFF].sig_id);
 
                g_dbus_proxy_call(proxy, "disable_bt_tethering",
+                               g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV4),
+                               G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+                               (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,
                                (GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
                break;
@@ -1689,14 +1886,16 @@ API int tethering_disable(tethering_h tethering, tethering_type_e type)
                                sigs[E_SIGNAL_WIFI_TETHER_OFF].sig_id);
 
                g_dbus_proxy_call(proxy, "disable_wifi_tethering",
-                               NULL, G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+                               g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV4),
+                               G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                                (GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
 
                g_dbus_connection_signal_unsubscribe(connection,
                                sigs[E_SIGNAL_BT_TETHER_OFF].sig_id);
 
                g_dbus_proxy_call(proxy, "disable_bt_tethering",
-                               NULL, G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+                               g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV4),
+                               G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
                                (GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
                break;
 
@@ -1704,6 +1903,7 @@ 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;
@@ -1743,11 +1943,15 @@ API bool tethering_is_enabled(tethering_h tethering, tethering_type_e type)
                vconf_type = VCONFKEY_MOBILE_HOTSPOT_MODE_BT;
                break;
 
+       case TETHERING_TYPE_P2P:
+               vconf_type = VCONFKEY_MOBILE_HOTSPOT_MODE_P2P;
+               break;
+
        default:
                ERR("Not supported type : %d\n", type);
                break;
        }
-       INFO("- enabled:  %s\n",(is_on & vconf_type)? "true" : "false");
+       INFO("- enabled:  %s\n", (is_on & vconf_type) ? "true" : "false");
        return is_on & vconf_type ? true : false;
 }
 
@@ -1774,9 +1978,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);
+       if (type == TETHERING_TYPE_USB) CHECK_FEATURE_SUPPORTED(TETHERING_USB_FEATURE); //LCOV_EXCL_LINE
        else if (type == TETHERING_TYPE_WIFI) CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
-       else if (type == TETHERING_TYPE_BT) CHECK_FEATURE_SUPPORTED(TETHERING_BT_FEATURE);
+       else if (type == TETHERING_TYPE_BT) CHECK_FEATURE_SUPPORTED(TETHERING_BT_FEATURE); //LCOV_EXCL_LINE
 
        _retvm_if(tethering_is_enabled(tethering, type) == false,
                        TETHERING_ERROR_NOT_ENABLED,
@@ -1798,9 +2002,11 @@ 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);
 
@@ -1891,9 +2097,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);
+       if (type == TETHERING_TYPE_USB) CHECK_FEATURE_SUPPORTED(TETHERING_USB_FEATURE); //LCOV_EXCL_LINE
        else if (type == TETHERING_TYPE_WIFI) CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
-       else if (type == TETHERING_TYPE_BT) CHECK_FEATURE_SUPPORTED(TETHERING_BT_FEATURE);
+       else if (type == TETHERING_TYPE_BT) CHECK_FEATURE_SUPPORTED(TETHERING_BT_FEATURE); //LCOV_EXCL_LINE
 
        _retvm_if(tethering_is_enabled(tethering, type) == false,
                        TETHERING_ERROR_NOT_ENABLED,
@@ -2113,8 +2319,9 @@ API int tethering_foreach_connected_clients(tethering_h tethering, tethering_typ
                        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);
+               ERR("g_dbus_proxy_call_sync is failed and error is %s\n", error->message); //LCOV_EXCL_LINE
        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)) {
@@ -2174,6 +2381,7 @@ API int tethering_foreach_connected_clients(tethering_h tethering, tethering_typ
                }
                g_free(client.hostname);
        }
+       //LCOV_EXCL_STOP
        g_variant_iter_free(outer_iter);
        g_variant_unref(station);
        g_variant_unref(result);
@@ -2219,7 +2427,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_BT; ti++) {
+       for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_P2P; ti++) {
                th->enabled_cb[ti] = callback;
                th->enabled_user_data[ti] = user_data;
        }
@@ -2261,7 +2469,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_BT; ti++) {
+       for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_P2P; ti++) {
                th->enabled_cb[ti] = NULL;
                th->enabled_user_data[ti] = NULL;
        }
@@ -2307,7 +2515,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_BT; ti++) {
+       for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_P2P; ti++) {
                th->disabled_cb[ti] = callback;
                th->disabled_user_data[ti] = user_data;
        }
@@ -2348,7 +2556,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_BT; ti++) {
+       for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_P2P; ti++) {
                th->disabled_cb[ti] = NULL;
                th->disabled_user_data[ti] = NULL;
        }
@@ -2787,7 +2995,7 @@ API int tethering_wifi_get_ssid(tethering_h tethering, char **ssid)
        }
 
        if (*ssid == NULL) {
-               ERR("strdup is failed\n");
+               ERR("strdup is failed\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_OUT_OF_MEMORY;
        }
 
@@ -2823,7 +3031,6 @@ API int tethering_wifi_set_ssid_visibility(tethering_h tethering, bool visible)
 
        ret = __set_visible(visible);
        if (ret == TETHERING_ERROR_NONE) {
-
                __send_dbus_signal(th->client_bus,
                                SIGNAL_NAME_SSID_VISIBILITY_CHANGED,
                                visible ? SIGNAL_MSG_SSID_VISIBLE :
@@ -3082,13 +3289,13 @@ API int tethering_wifi_reload_settings(tethering_h tethering, tethering_wifi_set
        DBG("+\n");
 
        if (th->settings_reloaded_cb) {
-               ERR("Operation in progress\n");
+               ERR("Operation in progress\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_OPERATION_FAILED;
        }
 
        ret = __prepare_wifi_settings(tethering, &set);
        if (ret != TETHERING_ERROR_NONE) {
-               ERR("softap settings initialization failed\n");
+               ERR("softap settings initialization failed\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_OPERATION_FAILED;
        }
 
@@ -3142,19 +3349,19 @@ static int __add_mac_to_file(const char *filepath, const char *mac)
 
        p_mac = strdup(mac);
        if (p_mac == NULL) {
-               ERR("strdup failed\n");
+               ERR("strdup failed\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_OUT_OF_MEMORY;
        }
 
        fp = fopen(filepath, "a+");
        if (!fp) {
-               ERR("fopen is failed\n");
+               ERR("fopen is failed\n"); //LCOV_EXCL_LINE
                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);
+                       DBG("MAC %s already exist in the list\n", mac); //LCOV_EXCL_LINE
                        mac_exist = true;
                        break;
                }
@@ -3329,6 +3536,7 @@ 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;
@@ -3339,6 +3547,7 @@ 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);
@@ -3376,6 +3585,7 @@ 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)
@@ -3387,6 +3597,7 @@ 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);
@@ -3432,9 +3643,11 @@ API int tethering_wifi_set_txpower(tethering_h tethering, unsigned int 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;
 }
@@ -3464,10 +3677,12 @@ 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;
@@ -3493,6 +3708,7 @@ 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)
@@ -3502,6 +3718,7 @@ 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);
@@ -3533,6 +3750,7 @@ 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)
@@ -3542,13 +3760,14 @@ 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);
-
        g_variant_unref(parameters);
 
-       th->change_mac = true;
+       if (result == MOBILE_AP_ERROR_NOT_PERMITTED)
+               return TETHERING_ERROR_NOT_SUPPORT_API;
 
        return TETHERING_ERROR_NONE;
 }
@@ -3604,6 +3823,7 @@ 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)
@@ -3613,6 +3833,7 @@ 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);
@@ -3647,6 +3868,7 @@ 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)
@@ -3656,6 +3878,7 @@ 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);
@@ -3665,7 +3888,7 @@ API int tethering_wifi_add_port_forwarding_rule(tethering_h tethering, char *ifn
 
        list = strdup(cmd);
        if (list == NULL) {
-               ERR("strdup failed\n");
+               ERR("strdup failed\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_OUT_OF_MEMORY;
        }
 
@@ -3693,6 +3916,7 @@ 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)
@@ -3702,6 +3926,7 @@ 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);
@@ -3762,6 +3987,7 @@ 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)
@@ -3771,6 +3997,7 @@ 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);
@@ -3805,6 +4032,7 @@ 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)
@@ -3814,6 +4042,7 @@ 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);
@@ -3828,7 +4057,7 @@ API int tethering_wifi_add_port_filtering_rule(tethering_h tethering, int port,
 
        list = strdup(cmd);
        if (list == NULL) {
-               ERR("strdup failed\n");
+               ERR("strdup failed\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_OUT_OF_MEMORY;
        }
 
@@ -3861,6 +4090,7 @@ 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)
@@ -3870,6 +4100,7 @@ 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);
@@ -3884,7 +4115,7 @@ API int tethering_wifi_add_custom_port_filtering_rule(tethering_h tethering, int
 
        list = strdup(cmd);
        if (list == NULL) {
-               ERR("strdup failed\n");
+               ERR("strdup failed\n"); //LCOV_EXCL_LINE
                return TETHERING_ERROR_OUT_OF_MEMORY;
        }
 
@@ -3958,6 +4189,7 @@ 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)
@@ -3967,6 +4199,7 @@ 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);
@@ -3993,6 +4226,7 @@ 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)
@@ -4002,6 +4236,7 @@ API int tethering_wifi_push_wps_button(tethering_h tethering)
 
                g_error_free(error);
                return ret;
+               //LCOV_EXCL_STOP
        }
 
        if (parameters != NULL) {
@@ -4029,6 +4264,7 @@ 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)
@@ -4038,6 +4274,7 @@ 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) {