Added support of wifi-sharing feature. 44/242044/6
authorNiraj Kumar Goit <niraj.g@samsung.com>
Fri, 21 Aug 2020 19:26:14 +0000 (00:56 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Wed, 26 Aug 2020 06:59:53 +0000 (12:29 +0530)
Added support of wifi-sharing feature to share internet of
wireless network connection with other devices.

Change-Id: I5850be72853dcc8a5c99505502232e9398c6ceaf
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
include/mobileap_network.h
include/mobileap_softap.h
include/mobileap_wifi.h
include/tethering-dbus-interface.xml
src/mobileap_common.c
src/mobileap_network.c
src/mobileap_softap.c
src/mobileap_wifi.c

index 79b18fa..58fb20b 100644 (file)
@@ -67,5 +67,6 @@ int _open_network(void);
 void _close_network(void);
 gboolean _init_network(void *user_data);
 gboolean _deinit_network(void);
+char *_get_wifi_source_interface_name(void);
 
 #endif /* __MOBILEAP_NETWORK_H__ */
index cfbe1e7..9d86547 100755 (executable)
@@ -54,6 +54,7 @@
 
 #define P2P_IF                 "p2p0"
 #define WIFI_IF                        "wlan0"
+#define WIFI_IF_1              "wlan1"
 #define IP_ADDRESS_WIFI                0xC0A82B02      /* 192.168.43.2 */
 
 #define SOFTAP_IF              "wl0.1"
 #define CHECK_NET_STATE_RETRY_COUNT    5
 #define PSK_ITERATION_COUNT            4096
 
+#define WIFI_TETHER_TYPE_LEN   15      /**< Maximum length of tethering type */
+
 typedef enum {
        SOFTAP_SECURITY_TYPE_OPEN = 0,
        SOFTAP_SECURITY_TYPE_WPA2_PSK,
@@ -297,6 +300,7 @@ typedef struct {
 
        uint32_t ip_addr;
        int txpower;
+       char tether_type[WIFI_TETHER_TYPE_LEN + 1];
 } softap_settings_t;
 
 typedef struct {
@@ -324,7 +328,7 @@ typedef struct {
 
 /* ssid : 32  key : 64 */
 int _mh_core_enable_softap(const mobile_ap_type_e type, softap_settings_t *settings);
-int _mh_core_disable_softap(void);
+int _mh_core_disable_softap(char *if_name);
 int _mh_core_execute_dhcp_server(gchar *softap_rangestart, gchar *softap_rangestop);
 int _mh_core_terminate_dhcp_server(void);
 int _mh_core_enable_masquerade(const char *ext_if);
index b8dcc7b..ff9680b 100644 (file)
@@ -54,7 +54,7 @@ gboolean _is_trying_wifi_operation(void);
 mobile_ap_error_code_e _reload_softap_settings(Tethering *obj, softap_settings_t *settings);
 
 gboolean tethering_enable_wifi_tethering(Tethering *obj,
-               GDBusMethodInvocation *context, gchar *ssid,
+               GDBusMethodInvocation *context, gchar *tether_type, gchar *ssid,
                gchar *key, gchar *mode, gint channel, gint visibility,
                gint mac_filter, gint max_sta, gint security_type,
                gint txpower, gint address_type);
index 2d27a08..7bc88a9 100755 (executable)
@@ -15,6 +15,7 @@
                </method>
 
                <method name="enable_wifi_tethering">
+                       <arg type="s" name="tether_type" direction="in"/>
                        <arg type="s" name="ssid" direction="in"/>
                        <arg type="s" name="key" direction="in"/>
                        <arg type="s" name="mode" direction="in"/>
index bb75abc..e607970 100755 (executable)
@@ -852,8 +852,9 @@ gboolean tethering_get_data_packet_usage(Tethering *obj,
                return TRUE;
        }
 
+       char *src_if = _get_wifi_source_interface_name();
        if (_mobileap_is_enabled(MOBILE_AP_STATE_WIFI))
-               _get_data_usage(WIFI_IF, if_name,
+               _get_data_usage(src_if, if_name,
                                &wifi_tx_bytes, &wifi_rx_bytes);
 
        if (_mobileap_is_enabled(MOBILE_AP_STATE_BT))
index c195040..d93acc5 100644 (file)
@@ -82,6 +82,9 @@ static guint net_timeout_id;
 static connection_profile_h tethered_prof = NULL;
 static GSList *port_forward_info = NULL;
 
+/* wifi-sharing source interface */
+const char *g_sharing_if = NULL;
+
 static gboolean __try_to_open_tethering_profile(gpointer user_data);
 
 //LCOV_EXCL_START
@@ -697,6 +700,14 @@ gboolean _is_trying_network_operation(void)
        return FALSE;
 }
 
+char *_get_wifi_source_interface_name(void)
+{
+       if (g_sharing_if)
+               return (char *)g_sharing_if;
+
+       return WIFI_IF;
+}
+
 gboolean _get_network_interface_name(char **if_name)
 {
        if (if_name == NULL) {
@@ -789,6 +800,7 @@ gboolean _get_network_dns_address(mobile_ap_address_type_e address_type, char **
 
 gboolean _set_masquerade(void)
 {
+       /* default connected interface */
        char *if_name = NULL;
 
        if (_get_network_interface_name(&if_name) == FALSE) {
@@ -797,6 +809,17 @@ gboolean _set_masquerade(void)
        }
        SDBG("Network interface : %s\n", if_name);
 
+       /* wifi-sharing: set wifi source interface name */
+       if (g_strcmp0(if_name, WIFI_IF) == 0)
+               g_sharing_if = WIFI_IF_1;
+       else if (g_strcmp0(if_name, WIFI_IF_1) == 0)
+               g_sharing_if = WIFI_IF;
+       else
+               g_sharing_if = NULL;
+
+       if (g_sharing_if)
+               SDBG("wifi-sharing source interface: %s", g_sharing_if);
+
        _mh_core_enable_masquerade(if_name);
        free(if_name);
 
index cd8758d..22c71ba 100755 (executable)
@@ -83,6 +83,7 @@ struct in6_ifreq {
 static void __generate_eui64_address(int idx, const char *hw_addr, char **eui64_addr);
 #endif
 
+const char *g_tether_type = NULL;
 static gboolean __hostapd_connect_timer_cb(gpointer user_data);
 
 static char *__find_first_caps_char(char *str)
@@ -189,6 +190,7 @@ static int __execute_hostapd(const mobile_ap_type_e type, softap_settings_t *set
        pid_t pid;
        int ret;
        char key[MOBILE_AP_WIFI_KEY_MAX_LEN + 1];
+       char *src_if = _get_wifi_source_interface_name();
 
        ret = __make_hostapd_dir();
        if (ret != MOBILE_AP_ERROR_NONE)
@@ -196,7 +198,7 @@ static int __execute_hostapd(const mobile_ap_type_e type, softap_settings_t *set
 
 #ifdef TIZEN_FEATURE_HEADLESS
        snprintf(buf, sizeof(buf), HOSTAPD_RPI_CONF,
-                       WIFI_IF,
+                       src_if,
                        HOSTAPD_CTRL_INTF_DIR,
                        settings->ssid,
                        settings->channel,
@@ -205,7 +207,7 @@ static int __execute_hostapd(const mobile_ap_type_e type, softap_settings_t *set
                        settings->max_sta);
 #else
        snprintf(buf, sizeof(buf), HOSTAPD_CONF,
-                       WIFI_IF,
+                       src_if,
                        HOSTAPD_CTRL_INTF_DIR,
                        settings->ssid,
                        settings->channel,
@@ -307,6 +309,7 @@ static int __execute_hostapd_wps(const mobile_ap_type_e type, softap_settings_t
        char *old_conf = NULL;
        char buf[HOSTAPD_CONF_LEN] = "";
        char key[MOBILE_AP_WIFI_KEY_MAX_LEN + 1];
+       char *src_if = _get_wifi_source_interface_name();
        FILE *fp = NULL;
        pid_t pid;
 
@@ -323,7 +326,8 @@ static int __execute_hostapd_wps(const mobile_ap_type_e type, softap_settings_t
        }
        /* Default conf. */
        snprintf(buf, sizeof(buf), HOSTAPD_WPS_CONF,
-                       WIFI_IF, HOSTAPD_CTRL_INTF_DIR,
+                       src_if,
+                       HOSTAPD_CTRL_INTF_DIR,
                        settings->ssid,
                        settings->channel,
                        settings->hide_mode,
@@ -507,7 +511,9 @@ static int __open_hostapd_intf(int *fd, const char *intf)
        }
 
        snprintf(ctrl_intf, sizeof(ctrl_intf), "%s/%s",
-                       HOSTAPD_CTRL_INTF_DIR, WIFI_IF);
+                       HOSTAPD_CTRL_INTF_DIR, _get_wifi_source_interface_name());
+       ERR("hostapd ctrl_intf [%s]\n", ctrl_intf); //LCOV_EXCL_LINE
+
        dest.sun_family = AF_UNIX;
        g_strlcpy(dest.sun_path, ctrl_intf, sizeof(dest.sun_path));
 
@@ -813,7 +819,7 @@ static mobile_ap_drv_interface_e __get_drv_interface(void)
        return drv_interface;
 }
 
-static int __mh_core_softap_firmware_start(void)
+static int __mh_core_softap_firmware_start(const char *tether_type, const char *src_if)
 {
        int err = 0;
        DBusError error;
@@ -823,6 +829,16 @@ static int __mh_core_softap_firmware_start(void)
        DBusConnection *connection = NULL;
        const char *device = "softap";
 
+       if (g_strcmp0(tether_type, "wifi_sharing") == 0) {
+               g_tether_type = "wifi_sharing";
+
+               char buf[20] = {'\0'};
+               snprintf(buf, sizeof(buf), "%s_%s", tether_type, src_if);
+
+               device = buf;
+       }
+       DBG("Start Device: %s", device);
+
        DBG("+");
        connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
        if (connection == NULL) {
@@ -870,7 +886,7 @@ static int __mh_core_softap_firmware_start(void)
        return err;
 }
 
-static int __mh_core_softap_firmware_stop(void)
+static int __mh_core_softap_firmware_stop(const char *src_if)
 {
        int err = 0;
        DBusError error;
@@ -880,6 +896,16 @@ static int __mh_core_softap_firmware_stop(void)
        DBusConnection *connection = NULL;
        const char *device = "softap";
 
+       if (g_strcmp0(g_tether_type, "wifi_sharing") == 0) {
+
+               char buf[20] = {'\0'};
+               snprintf(buf, sizeof(buf), "%s_%s", g_tether_type, src_if);
+
+               device = buf;
+       }
+
+       DBG("Stop device: %s", device);
+
        connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
        if (connection == NULL) {
                ERR("Failed to get system bus"); //LCOV_EXCL_LINE
@@ -937,19 +963,26 @@ int _mh_core_enable_softap(const mobile_ap_type_e type, softap_settings_t *setti
        mobile_ap_drv_interface_e drv_interface = MOBILE_AP_DRV_INTERFACE_NONE;
 
        int sock_fd;
-       char *if_name = WIFI_IF;
        char buf[MAX_BUF_SIZE] = { 0 };
-
        char wext_ssid[MOBILE_AP_WIFI_SSID_MAX_LEN] = { 0 };
        char *ptr = NULL;
        char *wlan_hw_addr = NULL;
        char *wlan_ipv6_address = NULL;
 
-       if (__mh_core_softap_firmware_start() < 0)
+       /** source wifi interface name */
+       char *if_name = _get_wifi_source_interface_name();
+       if (!if_name) {
+               ERR("Source interface is null.\n");
+               return MOBILE_AP_ERROR_INTERNAL;
+       }
+
+       if (__mh_core_softap_firmware_start(settings->tether_type, if_name) < 0)
                return MOBILE_AP_ERROR_INTERNAL;
 
        drv_interface = __get_drv_interface();
 
+       DBG("source if_name: %s", if_name);
+
        switch (drv_interface) {
 #ifndef TIZEN_FEATURE_UNITTEST
        case MOBILE_AP_WEXT:
@@ -1001,10 +1034,10 @@ int _mh_core_enable_softap(const mobile_ap_type_e type, softap_settings_t *setti
                        break;
                }
 
-               ret_status = _mh_core_set_ip_address(WIFI_IF,
+               ret_status = _mh_core_set_ip_address(if_name,
                                IP_ADDRESS_WIFI);
                if (ret_status != MOBILE_AP_ERROR_NONE) {
-                       ERR("_mh_core_set_ip_address of WIFI_IF is failed\n"); //LCOV_EXCL_LINE
+                       ERR("_mh_core_set_ip_address of if_name: %s is failed\n", if_name); //LCOV_EXCL_LINE
                        break;
                }
                break;
@@ -1013,7 +1046,7 @@ int _mh_core_enable_softap(const mobile_ap_type_e type, softap_settings_t *setti
 #ifdef TIZEN_FEATURE_ENABLE_IPV6
                if (settings->address_type == MOBILE_AP_ADDRESS_TYPE_IPV6) {
                        /* Setup IPv6 address for wlan0 */
-                       ret_status = _get_hw_address(WIFI_IF, &wlan_hw_addr);
+                       ret_status = _get_hw_address(if_name, &wlan_hw_addr);
                        if (ret_status != MOBILE_AP_ERROR_NONE || wlan_hw_addr == NULL) {
                                ERR("Failed to get network hw address"); //LCOV_EXCL_LINE
                                break;
@@ -1022,12 +1055,12 @@ int _mh_core_enable_softap(const mobile_ap_type_e type, softap_settings_t *setti
                        ret_status = _mh_core_create_ipv6_address(0,
                                        (const char *)wlan_hw_addr, &wlan_ipv6_address);
                        if (wlan_ipv6_address) {
-                               ret_status = _enable_ipv6(WIFI_IF);
+                               ret_status = _enable_ipv6(if_name);
                                if (ret_status != MOBILE_AP_ERROR_NONE)
                                        break;
-                               ret_status = _mh_core_set_ipv6_address(WIFI_IF, wlan_ipv6_address);
+                               ret_status = _mh_core_set_ipv6_address(if_name, wlan_ipv6_address);
                                if (ret_status != MOBILE_AP_ERROR_NONE) {
-                                       ERR("Failed to set ip address"); //LCOV_EXCL_LINE
+                                       ERR("Failed to set ip address on %s", if_name); //LCOV_EXCL_LINE
                                        break;
                                }
                        }
@@ -1035,13 +1068,13 @@ int _mh_core_enable_softap(const mobile_ap_type_e type, softap_settings_t *setti
                } else {
 #endif
                        if (settings->ip_addr > 0)
-                               ret_status = _mh_core_set_ip_address(WIFI_IF,
+                               ret_status = _mh_core_set_ip_address(if_name,
                                                settings->ip_addr);
                        else
-                               ret_status = _mh_core_set_ip_address(WIFI_IF,
+                               ret_status = _mh_core_set_ip_address(if_name,
                                                IP_ADDRESS_SOFTAP);
                        if (ret_status != MOBILE_AP_ERROR_NONE) {
-                               ERR("_mh_core_set_ip_address is failed\n"); //LCOV_EXCL_LINE
+                               ERR("_mh_core_set_ip_address is failed on %s\n", if_name); //LCOV_EXCL_LINE
                                break;
                        }
 #ifdef TIZEN_FEATURE_ENABLE_IPV6
@@ -1086,7 +1119,7 @@ int _mh_core_enable_softap(const mobile_ap_type_e type, softap_settings_t *setti
        }
 
        if (ret_status != MOBILE_AP_ERROR_NONE)
-               __mh_core_softap_firmware_stop();
+               __mh_core_softap_firmware_stop(if_name);
 
        g_free(wlan_hw_addr);
        g_free(wlan_ipv6_address);
@@ -1094,7 +1127,7 @@ int _mh_core_enable_softap(const mobile_ap_type_e type, softap_settings_t *setti
        return ret_status;
 }
 
-int _mh_core_disable_softap(void)
+int _mh_core_disable_softap(char *if_name)
 {
        char cmd[MAX_BUF_SIZE] = { 0 };
        int ret_status = MOBILE_AP_ERROR_NONE;
@@ -1102,7 +1135,6 @@ int _mh_core_disable_softap(void)
 
        int sock_fd = 0;
        char buf[MAX_BUF_SIZE] = { 0 };
-       char *if_name = WIFI_IF;
 
        drv_interface = __get_drv_interface();
 
@@ -1146,7 +1178,7 @@ int _mh_core_disable_softap(void)
                break;
        }
 
-       if (__mh_core_softap_firmware_stop() < 0)
+       if (__mh_core_softap_firmware_stop(if_name) < 0)
                ret_status = MOBILE_AP_ERROR_INTERNAL;
 
        return ret_status;
@@ -1513,6 +1545,8 @@ int _mh_core_enable_masquerade(const char *ext_if)
        }
 
        int fd = -1;
+       char *src_if = _get_wifi_source_interface_name();
+       ERR("src_if: %s ext_if: %s", src_if, ext_if);
 
        fd = open(IP_FORWARD, O_WRONLY);
        if (fd < 0) {
@@ -1542,28 +1576,28 @@ int _mh_core_enable_masquerade(const char *ext_if)
        _iptables_add_rule(FORWARD_RULE_WITH_ACTION_AND_STATE, TABLE_FILTER, TETH_FILTER_FW,
                BT_IF_ALL, ext_if, ACTION_RETURN, STATE_RELATED_ESTAB);
        _iptables_add_rule(FORWARD_RULE_WITH_ACTION_AND_STATE, TABLE_FILTER, TETH_FILTER_FW,
-               WIFI_IF, ext_if, ACTION_RETURN, STATE_RELATED_ESTAB);
+               src_if, ext_if, ACTION_RETURN, STATE_RELATED_ESTAB);
        _iptables_add_rule(FORWARD_RULE_WITH_ACTION_AND_STATE, TABLE_FILTER, TETH_FILTER_FW,
                USB_IF, ext_if, ACTION_RETURN, STATE_RELATED_ESTAB);
 
        _iptables_add_rule(FORWARD_RULE_WITH_ACTION_AND_STATE, TABLE_FILTER, TETH_FILTER_FW,
                ext_if, BT_IF_ALL, ACTION_DROP, STATE_INVALID);
        _iptables_add_rule(FORWARD_RULE_WITH_ACTION_AND_STATE, TABLE_FILTER, TETH_FILTER_FW,
-               ext_if, WIFI_IF, ACTION_DROP, STATE_INVALID);
+               ext_if, src_if, ACTION_DROP, STATE_INVALID);
        _iptables_add_rule(FORWARD_RULE_WITH_ACTION_AND_STATE, TABLE_FILTER, TETH_FILTER_FW,
                ext_if, USB_IF, ACTION_DROP, STATE_INVALID);
 
        _iptables_add_rule(FORWARD_RULE_WITH_ACTION, TABLE_FILTER, TETH_FILTER_FW,
                ext_if, BT_IF_ALL, ACTION_RETURN);
        _iptables_add_rule(FORWARD_RULE_WITH_ACTION, TABLE_FILTER, TETH_FILTER_FW,
-               ext_if, WIFI_IF, ACTION_RETURN);
+               ext_if, src_if, ACTION_RETURN);
        _iptables_add_rule(FORWARD_RULE_WITH_ACTION, TABLE_FILTER, TETH_FILTER_FW,
                ext_if, USB_IF, ACTION_RETURN);
 
        _iptables_add_rule(FORWARD_RULE_WITH_ACTION, TABLE_FILTER, TETH_FILTER_FW,
                BT_IF_ALL, ext_if, ACTION_RETURN);
        _iptables_add_rule(FORWARD_RULE_WITH_ACTION, TABLE_FILTER, TETH_FILTER_FW,
-               WIFI_IF, ext_if, ACTION_RETURN);
+               src_if, ext_if, ACTION_RETURN);
        _iptables_add_rule(FORWARD_RULE_WITH_ACTION, TABLE_FILTER, TETH_FILTER_FW,
                USB_IF, ext_if, ACTION_RETURN);
 
@@ -1687,6 +1721,7 @@ int _mh_core_change_mac(const char *mac)
 #else
        struct ifreq ifr;
        int fd;
+       char *src_if = _get_wifi_source_interface_name();
 
        sscanf(mac, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
                        &ifr.ifr_hwaddr.sa_data[0],
@@ -1702,7 +1737,7 @@ int _mh_core_change_mac(const char *mac)
                return MOBILE_AP_ERROR_INTERNAL;
        }
 
-       strncpy(ifr.ifr_name, WIFI_IF, IFNAMSIZ);
+       strncpy(ifr.ifr_name, src_if, IFNAMSIZ);
        ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
 
        if (ioctl(fd, SIOCSIFHWADDR, &ifr) == -1) {
index 6ebd530..0235134 100755 (executable)
@@ -35,6 +35,7 @@
 #include "mobileap_common.h"
 #include "mobileap_wifi.h"
 #include "mobileap_handler.h"
+#include "mobileap_network.h"
 #include "mobileap_notification.h"
 
 #ifndef IFNAMSIZ
@@ -422,6 +423,7 @@ static mobile_ap_error_code_e __update_softap_settings(softap_settings_t *dst, s
        dst->address_type = src->address_type;
        dst->ip_addr = src->ip_addr;
        dst->txpower = src->txpower;
+       g_strlcpy(dst->tether_type, src->tether_type, sizeof(dst->tether_type));
 
        SDBG("ssid : %s security type : %d ip address: 0x%X hide mode : %d mac filter : %d max_sta: %d hw_mode: %s vendor: %s txpower: %d\n",
                        dst->ssid, dst->security_type, dst->ip_addr, dst->hide_mode, dst->mac_filter, dst->max_sta, dst->mode, dst->vendor_elements, dst->txpower);
@@ -770,10 +772,13 @@ mobile_ap_error_code_e _enable_wifi_tethering(Tethering *obj, softap_settings_t
        _start_timeout_cb(MOBILE_AP_TYPE_WIFI, time(NULL) + TETHERING_CONN_TIMEOUT);
 
        if (obj_softap_settings.address_type != MOBILE_AP_ADDRESS_TYPE_IPV6) {
-               _add_interface_routing(WIFI_IF, IP_ADDRESS_SOFTAP);
-               _add_routing_rule(WIFI_IF);
+               char *src_if = _get_wifi_source_interface_name();
+               DBG("wifi source interface: %s", src_if);
+
+               _add_interface_routing(src_if, IP_ADDRESS_SOFTAP);
+               _add_routing_rule(src_if);
 #ifdef TIZEN_FEATURE_MULTICAST
-               _add_multicast_routing(WIFI_IF);
+               _add_multicast_routing(src_if);
 #endif
        }
 
@@ -793,26 +798,31 @@ mobile_ap_error_code_e _disable_wifi_tethering(Tethering *obj, mobile_ap_address
 
        if (!_mobileap_is_enabled(state)) {
                ERR("Wi-Fi tethering ap has not been activated\n"); //LCOV_EXCL_LINE
-               ret = MOBILE_AP_ERROR_NOT_ENABLED;
-               return ret;
+               return MOBILE_AP_ERROR_NOT_ENABLED;
+       }
+
+       char *src_if = _get_wifi_source_interface_name();
+       if (!src_if) {
+               ERR("Source interface is null\n"); //LCOV_EXCL_LINE
+               return MOBILE_AP_ERROR_INTERNAL;
        }
 
        _block_device_sleep();
        if (address_type != MOBILE_AP_ADDRESS_TYPE_IPV6) {
 #ifdef TIZEN_FEATURE_MULTICAST
-               _del_multicast_routing(WIFI_IF);
+               _del_multicast_routing(src_if);
 #endif
-               _del_routing_rule(WIFI_IF);
-               _del_interface_routing(WIFI_IF, IP_ADDRESS_SOFTAP);
+               _del_routing_rule(src_if);
+               _del_interface_routing(src_if, IP_ADDRESS_SOFTAP);
        }
 
-       _flush_ip_address(WIFI_IF);
+       _flush_ip_address(src_if);
        _deinit_timeout_cb(type);
 
        if (_remove_station_info_all(type) != MOBILE_AP_ERROR_NONE)
                ERR("_remove_station_info_all is failed. Ignore it.\n"); //LCOV_EXCL_LINE
 
-       ret = _mh_core_disable_softap();
+       ret = _mh_core_disable_softap(src_if);
        if (ret != MOBILE_AP_ERROR_NONE) {
                ERR("_mh_core_disable_softap is failed : %d\n", ret); //LCOV_EXCL_LINE
                goto DONE;
@@ -921,13 +931,15 @@ mobile_ap_error_code_e _enable_soft_ap(Softap *obj, softap_settings_t *settings)
                notification_handler.delete_timeout_noti();
        _init_timeout_cb(MOBILE_AP_TYPE_WIFI_AP, (void *)obj);
        _start_timeout_cb(MOBILE_AP_TYPE_WIFI_AP, time(NULL) + WIFI_AP_CONN_TIMEOUT);
+
+       char *src_if = _get_wifi_source_interface_name();
        if (obj_softap_settings.ip_addr > 0)
-               _add_interface_routing(WIFI_IF, obj_softap_settings.ip_addr);
+               _add_interface_routing(src_if, obj_softap_settings.ip_addr);
        else
-               _add_interface_routing(WIFI_IF, IP_ADDRESS_SOFTAP);
-       _add_routing_rule(WIFI_IF);
+               _add_interface_routing(src_if, IP_ADDRESS_SOFTAP);
+       _add_routing_rule(src_if);
 #ifdef TIZEN_FEATURE_MULTICAST
-       _add_multicast_routing(WIFI_IF);
+       _add_multicast_routing(src_if);
 #endif
 
 DONE:
@@ -946,22 +958,27 @@ mobile_ap_error_code_e _disable_soft_ap(Softap *obj)
 
        if (!_mobileap_is_enabled(state)) {
                ERR("Wi-Fi ap tethering has not been activated\n"); //LCOV_EXCL_LINE
-               ret = MOBILE_AP_ERROR_NOT_ENABLED;
-               return ret;
+               return MOBILE_AP_ERROR_NOT_ENABLED;
+       }
+
+       char *src_if = _get_wifi_source_interface_name();
+       if (!src_if) {
+               ERR("Source interface is null\n"); //LCOV_EXCL_LINE
+               return MOBILE_AP_ERROR_INTERNAL;
        }
 
        _block_device_sleep();
 #ifdef TIZEN_FEATURE_MULTICAST
-       _del_multicast_routing(WIFI_IF);
+       _del_multicast_routing(src_if);
 #endif
-       _del_routing_rule(WIFI_IF);
-       _del_interface_routing(WIFI_IF, IP_ADDRESS_SOFTAP);
-       _flush_ip_address(WIFI_IF);
+       _del_routing_rule(src_if);
+       _del_interface_routing(src_if, IP_ADDRESS_SOFTAP);
+       _flush_ip_address(src_if);
        _deinit_timeout_cb(type);
        if (_remove_station_info_all(type) != MOBILE_AP_ERROR_NONE)
                ERR("_remove_station_info_all is failed. Ignore it.\n"); //LCOV_EXCL_LINE
 
-       ret = _mh_core_disable_softap();
+       ret = _mh_core_disable_softap(src_if);
        if (ret != MOBILE_AP_ERROR_NONE) {
                ERR("_mh_core_disable_softap is failed : %d\n", ret); //LCOV_EXCL_LINE
                goto DONE;
@@ -1034,7 +1051,7 @@ mobile_ap_error_code_e _reload_softap_settings_for_softap(Softap *obj, softap_se
 }
 
 gboolean tethering_enable_wifi_tethering(Tethering *obj,
-               GDBusMethodInvocation *context, gchar *ssid,
+               GDBusMethodInvocation *context, gchar *tether_type, gchar *ssid,
                gchar *key, gchar *mode, gint channel, gint visibility,
                gint mac_filter, gint max_sta, gint security_type,
                gint txpower, gint address_type)
@@ -1088,6 +1105,7 @@ gboolean tethering_enable_wifi_tethering(Tethering *obj,
        wifi_settings.max_sta = max_sta;
        wifi_settings.address_type = address_type;
        wifi_settings.txpower = txpower;
+       g_strlcpy(wifi_settings.tether_type, tether_type, sizeof(wifi_settings.tether_type));
 
        if (wifi_recovery_timeout_id) {
                DBG("Wi-Fi recovery is cancelled\n"); //LCOV_EXCL_LINE
@@ -1096,29 +1114,33 @@ gboolean tethering_enable_wifi_tethering(Tethering *obj,
                prev_wifi_on = TRUE;
        }
 
+       if (g_strcmp0(wifi_settings.tether_type, "wifi_tether") == 0) {
 #ifdef TIZEN_FEATURE_ENABLE_WIFI_DIRECT
-       if (__is_wifi_direct_on() == TRUE) {
-               DBG("Wi-Fi and Wi-Fi direct are turned on\n");
-               if (__turn_off_wifi_direct(obj) != MOBILE_AP_ERROR_NONE) {
-                       ERR("_turn_off_wifi_direct is failed\n"); //LCOV_EXCL_LINE
-                       ret = MOBILE_AP_ERROR_INTERNAL;
-                       goto DONE;
+               if (__is_wifi_direct_on() == TRUE) {
+                       DBG("Wi-Fi and Wi-Fi direct are turned on\n");
+                       if (__turn_off_wifi_direct(obj) != MOBILE_AP_ERROR_NONE) {
+                               ERR("_turn_off_wifi_direct is failed\n"); //LCOV_EXCL_LINE
+                               ret = MOBILE_AP_ERROR_INTERNAL;
+                               goto DONE;
+                       }
+                       g_object_ref(g_context);
+                       return TRUE;
                }
-               g_object_ref(g_context);
-               return TRUE;
-       }
 #endif
 
-       wifi_manager_is_activated(wifi_manager, &wifi_state);
-       if (wifi_state == true) {
-               DBG("Wi-Fi is turned on\n"); //LCOV_EXCL_LINE
-               if (__turn_off_wifi(obj) != MOBILE_AP_ERROR_NONE) {
-                       ERR("_turn_off_wifi is failed\n"); //LCOV_EXCL_LINE
-                       ret = MOBILE_AP_ERROR_INTERNAL;
-                       goto DONE;
+               wifi_manager_is_activated(wifi_manager, &wifi_state);
+               if (wifi_state == true) {
+                       DBG("Wi-Fi is turned on\n"); //LCOV_EXCL_LINE
+                       if (__turn_off_wifi(obj) != MOBILE_AP_ERROR_NONE) {
+                               ERR("_turn_off_wifi is failed\n"); //LCOV_EXCL_LINE
+                               ret = MOBILE_AP_ERROR_INTERNAL;
+                               goto DONE;
+                       }
+                       g_object_ref(g_context);
+                       return TRUE;
                }
-               g_object_ref(g_context);
-               return TRUE;
+       } else {
+               /* wifi sharing */
        }
 
        ret = _enable_wifi_tethering(obj, &wifi_settings);