diff options
author | David Kilroy <kilroyd@googlemail.com> | 2009-06-18 18:21:33 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-07-10 15:01:46 -0400 |
commit | c63cdbe8f80487c372fe0dfe460ed30467029f01 (patch) | |
tree | a981d5b052fc74b5f894775353a3e6e96591a1c7 /drivers/net/wireless/orinoco/wext.c | |
parent | 5217c571c898371c540e49671600d54346b2e123 (diff) |
orinoco: convert scanning to cfg80211
This removes the custom scan cache used by orinoco.
We also have to avoid calling cfg80211_scan_done from the hard
interrupt, so we offload the entirety of scan processing to a workqueue.
This may behave strangely if you start scanning just prior to
suspending...
Signed-off-by: David Kilroy <kilroyd@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/orinoco/wext.c')
-rw-r--r-- | drivers/net/wireless/orinoco/wext.c | 517 |
1 files changed, 2 insertions, 515 deletions
diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c index 9cd991a41ad4..082ea0a0cc98 100644 --- a/drivers/net/wireless/orinoco/wext.c +++ b/drivers/net/wireless/orinoco/wext.c | |||
@@ -1583,519 +1583,6 @@ static int orinoco_ioctl_getrid(struct net_device *dev, | |||
1583 | return err; | 1583 | return err; |
1584 | } | 1584 | } |
1585 | 1585 | ||
1586 | /* Trigger a scan (look for other cells in the vicinity) */ | ||
1587 | static int orinoco_ioctl_setscan(struct net_device *dev, | ||
1588 | struct iw_request_info *info, | ||
1589 | struct iw_point *srq, | ||
1590 | char *extra) | ||
1591 | { | ||
1592 | struct orinoco_private *priv = ndev_priv(dev); | ||
1593 | hermes_t *hw = &priv->hw; | ||
1594 | struct iw_scan_req *si = (struct iw_scan_req *) extra; | ||
1595 | int err = 0; | ||
1596 | unsigned long flags; | ||
1597 | |||
1598 | /* Note : you may have realised that, as this is a SET operation, | ||
1599 | * this is privileged and therefore a normal user can't | ||
1600 | * perform scanning. | ||
1601 | * This is not an error, while the device perform scanning, | ||
1602 | * traffic doesn't flow, so it's a perfect DoS... | ||
1603 | * Jean II */ | ||
1604 | |||
1605 | if (orinoco_lock(priv, &flags) != 0) | ||
1606 | return -EBUSY; | ||
1607 | |||
1608 | /* Scanning with port 0 disabled would fail */ | ||
1609 | if (!netif_running(dev)) { | ||
1610 | err = -ENETDOWN; | ||
1611 | goto out; | ||
1612 | } | ||
1613 | |||
1614 | /* In monitor mode, the scan results are always empty. | ||
1615 | * Probe responses are passed to the driver as received | ||
1616 | * frames and could be processed in software. */ | ||
1617 | if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { | ||
1618 | err = -EOPNOTSUPP; | ||
1619 | goto out; | ||
1620 | } | ||
1621 | |||
1622 | /* Note : because we don't lock out the irq handler, the way | ||
1623 | * we access scan variables in priv is critical. | ||
1624 | * o scan_inprogress : not touched by irq handler | ||
1625 | * o scan_mode : not touched by irq handler | ||
1626 | * Before modifying anything on those variables, please think hard ! | ||
1627 | * Jean II */ | ||
1628 | |||
1629 | /* Save flags */ | ||
1630 | priv->scan_mode = srq->flags; | ||
1631 | |||
1632 | /* Always trigger scanning, even if it's in progress. | ||
1633 | * This way, if the info frame get lost, we will recover somewhat | ||
1634 | * gracefully - Jean II */ | ||
1635 | |||
1636 | if (priv->has_hostscan) { | ||
1637 | switch (priv->firmware_type) { | ||
1638 | case FIRMWARE_TYPE_SYMBOL: | ||
1639 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1640 | HERMES_RID_CNFHOSTSCAN_SYMBOL, | ||
1641 | HERMES_HOSTSCAN_SYMBOL_ONCE | | ||
1642 | HERMES_HOSTSCAN_SYMBOL_BCAST); | ||
1643 | break; | ||
1644 | case FIRMWARE_TYPE_INTERSIL: { | ||
1645 | __le16 req[3]; | ||
1646 | |||
1647 | req[0] = cpu_to_le16(0x3fff); /* All channels */ | ||
1648 | req[1] = cpu_to_le16(0x0001); /* rate 1 Mbps */ | ||
1649 | req[2] = 0; /* Any ESSID */ | ||
1650 | err = HERMES_WRITE_RECORD(hw, USER_BAP, | ||
1651 | HERMES_RID_CNFHOSTSCAN, &req); | ||
1652 | } | ||
1653 | break; | ||
1654 | case FIRMWARE_TYPE_AGERE: | ||
1655 | if (priv->scan_mode & IW_SCAN_THIS_ESSID) { | ||
1656 | struct hermes_idstring idbuf; | ||
1657 | size_t len = min(sizeof(idbuf.val), | ||
1658 | (size_t) si->essid_len); | ||
1659 | idbuf.len = cpu_to_le16(len); | ||
1660 | memcpy(idbuf.val, si->essid, len); | ||
1661 | |||
1662 | err = hermes_write_ltv(hw, USER_BAP, | ||
1663 | HERMES_RID_CNFSCANSSID_AGERE, | ||
1664 | HERMES_BYTES_TO_RECLEN(len + 2), | ||
1665 | &idbuf); | ||
1666 | } else | ||
1667 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1668 | HERMES_RID_CNFSCANSSID_AGERE, | ||
1669 | 0); /* Any ESSID */ | ||
1670 | if (err) | ||
1671 | break; | ||
1672 | |||
1673 | if (priv->has_ext_scan) { | ||
1674 | /* Clear scan results at the start of | ||
1675 | * an extended scan */ | ||
1676 | orinoco_clear_scan_results(priv, | ||
1677 | msecs_to_jiffies(15000)); | ||
1678 | |||
1679 | /* TODO: Is this available on older firmware? | ||
1680 | * Can we use it to scan specific channels | ||
1681 | * for IW_SCAN_THIS_FREQ? */ | ||
1682 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1683 | HERMES_RID_CNFSCANCHANNELS2GHZ, | ||
1684 | 0x7FFF); | ||
1685 | if (err) | ||
1686 | goto out; | ||
1687 | |||
1688 | err = hermes_inquire(hw, | ||
1689 | HERMES_INQ_CHANNELINFO); | ||
1690 | } else | ||
1691 | err = hermes_inquire(hw, HERMES_INQ_SCAN); | ||
1692 | break; | ||
1693 | } | ||
1694 | } else | ||
1695 | err = hermes_inquire(hw, HERMES_INQ_SCAN); | ||
1696 | |||
1697 | /* One more client */ | ||
1698 | if (!err) | ||
1699 | priv->scan_inprogress = 1; | ||
1700 | |||
1701 | out: | ||
1702 | orinoco_unlock(priv, &flags); | ||
1703 | return err; | ||
1704 | } | ||
1705 | |||
1706 | #define MAX_CUSTOM_LEN 64 | ||
1707 | |||
1708 | /* Translate scan data returned from the card to a card independant | ||
1709 | * format that the Wireless Tools will understand - Jean II */ | ||
1710 | static inline char *orinoco_translate_scan(struct net_device *dev, | ||
1711 | struct iw_request_info *info, | ||
1712 | char *current_ev, | ||
1713 | char *end_buf, | ||
1714 | union hermes_scan_info *bss, | ||
1715 | unsigned long last_scanned) | ||
1716 | { | ||
1717 | struct orinoco_private *priv = ndev_priv(dev); | ||
1718 | u16 capabilities; | ||
1719 | u16 channel; | ||
1720 | struct iw_event iwe; /* Temporary buffer */ | ||
1721 | char custom[MAX_CUSTOM_LEN]; | ||
1722 | |||
1723 | memset(&iwe, 0, sizeof(iwe)); | ||
1724 | |||
1725 | /* First entry *MUST* be the AP MAC address */ | ||
1726 | iwe.cmd = SIOCGIWAP; | ||
1727 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; | ||
1728 | memcpy(iwe.u.ap_addr.sa_data, bss->a.bssid, ETH_ALEN); | ||
1729 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1730 | &iwe, IW_EV_ADDR_LEN); | ||
1731 | |||
1732 | /* Other entries will be displayed in the order we give them */ | ||
1733 | |||
1734 | /* Add the ESSID */ | ||
1735 | iwe.u.data.length = le16_to_cpu(bss->a.essid_len); | ||
1736 | if (iwe.u.data.length > 32) | ||
1737 | iwe.u.data.length = 32; | ||
1738 | iwe.cmd = SIOCGIWESSID; | ||
1739 | iwe.u.data.flags = 1; | ||
1740 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1741 | &iwe, bss->a.essid); | ||
1742 | |||
1743 | /* Add mode */ | ||
1744 | iwe.cmd = SIOCGIWMODE; | ||
1745 | capabilities = le16_to_cpu(bss->a.capabilities); | ||
1746 | if (capabilities & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) { | ||
1747 | if (capabilities & WLAN_CAPABILITY_ESS) | ||
1748 | iwe.u.mode = IW_MODE_MASTER; | ||
1749 | else | ||
1750 | iwe.u.mode = IW_MODE_ADHOC; | ||
1751 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1752 | &iwe, IW_EV_UINT_LEN); | ||
1753 | } | ||
1754 | |||
1755 | channel = bss->s.channel; | ||
1756 | if ((channel >= 1) && (channel <= NUM_CHANNELS)) { | ||
1757 | /* Add channel and frequency */ | ||
1758 | iwe.cmd = SIOCGIWFREQ; | ||
1759 | iwe.u.freq.m = channel; | ||
1760 | iwe.u.freq.e = 0; | ||
1761 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1762 | &iwe, IW_EV_FREQ_LEN); | ||
1763 | |||
1764 | iwe.u.freq.m = ieee80211_dsss_chan_to_freq(channel) * 100000; | ||
1765 | iwe.u.freq.e = 1; | ||
1766 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1767 | &iwe, IW_EV_FREQ_LEN); | ||
1768 | } | ||
1769 | |||
1770 | /* Add quality statistics. level and noise in dB. No link quality */ | ||
1771 | iwe.cmd = IWEVQUAL; | ||
1772 | iwe.u.qual.updated = IW_QUAL_DBM | IW_QUAL_QUAL_INVALID; | ||
1773 | iwe.u.qual.level = (__u8) le16_to_cpu(bss->a.level) - 0x95; | ||
1774 | iwe.u.qual.noise = (__u8) le16_to_cpu(bss->a.noise) - 0x95; | ||
1775 | /* Wireless tools prior to 27.pre22 will show link quality | ||
1776 | * anyway, so we provide a reasonable value. */ | ||
1777 | if (iwe.u.qual.level > iwe.u.qual.noise) | ||
1778 | iwe.u.qual.qual = iwe.u.qual.level - iwe.u.qual.noise; | ||
1779 | else | ||
1780 | iwe.u.qual.qual = 0; | ||
1781 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1782 | &iwe, IW_EV_QUAL_LEN); | ||
1783 | |||
1784 | /* Add encryption capability */ | ||
1785 | iwe.cmd = SIOCGIWENCODE; | ||
1786 | if (capabilities & WLAN_CAPABILITY_PRIVACY) | ||
1787 | iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; | ||
1788 | else | ||
1789 | iwe.u.data.flags = IW_ENCODE_DISABLED; | ||
1790 | iwe.u.data.length = 0; | ||
1791 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1792 | &iwe, NULL); | ||
1793 | |||
1794 | /* Bit rate is not available in Lucent/Agere firmwares */ | ||
1795 | if (priv->firmware_type != FIRMWARE_TYPE_AGERE) { | ||
1796 | char *current_val = current_ev + iwe_stream_lcp_len(info); | ||
1797 | int i; | ||
1798 | int step; | ||
1799 | |||
1800 | if (priv->firmware_type == FIRMWARE_TYPE_SYMBOL) | ||
1801 | step = 2; | ||
1802 | else | ||
1803 | step = 1; | ||
1804 | |||
1805 | iwe.cmd = SIOCGIWRATE; | ||
1806 | /* Those two flags are ignored... */ | ||
1807 | iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; | ||
1808 | /* Max 10 values */ | ||
1809 | for (i = 0; i < 10; i += step) { | ||
1810 | /* NULL terminated */ | ||
1811 | if (bss->p.rates[i] == 0x0) | ||
1812 | break; | ||
1813 | /* Bit rate given in 500 kb/s units (+ 0x80) */ | ||
1814 | iwe.u.bitrate.value = | ||
1815 | ((bss->p.rates[i] & 0x7f) * 500000); | ||
1816 | current_val = iwe_stream_add_value(info, current_ev, | ||
1817 | current_val, | ||
1818 | end_buf, &iwe, | ||
1819 | IW_EV_PARAM_LEN); | ||
1820 | } | ||
1821 | /* Check if we added any event */ | ||
1822 | if ((current_val - current_ev) > iwe_stream_lcp_len(info)) | ||
1823 | current_ev = current_val; | ||
1824 | } | ||
1825 | |||
1826 | /* Beacon interval */ | ||
1827 | iwe.cmd = IWEVCUSTOM; | ||
1828 | iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN, | ||
1829 | "bcn_int=%d", | ||
1830 | le16_to_cpu(bss->a.beacon_interv)); | ||
1831 | if (iwe.u.data.length) | ||
1832 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1833 | &iwe, custom); | ||
1834 | |||
1835 | /* Capabilites */ | ||
1836 | iwe.cmd = IWEVCUSTOM; | ||
1837 | iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN, | ||
1838 | "capab=0x%04x", | ||
1839 | capabilities); | ||
1840 | if (iwe.u.data.length) | ||
1841 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1842 | &iwe, custom); | ||
1843 | |||
1844 | /* Add EXTRA: Age to display seconds since last beacon/probe response | ||
1845 | * for given network. */ | ||
1846 | iwe.cmd = IWEVCUSTOM; | ||
1847 | iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN, | ||
1848 | " Last beacon: %dms ago", | ||
1849 | jiffies_to_msecs(jiffies - last_scanned)); | ||
1850 | if (iwe.u.data.length) | ||
1851 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1852 | &iwe, custom); | ||
1853 | |||
1854 | return current_ev; | ||
1855 | } | ||
1856 | |||
1857 | static inline char *orinoco_translate_ext_scan(struct net_device *dev, | ||
1858 | struct iw_request_info *info, | ||
1859 | char *current_ev, | ||
1860 | char *end_buf, | ||
1861 | struct agere_ext_scan_info *bss, | ||
1862 | unsigned long last_scanned) | ||
1863 | { | ||
1864 | u16 capabilities; | ||
1865 | u16 channel; | ||
1866 | struct iw_event iwe; /* Temporary buffer */ | ||
1867 | char custom[MAX_CUSTOM_LEN]; | ||
1868 | u8 *ie; | ||
1869 | |||
1870 | memset(&iwe, 0, sizeof(iwe)); | ||
1871 | |||
1872 | /* First entry *MUST* be the AP MAC address */ | ||
1873 | iwe.cmd = SIOCGIWAP; | ||
1874 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; | ||
1875 | memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN); | ||
1876 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1877 | &iwe, IW_EV_ADDR_LEN); | ||
1878 | |||
1879 | /* Other entries will be displayed in the order we give them */ | ||
1880 | |||
1881 | /* Add the ESSID */ | ||
1882 | ie = bss->data; | ||
1883 | iwe.u.data.length = ie[1]; | ||
1884 | if (iwe.u.data.length) { | ||
1885 | if (iwe.u.data.length > 32) | ||
1886 | iwe.u.data.length = 32; | ||
1887 | iwe.cmd = SIOCGIWESSID; | ||
1888 | iwe.u.data.flags = 1; | ||
1889 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1890 | &iwe, &ie[2]); | ||
1891 | } | ||
1892 | |||
1893 | /* Add mode */ | ||
1894 | capabilities = le16_to_cpu(bss->capabilities); | ||
1895 | if (capabilities & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) { | ||
1896 | iwe.cmd = SIOCGIWMODE; | ||
1897 | if (capabilities & WLAN_CAPABILITY_ESS) | ||
1898 | iwe.u.mode = IW_MODE_MASTER; | ||
1899 | else | ||
1900 | iwe.u.mode = IW_MODE_ADHOC; | ||
1901 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1902 | &iwe, IW_EV_UINT_LEN); | ||
1903 | } | ||
1904 | |||
1905 | ie = orinoco_get_ie(bss->data, sizeof(bss->data), WLAN_EID_DS_PARAMS); | ||
1906 | channel = ie ? ie[2] : 0; | ||
1907 | if ((channel >= 1) && (channel <= NUM_CHANNELS)) { | ||
1908 | /* Add channel and frequency */ | ||
1909 | iwe.cmd = SIOCGIWFREQ; | ||
1910 | iwe.u.freq.m = channel; | ||
1911 | iwe.u.freq.e = 0; | ||
1912 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1913 | &iwe, IW_EV_FREQ_LEN); | ||
1914 | |||
1915 | iwe.u.freq.m = ieee80211_dsss_chan_to_freq(channel) * 100000; | ||
1916 | iwe.u.freq.e = 1; | ||
1917 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1918 | &iwe, IW_EV_FREQ_LEN); | ||
1919 | } | ||
1920 | |||
1921 | /* Add quality statistics. level and noise in dB. No link quality */ | ||
1922 | iwe.cmd = IWEVQUAL; | ||
1923 | iwe.u.qual.updated = IW_QUAL_DBM | IW_QUAL_QUAL_INVALID; | ||
1924 | iwe.u.qual.level = bss->level - 0x95; | ||
1925 | iwe.u.qual.noise = bss->noise - 0x95; | ||
1926 | /* Wireless tools prior to 27.pre22 will show link quality | ||
1927 | * anyway, so we provide a reasonable value. */ | ||
1928 | if (iwe.u.qual.level > iwe.u.qual.noise) | ||
1929 | iwe.u.qual.qual = iwe.u.qual.level - iwe.u.qual.noise; | ||
1930 | else | ||
1931 | iwe.u.qual.qual = 0; | ||
1932 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1933 | &iwe, IW_EV_QUAL_LEN); | ||
1934 | |||
1935 | /* Add encryption capability */ | ||
1936 | iwe.cmd = SIOCGIWENCODE; | ||
1937 | if (capabilities & WLAN_CAPABILITY_PRIVACY) | ||
1938 | iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; | ||
1939 | else | ||
1940 | iwe.u.data.flags = IW_ENCODE_DISABLED; | ||
1941 | iwe.u.data.length = 0; | ||
1942 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1943 | &iwe, NULL); | ||
1944 | |||
1945 | /* WPA IE */ | ||
1946 | ie = orinoco_get_wpa_ie(bss->data, sizeof(bss->data)); | ||
1947 | if (ie) { | ||
1948 | iwe.cmd = IWEVGENIE; | ||
1949 | iwe.u.data.length = ie[1] + 2; | ||
1950 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1951 | &iwe, ie); | ||
1952 | } | ||
1953 | |||
1954 | /* RSN IE */ | ||
1955 | ie = orinoco_get_ie(bss->data, sizeof(bss->data), WLAN_EID_RSN); | ||
1956 | if (ie) { | ||
1957 | iwe.cmd = IWEVGENIE; | ||
1958 | iwe.u.data.length = ie[1] + 2; | ||
1959 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1960 | &iwe, ie); | ||
1961 | } | ||
1962 | |||
1963 | ie = orinoco_get_ie(bss->data, sizeof(bss->data), WLAN_EID_SUPP_RATES); | ||
1964 | if (ie) { | ||
1965 | char *p = current_ev + iwe_stream_lcp_len(info); | ||
1966 | int i; | ||
1967 | |||
1968 | iwe.cmd = SIOCGIWRATE; | ||
1969 | /* Those two flags are ignored... */ | ||
1970 | iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; | ||
1971 | |||
1972 | for (i = 2; i < (ie[1] + 2); i++) { | ||
1973 | iwe.u.bitrate.value = ((ie[i] & 0x7F) * 500000); | ||
1974 | p = iwe_stream_add_value(info, current_ev, p, end_buf, | ||
1975 | &iwe, IW_EV_PARAM_LEN); | ||
1976 | } | ||
1977 | /* Check if we added any event */ | ||
1978 | if (p > (current_ev + iwe_stream_lcp_len(info))) | ||
1979 | current_ev = p; | ||
1980 | } | ||
1981 | |||
1982 | /* Timestamp */ | ||
1983 | iwe.cmd = IWEVCUSTOM; | ||
1984 | iwe.u.data.length = | ||
1985 | snprintf(custom, MAX_CUSTOM_LEN, "tsf=%016llx", | ||
1986 | (unsigned long long) le64_to_cpu(bss->timestamp)); | ||
1987 | if (iwe.u.data.length) | ||
1988 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1989 | &iwe, custom); | ||
1990 | |||
1991 | /* Beacon interval */ | ||
1992 | iwe.cmd = IWEVCUSTOM; | ||
1993 | iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN, | ||
1994 | "bcn_int=%d", | ||
1995 | le16_to_cpu(bss->beacon_interval)); | ||
1996 | if (iwe.u.data.length) | ||
1997 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1998 | &iwe, custom); | ||
1999 | |||
2000 | /* Capabilites */ | ||
2001 | iwe.cmd = IWEVCUSTOM; | ||
2002 | iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN, | ||
2003 | "capab=0x%04x", | ||
2004 | capabilities); | ||
2005 | if (iwe.u.data.length) | ||
2006 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
2007 | &iwe, custom); | ||
2008 | |||
2009 | /* Add EXTRA: Age to display seconds since last beacon/probe response | ||
2010 | * for given network. */ | ||
2011 | iwe.cmd = IWEVCUSTOM; | ||
2012 | iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN, | ||
2013 | " Last beacon: %dms ago", | ||
2014 | jiffies_to_msecs(jiffies - last_scanned)); | ||
2015 | if (iwe.u.data.length) | ||
2016 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
2017 | &iwe, custom); | ||
2018 | |||
2019 | return current_ev; | ||
2020 | } | ||
2021 | |||
2022 | /* Return results of a scan */ | ||
2023 | static int orinoco_ioctl_getscan(struct net_device *dev, | ||
2024 | struct iw_request_info *info, | ||
2025 | struct iw_point *srq, | ||
2026 | char *extra) | ||
2027 | { | ||
2028 | struct orinoco_private *priv = ndev_priv(dev); | ||
2029 | int err = 0; | ||
2030 | unsigned long flags; | ||
2031 | char *current_ev = extra; | ||
2032 | |||
2033 | if (orinoco_lock(priv, &flags) != 0) | ||
2034 | return -EBUSY; | ||
2035 | |||
2036 | if (priv->scan_inprogress) { | ||
2037 | /* Important note : we don't want to block the caller | ||
2038 | * until results are ready for various reasons. | ||
2039 | * First, managing wait queues is complex and racy. | ||
2040 | * Second, we grab some rtnetlink lock before comming | ||
2041 | * here (in dev_ioctl()). | ||
2042 | * Third, we generate an Wireless Event, so the | ||
2043 | * caller can wait itself on that - Jean II */ | ||
2044 | err = -EAGAIN; | ||
2045 | goto out; | ||
2046 | } | ||
2047 | |||
2048 | if (priv->has_ext_scan) { | ||
2049 | struct xbss_element *bss; | ||
2050 | |||
2051 | list_for_each_entry(bss, &priv->bss_list, list) { | ||
2052 | /* Translate this entry to WE format */ | ||
2053 | current_ev = | ||
2054 | orinoco_translate_ext_scan(dev, info, | ||
2055 | current_ev, | ||
2056 | extra + srq->length, | ||
2057 | &bss->bss, | ||
2058 | bss->last_scanned); | ||
2059 | |||
2060 | /* Check if there is space for one more entry */ | ||
2061 | if ((extra + srq->length - current_ev) | ||
2062 | <= IW_EV_ADDR_LEN) { | ||
2063 | /* Ask user space to try again with a | ||
2064 | * bigger buffer */ | ||
2065 | err = -E2BIG; | ||
2066 | goto out; | ||
2067 | } | ||
2068 | } | ||
2069 | |||
2070 | } else { | ||
2071 | struct bss_element *bss; | ||
2072 | |||
2073 | list_for_each_entry(bss, &priv->bss_list, list) { | ||
2074 | /* Translate this entry to WE format */ | ||
2075 | current_ev = orinoco_translate_scan(dev, info, | ||
2076 | current_ev, | ||
2077 | extra + srq->length, | ||
2078 | &bss->bss, | ||
2079 | bss->last_scanned); | ||
2080 | |||
2081 | /* Check if there is space for one more entry */ | ||
2082 | if ((extra + srq->length - current_ev) | ||
2083 | <= IW_EV_ADDR_LEN) { | ||
2084 | /* Ask user space to try again with a | ||
2085 | * bigger buffer */ | ||
2086 | err = -E2BIG; | ||
2087 | goto out; | ||
2088 | } | ||
2089 | } | ||
2090 | } | ||
2091 | |||
2092 | srq->length = (current_ev - extra); | ||
2093 | srq->flags = (__u16) priv->scan_mode; | ||
2094 | |||
2095 | out: | ||
2096 | orinoco_unlock(priv, &flags); | ||
2097 | return err; | ||
2098 | } | ||
2099 | 1586 | ||
2100 | /* Commit handler, called after set operations */ | 1587 | /* Commit handler, called after set operations */ |
2101 | static int orinoco_ioctl_commit(struct net_device *dev, | 1588 | static int orinoco_ioctl_commit(struct net_device *dev, |
@@ -2161,8 +1648,8 @@ static const iw_handler orinoco_handler[] = { | |||
2161 | STD_IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy), | 1648 | STD_IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy), |
2162 | STD_IW_HANDLER(SIOCSIWAP, orinoco_ioctl_setwap), | 1649 | STD_IW_HANDLER(SIOCSIWAP, orinoco_ioctl_setwap), |
2163 | STD_IW_HANDLER(SIOCGIWAP, orinoco_ioctl_getwap), | 1650 | STD_IW_HANDLER(SIOCGIWAP, orinoco_ioctl_getwap), |
2164 | STD_IW_HANDLER(SIOCSIWSCAN, orinoco_ioctl_setscan), | 1651 | STD_IW_HANDLER(SIOCSIWSCAN, cfg80211_wext_siwscan), |
2165 | STD_IW_HANDLER(SIOCGIWSCAN, orinoco_ioctl_getscan), | 1652 | STD_IW_HANDLER(SIOCGIWSCAN, cfg80211_wext_giwscan), |
2166 | STD_IW_HANDLER(SIOCSIWESSID, orinoco_ioctl_setessid), | 1653 | STD_IW_HANDLER(SIOCSIWESSID, orinoco_ioctl_setessid), |
2167 | STD_IW_HANDLER(SIOCGIWESSID, orinoco_ioctl_getessid), | 1654 | STD_IW_HANDLER(SIOCGIWESSID, orinoco_ioctl_getessid), |
2168 | STD_IW_HANDLER(SIOCSIWNICKN, orinoco_ioctl_setnick), | 1655 | STD_IW_HANDLER(SIOCSIWNICKN, orinoco_ioctl_setnick), |