wext.c 34 KB

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