[mobileap-agent] Enabling/disabling the mac-filtering feature 78/56578/3 accepted/tizen/common/20160222.162215 accepted/tizen/ivi/20160218.023441 accepted/tizen/mobile/20160212.002709 accepted/tizen/tv/20160212.002734 accepted/tizen/wearable/20160212.002753 submit/tizen/20160211.121512 submit/tizen_common/20160222.141210 submit/tizen_ivi/20160217.000000 submit/tizen_ivi/20160217.000002
authorSeonah Moon <seonah1.moon@samsung.com>
Mon, 11 Jan 2016 09:03:41 +0000 (18:03 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Thu, 11 Feb 2016 01:29:52 +0000 (10:29 +0900)
1. Set/Get enable mac-filtering feature
2. Add/Remove mac address allowed/white list
3. Add/Remove mac address blocked/black list

Change-Id: I4195db46e6ac358a6d09dc2233d440b9eeef89bc
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
include/mobileap_softap.h
include/mobileap_wifi.h
include/tethering-dbus-interface.xml
src/mobileap_handler.c
src/mobileap_softap.c
src/mobileap_wifi.c

index e3a4718..45235d2 100755 (executable)
                                "ignore_broadcast_ssid=%d\n" \
                                "hw_mode=%s\n" \
                                "max_num_sta=%d\n" \
+                               "macaddr_acl=%d\n" \
+                               "accept_mac_file=/etc/hostapd.accept\n" \
+                               "deny_mac_file=/etc/hostapd.deny\n" \
                                "ieee80211n=1\n"
 #else
 #define HOSTAPD_CONF           "interface=%s\n" \
                                "ignore_broadcast_ssid=%d\n" \
                                "hw_mode=%s\n" \
                                "max_num_sta=%d\n" \
+                               "macaddr_acl=%d\n" \
+                               "accept_mac_file=/etc/hostapd.accept\n" \
+                               "deny_mac_file=/etc/hostapd.deny\n" \
                                "ieee80211n=1\n" \
                                "wowlan_triggers=any\n"
 #endif
@@ -179,6 +185,7 @@ typedef struct {
        char security_type[SECURITY_TYPE_LEN];
        char mode[MOBILE_AP_WIFI_MODE_MAX_LEN + 1];
        int channel;
+       int mac_filter;
 } softap_settings_t;
 
 typedef struct {
@@ -206,7 +213,7 @@ typedef struct {
 
 /* ssid : 32  key : 64 */
 int _mh_core_enable_softap(const mobile_ap_type_e type, const char *ssid,
-               const char *security, const char *key, const char *mode, int channel, int hide_mode);
+               const char *security, const char *key, const char *mode, int channel, int hide_mode, int mac_filter);
 int _mh_core_disable_softap(void);
 int _mh_core_get_device_info(softap_device_info_t *di);
 int _mh_core_execute_dhcp_server(void);
index daa8f4c..3e1024d 100644 (file)
@@ -33,6 +33,7 @@ typedef enum {
 
 typedef struct {
        int hide_mode;
+       int mac_filter;
        char *ssid;
        char *key;
        char *mode;
@@ -42,11 +43,11 @@ typedef struct {
 
 int _get_wifi_name_from_lease_info(const char *mac, char **name_buf);
 mobile_ap_error_code_e _enable_wifi_tethering(Tethering *obj, gchar *ssid,
-       gchar *passphrase, gchar* mode, gint channel, int hide_mode, softap_security_type_e security_type);
+       gchar *passphrase, gchar* mode, gint channel, int hide_mode, int mac_filter, softap_security_type_e security_type);
 mobile_ap_error_code_e _disable_wifi_tethering(Tethering *obj);
 gboolean _is_trying_wifi_operation(void);
 mobile_ap_error_code_e _reload_softap_settings(Tethering *obj,
-               gchar *ssid, gchar *key, gchar* mode, gint channel, gint hide_mode, gint security_type);
+               gchar *ssid, gchar *key, gchar* mode, gint channel, gint hide_mode, gint mac_filter, gint security_type);
 mobile_ap_error_code_e _reload_softap_settings_for_ap(Tethering *obj,
        gchar *ssid, gchar *key, gint hide_mode, gint security_type);
 
@@ -57,7 +58,7 @@ mobile_ap_error_code_e _enable_wifi_ap(Tethering *obj, gchar *ssid,
 mobile_ap_error_code_e _disable_wifi_ap(Tethering *obj);
 gboolean tethering_enable_wifi_tethering(Tethering *obj,
                GDBusMethodInvocation *context, gchar *ssid,
-               gchar *key, gchar* mode, gint channel, gint visibility, gint security_type);
+               gchar *key, gchar* mode, gint channel, gint visibility, gint mac_filter, gint security_type);
 
 softap_settings_t  *_get_softap_settings();
 
@@ -66,7 +67,7 @@ gboolean tethering_disable_wifi_tethering(Tethering *obj,
 
 gboolean tethering_reload_wifi_settings(Tethering *obj,
                GDBusMethodInvocation *context,
-               gchar *ssid, gchar *key, gchar* mode, gint channel, gint visibility, gint security_type);
+               gchar *ssid, gchar *key, gchar* mode, gint channel, gint visibility, gint mac_filter, gint security_type);
 
 gboolean tethering_reload_wifi_ap_settings(Tethering *obj,
                                GDBusMethodInvocation *context, gchar *ssid, gchar *key,
index d4115c4..7c9ecbf 100644 (file)
@@ -20,6 +20,7 @@
                        <arg type="s" name="mode" direction="in"/>
                        <arg type="i" name="channel" direction="in"/>
                        <arg type="i" name="visibility" direction="in"/>
+                       <arg type="i" name="mac_filter" direction="in"/>
                        <arg type="i" name="security" direction="in"/>
                        <arg type="u" name="result" direction="out"/>
                </method>
@@ -84,6 +85,7 @@
                        <arg type="s" name="mode" direction="in"/>
                        <arg type="i" name="channel" direction="in"/>
                        <arg type="i" name="visibility" direction="in"/>
+                       <arg type="i" name="mac_filter" direction="in"/>
                        <arg type="i" name="security" direction="in"/>
                        <arg type="u" name="result" direction="out"/>
                </method>
index 4035128..0b5579b 100644 (file)
@@ -114,7 +114,7 @@ static void __handle_device_name_changed_cb(keynode_t *key, void *data)
                }
                if (_mobileap_is_enabled(MOBILE_AP_STATE_WIFI)) {
                        _reload_softap_settings(obj, vconf_key, new_settings->key,
-                                       new_settings->mode, new_settings->channel, new_settings->hide_mode, sec_type);
+                                       new_settings->mode, new_settings->channel, new_settings->hide_mode, new_settings->mac_filter, sec_type);
                } else if (_mobileap_is_enabled(MOBILE_AP_STATE_WIFI_AP)) {
                        _reload_softap_settings_for_ap(obj, vconf_key, new_settings->key,
                                        new_settings->hide_mode, sec_type);
index 1282006..5a68e5b 100755 (executable)
@@ -133,7 +133,7 @@ static int __get_psk_hexascii(const char *pass, const unsigned char *salt,
 }
 
 static int __execute_hostapd(const mobile_ap_type_e type, const char *ssid,
-               const char *security, const char *passphrase, const char* mode, int channel, int hide_mode)
+               const char *security, const char *passphrase, const char* mode, int channel, int hide_mode, int mac_filter)
 {
        DBG("+\n");
 
@@ -160,7 +160,8 @@ static int __execute_hostapd(const mobile_ap_type_e type, const char *ssid,
                        channel,
                        hide_mode ? 2 : 0,
                        hw_mode,
-                       MOBILE_AP_MAX_WIFI_STA);
+                       MOBILE_AP_MAX_WIFI_STA,
+                       mac_filter);
        conf = g_strdup(buf);
 
        free(hw_mode);
@@ -778,7 +779,7 @@ static int __mh_core_softap_firmware_stop(void)
 }
 
 int _mh_core_enable_softap(const mobile_ap_type_e type, const char *ssid,
-               const char *security, const char *key, const char *mode, int channel, int hide_mode)
+               const char *security, const char *key, const char *mode, int channel, int hide_mode, int mac_filter)
 {
        if (ssid == NULL || security == NULL || key == NULL) {
                ERR("Invalid param\n");
@@ -867,7 +868,7 @@ int _mh_core_enable_softap(const mobile_ap_type_e type, const char *ssid,
                        break;
                }
 
-               ret_status = __execute_hostapd(type, ssid, security, key, mode, channel, hide_mode);
+               ret_status = __execute_hostapd(type, ssid, security, key, mode, channel, hide_mode, mac_filter);
                if (ret_status != MOBILE_AP_ERROR_NONE) {
                        ERR("__execute_hostapd is failed\n");
                        break;
index 43da453..548a076 100755 (executable)
@@ -37,7 +37,7 @@
 #define MOBILE_AP_WIFI_PASSPHRASE_STORE_KEY "tethering_wifi_passphrase"
 
 static mobile_ap_error_code_e __update_softap_settings(softap_settings_t *st,
-       gchar *ssid, gchar *passphrase, gchar* mode, gint channel, int hide_mode, softap_security_type_e security_type);
+       gchar *ssid, gchar *passphrase, gchar* mode, gint channel, int hide_mode, int mac_filter, softap_security_type_e security_type);
 static mobile_ap_error_code_e __get_passphrase(char *passphrase,
        unsigned int passphrase_size, unsigned int *passphrase_len);
 static mobile_ap_error_code_e __set_passphrase(const char *passphrase, const unsigned int size);
@@ -96,7 +96,7 @@ static void _wifi_direct_state_cb(int error_code, wifi_direct_device_state_e sta
        }
 
        ret = _enable_wifi_tethering(obj, wifi_settings.ssid, wifi_settings.key,
-                       wifi_settings.mode, wifi_settings.channel, wifi_settings.hide_mode, wifi_settings.security_type);
+                       wifi_settings.mode, wifi_settings.channel, wifi_settings.hide_mode, wifi_settings.mac_filter, wifi_settings.security_type);
        if (ret != MOBILE_AP_ERROR_NONE) {
                ERR("_enable_wifi_tethering is failed\n");
        } else {
@@ -144,7 +144,7 @@ static void __wifi_deactivated_cb(wifi_error_e result, void *user_data)
        DBG("Wi-Fi is turned off\n");
 
        ret = _enable_wifi_tethering(obj, wifi_settings.ssid, wifi_settings.key,
-                       wifi_settings.mode, wifi_settings.channel, wifi_settings.hide_mode, wifi_settings.security_type);
+                       wifi_settings.mode, wifi_settings.channel, wifi_settings.hide_mode, wifi_settings.mac_filter, wifi_settings.security_type);
        if (ret != MOBILE_AP_ERROR_NONE) {
                ERR("_enable_wifi_tethering is failed\n");
        } else {
@@ -262,7 +262,7 @@ static int __turn_off_wifi_direct(Tethering *obj)
 }
 
 static mobile_ap_error_code_e __update_softap_settings(softap_settings_t *st,
-       gchar *ssid, gchar *passphrase, gchar* mode, gint channel, int hide_mode, softap_security_type_e security_type)
+       gchar *ssid, gchar *passphrase, gchar* mode, gint channel, int hide_mode, int mac_filter, softap_security_type_e security_type)
 {
        if (st == NULL) {
                ERR("Invalid param\n");
@@ -292,9 +292,10 @@ static mobile_ap_error_code_e __update_softap_settings(softap_settings_t *st,
 
        st->channel = channel;
        st->hide_mode = hide_mode;
+       st->mac_filter = mac_filter;
 
-       SDBG("ssid : %s security type : %s hide mode : %d\n",
-                       st->ssid, st->security_type, st->hide_mode);
+       SDBG("ssid : %s security type : %s hide mode : %d mac filter : %d\n",
+                       st->ssid, st->security_type, st->hide_mode, st->mac_filter);
 
        return MOBILE_AP_ERROR_NONE;
 }
@@ -304,6 +305,9 @@ static gboolean __is_equal_softap_settings(softap_settings_t *a, softap_settings
        if (a->hide_mode != b->hide_mode)
                return FALSE;
 
+       if (a->mac_filter != b->mac_filter)
+               return FALSE;
+
        if (strcmp(a->ssid, b->ssid) != 0)
                return FALSE;
 
@@ -323,7 +327,7 @@ static gboolean __is_equal_softap_settings(softap_settings_t *a, softap_settings
 }
 
 mobile_ap_error_code_e _reload_softap_settings(Tethering *obj,
-               gchar *ssid, gchar *key, gchar* mode, gint channel, gint hide_mode, gint security_type)
+               gchar *ssid, gchar *key, gchar* mode, gint channel, gint hide_mode, gint mac_filter, gint security_type)
 {
        gboolean backup_prev_wifi_on = prev_wifi_on;
        mobile_ap_error_code_e ret;
@@ -339,7 +343,7 @@ mobile_ap_error_code_e _reload_softap_settings(Tethering *obj,
                return MOBILE_AP_ERROR_NONE;
 
        ret = __update_softap_settings(&new_settings, ssid, key, mode, channel, hide_mode,
-                       (softap_security_type_e)security_type);
+                       mac_filter, (softap_security_type_e)security_type);
        if (ret != MOBILE_AP_ERROR_NONE) {
                ERR("__update_softap_settings is failed\n");
                return ret;
@@ -360,7 +364,7 @@ mobile_ap_error_code_e _reload_softap_settings(Tethering *obj,
        }
 
        ret = _enable_wifi_tethering(obj, ssid, key, mode, channel, hide_mode,
-                       (softap_security_type_e)security_type);
+                       mac_filter, (softap_security_type_e)security_type);
        if (ret != MOBILE_AP_ERROR_NONE) {
                ERR("_enable_wifi_tethering is failed : %d\n", ret);
                return ret;
@@ -385,7 +389,7 @@ mobile_ap_error_code_e _reload_softap_settings_for_ap(Tethering *obj,
        }
 
        ret = __update_softap_settings(&new_settings, ssid, key, NULL, MOBILE_AP_WIFI_CHANNEL, hide_mode,
-                       (softap_security_type_e)security_type);
+                       false, (softap_security_type_e)security_type);
        if (ret != MOBILE_AP_ERROR_NONE) {
                ERR("__update_softap_settings is failed\n");
                return ret;
@@ -455,7 +459,7 @@ int _get_wifi_name_from_lease_info(const char *mac, char **name_buf)
 }
 
 mobile_ap_error_code_e _enable_wifi_tethering(Tethering *obj, gchar *ssid,
-       gchar *passphrase, gchar* mode, gint channel, int hide_mode, softap_security_type_e security_type)
+       gchar *passphrase, gchar* mode, gint channel, int hide_mode, int mac_filter, softap_security_type_e security_type)
 {
        mobile_ap_error_code_e ret;
 
@@ -489,7 +493,7 @@ mobile_ap_error_code_e _enable_wifi_tethering(Tethering *obj, gchar *ssid,
 
        /* Update Wi-Fi hotspot data to global settings pointer */
        ret = __update_softap_settings(&obj_softap_settings, ssid, passphrase,
-                       mode, channel, hide_mode, security_type);
+                       mode, channel, hide_mode, mac_filter, security_type);
        if (ret != MOBILE_AP_ERROR_NONE) {
                _mobileap_clear_state(MOBILE_AP_STATE_WIFI);
                return ret;
@@ -515,7 +519,8 @@ mobile_ap_error_code_e _enable_wifi_tethering(Tethering *obj, gchar *ssid,
                        obj_softap_settings.key,
                        obj_softap_settings.mode,
                        obj_softap_settings.channel,
-                       obj_softap_settings.hide_mode);
+                       obj_softap_settings.hide_mode,
+                       obj_softap_settings.mac_filter);
        if (ret != MOBILE_AP_ERROR_NONE) {
                _deinit_tethering();
                _mobileap_clear_state(MOBILE_AP_STATE_WIFI);
@@ -566,7 +571,7 @@ mobile_ap_error_code_e _enable_wifi_ap(Tethering *obj,
                return MOBILE_AP_ERROR_RESOURCE;
        }
        ret = __update_softap_settings(&obj_softap_settings, ssid, passphrase,
-                       NULL, MOBILE_AP_WIFI_CHANNEL, hide_mode, security_type);
+                       NULL, MOBILE_AP_WIFI_CHANNEL, hide_mode, false, security_type);
        if (ret != MOBILE_AP_ERROR_NONE) {
                _mobileap_clear_state(MOBILE_AP_STATE_WIFI_AP);
                return ret;
@@ -587,7 +592,8 @@ mobile_ap_error_code_e _enable_wifi_ap(Tethering *obj,
                        obj_softap_settings.key,
                        NULL,
                        obj_softap_settings.channel,
-                       obj_softap_settings.hide_mode);
+                       obj_softap_settings.hide_mode,
+                       obj_softap_settings.mac_filter);
        if (ret != MOBILE_AP_ERROR_NONE) {
                _deinit_tethering();
                _mobileap_clear_state(MOBILE_AP_STATE_WIFI_AP);
@@ -696,7 +702,7 @@ DONE:
 
 gboolean tethering_enable_wifi_tethering(Tethering *obj,
                GDBusMethodInvocation *context, gchar *ssid,
-               gchar *key, gchar *mode, gint channel, gint visibility, gint security_type)
+               gchar *key, gchar *mode, gint channel, gint visibility, gint mac_filter, gint security_type)
 {
        DBG("+\n");
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
@@ -753,7 +759,7 @@ gboolean tethering_enable_wifi_tethering(Tethering *obj,
        }
 
        ret = _enable_wifi_tethering(obj, ssid, key, mode, channel, !visibility,
-                       (softap_security_type_e)security_type);
+                       mac_filter, (softap_security_type_e)security_type);
        if (ret != MOBILE_AP_ERROR_NONE) {
                ERR("_enable_wifi_tethering is failed\n");
        } else {
@@ -845,7 +851,7 @@ gboolean tethering_disable_wifi_ap(Tethering *obj,
 
 gboolean tethering_reload_wifi_settings(Tethering *obj,
                GDBusMethodInvocation *context, gchar *ssid,
-               gchar *key, gchar *mode, gint channel, gint visibility, gint security_type)
+               gchar *key, gchar *mode, gint channel, gint visibility, gint mac_filter, gint security_type)
 {
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
        gboolean ret_val = TRUE;
@@ -854,7 +860,7 @@ gboolean tethering_reload_wifi_settings(Tethering *obj,
        g_assert(obj != NULL);
        g_assert(context != NULL);
 
-       ret = _reload_softap_settings(obj, ssid, key, mode, channel, !visibility, security_type);
+       ret = _reload_softap_settings(obj, ssid, key, mode, channel, !visibility, mac_filter, security_type);
        if (ret != MOBILE_AP_ERROR_NONE) {
                ERR("_reload_softap_settings is failed\n");
                ret_val = FALSE;