aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/hostap/hostap_ioctl.c
diff options
context:
space:
mode:
authorJouni Malinen <jkmaline@cc.hut.fi>2005-07-30 15:50:02 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-07-30 18:17:23 -0400
commit2e4fd068e7e25e654a454ed4a425f239c0f6407a (patch)
tree64206e16c44242428b9eeb48b21109d478de6782 /drivers/net/wireless/hostap/hostap_ioctl.c
parent72ca9c61cddb82a8596cee8141656d50aba42be5 (diff)
[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: Jouni Malinen <jkmaline@cc.hut.fi> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/net/wireless/hostap/hostap_ioctl.c')
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c77
1 files changed, 31 insertions, 46 deletions
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index 4c236e7903f5..97836198691a 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -663,7 +663,7 @@ static int hostap_join_ap(struct net_device *dev)
663 struct hfa384x_join_request req; 663 struct hfa384x_join_request req;
664 unsigned long flags; 664 unsigned long flags;
665 int i; 665 int i;
666 struct hfa384x_scan_result *entry; 666 struct hfa384x_hostscan_result *entry;
667 667
668 iface = netdev_priv(dev); 668 iface = netdev_priv(dev);
669 local = iface->local; 669 local = iface->local;
@@ -1795,10 +1795,8 @@ static int prism2_ioctl_siwscan(struct net_device *dev,
1795 1795
1796#ifndef PRISM2_NO_STATION_MODES 1796#ifndef PRISM2_NO_STATION_MODES
1797static char * __prism2_translate_scan(local_info_t *local, 1797static char * __prism2_translate_scan(local_info_t *local,
1798 struct hfa384x_scan_result *scan, 1798 struct hfa384x_hostscan_result *scan,
1799 struct hfa384x_hostscan_result *hscan, 1799 struct hostap_bss_info *bss,
1800 int hostscan,
1801 struct hostap_bss_info *bss, u8 *bssid,
1802 char *current_ev, char *end_buf) 1800 char *current_ev, char *end_buf)
1803{ 1801{
1804 int i, chan; 1802 int i, chan;
@@ -1806,17 +1804,18 @@ static char * __prism2_translate_scan(local_info_t *local,
1806 char *current_val; 1804 char *current_val;
1807 u16 capabilities; 1805 u16 capabilities;
1808 u8 *pos; 1806 u8 *pos;
1809 u8 *ssid; 1807 u8 *ssid, *bssid;
1810 size_t ssid_len; 1808 size_t ssid_len;
1811 char *buf; 1809 char *buf;
1812 1810
1813 if (bss) { 1811 if (bss) {
1814 ssid = bss->ssid; 1812 ssid = bss->ssid;
1815 ssid_len = bss->ssid_len; 1813 ssid_len = bss->ssid_len;
1814 bssid = bss->bssid;
1816 } else { 1815 } else {
1817 ssid = hostscan ? hscan->ssid : scan->ssid; 1816 ssid = scan->ssid;
1818 ssid_len = le16_to_cpu(hostscan ? hscan->ssid_len : 1817 ssid_len = le16_to_cpu(scan->ssid_len);
1819 scan->ssid_len); 1818 bssid = scan->bssid;
1820 } 1819 }
1821 if (ssid_len > 32) 1820 if (ssid_len > 32)
1822 ssid_len = 32; 1821 ssid_len = 32;
@@ -1850,8 +1849,7 @@ static char * __prism2_translate_scan(local_info_t *local,
1850 if (bss) { 1849 if (bss) {
1851 capabilities = bss->capab_info; 1850 capabilities = bss->capab_info;
1852 } else { 1851 } else {
1853 capabilities = le16_to_cpu(hostscan ? hscan->capability : 1852 capabilities = le16_to_cpu(scan->capability);
1854 scan->capability);
1855 } 1853 }
1856 if (capabilities & (WLAN_CAPABILITY_ESS | 1854 if (capabilities & (WLAN_CAPABILITY_ESS |
1857 WLAN_CAPABILITY_IBSS)) { 1855 WLAN_CAPABILITY_IBSS)) {
@@ -1866,8 +1864,8 @@ static char * __prism2_translate_scan(local_info_t *local,
1866 1864
1867 memset(&iwe, 0, sizeof(iwe)); 1865 memset(&iwe, 0, sizeof(iwe));
1868 iwe.cmd = SIOCGIWFREQ; 1866 iwe.cmd = SIOCGIWFREQ;
1869 if (hscan || scan) { 1867 if (scan) {
1870 chan = hostscan ? hscan->chid : scan->chid; 1868 chan = scan->chid;
1871 } else if (bss) { 1869 } else if (bss) {
1872 chan = bss->chan; 1870 chan = bss->chan;
1873 } else { 1871 } else {
@@ -1882,12 +1880,12 @@ static char * __prism2_translate_scan(local_info_t *local,
1882 IW_EV_FREQ_LEN); 1880 IW_EV_FREQ_LEN);
1883 } 1881 }
1884 1882
1885 if (scan || hscan) { 1883 if (scan) {
1886 memset(&iwe, 0, sizeof(iwe)); 1884 memset(&iwe, 0, sizeof(iwe));
1887 iwe.cmd = IWEVQUAL; 1885 iwe.cmd = IWEVQUAL;
1888 if (hostscan) { 1886 if (local->last_scan_type == PRISM2_HOSTSCAN) {
1889 iwe.u.qual.level = le16_to_cpu(hscan->sl); 1887 iwe.u.qual.level = le16_to_cpu(scan->sl);
1890 iwe.u.qual.noise = le16_to_cpu(hscan->anl); 1888 iwe.u.qual.noise = le16_to_cpu(scan->anl);
1891 } else { 1889 } else {
1892 iwe.u.qual.level = 1890 iwe.u.qual.level =
1893 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->sl)); 1891 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->sl));
@@ -1910,11 +1908,11 @@ static char * __prism2_translate_scan(local_info_t *local,
1910 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, ""); 1908 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, "");
1911 1909
1912 /* TODO: add SuppRates into BSS table */ 1910 /* TODO: add SuppRates into BSS table */
1913 if (scan || hscan) { 1911 if (scan) {
1914 memset(&iwe, 0, sizeof(iwe)); 1912 memset(&iwe, 0, sizeof(iwe));
1915 iwe.cmd = SIOCGIWRATE; 1913 iwe.cmd = SIOCGIWRATE;
1916 current_val = current_ev + IW_EV_LCP_LEN; 1914 current_val = current_ev + IW_EV_LCP_LEN;
1917 pos = hostscan ? hscan->sup_rates : scan->sup_rates; 1915 pos = scan->sup_rates;
1918 for (i = 0; i < sizeof(scan->sup_rates); i++) { 1916 for (i = 0; i < sizeof(scan->sup_rates); i++) {
1919 if (pos[i] == 0) 1917 if (pos[i] == 0)
1920 break; 1918 break;
@@ -1931,29 +1929,26 @@ static char * __prism2_translate_scan(local_info_t *local,
1931 1929
1932 /* TODO: add BeaconInt,resp_rate,atim into BSS table */ 1930 /* TODO: add BeaconInt,resp_rate,atim into BSS table */
1933 buf = kmalloc(MAX_WPA_IE_LEN * 2 + 30, GFP_KERNEL); 1931 buf = kmalloc(MAX_WPA_IE_LEN * 2 + 30, GFP_KERNEL);
1934 if (buf && (scan || hscan)) { 1932 if (buf && scan) {
1935 memset(&iwe, 0, sizeof(iwe)); 1933 memset(&iwe, 0, sizeof(iwe));
1936 iwe.cmd = IWEVCUSTOM; 1934 iwe.cmd = IWEVCUSTOM;
1937 sprintf(buf, "bcn_int=%d", 1935 sprintf(buf, "bcn_int=%d", le16_to_cpu(scan->beacon_interval));
1938 le16_to_cpu(hostscan ? hscan->beacon_interval :
1939 scan->beacon_interval));
1940 iwe.u.data.length = strlen(buf); 1936 iwe.u.data.length = strlen(buf);
1941 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, 1937 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
1942 buf); 1938 buf);
1943 1939
1944 memset(&iwe, 0, sizeof(iwe)); 1940 memset(&iwe, 0, sizeof(iwe));
1945 iwe.cmd = IWEVCUSTOM; 1941 iwe.cmd = IWEVCUSTOM;
1946 sprintf(buf, "resp_rate=%d", le16_to_cpu(hostscan ? 1942 sprintf(buf, "resp_rate=%d", le16_to_cpu(scan->rate));
1947 hscan->rate :
1948 scan->rate));
1949 iwe.u.data.length = strlen(buf); 1943 iwe.u.data.length = strlen(buf);
1950 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, 1944 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
1951 buf); 1945 buf);
1952 1946
1953 if (hostscan && (capabilities & WLAN_CAPABILITY_IBSS)) { 1947 if (local->last_scan_type == PRISM2_HOSTSCAN &&
1948 (capabilities & WLAN_CAPABILITY_IBSS)) {
1954 memset(&iwe, 0, sizeof(iwe)); 1949 memset(&iwe, 0, sizeof(iwe));
1955 iwe.cmd = IWEVCUSTOM; 1950 iwe.cmd = IWEVCUSTOM;
1956 sprintf(buf, "atim=%d", le16_to_cpu(hscan->atim)); 1951 sprintf(buf, "atim=%d", le16_to_cpu(scan->atim));
1957 iwe.u.data.length = strlen(buf); 1952 iwe.u.data.length = strlen(buf);
1958 current_ev = iwe_stream_add_point(current_ev, end_buf, 1953 current_ev = iwe_stream_add_point(current_ev, end_buf,
1959 &iwe, buf); 1954 &iwe, buf);
@@ -1986,12 +1981,10 @@ static char * __prism2_translate_scan(local_info_t *local,
1986static inline int prism2_translate_scan(local_info_t *local, 1981static inline int prism2_translate_scan(local_info_t *local,
1987 char *buffer, int buflen) 1982 char *buffer, int buflen)
1988{ 1983{
1989 struct hfa384x_scan_result *scan; 1984 struct hfa384x_hostscan_result *scan;
1990 struct hfa384x_hostscan_result *hscan; 1985 int entry, hostscan;
1991 int entries, entry, hostscan;
1992 char *current_ev = buffer; 1986 char *current_ev = buffer;
1993 char *end_buf = buffer + buflen; 1987 char *end_buf = buffer + buflen;
1994 u8 *bssid;
1995 struct list_head *ptr; 1988 struct list_head *ptr;
1996 1989
1997 spin_lock_bh(&local->lock); 1990 spin_lock_bh(&local->lock);
@@ -2003,14 +1996,9 @@ static inline int prism2_translate_scan(local_info_t *local,
2003 } 1996 }
2004 1997
2005 hostscan = local->last_scan_type == PRISM2_HOSTSCAN; 1998 hostscan = local->last_scan_type == PRISM2_HOSTSCAN;
2006 entries = hostscan ? local->last_hostscan_results_count : 1999 for (entry = 0; entry < local->last_scan_results_count; entry++) {
2007 local->last_scan_results_count;
2008 for (entry = 0; entry < entries; entry++) {
2009 int found = 0; 2000 int found = 0;
2010 scan = &local->last_scan_results[entry]; 2001 scan = &local->last_scan_results[entry];
2011 hscan = &local->last_hostscan_results[entry];
2012
2013 bssid = hostscan ? hscan->bssid : scan->bssid;
2014 2002
2015 /* Report every SSID if the AP is using multiple SSIDs. If no 2003 /* Report every SSID if the AP is using multiple SSIDs. If no
2016 * BSS record is found (e.g., when WPA mode is disabled), 2004 * 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 list_for_each(ptr, &local->bss_list) { 2006 list_for_each(ptr, &local->bss_list) {
2019 struct hostap_bss_info *bss; 2007 struct hostap_bss_info *bss;
2020 bss = list_entry(ptr, struct hostap_bss_info, list); 2008 bss = list_entry(ptr, struct hostap_bss_info, list);
2021 if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0) { 2009 if (memcmp(bss->bssid, scan->bssid, ETH_ALEN) == 0) {
2022 bss->included = 1; 2010 bss->included = 1;
2023 current_ev = __prism2_translate_scan( 2011 current_ev = __prism2_translate_scan(
2024 local, scan, hscan, hostscan, bss, 2012 local, scan, bss, current_ev, end_buf);
2025 bssid, current_ev, end_buf);
2026 found++; 2013 found++;
2027 } 2014 }
2028 } 2015 }
2029 if (!found) { 2016 if (!found) {
2030 current_ev = __prism2_translate_scan( 2017 current_ev = __prism2_translate_scan(
2031 local, scan, hscan, hostscan, NULL, bssid, 2018 local, scan, NULL, current_ev, end_buf);
2032 current_ev, end_buf);
2033 } 2019 }
2034 /* Check if there is space for one more entry */ 2020 /* Check if there is space for one more entry */
2035 if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) { 2021 if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) {
@@ -2047,9 +2033,8 @@ static inline int prism2_translate_scan(local_info_t *local,
2047 bss = list_entry(ptr, struct hostap_bss_info, list); 2033 bss = list_entry(ptr, struct hostap_bss_info, list);
2048 if (bss->included) 2034 if (bss->included)
2049 continue; 2035 continue;
2050 current_ev = __prism2_translate_scan(local, NULL, NULL, 0, bss, 2036 current_ev = __prism2_translate_scan(local, NULL, bss,
2051 bss->bssid, current_ev, 2037 current_ev, end_buf);
2052 end_buf);
2053 /* Check if there is space for one more entry */ 2038 /* Check if there is space for one more entry */
2054 if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) { 2039 if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) {
2055 /* Ask user space to try again with a bigger buffer */ 2040 /* Ask user space to try again with a bigger buffer */