Commit 2e4fd068 authored by Jouni Malinen's avatar Jouni Malinen Committed by Jeff Garzik

[PATCH] hostap update

Cleaned up scan result processing by converting struct
hfa384x_scan_result into struct hfa384x_hostscan_result. This removes
special cases from result processing since the results are only used
in one, hostscan, format.
Signed-off-by: default avatarJouni Malinen <jkmaline@cc.hut.fi>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent 72ca9c61
...@@ -160,7 +160,7 @@ static void prism2_host_roaming(local_info_t *local) ...@@ -160,7 +160,7 @@ static void prism2_host_roaming(local_info_t *local)
{ {
struct hfa384x_join_request req; struct hfa384x_join_request req;
struct net_device *dev = local->dev; struct net_device *dev = local->dev;
struct hfa384x_scan_result *selected, *entry; struct hfa384x_hostscan_result *selected, *entry;
int i; int i;
unsigned long flags; unsigned long flags;
...@@ -244,9 +244,10 @@ static void prism2_info_scanresults(local_info_t *local, unsigned char *buf, ...@@ -244,9 +244,10 @@ static void prism2_info_scanresults(local_info_t *local, unsigned char *buf,
int left) int left)
{ {
u16 *pos; u16 *pos;
int new_count; int new_count, i;
unsigned long flags; unsigned long flags;
struct hfa384x_scan_result *results, *prev; struct hfa384x_scan_result *res;
struct hfa384x_hostscan_result *results, *prev;
if (left < 4) { if (left < 4) {
printk(KERN_DEBUG "%s: invalid scanresult info frame " printk(KERN_DEBUG "%s: invalid scanresult info frame "
...@@ -260,11 +261,18 @@ static void prism2_info_scanresults(local_info_t *local, unsigned char *buf, ...@@ -260,11 +261,18 @@ static void prism2_info_scanresults(local_info_t *local, unsigned char *buf,
left -= 4; left -= 4;
new_count = left / sizeof(struct hfa384x_scan_result); new_count = left / sizeof(struct hfa384x_scan_result);
results = kmalloc(new_count * sizeof(struct hfa384x_scan_result), results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result),
GFP_ATOMIC); GFP_ATOMIC);
if (results == NULL) if (results == NULL)
return; return;
memcpy(results, pos, new_count * sizeof(struct hfa384x_scan_result));
/* Convert to hostscan result format. */
res = (struct hfa384x_scan_result *) pos;
for (i = 0; i < new_count; i++) {
memcpy(&results[i], &res[i],
sizeof(struct hfa384x_scan_result));
results[i].atim = 0;
}
spin_lock_irqsave(&local->lock, flags); spin_lock_irqsave(&local->lock, flags);
local->last_scan_type = PRISM2_SCAN; local->last_scan_type = PRISM2_SCAN;
...@@ -335,9 +343,9 @@ static void prism2_info_hostscanresults(local_info_t *local, ...@@ -335,9 +343,9 @@ static void prism2_info_hostscanresults(local_info_t *local,
spin_lock_irqsave(&local->lock, flags); spin_lock_irqsave(&local->lock, flags);
local->last_scan_type = PRISM2_HOSTSCAN; local->last_scan_type = PRISM2_HOSTSCAN;
prev = local->last_hostscan_results; prev = local->last_scan_results;
local->last_hostscan_results = results; local->last_scan_results = results;
local->last_hostscan_results_count = new_count; local->last_scan_results_count = new_count;
spin_unlock_irqrestore(&local->lock, flags); spin_unlock_irqrestore(&local->lock, flags);
kfree(prev); kfree(prev);
......
...@@ -663,7 +663,7 @@ static int hostap_join_ap(struct net_device *dev) ...@@ -663,7 +663,7 @@ static int hostap_join_ap(struct net_device *dev)
struct hfa384x_join_request req; struct hfa384x_join_request req;
unsigned long flags; unsigned long flags;
int i; int i;
struct hfa384x_scan_result *entry; struct hfa384x_hostscan_result *entry;
iface = netdev_priv(dev); iface = netdev_priv(dev);
local = iface->local; local = iface->local;
...@@ -1795,10 +1795,8 @@ static int prism2_ioctl_siwscan(struct net_device *dev, ...@@ -1795,10 +1795,8 @@ static int prism2_ioctl_siwscan(struct net_device *dev,
#ifndef PRISM2_NO_STATION_MODES #ifndef PRISM2_NO_STATION_MODES
static char * __prism2_translate_scan(local_info_t *local, static char * __prism2_translate_scan(local_info_t *local,
struct hfa384x_scan_result *scan, struct hfa384x_hostscan_result *scan,
struct hfa384x_hostscan_result *hscan, struct hostap_bss_info *bss,
int hostscan,
struct hostap_bss_info *bss, u8 *bssid,
char *current_ev, char *end_buf) char *current_ev, char *end_buf)
{ {
int i, chan; int i, chan;
...@@ -1806,17 +1804,18 @@ static char * __prism2_translate_scan(local_info_t *local, ...@@ -1806,17 +1804,18 @@ static char * __prism2_translate_scan(local_info_t *local,
char *current_val; char *current_val;
u16 capabilities; u16 capabilities;
u8 *pos; u8 *pos;
u8 *ssid; u8 *ssid, *bssid;
size_t ssid_len; size_t ssid_len;
char *buf; char *buf;
if (bss) { if (bss) {
ssid = bss->ssid; ssid = bss->ssid;
ssid_len = bss->ssid_len; ssid_len = bss->ssid_len;
bssid = bss->bssid;
} else { } else {
ssid = hostscan ? hscan->ssid : scan->ssid; ssid = scan->ssid;
ssid_len = le16_to_cpu(hostscan ? hscan->ssid_len : ssid_len = le16_to_cpu(scan->ssid_len);
scan->ssid_len); bssid = scan->bssid;
} }
if (ssid_len > 32) if (ssid_len > 32)
ssid_len = 32; ssid_len = 32;
...@@ -1850,8 +1849,7 @@ static char * __prism2_translate_scan(local_info_t *local, ...@@ -1850,8 +1849,7 @@ static char * __prism2_translate_scan(local_info_t *local,
if (bss) { if (bss) {
capabilities = bss->capab_info; capabilities = bss->capab_info;
} else { } else {
capabilities = le16_to_cpu(hostscan ? hscan->capability : capabilities = le16_to_cpu(scan->capability);
scan->capability);
} }
if (capabilities & (WLAN_CAPABILITY_ESS | if (capabilities & (WLAN_CAPABILITY_ESS |
WLAN_CAPABILITY_IBSS)) { WLAN_CAPABILITY_IBSS)) {
...@@ -1866,8 +1864,8 @@ static char * __prism2_translate_scan(local_info_t *local, ...@@ -1866,8 +1864,8 @@ static char * __prism2_translate_scan(local_info_t *local,
memset(&iwe, 0, sizeof(iwe)); memset(&iwe, 0, sizeof(iwe));
iwe.cmd = SIOCGIWFREQ; iwe.cmd = SIOCGIWFREQ;
if (hscan || scan) { if (scan) {
chan = hostscan ? hscan->chid : scan->chid; chan = scan->chid;
} else if (bss) { } else if (bss) {
chan = bss->chan; chan = bss->chan;
} else { } else {
...@@ -1882,12 +1880,12 @@ static char * __prism2_translate_scan(local_info_t *local, ...@@ -1882,12 +1880,12 @@ static char * __prism2_translate_scan(local_info_t *local,
IW_EV_FREQ_LEN); IW_EV_FREQ_LEN);
} }
if (scan || hscan) { if (scan) {
memset(&iwe, 0, sizeof(iwe)); memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVQUAL; iwe.cmd = IWEVQUAL;
if (hostscan) { if (local->last_scan_type == PRISM2_HOSTSCAN) {
iwe.u.qual.level = le16_to_cpu(hscan->sl); iwe.u.qual.level = le16_to_cpu(scan->sl);
iwe.u.qual.noise = le16_to_cpu(hscan->anl); iwe.u.qual.noise = le16_to_cpu(scan->anl);
} else { } else {
iwe.u.qual.level = iwe.u.qual.level =
HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->sl)); HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->sl));
...@@ -1910,11 +1908,11 @@ static char * __prism2_translate_scan(local_info_t *local, ...@@ -1910,11 +1908,11 @@ static char * __prism2_translate_scan(local_info_t *local,
current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, ""); current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, "");
/* TODO: add SuppRates into BSS table */ /* TODO: add SuppRates into BSS table */
if (scan || hscan) { if (scan) {
memset(&iwe, 0, sizeof(iwe)); memset(&iwe, 0, sizeof(iwe));
iwe.cmd = SIOCGIWRATE; iwe.cmd = SIOCGIWRATE;
current_val = current_ev + IW_EV_LCP_LEN; current_val = current_ev + IW_EV_LCP_LEN;
pos = hostscan ? hscan->sup_rates : scan->sup_rates; pos = scan->sup_rates;
for (i = 0; i < sizeof(scan->sup_rates); i++) { for (i = 0; i < sizeof(scan->sup_rates); i++) {
if (pos[i] == 0) if (pos[i] == 0)
break; break;
...@@ -1931,29 +1929,26 @@ static char * __prism2_translate_scan(local_info_t *local, ...@@ -1931,29 +1929,26 @@ static char * __prism2_translate_scan(local_info_t *local,
/* TODO: add BeaconInt,resp_rate,atim into BSS table */ /* TODO: add BeaconInt,resp_rate,atim into BSS table */
buf = kmalloc(MAX_WPA_IE_LEN * 2 + 30, GFP_KERNEL); buf = kmalloc(MAX_WPA_IE_LEN * 2 + 30, GFP_KERNEL);
if (buf && (scan || hscan)) { if (buf && scan) {
memset(&iwe, 0, sizeof(iwe)); memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVCUSTOM; iwe.cmd = IWEVCUSTOM;
sprintf(buf, "bcn_int=%d", sprintf(buf, "bcn_int=%d", le16_to_cpu(scan->beacon_interval));
le16_to_cpu(hostscan ? hscan->beacon_interval :
scan->beacon_interval));
iwe.u.data.length = strlen(buf); iwe.u.data.length = strlen(buf);
current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
buf); buf);
memset(&iwe, 0, sizeof(iwe)); memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVCUSTOM; iwe.cmd = IWEVCUSTOM;
sprintf(buf, "resp_rate=%d", le16_to_cpu(hostscan ? sprintf(buf, "resp_rate=%d", le16_to_cpu(scan->rate));
hscan->rate :
scan->rate));
iwe.u.data.length = strlen(buf); iwe.u.data.length = strlen(buf);
current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
buf); buf);
if (hostscan && (capabilities & WLAN_CAPABILITY_IBSS)) { if (local->last_scan_type == PRISM2_HOSTSCAN &&
(capabilities & WLAN_CAPABILITY_IBSS)) {
memset(&iwe, 0, sizeof(iwe)); memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVCUSTOM; iwe.cmd = IWEVCUSTOM;
sprintf(buf, "atim=%d", le16_to_cpu(hscan->atim)); sprintf(buf, "atim=%d", le16_to_cpu(scan->atim));
iwe.u.data.length = strlen(buf); iwe.u.data.length = strlen(buf);
current_ev = iwe_stream_add_point(current_ev, end_buf, current_ev = iwe_stream_add_point(current_ev, end_buf,
&iwe, buf); &iwe, buf);
...@@ -1986,12 +1981,10 @@ static char * __prism2_translate_scan(local_info_t *local, ...@@ -1986,12 +1981,10 @@ static char * __prism2_translate_scan(local_info_t *local,
static inline int prism2_translate_scan(local_info_t *local, static inline int prism2_translate_scan(local_info_t *local,
char *buffer, int buflen) char *buffer, int buflen)
{ {
struct hfa384x_scan_result *scan; struct hfa384x_hostscan_result *scan;
struct hfa384x_hostscan_result *hscan; int entry, hostscan;
int entries, entry, hostscan;
char *current_ev = buffer; char *current_ev = buffer;
char *end_buf = buffer + buflen; char *end_buf = buffer + buflen;
u8 *bssid;
struct list_head *ptr; struct list_head *ptr;
spin_lock_bh(&local->lock); spin_lock_bh(&local->lock);
...@@ -2003,14 +1996,9 @@ static inline int prism2_translate_scan(local_info_t *local, ...@@ -2003,14 +1996,9 @@ static inline int prism2_translate_scan(local_info_t *local,
} }
hostscan = local->last_scan_type == PRISM2_HOSTSCAN; hostscan = local->last_scan_type == PRISM2_HOSTSCAN;
entries = hostscan ? local->last_hostscan_results_count : for (entry = 0; entry < local->last_scan_results_count; entry++) {
local->last_scan_results_count;
for (entry = 0; entry < entries; entry++) {
int found = 0; int found = 0;
scan = &local->last_scan_results[entry]; scan = &local->last_scan_results[entry];
hscan = &local->last_hostscan_results[entry];
bssid = hostscan ? hscan->bssid : scan->bssid;
/* Report every SSID if the AP is using multiple SSIDs. If no /* Report every SSID if the AP is using multiple SSIDs. If no
* BSS record is found (e.g., when WPA mode is disabled), * BSS record is found (e.g., when WPA mode is disabled),
...@@ -2018,18 +2006,16 @@ static inline int prism2_translate_scan(local_info_t *local, ...@@ -2018,18 +2006,16 @@ static inline int prism2_translate_scan(local_info_t *local,
list_for_each(ptr, &local->bss_list) { list_for_each(ptr, &local->bss_list) {
struct hostap_bss_info *bss; struct hostap_bss_info *bss;
bss = list_entry(ptr, struct hostap_bss_info, list); bss = list_entry(ptr, struct hostap_bss_info, list);
if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0) { if (memcmp(bss->bssid, scan->bssid, ETH_ALEN) == 0) {
bss->included = 1; bss->included = 1;
current_ev = __prism2_translate_scan( current_ev = __prism2_translate_scan(
local, scan, hscan, hostscan, bss, local, scan, bss, current_ev, end_buf);
bssid, current_ev, end_buf);
found++; found++;
} }
} }
if (!found) { if (!found) {
current_ev = __prism2_translate_scan( current_ev = __prism2_translate_scan(
local, scan, hscan, hostscan, NULL, bssid, local, scan, NULL, current_ev, end_buf);
current_ev, end_buf);
} }
/* Check if there is space for one more entry */ /* Check if there is space for one more entry */
if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) { if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) {
...@@ -2047,9 +2033,8 @@ static inline int prism2_translate_scan(local_info_t *local, ...@@ -2047,9 +2033,8 @@ static inline int prism2_translate_scan(local_info_t *local,
bss = list_entry(ptr, struct hostap_bss_info, list); bss = list_entry(ptr, struct hostap_bss_info, list);
if (bss->included) if (bss->included)
continue; continue;
current_ev = __prism2_translate_scan(local, NULL, NULL, 0, bss, current_ev = __prism2_translate_scan(local, NULL, bss,
bss->bssid, current_ev, current_ev, end_buf);
end_buf);
/* Check if there is space for one more entry */ /* Check if there is space for one more entry */
if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) { if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) {
/* Ask user space to try again with a bigger buffer */ /* Ask user space to try again with a bigger buffer */
......
...@@ -302,20 +302,15 @@ static int prism2_scan_results_proc_read(char *page, char **start, off_t off, ...@@ -302,20 +302,15 @@ static int prism2_scan_results_proc_read(char *page, char **start, off_t off,
{ {
char *p = page; char *p = page;
local_info_t *local = (local_info_t *) data; local_info_t *local = (local_info_t *) data;
int entries, entry, i, len, total = 0, hostscan; int entry, i, len, total = 0;
struct hfa384x_scan_result *scanres; struct hfa384x_hostscan_result *scanres;
struct hfa384x_hostscan_result *hscanres;
u8 *pos; u8 *pos;
p += sprintf(p, "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates " p += sprintf(p, "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates "
"SSID\n"); "SSID\n");
spin_lock_bh(&local->lock); spin_lock_bh(&local->lock);
hostscan = local->last_scan_type == PRISM2_HOSTSCAN; for (entry = 0; entry < local->last_scan_results_count; entry++) {
entries = hostscan ? local->last_hostscan_results_count :
local->last_scan_results_count;
for (entry = 0; entry < entries; entry++) {
hscanres = &local->last_hostscan_results[entry];
scanres = &local->last_scan_results[entry]; scanres = &local->last_scan_results[entry];
if (total + (p - page) <= off) { if (total + (p - page) <= off) {
...@@ -327,39 +322,26 @@ static int prism2_scan_results_proc_read(char *page, char **start, off_t off, ...@@ -327,39 +322,26 @@ static int prism2_scan_results_proc_read(char *page, char **start, off_t off,
if ((p - page) > (PAGE_SIZE - 200)) if ((p - page) > (PAGE_SIZE - 200))
break; break;
if (hostscan) { p += sprintf(p, "%d %d %d %d 0x%02x %d " MACSTR " %d ",
p += sprintf(p, "%d %d %d %d 0x%02x %d " MACSTR " %d ", le16_to_cpu(scanres->chid),
le16_to_cpu(hscanres->chid), (s16) le16_to_cpu(scanres->anl),
(s16) le16_to_cpu(hscanres->anl), (s16) le16_to_cpu(scanres->sl),
(s16) le16_to_cpu(hscanres->sl), le16_to_cpu(scanres->beacon_interval),
le16_to_cpu(hscanres->beacon_interval), le16_to_cpu(scanres->capability),
le16_to_cpu(hscanres->capability), le16_to_cpu(scanres->rate),
le16_to_cpu(hscanres->rate), MAC2STR(scanres->bssid),
MAC2STR(hscanres->bssid), le16_to_cpu(scanres->atim));
le16_to_cpu(hscanres->atim));
} else { pos = scanres->sup_rates;
p += sprintf(p, "%d %d %d %d 0x%02x %d " MACSTR for (i = 0; i < sizeof(scanres->sup_rates); i++) {
" N/A ",
le16_to_cpu(scanres->chid),
(s16) le16_to_cpu(scanres->anl),
(s16) le16_to_cpu(scanres->sl),
le16_to_cpu(scanres->beacon_interval),
le16_to_cpu(scanres->capability),
le16_to_cpu(scanres->rate),
MAC2STR(scanres->bssid));
}
pos = hostscan ? hscanres->sup_rates : scanres->sup_rates;
for (i = 0; i < sizeof(hscanres->sup_rates); i++) {
if (pos[i] == 0) if (pos[i] == 0)
break; break;
p += sprintf(p, "<%02x>", pos[i]); p += sprintf(p, "<%02x>", pos[i]);
} }
p += sprintf(p, " "); p += sprintf(p, " ");
pos = hostscan ? hscanres->ssid : scanres->ssid; pos = scanres->ssid;
len = le16_to_cpu(hostscan ? hscanres->ssid_len : len = le16_to_cpu(scanres->ssid_len);
scanres->ssid_len);
if (len > 32) if (len > 32)
len = 32; len = 32;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
......
...@@ -824,10 +824,8 @@ struct local_info { ...@@ -824,10 +824,8 @@ struct local_info {
int host_roaming; int host_roaming;
unsigned long last_join_time; /* time of last JoinRequest */ unsigned long last_join_time; /* time of last JoinRequest */
struct hfa384x_scan_result *last_scan_results; struct hfa384x_hostscan_result *last_scan_results;
int last_scan_results_count; int last_scan_results_count;
struct hfa384x_hostscan_result *last_hostscan_results;
int last_hostscan_results_count;
enum { PRISM2_SCAN, PRISM2_HOSTSCAN } last_scan_type; enum { PRISM2_SCAN, PRISM2_HOSTSCAN } last_scan_type;
struct work_struct info_queue; struct work_struct info_queue;
long pending_info; /* bit field of pending info_queue items */ long pending_info; /* bit field of pending info_queue items */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment