David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1 | /* Wireless extensions support. |
| 2 | * |
| 3 | * See copyright notice in main.c |
| 4 | */ |
| 5 | #include <linux/kernel.h> |
| 6 | #include <linux/if_arp.h> |
| 7 | #include <linux/wireless.h> |
| 8 | #include <linux/ieee80211.h> |
| 9 | #include <net/iw_handler.h> |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 10 | #include <net/cfg80211.h> |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 11 | |
| 12 | #include "hermes.h" |
| 13 | #include "hermes_rid.h" |
| 14 | #include "orinoco.h" |
| 15 | |
| 16 | #include "hw.h" |
| 17 | #include "mic.h" |
| 18 | #include "scan.h" |
| 19 | #include "main.h" |
| 20 | |
| 21 | #include "wext.h" |
| 22 | |
| 23 | #define MAX_RID_LEN 1024 |
| 24 | |
| 25 | static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev) |
| 26 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 27 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 28 | hermes_t *hw = &priv->hw; |
| 29 | struct iw_statistics *wstats = &priv->wstats; |
| 30 | int err; |
| 31 | unsigned long flags; |
| 32 | |
| 33 | if (!netif_device_present(dev)) { |
| 34 | printk(KERN_WARNING "%s: get_wireless_stats() called while device not present\n", |
| 35 | dev->name); |
| 36 | return NULL; /* FIXME: Can we do better than this? */ |
| 37 | } |
| 38 | |
| 39 | /* If busy, return the old stats. Returning NULL may cause |
| 40 | * the interface to disappear from /proc/net/wireless */ |
| 41 | if (orinoco_lock(priv, &flags) != 0) |
| 42 | return wstats; |
| 43 | |
| 44 | /* We can't really wait for the tallies inquiry command to |
| 45 | * complete, so we just use the previous results and trigger |
| 46 | * a new tallies inquiry command for next time - Jean II */ |
| 47 | /* FIXME: Really we should wait for the inquiry to come back - |
| 48 | * as it is the stats we give don't make a whole lot of sense. |
| 49 | * Unfortunately, it's not clear how to do that within the |
| 50 | * wireless extensions framework: I think we're in user |
| 51 | * context, but a lock seems to be held by the time we get in |
| 52 | * here so we're not safe to sleep here. */ |
| 53 | hermes_inquire(hw, HERMES_INQ_TALLIES); |
| 54 | |
David Kilroy | 5217c57 | 2009-06-18 23:21:32 +0100 | [diff] [blame] | 55 | if (priv->iw_mode == NL80211_IFTYPE_ADHOC) { |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 56 | memset(&wstats->qual, 0, sizeof(wstats->qual)); |
| 57 | /* If a spy address is defined, we report stats of the |
| 58 | * first spy address - Jean II */ |
| 59 | if (SPY_NUMBER(priv)) { |
| 60 | wstats->qual.qual = priv->spy_data.spy_stat[0].qual; |
| 61 | wstats->qual.level = priv->spy_data.spy_stat[0].level; |
| 62 | wstats->qual.noise = priv->spy_data.spy_stat[0].noise; |
| 63 | wstats->qual.updated = |
| 64 | priv->spy_data.spy_stat[0].updated; |
| 65 | } |
| 66 | } else { |
| 67 | struct { |
| 68 | __le16 qual, signal, noise, unused; |
| 69 | } __attribute__ ((packed)) cq; |
| 70 | |
| 71 | err = HERMES_READ_RECORD(hw, USER_BAP, |
| 72 | HERMES_RID_COMMSQUALITY, &cq); |
| 73 | |
| 74 | if (!err) { |
| 75 | wstats->qual.qual = (int)le16_to_cpu(cq.qual); |
| 76 | wstats->qual.level = (int)le16_to_cpu(cq.signal) - 0x95; |
| 77 | wstats->qual.noise = (int)le16_to_cpu(cq.noise) - 0x95; |
| 78 | wstats->qual.updated = |
| 79 | IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | orinoco_unlock(priv, &flags); |
| 84 | return wstats; |
| 85 | } |
| 86 | |
| 87 | /********************************************************************/ |
| 88 | /* Wireless extensions */ |
| 89 | /********************************************************************/ |
| 90 | |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 91 | static int orinoco_ioctl_setwap(struct net_device *dev, |
| 92 | struct iw_request_info *info, |
| 93 | struct sockaddr *ap_addr, |
| 94 | char *extra) |
| 95 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 96 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 97 | int err = -EINPROGRESS; /* Call commit handler */ |
| 98 | unsigned long flags; |
| 99 | static const u8 off_addr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
| 100 | static const u8 any_addr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
| 101 | |
| 102 | if (orinoco_lock(priv, &flags) != 0) |
| 103 | return -EBUSY; |
| 104 | |
| 105 | /* Enable automatic roaming - no sanity checks are needed */ |
| 106 | if (memcmp(&ap_addr->sa_data, off_addr, ETH_ALEN) == 0 || |
| 107 | memcmp(&ap_addr->sa_data, any_addr, ETH_ALEN) == 0) { |
| 108 | priv->bssid_fixed = 0; |
| 109 | memset(priv->desired_bssid, 0, ETH_ALEN); |
| 110 | |
| 111 | /* "off" means keep existing connection */ |
| 112 | if (ap_addr->sa_data[0] == 0) { |
| 113 | __orinoco_hw_set_wap(priv); |
| 114 | err = 0; |
| 115 | } |
| 116 | goto out; |
| 117 | } |
| 118 | |
| 119 | if (priv->firmware_type == FIRMWARE_TYPE_AGERE) { |
| 120 | printk(KERN_WARNING "%s: Lucent/Agere firmware doesn't " |
| 121 | "support manual roaming\n", |
| 122 | dev->name); |
| 123 | err = -EOPNOTSUPP; |
| 124 | goto out; |
| 125 | } |
| 126 | |
David Kilroy | 5217c57 | 2009-06-18 23:21:32 +0100 | [diff] [blame] | 127 | if (priv->iw_mode != NL80211_IFTYPE_STATION) { |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 128 | printk(KERN_WARNING "%s: Manual roaming supported only in " |
| 129 | "managed mode\n", dev->name); |
| 130 | err = -EOPNOTSUPP; |
| 131 | goto out; |
| 132 | } |
| 133 | |
| 134 | /* Intersil firmware hangs without Desired ESSID */ |
| 135 | if (priv->firmware_type == FIRMWARE_TYPE_INTERSIL && |
| 136 | strlen(priv->desired_essid) == 0) { |
| 137 | printk(KERN_WARNING "%s: Desired ESSID must be set for " |
| 138 | "manual roaming\n", dev->name); |
| 139 | err = -EOPNOTSUPP; |
| 140 | goto out; |
| 141 | } |
| 142 | |
| 143 | /* Finally, enable manual roaming */ |
| 144 | priv->bssid_fixed = 1; |
| 145 | memcpy(priv->desired_bssid, &ap_addr->sa_data, ETH_ALEN); |
| 146 | |
| 147 | out: |
| 148 | orinoco_unlock(priv, &flags); |
| 149 | return err; |
| 150 | } |
| 151 | |
| 152 | static int orinoco_ioctl_getwap(struct net_device *dev, |
| 153 | struct iw_request_info *info, |
| 154 | struct sockaddr *ap_addr, |
| 155 | char *extra) |
| 156 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 157 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 158 | |
| 159 | hermes_t *hw = &priv->hw; |
| 160 | int err = 0; |
| 161 | unsigned long flags; |
| 162 | |
| 163 | if (orinoco_lock(priv, &flags) != 0) |
| 164 | return -EBUSY; |
| 165 | |
| 166 | ap_addr->sa_family = ARPHRD_ETHER; |
| 167 | err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID, |
| 168 | ETH_ALEN, NULL, ap_addr->sa_data); |
| 169 | |
| 170 | orinoco_unlock(priv, &flags); |
| 171 | |
| 172 | return err; |
| 173 | } |
| 174 | |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 175 | static int orinoco_ioctl_setiwencode(struct net_device *dev, |
| 176 | struct iw_request_info *info, |
| 177 | struct iw_point *erq, |
| 178 | char *keybuf) |
| 179 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 180 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 181 | int index = (erq->flags & IW_ENCODE_INDEX) - 1; |
| 182 | int setindex = priv->tx_key; |
| 183 | int encode_alg = priv->encode_alg; |
| 184 | int restricted = priv->wep_restrict; |
| 185 | u16 xlen = 0; |
| 186 | int err = -EINPROGRESS; /* Call commit handler */ |
| 187 | unsigned long flags; |
| 188 | |
| 189 | if (!priv->has_wep) |
| 190 | return -EOPNOTSUPP; |
| 191 | |
| 192 | if (erq->pointer) { |
| 193 | /* We actually have a key to set - check its length */ |
| 194 | if (erq->length > LARGE_KEY_SIZE) |
| 195 | return -E2BIG; |
| 196 | |
| 197 | if ((erq->length > SMALL_KEY_SIZE) && !priv->has_big_wep) |
| 198 | return -E2BIG; |
| 199 | } |
| 200 | |
| 201 | if (orinoco_lock(priv, &flags) != 0) |
| 202 | return -EBUSY; |
| 203 | |
| 204 | /* Clear any TKIP key we have */ |
| 205 | if ((priv->has_wpa) && (priv->encode_alg == IW_ENCODE_ALG_TKIP)) |
| 206 | (void) orinoco_clear_tkip_key(priv, setindex); |
| 207 | |
| 208 | if (erq->length > 0) { |
| 209 | if ((index < 0) || (index >= ORINOCO_MAX_KEYS)) |
| 210 | index = priv->tx_key; |
| 211 | |
| 212 | /* Adjust key length to a supported value */ |
| 213 | if (erq->length > SMALL_KEY_SIZE) |
| 214 | xlen = LARGE_KEY_SIZE; |
| 215 | else if (erq->length > 0) |
| 216 | xlen = SMALL_KEY_SIZE; |
| 217 | else |
| 218 | xlen = 0; |
| 219 | |
| 220 | /* Switch on WEP if off */ |
| 221 | if ((encode_alg != IW_ENCODE_ALG_WEP) && (xlen > 0)) { |
| 222 | setindex = index; |
| 223 | encode_alg = IW_ENCODE_ALG_WEP; |
| 224 | } |
| 225 | } else { |
| 226 | /* Important note : if the user do "iwconfig eth0 enc off", |
| 227 | * we will arrive there with an index of -1. This is valid |
| 228 | * but need to be taken care off... Jean II */ |
| 229 | if ((index < 0) || (index >= ORINOCO_MAX_KEYS)) { |
| 230 | if ((index != -1) || (erq->flags == 0)) { |
| 231 | err = -EINVAL; |
| 232 | goto out; |
| 233 | } |
| 234 | } else { |
| 235 | /* Set the index : Check that the key is valid */ |
| 236 | if (priv->keys[index].len == 0) { |
| 237 | err = -EINVAL; |
| 238 | goto out; |
| 239 | } |
| 240 | setindex = index; |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | if (erq->flags & IW_ENCODE_DISABLED) |
| 245 | encode_alg = IW_ENCODE_ALG_NONE; |
| 246 | if (erq->flags & IW_ENCODE_OPEN) |
| 247 | restricted = 0; |
| 248 | if (erq->flags & IW_ENCODE_RESTRICTED) |
| 249 | restricted = 1; |
| 250 | |
| 251 | if (erq->pointer && erq->length > 0) { |
| 252 | priv->keys[index].len = cpu_to_le16(xlen); |
| 253 | memset(priv->keys[index].data, 0, |
| 254 | sizeof(priv->keys[index].data)); |
| 255 | memcpy(priv->keys[index].data, keybuf, erq->length); |
| 256 | } |
| 257 | priv->tx_key = setindex; |
| 258 | |
| 259 | /* Try fast key change if connected and only keys are changed */ |
| 260 | if ((priv->encode_alg == encode_alg) && |
| 261 | (priv->wep_restrict == restricted) && |
| 262 | netif_carrier_ok(dev)) { |
| 263 | err = __orinoco_hw_setup_wepkeys(priv); |
| 264 | /* No need to commit if successful */ |
| 265 | goto out; |
| 266 | } |
| 267 | |
| 268 | priv->encode_alg = encode_alg; |
| 269 | priv->wep_restrict = restricted; |
| 270 | |
| 271 | out: |
| 272 | orinoco_unlock(priv, &flags); |
| 273 | |
| 274 | return err; |
| 275 | } |
| 276 | |
| 277 | static int orinoco_ioctl_getiwencode(struct net_device *dev, |
| 278 | struct iw_request_info *info, |
| 279 | struct iw_point *erq, |
| 280 | char *keybuf) |
| 281 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 282 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 283 | int index = (erq->flags & IW_ENCODE_INDEX) - 1; |
| 284 | u16 xlen = 0; |
| 285 | unsigned long flags; |
| 286 | |
| 287 | if (!priv->has_wep) |
| 288 | return -EOPNOTSUPP; |
| 289 | |
| 290 | if (orinoco_lock(priv, &flags) != 0) |
| 291 | return -EBUSY; |
| 292 | |
| 293 | if ((index < 0) || (index >= ORINOCO_MAX_KEYS)) |
| 294 | index = priv->tx_key; |
| 295 | |
| 296 | erq->flags = 0; |
| 297 | if (!priv->encode_alg) |
| 298 | erq->flags |= IW_ENCODE_DISABLED; |
| 299 | erq->flags |= index + 1; |
| 300 | |
| 301 | if (priv->wep_restrict) |
| 302 | erq->flags |= IW_ENCODE_RESTRICTED; |
| 303 | else |
| 304 | erq->flags |= IW_ENCODE_OPEN; |
| 305 | |
| 306 | xlen = le16_to_cpu(priv->keys[index].len); |
| 307 | |
| 308 | erq->length = xlen; |
| 309 | |
| 310 | memcpy(keybuf, priv->keys[index].data, ORINOCO_MAX_KEY_SIZE); |
| 311 | |
| 312 | orinoco_unlock(priv, &flags); |
| 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | static int orinoco_ioctl_setessid(struct net_device *dev, |
| 317 | struct iw_request_info *info, |
| 318 | struct iw_point *erq, |
| 319 | char *essidbuf) |
| 320 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 321 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 322 | unsigned long flags; |
| 323 | |
| 324 | /* Note : ESSID is ignored in Ad-Hoc demo mode, but we can set it |
| 325 | * anyway... - Jean II */ |
| 326 | |
| 327 | /* Hum... Should not use Wireless Extension constant (may change), |
| 328 | * should use our own... - Jean II */ |
| 329 | if (erq->length > IW_ESSID_MAX_SIZE) |
| 330 | return -E2BIG; |
| 331 | |
| 332 | if (orinoco_lock(priv, &flags) != 0) |
| 333 | return -EBUSY; |
| 334 | |
| 335 | /* NULL the string (for NULL termination & ESSID = ANY) - Jean II */ |
| 336 | memset(priv->desired_essid, 0, sizeof(priv->desired_essid)); |
| 337 | |
| 338 | /* If not ANY, get the new ESSID */ |
| 339 | if (erq->flags) |
| 340 | memcpy(priv->desired_essid, essidbuf, erq->length); |
| 341 | |
| 342 | orinoco_unlock(priv, &flags); |
| 343 | |
| 344 | return -EINPROGRESS; /* Call commit handler */ |
| 345 | } |
| 346 | |
| 347 | static int orinoco_ioctl_getessid(struct net_device *dev, |
| 348 | struct iw_request_info *info, |
| 349 | struct iw_point *erq, |
| 350 | char *essidbuf) |
| 351 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 352 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 353 | int active; |
| 354 | int err = 0; |
| 355 | unsigned long flags; |
| 356 | |
| 357 | if (netif_running(dev)) { |
| 358 | err = orinoco_hw_get_essid(priv, &active, essidbuf); |
| 359 | if (err < 0) |
| 360 | return err; |
| 361 | erq->length = err; |
| 362 | } else { |
| 363 | if (orinoco_lock(priv, &flags) != 0) |
| 364 | return -EBUSY; |
| 365 | memcpy(essidbuf, priv->desired_essid, IW_ESSID_MAX_SIZE); |
| 366 | erq->length = strlen(priv->desired_essid); |
| 367 | orinoco_unlock(priv, &flags); |
| 368 | } |
| 369 | |
| 370 | erq->flags = 1; |
| 371 | |
| 372 | return 0; |
| 373 | } |
| 374 | |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 375 | static int orinoco_ioctl_setfreq(struct net_device *dev, |
| 376 | struct iw_request_info *info, |
| 377 | struct iw_freq *frq, |
| 378 | char *extra) |
| 379 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 380 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 381 | int chan = -1; |
| 382 | unsigned long flags; |
| 383 | int err = -EINPROGRESS; /* Call commit handler */ |
| 384 | |
| 385 | /* In infrastructure mode the AP sets the channel */ |
David Kilroy | 5217c57 | 2009-06-18 23:21:32 +0100 | [diff] [blame] | 386 | if (priv->iw_mode == NL80211_IFTYPE_STATION) |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 387 | return -EBUSY; |
| 388 | |
| 389 | if ((frq->e == 0) && (frq->m <= 1000)) { |
| 390 | /* Setting by channel number */ |
| 391 | chan = frq->m; |
| 392 | } else { |
| 393 | /* Setting by frequency */ |
| 394 | int denom = 1; |
| 395 | int i; |
| 396 | |
| 397 | /* Calculate denominator to rescale to MHz */ |
| 398 | for (i = 0; i < (6 - frq->e); i++) |
| 399 | denom *= 10; |
| 400 | |
| 401 | chan = ieee80211_freq_to_dsss_chan(frq->m / denom); |
| 402 | } |
| 403 | |
| 404 | if ((chan < 1) || (chan > NUM_CHANNELS) || |
| 405 | !(priv->channel_mask & (1 << (chan-1)))) |
| 406 | return -EINVAL; |
| 407 | |
| 408 | if (orinoco_lock(priv, &flags) != 0) |
| 409 | return -EBUSY; |
| 410 | |
| 411 | priv->channel = chan; |
David Kilroy | 5217c57 | 2009-06-18 23:21:32 +0100 | [diff] [blame] | 412 | if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 413 | /* Fast channel change - no commit if successful */ |
| 414 | hermes_t *hw = &priv->hw; |
| 415 | err = hermes_docmd_wait(hw, HERMES_CMD_TEST | |
| 416 | HERMES_TEST_SET_CHANNEL, |
| 417 | chan, NULL); |
| 418 | } |
| 419 | orinoco_unlock(priv, &flags); |
| 420 | |
| 421 | return err; |
| 422 | } |
| 423 | |
| 424 | static int orinoco_ioctl_getfreq(struct net_device *dev, |
| 425 | struct iw_request_info *info, |
| 426 | struct iw_freq *frq, |
| 427 | char *extra) |
| 428 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 429 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 430 | int tmp; |
| 431 | |
| 432 | /* Locking done in there */ |
| 433 | tmp = orinoco_hw_get_freq(priv); |
| 434 | if (tmp < 0) |
| 435 | return tmp; |
| 436 | |
| 437 | frq->m = tmp * 100000; |
| 438 | frq->e = 1; |
| 439 | |
| 440 | return 0; |
| 441 | } |
| 442 | |
| 443 | static int orinoco_ioctl_getsens(struct net_device *dev, |
| 444 | struct iw_request_info *info, |
| 445 | struct iw_param *srq, |
| 446 | char *extra) |
| 447 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 448 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 449 | hermes_t *hw = &priv->hw; |
| 450 | u16 val; |
| 451 | int err; |
| 452 | unsigned long flags; |
| 453 | |
| 454 | if (!priv->has_sensitivity) |
| 455 | return -EOPNOTSUPP; |
| 456 | |
| 457 | if (orinoco_lock(priv, &flags) != 0) |
| 458 | return -EBUSY; |
| 459 | err = hermes_read_wordrec(hw, USER_BAP, |
| 460 | HERMES_RID_CNFSYSTEMSCALE, &val); |
| 461 | orinoco_unlock(priv, &flags); |
| 462 | |
| 463 | if (err) |
| 464 | return err; |
| 465 | |
| 466 | srq->value = val; |
| 467 | srq->fixed = 0; /* auto */ |
| 468 | |
| 469 | return 0; |
| 470 | } |
| 471 | |
| 472 | static int orinoco_ioctl_setsens(struct net_device *dev, |
| 473 | struct iw_request_info *info, |
| 474 | struct iw_param *srq, |
| 475 | char *extra) |
| 476 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 477 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 478 | int val = srq->value; |
| 479 | unsigned long flags; |
| 480 | |
| 481 | if (!priv->has_sensitivity) |
| 482 | return -EOPNOTSUPP; |
| 483 | |
| 484 | if ((val < 1) || (val > 3)) |
| 485 | return -EINVAL; |
| 486 | |
| 487 | if (orinoco_lock(priv, &flags) != 0) |
| 488 | return -EBUSY; |
| 489 | priv->ap_density = val; |
| 490 | orinoco_unlock(priv, &flags); |
| 491 | |
| 492 | return -EINPROGRESS; /* Call commit handler */ |
| 493 | } |
| 494 | |
| 495 | static int orinoco_ioctl_setrts(struct net_device *dev, |
| 496 | struct iw_request_info *info, |
| 497 | struct iw_param *rrq, |
| 498 | char *extra) |
| 499 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 500 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 501 | int val = rrq->value; |
| 502 | unsigned long flags; |
| 503 | |
| 504 | if (rrq->disabled) |
| 505 | val = 2347; |
| 506 | |
| 507 | if ((val < 0) || (val > 2347)) |
| 508 | return -EINVAL; |
| 509 | |
| 510 | if (orinoco_lock(priv, &flags) != 0) |
| 511 | return -EBUSY; |
| 512 | |
| 513 | priv->rts_thresh = val; |
| 514 | orinoco_unlock(priv, &flags); |
| 515 | |
| 516 | return -EINPROGRESS; /* Call commit handler */ |
| 517 | } |
| 518 | |
| 519 | static int orinoco_ioctl_getrts(struct net_device *dev, |
| 520 | struct iw_request_info *info, |
| 521 | struct iw_param *rrq, |
| 522 | char *extra) |
| 523 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 524 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 525 | |
| 526 | rrq->value = priv->rts_thresh; |
| 527 | rrq->disabled = (rrq->value == 2347); |
| 528 | rrq->fixed = 1; |
| 529 | |
| 530 | return 0; |
| 531 | } |
| 532 | |
| 533 | static int orinoco_ioctl_setfrag(struct net_device *dev, |
| 534 | struct iw_request_info *info, |
| 535 | struct iw_param *frq, |
| 536 | char *extra) |
| 537 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 538 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 539 | int err = -EINPROGRESS; /* Call commit handler */ |
| 540 | unsigned long flags; |
| 541 | |
| 542 | if (orinoco_lock(priv, &flags) != 0) |
| 543 | return -EBUSY; |
| 544 | |
| 545 | if (priv->has_mwo) { |
| 546 | if (frq->disabled) |
| 547 | priv->mwo_robust = 0; |
| 548 | else { |
| 549 | if (frq->fixed) |
| 550 | printk(KERN_WARNING "%s: Fixed fragmentation " |
| 551 | "is not supported on this firmware. " |
| 552 | "Using MWO robust instead.\n", |
| 553 | dev->name); |
| 554 | priv->mwo_robust = 1; |
| 555 | } |
| 556 | } else { |
| 557 | if (frq->disabled) |
| 558 | priv->frag_thresh = 2346; |
| 559 | else { |
| 560 | if ((frq->value < 256) || (frq->value > 2346)) |
| 561 | err = -EINVAL; |
| 562 | else |
| 563 | /* must be even */ |
| 564 | priv->frag_thresh = frq->value & ~0x1; |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | orinoco_unlock(priv, &flags); |
| 569 | |
| 570 | return err; |
| 571 | } |
| 572 | |
| 573 | static int orinoco_ioctl_getfrag(struct net_device *dev, |
| 574 | struct iw_request_info *info, |
| 575 | struct iw_param *frq, |
| 576 | char *extra) |
| 577 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 578 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 579 | hermes_t *hw = &priv->hw; |
| 580 | int err; |
| 581 | u16 val; |
| 582 | unsigned long flags; |
| 583 | |
| 584 | if (orinoco_lock(priv, &flags) != 0) |
| 585 | return -EBUSY; |
| 586 | |
| 587 | if (priv->has_mwo) { |
| 588 | err = hermes_read_wordrec(hw, USER_BAP, |
| 589 | HERMES_RID_CNFMWOROBUST_AGERE, |
| 590 | &val); |
| 591 | if (err) |
| 592 | val = 0; |
| 593 | |
| 594 | frq->value = val ? 2347 : 0; |
| 595 | frq->disabled = !val; |
| 596 | frq->fixed = 0; |
| 597 | } else { |
| 598 | err = hermes_read_wordrec(hw, USER_BAP, |
| 599 | HERMES_RID_CNFFRAGMENTATIONTHRESHOLD, |
| 600 | &val); |
| 601 | if (err) |
| 602 | val = 0; |
| 603 | |
| 604 | frq->value = val; |
| 605 | frq->disabled = (val >= 2346); |
| 606 | frq->fixed = 1; |
| 607 | } |
| 608 | |
| 609 | orinoco_unlock(priv, &flags); |
| 610 | |
| 611 | return err; |
| 612 | } |
| 613 | |
| 614 | static int orinoco_ioctl_setrate(struct net_device *dev, |
| 615 | struct iw_request_info *info, |
| 616 | struct iw_param *rrq, |
| 617 | char *extra) |
| 618 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 619 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 620 | int ratemode; |
| 621 | int bitrate; /* 100s of kilobits */ |
| 622 | unsigned long flags; |
| 623 | |
| 624 | /* As the user space doesn't know our highest rate, it uses -1 |
| 625 | * to ask us to set the highest rate. Test it using "iwconfig |
| 626 | * ethX rate auto" - Jean II */ |
| 627 | if (rrq->value == -1) |
| 628 | bitrate = 110; |
| 629 | else { |
| 630 | if (rrq->value % 100000) |
| 631 | return -EINVAL; |
| 632 | bitrate = rrq->value / 100000; |
| 633 | } |
| 634 | |
| 635 | ratemode = orinoco_get_bitratemode(bitrate, !rrq->fixed); |
| 636 | |
| 637 | if (ratemode == -1) |
| 638 | return -EINVAL; |
| 639 | |
| 640 | if (orinoco_lock(priv, &flags) != 0) |
| 641 | return -EBUSY; |
| 642 | priv->bitratemode = ratemode; |
| 643 | orinoco_unlock(priv, &flags); |
| 644 | |
| 645 | return -EINPROGRESS; |
| 646 | } |
| 647 | |
| 648 | static int orinoco_ioctl_getrate(struct net_device *dev, |
| 649 | struct iw_request_info *info, |
| 650 | struct iw_param *rrq, |
| 651 | char *extra) |
| 652 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 653 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 654 | int err = 0; |
| 655 | int bitrate, automatic; |
| 656 | unsigned long flags; |
| 657 | |
| 658 | if (orinoco_lock(priv, &flags) != 0) |
| 659 | return -EBUSY; |
| 660 | |
| 661 | orinoco_get_ratemode_cfg(priv->bitratemode, &bitrate, &automatic); |
| 662 | |
| 663 | /* If the interface is running we try to find more about the |
| 664 | current mode */ |
| 665 | if (netif_running(dev)) |
| 666 | err = orinoco_hw_get_act_bitrate(priv, &bitrate); |
| 667 | |
| 668 | orinoco_unlock(priv, &flags); |
| 669 | |
| 670 | rrq->value = bitrate; |
| 671 | rrq->fixed = !automatic; |
| 672 | rrq->disabled = 0; |
| 673 | |
| 674 | return err; |
| 675 | } |
| 676 | |
| 677 | static int orinoco_ioctl_setpower(struct net_device *dev, |
| 678 | struct iw_request_info *info, |
| 679 | struct iw_param *prq, |
| 680 | char *extra) |
| 681 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 682 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 683 | int err = -EINPROGRESS; /* Call commit handler */ |
| 684 | unsigned long flags; |
| 685 | |
| 686 | if (orinoco_lock(priv, &flags) != 0) |
| 687 | return -EBUSY; |
| 688 | |
| 689 | if (prq->disabled) { |
| 690 | priv->pm_on = 0; |
| 691 | } else { |
| 692 | switch (prq->flags & IW_POWER_MODE) { |
| 693 | case IW_POWER_UNICAST_R: |
| 694 | priv->pm_mcast = 0; |
| 695 | priv->pm_on = 1; |
| 696 | break; |
| 697 | case IW_POWER_ALL_R: |
| 698 | priv->pm_mcast = 1; |
| 699 | priv->pm_on = 1; |
| 700 | break; |
| 701 | case IW_POWER_ON: |
| 702 | /* No flags : but we may have a value - Jean II */ |
| 703 | break; |
| 704 | default: |
| 705 | err = -EINVAL; |
| 706 | goto out; |
| 707 | } |
| 708 | |
| 709 | if (prq->flags & IW_POWER_TIMEOUT) { |
| 710 | priv->pm_on = 1; |
| 711 | priv->pm_timeout = prq->value / 1000; |
| 712 | } |
| 713 | if (prq->flags & IW_POWER_PERIOD) { |
| 714 | priv->pm_on = 1; |
| 715 | priv->pm_period = prq->value / 1000; |
| 716 | } |
| 717 | /* It's valid to not have a value if we are just toggling |
| 718 | * the flags... Jean II */ |
| 719 | if (!priv->pm_on) { |
| 720 | err = -EINVAL; |
| 721 | goto out; |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | out: |
| 726 | orinoco_unlock(priv, &flags); |
| 727 | |
| 728 | return err; |
| 729 | } |
| 730 | |
| 731 | static int orinoco_ioctl_getpower(struct net_device *dev, |
| 732 | struct iw_request_info *info, |
| 733 | struct iw_param *prq, |
| 734 | char *extra) |
| 735 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 736 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 737 | hermes_t *hw = &priv->hw; |
| 738 | int err = 0; |
| 739 | u16 enable, period, timeout, mcast; |
| 740 | unsigned long flags; |
| 741 | |
| 742 | if (orinoco_lock(priv, &flags) != 0) |
| 743 | return -EBUSY; |
| 744 | |
| 745 | err = hermes_read_wordrec(hw, USER_BAP, |
| 746 | HERMES_RID_CNFPMENABLED, &enable); |
| 747 | if (err) |
| 748 | goto out; |
| 749 | |
| 750 | err = hermes_read_wordrec(hw, USER_BAP, |
| 751 | HERMES_RID_CNFMAXSLEEPDURATION, &period); |
| 752 | if (err) |
| 753 | goto out; |
| 754 | |
| 755 | err = hermes_read_wordrec(hw, USER_BAP, |
| 756 | HERMES_RID_CNFPMHOLDOVERDURATION, &timeout); |
| 757 | if (err) |
| 758 | goto out; |
| 759 | |
| 760 | err = hermes_read_wordrec(hw, USER_BAP, |
| 761 | HERMES_RID_CNFMULTICASTRECEIVE, &mcast); |
| 762 | if (err) |
| 763 | goto out; |
| 764 | |
| 765 | prq->disabled = !enable; |
| 766 | /* Note : by default, display the period */ |
| 767 | if ((prq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { |
| 768 | prq->flags = IW_POWER_TIMEOUT; |
| 769 | prq->value = timeout * 1000; |
| 770 | } else { |
| 771 | prq->flags = IW_POWER_PERIOD; |
| 772 | prq->value = period * 1000; |
| 773 | } |
| 774 | if (mcast) |
| 775 | prq->flags |= IW_POWER_ALL_R; |
| 776 | else |
| 777 | prq->flags |= IW_POWER_UNICAST_R; |
| 778 | |
| 779 | out: |
| 780 | orinoco_unlock(priv, &flags); |
| 781 | |
| 782 | return err; |
| 783 | } |
| 784 | |
| 785 | static int orinoco_ioctl_set_encodeext(struct net_device *dev, |
| 786 | struct iw_request_info *info, |
| 787 | union iwreq_data *wrqu, |
| 788 | char *extra) |
| 789 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 790 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 791 | struct iw_point *encoding = &wrqu->encoding; |
| 792 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; |
| 793 | int idx, alg = ext->alg, set_key = 1; |
| 794 | unsigned long flags; |
| 795 | int err = -EINVAL; |
| 796 | u16 key_len; |
| 797 | |
| 798 | if (orinoco_lock(priv, &flags) != 0) |
| 799 | return -EBUSY; |
| 800 | |
| 801 | /* Determine and validate the key index */ |
| 802 | idx = encoding->flags & IW_ENCODE_INDEX; |
| 803 | if (idx) { |
| 804 | if ((idx < 1) || (idx > 4)) |
| 805 | goto out; |
| 806 | idx--; |
| 807 | } else |
| 808 | idx = priv->tx_key; |
| 809 | |
| 810 | if (encoding->flags & IW_ENCODE_DISABLED) |
| 811 | alg = IW_ENCODE_ALG_NONE; |
| 812 | |
| 813 | if (priv->has_wpa && (alg != IW_ENCODE_ALG_TKIP)) { |
| 814 | /* Clear any TKIP TX key we had */ |
| 815 | (void) orinoco_clear_tkip_key(priv, priv->tx_key); |
| 816 | } |
| 817 | |
| 818 | if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { |
| 819 | priv->tx_key = idx; |
| 820 | set_key = ((alg == IW_ENCODE_ALG_TKIP) || |
| 821 | (ext->key_len > 0)) ? 1 : 0; |
| 822 | } |
| 823 | |
| 824 | if (set_key) { |
| 825 | /* Set the requested key first */ |
| 826 | switch (alg) { |
| 827 | case IW_ENCODE_ALG_NONE: |
| 828 | priv->encode_alg = alg; |
| 829 | priv->keys[idx].len = 0; |
| 830 | break; |
| 831 | |
| 832 | case IW_ENCODE_ALG_WEP: |
| 833 | if (ext->key_len > SMALL_KEY_SIZE) |
| 834 | key_len = LARGE_KEY_SIZE; |
| 835 | else if (ext->key_len > 0) |
| 836 | key_len = SMALL_KEY_SIZE; |
| 837 | else |
| 838 | goto out; |
| 839 | |
| 840 | priv->encode_alg = alg; |
| 841 | priv->keys[idx].len = cpu_to_le16(key_len); |
| 842 | |
| 843 | key_len = min(ext->key_len, key_len); |
| 844 | |
| 845 | memset(priv->keys[idx].data, 0, ORINOCO_MAX_KEY_SIZE); |
| 846 | memcpy(priv->keys[idx].data, ext->key, key_len); |
| 847 | break; |
| 848 | |
| 849 | case IW_ENCODE_ALG_TKIP: |
| 850 | { |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 851 | u8 *tkip_iv = NULL; |
| 852 | |
| 853 | if (!priv->has_wpa || |
| 854 | (ext->key_len > sizeof(priv->tkip_key[0]))) |
| 855 | goto out; |
| 856 | |
| 857 | priv->encode_alg = alg; |
| 858 | memset(&priv->tkip_key[idx], 0, |
| 859 | sizeof(priv->tkip_key[idx])); |
| 860 | memcpy(&priv->tkip_key[idx], ext->key, ext->key_len); |
| 861 | |
| 862 | if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) |
| 863 | tkip_iv = &ext->rx_seq[0]; |
| 864 | |
David Kilroy | 98e5f40 | 2009-06-18 23:21:25 +0100 | [diff] [blame] | 865 | err = __orinoco_hw_set_tkip_key(priv, idx, |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 866 | ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY, |
| 867 | (u8 *) &priv->tkip_key[idx], |
| 868 | tkip_iv, NULL); |
| 869 | if (err) |
| 870 | printk(KERN_ERR "%s: Error %d setting TKIP key" |
| 871 | "\n", dev->name, err); |
| 872 | |
| 873 | goto out; |
| 874 | } |
| 875 | default: |
| 876 | goto out; |
| 877 | } |
| 878 | } |
| 879 | err = -EINPROGRESS; |
| 880 | out: |
| 881 | orinoco_unlock(priv, &flags); |
| 882 | |
| 883 | return err; |
| 884 | } |
| 885 | |
| 886 | static int orinoco_ioctl_get_encodeext(struct net_device *dev, |
| 887 | struct iw_request_info *info, |
| 888 | union iwreq_data *wrqu, |
| 889 | char *extra) |
| 890 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 891 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 892 | struct iw_point *encoding = &wrqu->encoding; |
| 893 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; |
| 894 | int idx, max_key_len; |
| 895 | unsigned long flags; |
| 896 | int err; |
| 897 | |
| 898 | if (orinoco_lock(priv, &flags) != 0) |
| 899 | return -EBUSY; |
| 900 | |
| 901 | err = -EINVAL; |
| 902 | max_key_len = encoding->length - sizeof(*ext); |
| 903 | if (max_key_len < 0) |
| 904 | goto out; |
| 905 | |
| 906 | idx = encoding->flags & IW_ENCODE_INDEX; |
| 907 | if (idx) { |
| 908 | if ((idx < 1) || (idx > 4)) |
| 909 | goto out; |
| 910 | idx--; |
| 911 | } else |
| 912 | idx = priv->tx_key; |
| 913 | |
| 914 | encoding->flags = idx + 1; |
| 915 | memset(ext, 0, sizeof(*ext)); |
| 916 | |
| 917 | ext->alg = priv->encode_alg; |
| 918 | switch (priv->encode_alg) { |
| 919 | case IW_ENCODE_ALG_NONE: |
| 920 | ext->key_len = 0; |
| 921 | encoding->flags |= IW_ENCODE_DISABLED; |
| 922 | break; |
| 923 | case IW_ENCODE_ALG_WEP: |
| 924 | ext->key_len = min_t(u16, le16_to_cpu(priv->keys[idx].len), |
| 925 | max_key_len); |
| 926 | memcpy(ext->key, priv->keys[idx].data, ext->key_len); |
| 927 | encoding->flags |= IW_ENCODE_ENABLED; |
| 928 | break; |
| 929 | case IW_ENCODE_ALG_TKIP: |
| 930 | ext->key_len = min_t(u16, sizeof(struct orinoco_tkip_key), |
| 931 | max_key_len); |
| 932 | memcpy(ext->key, &priv->tkip_key[idx], ext->key_len); |
| 933 | encoding->flags |= IW_ENCODE_ENABLED; |
| 934 | break; |
| 935 | } |
| 936 | |
| 937 | err = 0; |
| 938 | out: |
| 939 | orinoco_unlock(priv, &flags); |
| 940 | |
| 941 | return err; |
| 942 | } |
| 943 | |
| 944 | static int orinoco_ioctl_set_auth(struct net_device *dev, |
| 945 | struct iw_request_info *info, |
| 946 | union iwreq_data *wrqu, char *extra) |
| 947 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 948 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 949 | hermes_t *hw = &priv->hw; |
| 950 | struct iw_param *param = &wrqu->param; |
| 951 | unsigned long flags; |
| 952 | int ret = -EINPROGRESS; |
| 953 | |
| 954 | if (orinoco_lock(priv, &flags) != 0) |
| 955 | return -EBUSY; |
| 956 | |
| 957 | switch (param->flags & IW_AUTH_INDEX) { |
| 958 | case IW_AUTH_WPA_VERSION: |
| 959 | case IW_AUTH_CIPHER_PAIRWISE: |
| 960 | case IW_AUTH_CIPHER_GROUP: |
| 961 | case IW_AUTH_RX_UNENCRYPTED_EAPOL: |
| 962 | case IW_AUTH_PRIVACY_INVOKED: |
| 963 | case IW_AUTH_DROP_UNENCRYPTED: |
| 964 | /* |
| 965 | * orinoco does not use these parameters |
| 966 | */ |
| 967 | break; |
| 968 | |
| 969 | case IW_AUTH_KEY_MGMT: |
| 970 | /* wl_lkm implies value 2 == PSK for Hermes I |
| 971 | * which ties in with WEXT |
| 972 | * no other hints tho :( |
| 973 | */ |
| 974 | priv->key_mgmt = param->value; |
| 975 | break; |
| 976 | |
| 977 | case IW_AUTH_TKIP_COUNTERMEASURES: |
| 978 | /* When countermeasures are enabled, shut down the |
| 979 | * card; when disabled, re-enable the card. This must |
| 980 | * take effect immediately. |
| 981 | * |
| 982 | * TODO: Make sure that the EAPOL message is getting |
| 983 | * out before card disabled |
| 984 | */ |
| 985 | if (param->value) { |
| 986 | priv->tkip_cm_active = 1; |
| 987 | ret = hermes_enable_port(hw, 0); |
| 988 | } else { |
| 989 | priv->tkip_cm_active = 0; |
| 990 | ret = hermes_disable_port(hw, 0); |
| 991 | } |
| 992 | break; |
| 993 | |
| 994 | case IW_AUTH_80211_AUTH_ALG: |
| 995 | if (param->value & IW_AUTH_ALG_SHARED_KEY) |
| 996 | priv->wep_restrict = 1; |
| 997 | else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) |
| 998 | priv->wep_restrict = 0; |
| 999 | else |
| 1000 | ret = -EINVAL; |
| 1001 | break; |
| 1002 | |
| 1003 | case IW_AUTH_WPA_ENABLED: |
| 1004 | if (priv->has_wpa) { |
| 1005 | priv->wpa_enabled = param->value ? 1 : 0; |
| 1006 | } else { |
| 1007 | if (param->value) |
| 1008 | ret = -EOPNOTSUPP; |
| 1009 | /* else silently accept disable of WPA */ |
| 1010 | priv->wpa_enabled = 0; |
| 1011 | } |
| 1012 | break; |
| 1013 | |
| 1014 | default: |
| 1015 | ret = -EOPNOTSUPP; |
| 1016 | } |
| 1017 | |
| 1018 | orinoco_unlock(priv, &flags); |
| 1019 | return ret; |
| 1020 | } |
| 1021 | |
| 1022 | static int orinoco_ioctl_get_auth(struct net_device *dev, |
| 1023 | struct iw_request_info *info, |
| 1024 | union iwreq_data *wrqu, char *extra) |
| 1025 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1026 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1027 | struct iw_param *param = &wrqu->param; |
| 1028 | unsigned long flags; |
| 1029 | int ret = 0; |
| 1030 | |
| 1031 | if (orinoco_lock(priv, &flags) != 0) |
| 1032 | return -EBUSY; |
| 1033 | |
| 1034 | switch (param->flags & IW_AUTH_INDEX) { |
| 1035 | case IW_AUTH_KEY_MGMT: |
| 1036 | param->value = priv->key_mgmt; |
| 1037 | break; |
| 1038 | |
| 1039 | case IW_AUTH_TKIP_COUNTERMEASURES: |
| 1040 | param->value = priv->tkip_cm_active; |
| 1041 | break; |
| 1042 | |
| 1043 | case IW_AUTH_80211_AUTH_ALG: |
| 1044 | if (priv->wep_restrict) |
| 1045 | param->value = IW_AUTH_ALG_SHARED_KEY; |
| 1046 | else |
| 1047 | param->value = IW_AUTH_ALG_OPEN_SYSTEM; |
| 1048 | break; |
| 1049 | |
| 1050 | case IW_AUTH_WPA_ENABLED: |
| 1051 | param->value = priv->wpa_enabled; |
| 1052 | break; |
| 1053 | |
| 1054 | default: |
| 1055 | ret = -EOPNOTSUPP; |
| 1056 | } |
| 1057 | |
| 1058 | orinoco_unlock(priv, &flags); |
| 1059 | return ret; |
| 1060 | } |
| 1061 | |
| 1062 | static int orinoco_ioctl_set_genie(struct net_device *dev, |
| 1063 | struct iw_request_info *info, |
| 1064 | union iwreq_data *wrqu, char *extra) |
| 1065 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1066 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1067 | u8 *buf; |
| 1068 | unsigned long flags; |
| 1069 | |
| 1070 | /* cut off at IEEE80211_MAX_DATA_LEN */ |
| 1071 | if ((wrqu->data.length > IEEE80211_MAX_DATA_LEN) || |
| 1072 | (wrqu->data.length && (extra == NULL))) |
| 1073 | return -EINVAL; |
| 1074 | |
| 1075 | if (wrqu->data.length) { |
| 1076 | buf = kmalloc(wrqu->data.length, GFP_KERNEL); |
| 1077 | if (buf == NULL) |
| 1078 | return -ENOMEM; |
| 1079 | |
| 1080 | memcpy(buf, extra, wrqu->data.length); |
| 1081 | } else |
| 1082 | buf = NULL; |
| 1083 | |
| 1084 | if (orinoco_lock(priv, &flags) != 0) { |
| 1085 | kfree(buf); |
| 1086 | return -EBUSY; |
| 1087 | } |
| 1088 | |
| 1089 | kfree(priv->wpa_ie); |
| 1090 | priv->wpa_ie = buf; |
| 1091 | priv->wpa_ie_len = wrqu->data.length; |
| 1092 | |
| 1093 | if (priv->wpa_ie) { |
| 1094 | /* Looks like wl_lkm wants to check the auth alg, and |
| 1095 | * somehow pass it to the firmware. |
| 1096 | * Instead it just calls the key mgmt rid |
| 1097 | * - we do this in set auth. |
| 1098 | */ |
| 1099 | } |
| 1100 | |
| 1101 | orinoco_unlock(priv, &flags); |
| 1102 | return 0; |
| 1103 | } |
| 1104 | |
| 1105 | static int orinoco_ioctl_get_genie(struct net_device *dev, |
| 1106 | struct iw_request_info *info, |
| 1107 | union iwreq_data *wrqu, char *extra) |
| 1108 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1109 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1110 | unsigned long flags; |
| 1111 | int err = 0; |
| 1112 | |
| 1113 | if (orinoco_lock(priv, &flags) != 0) |
| 1114 | return -EBUSY; |
| 1115 | |
| 1116 | if ((priv->wpa_ie_len == 0) || (priv->wpa_ie == NULL)) { |
| 1117 | wrqu->data.length = 0; |
| 1118 | goto out; |
| 1119 | } |
| 1120 | |
| 1121 | if (wrqu->data.length < priv->wpa_ie_len) { |
| 1122 | err = -E2BIG; |
| 1123 | goto out; |
| 1124 | } |
| 1125 | |
| 1126 | wrqu->data.length = priv->wpa_ie_len; |
| 1127 | memcpy(extra, priv->wpa_ie, priv->wpa_ie_len); |
| 1128 | |
| 1129 | out: |
| 1130 | orinoco_unlock(priv, &flags); |
| 1131 | return err; |
| 1132 | } |
| 1133 | |
| 1134 | static int orinoco_ioctl_set_mlme(struct net_device *dev, |
| 1135 | struct iw_request_info *info, |
| 1136 | union iwreq_data *wrqu, char *extra) |
| 1137 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1138 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1139 | hermes_t *hw = &priv->hw; |
| 1140 | struct iw_mlme *mlme = (struct iw_mlme *)extra; |
| 1141 | unsigned long flags; |
| 1142 | int ret = 0; |
| 1143 | |
| 1144 | if (orinoco_lock(priv, &flags) != 0) |
| 1145 | return -EBUSY; |
| 1146 | |
| 1147 | switch (mlme->cmd) { |
| 1148 | case IW_MLME_DEAUTH: |
| 1149 | /* silently ignore */ |
| 1150 | break; |
| 1151 | |
| 1152 | case IW_MLME_DISASSOC: |
| 1153 | { |
| 1154 | struct { |
| 1155 | u8 addr[ETH_ALEN]; |
| 1156 | __le16 reason_code; |
| 1157 | } __attribute__ ((packed)) buf; |
| 1158 | |
| 1159 | memcpy(buf.addr, mlme->addr.sa_data, ETH_ALEN); |
| 1160 | buf.reason_code = cpu_to_le16(mlme->reason_code); |
| 1161 | ret = HERMES_WRITE_RECORD(hw, USER_BAP, |
| 1162 | HERMES_RID_CNFDISASSOCIATE, |
| 1163 | &buf); |
| 1164 | break; |
| 1165 | } |
| 1166 | default: |
| 1167 | ret = -EOPNOTSUPP; |
| 1168 | } |
| 1169 | |
| 1170 | orinoco_unlock(priv, &flags); |
| 1171 | return ret; |
| 1172 | } |
| 1173 | |
| 1174 | static int orinoco_ioctl_getretry(struct net_device *dev, |
| 1175 | struct iw_request_info *info, |
| 1176 | struct iw_param *rrq, |
| 1177 | char *extra) |
| 1178 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1179 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1180 | hermes_t *hw = &priv->hw; |
| 1181 | int err = 0; |
| 1182 | u16 short_limit, long_limit, lifetime; |
| 1183 | unsigned long flags; |
| 1184 | |
| 1185 | if (orinoco_lock(priv, &flags) != 0) |
| 1186 | return -EBUSY; |
| 1187 | |
| 1188 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_SHORTRETRYLIMIT, |
| 1189 | &short_limit); |
| 1190 | if (err) |
| 1191 | goto out; |
| 1192 | |
| 1193 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_LONGRETRYLIMIT, |
| 1194 | &long_limit); |
| 1195 | if (err) |
| 1196 | goto out; |
| 1197 | |
| 1198 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_MAXTRANSMITLIFETIME, |
| 1199 | &lifetime); |
| 1200 | if (err) |
| 1201 | goto out; |
| 1202 | |
| 1203 | rrq->disabled = 0; /* Can't be disabled */ |
| 1204 | |
| 1205 | /* Note : by default, display the retry number */ |
| 1206 | if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { |
| 1207 | rrq->flags = IW_RETRY_LIFETIME; |
| 1208 | rrq->value = lifetime * 1000; /* ??? */ |
| 1209 | } else { |
| 1210 | /* By default, display the min number */ |
| 1211 | if ((rrq->flags & IW_RETRY_LONG)) { |
| 1212 | rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; |
| 1213 | rrq->value = long_limit; |
| 1214 | } else { |
| 1215 | rrq->flags = IW_RETRY_LIMIT; |
| 1216 | rrq->value = short_limit; |
| 1217 | if (short_limit != long_limit) |
| 1218 | rrq->flags |= IW_RETRY_SHORT; |
| 1219 | } |
| 1220 | } |
| 1221 | |
| 1222 | out: |
| 1223 | orinoco_unlock(priv, &flags); |
| 1224 | |
| 1225 | return err; |
| 1226 | } |
| 1227 | |
| 1228 | static int orinoco_ioctl_reset(struct net_device *dev, |
| 1229 | struct iw_request_info *info, |
| 1230 | void *wrqu, |
| 1231 | char *extra) |
| 1232 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1233 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1234 | |
| 1235 | if (!capable(CAP_NET_ADMIN)) |
| 1236 | return -EPERM; |
| 1237 | |
| 1238 | if (info->cmd == (SIOCIWFIRSTPRIV + 0x1)) { |
| 1239 | printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name); |
| 1240 | |
| 1241 | /* Firmware reset */ |
| 1242 | orinoco_reset(&priv->reset_work); |
| 1243 | } else { |
| 1244 | printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name); |
| 1245 | |
| 1246 | schedule_work(&priv->reset_work); |
| 1247 | } |
| 1248 | |
| 1249 | return 0; |
| 1250 | } |
| 1251 | |
| 1252 | static int orinoco_ioctl_setibssport(struct net_device *dev, |
| 1253 | struct iw_request_info *info, |
| 1254 | void *wrqu, |
| 1255 | char *extra) |
| 1256 | |
| 1257 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1258 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1259 | int val = *((int *) extra); |
| 1260 | unsigned long flags; |
| 1261 | |
| 1262 | if (orinoco_lock(priv, &flags) != 0) |
| 1263 | return -EBUSY; |
| 1264 | |
| 1265 | priv->ibss_port = val ; |
| 1266 | |
| 1267 | /* Actually update the mode we are using */ |
| 1268 | set_port_type(priv); |
| 1269 | |
| 1270 | orinoco_unlock(priv, &flags); |
| 1271 | return -EINPROGRESS; /* Call commit handler */ |
| 1272 | } |
| 1273 | |
| 1274 | static int orinoco_ioctl_getibssport(struct net_device *dev, |
| 1275 | struct iw_request_info *info, |
| 1276 | void *wrqu, |
| 1277 | char *extra) |
| 1278 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1279 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1280 | int *val = (int *) extra; |
| 1281 | |
| 1282 | *val = priv->ibss_port; |
| 1283 | return 0; |
| 1284 | } |
| 1285 | |
| 1286 | static int orinoco_ioctl_setport3(struct net_device *dev, |
| 1287 | struct iw_request_info *info, |
| 1288 | void *wrqu, |
| 1289 | char *extra) |
| 1290 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1291 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1292 | int val = *((int *) extra); |
| 1293 | int err = 0; |
| 1294 | unsigned long flags; |
| 1295 | |
| 1296 | if (orinoco_lock(priv, &flags) != 0) |
| 1297 | return -EBUSY; |
| 1298 | |
| 1299 | switch (val) { |
| 1300 | case 0: /* Try to do IEEE ad-hoc mode */ |
| 1301 | if (!priv->has_ibss) { |
| 1302 | err = -EINVAL; |
| 1303 | break; |
| 1304 | } |
| 1305 | priv->prefer_port3 = 0; |
| 1306 | |
| 1307 | break; |
| 1308 | |
| 1309 | case 1: /* Try to do Lucent proprietary ad-hoc mode */ |
| 1310 | if (!priv->has_port3) { |
| 1311 | err = -EINVAL; |
| 1312 | break; |
| 1313 | } |
| 1314 | priv->prefer_port3 = 1; |
| 1315 | break; |
| 1316 | |
| 1317 | default: |
| 1318 | err = -EINVAL; |
| 1319 | } |
| 1320 | |
| 1321 | if (!err) { |
| 1322 | /* Actually update the mode we are using */ |
| 1323 | set_port_type(priv); |
| 1324 | err = -EINPROGRESS; |
| 1325 | } |
| 1326 | |
| 1327 | orinoco_unlock(priv, &flags); |
| 1328 | |
| 1329 | return err; |
| 1330 | } |
| 1331 | |
| 1332 | static int orinoco_ioctl_getport3(struct net_device *dev, |
| 1333 | struct iw_request_info *info, |
| 1334 | void *wrqu, |
| 1335 | char *extra) |
| 1336 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1337 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1338 | int *val = (int *) extra; |
| 1339 | |
| 1340 | *val = priv->prefer_port3; |
| 1341 | return 0; |
| 1342 | } |
| 1343 | |
| 1344 | static int orinoco_ioctl_setpreamble(struct net_device *dev, |
| 1345 | struct iw_request_info *info, |
| 1346 | void *wrqu, |
| 1347 | char *extra) |
| 1348 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1349 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1350 | unsigned long flags; |
| 1351 | int val; |
| 1352 | |
| 1353 | if (!priv->has_preamble) |
| 1354 | return -EOPNOTSUPP; |
| 1355 | |
| 1356 | /* 802.11b has recently defined some short preamble. |
| 1357 | * Basically, the Phy header has been reduced in size. |
| 1358 | * This increase performance, especially at high rates |
| 1359 | * (the preamble is transmitted at 1Mb/s), unfortunately |
| 1360 | * this give compatibility troubles... - Jean II */ |
| 1361 | val = *((int *) extra); |
| 1362 | |
| 1363 | if (orinoco_lock(priv, &flags) != 0) |
| 1364 | return -EBUSY; |
| 1365 | |
| 1366 | if (val) |
| 1367 | priv->preamble = 1; |
| 1368 | else |
| 1369 | priv->preamble = 0; |
| 1370 | |
| 1371 | orinoco_unlock(priv, &flags); |
| 1372 | |
| 1373 | return -EINPROGRESS; /* Call commit handler */ |
| 1374 | } |
| 1375 | |
| 1376 | static int orinoco_ioctl_getpreamble(struct net_device *dev, |
| 1377 | struct iw_request_info *info, |
| 1378 | void *wrqu, |
| 1379 | char *extra) |
| 1380 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1381 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1382 | int *val = (int *) extra; |
| 1383 | |
| 1384 | if (!priv->has_preamble) |
| 1385 | return -EOPNOTSUPP; |
| 1386 | |
| 1387 | *val = priv->preamble; |
| 1388 | return 0; |
| 1389 | } |
| 1390 | |
| 1391 | /* ioctl interface to hermes_read_ltv() |
| 1392 | * To use with iwpriv, pass the RID as the token argument, e.g. |
| 1393 | * iwpriv get_rid [0xfc00] |
| 1394 | * At least Wireless Tools 25 is required to use iwpriv. |
| 1395 | * For Wireless Tools 25 and 26 append "dummy" are the end. */ |
| 1396 | static int orinoco_ioctl_getrid(struct net_device *dev, |
| 1397 | struct iw_request_info *info, |
| 1398 | struct iw_point *data, |
| 1399 | char *extra) |
| 1400 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1401 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1402 | hermes_t *hw = &priv->hw; |
| 1403 | int rid = data->flags; |
| 1404 | u16 length; |
| 1405 | int err; |
| 1406 | unsigned long flags; |
| 1407 | |
| 1408 | /* It's a "get" function, but we don't want users to access the |
| 1409 | * WEP key and other raw firmware data */ |
| 1410 | if (!capable(CAP_NET_ADMIN)) |
| 1411 | return -EPERM; |
| 1412 | |
| 1413 | if (rid < 0xfc00 || rid > 0xffff) |
| 1414 | return -EINVAL; |
| 1415 | |
| 1416 | if (orinoco_lock(priv, &flags) != 0) |
| 1417 | return -EBUSY; |
| 1418 | |
| 1419 | err = hermes_read_ltv(hw, USER_BAP, rid, MAX_RID_LEN, &length, |
| 1420 | extra); |
| 1421 | if (err) |
| 1422 | goto out; |
| 1423 | |
| 1424 | data->length = min_t(u16, HERMES_RECLEN_TO_BYTES(length), |
| 1425 | MAX_RID_LEN); |
| 1426 | |
| 1427 | out: |
| 1428 | orinoco_unlock(priv, &flags); |
| 1429 | return err; |
| 1430 | } |
| 1431 | |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1432 | |
| 1433 | /* Commit handler, called after set operations */ |
| 1434 | static int orinoco_ioctl_commit(struct net_device *dev, |
| 1435 | struct iw_request_info *info, |
| 1436 | void *wrqu, |
| 1437 | char *extra) |
| 1438 | { |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1439 | struct orinoco_private *priv = ndev_priv(dev); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1440 | unsigned long flags; |
| 1441 | int err = 0; |
| 1442 | |
| 1443 | if (!priv->open) |
| 1444 | return 0; |
| 1445 | |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1446 | if (orinoco_lock(priv, &flags) != 0) |
| 1447 | return err; |
| 1448 | |
David Kilroy | 721aa2f | 2009-06-18 23:21:31 +0100 | [diff] [blame] | 1449 | err = orinoco_commit(priv); |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1450 | |
| 1451 | orinoco_unlock(priv, &flags); |
| 1452 | return err; |
| 1453 | } |
| 1454 | |
| 1455 | static const struct iw_priv_args orinoco_privtab[] = { |
| 1456 | { SIOCIWFIRSTPRIV + 0x0, 0, 0, "force_reset" }, |
| 1457 | { SIOCIWFIRSTPRIV + 0x1, 0, 0, "card_reset" }, |
| 1458 | { SIOCIWFIRSTPRIV + 0x2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 1459 | 0, "set_port3" }, |
| 1460 | { SIOCIWFIRSTPRIV + 0x3, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 1461 | "get_port3" }, |
| 1462 | { SIOCIWFIRSTPRIV + 0x4, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 1463 | 0, "set_preamble" }, |
| 1464 | { SIOCIWFIRSTPRIV + 0x5, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 1465 | "get_preamble" }, |
| 1466 | { SIOCIWFIRSTPRIV + 0x6, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 1467 | 0, "set_ibssport" }, |
| 1468 | { SIOCIWFIRSTPRIV + 0x7, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
| 1469 | "get_ibssport" }, |
| 1470 | { SIOCIWFIRSTPRIV + 0x9, 0, IW_PRIV_TYPE_BYTE | MAX_RID_LEN, |
| 1471 | "get_rid" }, |
| 1472 | }; |
| 1473 | |
| 1474 | |
| 1475 | /* |
| 1476 | * Structures to export the Wireless Handlers |
| 1477 | */ |
| 1478 | |
| 1479 | #define STD_IW_HANDLER(id, func) \ |
| 1480 | [IW_IOCTL_IDX(id)] = (iw_handler) func |
| 1481 | static const iw_handler orinoco_handler[] = { |
| 1482 | STD_IW_HANDLER(SIOCSIWCOMMIT, orinoco_ioctl_commit), |
David Kilroy | ea60a6a | 2009-06-18 23:21:26 +0100 | [diff] [blame] | 1483 | STD_IW_HANDLER(SIOCGIWNAME, cfg80211_wext_giwname), |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1484 | STD_IW_HANDLER(SIOCSIWFREQ, orinoco_ioctl_setfreq), |
| 1485 | STD_IW_HANDLER(SIOCGIWFREQ, orinoco_ioctl_getfreq), |
David Kilroy | 5217c57 | 2009-06-18 23:21:32 +0100 | [diff] [blame] | 1486 | STD_IW_HANDLER(SIOCSIWMODE, cfg80211_wext_siwmode), |
| 1487 | STD_IW_HANDLER(SIOCGIWMODE, cfg80211_wext_giwmode), |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1488 | STD_IW_HANDLER(SIOCSIWSENS, orinoco_ioctl_setsens), |
| 1489 | STD_IW_HANDLER(SIOCGIWSENS, orinoco_ioctl_getsens), |
David Kilroy | 934fd51 | 2009-06-18 23:21:34 +0100 | [diff] [blame] | 1490 | STD_IW_HANDLER(SIOCGIWRANGE, cfg80211_wext_giwrange), |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1491 | STD_IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy), |
| 1492 | STD_IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy), |
| 1493 | STD_IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy), |
| 1494 | STD_IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy), |
| 1495 | STD_IW_HANDLER(SIOCSIWAP, orinoco_ioctl_setwap), |
| 1496 | STD_IW_HANDLER(SIOCGIWAP, orinoco_ioctl_getwap), |
David Kilroy | c63cdbe | 2009-06-18 23:21:33 +0100 | [diff] [blame] | 1497 | STD_IW_HANDLER(SIOCSIWSCAN, cfg80211_wext_siwscan), |
| 1498 | STD_IW_HANDLER(SIOCGIWSCAN, cfg80211_wext_giwscan), |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1499 | STD_IW_HANDLER(SIOCSIWESSID, orinoco_ioctl_setessid), |
| 1500 | STD_IW_HANDLER(SIOCGIWESSID, orinoco_ioctl_getessid), |
David Kilroy | cb1576a | 2009-02-04 23:05:56 +0000 | [diff] [blame] | 1501 | STD_IW_HANDLER(SIOCSIWRATE, orinoco_ioctl_setrate), |
| 1502 | STD_IW_HANDLER(SIOCGIWRATE, orinoco_ioctl_getrate), |
| 1503 | STD_IW_HANDLER(SIOCSIWRTS, orinoco_ioctl_setrts), |
| 1504 | STD_IW_HANDLER(SIOCGIWRTS, orinoco_ioctl_getrts), |
| 1505 | STD_IW_HANDLER(SIOCSIWFRAG, orinoco_ioctl_setfrag), |
| 1506 | STD_IW_HANDLER(SIOCGIWFRAG, orinoco_ioctl_getfrag), |
| 1507 | STD_IW_HANDLER(SIOCGIWRETRY, orinoco_ioctl_getretry), |
| 1508 | STD_IW_HANDLER(SIOCSIWENCODE, orinoco_ioctl_setiwencode), |
| 1509 | STD_IW_HANDLER(SIOCGIWENCODE, orinoco_ioctl_getiwencode), |
| 1510 | STD_IW_HANDLER(SIOCSIWPOWER, orinoco_ioctl_setpower), |
| 1511 | STD_IW_HANDLER(SIOCGIWPOWER, orinoco_ioctl_getpower), |
| 1512 | STD_IW_HANDLER(SIOCSIWGENIE, orinoco_ioctl_set_genie), |
| 1513 | STD_IW_HANDLER(SIOCGIWGENIE, orinoco_ioctl_get_genie), |
| 1514 | STD_IW_HANDLER(SIOCSIWMLME, orinoco_ioctl_set_mlme), |
| 1515 | STD_IW_HANDLER(SIOCSIWAUTH, orinoco_ioctl_set_auth), |
| 1516 | STD_IW_HANDLER(SIOCGIWAUTH, orinoco_ioctl_get_auth), |
| 1517 | STD_IW_HANDLER(SIOCSIWENCODEEXT, orinoco_ioctl_set_encodeext), |
| 1518 | STD_IW_HANDLER(SIOCGIWENCODEEXT, orinoco_ioctl_get_encodeext), |
| 1519 | }; |
| 1520 | |
| 1521 | |
| 1522 | /* |
| 1523 | Added typecasting since we no longer use iwreq_data -- Moustafa |
| 1524 | */ |
| 1525 | static const iw_handler orinoco_private_handler[] = { |
| 1526 | [0] = (iw_handler) orinoco_ioctl_reset, |
| 1527 | [1] = (iw_handler) orinoco_ioctl_reset, |
| 1528 | [2] = (iw_handler) orinoco_ioctl_setport3, |
| 1529 | [3] = (iw_handler) orinoco_ioctl_getport3, |
| 1530 | [4] = (iw_handler) orinoco_ioctl_setpreamble, |
| 1531 | [5] = (iw_handler) orinoco_ioctl_getpreamble, |
| 1532 | [6] = (iw_handler) orinoco_ioctl_setibssport, |
| 1533 | [7] = (iw_handler) orinoco_ioctl_getibssport, |
| 1534 | [9] = (iw_handler) orinoco_ioctl_getrid, |
| 1535 | }; |
| 1536 | |
| 1537 | const struct iw_handler_def orinoco_handler_def = { |
| 1538 | .num_standard = ARRAY_SIZE(orinoco_handler), |
| 1539 | .num_private = ARRAY_SIZE(orinoco_private_handler), |
| 1540 | .num_private_args = ARRAY_SIZE(orinoco_privtab), |
| 1541 | .standard = orinoco_handler, |
| 1542 | .private = orinoco_private_handler, |
| 1543 | .private_args = orinoco_privtab, |
| 1544 | .get_wireless_stats = orinoco_get_wireless_stats, |
| 1545 | }; |