Fix internet access issue in second Wi-Fi hotspot 81/243181/2 accepted/tizen/unified/20200915.014613 submit/tizen/20200914.130535
authorNishant Chaprana <n.chaprana@samsung.com>
Thu, 3 Sep 2020 17:48:49 +0000 (23:18 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Thu, 3 Sep 2020 17:53:37 +0000 (23:23 +0530)
This patch fixes the internet access issue in second Wi-Fi hotspot
by using separate subnet for each wifi interface.

Change-Id: I782d71ec74ef824947726be87db1068b2254879b
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
include/mobileap_softap.h
packaging/mobileap-agent.spec
src/mobileap_common.c
src/mobileap_iptables.c
src/mobileap_softap.c

index c35b37f..9d59a63 100755 (executable)
 #define WIFI_IF                        "wlan0"
 #define WIFI_IF_1              "wlan1"
 #define IP_ADDRESS_WIFI                0xC0A82B02      /* 192.168.43.2 */
-#define IP_ADDRESS_WIFI_5G     0xC0A82B04      /* 192.168.43.4 */
+#define IP_ADDRESS_WIFI_5G     0xC0A82C02      /* 192.168.44.2 */
 
 #define SOFTAP_IF              "wl0.1"
 #define SOFTAP_IF_5G            "wl0.2"
 #define IP_ADDRESS_SOFTAP      0xC0A82B01      /* 192.168.43.1 */
-#define IP_ADDRESS_SOFTAP_5G   0xC0A82B03      /* 192.168.43.3 */
+#define IP_ADDRESS_SOFTAP_5G   0xC0A82C01      /* 192.168.44.1 */
 
 #define USB_IF                 "usb0"
 #define IP_ADDRESS_USB         0xC0A88103      /* 192.168.129.3 */
@@ -84,6 +84,7 @@
 #define DNSMASQ_CONF_FILE      "/tmp/dnsmasq.conf"
 #define DNSMASQ_CONF   \
                        "dhcp-range=%s,%s,255.255.255.0\n" \
+                       "dhcp-range=192.168.44.3,192.168.44.150,255.255.255.0\n" \
                        "dhcp-range=192.168.130.2,192.168.130.150,255.255.255.0\n" \
                        "dhcp-range=192.168.131.2,192.168.131.150,255.255.255.0\n" \
                        "dhcp-range=192.168.132.2,192.168.132.150,255.255.255.0\n" \
                        "enable-ra\n" \
                        "dhcp-range=interface:usb0, %s::ffff:ffe0, %s::ffff:ffff, 64, 12h\n"\
                        "dhcp-range=interface:wlan0, %s::fffe:ffe0, %s::fffe:ffff, 64, 12h\n"\
+                       "dhcp-range=interface:wlan1, %s::fffe:ffe0, %s::fffe:ffff, 64, 12h\n"\
                        "dhcp-range=interface:bnep0, %s::fffd:ffe0, %s::fffd:ffff, 64, 12h\n"\
                        "dhcp-range=interface:bnep1, %s::fffc:ffe0, %s::fffc:ffff, 64, 12h\n"\
                        "dhcp-range=interface:bnep2, %s::fffb:ffe0, %s::fffb:ffff, 64, 12h\n"\
index c6f0e52..a507c92 100644 (file)
@@ -1,6 +1,6 @@
 Name: mobileap-agent
 Summary: Mobile AP daemon for setting tethering environments
-Version: 1.0.138
+Version: 1.0.139
 Release: 1
 Group: System/Network
 License: Apache-2.0
index ec1328c..e605cb4 100755 (executable)
@@ -635,6 +635,7 @@ int _get_tethering_type_from_ip(const char *ip, mobile_ap_type_e *type)
 
        static gboolean is_init = FALSE;
        static in_addr_t subnet_wifi;
+       static in_addr_t subnet_wifi_5g;
        static in_addr_t subnet_bt_min;
        static in_addr_t subnet_bt_max;
        static in_addr_t subnet_usb;
@@ -654,6 +655,9 @@ int _get_tethering_type_from_ip(const char *ip, mobile_ap_type_e *type)
                        addr.s_addr = htonl(IP_ADDRESS_WIFI);
                        subnet_wifi = inet_netof(addr);
 
+                       addr.s_addr = htonl(IP_ADDRESS_WIFI_5G);
+                       subnet_wifi_5g = inet_netof(addr);
+
                        addr.s_addr = htonl(IP_ADDRESS_BT_1);
                        subnet_bt_min = inet_netof(addr);
 
@@ -672,7 +676,7 @@ int _get_tethering_type_from_ip(const char *ip, mobile_ap_type_e *type)
                        subnet_wifi = inet_netof(addr);
                }
 
