aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/hostap/hostap_ioctl.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-06-16 21:50:49 -0400
committerDavid S. Miller <davem@davemloft.net>2008-06-16 21:50:49 -0400
commitccc580571cf0799d0460a085a7632b77753f083e (patch)
tree018e0f83776b089b1f272694132688ac93be25b4 /drivers/net/wireless/hostap/hostap_ioctl.c
parent0f5cabba49021d36e9f76bd97d7fa0f4a408063f (diff)
wext: Emit event stream entries correctly when compat.
Three major portions to this change: 1) Add IW_EV_COMPAT_LCP_LEN, IW_EV_COMPAT_POINT_OFF, and IW_EV_COMPAT_POINT_LEN helper defines. 2) Delete iw_stream_check_add_*(), they are unused. 3) Add iw_request_info argument to iwe_stream_add_*(), and use it to size the event and pointer lengths correctly depending upon whether IW_REQUEST_FLAG_COMPAT is set or not. 4) The mechanical transformations to the drivers and wireless stack bits to get the iw_request_info passed down into the routines modified in #3. Also, explicit references to IW_EV_LCP_LEN are replaced with iwe_stream_lcp_len(info). With a lot of help and bug fixes from Masakazu Mokuno. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wireless/hostap/hostap_ioctl.c')
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index 0ca0bfeb0ada..ed52d98317cd 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -1793,6 +1793,7 @@ static int prism2_ioctl_siwscan(struct net_device *dev,
1793 1793
1794#ifndef PRISM2_NO_STATION_MODES 1794#ifndef PRISM2_NO_STATION_MODES
1795static char * __prism2_translate_scan(local_info_t *local, 1795static char * __prism2_translate_scan(local_info_t *local,
1796 struct iw_request_info *info,
1796 struct hfa384x_hostscan_result *scan, 1797 struct hfa384x_hostscan_result *scan,
1797 struct hostap_bss_info *bss, 1798 struct hostap_bss_info *bss,
1798 char *current_ev, char *end_buf) 1799 char *current_ev, char *end_buf)
@@ -1823,7 +1824,7 @@ static char * __prism2_translate_scan(local_info_t *local,
1823 iwe.cmd = SIOCGIWAP; 1824 iwe.cmd = SIOCGIWAP;
1824 iwe.u.ap_addr.sa_family = ARPHRD_ETHER; 1825 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1825 memcpy(iwe.u.ap_addr.sa_data, bssid, ETH_ALEN); 1826 memcpy(iwe.u.ap_addr.sa_data, bssid, ETH_ALEN);
1826 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, 1827 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,
1827 IW_EV_ADDR_LEN); 1828 IW_EV_ADDR_LEN);
1828 1829
1829 /* Other entries will be displayed in the order we give them */ 1830 /* Other entries will be displayed in the order we give them */
@@ -1832,7 +1833,8 @@ static char * __prism2_translate_scan(local_info_t *local,
1832 iwe.cmd = SIOCGIWESSID; 1833 iwe.cmd = SIOCGIWESSID;
1833 iwe.u.data.length = ssid_len; 1834 iwe.u.data.length = ssid_len;
1834 iwe.u.data.flags = 1; 1835 iwe.u.data.flags = 1;
1835 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, ssid); 1836 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1837 &iwe, ssid);
1836 1838
1837 memset(&iwe, 0, sizeof(iwe)); 1839 memset(&iwe, 0, sizeof(iwe));
1838 iwe.cmd = SIOCGIWMODE; 1840 iwe.cmd = SIOCGIWMODE;
@@ -1847,8 +1849,8 @@ static char * __prism2_translate_scan(local_info_t *local,
1847 iwe.u.mode = IW_MODE_MASTER; 1849 iwe.u.mode = IW_MODE_MASTER;
1848 else 1850 else
1849 iwe.u.mode = IW_MODE_ADHOC; 1851 iwe.u.mode = IW_MODE_ADHOC;
1850 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, 1852 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
1851 IW_EV_UINT_LEN); 1853 &iwe, IW_EV_UINT_LEN);
1852 } 1854 }
1853 1855
1854 memset(&iwe, 0, sizeof(iwe)); 1856 memset(&iwe, 0, sizeof(iwe));
@@ -1864,8 +1866,8 @@ static char * __prism2_translate_scan(local_info_t *local,
1864 if (chan > 0) { 1866 if (chan > 0) {
1865 iwe.u.freq.m = freq_list[chan - 1] * 100000; 1867 iwe.u.freq.m = freq_list[chan - 1] * 100000;
1866 iwe.u.freq.e = 1; 1868 iwe.u.freq.e = 1;
1867 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, 1869 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
1868 IW_EV_FREQ_LEN); 1870 &iwe, IW_EV_FREQ_LEN);
1869 } 1871 }
1870 1872
1871 if (scan) { 1873 if (scan) {
@@ -1884,8 +1886,8 @@ static char * __prism2_translate_scan(local_info_t *local,
1884 | IW_QUAL_NOISE_UPDATED 1886 | IW_QUAL_NOISE_UPDATED
1885 | IW_QUAL_QUAL_INVALID 1887 | IW_QUAL_QUAL_INVALID
1886 | IW_QUAL_DBM; 1888 | IW_QUAL_DBM;
1887 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, 1889 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
1888 IW_EV_QUAL_LEN); 1890 &iwe, IW_EV_QUAL_LEN);
1889 } 1891 }
1890 1892
1891 memset(&iwe, 0, sizeof(iwe)); 1893 memset(&iwe, 0, sizeof(iwe));
@@ -1895,13 +1897,13 @@ static char * __prism2_translate_scan(local_info_t *local,
1895 else 1897 else
1896 iwe.u.data.flags = IW_ENCODE_DISABLED; 1898 iwe.u.data.flags = IW_ENCODE_DISABLED;
1897 iwe.u.data.length = 0; 1899 iwe.u.data.length = 0;
1898 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, ""); 1900 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, "");
1899 1901
1900 /* TODO: add SuppRates into BSS table */ 1902 /* TODO: add SuppRates into BSS table */
1901 if (scan) { 1903 if (scan) {
1902 memset(&iwe, 0, sizeof(iwe)); 1904 memset(&iwe, 0, sizeof(iwe));
1903 iwe.cmd = SIOCGIWRATE; 1905 iwe.cmd = SIOCGIWRATE;
1904 current_val = current_ev + IW_EV_LCP_LEN; 1906 current_val = current_ev + iwe_stream_lcp_len(info);
1905 pos = scan->sup_rates; 1907 pos = scan->sup_rates;
1906 for (i = 0; i < sizeof(scan->sup_rates); i++) { 1908 for (i = 0; i < sizeof(scan->sup_rates); i++) {
1907 if (pos[i] == 0) 1909 if (pos[i] == 0)
@@ -1909,11 +1911,11 @@ static char * __prism2_translate_scan(local_info_t *local,
1909 /* Bit rate given in 500 kb/s units (+ 0x80) */ 1911 /* Bit rate given in 500 kb/s units (+ 0x80) */
1910 iwe.u.bitrate.value = ((pos[i] & 0x7f) * 500000); 1912 iwe.u.bitrate.value = ((pos[i] & 0x7f) * 500000);
1911 current_val = iwe_stream_add_value( 1913 current_val = iwe_stream_add_value(
1912 current_ev, current_val, end_buf, &iwe, 1914 info, current_ev, current_val, end_buf, &iwe,
1913 IW_EV_PARAM_LEN); 1915 IW_EV_PARAM_LEN);
1914 } 1916 }
1915 /* Check if we added any event */ 1917 /* Check if we added any event */
1916 if ((current_val - current_ev) > IW_EV_LCP_LEN) 1918 if ((current_val - current_ev) > iwe_stream_lcp_len(info))
1917 current_ev = current_val; 1919 current_ev = current_val;
1918 } 1920 }
1919 1921
@@ -1924,15 +1926,15 @@ static char * __prism2_translate_scan(local_info_t *local,
1924 iwe.cmd = IWEVCUSTOM; 1926 iwe.cmd = IWEVCUSTOM;
1925 sprintf(buf, "bcn_int=%d", le16_to_cpu(scan->beacon_interval)); 1927 sprintf(buf, "bcn_int=%d", le16_to_cpu(scan->beacon_interval));
1926 iwe.u.data.length = strlen(buf); 1928 iwe.u.data.length = strlen(buf);
1927 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, 1929 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1928 buf); 1930 &iwe, buf);
1929 1931
1930 memset(&iwe, 0, sizeof(iwe)); 1932 memset(&iwe, 0, sizeof(iwe));
1931 iwe.cmd = IWEVCUSTOM; 1933 iwe.cmd = IWEVCUSTOM;
1932 sprintf(buf, "resp_rate=%d", le16_to_cpu(scan->rate)); 1934 sprintf(buf, "resp_rate=%d", le16_to_cpu(scan->rate));
1933 iwe.u.data.length = strlen(buf); 1935 iwe.u.data.length = strlen(buf);
1934 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, 1936 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1935 buf); 1937 &iwe, buf);
1936 1938
1937 if (local->last_scan_type == PRISM2_HOSTSCAN && 1939 if (local->last_scan_type == PRISM2_HOSTSCAN &&
1938 (capabilities & WLAN_CAPABILITY_IBSS)) { 1940 (capabilities & WLAN_CAPABILITY_IBSS)) {
@@ -1940,8 +1942,8 @@ static char * __prism2_translate_scan(local_info_t *local,
1940 iwe.cmd = IWEVCUSTOM; 1942 iwe.cmd = IWEVCUSTOM;
1941 sprintf(buf, "atim=%d", le16_to_cpu(scan->atim)); 1943 sprintf(buf, "atim=%d", le16_to_cpu(scan->atim));
1942 iwe.u.data.length = strlen(buf); 1944 iwe.u.data.length = strlen(buf);
1943 current_ev = iwe_stream_add_point(current_ev, end_buf, 1945 current_ev = iwe_stream_add_point(info, current_ev,
1944 &iwe, buf); 1946 end_buf, &iwe, buf);
1945 } 1947 }
1946 } 1948 }
1947 kfree(buf); 1949 kfree(buf);
@@ -1950,16 +1952,16 @@ static char * __prism2_translate_scan(local_info_t *local,
1950 memset(&iwe, 0, sizeof(iwe)); 1952 memset(&iwe, 0, sizeof(iwe));
1951 iwe.cmd = IWEVGENIE; 1953 iwe.cmd = IWEVGENIE;
1952 iwe.u.data.length = bss->wpa_ie_len; 1954 iwe.u.data.length = bss->wpa_ie_len;
1953 current_ev = iwe_stream_add_point( 1955 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1954 current_ev, end_buf, &iwe, bss->wpa_ie); 1956 &iwe, bss->wpa_ie);
1955 } 1957 }
1956 1958
1957 if (bss && bss->rsn_ie_len > 0 && bss->rsn_ie_len <= MAX_WPA_IE_LEN) { 1959 if (bss && bss->rsn_ie_len > 0 && bss->rsn_ie_len <= MAX_WPA_IE_LEN) {
1958 memset(&iwe, 0, sizeof(iwe)); 1960 memset(&iwe, 0, sizeof(iwe));
1959 iwe.cmd = IWEVGENIE; 1961 iwe.cmd = IWEVGENIE;
1960 iwe.u.data.length = bss->rsn_ie_len; 1962 iwe.u.data.length = bss->rsn_ie_len;
1961 current_ev = iwe_stream_add_point( 1963 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1962 current_ev, end_buf, &iwe, bss->rsn_ie); 1964 &iwe, bss->rsn_ie);
1963 } 1965 }
1964 1966
1965 return current_ev; 1967 return current_ev;
@@ -1969,6 +1971,7 @@ static char * __prism2_translate_scan(local_info_t *local,
1969/* Translate scan data returned from the card to a card independant 1971/* Translate scan data returned from the card to a card independant
1970 * format that the Wireless Tools will understand - Jean II */ 1972 * format that the Wireless Tools will understand - Jean II */
1971static inline int prism2_translate_scan(local_info_t *local, 1973static inline int prism2_translate_scan(local_info_t *local,
1974 struct iw_request_info *info,
1972 char *buffer, int buflen) 1975 char *buffer, int buflen)
1973{ 1976{
1974 struct hfa384x_hostscan_result *scan; 1977 struct hfa384x_hostscan_result *scan;
@@ -1999,13 +2002,14 @@ static inline int prism2_translate_scan(local_info_t *local,
1999 if (memcmp(bss->bssid, scan->bssid, ETH_ALEN) == 0) { 2002 if (memcmp(bss->bssid, scan->bssid, ETH_ALEN) == 0) {
2000 bss->included = 1; 2003 bss->included = 1;
2001 current_ev = __prism2_translate_scan( 2004 current_ev = __prism2_translate_scan(
2002 local, scan, bss, current_ev, end_buf); 2005 local, info, scan, bss, current_ev,
2006 end_buf);
2003 found++; 2007 found++;
2004 } 2008 }
2005 } 2009 }
2006 if (!found) { 2010 if (!found) {
2007 current_ev = __prism2_translate_scan( 2011 current_ev = __prism2_translate_scan(
2008 local, scan, NULL, current_ev, end_buf); 2012 local, info, scan, NULL, current_ev, end_buf);
2009 } 2013 }
2010 /* Check if there is space for one more entry */ 2014 /* Check if there is space for one more entry */
2011 if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) { 2015 if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) {
@@ -2023,7 +2027,7 @@ static inline int prism2_translate_scan(local_info_t *local,
2023 bss = list_entry(ptr, struct hostap_bss_info, list); 2027 bss = list_entry(ptr, struct hostap_bss_info, list);
2024 if (bss->included) 2028 if (bss->included)
2025 continue; 2029 continue;
2026 current_ev = __prism2_translate_scan(local, NULL, bss, 2030 current_ev = __prism2_translate_scan(local, info, NULL, bss,
2027 current_ev, end_buf); 2031 current_ev, end_buf);
2028 /* Check if there is space for one more entry */ 2032 /* Check if there is space for one more entry */
2029 if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) { 2033 if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) {
@@ -2070,7 +2074,7 @@ static inline int prism2_ioctl_giwscan_sta(struct net_device *dev,
2070 } 2074 }
2071 local->scan_timestamp = 0; 2075 local->scan_timestamp = 0;
2072 2076
2073 res = prism2_translate_scan(local, extra, data->length); 2077 res = prism2_translate_scan(local, info, extra, data->length);
2074 2078
2075 if (res >= 0) { 2079 if (res >= 0) {
2076 data->length = res; 2080 data->length = res;
@@ -2103,7 +2107,7 @@ static int prism2_ioctl_giwscan(struct net_device *dev,
2103 * Jean II */ 2107 * Jean II */
2104 2108
2105 /* Translate to WE format */ 2109 /* Translate to WE format */
2106 res = prism2_ap_translate_scan(dev, extra); 2110 res = prism2_ap_translate_scan(dev, info, extra);
2107 if (res >= 0) { 2111 if (res >= 0) {
2108 printk(KERN_DEBUG "Scan result translation succeeded " 2112 printk(KERN_DEBUG "Scan result translation succeeded "
2109 "(length=%d)\n", res); 2113 "(length=%d)\n", res);