wext.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400
  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. } __attribute__ ((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 = kmalloc(wrqu->data.length, GFP_KERNEL);
  825. if (buf == NULL)
  826. return -ENOMEM;
  827. memcpy(buf, extra, wrqu->data.length);
  828. } else
  829. buf = NULL;
  830. if (orinoco_lock(priv, &flags) != 0) {
  831. kfree(buf);
  832. return -EBUSY;
  833. }
  834. kfree(priv->wpa_ie);
  835. priv->wpa_ie = buf;
  836. priv->wpa_ie_len = wrqu->data.length;
  837. if (priv->wpa_ie) {
  838. /* Looks like wl_lkm wants to check the auth alg, and
  839. * somehow pass it to the firmware.
  840. * Instead it just calls the key mgmt rid
  841. * - we do this in set auth.
  842. */
  843. }
  844. orinoco_unlock(priv, &flags);
  845. return 0;
  846. }
  847. static int orinoco_ioctl_get_genie(struct net_device *dev,
  848. struct iw_request_info *info,
  849. union iwreq_data *wrqu, char *extra)
  850. {
  851. struct orinoco_private *priv = ndev_priv(dev);
  852. unsigned long flags;
  853. int err = 0;
  854. if (orinoco_lock(priv, &flags) != 0)
  855. return -EBUSY;
  856. if ((priv->wpa_ie_len == 0) || (priv->wpa_ie == NULL)) {
  857. wrqu->data.length = 0;
  858. goto out;
  859. }
  860. if (wrqu->data.length < priv->wpa_ie_len) {
  861. err = -E2BIG;
  862. goto out;
  863. }
  864. wrqu->data.length = priv->wpa_ie_len;
  865. memcpy(extra, priv->wpa_ie, priv->wpa_ie_len);
  866. out:
  867. orinoco_unlock(priv, &flags);
  868. return err;
  869. }
  870. static int orinoco_ioctl_set_mlme(struct net_device *dev,
  871. struct iw_request_info *info,
  872. union iwreq_data *wrqu, char *extra)
  873. {
  874. struct orinoco_private *priv = ndev_priv(dev);
  875. struct iw_mlme *mlme = (struct iw_mlme *)extra;
  876. unsigned long flags;
  877. int ret = 0;
  878. if (orinoco_lock(priv, &flags) != 0)
  879. return -EBUSY;
  880. switch (mlme->cmd) {
  881. case IW_MLME_DEAUTH:
  882. /* silently ignore */
  883. break;
  884. case IW_MLME_DISASSOC:
  885. ret = orinoco_hw_disassociate(priv, mlme->addr.sa_data,
  886. mlme->reason_code);
  887. break;
  888. default:
  889. ret = -EOPNOTSUPP;
  890. }
  891. orinoco_unlock(priv, &flags);
  892. return ret;
  893. }
  894. static int orinoco_ioctl_reset(struct net_device *dev,
  895. struct iw_request_info *info,
  896. void *wrqu,
  897. char *extra)
  898. {
  899. struct orinoco_private *priv = ndev_priv(dev);
  900. if (!capable(CAP_NET_ADMIN))
  901. return -EPERM;
  902. if (info->cmd == (SIOCIWFIRSTPRIV + 0x1)) {
  903. printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name);
  904. /* Firmware reset */
  905. orinoco_reset(&priv->reset_work);
  906. } else {
  907. printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name);
  908. schedule_work(&priv->reset_work);
  909. }
  910. return 0;
  911. }
  912. static int orinoco_ioctl_setibssport(struct net_device *dev,
  913. struct iw_request_info *info,
  914. void *wrqu,
  915. char *extra)
  916. {
  917. struct orinoco_private *priv = ndev_priv(dev);
  918. int val = *((int *) extra);
  919. unsigned long flags;
  920. if (orinoco_lock(priv, &flags) != 0)
  921. return -EBUSY;
  922. priv->ibss_port = val;
  923. /* Actually update the mode we are using */
  924. set_port_type(priv);
  925. orinoco_unlock(priv, &flags);
  926. return -EINPROGRESS; /* Call commit handler */
  927. }
  928. static int orinoco_ioctl_getibssport(struct net_device *dev,
  929. struct iw_request_info *info,
  930. void *wrqu,
  931. char *extra)
  932. {
  933. struct orinoco_private *priv = ndev_priv(dev);
  934. int *val = (int *) extra;
  935. *val = priv->ibss_port;
  936. return 0;
  937. }
  938. static int orinoco_ioctl_setport3(struct net_device *dev,
  939. struct iw_request_info *info,
  940. void *wrqu,
  941. char *extra)
  942. {
  943. struct orinoco_private *priv = ndev_priv(dev);
  944. int val = *((int *) extra);
  945. int err = 0;
  946. unsigned long flags;
  947. if (orinoco_lock(priv, &flags) != 0)
  948. return -EBUSY;
  949. switch (val) {
  950. case 0: /* Try to do IEEE ad-hoc mode */
  951. if (!priv->has_ibss) {
  952. err = -EINVAL;
  953. break;
  954. }
  955. priv->prefer_port3 = 0;
  956. break;
  957. case 1: /* Try to do Lucent proprietary ad-hoc mode */
  958. if (!priv->has_port3) {
  959. err = -EINVAL;
  960. break;
  961. }
  962. priv->prefer_port3 = 1;
  963. break;
  964. default:
  965. err = -EINVAL;
  966. }
  967. if (!err) {
  968. /* Actually update the mode we are using */
  969. set_port_type(priv);
  970. err = -EINPROGRESS;
  971. }
  972. orinoco_unlock(priv, &flags);
  973. return err;
  974. }
  975. static int orinoco_ioctl_getport3(struct net_device *dev,
  976. struct iw_request_info *info,
  977. void *wrqu,
  978. char *extra)
  979. {
  980. struct orinoco_private *priv = ndev_priv(dev);
  981. int *val = (int *) extra;
  982. *val = priv->prefer_port3;
  983. return 0;
  984. }
  985. static int orinoco_ioctl_setpreamble(struct net_device *dev,
  986. struct iw_request_info *info,
  987. void *wrqu,
  988. char *extra)
  989. {
  990. struct orinoco_private *priv = ndev_priv(dev);
  991. unsigned long flags;
  992. int val;
  993. if (!priv->has_preamble)
  994. return -EOPNOTSUPP;
  995. /* 802.11b has recently defined some short preamble.
  996. * Basically, the Phy header has been reduced in size.
  997. * This increase performance, especially at high rates
  998. * (the preamble is transmitted at 1Mb/s), unfortunately
  999. * this give compatibility troubles... - Jean II */
  1000. val = *((int *) extra);
  1001. if (orinoco_lock(priv, &flags) != 0)
  1002. return -EBUSY;
  1003. if (val)
  1004. priv->preamble = 1;
  1005. else
  1006. priv->preamble = 0;
  1007. orinoco_unlock(priv, &flags);
  1008. return -EINPROGRESS; /* Call commit handler */
  1009. }
  1010. static int orinoco_ioctl_getpreamble(struct net_device *dev,
  1011. struct iw_request_info *info,
  1012. void *wrqu,
  1013. char *extra)
  1014. {
  1015. struct orinoco_private *priv = ndev_priv(dev);
  1016. int *val = (int *) extra;
  1017. if (!priv->has_preamble)
  1018. return -EOPNOTSUPP;
  1019. *val = priv->preamble;
  1020. return 0;
  1021. }
  1022. /* ioctl interface to hermes_read_ltv()
  1023. * To use with iwpriv, pass the RID as the token argument, e.g.
  1024. * iwpriv get_rid [0xfc00]
  1025. * At least Wireless Tools 25 is required to use iwpriv.
  1026. * For Wireless Tools 25 and 26 append "dummy" are the end. */
  1027. static int orinoco_ioctl_getrid(struct net_device *dev,
  1028. struct iw_request_info *info,
  1029. struct iw_point *data,
  1030. char *extra)
  1031. {
  1032. struct orinoco_private *priv = ndev_priv(dev);
  1033. hermes_t *hw = &priv->hw;
  1034. int rid = data->flags;
  1035. u16 length;
  1036. int err;
  1037. unsigned long flags;
  1038. /* It's a "get" function, but we don't want users to access the
  1039. * WEP key and other raw firmware data */
  1040. if (!capable(CAP_NET_ADMIN))
  1041. return -EPERM;
  1042. if (rid < 0xfc00 || rid > 0xffff)
  1043. return -EINVAL;
  1044. if (orinoco_lock(priv, &flags) != 0)
  1045. return -EBUSY;
  1046. err = hw->ops->read_ltv(hw, USER_BAP, rid, MAX_RID_LEN, &length,
  1047. extra);
  1048. if (err)
  1049. goto out;
  1050. data->length = min_t(u16, HERMES_RECLEN_TO_BYTES(length),
  1051. MAX_RID_LEN);
  1052. out:
  1053. orinoco_unlock(priv, &flags);
  1054. return err;
  1055. }
  1056. /* Commit handler, called after set operations */
  1057. static int orinoco_ioctl_commit(struct net_device *dev,
  1058. struct iw_request_info *info,
  1059. void *wrqu,
  1060. char *extra)
  1061. {
  1062. struct orinoco_private *priv = ndev_priv(dev);
  1063. unsigned long flags;
  1064. int err = 0;
  1065. if (!priv->open)
  1066. return 0;
  1067. if (orinoco_lock(priv, &flags) != 0)
  1068. return err;
  1069. err = orinoco_commit(priv);
  1070. orinoco_unlock(priv, &flags);
  1071. return err;
  1072. }
  1073. static const struct iw_priv_args orinoco_privtab[] = {
  1074. { SIOCIWFIRSTPRIV + 0x0, 0, 0, "force_reset" },
  1075. { SIOCIWFIRSTPRIV + 0x1, 0, 0, "card_reset" },
  1076. { SIOCIWFIRSTPRIV + 0x2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1077. 0, "set_port3" },
  1078. { SIOCIWFIRSTPRIV + 0x3, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1079. "get_port3" },
  1080. { SIOCIWFIRSTPRIV + 0x4, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1081. 0, "set_preamble" },
  1082. { SIOCIWFIRSTPRIV + 0x5, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1083. "get_preamble" },
  1084. { SIOCIWFIRSTPRIV + 0x6, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1085. 0, "set_ibssport" },
  1086. { SIOCIWFIRSTPRIV + 0x7, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  1087. "get_ibssport" },
  1088. { SIOCIWFIRSTPRIV + 0x9, 0, IW_PRIV_TYPE_BYTE | MAX_RID_LEN,
  1089. "get_rid" },
  1090. };
  1091. /*
  1092. * Structures to export the Wireless Handlers
  1093. */
  1094. static const iw_handler orinoco_handler[] = {
  1095. IW_HANDLER(SIOCSIWCOMMIT, (iw_handler)orinoco_ioctl_commit),
  1096. IW_HANDLER(SIOCGIWNAME, (iw_handler)cfg80211_wext_giwname),
  1097. IW_HANDLER(SIOCSIWFREQ, (iw_handler)orinoco_ioctl_setfreq),
  1098. IW_HANDLER(SIOCGIWFREQ, (iw_handler)orinoco_ioctl_getfreq),
  1099. IW_HANDLER(SIOCSIWMODE, (iw_handler)cfg80211_wext_siwmode),
  1100. IW_HANDLER(SIOCGIWMODE, (iw_handler)cfg80211_wext_giwmode),
  1101. IW_HANDLER(SIOCSIWSENS, (iw_handler)orinoco_ioctl_setsens),
  1102. IW_HANDLER(SIOCGIWSENS, (iw_handler)orinoco_ioctl_getsens),
  1103. IW_HANDLER(SIOCGIWRANGE, (iw_handler)cfg80211_wext_giwrange),
  1104. IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy),
  1105. IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy),
  1106. IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy),
  1107. IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy),
  1108. IW_HANDLER(SIOCSIWAP, (iw_handler)orinoco_ioctl_setwap),
  1109. IW_HANDLER(SIOCGIWAP, (iw_handler)orinoco_ioctl_getwap),
  1110. IW_HANDLER(SIOCSIWSCAN, (iw_handler)cfg80211_wext_siwscan),
  1111. IW_HANDLER(SIOCGIWSCAN, (iw_handler)cfg80211_wext_giwscan),
  1112. IW_HANDLER(SIOCSIWESSID, (iw_handler)orinoco_ioctl_setessid),
  1113. IW_HANDLER(SIOCGIWESSID, (iw_handler)orinoco_ioctl_getessid),
  1114. IW_HANDLER(SIOCSIWRATE, (iw_handler)orinoco_ioctl_setrate),
  1115. IW_HANDLER(SIOCGIWRATE, (iw_handler)orinoco_ioctl_getrate),
  1116. IW_HANDLER(SIOCSIWRTS, (iw_handler)cfg80211_wext_siwrts),
  1117. IW_HANDLER(SIOCGIWRTS, (iw_handler)cfg80211_wext_giwrts),
  1118. IW_HANDLER(SIOCSIWFRAG, (iw_handler)cfg80211_wext_siwfrag),
  1119. IW_HANDLER(SIOCGIWFRAG, (iw_handler)cfg80211_wext_giwfrag),
  1120. IW_HANDLER(SIOCGIWRETRY, (iw_handler)cfg80211_wext_giwretry),
  1121. IW_HANDLER(SIOCSIWENCODE, (iw_handler)orinoco_ioctl_setiwencode),
  1122. IW_HANDLER(SIOCGIWENCODE, (iw_handler)orinoco_ioctl_getiwencode),
  1123. IW_HANDLER(SIOCSIWPOWER, (iw_handler)orinoco_ioctl_setpower),
  1124. IW_HANDLER(SIOCGIWPOWER, (iw_handler)orinoco_ioctl_getpower),
  1125. IW_HANDLER(SIOCSIWGENIE, orinoco_ioctl_set_genie),
  1126. IW_HANDLER(SIOCGIWGENIE, orinoco_ioctl_get_genie),
  1127. IW_HANDLER(SIOCSIWMLME, orinoco_ioctl_set_mlme),
  1128. IW_HANDLER(SIOCSIWAUTH, orinoco_ioctl_set_auth),
  1129. IW_HANDLER(SIOCGIWAUTH, orinoco_ioctl_get_auth),
  1130. IW_HANDLER(SIOCSIWENCODEEXT, orinoco_ioctl_set_encodeext),
  1131. IW_HANDLER(SIOCGIWENCODEEXT, orinoco_ioctl_get_encodeext),
  1132. };
  1133. /*
  1134. Added typecasting since we no longer use iwreq_data -- Moustafa
  1135. */
  1136. static const iw_handler orinoco_private_handler[] = {
  1137. [0] = (iw_handler)orinoco_ioctl_reset,
  1138. [1] = (iw_handler)orinoco_ioctl_reset,
  1139. [2] = (iw_handler)orinoco_ioctl_setport3,
  1140. [3] = (iw_handler)orinoco_ioctl_getport3,
  1141. [4] = (iw_handler)orinoco_ioctl_setpreamble,
  1142. [5] = (iw_handler)orinoco_ioctl_getpreamble,
  1143. [6] = (iw_handler)orinoco_ioctl_setibssport,
  1144. [7] = (iw_handler)orinoco_ioctl_getibssport,
  1145. [9] = (iw_handler)orinoco_ioctl_getrid,
  1146. };
  1147. const struct iw_handler_def orinoco_handler_def = {
  1148. .num_standard = ARRAY_SIZE(orinoco_handler),
  1149. .num_private = ARRAY_SIZE(orinoco_private_handler),
  1150. .num_private_args = ARRAY_SIZE(orinoco_privtab),
  1151. .standard = orinoco_handler,
  1152. .private = orinoco_private_handler,
  1153. .private_args = orinoco_privtab,
  1154. .get_wireless_stats = orinoco_get_wireless_stats,
  1155. };