summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiraj Kumar Goit <niraj.g@samsung.com>2018-04-05 06:27:15 (GMT)
committerNiraj Kumar Goit <niraj.g@samsung.com>2018-04-10 14:09:28 (GMT)
commit22367513ced9ff5921eb6b1dd7b65c5d108b2a99 (patch)
treefd1dfd27ff3976f8f506fb53870d33044bde98d7
parentef389a7b9279d9e7c2a677041ef87f5d7dad605a (diff)
downloadconnman-22367513ced9ff5921eb6b1dd7b65c5d108b2a99.zip
connman-22367513ced9ff5921eb6b1dd7b65c5d108b2a99.tar.gz
connman-22367513ced9ff5921eb6b1dd7b65c5d108b2a99.tar.bz2
Add SSID and Frequency mixed scan.refs/changes/31/174931/2
Change-Id: I6ca91a5f073c11712a936844589aa72c27c0145e Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
-rwxr-xr-xinclude/technology.h13
-rwxr-xr-xplugins/wifi.c49
-rwxr-xr-xsrc/technology.c49
3 files changed, 102 insertions, 9 deletions
diff --git a/include/technology.h b/include/technology.h
index 55bb3dd..73cd8e7 100755
--- a/include/technology.h
+++ b/include/technology.h
@@ -34,6 +34,19 @@ extern "C" {
* @short_description: Functions for handling technology details
*/
+#if defined TIZEN_EXT
+typedef enum {
+ CONNMAN_MULTI_SCAN_SSID = 0x01,
+ CONNMAN_MULTI_SCAN_FREQ,
+ CONNMAN_MULTI_SCAN_SSID_FREQ,
+} connman_multi_scan_type_e;
+
+typedef struct {
+ char str[128];
+ gboolean flag;
+} connman_multi_scan_ap_s;
+#endif
+
struct connman_technology;
int connman_technology_tethering_add_station(enum connman_service_type type,
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 3135484..a9ffad0 100755
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -2075,7 +2075,7 @@ static int wifi_specific_scan(enum connman_service_type type,
return -EALREADY;
DBG("scan_type: %d", scan_type);
- if (scan_type == 1) { /* ssid based scan */
+ if (scan_type == CONNMAN_MULTI_SCAN_SSID) { /* ssid based scan */
scan_params = g_try_malloc0(sizeof(GSupplicantScanParams));
if (!scan_params) {
DBG("Failed to allocate memory.");
@@ -2101,7 +2101,7 @@ static int wifi_specific_scan(enum connman_service_type type,
}
scan_params->num_ssids = count;
- } else if (scan_type == 2) { /* frequency based scan */
+ } else if (scan_type == CONNMAN_MULTI_SCAN_FREQ) { /* frequency based scan */
scan_params = g_try_malloc0(sizeof(GSupplicantScanParams));
if (!scan_params) {
@@ -2129,6 +2129,51 @@ static int wifi_specific_scan(enum connman_service_type type,
}
scan_params->num_freqs = count;
+ } else if (scan_type == CONNMAN_MULTI_SCAN_SSID_FREQ) { /* SSID & Frequency mixed scan */
+ int freq_count, ap_count;
+ scan_params = g_try_malloc0(sizeof(GSupplicantScanParams));
+ if (!scan_params) {
+ DBG("Failed to allocate memory.");
+ return -ENOMEM;
+ }
+
+ guint size = g_slist_length(specific_scan_list);
+
+ scan_params->freqs = g_try_new0(uint16_t, size/2);
+ if (!scan_params->freqs) {
+ DBG("Failed to allocate memory.");
+ g_free(scan_params);
+ return -ENOMEM;
+ }
+
+ ap_count = freq_count = 0;
+ for (list = specific_scan_list; list; list = list->next) {
+ if (((connman_multi_scan_ap_s *)list->data)->flag == true) { /** ssid */
+ ssid = ((connman_multi_scan_ap_s *)list->data)->str;
+ int ssid_len = strlen(ssid);
+
+ scan_ssid = g_try_new0(struct scan_ssid, 1);
+ if (!scan_ssid) {
+ DBG("Failed to allocate memory.");
+ g_supplicant_free_scan_params(scan_params);
+ return -ENOMEM;
+ }
+
+ memcpy(scan_ssid->ssid, ssid, (ssid_len + 1));
+ DBG("scan ssid %s len: %d", scan_ssid->ssid, ssid_len);
+ scan_ssid->ssid_len = ssid_len;
+ scan_params->ssids = g_slist_prepend(scan_params->ssids, scan_ssid);
+ ap_count++;
+
+ } else { /* freq */
+ freq = atoi(((connman_multi_scan_ap_s *)list->data)->str);
+ scan_params->freqs[freq_count] = freq;
+ DBG("scan_params->freqs[%d]: %d", freq_count, scan_params->freqs[freq_count]);
+ freq_count++;
+ }
+ }
+ scan_params->num_ssids = ap_count;
+ scan_params->num_freqs = freq_count;
} else {
DBG("Invalid scan");
return -EINVAL;
diff --git a/src/technology.c b/src/technology.c
index 5d5b70f..57ab8e1 100755
--- a/src/technology.c
+++ b/src/technology.c
@@ -27,6 +27,7 @@
#include <string.h>
#if defined TIZEN_EXT
#include <stdio.h>
+#include <stdlib.h>
#endif
#include <gdbus.h>
@@ -1280,7 +1281,7 @@ static DBusMessage *specific_scan(DBusConnection *conn, DBusMessage *msg, void *
GSList *specific_scan_list = NULL;
int scan_type = 0;
const char *name = NULL;
- unsigned int freq = 0;
+ const char *freq = NULL;
DBusMessageIter iter, dict;
int err;
@@ -1321,20 +1322,53 @@ static DBusMessage *specific_scan(DBusConnection *conn, DBusMessage *msg, void *
return __connman_error_invalid_arguments(msg);
}
- scan_type = 1; /* SSID based scan */
+ scan_type = CONNMAN_MULTI_SCAN_SSID; /* SSID based scan */
dbus_message_iter_get_basic(&value2, &name);
DBG("name %s", name);
specific_scan_list = g_slist_append(specific_scan_list, g_strdup(name));
} else if (g_str_equal(key, "Frequency")) {
- if (type != DBUS_TYPE_UINT16) {
+ if (type != DBUS_TYPE_STRING) {
+ g_slist_free_full(specific_scan_list, g_free);
+ return __connman_error_invalid_arguments(msg);
+ }
+
+ scan_type = CONNMAN_MULTI_SCAN_FREQ; /* Frequency based scan */
+ dbus_message_iter_get_basic(&value2, &freq);
+ DBG("freq %s", freq);
+ specific_scan_list = g_slist_append(specific_scan_list, GINT_TO_POINTER(atoi(freq)));
+ } else if (g_str_equal(key, "SSID_Mixed")) {
+ if (type != DBUS_TYPE_STRING) {
+ g_slist_free_full(specific_scan_list, g_free);
+ return __connman_error_invalid_arguments(msg);
+ }
+
+ scan_type = CONNMAN_MULTI_SCAN_SSID_FREQ; /* SSID & Frequency mixed scan */
+ dbus_message_iter_get_basic(&value2, &name);
+
+ connman_multi_scan_ap_s *ap = (connman_multi_scan_ap_s*)g_try_malloc0(sizeof(connman_multi_scan_ap_s));
+ if (ap) {
+ g_strlcpy(ap->str, name, strlen(name) + 1);
+ ap->flag = true;
+ specific_scan_list = g_slist_append(specific_scan_list, ap);
+ } else
+ DBG("Failed to allocate memory");
+
+ } else if (g_str_equal(key, "Frequency_Mixed")) {
+ if (type != DBUS_TYPE_STRING) {
g_slist_free_full(specific_scan_list, g_free);
return __connman_error_invalid_arguments(msg);
}
- scan_type = 2; /* Frequency based scan */
+ scan_type = CONNMAN_MULTI_SCAN_SSID_FREQ; /* SSID & Frequency mixed scan */
dbus_message_iter_get_basic(&value2, &freq);
- DBG("freq %d", freq);
- specific_scan_list = g_slist_append(specific_scan_list, GINT_TO_POINTER(freq));
+
+ connman_multi_scan_ap_s *ap = (connman_multi_scan_ap_s*)g_try_malloc0(sizeof(connman_multi_scan_ap_s));
+ if (ap) {
+ g_strlcpy(ap->str, freq, strlen(freq) + 1);
+ ap->flag = false;
+ specific_scan_list = g_slist_append(specific_scan_list, ap);
+ } else
+ DBG("Failed to allocate memory");
}
dbus_message_iter_next(&dict);
}
@@ -1356,7 +1390,8 @@ static DBusMessage *specific_scan(DBusConnection *conn, DBusMessage *msg, void *
technology->scan_pending =
g_slist_prepend(technology->scan_pending, msg);
- if (scan_type == 1) {
+ if (scan_type == CONNMAN_MULTI_SCAN_SSID ||
+ scan_type == CONNMAN_MULTI_SCAN_SSID_FREQ) {
g_slist_free_full(specific_scan_list, g_free);
scan_type = 0;
}