diff options
author | Jean Tourrilhes <jt@hpl.hp.com> | 2007-08-02 13:16:30 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:50:12 -0400 |
commit | 9483f03150cbfa1f706355b7f9d218d6086c6fce (patch) | |
tree | aaf127fa470555557ca20d03d2b4d46a0ca3a2c1 /drivers | |
parent | d21b31fd53626f9c1d14fc676793dbe86b44d1c6 (diff) |
[PATCH] libertas: fix a few wext abuses...
o SIOCGIWNAME is not designed to return the version number of the driver.
On the other hand, you are free to abuse SIOCGIWNICKN for that purpose.
o Don't attempt to fix the WE19/WE20 transition in the driver, because
your fixes are bogus, and redundant with the code in the kernel (you may
endup with +2, you can't read 32 char ESSID...).
o In SIOCSIWTXPOW, if you specified in iwrange that you want dBm, you
should only get dBm, which allow to reduce code bloat.
Signed-off-by: Jean Tourrilhes <jt@hpl.hp.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/libertas/wext.c | 120 |
1 files changed, 27 insertions, 93 deletions
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c index 1fb0f91e538a..15395bf0a2ac 100644 --- a/drivers/net/wireless/libertas/wext.c +++ b/drivers/net/wireless/libertas/wext.c | |||
@@ -22,52 +22,6 @@ | |||
22 | 22 | ||
23 | 23 | ||
24 | /** | 24 | /** |
25 | * @brief Convert mw value to dbm value | ||
26 | * | ||
27 | * @param mw the value of mw | ||
28 | * @return the value of dbm | ||
29 | */ | ||
30 | static int mw_to_dbm(int mw) | ||
31 | { | ||
32 | if (mw < 2) | ||
33 | return 0; | ||
34 | else if (mw < 3) | ||
35 | return 3; | ||
36 | else if (mw < 4) | ||
37 | return 5; | ||
38 | else if (mw < 6) | ||
39 | return 7; | ||
40 | else if (mw < 7) | ||
41 | return 8; | ||
42 | else if (mw < 8) | ||
43 | return 9; | ||
44 | else if (mw < 10) | ||
45 | return 10; | ||
46 | else if (mw < 13) | ||
47 | return 11; | ||
48 | else if (mw < 16) | ||
49 | return 12; | ||
50 | else if (mw < 20) | ||
51 | return 13; | ||
52 | else if (mw < 25) | ||
53 | return 14; | ||
54 | else if (mw < 32) | ||
55 | return 15; | ||
56 | else if (mw < 40) | ||
57 | return 16; | ||
58 | else if (mw < 50) | ||
59 | return 17; | ||
60 | else if (mw < 63) | ||
61 | return 18; | ||
62 | else if (mw < 79) | ||
63 | return 19; | ||
64 | else if (mw < 100) | ||
65 | return 20; | ||
66 | else | ||
67 | return 21; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * @brief Find the channel frequency power info with specific channel | 25 | * @brief Find the channel frequency power info with specific channel |
72 | * | 26 | * |
73 | * @param adapter A pointer to wlan_adapter structure | 27 | * @param adapter A pointer to wlan_adapter structure |
@@ -199,28 +153,11 @@ static void copy_active_data_rates(wlan_adapter * adapter, u8 * rates) | |||
199 | static int wlan_get_name(struct net_device *dev, struct iw_request_info *info, | 153 | static int wlan_get_name(struct net_device *dev, struct iw_request_info *info, |
200 | char *cwrq, char *extra) | 154 | char *cwrq, char *extra) |
201 | { | 155 | { |
202 | const char *cp; | ||
203 | char comm[6] = { "COMM-" }; | ||
204 | char mrvl[6] = { "MRVL-" }; | ||
205 | int cnt; | ||
206 | 156 | ||
207 | lbs_deb_enter(LBS_DEB_WEXT); | 157 | lbs_deb_enter(LBS_DEB_WEXT); |
208 | 158 | ||
209 | strcpy(cwrq, mrvl); | 159 | /* We could add support for 802.11n here as needed. Jean II */ |
210 | 160 | snprintf(cwrq, IFNAMSIZ, "IEEE 802.11b/g"); | |
211 | cp = strstr(libertas_driver_version, comm); | ||
212 | if (cp == libertas_driver_version) //skip leading "COMM-" | ||
213 | cp = libertas_driver_version + strlen(comm); | ||
214 | else | ||
215 | cp = libertas_driver_version; | ||
216 | |||
217 | cnt = strlen(mrvl); | ||
218 | cwrq += cnt; | ||
219 | while (cnt < 16 && (*cp != '-')) { | ||
220 | *cwrq++ = toupper(*cp++); | ||
221 | cnt++; | ||
222 | } | ||
223 | *cwrq = '\0'; | ||
224 | 161 | ||
225 | lbs_deb_leave(LBS_DEB_WEXT); | 162 | lbs_deb_leave(LBS_DEB_WEXT); |
226 | return 0; | 163 | return 0; |
@@ -300,29 +237,37 @@ static int wlan_set_nick(struct net_device *dev, struct iw_request_info *info, | |||
300 | static int wlan_get_nick(struct net_device *dev, struct iw_request_info *info, | 237 | static int wlan_get_nick(struct net_device *dev, struct iw_request_info *info, |
301 | struct iw_point *dwrq, char *extra) | 238 | struct iw_point *dwrq, char *extra) |
302 | { | 239 | { |
303 | wlan_private *priv = dev->priv; | 240 | const char *cp; |
304 | wlan_adapter *adapter = priv->adapter; | 241 | char comm[6] = { "COMM-" }; |
242 | char mrvl[6] = { "MRVL-" }; | ||
243 | int cnt; | ||
305 | 244 | ||
306 | lbs_deb_enter(LBS_DEB_WEXT); | 245 | lbs_deb_enter(LBS_DEB_WEXT); |
307 | 246 | ||
308 | /* | 247 | /* |
309 | * Get the Nick Name saved | 248 | * Nick Name is not used internally in this mode, |
249 | * therefore return something useful instead. Jean II | ||
310 | */ | 250 | */ |
311 | 251 | ||
312 | mutex_lock(&adapter->lock); | 252 | strcpy(extra, mrvl); |
313 | strncpy(extra, adapter->nodename, 16); | ||
314 | mutex_unlock(&adapter->lock); | ||
315 | 253 | ||
316 | extra[16] = '\0'; | 254 | cp = strstr(libertas_driver_version, comm); |
255 | if (cp == libertas_driver_version) //skip leading "COMM-" | ||
256 | cp = libertas_driver_version + strlen(comm); | ||
257 | else | ||
258 | cp = libertas_driver_version; | ||
317 | 259 | ||
318 | /* | 260 | cnt = strlen(mrvl); |
319 | * If none, we may want to get the one that was set | 261 | extra += cnt; |
320 | */ | 262 | while (cnt < 16 && (*cp != '-')) { |
263 | *extra++ = toupper(*cp++); | ||
264 | cnt++; | ||
265 | } | ||
321 | 266 | ||
322 | /* | 267 | /* |
323 | * Push it out ! | 268 | * Push it out ! |
324 | */ | 269 | */ |
325 | dwrq->length = strlen(extra) + 1; | 270 | dwrq->length = cnt; |
326 | 271 | ||
327 | lbs_deb_leave(LBS_DEB_WEXT); | 272 | lbs_deb_leave(LBS_DEB_WEXT); |
328 | return 0; | 273 | return 0; |
@@ -341,12 +286,12 @@ static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info, | |||
341 | if (adapter->connect_status == LIBERTAS_CONNECTED) { | 286 | if (adapter->connect_status == LIBERTAS_CONNECTED) { |
342 | strncpy(extra, "Mesh", 12); | 287 | strncpy(extra, "Mesh", 12); |
343 | extra[12] = '\0'; | 288 | extra[12] = '\0'; |
344 | dwrq->length = strlen(extra) + 1; | 289 | dwrq->length = strlen(extra); |
345 | } | 290 | } |
346 | 291 | ||
347 | else { | 292 | else { |
348 | extra[0] = '\0'; | 293 | extra[0] = '\0'; |
349 | dwrq->length = 1 ; | 294 | dwrq->length = 0; |
350 | } | 295 | } |
351 | 296 | ||
352 | lbs_deb_leave(LBS_DEB_WEXT); | 297 | lbs_deb_leave(LBS_DEB_WEXT); |
@@ -1897,8 +1842,10 @@ static int wlan_set_txpow(struct net_device *dev, struct iw_request_info *info, | |||
1897 | 1842 | ||
1898 | wlan_radio_ioctl(priv, RADIO_ON); | 1843 | wlan_radio_ioctl(priv, RADIO_ON); |
1899 | 1844 | ||
1845 | /* Userspace check in iwrange if it should use dBm or mW, | ||
1846 | * therefore this should never happen... Jean II */ | ||
1900 | if ((vwrq->flags & IW_TXPOW_TYPE) == IW_TXPOW_MWATT) { | 1847 | if ((vwrq->flags & IW_TXPOW_TYPE) == IW_TXPOW_MWATT) { |
1901 | dbm = (u16) mw_to_dbm(vwrq->value); | 1848 | return -EOPNOTSUPP; |
1902 | } else | 1849 | } else |
1903 | dbm = (u16) vwrq->value; | 1850 | dbm = (u16) vwrq->value; |
1904 | 1851 | ||
@@ -1946,12 +1893,7 @@ static int wlan_get_essid(struct net_device *dev, struct iw_request_info *info, | |||
1946 | * If none, we may want to get the one that was set | 1893 | * If none, we may want to get the one that was set |
1947 | */ | 1894 | */ |
1948 | 1895 | ||
1949 | /* To make the driver backward compatible with WPA supplicant v0.2.4 */ | 1896 | dwrq->length = adapter->curbssparams.ssid_len; |
1950 | if (dwrq->length == 32) /* check with WPA supplicant buffer size */ | ||
1951 | dwrq->length = min_t(size_t, adapter->curbssparams.ssid_len, | ||
1952 | IW_ESSID_MAX_SIZE); | ||
1953 | else | ||
1954 | dwrq->length = adapter->curbssparams.ssid_len + 1; | ||
1955 | 1897 | ||
1956 | dwrq->flags = 1; /* active */ | 1898 | dwrq->flags = 1; /* active */ |
1957 | 1899 | ||
@@ -1972,14 +1914,6 @@ static int wlan_set_essid(struct net_device *dev, struct iw_request_info *info, | |||
1972 | 1914 | ||
1973 | lbs_deb_enter(LBS_DEB_WEXT); | 1915 | lbs_deb_enter(LBS_DEB_WEXT); |
1974 | 1916 | ||
1975 | /* | ||
1976 | * WE-20 and earlier NULL pad the end of the SSID and increment | ||
1977 | * SSID length so it can be used like a string. WE-21 and later don't, | ||
1978 | * but some userspace tools aren't able to cope with the change. | ||
1979 | */ | ||
1980 | if ((in_ssid_len > 0) && (extra[in_ssid_len - 1] == '\0')) | ||
1981 | in_ssid_len--; | ||
1982 | |||
1983 | /* Check the size of the string */ | 1917 | /* Check the size of the string */ |
1984 | if (in_ssid_len > IW_ESSID_MAX_SIZE) { | 1918 | if (in_ssid_len > IW_ESSID_MAX_SIZE) { |
1985 | ret = -E2BIG; | 1919 | ret = -E2BIG; |