summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Kim <jeik01.kim@samsung.com>2018-11-06 10:37:10 (GMT)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>2018-11-06 10:37:10 (GMT)
commit271ae828d35c8814e18b3de80cb835513640c0db (patch)
tree6b76406bfcef81ef4e07d77933c01ea4e103745d
parentae2e73a206fa707a9f490f0e7c51a855ed874cbe (diff)
parent071fe548f78efbfa84ee6841c013713903a7e28c (diff)
downloadconnman-271ae828d35c8814e18b3de80cb835513640c0db.zip
connman-271ae828d35c8814e18b3de80cb835513640c0db.tar.gz
connman-271ae828d35c8814e18b3de80cb835513640c0db.tar.bz2
Merge "[CONNMAN][Change AP's max speed logic]" into tizen
-rw-r--r--gsupplicant/gsupplicant.h11
-rw-r--r--gsupplicant/supplicant.c92
-rwxr-xr-xinclude/network.h6
-rw-r--r--packaging/connman.spec2
-rw-r--r--plugins/wifi.c67
-rwxr-xr-xsrc/network.c19
-rw-r--r--src/service.c4
7 files changed, 200 insertions, 1 deletions
diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 7e94711..035789e 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -288,6 +288,11 @@ typedef void (*GSupplicantInterfaceCallback) (int result,
GSupplicantInterface *interface,
void *user_data);
+#if defined TIZEN_EXT
+typedef void (*GSupplicantMaxSpeedCallback) (int result,
+ int maxspeed, void *user_data);
+#endif
+
void g_supplicant_interface_cancel(GSupplicantInterface *interface);
int g_supplicant_interface_create(const char *ifname, const char *driver,
@@ -302,6 +307,12 @@ int g_supplicant_interface_scan(GSupplicantInterface *interface,
GSupplicantInterfaceCallback callback,
void *user_data);
+#if defined TIZEN_EXT
+int g_supplicant_interface_signalpoll(GSupplicantInterface *interface,
+ GSupplicantMaxSpeedCallback callback,
+ void *user_data);
+#endif
+
int g_supplicant_interface_p2p_find(GSupplicantInterface *interface,
GSupplicantInterfaceCallback callback,
void *user_data);
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 83acfc5..e300f19 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -314,6 +314,15 @@ struct interface_data {
GSupplicantSSID *ssid;
};
+#if defined TIZEN_EXT
+struct interface_signalpoll_data {
+ GSupplicantInterface *interface;
+ char *path;
+ GSupplicantMaxSpeedCallback callback;
+ void *user_data;
+};
+#endif
+
struct interface_create_data {
char *ifname;
char *driver;
@@ -5313,6 +5322,89 @@ int g_supplicant_interface_scan(GSupplicantInterface *interface,
return ret;
}
+#if defined TIZEN_EXT
+static void interface_signalpoll_result(const char *error,
+ DBusMessageIter *iter, void *user_data)
+{
+ struct interface_signalpoll_data *data = user_data;
+ int err = 0;
+ dbus_int32_t maxspeed = 0;
+ DBusMessageIter sub_iter, dict;
+
+ if (error) {
+ err = -EIO;
+ SUPPLICANT_DBG("error: %s", error);
+ goto out;
+ }
+
+ dbus_message_iter_get_arg_type(iter);
+ dbus_message_iter_recurse(iter, &sub_iter);
+ dbus_message_iter_recurse(&sub_iter, &dict);
+
+ while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, value;
+ const char *key;
+
+ dbus_message_iter_recurse(&dict, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &value);
+
+ switch (dbus_message_iter_get_arg_type(&value)) {
+ case DBUS_TYPE_INT32:
+ if (g_strcmp0(key, "linkspeed") == 0) {
+ dbus_message_iter_get_basic(&value, &maxspeed);
+ SUPPLICANT_DBG("linkspeed = %d", maxspeed);
+ break;
+ }
+ }
+ dbus_message_iter_next(&dict);
+ }
+
+out:
+ if(data->callback)
+ data->callback(err, maxspeed, data->user_data);
+
+ g_free(data->path);
+ dbus_free(data);
+}
+
+int g_supplicant_interface_signalpoll(GSupplicantInterface *interface,
+ GSupplicantMaxSpeedCallback callback,
+ void *user_data)
+{
+ struct interface_signalpoll_data *data;
+ int ret;
+
+ if (!interface)
+ return -EINVAL;
+
+ if (!system_available)
+ return -EFAULT;
+
+ data = dbus_malloc0(sizeof(*data));
+ if (!data)
+ return -ENOMEM;
+
+ data->interface = interface;
+ data->path = g_strdup(interface->path);
+ data->callback = callback;
+ data->user_data = user_data;
+
+ ret = supplicant_dbus_method_call(interface->path,
+ SUPPLICANT_INTERFACE ".Interface", "SignalPoll",
+ NULL, interface_signalpoll_result, data,
+ interface);
+
+ if (ret < 0) {
+ g_free(data->path);
+ dbus_free(data);
+ }
+
+ return ret;
+}
+#endif
+
static int parse_supplicant_error(DBusMessageIter *iter)
{
int err = -ECONNABORTED;
diff --git a/include/network.h b/include/network.h
index 98fa7d7..2c74299 100755
--- a/include/network.h
+++ b/include/network.h
@@ -142,8 +142,14 @@ unsigned char *connman_network_get_bssid(struct connman_network *network);
int connman_network_set_maxrate(struct connman_network *network,
unsigned int maxrate);
+
+int connman_network_set_maxspeed(struct connman_network *network,
+ int maxrate);
+
unsigned int connman_network_get_maxrate(struct connman_network *network);
+int connman_network_get_maxspeed(struct connman_network *network);
+
int connman_network_set_enc_mode(struct connman_network *network,
const char *encryption_mode);
const char *connman_network_get_enc_mode(struct connman_network *network);
diff --git a/packaging/connman.spec b/packaging/connman.spec
index dd32047..e5e1b0e 100644
--- a/packaging/connman.spec
+++ b/packaging/connman.spec
@@ -5,7 +5,7 @@
Name: connman
Version: 1.35
-Release: 29
+Release: 30
License: GPL-2.0+
Summary: Connection Manager
Url: http://connman.net
diff --git a/plugins/wifi.c b/plugins/wifi.c
index fe753d7..92e70f4 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -3426,6 +3426,59 @@ static int network_disconnect(struct connman_network *network)
return err;
}
+#if defined TIZEN_EXT
+static unsigned int automaxspeed_timeout = 0;
+
+static void signalpoll_callback(int result, int maxspeed, void *user_data)
+{
+ struct connman_network *network = user_data;
+
+ if (result != 0) {
+ DBG("Failed to get maxspeed from signalpoll !");
+ return;
+ }
+
+ DBG("maxspeed = %d", maxspeed);
+ if (network)
+ connman_network_set_maxspeed(network, maxspeed);
+}
+
+static int network_signalpoll(struct connman_network *network)
+{
+ struct connman_device *device = connman_network_get_device(network);
+ struct wifi_data *wifi;
+ GSupplicantInterface *interface;
+
+ DBG("network %p", network);
+ wifi = connman_device_get_data(device);
+
+ if (!wifi)
+ return -ENODEV;
+
+ interface = wifi->interface;
+
+ return g_supplicant_interface_signalpoll(interface, signalpoll_callback, network);
+}
+
+static gboolean autosignalpoll_timeout(gpointer data)
+{
+ struct connman_network *network = data;
+ int ret = 0;
+
+ automaxspeed_timeout = 0;
+ ret = network_signalpoll(network);
+
+ if (ret < 0) {
+ DBG("Fail to get max speed !!");
+ return FALSE;
+ }
+
+ automaxspeed_timeout = g_timeout_add_seconds(30, autosignalpoll_timeout, network);
+
+ return FALSE;
+}
+#endif
+
static struct connman_network_driver network_driver = {
.name = "wifi",
.type = CONNMAN_NETWORK_TYPE_WIFI,
@@ -3768,6 +3821,11 @@ static void interface_state(GSupplicantInterface *interface)
CONNMAN_SERVICE_TYPE_WIFI, false);
connman_device_unref(device);
}
+
+ if (!automaxspeed_timeout) {
+ DBG("Going to start signalpoll timer!!");
+ autosignalpoll_timeout(network);
+ }
#else
/* though it should be already stopped: */
stop_autoscan(device);
@@ -3784,6 +3842,15 @@ static void interface_state(GSupplicantInterface *interface)
break;
case G_SUPPLICANT_STATE_DISCONNECTED:
+#if defined TIZEN_EXT
+ connman_network_set_maxspeed(network, 0);
+
+ if (automaxspeed_timeout != 0) {
+ g_source_remove(automaxspeed_timeout);
+ automaxspeed_timeout = 0;
+ DBG("Remove signalpoll timer!!");
+ }
+#endif
/*
* If we're in one of the idle modes, we have
* not started association yet and thus setting
diff --git a/src/network.c b/src/network.c
index e189955..85eb0fd 100755
--- a/src/network.c
+++ b/src/network.c
@@ -108,6 +108,7 @@ struct connman_network {
char encryption_mode[WIFI_ENCYPTION_MODE_LEN_MAX];
unsigned char bssid[WIFI_BSSID_LEN_MAX];
unsigned int maxrate;
+ int maxspeed;
bool isHS20AP;
unsigned int keymgmt;
char *keymgmt_type;
@@ -1972,6 +1973,24 @@ unsigned char *connman_network_get_bssid(struct connman_network *network)
return (unsigned char *)network->wifi.bssid;
}
+int connman_network_set_maxspeed(struct connman_network *network,
+ int maxspeed)
+{
+ network->wifi.maxspeed = maxspeed;
+ return 0;
+}
+
+int connman_network_get_maxspeed(struct connman_network *network)
+{
+ if (!network->driver)
+ return 0;
+
+ if (network->connected)
+ return network->wifi.maxspeed;
+
+ return 0;
+}
+
int connman_network_set_maxrate(struct connman_network *network,
unsigned int maxrate)
{
diff --git a/src/service.c b/src/service.c
index e0947e9..ea61f32 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3253,6 +3253,7 @@ static void append_wifi_ext_info(DBusMessageIter *dict,
unsigned int ssid_len;
unsigned char *bssid;
unsigned int maxrate;
+ int maxspeed;
unsigned int keymgmt;
uint16_t frequency;
const char *enc_mode;
@@ -3265,6 +3266,7 @@ static void append_wifi_ext_info(DBusMessageIter *dict,
ssid = connman_network_get_blob(network, "WiFi.SSID", &ssid_len);
bssid = connman_network_get_bssid(network);
maxrate = connman_network_get_maxrate(network);
+ maxspeed = connman_network_get_maxspeed(network);
frequency = connman_network_get_frequency(network);
enc_mode = connman_network_get_enc_mode(network);
passpoint = connman_network_get_bool(network, "WiFi.HS20AP");
@@ -3285,6 +3287,8 @@ static void append_wifi_ext_info(DBusMessageIter *dict,
DBUS_TYPE_STRING, &bssid_str);
connman_dbus_dict_append_basic(dict, "MaxRate",
DBUS_TYPE_UINT32, &maxrate);
+ connman_dbus_dict_append_basic(dict, "MaxSpeed",
+ DBUS_TYPE_INT32, &maxspeed);
connman_dbus_dict_append_basic(dict, "Frequency",
DBUS_TYPE_UINT16, &frequency);
connman_dbus_dict_append_basic(dict, "EncryptionMode",