Set vendor element for softap 96/138896/3
authorSeonah Moon <seonah1.moon@samsung.com>
Fri, 14 Jul 2017 07:08:38 +0000 (16:08 +0900)
committertaesub kim <taesub.kim@samsung.com>
Mon, 17 Jul 2017 22:30:12 +0000 (22:30 +0000)
Change-Id: I30486947a85b66a6198ee7c3f8da74f7e0a2cde5
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
include/mobileap.h
include/mobileap_softap.h
include/mobileap_wifi.h
include/softap-dbus-interface.xml
packaging/mobileap-agent.spec
src/mobileap_softap.c
src/mobileap_wifi.c

index b69b076..e98f36b 100644 (file)
@@ -86,6 +86,7 @@ typedef enum {
 #define MOBILE_AP_WIFI_PLAIN_TEXT_KEY_MAX_LEN  63      /**< Maximum length of wifi plain text key */
 #define MOBILE_AP_WIFI_KEY_MAX_LEN     64      /**< Maximum length of wifi hash key */
 #define MOBILE_AP_WIFI_MODE_MAX_LEN 10 /**< Minimum length of wifi mode */
+#define MOBILE_AP_WIFI_VENDOR_MAX_LEN  64      /**< Maximum length of vendor elements */
 
 /**
 * Common configuration
index f0a8460..850744b 100755 (executable)
 #define HOSTAPD_MONITOR_DETACH "DETACH"
 #define HOSTAPD_DHCP_MAX_INTERVAL 30000 /* 30 seconds */
 
-/* Samsung VSIE value in beacon / probe response.
- * Wi-Fi station can identify AP whether it is tethering or AP only using this value.
- */
-#define HOSTAPD_VENDOR_ELEMENTS_TETH   "DD050016328000"        /* Samsung tethering device */
-#define HOSTAPD_VENDOR_ELEMENTS_WIFI_AP        "DD050016321000"        /* Specific application mode AP */
-/* End of hostapd configuration */
-
 #define IP_FORWARD     "/proc/sys/net/ipv4/ip_forward"
 #define IPV4_FORWARDING        "/proc/sys/net/ipv4/conf/all/forwarding"
 #define IP_CMD         "/usr/sbin/ip"
@@ -270,6 +263,7 @@ typedef struct {
        char key[MOBILE_AP_WIFI_KEY_MAX_LEN + 1];
        char security_type[SECURITY_TYPE_LEN];
        char mode[MOBILE_AP_WIFI_MODE_MAX_LEN + 1];
+       char vendor_elements[MOBILE_AP_WIFI_VENDOR_MAX_LEN + 1];
        int channel;
        int mac_filter;
        int max_sta;
index be171ea..0390680 100644 (file)
@@ -111,13 +111,13 @@ gboolean tethering_set_vpn_passthrough_rule(Tethering *obj,
 
 /* Dbus method for softap APIs */
 gboolean softap_enable(Softap *obj, GDBusMethodInvocation *context,
-               gchar *ssid, gchar *key, gint hide_mode, gint security_type);
+               gchar *ssid, gchar *key, gchar *vendor_elements, gint hide_mode, gint security_type);
 
 gboolean softap_disable(Softap *obj,
                GDBusMethodInvocation *context);
 
 gboolean softap_reload_settings(Softap *obj, GDBusMethodInvocation *context,
-               gchar *ssid, char *key, gint visibility, gint security_type);
+               gchar *ssid, gchar *key, gchar *vendor_elements, gint visibility, gint security_type);
 
 gboolean softap_set_wps_pin(Softap *obj,
                GDBusMethodInvocation *context, gchar *wps_pin);
index 37b27e9..87a40c1 100644 (file)
@@ -12,6 +12,7 @@
                <method name="enable">
                        <arg type="s" name="ssid" direction="in"/>
                        <arg type="s" name="key" direction="in"/>
+                       <arg type="s" name="vendor_elements" direction="in"/>
                        <arg type="i" name="visibility" direction="in"/>
                        <arg type="i" name="security" direction="in"/>
                        <arg type="u" name="result" direction="out"/>
@@ -24,6 +25,7 @@
                <method name="reload_settings">
                        <arg type="s" name="ssid" direction="in"/>
                        <arg type="s" name="key" direction="in"/>
+                       <arg type="s" name="vendor_elements" direction="in"/>
                        <arg type="i" name="visibility" direction="in"/>
                        <arg type="i" name="security" direction="in"/>
                        <arg type="u" name="result" direction="out"/>
index f34d7c0..aeaff6c 100644 (file)
@@ -1,6 +1,6 @@
 Name: mobileap-agent
 Summary: Mobile AP daemon for setting tethering environments
-Version: 1.0.102
+Version: 1.0.103
 Release: 1
 Group: System/Network
 License: Apache-2.0
index f34dc23..8b25132 100755 (executable)
@@ -191,16 +191,9 @@ static int __execute_hostapd(const mobile_ap_type_e type, softap_settings_t *set
 #endif
 
        /* Vendor elements conf. */
-       if (type == MOBILE_AP_TYPE_WIFI) {
+       if (strlen(settings->vendor_elements)) {
                snprintf(buf, sizeof(buf),
-                               "vendor_elements=%s\n", HOSTAPD_VENDOR_ELEMENTS_TETH);
-       } else if (type == MOBILE_AP_TYPE_WIFI_AP) {
-               snprintf(buf, sizeof(buf),
-                               "vendor_elements=%s\n", HOSTAPD_VENDOR_ELEMENTS_WIFI_AP);
-       } else {
-               ERR("Unknown type: %d\n", type);
-               g_free(conf);
-               return MOBILE_AP_ERROR_INVALID_PARAM;
+                               "vendor_elements=%s\n", settings->vendor_elements);
        }
        old_conf = conf;
        conf = g_strconcat(old_conf, buf, NULL);
@@ -296,16 +289,9 @@ static int __execute_hostapd_wps(const mobile_ap_type_e type, softap_settings_t
        conf = g_strdup(buf);
 
        /* Vendor elements conf. */
-       if (type == MOBILE_AP_TYPE_WIFI) {
+       if (strlen(settings->vendor_elements)) {
                snprintf(buf, sizeof(buf),
-                       "vendor_elements=%s\n", HOSTAPD_VENDOR_ELEMENTS_TETH);
-       } else if (type == MOBILE_AP_TYPE_WIFI_AP) {
-               snprintf(buf, sizeof(buf),
-                       "vendor_elements=%s\n", HOSTAPD_VENDOR_ELEMENTS_WIFI_AP);
-       } else {
-               ERR("Unknown type: %d\n", type);
-               g_free(conf);
-               return MOBILE_AP_ERROR_INVALID_PARAM;
+                               "vendor_elements=%s\n", settings->vendor_elements);
        }
        old_conf = conf;
        conf = g_strconcat(old_conf, buf, NULL);
index 593ef20..04bcd21 100755 (executable)
@@ -51,9 +51,9 @@ static GDBusMethodInvocation *g_context = NULL;
 static guint wifi_recovery_timeout_id = 0;
 static gboolean prev_wifi_on = FALSE;
 static gboolean is_softap = FALSE;
-static softap_settings_t wifi_settings = {0, "", "", "", "", 0, 0, 0, 0};
-static softap_settings_t wifi_ap_settings = {0, "", "", "", "", 0, 0, 0, 0};
-static softap_settings_t obj_softap_settings = {0, "", "", "", "", 0, 0, 0, 0};
+static softap_settings_t wifi_settings = {0, "", "", "", "", "", 0, 0, 0, 0};
+static softap_settings_t wifi_ap_settings = {0, "", "", "", "", "", 0, 0, 0, 0};
+static softap_settings_t obj_softap_settings = {0, "", "", "", "", "", 0, 0, 0, 0};
 
 static wifi_manager_h wifi_manager = NULL;
 
@@ -325,14 +325,17 @@ static mobile_ap_error_code_e __update_softap_settings(softap_settings_t *dst, s
        if (strlen(src->mode))
                g_strlcpy(dst->mode, src->mode, sizeof(dst->mode));
 
+       if (strlen(src->vendor_elements))
+               g_strlcpy(dst->vendor_elements, src->vendor_elements, sizeof(dst->vendor_elements));
+
        dst->channel = src->channel;
        dst->hide_mode = src->hide_mode;
        dst->mac_filter = src->mac_filter;
        dst->max_sta = src->max_sta;
        dst->address_type = src->address_type;
 
-       SDBG("ssid : %s security type : %s hide mode : %d mac filter : %d max_sta: %d hw_mode: %s \n",
-                       dst->ssid, dst->security_type, dst->hide_mode, dst->mac_filter, dst->max_sta, dst->mode);
+       SDBG("ssid : %s security type : %s hide mode : %d mac filter : %d max_sta: %d hw_mode: %s vendor: %s \n",
+                       dst->ssid, dst->security_type, dst->hide_mode, dst->mac_filter, dst->max_sta, dst->mode, dst->vendor_elements);
 
        return MOBILE_AP_ERROR_NONE;
 }
@@ -1233,7 +1236,7 @@ gboolean tethering_set_wifi_tethering_passphrase(Tethering *obj,
 }
 
 gboolean softap_enable(Softap *obj, GDBusMethodInvocation *context,
-               gchar *ssid, gchar *key, gint visibility, gint security_type)
+               gchar *ssid, gchar *key, gchar *vendor_elements, gint visibility, gint security_type)
 {
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
        gboolean ret_val = FALSE;
@@ -1266,6 +1269,7 @@ gboolean softap_enable(Softap *obj, GDBusMethodInvocation *context,
                                sizeof(wifi_ap_settings.security_type));
        }
 
+       g_strlcpy(wifi_ap_settings.vendor_elements, vendor_elements, sizeof(wifi_ap_settings.vendor_elements));
        wifi_ap_settings.hide_mode = (!visibility);
        wifi_ap_settings.address_type = MOBILE_AP_ADDRESS_TYPE_IPV4;
        wifi_ap_settings.channel = MOBILE_AP_WIFI_CHANNEL;
@@ -1340,7 +1344,7 @@ gboolean softap_disable(Softap *obj,
 
 gboolean softap_reload_settings(Softap *obj,
                GDBusMethodInvocation *context, gchar *ssid,
-               gchar *key, gint visibility, gint security_type)
+               gchar *key, gchar *vendor_elements, gint visibility, gint security_type)
 {
        mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
        gboolean ret_val = TRUE;
@@ -1365,6 +1369,8 @@ gboolean softap_reload_settings(Softap *obj,
                                sizeof(settings.security_type));
        }
 
+       g_strlcpy(wifi_ap_settings.vendor_elements, vendor_elements, sizeof(wifi_ap_settings.vendor_elements));
+
        settings.hide_mode = (!visibility);
        settings.address_type = MOBILE_AP_ADDRESS_TYPE_IPV4;
        settings.channel = MOBILE_AP_WIFI_CHANNEL;