wext.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398
  1. /* Wireless extensions support.
  2. *
  3. * See copyright notice in main.c
  4. */
  5. #include <linux/slab.h>
  6. #include <linux/kernel.h>
  7. #include <linux/if_arp.h>
  8. #include <linux/wireless.h>
  9. #include <linux/ieee80211.h>
  10. #include <net/iw_handler.h>
  11. #include <net/cfg80211.h>
  12. #include "hermes.h"
  13. #include "hermes_rid.h"
  14. #include "orinoco.h"
  15. #include "hw.h"
  16. #include "mic.h"
  17. #include "scan.h"
  18. #include "main.h"
  19. #include "wext.h"
  20. #define MAX_RID_LEN 1024
  21. /* Helper routine to record keys
  22. * It is called under orinoco_lock so it may not sleep */
  23. static int orinoco_set_key(struct orinoco_private *priv, int index,
  24. enum orinoco_alg alg, const u8 *key, int key_len,
  25. const u8 *seq, int seq_len)
  26. {
  27. kzfree(priv->keys[index].key);
  28. kzfree(priv->keys[index].seq);
  29. if (key_len) {
  30. priv->keys[index].key = kzalloc(key_len, GFP_ATOMIC);
  31. if (!priv->keys[index].key)
  32. goto nomem;
  33. } else
  34. priv->keys[index].key = NULL;
  35. if (seq_len) {
  36. priv->keys[index].seq = kzalloc(seq_len, GFP_ATOMIC);
  37. if (!priv->keys[index].seq)
  38. goto free_key;
  39. } else
  40. priv->keys[index].seq = NULL;
  41. priv->keys[index].key_len = key_len;
  42. priv->keys[index].seq_len = seq_len;
  43. if (key_len)
  44. memcpy(priv->keys[index].key, key, key_len);
  45. if (seq_len)
  46. memcpy(priv->keys[index].seq, seq, seq_len);
  47. switch (alg) {
  48. case ORINOCO_ALG_TKIP:
  49. priv->keys[index].cipher = WLAN_CIPHER_SUITE_TKIP;
  50. break;
  51. case ORINOCO_ALG_WEP:
  52. priv->keys[index].cipher = (key_len > SMALL_KEY_SIZE) ?
  53. WLAN_CIPHER_SUITE_WEP104 : WLAN_CIPHER_SUITE_WEP40;
  54. break;
  55. case ORINOCO_ALG_NONE:
  56. default:
  57. priv->keys[index].cipher = 0;
  58. break;
  59. }
  60. return 0;
  61. free_key:
  62. kfree(priv->keys[index].key);
  63. priv->keys[index].key = NULL;
  64. nomem:
  65. priv->keys[index].key_len = 0;
  66. priv->keys[index].seq_len = 0;
  67. priv->keys[index].cipher = 0;
  68. return -ENOMEM;
  69. }
  70. static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev)
  71. {
  72. struct orinoco_private *priv = ndev_priv(dev);
  73. hermes_t *hw = &priv->hw;
  74. struct iw_statistics *wstats = &priv->wstats;
  75. int err;
  76. unsigned long flags;
  77. if (!netif_device_present(dev)) {
  78. printk(KERN_WARNING "%s: get_wireless_stats() called while device not present\n",
  79. dev->name);
  80. return NULL; /* FIXME: Can we do better than this? */
  81. }
  82. /* If busy, return the old stats. Returning NULL may cause
  83. * the interface to disappear from /proc/net/wireless */
  84. if (orinoco_lock(priv, &flags) != 0)
  85. return wstats;
  86. /* We can't really wait for the tallies inquiry command to
  87. * complete, so we just use the previous results and trigger
  88. * a new tallies inquiry command for next time - Jean II */
  89. /* FIXME: Really we should wait for the inquiry to come back -
  90. * as it is the stats we give don't make a whole lot of sense.
  91. * Unfortunately, it's not clear how to do that within the
  92. * wireless extensions framework: I think we're in user
  93. * context, but a lock seems to be held by the time we get in
  94. * here so we're not safe to sleep here. */
  95. hermes_inquire(hw, HERMES_INQ_TALLIES);
  96. if (priv->iw_mode == NL80211_IFTYPE_ADHOC) {
  97. memset(&wstats->qual, 0, sizeof(wstats->qual));
  98. /* If a spy address is defined, we report stats of the
  99. * first spy address - Jean II */
  100. if (SPY_NUMBER(priv)) {
  101. wstats->qual.qual = priv->spy_data.spy_stat[0].qual;
  102. wstats->qual.level = priv->spy_data.spy_stat[0].level;
  103. wstats->qual.noise = priv->spy_data.spy_stat[0].noise;
  104. wstats->qual.updated =
  105. priv->spy_data.spy_stat[0].updated;
  106. }
  107. } else {
  108. struct {
  109. __le16 qual, signal, noise, unused;
  110. } __packed cq;
  111. err = HERMES_READ_RECORD(hw, USER_BAP,
  112. HERMES_RID_COMMSQUALITY, &cq);
  113. if (!err) {
  114. wstats->qual.qual = (int)le16_to_cpu(cq.qual);
  115. wstats->qual.level = (int)le16_to_cpu(cq.signal) - 0x95;
  116. wstats->qual.noise = (int)le16_to_cpu(cq.noise) - 0x95;
  117. wstats->qual.updated =
  118. IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
  119. }
  120. }
  121. orinoco_unlock(priv, &flags);
  122. return wstats;
  123. }
  124. /********************************************************************/
  125. /* Wireless extensions */
  126. /********************************************************************/
  127. static int orinoco_ioctl_setwap(struct net_device *dev,
  128. struct iw_request_info *info,
  129. struct sockaddr *ap_addr,
  130. char *extra)
  131. {
  132. struct orinoco_private *priv = ndev_priv(dev);
  133. int err = -EINPROGRESS; /* Call commit handler */
  134. unsigned long flags;
  135. static const u8 off_addr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
  136. static const u8 any_addr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  137. if (orinoco_lock(priv, &flags) != 0)
  138. return -EBUSY;
  139. /* Enable automatic roaming - no sanity checks are needed */
  140. if (memcmp(&ap_addr->sa_data, off_addr, ETH_ALEN) == 0 ||
  141. memcmp(&ap_addr->sa_data, any_addr, ETH_ALEN) == 0) {
  142. priv->bssid_fixed = 0;
  143. memset(priv->desired_bssid, 0, ETH_ALEN);
  144. /* "off" means keep existing connection */
  145. if (ap_addr->sa_data[0] == 0) {
  146. __orinoco_hw_set_wap(priv);
  147. err = 0;
  148. }
  149. goto out;
  150. }
  151. if (priv->firmware_type == FIRMWARE_TYPE_AGERE) {
  152. printk(KERN_WARNING "%s: Lucent/Agere firmware doesn't "
  153. "support manual roaming\n",
  154. dev->name);
  155. err = -EOPNOTSUPP;
  156. goto out;
  157. }
  158. if (priv->iw_mode != NL80211_IFTYPE_STATION) {
  159. printk(KERN_WARNING "%s: Manual roaming supported only in "
  160. "managed mode\n", dev->name);
  161. err = -EOPNOTSUPP;
  162. goto out;
  163. }
  164. /* Intersil firmware hangs without Desired ESSID */
  165. if (priv->firmware_type == FIRMWARE_TYPE_INTERSIL &&
  166. strlen(priv->desired_essid) == 0) {
  167. printk(KERN_WARNING "%s: Desired ESSID must be set for "
  168. "manual roaming\n", dev->name);
  169. err = -EOPNOTSUPP;
  170. goto out;
  171. }
  172. /* Finally, enable manual roaming */
  173. priv->bssid_fixed = 1;
  174. memcpy(priv->desired_bssid, &ap_addr->sa_data, ETH_ALEN);
  175. out:
  176. orinoco_unlock(priv, &flags);
  177. return err;
  178. }
  179. static int orinoco_ioctl_getwap(struct net_device *dev,
  180. struct iw_request_info *info,
  181. struct sockaddr *ap_addr,
  182. char *extra)
  183. {
  184. struct orinoco_private *priv = ndev_priv(dev);
  185. int err = 0;
  186. unsigned long flags;
  187. if (orinoco_lock(priv, &flags) != 0)
  188. return -EBUSY;
  189. ap_addr->sa_family = ARPHRD_ETHER;
  190. err = orinoco_hw_get_current_bssid(priv, ap_addr->sa_data);
  191. orinoco_unlock(priv, &flags);
  192. return err;
  193. }
  194. static int orinoco_ioctl_setiwencode(struct net_device *dev,
  195. struct iw_request_info *info,
  196. struct iw_point *erq,
  197. char *keybuf)
  198. {
  199. struct orinoco_private *priv = ndev_priv(dev);
  200. int index = (erq->flags & IW_ENCODE_INDEX) - 1;
  201. int setindex = priv->tx_key;
  202. enum orinoco_alg encode_alg = priv->encode_alg;
  203. int restricted = priv->wep_restrict;
  204. int err = -EINPROGRESS; /* Call commit handler */
  205. unsigned long flags;
  206. if (!priv->has_wep)
  207. return -EOPNOTSUPP;
  208. if (erq->pointer) {
  209. /* We actually have a key to set - check its length */
  210. if (erq->length > LARGE_KEY_SIZE)
  211. return -E2BIG;
  212. if ((erq->length > SMALL_KEY_SIZE) && !priv->has_big_wep)
  213. return -E2BIG;
  214. }
  215. if (orinoco_lock(priv, &flags) != 0)
  216. return -EBUSY;
  217. /* Clear any TKIP key we have */
  218. if ((priv->has_wpa) && (priv->encode_alg == ORINOCO_ALG_TKIP))
  219. (void) orinoco_clear_tkip_key(priv, setindex);
  220. if (erq->length > 0) {
  221. if ((index < 0) || (index >= ORINOCO_MAX_KEYS))
  222. index = priv->tx_key;
  223. /* Switch on WEP if off */
  224. if (encode_alg != ORINOCO_ALG_WEP) {
  225. setindex = index;
  226. encode_alg = ORINOCO_ALG_WEP;
  227. }
  228. } else {
  229. /* Important note : if the user do "iwconfig eth0 enc off",
  230. * we will arrive there with an index of -1. This is valid
  231. * but need to be taken care off... Jean II */
  232. if ((index < 0) || (index >= ORINOCO_MAX_KEYS)) {
  233. if ((index != -1) || (erq->flags == 0)) {
  234. err = -EINVAL;
  235. goto out;
  236. }
  237. } else {
  238. /* Set the index : Check that the key is valid */
  239. if (priv->keys[index].key_len == 0) {
  240. err = -EINVAL;
  241. goto out;
  242. }
  243. setindex = index;
  244. }
  245. }
  246. if (erq->flags & IW_ENCODE_DISABLED)
  247. encode_alg = ORINOCO_ALG_NONE;
  248. if (erq->flags & IW_ENCODE_OPEN)
  249. restricted = 0;
  250. if (erq->flags & IW_ENCODE_RESTRICTED)
  251. restricted = 1;
  252. if (erq->pointer && erq->length > 0) {
  253. err = orinoco_set_key(priv, index, ORINOCO_ALG_WEP, keybuf,
  254. erq->length, NULL, 0);
  255. }
  256. priv->tx_key = setindex;
  257. /* Try fast key change if connected and only keys are changed */
  258. if ((priv->encode_alg == encode_alg) &&
  259. (priv->wep_restrict == restricted) &&
  260. netif_carrier_ok(dev)) {
  261. err = __orinoco_hw_setup_wepkeys(priv);
  262. /* No need to commit if successful */
  263. goto out;
  264. }
  265. priv->encode_alg = encode_alg;
  266. priv->wep_restrict = restricted;
  267. out:
  268. orinoco_unlock(priv, &flags);
  269. return err;
  270. }
  271. static int orinoco_ioctl_getiwencode(struct net_device *dev,
  272. struct iw_request_info *info,
  273. struct iw_point *erq,
  274. char *keybuf)
  275. {
  276. struct orinoco_private *priv = ndev_priv(dev);
  277. int index = (erq->flags & IW_ENCODE_INDEX) - 1;
  278. unsigned long flags;
  279. if (!priv->has_wep)
  280. return -EOPNOTSUPP;
  281. if (orinoco_lock(priv, &flags) != 0)
  282. return -EBUSY;
  283. if ((index < 0) || (index >= ORINOCO_MAX_KEYS))
  284. index = priv->tx_key;
  285. erq->flags = 0;
  286. if (!priv->encode_alg)
  287. erq->flags |= IW_ENCODE_DISABLED;
  288. erq->flags |= index + 1;
  289. if (priv->wep_restrict)
  290. erq->flags |= IW_ENCODE_RESTRICTED;
  291. else
  292. erq->flags |= IW_ENCODE_OPEN;
  293. erq->length = priv->keys[index].key_len;
  294. memcpy(keybuf, priv->keys[index].key, erq->length);
  295. orinoco_unlock(priv, &flags);
  296. return 0;
  297. }
  298. static int orinoco_ioctl_setessid(struct net_device *dev,
  299. struct iw_request_info *info,
  300. struct iw_point *erq,
  301. char *essidbuf)
  302. {
  303. struct orinoco_private *priv = ndev_priv(dev);
  304. unsigned long flags;
  305. /* Note : ESSID is ignored in Ad-Hoc demo mode, but we can set it
  306. * anyway... - Jean II */
  307. /* Hum... Should not use Wireless Extension constant (may change),
  308. * should use our own... - Jean II */
  309. if (erq->length > IW_ESSID_MAX_SIZE)
  310. return -E2BIG;
  311. if (orinoco_lock(priv, &flags) != 0)
  312. return -EBUSY;
  313. /* NULL the string (for NULL termination & ESSID = ANY) - Jean II */
  314. memset(priv->desired_essid, 0, sizeof(priv->desired_essid));
  315. /* If not ANY, get the new ESSID */
  316. if (erq->flags)
  317. memcpy(priv->desired_essid, essidbuf, erq->length);
  318. orinoco_unlock(priv, &flags);
  319. return -EINPROGRESS; /* Call commit handler */
  320. }
  321. static int orinoco_ioctl_getessid(struct net_device *dev,
  322. struct iw_request_info *info,
  323. struct iw_point *erq,
  324. char *essidbuf)
  325. {
  326. struct orinoco_private *priv = ndev_priv(dev);
  327. int active;
  328. int err = 0;
  329. unsigned long flags;
  330. if (netif_running(dev)) {
  331. err = orinoco_hw_get_essid(priv, &active, essidbuf);
  332. if (err < 0)
  333. return err;
  334. erq->length = err;
  335. } else {
  336. if (orinoco_lock(priv, &flags) != 0)
  337. return -EBUSY;
  338. memcpy(essidbuf, priv->desired_essid, IW_ESSID_MAX_SIZE);
  339. erq->length = strlen(priv->desired_essid);
  340. orinoco_unlock(priv, &flags);
  341. }
  342. erq->flags = 1;
  343. return 0;
  344. }
  345. static int orinoco_ioctl_setfreq(struct net_device *dev,
  346. struct iw_request_info *info,
  347. struct iw_freq *frq,
  348. char *extra)
  349. {
  350. struct orinoco_private *priv = ndev_priv(dev);
  351. int chan = -1;
  352. unsigned long flags;
  353. int err = -EINPROGRESS; /* Call commit handler */
  354. /* In infrastructure mode the AP sets the channel */
  355. if (priv->iw_mode == NL80211_IFTYPE_STATION)
  356. return -EBUSY;
  357. if ((frq->e == 0) && (frq->m <= 1000)) {
  358. /* Setting by channel number */
  359. chan = frq->m;
  360. } else {
  361. /* Setting by frequency */
  362. int denom = 1;
  363. int i;
  364. /* Calculate denominator to rescale to MHz */
  365. for (i = 0; i < (6 - frq->e); i++)
  366. denom *= 10;
  367. chan = ieee80211_freq_to_dsss_chan(frq->m / denom);
  368. }
  369. if ((chan < 1) || (chan > NUM_CHANNELS) ||
  370. !(priv->channel_mask & (1 << (chan-1))))
  371. return -EINVAL;
  372. if (orinoco_lock(priv, &flags) != 0)
  373. return -EBUSY;
  374. priv->channel = chan;
  375. if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
  376. /* Fast channel change - no commit if successful */
  377. hermes_t *hw = &priv->hw;
  378. err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
  379. HERMES_TEST_SET_CHANNEL,
  380. chan, NULL);
  381. }
  382. orinoco_unlock(priv, &flags);
  383. return err;
  384. }
  385. static int orinoco_ioctl_getfreq(struct net_device *dev,
  386. struct iw_request_info *info,
  387. struct iw_freq *frq,
  388. char *extra)
  389. {
  390. struct orinoco_private *priv = ndev_priv(dev);
  391. int tmp;
  392. /* Locking done in there */
  393. tmp = orinoco_hw_get_freq(priv);
  394. if (tmp < 0)
  395. return tmp;
  396. frq->m = tmp * 100000;
  397. frq->e = 1;
  398. return 0;
  399. }
  400. static int orinoco_ioctl_getsens(struct net_device *dev,
  401. struct iw_request_info *info,
  402. struct iw_param *srq,
  403. char *extra)
  404. {
  405. struct orinoco_private *priv = ndev_priv(dev);
  406. hermes_t *hw = &priv->hw;
  407. u16 val;
  408. int err;
  409. unsigned long flags;
  410. if (!priv->has_sensitivity)
  411. return -EOPNOTSUPP;
  412. if (orinoco_lock(priv, &flags) != 0)
  413. return -EBUSY;
  414. err = hermes_read_wordrec(hw, USER_BAP,
  415. HERMES_RID_CNFSYSTEMSCALE, &val);
  416. orinoco_unlock(priv, &flags);
  417. if (err)
  418. return err;
  419. srq->value = val;
  420. srq->fixed = 0; /* auto */
  421. return 0;
  422. }
  423. static int orinoco_ioctl_setsens(struct net_device *dev,
  424. struct iw_request_info *info,
  425. struct iw_param *srq,
  426. char *extra)
  427. {
  428. struct orinoco_private *priv = ndev_priv(dev);
  429. int val = srq->value;
  430. unsigned long flags;
  431. if (!priv->has_sensitivity)
  432. return -EOPNOTSUPP;
  433. if ((val < 1) || (val > 3))
  434. return -EINVAL;
  435. if (orinoco_lock(priv, &flags) != 0)
  436. return -EBUSY;
  437. priv->ap_density = val;
  438. orinoco_unlock(priv, &flags);
  439. return -EINPROGRESS; /* Call commit handler */
  440. }
  441. static int orinoco_ioctl_setrate(struct net_device *dev,
  442. struct iw_request_info *info,
  443. struct iw_param *rrq,
  444. char *extra)
  445. {
  446. struct orinoco_private *priv = ndev_priv(dev);
  447. int ratemode;
  448. int bitrate; /* 100s of kilobits */
  449. unsigned long flags;
  450. /* As the user space doesn't know our highest rate, it uses -1
  451. * to ask us to set the highest rate. Test it using "iwconfig
  452. * ethX rate auto" - Jean II */
  453. if (rrq->value == -1)
  454. bitrate = 110;
  455. else {
  456. if (rrq->value % 100000)
  457. return -EINVAL;
  458. bitrate = rrq->value / 100000;
  459. }
  460. ratemode = orinoco_get_bitratemode(bitrate, !rrq->fixed);
  461. if (ratemode == -1)
  462. return -EINVAL;
  463. if (orinoco_lock(priv, &flags) != 0)
  464. return -EBUSY;
  465. priv->bitratemode = ratemode;
  466. orinoco_unlock(priv, &flags);
  467. return -EINPROGRESS;
  468. }
  469. static int orinoco_ioctl_getrate(struct net_device *dev,
  470. struct iw_request_info *info,
  471. struct iw_param *rrq,
  472. char *extra)
  473. {
  474. struct orinoco_private *priv = ndev_priv(dev);
  475. int err = 0;
  476. int bitrate, automatic;
  477. unsigned long flags;
  478. if (orinoco_lock(priv, &flags) != 0)
  479. return -EBUSY;
  480. orinoco_get_ratemode_cfg(priv->bitratemode, &bitrate, &automatic);
  481. /* If the interface is running we try to find more about the
  482. current mode */
  483. if (netif_running(dev))
  484. err = orinoco_hw_get_act_bitrate(priv, &bitrate);
  485. orinoco_unlock(priv, &flags);
  486. rrq->value = bitrate;
  487. rrq->fixed = !automatic;
  488. rrq->disabled = 0;
  489. return err;
  490. }
  491. static int orinoco_ioctl_setpower(struct net_device *dev,
  492. struct iw_request_info *info,
  493. struct iw_param *prq,
  494. char *extra)
  495. {
  496. struct orinoco_private *priv = ndev_priv(dev);
  497. int err = -EINPROGRESS; /* Call commit handler */
  498. unsigned long flags;
  499. if (orinoco_lock(priv, &flags) != 0)
  500. return -EBUSY;
  501. if (prq->disabled) {
  502. priv->pm_on = 0;
  503. } else {
  504. switch (prq->flags & IW_POWER_MODE) {
  505. case IW_POWER_UNICAST_R:
  506. priv->pm_mcast = 0;
  507. priv->pm_on = 1;
  508. break;
  509. case IW_POWER_ALL_R:
  510. priv->pm_mcast = 1;
  511. priv->pm_on = 1;
  512. break;
  513. case IW_POWER_ON:
  514. /* No flags : but we may have a value - Jean II */
  515. break;
  516. default:
  517. err = -EINVAL;
  518. goto out;
  519. }
  520. if (prq->flags & IW_POWER_TIMEOUT) {
  521. priv->pm_on = 1;
  522. priv->pm_timeout = prq->value / 1000;
  523. }
  524. if (prq->flags & IW_POWER_PERIOD) {
  525. priv->pm_on = 1;
  526. priv->pm_period = prq->value / 1000;
  527. }
  528. /* It's valid to not have a value if we are just toggling
  529. * the flags... Jean II */
  530. if (!priv->pm_on) {
  531. err = -EINVAL;
  532. goto out;
  533. }
  534. }
  535. out:
  536. orinoco_unlock(priv, &flags);
  537. return err;
  538. }
  539. static int orinoco_ioctl_getpower(struct net_device *dev,
  540. struct iw_request_info *info,
  541. struct iw_param *prq,
  542. char *extra)
  543. {
  544. struct orinoco_private *priv = ndev_priv(dev);
  545. hermes_t *hw = &priv->hw;
  546. int err = 0;
  547. u16 enable, period, timeout, mcast;
  548. unsigned long flags;
  549. if (orinoco_lock(priv, &flags) != 0)
  550. return -EBUSY;
  551. err = hermes_read_wordrec(hw, USER_BAP,
  552. HERMES_RID_CNFPMENABLED, &enable);
  553. if (err)
  554. goto out;
  555. err = hermes_read_wordrec(hw, USER_BAP,
  556. HERMES_RID_CNFMAXSLEEPDURATION, &period);
  557. if (err)
  558. goto out;
  559. err = hermes_read_wordrec(hw, USER_BAP,
  560. HERMES_RID_CNFPMHOLDOVERDURATION, &timeout);
  561. if (err)
  562. goto out;
  563. err = hermes_read_wordrec(hw, USER_BAP,
  564. HERMES_RID_CNFMULTICASTRECEIVE, &mcast);
  565. if (err)
  566. goto out;
  567. prq->disabled = !enable;
  568. /* Note : by default, display the period */
  569. if ((prq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
  570. prq->flags = IW_POWER_TIMEOUT;
  571. prq->value = timeout * 1000;
  572. } else {
  573. prq->flags = IW_POWER_PERIOD;
  574. prq->value = period * 1000;
  575. }
  576. if (mcast)
  577. prq->flags |= IW_POWER_ALL_R;
  578. else
  579. prq->flags |= IW_POWER_UNICAST_R;
  580. out:
  581. orinoco_unlock(priv, &flags);
  582. return err;
  583. }
  584. static int orinoco_ioctl_set_encodeext(struct net_device *dev,
  585. struct iw_request_info *info,
  586. union iwreq_data *wrqu,
  587. char *extra)
  588. {
  589. struct orinoco_private *priv = ndev_priv(dev);
  590. struct iw_point *encoding = &wrqu->encoding;
  591. struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  592. int idx, alg = ext->alg, set_key = 1;
  593. unsigned long flags;
  594. int err = -EINVAL;
  595. if (orinoco_lock(priv, &flags) != 0)
  596. return -EBUSY;
  597. /* Determine and validate the key index */
  598. idx = encoding->flags & IW_ENCODE_INDEX;
  599. if (idx) {
  600. if ((idx < 1) || (idx > 4))
  601. goto out;
  602. idx--;
  603. } else
  604. idx = priv->tx_key;
  605. if (encoding->flags & IW_ENCODE_DISABLED)
  606. alg = IW_ENCODE_ALG_NONE;
  607. if (priv->has_wpa && (alg != IW_ENCODE_ALG_TKIP)) {
  608. /* Clear any TKIP TX key we had */
  609. (void) orinoco_clear_tkip_key(priv, priv->tx_key);
  610. }
  611. if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
  612. priv->tx_key = idx;
  613. set_key = ((alg == IW_ENCODE_ALG_TKIP) ||
  614. (ext->key_len > 0)) ? 1 : 0;
  615. }
  616. if (set_key) {
  617. /* Set the requested key first */
  618. switch (alg) {
  619. case IW_ENCODE_ALG_NONE:
  620. priv->encode_alg = ORINOCO_ALG_NONE;
  621. err = orinoco_set_key(priv, idx, ORINOCO_ALG_NONE,
  622. NULL, 0, NULL, 0);
  623. break;
  624. case IW_ENCODE_ALG_WEP:
  625. if (ext->key_len <= 0)
  626. goto out;
  627. priv->encode_alg = ORINOCO_ALG_WEP;
  628. err = orinoco_set_key(priv, idx, ORINOCO_ALG_WEP,
  629. ext->key, ext->key_len, NULL, 0);
  630. break;
  631. case IW_ENCODE_ALG_TKIP:
  632. {
  633. u8 *tkip_iv = NULL;
  634. if (!priv->has_wpa ||
  635. (ext->key_len > sizeof(struct orinoco_tkip_key)))
  636. goto out;
  637. priv->encode_alg = ORINOCO_ALG_TKIP;
  638. if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID)
  639. tkip_iv = &ext->rx_seq[0];
  640. err = orinoco_set_key(priv, idx, ORINOCO_ALG_TKIP,
  641. ext->key, ext->key_len, tkip_iv,
  642. ORINOCO_SEQ_LEN);
  643. err = __orinoco_hw_set_tkip_key(priv, idx,
  644. ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY,
  645. priv->keys[idx].key,
  646. tkip_iv, ORINOCO_SEQ_LEN, NULL, 0);
  647. if (err)
  648. printk(KERN_ERR "%s: Error %d setting TKIP key"
  649. "\n", dev->name, err);
  650. goto out;
  651. }
  652. default:
  653. goto out;
  654. }
  655. }
  656. err = -EINPROGRESS;
  657. out:
  658. orinoco_unlock(priv, &flags);
  659. return err;
  660. }
  661. static int orinoco_ioctl_get_encodeext(struct net_device *dev,
  662. struct iw_request_info *info,
  663. union iwreq_data *wrqu,
  664. char *extra)
  665. {
  666. struct orinoco_private *priv = ndev_priv(dev);
  667. struct iw_point *encoding = &wrqu->encoding;
  668. struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  669. int idx, max_key_len;
  670. unsigned long flags;
  671. int err;
  672. if (orinoco_lock(priv, &flags) != 0)
  673. return -EBUSY;
  674. err = -EINVAL;
  675. max_key_len = encoding->length - sizeof(*ext);
  676. if (max_key_len < 0)
  677. goto out;
  678. idx = encoding->flags & IW_ENCODE_INDEX;
  679. if (idx) {
  680. if ((idx < 1) || (idx > 4))
  681. goto out;
  682. idx--;
  683. } else
  684. idx = priv->tx_key;
  685. encoding->flags = idx + 1;
  686. memset(ext, 0, sizeof(*ext));
  687. switch (priv->encode_alg) {
  688. case ORINOCO_ALG_NONE:
  689. ext->alg = IW_ENCODE_ALG_NONE;
  690. ext->key_len = 0;
  691. encoding->flags |= IW_ENCODE_DISABLED;
  692. break;
  693. case ORINOCO_ALG_WEP:
  694. ext->alg = IW_ENCODE_ALG_WEP;
  695. ext->key_len = min(priv->keys[idx].key_len, max_key_len);
  696. memcpy(ext->key, priv->keys[idx].key, ext->key_len);
  697. encoding->flags |= IW_ENCODE_ENABLED;
  698. break;
  699. case ORINOCO_ALG_TKIP:
  700. ext->alg = IW_ENCODE_ALG_TKIP;
  701. ext->key_len = min(priv->keys[idx].key_len, max_key_len);
  702. memcpy(ext->key, priv->keys[idx].key, ext->key_len);
  703. encoding->flags |= IW_ENCODE_ENABLED;
  704. break;
  705. }
  706. err = 0;
  707. out:
  708. orinoco_unlock(priv, &flags);
  709. return err;
  710. }
  711. static int orinoco_ioctl_set_auth(struct net_device *dev,
  712. struct iw_request_info *info,
  713. union iwreq_data *wrqu, char *extra)
  714. {
  715. struct orinoco_private *priv = ndev_priv(dev);
  716. hermes_t *hw = &priv->hw;
  717. struct iw_param *param = &wrqu->param;
  718. unsigned long flags;
  719. int ret = -EINPROGRESS;
  720. if (orinoco_lock(priv, &flags) != 0)
  721. return -EBUSY;
  722. switch (param->flags & IW_AUTH_INDEX) {
  723. case IW_AUTH_WPA_VERSION:
  724. case IW_AUTH_CIPHER_PAIRWISE:
  725. case IW_AUTH_CIPHER_GROUP:
  726. case IW_AUTH_RX_UNENCRYPTED_EAPOL:
  727. case IW_AUTH_PRIVACY_INVOKED:
  728. case IW_AUTH_DROP_UNENCRYPTED:
  729. /*
  730. * orinoco does not use these parameters
  731. */
  732. break;
  733. case IW_AUTH_KEY_MGMT:
  734. /* wl_lkm implies value 2 == PSK for Hermes I
  735. * which ties in with WEXT
  736. * no other hints tho :(
  737. */
  738. priv->key_mgmt = param->value;
  739. break;
  740. case IW_AUTH_TKIP_COUNTERMEASURES:
  741. /* When countermeasures are enabled, shut down the
  742. * card; when disabled, re-enable the card. This must
  743. * take effect immediately.
  744. *
  745. * TODO: Make sure that the EAPOL message is getting
  746. * out before card disabled
  747. */
  748. if (param->value) {
  749. priv->tkip_cm_active = 1;
  750. ret = hermes_enable_port(hw, 0);
  751. } else {
  752. priv->tkip_cm_active = 0;
  753. ret = hermes_disable_port(hw, 0);
  754. }
  755. break;
  756. case IW_AUTH_80211_AUTH_ALG:
  757. if (param->value & IW_AUTH_ALG_SHARED_KEY)
  758. priv->wep_restrict = 1;
  759. else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
  760. priv->wep_restrict = 0;
  761. else
  762. ret = -EINVAL;
  763. break;
  764. case IW_AUTH_WPA_ENABLED:
  765. if (priv->has_wpa) {
  766. priv->wpa_enabled = param->value ? 1 : 0;
  767. } else {
  768. if (param->value)
  769. ret = -EOPNOTSUPP;
  770. /* else silently accept disable of WPA */
  771. priv->wpa_enabled = 0;
  772. }
  773. break;
  774. default:
  775. ret = -EOPNOTSUPP;
  776. }
  777. orinoco_unlock(priv, &flags);
  778. return ret;
  779. }
  780. static int orinoco_ioctl_get_auth(struct net_device *dev,
  781. struct iw_request_info *info,
  782. union iwreq_data *wrqu, char *extra)
  783. {
  784. struct orinoco_private *priv = ndev_priv(dev);
  785. struct iw_param *param = &wrqu->param;
  786. unsigned long flags;
  787. int ret = 0;
  788. if (orinoco_lock(priv, &flags) != 0)
  789. return -EBUSY;
  790. switch (param->flags & IW_AUTH_INDEX) {
  791. case IW_AUTH_KEY_MGMT:
  792. param->value = priv->key_mgmt;
  793. break;
  794. case IW_AUTH_TKIP_COUNTERMEASURES:
  795. param->value = priv->tkip_cm_active;
  796. break;
  797. case IW_AUTH_80211_AUTH_ALG:
  798. if (priv->wep_restrict)
  799. param->value = IW_AUTH_ALG_SHARED_KEY;
  800. else
  801. param->value = IW_AUTH_ALG_OPEN_SYSTEM;
  802. break;
  803. case IW_AUTH_WPA_ENABLED:
  804. param->value = priv->wpa_enabled;
  805. break;
  806. default:
  807. ret = -EOPNOTSUPP;
  808. }
  809. orinoco_unlock(priv, &flags);
  810. return ret;
  811. }
  812. static int orinoco_ioctl_set_genie(struct net_device *dev,
  813. struct iw_request_info *info,
  814. union iwreq_data *wrqu, char *extra)
  815. {
  816. struct orinoco_private *priv = ndev_priv(dev);
  817. u8 *buf;
  818. unsigned long flags;
  819. /* cut off at IEEE80211_MAX_DATA_LEN */
  820. if ((wrqu->data.length > IEEE80211_MAX_DATA_LEN) ||
  821. (wrqu->data.length && (extra == NULL)))
  822. return -EINVAL;
  823. if (wrqu->data.length) {
  824. buf = kmemdup(extra, wrqu->data.length, GFP_KERNEL);
  825. if (buf == NULL)
  826. return -ENOMEM;
  827. } else
  828. buf = NULL;
  829. if (orinoco_lock(priv, &flags) != 0) {
  830. kfree(buf);
  831. return -EBUSY;
  832. }
  833. kfree(priv->wpa_ie);
  834. priv->wpa_ie = buf;
  835. priv->wpa_ie_len = wrqu->data.length;
  836. if (priv->wpa_ie) {
  837. /* Looks like wl_lkm wants to check the auth alg, and
  838. * somehow pass it to the firmware.
  839. * Instead it just calls the key mgmt rid
  840. * - we do this in set auth.
  841. */
  842. }
  843. orinoco_unlock(priv, &flags);
  844. return 0;
  845. }
  846. static int orinoco_ioctl_get_genie(struct net_device *dev,
  847. struct iw_request_info *info,
  848. union iwreq_data *wrqu, char *extra)
  849. {
  850. struct orinoco_private *priv = ndev_priv(dev);
  851. unsigned long flags;
  852. int err = 0;
  853. if (orinoco_lock(priv, &flags) != 0)
  854. return -EBUSY;
  855. if ((priv->wpa_ie_len == 0) || (priv->wpa_ie == NULL)) {
  856. wrqu->data.length = 0;
  857. goto out;
  858. }
  859. if (wrqu->data.length < priv->wpa_ie_len) {
  860. err = -E2BIG;
  861. goto out;
  862. }
  863. wrqu->data.length = priv->wpa_ie_len;
  864. memcpy(extra, priv->wpa_ie, priv->wpa_ie_len);
  865. out:
  866. orinoco_unlock(priv, &flags);
  867. return err;
  868. }
  869. static int orinoco_ioctl_set_mlme(struct net_device *dev,
  870. struct iw_request_info *info,
  871. union iwreq_data *wrqu, char *extra)
  872. {
  873. struct orinoco_private *priv = ndev_priv(dev);
  874. struct iw_mlme *mlme = (struct iw_mlme *)extra;
  875. unsigned long flags;
  876. int ret = 0;
  877. if (orinoco_lock(priv, &flags) != 0)
  878. return -EBUSY;
  879. switch (mlme->cmd) {
  880. case IW_MLME_DEAUTH:
  881. /* silently ignore */
  882. break;
  883. case IW_MLME_DISASSOC:
  884. ret = orinoco_hw_disassociate(priv, mlme->addr.sa_data,
  885. mlme->reason_code);
  886. break;
  887. default:
  888. ret = -EOPNOTSUPP;
  889. }
  890. orinoco_unlock(priv, &flags);
  891. return ret;
  892. }
  893. static int orinoco_ioctl_reset(struct net_device *dev,
  894. struct iw_request_info *info,
  895. void *wrqu,
  896. char *extra)
  897. {
  898. struct orinoco_private *priv = ndev_priv(dev);
  899. if (!capable(CAP_NET_ADMIN))
  900. return -EPERM;
  901. if (info->cmd == (SIOCIWFIRSTPRIV + 0x1)) {
  902. printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name);
  903. /* Firmware reset */
  904. orinoco_reset(&priv->reset_work);
  905. } else {
  906. printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name);
  907. schedule_work(&priv->reset_work);
  908. }
  909. return 0;
  910. }
  911. static int orinoco_ioctl_setibssport(struct net_device *dev,
  912. struct iw_request_info *info,
  913. void *wrqu,
  914. char *extra)
  915. {
  916. struct orinoco_private *priv = ndev_priv(dev);
  917. int val = *((int *) extra);
  918. unsigned long flags;
  919. if (orinoco_lock(priv, &flags) != 0)
  920. return -EBUSY;
  921. priv->ibss_port = val;
  922. /* Actually update the mode we are using */
  923. set_port_type(priv);
  924. orinoco_unlock(priv, &flags);
  925. return -EINPROGRESS; /* Call commit handler */
  926. }
  927. static int orinoco_ioctl_getibssport(struct net_device *dev,
  928. struct iw_request_info *info,
  929. void *wrqu,
  930. char *extra)
  931. {
  932. struct orinoco_private *priv = ndev_priv(dev);
  933. int *val = (int *) extra;
  934. *val = priv->ibss_port;
  935. return 0;
  936. }
  937. static int orinoco_ioctl_setport3(struct net_device *dev,
  938. struct iw_request_info *info,
  939. void *wrqu,
  940. char *extra)
  941. {
  942. struct orinoco_private *priv = ndev_priv(dev);
  943. int val = *((int *) extra);
  944. int err = 0;
  945. unsigned long flags;
  946. if (orinoco_lock(priv, &flags) != 0)
  947. return -EBUSY;
  948. switch (val) {
  949. case 0: /* Try to do IEEE ad-hoc mode */
  950. if (!priv->has_ibss) {
  951. err = -EINVAL;
  952. break;
  953. }
  954. priv->prefer_port3 = 0;
  955. break;
  956. case 1: /* Try to do Lucent proprietary ad-hoc mode */
  957. if (!priv->has_port3) {
  958. err = -EINVAL;
  959. break;
  960. }
  961. priv->prefer_port3 = 1;
  962. break;
  963. default:
  964. err = -EINVAL;
  965. }
  966. if (!err) {
  967. /* Actually update the mode we are using */
  968. set_port_type(priv);
  969. err = -EINPROGRESS;
  970. }
  971. orinoco_unlock(priv, &flags);
  972. return err;
  973. }
  974. static int orinoco_ioctl_getport3(struct net_device *dev,
  975. struct iw_request_info *info,
  976. void *wrqu,
  977. char *extra)
  978. {
  979. struct orinoco_private *priv = ndev_priv(dev);
  980. int *val = (int *) extra;
  981. *val = priv->prefer_port3;
  982. return 0;
  983. }
  984. static int orinoco_ioctl_setpreamble(struct net_device *dev,
  985. struct iw_request_info *info,
  986. void *wrqu,
  987. char *extra)
  988. {
  989. struct orinoco_private *priv = ndev_priv(dev);
  990. unsigned long flags;
  991. int val;
  992. if (!priv->has_preamble)
  993. return -EOPNOTSUPP;
  994. /* 802.11b has recently defined some short preamble.
  995. * Basically, the Phy header has been reduced in size.
  996. * This increase performance, especially at high rates
  997. * (the preamble is transmitted at 1Mb/s), unfortunately
  998. * this give compatibility troubles... - Jean II */
  999. val = *((int *) extra);
  1000. if (orinoco_lock(priv, &flags) != 0)
  1001. return -EBUSY;
  1002. if (val)
  1003. priv->preamble = 1;
  1004. else
  1005. priv->preamble = 0;
  1006. orinoco_unlock(priv, &flags);
  1007. return -EINPROGRESS; /* Call commit handler */
  1008. }
  1009. static int orinoco_ioctl_getpreamble(struct net_device *dev,
  1010. struct iw_request_info *info,
  1011. void *wrqu,
  1012. char *extra)
  1013. {
  1014. struct orinoco_private *priv = ndev_priv(dev);
  1015. int *val = (int *) extra;
  1016. if (!priv->has_preamble)
  1017. return -EOPNOTSUPP;
  1018. *val = priv->preamble;
  1019. return 0;
  1020. }
  1021. /* ioctl interface to hermes_read_ltv()
  1022. * To use with iwpriv, pass the RID as the token argument, e.g.
  1023. * iwpriv get_rid [0xfc00]
  1024. * At least Wireless Tools 25 is required to use iwpriv.
  1025. * For Wireless Tools 25 and 26 append "dummy" are the end. */
  1026. static int orinoco_ioctl_getrid(struct net_device *dev,
  1027. struct iw_request_info *info,
  1028. struct iw_point *data,
  1029. char *extra)
  1030. {
  1031. struct orinoco_private *priv = ndev_priv(dev);
  1032. hermes_t *hw = &priv->hw;
  1033. int rid = data->flags;
  1034. u16 length;
  1035. int err;
  1036. unsigned long flags;
  1037. /* It's a "get" function, but we don't want users to access the
  1038. * WEP key and other raw firmware data */
  1039. if (!capable(CAP_NET_ADMIN))
  1040. return -EPERM;
  1041. if (rid < 0xfc00 || rid > 0xffff)
  1042. return -EINVAL;
  1043. if (orinoco_lock(priv, &flags) != 0)
  1044. return -EBUSY;
  1045. err = hw->ops->read_ltv(hw, USER_BAP, rid, MAX_RID_LEN, &length,
  1046. extra);
  1047. if (err)
  1048. goto out;
  1049. data->length = min_t(u16, HERMES_RECLEN_TO_BYTES(length),
  1050. MAX_RID_LEN);
  1051. out:
  1052. orinoco_unlock(priv, &flags);
  1053. return err;
  1054. }
  1055. /* Commit handler, called after set operations */
  1056. static int orinoco_ioctl_commit(struct net_device *dev,
  1057. struct iw_request_info *info,
  1058. void *wrqu,
  1059. char *extra)
  1060. {
  1061. struct orinoco_private *priv = ndev_priv(dev);
  1062. unsigned long flags;
  1063. int err = 0;
  1064. if (!priv->open)
  1065. return 0;
  1066. if (orinoco_lock(priv, &flags) != 0)
  1067. return err;
  1068. err = orinoco_commit(priv);
  1069. orinoco_unlock(priv, &flags);
  1070. return err;
  1071. }
  1072. static const struct iw_priv_args orinoco_privtab[] = {
  1073. { SIOCIWFIRSTPRIV + 0x0, 0, 0, "force_reset" },
  1074. { SIOCIWFIRSTPRIV + 0x1, 0, 0, "card_reset" },
  1075. { SIOCIWFIRSTPRIV + 0x2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1076. 0, "set_port3" },
  1077. { SIOCIWFIRSTPRIV + 0x3, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1078. "get_port3" },
  1079. { SIOCIWFIRSTPRIV + 0x4, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1080. 0, "set_preamble" },
  1081. { SIOCIWFIRSTPRIV + 0x5, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1082. "get_preamble" },
  1083. { SIOCIWFIRSTPRIV + 0x6, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1084. 0, "set_ibssport" },
  1085. { SIOCIWFIRSTPRIV + 0x7, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1086. "get_ibssport" },
  1087. { SIOCIWFIRSTPRIV + 0x9, 0, IW_PRIV_TYPE_BYTE | MAX_RID_LEN,
  1088. "get_rid" },
  1089. };
  1090. /*
  1091. * Structures to export the Wireless Handlers
  1092. */
  1093. static const iw_handler orinoco_handler[] = {
  1094. IW_HANDLER(SIOCSIWCOMMIT, (iw_handler)orinoco_ioctl_commit),
  1095. IW_HANDLER(SIOCGIWNAME, (iw_handler)cfg80211_wext_giwname),
  1096. IW_HANDLER(SIOCSIWFREQ, (iw_handler)orinoco_ioctl_setfreq),
  1097. IW_HANDLER(SIOCGIWFREQ, (iw_handler)orinoco_ioctl_getfreq),
  1098. IW_HANDLER(SIOCSIWMODE, (iw_handler)cfg80211_wext_siwmode),
  1099. IW_HANDLER(SIOCGIWMODE, (iw_handler)cfg80211_wext_giwmode),
  1100. IW_HANDLER(SIOCSIWSENS, (iw_handler)orinoco_ioctl_setsens),
  1101. IW_HANDLER(SIOCGIWSENS, (iw_handler)orinoco_ioctl_getsens),
  1102. IW_HANDLER(SIOCGIWRANGE, (iw_handler)cfg80211_wext_giwrange),
  1103. IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy),
  1104. IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy),
  1105. IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy),
  1106. IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy),
  1107. IW_HANDLER(SIOCSIWAP, (iw_handler)orinoco_ioctl_setwap),
  1108. IW_HANDLER(SIOCGIWAP, (iw_handler)orinoco_ioctl_getwap),
  1109. IW_HANDLER(SIOCSIWSCAN, (iw_handler)cfg80211_wext_siwscan),
  1110. IW_HANDLER(SIOCGIWSCAN, (iw_handler)cfg80211_wext_giwscan),
  1111. IW_HANDLER(SIOCSIWESSID, (iw_handler)orinoco_ioctl_setessid),
  1112. IW_HANDLER(SIOCGIWESSID, (iw_handler)orinoco_ioctl_getessid),
  1113. IW_HANDLER(SIOCSIWRATE, (iw_handler)orinoco_ioctl_setrate),
  1114. IW_HANDLER(SIOCGIWRATE, (iw_handler)orinoco_ioctl_getrate),
  1115. IW_HANDLER(SIOCSIWRTS, (iw_handler)cfg80211_wext_siwrts),
  1116. IW_HANDLER(SIOCGIWRTS, (iw_handler)cfg80211_wext_giwrts),
  1117. IW_HANDLER(SIOCSIWFRAG, (iw_handler)cfg80211_wext_siwfrag),
  1118. IW_HANDLER(SIOCGIWFRAG, (iw_handler)cfg80211_wext_giwfrag),
  1119. IW_HANDLER(SIOCGIWRETRY, (iw_handler)cfg80211_wext_giwretry),
  1120. IW_HANDLER(SIOCSIWENCODE, (iw_handler)orinoco_ioctl_setiwencode),
  1121. IW_HANDLER(SIOCGIWENCODE, (iw_handler)orinoco_ioctl_getiwencode),
  1122. IW_HANDLER(SIOCSIWPOWER, (iw_handler)orinoco_ioctl_setpower),
  1123. IW_HANDLER(SIOCGIWPOWER, (iw_handler)orinoco_ioctl_getpower),
  1124. IW_HANDLER(SIOCSIWGENIE, orinoco_ioctl_set_genie),
  1125. IW_HANDLER(SIOCGIWGENIE, orinoco_ioctl_get_genie),
  1126. IW_HANDLER(SIOCSIWMLME, orinoco_ioctl_set_mlme),
  1127. IW_HANDLER(SIOCSIWAUTH, orinoco_ioctl_set_auth),
  1128. IW_HANDLER(SIOCGIWAUTH, orinoco_ioctl_get_auth),
  1129. IW_HANDLER(SIOCSIWENCODEEXT, orinoco_ioctl_set_encodeext),
  1130. IW_HANDLER(SIOCGIWENCODEEXT, orinoco_ioctl_get_encodeext),
  1131. };
  1132. /*
  1133. Added typecasting since we no longer use iwreq_data -- Moustafa
  1134. */
  1135. static const iw_handler orinoco_private_handler[] = {
  1136. [0] = (iw_handler)orinoco_ioctl_reset,
  1137. [1] = (iw_handler)orinoco_ioctl_reset,
  1138. [2] = (iw_handler)orinoco_ioctl_setport3,
  1139. [3] = (iw_handler)orinoco_ioctl_getport3,
  1140. [4] = (iw_handler)orinoco_ioctl_setpreamble,
  1141. [5] = (iw_handler)orinoco_ioctl_getpreamble,
  1142. [6] = (iw_handler)orinoco_ioctl_setibssport,
  1143. [7] = (iw_handler)orinoco_ioctl_getibssport,
  1144. [9] = (iw_handler)orinoco_ioctl_getrid,
  1145. };
  1146. const struct iw_handler_def orinoco_handler_def = {
  1147. .num_standard = ARRAY_SIZE(orinoco_handler),
  1148. .num_private = ARRAY_SIZE(orinoco_private_handler),
  1149. .num_private_args = ARRAY_SIZE(orinoco_privtab),
  1150. .standard = orinoco_handler,
  1151. .private = orinoco_private_handler,
  1152. .private_args = orinoco_privtab,
  1153. .get_wireless_stats = orinoco_get_wireless_stats,
  1154. };