summaryrefslogtreecommitdiff
path: root/gsupplicant
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-05-04 12:24:32 (GMT)
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-05-04 13:17:05 (GMT)
commit305a6cb8bc6aa464a7a5e2669d00ac4691f4a2a5 (patch)
tree91a9ae59b32cd9d932a0abf86447d8a96f776052 /gsupplicant
parent4cd19238f5499623391ebf74c74af03905a14ef8 (diff)
downloadconnman-305a6cb8bc6aa464a7a5e2669d00ac4691f4a2a5.zip
connman-305a6cb8bc6aa464a7a5e2669d00ac4691f4a2a5.tar.gz
connman-305a6cb8bc6aa464a7a5e2669d00ac4691f4a2a5.tar.bz2
wifi: Allow max number of scan entries
Do no limit the scan entries to 4 (G_SUPPLICANT_MAX_FAST_SCAN) but use the limit given by the driver. The limit is given by wpa_s. If the supplicant does not return the limit, then use 4 as a max value.
Diffstat (limited to 'gsupplicant')
-rw-r--r--gsupplicant/gsupplicant.h31
-rw-r--r--gsupplicant/supplicant.c19
2 files changed, 36 insertions, 14 deletions
diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 883de7f..5dc5364 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -73,8 +73,6 @@ extern "C" {
#define G_SUPPLICANT_PAIRWISE_TKIP (1 << 1)
#define G_SUPPLICANT_PAIRWISE_CCMP (1 << 2)
-#define G_SUPPLICANT_MAX_FAST_SCAN 4
-
#define G_SUPPLICANT_WPS_CONFIGURED (1 << 0)
#define G_SUPPLICANT_WPS_PBC (1 << 1)
#define G_SUPPLICANT_WPS_PIN (1 << 2)
@@ -139,15 +137,26 @@ struct _GSupplicantSSID {
typedef struct _GSupplicantSSID GSupplicantSSID;
+/*
+ * Max number of SSIDs that can be scanned.
+ * In wpa_s 0.7x the limit is 4.
+ * In wps_s 0.8 or later it is 16.
+ * The value is only used if wpa_supplicant does not return any max limit
+ * for number of scannable SSIDs.
+ */
+#define WPAS_MAX_SCAN_SSIDS 4
+
+struct scan_ssid {
+ unsigned char ssid[32];
+ uint8_t ssid_len;
+};
+
struct _GSupplicantScanParams {
- struct scan_ssid {
- unsigned char ssid[32];
- uint8_t ssid_len;
- } ssids[G_SUPPLICANT_MAX_FAST_SCAN];
+ GSList *ssids;
uint8_t num_ssids;
- uint16_t freqs[G_SUPPLICANT_MAX_FAST_SCAN];
+ uint16_t *freqs;
};
typedef struct _GSupplicantScanParams GSupplicantScanParams;
@@ -250,6 +259,14 @@ typedef struct _GSupplicantCallbacks GSupplicantCallbacks;
int g_supplicant_register(const GSupplicantCallbacks *callbacks);
void g_supplicant_unregister(const GSupplicantCallbacks *callbacks);
+static inline
+void g_supplicant_free_scan_params(GSupplicantScanParams *scan_params)
+{
+ g_slist_free_full(scan_params->ssids, g_free);
+ g_free(scan_params->freqs);
+ g_free(scan_params);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 58d40c1..867fa02 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -742,6 +742,9 @@ unsigned int g_supplicant_interface_get_max_scan_ssids(
if (interface == NULL)
return 0;
+ if (interface->max_scan_ssids == 0)
+ return WPAS_MAX_SCAN_SSIDS;
+
return interface->max_scan_ssids;
}
@@ -2618,7 +2621,7 @@ static void interface_scan_result(const char *error,
}
if (data != NULL && data->scan_params != NULL)
- g_free(data->scan_params);
+ g_supplicant_free_scan_params(data->scan_params);
dbus_free(data);
}
@@ -2643,7 +2646,7 @@ static void add_scan_frequencies(DBusMessageIter *iter,
unsigned int freq;
int i;
- for (i = 0; i < G_SUPPLICANT_MAX_FAST_SCAN; i++) {
+ for (i = 0; i < scan_data->num_ssids; i++) {
freq = scan_data->freqs[i];
if (!freq)
break;
@@ -2668,11 +2671,13 @@ static void append_ssid(DBusMessageIter *iter,
static void append_ssids(DBusMessageIter *iter, void *user_data)
{
GSupplicantScanParams *scan_data = user_data;
- int i;
+ GSList *list;
- for (i = 0; i < scan_data->num_ssids; i++)
- append_ssid(iter, scan_data->ssids[i].ssid,
- scan_data->ssids[i].ssid_len);
+ for (list = scan_data->ssids; list; list = list->next) {
+ struct scan_ssid *scan_ssid = list->data;
+
+ append_ssid(iter, scan_ssid->ssid, scan_ssid->ssid_len);
+ }
}
static void supplicant_add_scan_frequency(DBusMessageIter *dict,
@@ -2683,7 +2688,7 @@ static void supplicant_add_scan_frequency(DBusMessageIter *dict,
DBusMessageIter entry, value, array;
const char *key = "Channels";
- if (scan_params->freqs[0] != 0) {
+ if (scan_params->freqs && scan_params->freqs[0] != 0) {
dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
NULL, &entry);