-               if (subnet == subnet_wifi) {
+               if (subnet == subnet_wifi || subnet == subnet_wifi_5g) {
                        if (_mobileap_is_enabled(MOBILE_AP_STATE_WIFI))
                                *type = MOBILE_AP_TYPE_WIFI;
                        else
index 390f516..185ea6f 100755 (executable)
@@ -39,6 +39,7 @@
 #define PORT_FORWARD_RULE_STR          "-t %s -A %s -i %s -p %s -d %s --dport %d -j DNAT --to %s:%d"
 #define CLAMP_MSS_RULE_STR                     "-t %s -A %s -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu"
 #define DEFAULT_RULE_STR                       "-t %s -A %s -j %s"
+#define DEL_DEFAULT_RULE_STR                   "-t %s -D %s -j %s"
 #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"
 
@@ -385,6 +386,21 @@ int _iptables_delete_rule(iptables_rule_e rule_type, const char *table, const ch
                break;
        }
 #endif
+       case DEFAULT_RULE: {
+               char *action;
+
+               action = va_arg(ap, char *);
+
+               if (action == NULL) {
+                       ERR("invalid parameters\n"); //LCOV_EXCL_LINE
+                       goto ERROR_EXIT;
+               }
+
+               snprintf(cmd, sizeof(cmd), "%s "DEL_DEFAULT_RULE_STR, IPTABLES,
+                       table, chain, action);
+               break;
+       }
+
        default:
                ERR("case not supported\n"); //LCOV_EXCL_LINE
                goto ERROR_EXIT;
index e666aa8..b412966 100755 (executable)
@@ -1576,6 +1576,9 @@ int _mh_core_enable_masquerade(const char *ext_if)
 
        _iptables_create_chain(TABLE_FILTER, TETH_FILTER_FW);
 
+       _iptables_delete_rule(DEFAULT_RULE, TABLE_FILTER, TETH_FILTER_FW,
+               ACTION_DROP);
+
        _iptables_add_rule(PKT_REDIRECTION_RULE, TABLE_FILTER, CHAIN_FW,
                        TETH_FILTER_FW);
 
@@ -2358,7 +2361,8 @@ int _mh_core_execute_dhcp6_server(void)
                                        prefix, prefix, prefix, prefix,
                                        prefix, prefix, prefix, prefix,
                                        prefix, prefix, prefix, prefix,
-                                       prefix, prefix, dns_addr);
+                                       prefix, prefix, prefix, prefix,
+                                       dns_addr);
                } else {
                        prefix = g_strndup(network_addr, 10);
                        snprintf(buf, DNSMASQ_CONF_LEN,
@@ -2367,7 +2371,8 @@ int _mh_core_execute_dhcp6_server(void)
                                        prefix, prefix, prefix, prefix,
                                        prefix, prefix, prefix, prefix,
                                        prefix, prefix, prefix, prefix,
-                                       prefix, prefix, DNS64_SERVER_ADDR);
+                                       prefix, prefix, prefix, prefix,
+                                       DNS64_SERVER_ADDR);
                }
 
                fputs(buf, fp);