From dc049dce1b0205b1ac6fdb02a2794b673cadb762 Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Fri, 14 Jul 2017 16:08:38 +0900 Subject: [PATCH] Set vendor element for softap Change-Id: I30486947a85b66a6198ee7c3f8da74f7e0a2cde5 Signed-off-by: Seonah Moon --- include/mobileap.h | 1 + include/mobileap_softap.h | 8 +------- include/mobileap_wifi.h | 4 ++-- include/softap-dbus-interface.xml | 2 ++ packaging/mobileap-agent.spec | 2 +- src/mobileap_softap.c | 22 ++++------------------ src/mobileap_wifi.c | 20 +++++++++++++------- 7 files changed, 24 insertions(+), 35 deletions(-) diff --git a/include/mobileap.h b/include/mobileap.h index b69b076..e98f36b 100644 --- a/include/mobileap.h +++ b/include/mobileap.h @@ -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 diff --git a/include/mobileap_softap.h b/include/mobileap_softap.h index f0a8460..850744b 100755 --- a/include/mobileap_softap.h +++ b/include/mobileap_softap.h @@ -206,13 +206,6 @@ #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; diff --git a/include/mobileap_wifi.h b/include/mobileap_wifi.h index be171ea..0390680 100644 --- a/include/mobileap_wifi.h +++ b/include/mobileap_wifi.h @@ -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); diff --git a/include/softap-dbus-interface.xml b/include/softap-dbus-interface.xml index 37b27e9..87a40c1 100644 --- a/include/softap-dbus-interface.xml +++ b/include/softap-dbus-interface.xml @@ -12,6 +12,7 @@ + @@ -24,6 +25,7 @@ + diff --git a/packaging/mobileap-agent.spec b/packaging/mobileap-agent.spec index f34d7c0..aeaff6c 100644 --- a/packaging/mobileap-agent.spec +++ b/packaging/mobileap-agent.spec @@ -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 diff --git a/src/mobileap_softap.c b/src/mobileap_softap.c index f34dc23..8b25132 100755 --- a/src/mobileap_softap.c +++ b/src/mobileap_softap.c @@ -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); diff --git a/src/mobileap_wifi.c b/src/mobileap_wifi.c index 593ef20..04bcd21 100755 --- a/src/mobileap_wifi.c +++ b/src/mobileap_wifi.c @@ -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; -- 2.7.4