wext.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413
  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 <linux/etherdevice.h>
  11. #include <net/iw_handler.h>
  12. #include <net/cfg80211.h>
  13. #include <net/cfg80211-wext.h>
  14. #include "hermes.h"
  15. #include "hermes_rid.h"
  16. #include "orinoco.h"
  17. #include "hw.h"
  18. #include "mic.h"
  19. #include "scan.h"
  20. #include "main.h"
  21. #include "wext.h"
  22. #define MAX_RID_LEN 1024
  23. /* Helper routine to record keys
  24. * It is called under orinoco_lock so it may not sleep */
  25. static int orinoco_set_key(struct orinoco_private *priv, int index,
  26. enum orinoco_alg alg, const u8 *key, int key_len,
  27. const u8 *seq, int seq_len)
  28. {
  29. kzfree(priv->keys[index].key);
  30. kzfree(priv->keys[index].seq);
  31. if (key_len) {
  32. priv->keys[index].key = kzalloc(key_len, GFP_ATOMIC);
  33. if (!priv->keys[index].key)
  34. goto nomem;
  35. } else
  36. priv->keys[index].key = NULL;
  37. if (seq_len) {
  38. priv->keys[index].seq = kzalloc(seq_len, GFP_ATOMIC);
  39. if (!priv->keys[index].seq)
  40. goto free_key;
  41. } else
  42. priv->keys[index].seq = NULL;
  43. priv->keys[index].key_len = key_len;
  44. priv->keys[index].seq_len = seq_len;
  45. if (key_len)
  46. memcpy((void *)priv->keys[index].key, key, key_len);
  47. if (seq_len)
  48. memcpy((void *)priv->keys[index].seq, seq, seq_len);
  49. switch (alg) {
  50. case ORINOCO_ALG_TKIP:
  51. priv->keys[index].cipher = WLAN_CIPHER_SUITE_TKIP;
  52. break;
  53. case ORINOCO_ALG_WEP:
  54. priv->keys[index].cipher = (key_len > SMALL_KEY_SIZE) ?
  55. WLAN_CIPHER_SUITE_WEP104 : WLAN_CIPHER_SUITE_WEP40;
  56. break;
  57. case ORINOCO_ALG_NONE:
  58. default:
  59. priv->keys[index].cipher = 0;
  60. break;
  61. }
  62. return 0;
  63. free_key:
  64. kfree(priv->keys[index].key);
  65. priv->keys[index].key = NULL;
  66. nomem:
  67. priv->keys[index].key_len = 0;
  68. priv->keys[index].seq_len = 0;
  69. priv->keys[index].cipher = 0;
  70. return -ENOMEM;
  71. }
  72. static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev)
  73. {
  74. struct orinoco_private *priv = ndev_priv(dev);
  75. struct hermes *hw = &priv->hw;
  76. struct iw_statistics *wstats = &priv->wstats;
  77. int err;
  78. unsigned long flags;
  79. if (!netif_device_present(dev)) {
  80. printk(KERN_WARNING "%s: get_wireless_stats() called while device not present\n",
  81. dev->name);
  82. return NULL; /* FIXME: Can we do better than this? */
  83. }
  84. /* If busy, return the old stats. Returning NULL may cause
  85. * the interface to disappear from /proc/net/wireless */
  86. if (orinoco_lock(priv, &flags) != 0)
  87. return wstats;
  88. /* We can't really wait for the tallies inquiry command to
  89. * complete, so we just use the previous results and trigger
  90. * a new tallies inquiry command for next time - Jean II */
  91. /* FIXME: Really we should wait for the inquiry to come back -
  92. * as it is the stats we give don't make a whole lot of sense.
  93. * Unfortunately, it's not clear how to do that within the
  94. * wireless extensions framework: I think we're in user
  95. * context, but a lock seems to be held by the time we get in
  96. * here so we're not safe to sleep here. */
  97. hermes_inquire(hw, HERMES_INQ_TALLIES);
  98. if (priv->iw_mode == NL80211_IFTYPE_ADHOC) {
  99. memset(&wstats->qual, 0, sizeof(wstats->qual));
  100. /* If a spy address is defined, we report stats of the
  101. * first spy address - Jean II */
  102. if (SPY_NUMBER(priv)) {
  103. wstats->qual.qual = priv->spy_data.spy_stat[0].qual;
  104. wstats->qual.level = priv->spy_data.spy_stat[0].level;
  105. wstats->qual.noise = priv->spy_data.spy_stat[0].noise;
  106. wstats->qual.updated =
  107. priv->spy_data.spy_stat[0].updated;
  108. }
  109. } else {
  110. struct {
  111. __le16 qual, signal, noise, unused;
  112. } __packed cq;
  113. err = HERMES_READ_RECORD(hw, USER_BAP,
  114. HERMES_RID_COMMSQUALITY, &cq);
  115. if (!err) {
  116. wstats->qual.qual = (int)le16_to_cpu(cq.qual);
  117. wstats->qual.level = (int)le16_to_cpu(cq.signal) - 0x95;
  118. wstats->qual.noise = (int)le16_to_cpu(cq.noise) - 0x95;
  119. wstats->qual.updated =
  120. IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
  121. }
  122. }
  123. orinoco_unlock(priv, &flags);
  124. return wstats;
  125. }
  126. /********************************************************************/
  127. /* Wireless extensions */
  128. /********************************************************************/
  129. static int orinoco_ioctl_setwap(struct net_device *dev,
  130. struct iw_request_info *info,
  131. struct sockaddr *ap_addr,
  132. char *extra)
  133. {
  134. struct orinoco_private *priv = ndev_priv(dev);
  135. int err = -EINPROGRESS; /* Call commit handler */
  136. unsigned long flags;
  137. if (orinoco_lock(priv, &flags) != 0)
  138. return -EBUSY;
  139. /* Enable automatic roaming - no sanity checks are needed */
  140. if (is_zero_ether_addr(ap_addr->sa_data) ||
  141. is_broadcast_ether_addr(ap_addr->sa_data)) {
  142. priv->bssid_fixed = 0;
  143. eth_zero_addr(priv->desired_bssid);
  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_frequency_to_channel(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. struct hermes *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. struct hermes *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. int act_bitrate;
  485. int lerr;
  486. /* Ignore errors if we can't get the actual bitrate */
  487. lerr = orinoco_hw_get_act_bitrate(priv, &act_bitrate);
  488. if (!lerr)
  489. bitrate = act_bitrate;
  490. }
  491. orinoco_unlock(priv, &flags);
  492. rrq->value = bitrate;
  493. rrq->fixed = !automatic;
  494. rrq->disabled = 0;
  495. return err;
  496. }
  497. static int orinoco_ioctl_setpower(struct net_device *dev,
  498. struct iw_request_info *info,
  499. struct iw_param *prq,
  500. char *extra)
  501. {
  502. struct orinoco_private *priv = ndev_priv(dev);
  503. int err = -EINPROGRESS; /* Call commit handler */
  504. unsigned long flags;
  505. if (orinoco_lock(priv, &flags) != 0)
  506. return -EBUSY;
  507. if (prq->disabled) {
  508. priv->pm_on = 0;
  509. } else {
  510. switch (prq->flags & IW_POWER_MODE) {
  511. case IW_POWER_UNICAST_R:
  512. priv->pm_mcast = 0;
  513. priv->pm_on = 1;
  514. break;
  515. case IW_POWER_ALL_R:
  516. priv->pm_mcast = 1;
  517. priv->pm_on = 1;
  518. break;
  519. case IW_POWER_ON:
  520. /* No flags : but we may have a value - Jean II */
  521. break;
  522. default:
  523. err = -EINVAL;
  524. goto out;
  525. }
  526. if (prq->flags & IW_POWER_TIMEOUT) {
  527. priv->pm_on = 1;
  528. priv->pm_timeout = prq->value / 1000;
  529. }
  530. if (prq->flags & IW_POWER_PERIOD) {
  531. priv->pm_on = 1;
  532. priv->pm_period = prq->value / 1000;
  533. }
  534. /* It's valid to not have a value if we are just toggling
  535. * the flags... Jean II */
  536. if (!priv->pm_on) {
  537. err = -EINVAL;
  538. goto out;
  539. }
  540. }
  541. out:
  542. orinoco_unlock(priv, &flags);
  543. return err;
  544. }
  545. static int orinoco_ioctl_getpower(struct net_device *dev,
  546. struct iw_request_info *info,
  547. struct iw_param *prq,
  548. char *extra)
  549. {
  550. struct orinoco_private *priv = ndev_priv(dev);
  551. struct hermes *hw = &priv->hw;
  552. int err = 0;
  553. u16 enable, period, timeout, mcast;
  554. unsigned long flags;
  555. if (orinoco_lock(priv, &flags) != 0)
  556. return -EBUSY;
  557. err = hermes_read_wordrec(hw, USER_BAP,
  558. HERMES_RID_CNFPMENABLED, &enable);
  559. if (err)
  560. goto out;
  561. err = hermes_read_wordrec(hw, USER_BAP,
  562. HERMES_RID_CNFMAXSLEEPDURATION, &period);
  563. if (err)
  564. goto out;
  565. err = hermes_read_wordrec(hw, USER_BAP,
  566. HERMES_RID_CNFPMHOLDOVERDURATION, &timeout);
  567. if (err)
  568. goto out;
  569. err = hermes_read_wordrec(hw, USER_BAP,
  570. HERMES_RID_CNFMULTICASTRECEIVE, &mcast);
  571. if (err)
  572. goto out;
  573. prq->disabled = !enable;
  574. /* Note : by default, display the period */
  575. if ((prq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
  576. prq->flags = IW_POWER_TIMEOUT;
  577. prq->value = timeout * 1000;
  578. } else {
  579. prq->flags = IW_POWER_PERIOD;
  580. prq->value = period * 1000;
  581. }
  582. if (mcast)
  583. prq->flags |= IW_POWER_ALL_R;
  584. else
  585. prq->flags |= IW_POWER_UNICAST_R;
  586. out:
  587. orinoco_unlock(priv, &flags);
  588. return err;
  589. }
  590. static int orinoco_ioctl_set_encodeext(struct net_device *dev,
  591. struct iw_request_info *info,
  592. union iwreq_data *wrqu,
  593. char *extra)
  594. {
  595. struct orinoco_private *priv = ndev_priv(dev);
  596. struct iw_point *encoding = &wrqu->encoding;
  597. struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  598. int idx, alg = ext->alg, set_key = 1;
  599. unsigned long flags;
  600. int err = -EINVAL;
  601. if (orinoco_lock(priv, &flags) != 0)
  602. return -EBUSY;
  603. /* Determine and validate the key index */
  604. idx = encoding->flags & IW_ENCODE_INDEX;
  605. if (idx) {
  606. if ((idx < 1) || (idx > 4))
  607. goto out;
  608. idx--;
  609. } else
  610. idx = priv->tx_key;
  611. if (encoding->flags & IW_ENCODE_DISABLED)
  612. alg = IW_ENCODE_ALG_NONE;
  613. if (priv->has_wpa && (alg != IW_ENCODE_ALG_TKIP)) {
  614. /* Clear any TKIP TX key we had */
  615. (void) orinoco_clear_tkip_key(priv, priv->tx_key);
  616. }
  617. if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
  618. priv->tx_key = idx;
  619. set_key = ((alg == IW_ENCODE_ALG_TKIP) ||
  620. (ext->key_len > 0)) ? 1 : 0;
  621. }
  622. if (set_key) {
  623. /* Set the requested key first */
  624. switch (alg) {
  625. case IW_ENCODE_ALG_NONE:
  626. priv->encode_alg = ORINOCO_ALG_NONE;
  627. err = orinoco_set_key(priv, idx, ORINOCO_ALG_NONE,
  628. NULL, 0, NULL, 0);
  629. break;
  630. case IW_ENCODE_ALG_WEP:
  631. if (ext->key_len <= 0)
  632. goto out;
  633. priv->encode_alg = ORINOCO_ALG_WEP;
  634. err = orinoco_set_key(priv, idx, ORINOCO_ALG_WEP,
  635. ext->key, ext->key_len, NULL, 0);
  636. break;
  637. case IW_ENCODE_ALG_TKIP:
  638. {
  639. u8 *tkip_iv = NULL;
  640. if (!priv->has_wpa ||
  641. (ext->key_len > sizeof(struct orinoco_tkip_key)))
  642. goto out;
  643. priv->encode_alg = ORINOCO_ALG_TKIP;
  644. if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID)
  645. tkip_iv = &ext->rx_seq[0];
  646. err = orinoco_set_key(priv, idx, ORINOCO_ALG_TKIP,
  647. ext->key, ext->key_len, tkip_iv,
  648. ORINOCO_SEQ_LEN);
  649. err = __orinoco_hw_set_tkip_key(priv, idx,
  650. ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY,
  651. priv->keys[idx].key,
  652. tkip_iv, ORINOCO_SEQ_LEN, NULL, 0);
  653. if (err)
  654. printk(KERN_ERR "%s: Error %d setting TKIP key"
  655. "\n", dev->name, err);
  656. goto out;
  657. }
  658. default:
  659. goto out;
  660. }
  661. }
  662. err = -EINPROGRESS;
  663. out:
  664. orinoco_unlock(priv, &flags);
  665. return err;
  666. }
  667. static int orinoco_ioctl_get_encodeext(struct net_device *dev,
  668. struct iw_request_info *info,
  669. union iwreq_data *wrqu,
  670. char *extra)
  671. {
  672. struct orinoco_private *priv = ndev_priv(dev);
  673. struct iw_point *encoding = &wrqu->encoding;
  674. struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  675. int idx, max_key_len;
  676. unsigned long flags;
  677. int err;
  678. if (orinoco_lock(priv, &flags) != 0)
  679. return -EBUSY;
  680. err = -EINVAL;
  681. max_key_len = encoding->length - sizeof(*ext);
  682. if (max_key_len < 0)
  683. goto out;
  684. idx = encoding->flags & IW_ENCODE_INDEX;
  685. if (idx) {
  686. if ((idx < 1) || (idx > 4))
  687. goto out;
  688. idx--;
  689. } else
  690. idx = priv->tx_key;
  691. encoding->flags = idx + 1;
  692. memset(ext, 0, sizeof(*ext));
  693. switch (priv->encode_alg) {
  694. case ORINOCO_ALG_NONE:
  695. ext->alg = IW_ENCODE_ALG_NONE;
  696. ext->key_len = 0;
  697. encoding->flags |= IW_ENCODE_DISABLED;
  698. break;
  699. case ORINOCO_ALG_WEP:
  700. ext->alg = IW_ENCODE_ALG_WEP;
  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. case ORINOCO_ALG_TKIP:
  706. ext->alg = IW_ENCODE_ALG_TKIP;
  707. ext->key_len = min(priv->keys[idx].key_len, max_key_len);
  708. memcpy(ext->key, priv->keys[idx].key, ext->key_len);
  709. encoding->flags |= IW_ENCODE_ENABLED;
  710. break;
  711. }
  712. err = 0;
  713. out:
  714. orinoco_unlock(priv, &flags);
  715. return err;
  716. }
  717. static int orinoco_ioctl_set_auth(struct net_device *dev,
  718. struct iw_request_info *info,
  719. union iwreq_data *wrqu, char *extra)
  720. {
  721. struct orinoco_private *priv = ndev_priv(dev);
  722. struct hermes *hw = &priv->hw;
  723. struct iw_param *param = &wrqu->param;
  724. unsigned long flags;
  725. int ret = -EINPROGRESS;
  726. if (orinoco_lock(priv, &flags) != 0)
  727. return -EBUSY;
  728. switch (param->flags & IW_AUTH_INDEX) {
  729. case IW_AUTH_WPA_VERSION:
  730. case IW_AUTH_CIPHER_PAIRWISE:
  731. case IW_AUTH_CIPHER_GROUP:
  732. case IW_AUTH_RX_UNENCRYPTED_EAPOL:
  733. case IW_AUTH_PRIVACY_INVOKED:
  734. case IW_AUTH_DROP_UNENCRYPTED:
  735. /*
  736. * orinoco does not use these parameters
  737. */
  738. break;
  739. case IW_AUTH_MFP:
  740. /* Management Frame Protection not supported.
  741. * Only fail if set to required.
  742. */
  743. if (param->value == IW_AUTH_MFP_REQUIRED)
  744. ret = -EINVAL;
  745. break;
  746. case IW_AUTH_KEY_MGMT:
  747. /* wl_lkm implies value 2 == PSK for Hermes I
  748. * which ties in with WEXT
  749. * no other hints tho :(
  750. */
  751. priv->key_mgmt = param->value;
  752. break;
  753. case IW_AUTH_TKIP_COUNTERMEASURES:
  754. /* When countermeasures are enabled, shut down the
  755. * card; when disabled, re-enable the card. This must
  756. * take effect immediately.
  757. *
  758. * TODO: Make sure that the EAPOL message is getting
  759. * out before card disabled
  760. */
  761. if (param->value) {
  762. priv->tkip_cm_active = 1;
  763. ret = hermes_disable_port(hw, 0);
  764. } else {
  765. priv->tkip_cm_active = 0;
  766. ret = hermes_enable_port(hw, 0);
  767. }
  768. break;
  769. case IW_AUTH_80211_AUTH_ALG:
  770. if (param->value & IW_AUTH_ALG_SHARED_KEY)
  771. priv->wep_restrict = 1;
  772. else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
  773. priv->wep_restrict = 0;
  774. else
  775. ret = -EINVAL;
  776. break;
  777. case IW_AUTH_WPA_ENABLED:
  778. if (priv->has_wpa) {
  779. priv->wpa_enabled = param->value ? 1 : 0;
  780. } else {
  781. if (param->value)
  782. ret = -EOPNOTSUPP;
  783. /* else silently accept disable of WPA */
  784. priv->wpa_enabled = 0;
  785. }
  786. break;
  787. default:
  788. ret = -EOPNOTSUPP;
  789. }
  790. orinoco_unlock(priv, &flags);
  791. return ret;
  792. }
  793. static int orinoco_ioctl_get_auth(struct net_device *dev,
  794. struct iw_request_info *info,
  795. union iwreq_data *wrqu, char *extra)
  796. {
  797. struct orinoco_private *priv = ndev_priv(dev);
  798. struct iw_param *param = &wrqu->param;
  799. unsigned long flags;
  800. int ret = 0;
  801. if (orinoco_lock(priv, &flags) != 0)
  802. return -EBUSY;
  803. switch (param->flags & IW_AUTH_INDEX) {
  804. case IW_AUTH_KEY_MGMT:
  805. param->value = priv->key_mgmt;
  806. break;
  807. case IW_AUTH_TKIP_COUNTERMEASURES:
  808. param->value = priv->tkip_cm_active;
  809. break;
  810. case IW_AUTH_80211_AUTH_ALG:
  811. if (priv->wep_restrict)
  812. param->value = IW_AUTH_ALG_SHARED_KEY;
  813. else
  814. param->value = IW_AUTH_ALG_OPEN_SYSTEM;
  815. break;
  816. case IW_AUTH_WPA_ENABLED:
  817. param->value = priv->wpa_enabled;
  818. break;
  819. default:
  820. ret = -EOPNOTSUPP;
  821. }
  822. orinoco_unlock(priv, &flags);
  823. return ret;
  824. }
  825. static int orinoco_ioctl_set_genie(struct net_device *dev,
  826. struct iw_request_info *info,
  827. union iwreq_data *wrqu, char *extra)
  828. {
  829. struct orinoco_private *priv = ndev_priv(dev);
  830. u8 *buf;
  831. unsigned long flags;
  832. /* cut off at IEEE80211_MAX_DATA_LEN */
  833. if ((wrqu->data.length > IEEE80211_MAX_DATA_LEN) ||
  834. (wrqu->data.length && (extra == NULL)))
  835. return -EINVAL;
  836. if (wrqu->data.length) {
  837. buf = kmemdup(extra, wrqu->data.length, GFP_KERNEL);
  838. if (buf == NULL)
  839. return -ENOMEM;
  840. } else
  841. buf = NULL;
  842. if (orinoco_lock(priv, &flags) != 0) {
  843. kfree(buf);
  844. return -EBUSY;
  845. }
  846. kfree(priv->wpa_ie);
  847. priv->wpa_ie = buf;
  848. priv->wpa_ie_len = wrqu->data.length;
  849. if (priv->wpa_ie) {
  850. /* Looks like wl_lkm wants to check the auth alg, and
  851. * somehow pass it to the firmware.
  852. * Instead it just calls the key mgmt rid
  853. * - we do this in set auth.
  854. */
  855. }
  856. orinoco_unlock(priv, &flags);
  857. return 0;
  858. }
  859. static int orinoco_ioctl_get_genie(struct net_device *dev,
  860. struct iw_request_info *info,
  861. union iwreq_data *wrqu, char *extra)
  862. {
  863. struct orinoco_private *priv = ndev_priv(dev);
  864. unsigned long flags;
  865. int err = 0;
  866. if (orinoco_lock(priv, &flags) != 0)
  867. return -EBUSY;
  868. if ((priv->wpa_ie_len == 0) || (priv->wpa_ie == NULL)) {
  869. wrqu->data.length = 0;
  870. goto out;
  871. }
  872. if (wrqu->data.length < priv->wpa_ie_len) {
  873. err = -E2BIG;
  874. goto out;
  875. }
  876. wrqu->data.length = priv->wpa_ie_len;
  877. memcpy(extra, priv->wpa_ie, priv->wpa_ie_len);
  878. out:
  879. orinoco_unlock(priv, &flags);
  880. return err;
  881. }
  882. static int orinoco_ioctl_set_mlme(struct net_device *dev,
  883. struct iw_request_info *info,
  884. union iwreq_data *wrqu, char *extra)
  885. {
  886. struct orinoco_private *priv = ndev_priv(dev);
  887. struct iw_mlme *mlme = (struct iw_mlme *)extra;
  888. unsigned long flags;
  889. int ret = 0;
  890. if (orinoco_lock(priv, &flags) != 0)
  891. return -EBUSY;
  892. switch (mlme->cmd) {
  893. case IW_MLME_DEAUTH:
  894. /* silently ignore */
  895. break;
  896. case IW_MLME_DISASSOC:
  897. ret = orinoco_hw_disassociate(priv, mlme->addr.sa_data,
  898. mlme->reason_code);
  899. break;
  900. default:
  901. ret = -EOPNOTSUPP;
  902. }
  903. orinoco_unlock(priv, &flags);
  904. return ret;
  905. }
  906. static int orinoco_ioctl_reset(struct net_device *dev,
  907. struct iw_request_info *info,
  908. void *wrqu,
  909. char *extra)
  910. {
  911. struct orinoco_private *priv = ndev_priv(dev);
  912. if (!capable(CAP_NET_ADMIN))
  913. return -EPERM;
  914. if (info->cmd == (SIOCIWFIRSTPRIV + 0x1)) {
  915. printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name);
  916. /* Firmware reset */
  917. orinoco_reset(&priv->reset_work);
  918. } else {
  919. printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name);
  920. schedule_work(&priv->reset_work);
  921. }
  922. return 0;
  923. }
  924. static int orinoco_ioctl_setibssport(struct net_device *dev,
  925. struct iw_request_info *info,
  926. void *wrqu,
  927. char *extra)
  928. {
  929. struct orinoco_private *priv = ndev_priv(dev);
  930. int val = *((int *) extra);
  931. unsigned long flags;
  932. if (orinoco_lock(priv, &flags) != 0)
  933. return -EBUSY;
  934. priv->ibss_port = val;
  935. /* Actually update the mode we are using */
  936. set_port_type(priv);
  937. orinoco_unlock(priv, &flags);
  938. return -EINPROGRESS; /* Call commit handler */
  939. }
  940. static int orinoco_ioctl_getibssport(struct net_device *dev,
  941. struct iw_request_info *info,
  942. void *wrqu,
  943. char *extra)
  944. {
  945. struct orinoco_private *priv = ndev_priv(dev);
  946. int *val = (int *) extra;
  947. *val = priv->ibss_port;
  948. return 0;
  949. }
  950. static int orinoco_ioctl_setport3(struct net_device *dev,
  951. struct iw_request_info *info,
  952. void *wrqu,
  953. char *extra)
  954. {
  955. struct orinoco_private *priv = ndev_priv(dev);
  956. int val = *((int *) extra);
  957. int err = 0;
  958. unsigned long flags;
  959. if (orinoco_lock(priv, &flags) != 0)
  960. return -EBUSY;
  961. switch (val) {
  962. case 0: /* Try to do IEEE ad-hoc mode */
  963. if (!priv->has_ibss) {
  964. err = -EINVAL;
  965. break;
  966. }
  967. priv->prefer_port3 = 0;
  968. break;
  969. case 1: /* Try to do Lucent proprietary ad-hoc mode */
  970. if (!priv->has_port3) {
  971. err = -EINVAL;
  972. break;
  973. }
  974. priv->prefer_port3 = 1;
  975. break;
  976. default:
  977. err = -EINVAL;
  978. }
  979. if (!err) {
  980. /* Actually update the mode we are using */
  981. set_port_type(priv);
  982. err = -EINPROGRESS;
  983. }
  984. orinoco_unlock(priv, &flags);
  985. return err;
  986. }
  987. static int orinoco_ioctl_getport3(struct net_device *dev,
  988. struct iw_request_info *info,
  989. void *wrqu,
  990. char *extra)
  991. {
  992. struct orinoco_private *priv = ndev_priv(dev);
  993. int *val = (int *) extra;
  994. *val = priv->prefer_port3;
  995. return 0;
  996. }
  997. static int orinoco_ioctl_setpreamble(struct net_device *dev,
  998. struct iw_request_info *info,
  999. void *wrqu,
  1000. char *extra)
  1001. {
  1002. struct orinoco_private *priv = ndev_priv(dev);
  1003. unsigned long flags;
  1004. int val;
  1005. if (!priv->has_preamble)
  1006. return -EOPNOTSUPP;
  1007. /* 802.11b has recently defined some short preamble.
  1008. * Basically, the Phy header has been reduced in size.
  1009. * This increase performance, especially at high rates
  1010. * (the preamble is transmitted at 1Mb/s), unfortunately
  1011. * this give compatibility troubles... - Jean II */
  1012. val = *((int *) extra);
  1013. if (orinoco_lock(priv, &flags) != 0)
  1014. return -EBUSY;
  1015. if (val)
  1016. priv->preamble = 1;
  1017. else
  1018. priv->preamble = 0;
  1019. orinoco_unlock(priv, &flags);
  1020. return -EINPROGRESS; /* Call commit handler */
  1021. }
  1022. static int orinoco_ioctl_getpreamble(struct net_device *dev,
  1023. struct iw_request_info *info,
  1024. void *wrqu,
  1025. char *extra)
  1026. {
  1027. struct orinoco_private *priv = ndev_priv(dev);
  1028. int *val = (int *) extra;
  1029. if (!priv->has_preamble)
  1030. return -EOPNOTSUPP;
  1031. *val = priv->preamble;
  1032. return 0;
  1033. }
  1034. /* ioctl interface to hermes_read_ltv()
  1035. * To use with iwpriv, pass the RID as the token argument, e.g.
  1036. * iwpriv get_rid [0xfc00]
  1037. * At least Wireless Tools 25 is required to use iwpriv.
  1038. * For Wireless Tools 25 and 26 append "dummy" are the end. */
  1039. static int orinoco_ioctl_getrid(struct net_device *dev,
  1040. struct iw_request_info *info,
  1041. struct iw_point *data,
  1042. char *extra)
  1043. {
  1044. struct orinoco_private *priv = ndev_priv(dev);
  1045. struct hermes *hw = &priv->hw;
  1046. int rid = data->flags;
  1047. u16 length;
  1048. int err;
  1049. unsigned long flags;
  1050. /* It's a "get" function, but we don't want users to access the
  1051. * WEP key and other raw firmware data */
  1052. if (!capable(CAP_NET_ADMIN))
  1053. return -EPERM;
  1054. if (rid < 0xfc00 || rid > 0xffff)
  1055. return -EINVAL;
  1056. if (orinoco_lock(priv, &flags) != 0)
  1057. return -EBUSY;
  1058. err = hw->ops->read_ltv(hw, USER_BAP, rid, MAX_RID_LEN, &length,
  1059. extra);
  1060. if (err)
  1061. goto out;
  1062. data->length = min_t(u16, HERMES_RECLEN_TO_BYTES(length),
  1063. MAX_RID_LEN);
  1064. out:
  1065. orinoco_unlock(priv, &flags);
  1066. return err;
  1067. }
  1068. /* Commit handler, called after set operations */
  1069. static int orinoco_ioctl_commit(struct net_device *dev,
  1070. struct iw_request_info *info,
  1071. void *wrqu,
  1072. char *extra)
  1073. {
  1074. struct orinoco_private *priv = ndev_priv(dev);
  1075. unsigned long flags;
  1076. int err = 0;
  1077. if (!priv->open)
  1078. return 0;
  1079. if (orinoco_lock(priv, &flags) != 0)
  1080. return err;
  1081. err = orinoco_commit(priv);
  1082. orinoco_unlock(priv, &flags);
  1083. return err;
  1084. }
  1085. static const struct iw_priv_args orinoco_privtab[] = {
  1086. { SIOCIWFIRSTPRIV + 0x0, 0, 0, "force_reset" },
  1087. { SIOCIWFIRSTPRIV + 0x1, 0, 0, "card_reset" },
  1088. { SIOCIWFIRSTPRIV + 0x2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1089. 0, "set_port3" },
  1090. { SIOCIWFIRSTPRIV + 0x3, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1091. "get_port3" },
  1092. { SIOCIWFIRSTPRIV + 0x4, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1093. 0, "set_preamble" },
  1094. { SIOCIWFIRSTPRIV + 0x5, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1095. "get_preamble" },
  1096. { SIOCIWFIRSTPRIV + 0x6, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1097. 0, "set_ibssport" },
  1098. { SIOCIWFIRSTPRIV + 0x7, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1099. "get_ibssport" },
  1100. { SIOCIWFIRSTPRIV + 0x9, 0, IW_PRIV_TYPE_BYTE | MAX_RID_LEN,
  1101. "get_rid" },
  1102. };
  1103. /*
  1104. * Structures to export the Wireless Handlers
  1105. */
  1106. static const iw_handler orinoco_handler[] = {
  1107. IW_HANDLER(SIOCSIWCOMMIT, (iw_handler)orinoco_ioctl_commit),
  1108. IW_HANDLER(SIOCGIWNAME, (iw_handler)cfg80211_wext_giwname),
  1109. IW_HANDLER(SIOCSIWFREQ, (iw_handler)orinoco_ioctl_setfreq),
  1110. IW_HANDLER(SIOCGIWFREQ, (iw_handler)orinoco_ioctl_getfreq),
  1111. IW_HANDLER(SIOCSIWMODE, (iw_handler)cfg80211_wext_siwmode),
  1112. IW_HANDLER(SIOCGIWMODE, (iw_handler)cfg80211_wext_giwmode),
  1113. IW_HANDLER(SIOCSIWSENS, (iw_handler)orinoco_ioctl_setsens),
  1114. IW_HANDLER(SIOCGIWSENS, (iw_handler)orinoco_ioctl_getsens),
  1115. IW_HANDLER(SIOCGIWRANGE, (iw_handler)cfg80211_wext_giwrange),
  1116. IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy),
  1117. IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy),
  1118. IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy),
  1119. IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy),
  1120. IW_HANDLER(SIOCSIWAP, (iw_handler)orinoco_ioctl_setwap),
  1121. IW_HANDLER(SIOCGIWAP, (iw_handler)orinoco_ioctl_getwap),
  1122. IW_HANDLER(SIOCSIWSCAN, (iw_handler)cfg80211_wext_siwscan),
  1123. IW_HANDLER(SIOCGIWSCAN, (iw_handler)cfg80211_wext_giwscan),
  1124. IW_HANDLER(SIOCSIWESSID, (iw_handler)orinoco_ioctl_setessid),
  1125. IW_HANDLER(SIOCGIWESSID, (iw_handler)orinoco_ioctl_getessid),
  1126. IW_HANDLER(SIOCSIWRATE, (iw_handler)orinoco_ioctl_setrate),
  1127. IW_HANDLER(SIOCGIWRATE, (iw_handler)orinoco_ioctl_getrate),
  1128. IW_HANDLER(SIOCSIWRTS, (iw_handler)cfg80211_wext_siwrts),
  1129. IW_HANDLER(SIOCGIWRTS, (iw_handler)cfg80211_wext_giwrts),
  1130. IW_HANDLER(SIOCSIWFRAG, (iw_handler)cfg80211_wext_siwfrag),
  1131. IW_HANDLER(SIOCGIWFRAG, (iw_handler)cfg80211_wext_giwfrag),
  1132. IW_HANDLER(SIOCGIWRETRY, (iw_handler)cfg80211_wext_giwretry),
  1133. IW_HANDLER(SIOCSIWENCODE, (iw_handler)orinoco_ioctl_setiwencode),
  1134. IW_HANDLER(SIOCGIWENCODE, (iw_handler)orinoco_ioctl_getiwencode),
  1135. IW_HANDLER(SIOCSIWPOWER, (iw_handler)orinoco_ioctl_setpower),
  1136. IW_HANDLER(SIOCGIWPOWER, (iw_handler)orinoco_ioctl_getpower),
  1137. IW_HANDLER(SIOCSIWGENIE, orinoco_ioctl_set_genie),
  1138. IW_HANDLER(SIOCGIWGENIE, orinoco_ioctl_get_genie),
  1139. IW_HANDLER(SIOCSIWMLME, orinoco_ioctl_set_mlme),
  1140. IW_HANDLER(SIOCSIWAUTH, orinoco_ioctl_set_auth),
  1141. IW_HANDLER(SIOCGIWAUTH, orinoco_ioctl_get_auth),
  1142. IW_HANDLER(SIOCSIWENCODEEXT, orinoco_ioctl_set_encodeext),
  1143. IW_HANDLER(SIOCGIWENCODEEXT, orinoco_ioctl_get_encodeext),
  1144. };
  1145. /*
  1146. Added typecasting since we no longer use iwreq_data -- Moustafa
  1147. */
  1148. static const iw_handler orinoco_private_handler[] = {
  1149. [0] = (iw_handler)orinoco_ioctl_reset,
  1150. [1] = (iw_handler)orinoco_ioctl_reset,
  1151. [2] = (iw_handler)orinoco_ioctl_setport3,
  1152. [3] = (iw_handler)orinoco_ioctl_getport3,
  1153. [4] = (iw_handler)orinoco_ioctl_setpreamble,
  1154. [5] = (iw_handler)orinoco_ioctl_getpreamble,
  1155. [6] = (iw_handler)orinoco_ioctl_setibssport,
  1156. [7] = (iw_handler)orinoco_ioctl_getibssport,
  1157. [9] = (iw_handler)orinoco_ioctl_getrid,
  1158. };
  1159. const struct iw_handler_def orinoco_handler_def = {
  1160. .num_standard = ARRAY_SIZE(orinoco_handler),
  1161. .num_private = ARRAY_SIZE(orinoco_private_handler),
  1162. .num_private_args = ARRAY_SIZE(orinoco_privtab),
  1163. .standard = orinoco_handler,
  1164. .private = orinoco_private_handler,
  1165. .private_args = orinoco_privtab,
  1166. .get_wireless_stats = orinoco_get_wireless_stats,
  1167. };