isl_ioctl.c 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910
  1. /*
  2. * Copyright (C) 2002 Intersil Americas Inc.
  3. * (C) 2003,2004 Aurelien Alleaume <slts@free.fr>
  4. * (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
  5. * (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. #include <linux/capability.h>
  21. #include <linux/module.h>
  22. #include <linux/kernel.h>
  23. #include <linux/if_arp.h>
  24. #include <linux/slab.h>
  25. #include <linux/pci.h>
  26. #include <linux/etherdevice.h>
  27. #include <asm/uaccess.h>
  28. #include "prismcompat.h"
  29. #include "isl_ioctl.h"
  30. #include "islpci_mgt.h"
  31. #include "isl_oid.h" /* additional types and defs for isl38xx fw */
  32. #include "oid_mgt.h"
  33. #include <net/iw_handler.h> /* New driver API */
  34. #define KEY_SIZE_WEP104 13 /* 104/128-bit WEP keys */
  35. #define KEY_SIZE_WEP40 5 /* 40/64-bit WEP keys */
  36. /* KEY_SIZE_TKIP should match isl_oid.h, struct obj_key.key[] size */
  37. #define KEY_SIZE_TKIP 32 /* TKIP keys */
  38. static void prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
  39. u8 *wpa_ie, size_t wpa_ie_len);
  40. static size_t prism54_wpa_bss_ie_get(islpci_private *priv, u8 *bssid, u8 *wpa_ie);
  41. static int prism54_set_wpa(struct net_device *, struct iw_request_info *,
  42. __u32 *, char *);
  43. /* In 500 kbps */
  44. static const unsigned char scan_rate_list[] = { 2, 4, 11, 22,
  45. 12, 18, 24, 36,
  46. 48, 72, 96, 108 };
  47. /**
  48. * prism54_mib_mode_helper - MIB change mode helper function
  49. * @mib: the &struct islpci_mib object to modify
  50. * @iw_mode: new mode (%IW_MODE_*)
  51. *
  52. * This is a helper function, hence it does not lock. Make sure
  53. * caller deals with locking *if* necessary. This function sets the
  54. * mode-dependent mib values and does the mapping of the Linux
  55. * Wireless API modes to Device firmware modes. It also checks for
  56. * correct valid Linux wireless modes.
  57. */
  58. static int
  59. prism54_mib_mode_helper(islpci_private *priv, u32 iw_mode)
  60. {
  61. u32 config = INL_CONFIG_MANUALRUN;
  62. u32 mode, bsstype;
  63. /* For now, just catch early the Repeater and Secondary modes here */
  64. if (iw_mode == IW_MODE_REPEAT || iw_mode == IW_MODE_SECOND) {
  65. printk(KERN_DEBUG
  66. "%s(): Sorry, Repeater mode and Secondary mode "
  67. "are not yet supported by this driver.\n", __func__);
  68. return -EINVAL;
  69. }
  70. priv->iw_mode = iw_mode;
  71. switch (iw_mode) {
  72. case IW_MODE_AUTO:
  73. mode = INL_MODE_CLIENT;
  74. bsstype = DOT11_BSSTYPE_ANY;
  75. break;
  76. case IW_MODE_ADHOC:
  77. mode = INL_MODE_CLIENT;
  78. bsstype = DOT11_BSSTYPE_IBSS;
  79. break;
  80. case IW_MODE_INFRA:
  81. mode = INL_MODE_CLIENT;
  82. bsstype = DOT11_BSSTYPE_INFRA;
  83. break;
  84. case IW_MODE_MASTER:
  85. mode = INL_MODE_AP;
  86. bsstype = DOT11_BSSTYPE_INFRA;
  87. break;
  88. case IW_MODE_MONITOR:
  89. mode = INL_MODE_PROMISCUOUS;
  90. bsstype = DOT11_BSSTYPE_ANY;
  91. config |= INL_CONFIG_RXANNEX;
  92. break;
  93. default:
  94. return -EINVAL;
  95. }
  96. if (init_wds)
  97. config |= INL_CONFIG_WDS;
  98. mgt_set(priv, DOT11_OID_BSSTYPE, &bsstype);
  99. mgt_set(priv, OID_INL_CONFIG, &config);
  100. mgt_set(priv, OID_INL_MODE, &mode);
  101. return 0;
  102. }
  103. /**
  104. * prism54_mib_init - fill MIB cache with defaults
  105. *
  106. * this function initializes the struct given as @mib with defaults,
  107. * of which many are retrieved from the global module parameter
  108. * variables.
  109. */
  110. void
  111. prism54_mib_init(islpci_private *priv)
  112. {
  113. u32 channel, authen, wep, filter, dot1x, mlme, conformance, power, mode;
  114. struct obj_buffer psm_buffer = {
  115. .size = PSM_BUFFER_SIZE,
  116. .addr = priv->device_psm_buffer
  117. };
  118. channel = CARD_DEFAULT_CHANNEL;
  119. authen = CARD_DEFAULT_AUTHEN;
  120. wep = CARD_DEFAULT_WEP;
  121. filter = CARD_DEFAULT_FILTER; /* (0) Do not filter un-encrypted data */
  122. dot1x = CARD_DEFAULT_DOT1X;
  123. mlme = CARD_DEFAULT_MLME_MODE;
  124. conformance = CARD_DEFAULT_CONFORMANCE;
  125. power = 127;
  126. mode = CARD_DEFAULT_IW_MODE;
  127. mgt_set(priv, DOT11_OID_CHANNEL, &channel);
  128. mgt_set(priv, DOT11_OID_AUTHENABLE, &authen);
  129. mgt_set(priv, DOT11_OID_PRIVACYINVOKED, &wep);
  130. mgt_set(priv, DOT11_OID_PSMBUFFER, &psm_buffer);
  131. mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &filter);
  132. mgt_set(priv, DOT11_OID_DOT1XENABLE, &dot1x);
  133. mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlme);
  134. mgt_set(priv, OID_INL_DOT11D_CONFORMANCE, &conformance);
  135. mgt_set(priv, OID_INL_OUTPUTPOWER, &power);
  136. /* This sets all of the mode-dependent values */
  137. prism54_mib_mode_helper(priv, mode);
  138. }
  139. /* this will be executed outside of atomic context thanks to
  140. * schedule_work(), thus we can as well use sleeping semaphore
  141. * locking */
  142. void
  143. prism54_update_stats(struct work_struct *work)
  144. {
  145. islpci_private *priv = container_of(work, islpci_private, stats_work);
  146. char *data;
  147. int j;
  148. struct obj_bss bss, *bss2;
  149. union oid_res_t r;
  150. mutex_lock(&priv->stats_lock);
  151. /* Noise floor.
  152. * I'm not sure if the unit is dBm.
  153. * Note : If we are not connected, this value seems to be irrelevant. */
  154. mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
  155. priv->local_iwstatistics.qual.noise = r.u;
  156. /* Get the rssi of the link. To do this we need to retrieve a bss. */
  157. /* First get the MAC address of the AP we are associated with. */
  158. mgt_get_request(priv, DOT11_OID_BSSID, 0, NULL, &r);
  159. data = r.ptr;
  160. /* copy this MAC to the bss */
  161. memcpy(bss.address, data, ETH_ALEN);
  162. kfree(data);
  163. /* now ask for the corresponding bss */
  164. j = mgt_get_request(priv, DOT11_OID_BSSFIND, 0, (void *) &bss, &r);
  165. bss2 = r.ptr;
  166. /* report the rssi and use it to calculate
  167. * link quality through a signal-noise
  168. * ratio */
  169. priv->local_iwstatistics.qual.level = bss2->rssi;
  170. priv->local_iwstatistics.qual.qual =
  171. bss2->rssi - priv->iwstatistics.qual.noise;
  172. kfree(bss2);
  173. /* report that the stats are new */
  174. priv->local_iwstatistics.qual.updated = 0x7;
  175. /* Rx : unable to decrypt the MPDU */
  176. mgt_get_request(priv, DOT11_OID_PRIVRXFAILED, 0, NULL, &r);
  177. priv->local_iwstatistics.discard.code = r.u;
  178. /* Tx : Max MAC retries num reached */
  179. mgt_get_request(priv, DOT11_OID_MPDUTXFAILED, 0, NULL, &r);
  180. priv->local_iwstatistics.discard.retries = r.u;
  181. mutex_unlock(&priv->stats_lock);
  182. }
  183. struct iw_statistics *
  184. prism54_get_wireless_stats(struct net_device *ndev)
  185. {
  186. islpci_private *priv = netdev_priv(ndev);
  187. /* If the stats are being updated return old data */
  188. if (mutex_trylock(&priv->stats_lock)) {
  189. memcpy(&priv->iwstatistics, &priv->local_iwstatistics,
  190. sizeof (struct iw_statistics));
  191. /* They won't be marked updated for the next time */
  192. priv->local_iwstatistics.qual.updated = 0;
  193. mutex_unlock(&priv->stats_lock);
  194. } else
  195. priv->iwstatistics.qual.updated = 0;
  196. /* Update our wireless stats, but do not schedule to often
  197. * (max 1 HZ) */
  198. if ((priv->stats_timestamp == 0) ||
  199. time_after(jiffies, priv->stats_timestamp + 1 * HZ)) {
  200. schedule_work(&priv->stats_work);
  201. priv->stats_timestamp = jiffies;
  202. }
  203. return &priv->iwstatistics;
  204. }
  205. static int
  206. prism54_commit(struct net_device *ndev, struct iw_request_info *info,
  207. char *cwrq, char *extra)
  208. {
  209. islpci_private *priv = netdev_priv(ndev);
  210. /* simply re-set the last set SSID, this should commit most stuff */
  211. /* Commit in Monitor mode is not necessary, also setting essid
  212. * in Monitor mode does not make sense and isn't allowed for this
  213. * device's firmware */
  214. if (priv->iw_mode != IW_MODE_MONITOR)
  215. return mgt_set_request(priv, DOT11_OID_SSID, 0, NULL);
  216. return 0;
  217. }
  218. static int
  219. prism54_get_name(struct net_device *ndev, struct iw_request_info *info,
  220. char *cwrq, char *extra)
  221. {
  222. islpci_private *priv = netdev_priv(ndev);
  223. char *capabilities;
  224. union oid_res_t r;
  225. int rvalue;
  226. if (islpci_get_state(priv) < PRV_STATE_INIT) {
  227. strncpy(cwrq, "NOT READY!", IFNAMSIZ);
  228. return 0;
  229. }
  230. rvalue = mgt_get_request(priv, OID_INL_PHYCAPABILITIES, 0, NULL, &r);
  231. switch (r.u) {
  232. case INL_PHYCAP_5000MHZ:
  233. capabilities = "IEEE 802.11a/b/g";
  234. break;
  235. case INL_PHYCAP_FAA:
  236. capabilities = "IEEE 802.11b/g - FAA Support";
  237. break;
  238. case INL_PHYCAP_2400MHZ:
  239. default:
  240. capabilities = "IEEE 802.11b/g"; /* Default */
  241. break;
  242. }
  243. strncpy(cwrq, capabilities, IFNAMSIZ);
  244. return rvalue;
  245. }
  246. static int
  247. prism54_set_freq(struct net_device *ndev, struct iw_request_info *info,
  248. struct iw_freq *fwrq, char *extra)
  249. {
  250. islpci_private *priv = netdev_priv(ndev);
  251. int rvalue;
  252. u32 c;
  253. if (fwrq->m < 1000)
  254. /* we have a channel number */
  255. c = fwrq->m;
  256. else
  257. c = (fwrq->e == 1) ? channel_of_freq(fwrq->m / 100000) : 0;
  258. rvalue = c ? mgt_set_request(priv, DOT11_OID_CHANNEL, 0, &c) : -EINVAL;
  259. /* Call commit handler */
  260. return (rvalue ? rvalue : -EINPROGRESS);
  261. }
  262. static int
  263. prism54_get_freq(struct net_device *ndev, struct iw_request_info *info,
  264. struct iw_freq *fwrq, char *extra)
  265. {
  266. islpci_private *priv = netdev_priv(ndev);
  267. union oid_res_t r;
  268. int rvalue;
  269. rvalue = mgt_get_request(priv, DOT11_OID_CHANNEL, 0, NULL, &r);
  270. fwrq->i = r.u;
  271. rvalue |= mgt_get_request(priv, DOT11_OID_FREQUENCY, 0, NULL, &r);
  272. fwrq->m = r.u;
  273. fwrq->e = 3;
  274. return rvalue;
  275. }
  276. static int
  277. prism54_set_mode(struct net_device *ndev, struct iw_request_info *info,
  278. __u32 * uwrq, char *extra)
  279. {
  280. islpci_private *priv = netdev_priv(ndev);
  281. u32 mlmeautolevel = CARD_DEFAULT_MLME_MODE;
  282. /* Let's see if the user passed a valid Linux Wireless mode */
  283. if (*uwrq > IW_MODE_MONITOR || *uwrq < IW_MODE_AUTO) {
  284. printk(KERN_DEBUG
  285. "%s: %s() You passed a non-valid init_mode.\n",
  286. priv->ndev->name, __func__);
  287. return -EINVAL;
  288. }
  289. down_write(&priv->mib_sem);
  290. if (prism54_mib_mode_helper(priv, *uwrq)) {
  291. up_write(&priv->mib_sem);
  292. return -EOPNOTSUPP;
  293. }
  294. /* the ACL code needs an intermediate mlmeautolevel. The wpa stuff an
  295. * extended one.
  296. */
  297. if ((*uwrq == IW_MODE_MASTER) && (priv->acl.policy != MAC_POLICY_OPEN))
  298. mlmeautolevel = DOT11_MLME_INTERMEDIATE;
  299. if (priv->wpa)
  300. mlmeautolevel = DOT11_MLME_EXTENDED;
  301. mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlmeautolevel);
  302. if (mgt_commit(priv)) {
  303. up_write(&priv->mib_sem);
  304. return -EIO;
  305. }
  306. priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR)
  307. ? priv->monitor_type : ARPHRD_ETHER;
  308. up_write(&priv->mib_sem);
  309. return 0;
  310. }
  311. /* Use mib cache */
  312. static int
  313. prism54_get_mode(struct net_device *ndev, struct iw_request_info *info,
  314. __u32 * uwrq, char *extra)
  315. {
  316. islpci_private *priv = netdev_priv(ndev);
  317. BUG_ON((priv->iw_mode < IW_MODE_AUTO) || (priv->iw_mode >
  318. IW_MODE_MONITOR));
  319. *uwrq = priv->iw_mode;
  320. return 0;
  321. }
  322. /* we use DOT11_OID_EDTHRESHOLD. From what I guess the card will not try to
  323. * emit data if (sensitivity > rssi - noise) (in dBm).
  324. * prism54_set_sens does not seem to work.
  325. */
  326. static int
  327. prism54_set_sens(struct net_device *ndev, struct iw_request_info *info,
  328. struct iw_param *vwrq, char *extra)
  329. {
  330. islpci_private *priv = netdev_priv(ndev);
  331. u32 sens;
  332. /* by default the card sets this to 20. */
  333. sens = vwrq->disabled ? 20 : vwrq->value;
  334. return mgt_set_request(priv, DOT11_OID_EDTHRESHOLD, 0, &sens);
  335. }
  336. static int
  337. prism54_get_sens(struct net_device *ndev, struct iw_request_info *info,
  338. struct iw_param *vwrq, char *extra)
  339. {
  340. islpci_private *priv = netdev_priv(ndev);
  341. union oid_res_t r;
  342. int rvalue;
  343. rvalue = mgt_get_request(priv, DOT11_OID_EDTHRESHOLD, 0, NULL, &r);
  344. vwrq->value = r.u;
  345. vwrq->disabled = (vwrq->value == 0);
  346. vwrq->fixed = 1;
  347. return rvalue;
  348. }
  349. static int
  350. prism54_get_range(struct net_device *ndev, struct iw_request_info *info,
  351. struct iw_point *dwrq, char *extra)
  352. {
  353. struct iw_range *range = (struct iw_range *) extra;
  354. islpci_private *priv = netdev_priv(ndev);
  355. u8 *data;
  356. int i, m, rvalue;
  357. struct obj_frequencies *freq;
  358. union oid_res_t r;
  359. memset(range, 0, sizeof (struct iw_range));
  360. dwrq->length = sizeof (struct iw_range);
  361. /* set the wireless extension version number */
  362. range->we_version_source = SUPPORTED_WIRELESS_EXT;
  363. range->we_version_compiled = WIRELESS_EXT;
  364. /* Now the encoding capabilities */
  365. range->num_encoding_sizes = 3;
  366. /* 64(40) bits WEP */
  367. range->encoding_size[0] = 5;
  368. /* 128(104) bits WEP */
  369. range->encoding_size[1] = 13;
  370. /* 256 bits for WPA-PSK */
  371. range->encoding_size[2] = 32;
  372. /* 4 keys are allowed */
  373. range->max_encoding_tokens = 4;
  374. /* we don't know the quality range... */
  375. range->max_qual.level = 0;
  376. range->max_qual.noise = 0;
  377. range->max_qual.qual = 0;
  378. /* these value describe an average quality. Needs more tweaking... */
  379. range->avg_qual.level = -80; /* -80 dBm */
  380. range->avg_qual.noise = 0; /* don't know what to put here */
  381. range->avg_qual.qual = 0;
  382. range->sensitivity = 200;
  383. /* retry limit capabilities */
  384. range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
  385. range->retry_flags = IW_RETRY_LIMIT;
  386. range->r_time_flags = IW_RETRY_LIFETIME;
  387. /* I don't know the range. Put stupid things here */
  388. range->min_retry = 1;
  389. range->max_retry = 65535;
  390. range->min_r_time = 1024;
  391. range->max_r_time = 65535 * 1024;
  392. /* txpower is supported in dBm's */
  393. range->txpower_capa = IW_TXPOW_DBM;
  394. /* Event capability (kernel + driver) */
  395. range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
  396. IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
  397. IW_EVENT_CAPA_MASK(SIOCGIWAP));
  398. range->event_capa[1] = IW_EVENT_CAPA_K_1;
  399. range->event_capa[4] = IW_EVENT_CAPA_MASK(IWEVCUSTOM);
  400. range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
  401. IW_ENC_CAPA_CIPHER_TKIP;
  402. if (islpci_get_state(priv) < PRV_STATE_INIT)
  403. return 0;
  404. /* Request the device for the supported frequencies
  405. * not really relevant since some devices will report the 5 GHz band
  406. * frequencies even if they don't support them.
  407. */
  408. rvalue =
  409. mgt_get_request(priv, DOT11_OID_SUPPORTEDFREQUENCIES, 0, NULL, &r);
  410. freq = r.ptr;
  411. range->num_channels = freq->nr;
  412. range->num_frequency = freq->nr;
  413. m = min(IW_MAX_FREQUENCIES, (int) freq->nr);
  414. for (i = 0; i < m; i++) {
  415. range->freq[i].m = freq->mhz[i];
  416. range->freq[i].e = 6;
  417. range->freq[i].i = channel_of_freq(freq->mhz[i]);
  418. }
  419. kfree(freq);
  420. rvalue |= mgt_get_request(priv, DOT11_OID_SUPPORTEDRATES, 0, NULL, &r);
  421. data = r.ptr;
  422. /* We got an array of char. It is NULL terminated. */
  423. i = 0;
  424. while ((i < IW_MAX_BITRATES) && (*data != 0)) {
  425. /* the result must be in bps. The card gives us 500Kbps */
  426. range->bitrate[i] = *data * 500000;
  427. i++;
  428. data++;
  429. }
  430. range->num_bitrates = i;
  431. kfree(r.ptr);
  432. return rvalue;
  433. }
  434. /* Set AP address*/
  435. static int
  436. prism54_set_wap(struct net_device *ndev, struct iw_request_info *info,
  437. struct sockaddr *awrq, char *extra)
  438. {
  439. islpci_private *priv = netdev_priv(ndev);
  440. char bssid[6];
  441. int rvalue;
  442. if (awrq->sa_family != ARPHRD_ETHER)
  443. return -EINVAL;
  444. /* prepare the structure for the set object */
  445. memcpy(&bssid[0], awrq->sa_data, ETH_ALEN);
  446. /* set the bssid -- does this make sense when in AP mode? */
  447. rvalue = mgt_set_request(priv, DOT11_OID_BSSID, 0, &bssid);
  448. return (rvalue ? rvalue : -EINPROGRESS); /* Call commit handler */
  449. }
  450. /* get AP address*/
  451. static int
  452. prism54_get_wap(struct net_device *ndev, struct iw_request_info *info,
  453. struct sockaddr *awrq, char *extra)
  454. {
  455. islpci_private *priv = netdev_priv(ndev);
  456. union oid_res_t r;
  457. int rvalue;
  458. rvalue = mgt_get_request(priv, DOT11_OID_BSSID, 0, NULL, &r);
  459. memcpy(awrq->sa_data, r.ptr, ETH_ALEN);
  460. awrq->sa_family = ARPHRD_ETHER;
  461. kfree(r.ptr);
  462. return rvalue;
  463. }
  464. static int
  465. prism54_set_scan(struct net_device *dev, struct iw_request_info *info,
  466. struct iw_param *vwrq, char *extra)
  467. {
  468. /* hehe the device does this automagicaly */
  469. return 0;
  470. }
  471. /* a little helper that will translate our data into a card independent
  472. * format that the Wireless Tools will understand. This was inspired by
  473. * the "Aironet driver for 4500 and 4800 series cards" (GPL)
  474. */
  475. static char *
  476. prism54_translate_bss(struct net_device *ndev, struct iw_request_info *info,
  477. char *current_ev, char *end_buf, struct obj_bss *bss,
  478. char noise)
  479. {
  480. struct iw_event iwe; /* Temporary buffer */
  481. short cap;
  482. islpci_private *priv = netdev_priv(ndev);
  483. u8 wpa_ie[MAX_WPA_IE_LEN];
  484. size_t wpa_ie_len;
  485. /* The first entry must be the MAC address */
  486. memcpy(iwe.u.ap_addr.sa_data, bss->address, ETH_ALEN);
  487. iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
  488. iwe.cmd = SIOCGIWAP;
  489. current_ev = iwe_stream_add_event(info, current_ev, end_buf,
  490. &iwe, IW_EV_ADDR_LEN);
  491. /* The following entries will be displayed in the same order we give them */
  492. /* The ESSID. */
  493. iwe.u.data.length = bss->ssid.length;
  494. iwe.u.data.flags = 1;
  495. iwe.cmd = SIOCGIWESSID;
  496. current_ev = iwe_stream_add_point(info, current_ev, end_buf,
  497. &iwe, bss->ssid.octets);
  498. /* Capabilities */
  499. #define CAP_ESS 0x01
  500. #define CAP_IBSS 0x02
  501. #define CAP_CRYPT 0x10
  502. /* Mode */
  503. cap = bss->capinfo;
  504. iwe.u.mode = 0;
  505. if (cap & CAP_ESS)
  506. iwe.u.mode = IW_MODE_MASTER;
  507. else if (cap & CAP_IBSS)
  508. iwe.u.mode = IW_MODE_ADHOC;
  509. iwe.cmd = SIOCGIWMODE;
  510. if (iwe.u.mode)
  511. current_ev = iwe_stream_add_event(info, current_ev, end_buf,
  512. &iwe, IW_EV_UINT_LEN);
  513. /* Encryption capability */
  514. if (cap & CAP_CRYPT)
  515. iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
  516. else
  517. iwe.u.data.flags = IW_ENCODE_DISABLED;
  518. iwe.u.data.length = 0;
  519. iwe.cmd = SIOCGIWENCODE;
  520. current_ev = iwe_stream_add_point(info, current_ev, end_buf,
  521. &iwe, NULL);
  522. /* Add frequency. (short) bss->channel is the frequency in MHz */
  523. iwe.u.freq.m = bss->channel;
  524. iwe.u.freq.e = 6;
  525. iwe.cmd = SIOCGIWFREQ;
  526. current_ev = iwe_stream_add_event(info, current_ev, end_buf,
  527. &iwe, IW_EV_FREQ_LEN);
  528. /* Add quality statistics */
  529. iwe.u.qual.level = bss->rssi;
  530. iwe.u.qual.noise = noise;
  531. /* do a simple SNR for quality */
  532. iwe.u.qual.qual = bss->rssi - noise;
  533. iwe.cmd = IWEVQUAL;
  534. current_ev = iwe_stream_add_event(info, current_ev, end_buf,
  535. &iwe, IW_EV_QUAL_LEN);
  536. /* Add WPA/RSN Information Element, if any */
  537. wpa_ie_len = prism54_wpa_bss_ie_get(priv, bss->address, wpa_ie);
  538. if (wpa_ie_len > 0) {
  539. iwe.cmd = IWEVGENIE;
  540. iwe.u.data.length = min_t(size_t, wpa_ie_len, MAX_WPA_IE_LEN);
  541. current_ev = iwe_stream_add_point(info, current_ev, end_buf,
  542. &iwe, wpa_ie);
  543. }
  544. /* Do the bitrates */
  545. {
  546. char *current_val = current_ev + iwe_stream_lcp_len(info);
  547. int i;
  548. int mask;
  549. iwe.cmd = SIOCGIWRATE;
  550. /* Those two flags are ignored... */
  551. iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
  552. /* Parse the bitmask */
  553. mask = 0x1;
  554. for(i = 0; i < sizeof(scan_rate_list); i++) {
  555. if(bss->rates & mask) {
  556. iwe.u.bitrate.value = (scan_rate_list[i] * 500000);
  557. current_val = iwe_stream_add_value(
  558. info, current_ev, current_val,
  559. end_buf, &iwe, IW_EV_PARAM_LEN);
  560. }
  561. mask <<= 1;
  562. }
  563. /* Check if we added any event */
  564. if ((current_val - current_ev) > iwe_stream_lcp_len(info))
  565. current_ev = current_val;
  566. }
  567. return current_ev;
  568. }
  569. static int
  570. prism54_get_scan(struct net_device *ndev, struct iw_request_info *info,
  571. struct iw_point *dwrq, char *extra)
  572. {
  573. islpci_private *priv = netdev_priv(ndev);
  574. int i, rvalue;
  575. struct obj_bsslist *bsslist;
  576. u32 noise = 0;
  577. char *current_ev = extra;
  578. union oid_res_t r;
  579. if (islpci_get_state(priv) < PRV_STATE_INIT) {
  580. /* device is not ready, fail gently */
  581. dwrq->length = 0;
  582. return 0;
  583. }
  584. /* first get the noise value. We will use it to report the link quality */
  585. rvalue = mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
  586. noise = r.u;
  587. /* Ask the device for a list of known bss.
  588. * The old API, using SIOCGIWAPLIST, had a hard limit of IW_MAX_AP=64.
  589. * The new API, using SIOCGIWSCAN, is only limited by the buffer size.
  590. * WE-14->WE-16, the buffer is limited to IW_SCAN_MAX_DATA bytes.
  591. * Starting with WE-17, the buffer can be as big as needed.
  592. * But the device won't repport anything if you change the value
  593. * of IWMAX_BSS=24. */
  594. rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r);
  595. bsslist = r.ptr;
  596. /* ok now, scan the list and translate its info */
  597. for (i = 0; i < (int) bsslist->nr; i++) {
  598. current_ev = prism54_translate_bss(ndev, info, current_ev,
  599. extra + dwrq->length,
  600. &(bsslist->bsslist[i]),
  601. noise);
  602. /* Check if there is space for one more entry */
  603. if((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) {
  604. /* Ask user space to try again with a bigger buffer */
  605. rvalue = -E2BIG;
  606. break;
  607. }
  608. }
  609. kfree(bsslist);
  610. dwrq->length = (current_ev - extra);
  611. dwrq->flags = 0; /* todo */
  612. return rvalue;
  613. }
  614. static int
  615. prism54_set_essid(struct net_device *ndev, struct iw_request_info *info,
  616. struct iw_point *dwrq, char *extra)
  617. {
  618. islpci_private *priv = netdev_priv(ndev);
  619. struct obj_ssid essid;
  620. memset(essid.octets, 0, 33);
  621. /* Check if we were asked for `any' */
  622. if (dwrq->flags && dwrq->length) {
  623. if (dwrq->length > 32)
  624. return -E2BIG;
  625. essid.length = dwrq->length;
  626. memcpy(essid.octets, extra, dwrq->length);
  627. } else
  628. essid.length = 0;
  629. if (priv->iw_mode != IW_MODE_MONITOR)
  630. return mgt_set_request(priv, DOT11_OID_SSID, 0, &essid);
  631. /* If in monitor mode, just save to mib */
  632. mgt_set(priv, DOT11_OID_SSID, &essid);
  633. return 0;
  634. }
  635. static int
  636. prism54_get_essid(struct net_device *ndev, struct iw_request_info *info,
  637. struct iw_point *dwrq, char *extra)
  638. {
  639. islpci_private *priv = netdev_priv(ndev);
  640. struct obj_ssid *essid;
  641. union oid_res_t r;
  642. int rvalue;
  643. rvalue = mgt_get_request(priv, DOT11_OID_SSID, 0, NULL, &r);
  644. essid = r.ptr;
  645. if (essid->length) {
  646. dwrq->flags = 1; /* set ESSID to ON for Wireless Extensions */
  647. /* if it is too big, trunk it */
  648. dwrq->length = min((u8)IW_ESSID_MAX_SIZE, essid->length);
  649. } else {
  650. dwrq->flags = 0;
  651. dwrq->length = 0;
  652. }
  653. essid->octets[dwrq->length] = '\0';
  654. memcpy(extra, essid->octets, dwrq->length);
  655. kfree(essid);
  656. return rvalue;
  657. }
  658. /* Provides no functionality, just completes the ioctl. In essence this is a
  659. * just a cosmetic ioctl.
  660. */
  661. static int
  662. prism54_set_nick(struct net_device *ndev, struct iw_request_info *info,
  663. struct iw_point *dwrq, char *extra)
  664. {
  665. islpci_private *priv = netdev_priv(ndev);
  666. if (dwrq->length > IW_ESSID_MAX_SIZE)
  667. return -E2BIG;
  668. down_write(&priv->mib_sem);
  669. memset(priv->nickname, 0, sizeof (priv->nickname));
  670. memcpy(priv->nickname, extra, dwrq->length);
  671. up_write(&priv->mib_sem);
  672. return 0;
  673. }
  674. static int
  675. prism54_get_nick(struct net_device *ndev, struct iw_request_info *info,
  676. struct iw_point *dwrq, char *extra)
  677. {
  678. islpci_private *priv = netdev_priv(ndev);
  679. dwrq->length = 0;
  680. down_read(&priv->mib_sem);
  681. dwrq->length = strlen(priv->nickname);
  682. memcpy(extra, priv->nickname, dwrq->length);
  683. up_read(&priv->mib_sem);
  684. return 0;
  685. }
  686. /* Set the allowed Bitrates */
  687. static int
  688. prism54_set_rate(struct net_device *ndev,
  689. struct iw_request_info *info,
  690. struct iw_param *vwrq, char *extra)
  691. {
  692. islpci_private *priv = netdev_priv(ndev);
  693. u32 rate, profile;
  694. char *data;
  695. int ret, i;
  696. union oid_res_t r;
  697. if (vwrq->value == -1) {
  698. /* auto mode. No limit. */
  699. profile = 1;
  700. return mgt_set_request(priv, DOT11_OID_PROFILES, 0, &profile);
  701. }
  702. ret = mgt_get_request(priv, DOT11_OID_SUPPORTEDRATES, 0, NULL, &r);
  703. if (ret) {
  704. kfree(r.ptr);
  705. return ret;
  706. }
  707. rate = (u32) (vwrq->value / 500000);
  708. data = r.ptr;
  709. i = 0;
  710. while (data[i]) {
  711. if (rate && (data[i] == rate)) {
  712. break;
  713. }
  714. if (vwrq->value == i) {
  715. break;
  716. }
  717. data[i] |= 0x80;
  718. i++;
  719. }
  720. if (!data[i]) {
  721. kfree(r.ptr);
  722. return -EINVAL;
  723. }
  724. data[i] |= 0x80;
  725. data[i + 1] = 0;
  726. /* Now, check if we want a fixed or auto value */
  727. if (vwrq->fixed) {
  728. data[0] = data[i];
  729. data[1] = 0;
  730. }
  731. /*
  732. i = 0;
  733. printk("prism54 rate: ");
  734. while(data[i]) {
  735. printk("%u ", data[i]);
  736. i++;
  737. }
  738. printk("0\n");
  739. */
  740. profile = -1;
  741. ret = mgt_set_request(priv, DOT11_OID_PROFILES, 0, &profile);
  742. ret |= mgt_set_request(priv, DOT11_OID_EXTENDEDRATES, 0, data);
  743. ret |= mgt_set_request(priv, DOT11_OID_RATES, 0, data);
  744. kfree(r.ptr);
  745. return ret;
  746. }
  747. /* Get the current bit rate */
  748. static int
  749. prism54_get_rate(struct net_device *ndev,
  750. struct iw_request_info *info,
  751. struct iw_param *vwrq, char *extra)
  752. {
  753. islpci_private *priv = netdev_priv(ndev);
  754. int rvalue;
  755. char *data;
  756. union oid_res_t r;
  757. /* Get the current bit rate */
  758. if ((rvalue = mgt_get_request(priv, GEN_OID_LINKSTATE, 0, NULL, &r)))
  759. return rvalue;
  760. vwrq->value = r.u * 500000;
  761. /* request the device for the enabled rates */
  762. rvalue = mgt_get_request(priv, DOT11_OID_RATES, 0, NULL, &r);
  763. if (rvalue) {
  764. kfree(r.ptr);
  765. return rvalue;
  766. }
  767. data = r.ptr;
  768. vwrq->fixed = (data[0] != 0) && (data[1] == 0);
  769. kfree(r.ptr);
  770. return 0;
  771. }
  772. static int
  773. prism54_set_rts(struct net_device *ndev, struct iw_request_info *info,
  774. struct iw_param *vwrq, char *extra)
  775. {
  776. islpci_private *priv = netdev_priv(ndev);
  777. return mgt_set_request(priv, DOT11_OID_RTSTHRESH, 0, &vwrq->value);
  778. }
  779. static int
  780. prism54_get_rts(struct net_device *ndev, struct iw_request_info *info,
  781. struct iw_param *vwrq, char *extra)
  782. {
  783. islpci_private *priv = netdev_priv(ndev);
  784. union oid_res_t r;
  785. int rvalue;
  786. /* get the rts threshold */
  787. rvalue = mgt_get_request(priv, DOT11_OID_RTSTHRESH, 0, NULL, &r);
  788. vwrq->value = r.u;
  789. return rvalue;
  790. }
  791. static int
  792. prism54_set_frag(struct net_device *ndev, struct iw_request_info *info,
  793. struct iw_param *vwrq, char *extra)
  794. {
  795. islpci_private *priv = netdev_priv(ndev);
  796. return mgt_set_request(priv, DOT11_OID_FRAGTHRESH, 0, &vwrq->value);
  797. }
  798. static int
  799. prism54_get_frag(struct net_device *ndev, struct iw_request_info *info,
  800. struct iw_param *vwrq, char *extra)
  801. {
  802. islpci_private *priv = netdev_priv(ndev);
  803. union oid_res_t r;
  804. int rvalue;
  805. rvalue = mgt_get_request(priv, DOT11_OID_FRAGTHRESH, 0, NULL, &r);
  806. vwrq->value = r.u;
  807. return rvalue;
  808. }
  809. /* Here we have (min,max) = max retries for (small frames, big frames). Where
  810. * big frame <=> bigger than the rts threshold
  811. * small frame <=> smaller than the rts threshold
  812. * This is not really the behavior expected by the wireless tool but it seems
  813. * to be a common behavior in other drivers.
  814. */
  815. static int
  816. prism54_set_retry(struct net_device *ndev, struct iw_request_info *info,
  817. struct iw_param *vwrq, char *extra)
  818. {
  819. islpci_private *priv = netdev_priv(ndev);
  820. u32 slimit = 0, llimit = 0; /* short and long limit */
  821. u32 lifetime = 0;
  822. int rvalue = 0;
  823. if (vwrq->disabled)
  824. /* we cannot disable this feature */
  825. return -EINVAL;
  826. if (vwrq->flags & IW_RETRY_LIMIT) {
  827. if (vwrq->flags & IW_RETRY_SHORT)
  828. slimit = vwrq->value;
  829. else if (vwrq->flags & IW_RETRY_LONG)
  830. llimit = vwrq->value;
  831. else {
  832. /* we are asked to set both */
  833. slimit = vwrq->value;
  834. llimit = vwrq->value;
  835. }
  836. }
  837. if (vwrq->flags & IW_RETRY_LIFETIME)
  838. /* Wireless tools use us unit while the device uses 1024 us unit */
  839. lifetime = vwrq->value / 1024;
  840. /* now set what is requested */
  841. if (slimit)
  842. rvalue =
  843. mgt_set_request(priv, DOT11_OID_SHORTRETRIES, 0, &slimit);
  844. if (llimit)
  845. rvalue |=
  846. mgt_set_request(priv, DOT11_OID_LONGRETRIES, 0, &llimit);
  847. if (lifetime)
  848. rvalue |=
  849. mgt_set_request(priv, DOT11_OID_MAXTXLIFETIME, 0,
  850. &lifetime);
  851. return rvalue;
  852. }
  853. static int
  854. prism54_get_retry(struct net_device *ndev, struct iw_request_info *info,
  855. struct iw_param *vwrq, char *extra)
  856. {
  857. islpci_private *priv = netdev_priv(ndev);
  858. union oid_res_t r;
  859. int rvalue = 0;
  860. vwrq->disabled = 0; /* It cannot be disabled */
  861. if ((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
  862. /* we are asked for the life time */
  863. rvalue =
  864. mgt_get_request(priv, DOT11_OID_MAXTXLIFETIME, 0, NULL, &r);
  865. vwrq->value = r.u * 1024;
  866. vwrq->flags = IW_RETRY_LIFETIME;
  867. } else if ((vwrq->flags & IW_RETRY_LONG)) {
  868. /* we are asked for the long retry limit */
  869. rvalue |=
  870. mgt_get_request(priv, DOT11_OID_LONGRETRIES, 0, NULL, &r);
  871. vwrq->value = r.u;
  872. vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
  873. } else {
  874. /* default. get the short retry limit */
  875. rvalue |=
  876. mgt_get_request(priv, DOT11_OID_SHORTRETRIES, 0, NULL, &r);
  877. vwrq->value = r.u;
  878. vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
  879. }
  880. return rvalue;
  881. }
  882. static int
  883. prism54_set_encode(struct net_device *ndev, struct iw_request_info *info,
  884. struct iw_point *dwrq, char *extra)
  885. {
  886. islpci_private *priv = netdev_priv(ndev);
  887. int rvalue = 0, force = 0;
  888. int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
  889. union oid_res_t r;
  890. /* with the new API, it's impossible to get a NULL pointer.
  891. * New version of iwconfig set the IW_ENCODE_NOKEY flag
  892. * when no key is given, but older versions don't. */
  893. if (dwrq->length > 0) {
  894. /* we have a key to set */
  895. int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
  896. int current_index;
  897. struct obj_key key = { DOT11_PRIV_WEP, 0, "" };
  898. /* get the current key index */
  899. rvalue = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
  900. current_index = r.u;
  901. /* Verify that the key is not marked as invalid */
  902. if (!(dwrq->flags & IW_ENCODE_NOKEY)) {
  903. if (dwrq->length > KEY_SIZE_TKIP) {
  904. /* User-provided key data too big */
  905. return -EINVAL;
  906. }
  907. if (dwrq->length > KEY_SIZE_WEP104) {
  908. /* WPA-PSK TKIP */
  909. key.type = DOT11_PRIV_TKIP;
  910. key.length = KEY_SIZE_TKIP;
  911. } else if (dwrq->length > KEY_SIZE_WEP40) {
  912. /* WEP 104/128 */
  913. key.length = KEY_SIZE_WEP104;
  914. } else {
  915. /* WEP 40/64 */
  916. key.length = KEY_SIZE_WEP40;
  917. }
  918. memset(key.key, 0, sizeof (key.key));
  919. memcpy(key.key, extra, dwrq->length);
  920. if ((index < 0) || (index > 3))
  921. /* no index provided use the current one */
  922. index = current_index;
  923. /* now send the key to the card */
  924. rvalue |=
  925. mgt_set_request(priv, DOT11_OID_DEFKEYX, index,
  926. &key);
  927. }
  928. /*
  929. * If a valid key is set, encryption should be enabled
  930. * (user may turn it off later).
  931. * This is also how "iwconfig ethX key on" works
  932. */
  933. if ((index == current_index) && (key.length > 0))
  934. force = 1;
  935. } else {
  936. int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
  937. if ((index >= 0) && (index <= 3)) {
  938. /* we want to set the key index */
  939. rvalue |=
  940. mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
  941. &index);
  942. } else {
  943. if (!(dwrq->flags & IW_ENCODE_MODE)) {
  944. /* we cannot do anything. Complain. */
  945. return -EINVAL;
  946. }
  947. }
  948. }
  949. /* now read the flags */
  950. if (dwrq->flags & IW_ENCODE_DISABLED) {
  951. /* Encoding disabled,
  952. * authen = DOT11_AUTH_OS;
  953. * invoke = 0;
  954. * exunencrypt = 0; */
  955. }
  956. if (dwrq->flags & IW_ENCODE_OPEN)
  957. /* Encode but accept non-encoded packets. No auth */
  958. invoke = 1;
  959. if ((dwrq->flags & IW_ENCODE_RESTRICTED) || force) {
  960. /* Refuse non-encoded packets. Auth */
  961. authen = DOT11_AUTH_BOTH;
  962. invoke = 1;
  963. exunencrypt = 1;
  964. }
  965. /* do the change if requested */
  966. if ((dwrq->flags & IW_ENCODE_MODE) || force) {
  967. rvalue |=
  968. mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
  969. rvalue |=
  970. mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &invoke);
  971. rvalue |=
  972. mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
  973. &exunencrypt);
  974. }
  975. return rvalue;
  976. }
  977. static int
  978. prism54_get_encode(struct net_device *ndev, struct iw_request_info *info,
  979. struct iw_point *dwrq, char *extra)
  980. {
  981. islpci_private *priv = netdev_priv(ndev);
  982. struct obj_key *key;
  983. u32 devindex, index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
  984. u32 authen = 0, invoke = 0, exunencrypt = 0;
  985. int rvalue;
  986. union oid_res_t r;
  987. /* first get the flags */
  988. rvalue = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
  989. authen = r.u;
  990. rvalue |= mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
  991. invoke = r.u;
  992. rvalue |= mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
  993. exunencrypt = r.u;
  994. if (invoke && (authen == DOT11_AUTH_BOTH) && exunencrypt)
  995. dwrq->flags = IW_ENCODE_RESTRICTED;
  996. else if ((authen == DOT11_AUTH_OS) && !exunencrypt) {
  997. if (invoke)
  998. dwrq->flags = IW_ENCODE_OPEN;
  999. else
  1000. dwrq->flags = IW_ENCODE_DISABLED;
  1001. } else
  1002. /* The card should not work in this state */
  1003. dwrq->flags = 0;
  1004. /* get the current device key index */
  1005. rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
  1006. devindex = r.u;
  1007. /* Now get the key, return it */
  1008. if (index == -1 || index > 3)
  1009. /* no index provided, use the current one */
  1010. index = devindex;
  1011. rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYX, index, NULL, &r);
  1012. key = r.ptr;
  1013. dwrq->length = key->length;
  1014. memcpy(extra, key->key, dwrq->length);
  1015. kfree(key);
  1016. /* return the used key index */
  1017. dwrq->flags |= devindex + 1;
  1018. return rvalue;
  1019. }
  1020. static int
  1021. prism54_get_txpower(struct net_device *ndev, struct iw_request_info *info,
  1022. struct iw_param *vwrq, char *extra)
  1023. {
  1024. islpci_private *priv = netdev_priv(ndev);
  1025. union oid_res_t r;
  1026. int rvalue;
  1027. rvalue = mgt_get_request(priv, OID_INL_OUTPUTPOWER, 0, NULL, &r);
  1028. /* intersil firmware operates in 0.25 dBm (1/4 dBm) */
  1029. vwrq->value = (s32) r.u / 4;
  1030. vwrq->fixed = 1;
  1031. /* radio is not turned of
  1032. * btw: how is possible to turn off only the radio
  1033. */
  1034. vwrq->disabled = 0;
  1035. return rvalue;
  1036. }
  1037. static int
  1038. prism54_set_txpower(struct net_device *ndev, struct iw_request_info *info,
  1039. struct iw_param *vwrq, char *extra)
  1040. {
  1041. islpci_private *priv = netdev_priv(ndev);
  1042. s32 u = vwrq->value;
  1043. /* intersil firmware operates in 0.25 dBm (1/4) */
  1044. u *= 4;
  1045. if (vwrq->disabled) {
  1046. /* don't know how to disable radio */
  1047. printk(KERN_DEBUG
  1048. "%s: %s() disabling radio is not yet supported.\n",
  1049. priv->ndev->name, __func__);
  1050. return -ENOTSUPP;
  1051. } else if (vwrq->fixed)
  1052. /* currently only fixed value is supported */
  1053. return mgt_set_request(priv, OID_INL_OUTPUTPOWER, 0, &u);
  1054. else {
  1055. printk(KERN_DEBUG
  1056. "%s: %s() auto power will be implemented later.\n",
  1057. priv->ndev->name, __func__);
  1058. return -ENOTSUPP;
  1059. }
  1060. }
  1061. static int prism54_set_genie(struct net_device *ndev,
  1062. struct iw_request_info *info,
  1063. struct iw_point *data, char *extra)
  1064. {
  1065. islpci_private *priv = netdev_priv(ndev);
  1066. int alen, ret = 0;
  1067. struct obj_attachment *attach;
  1068. if (data->length > MAX_WPA_IE_LEN ||
  1069. (data->length && extra == NULL))
  1070. return -EINVAL;
  1071. memcpy(priv->wpa_ie, extra, data->length);
  1072. priv->wpa_ie_len = data->length;
  1073. alen = sizeof(*attach) + priv->wpa_ie_len;
  1074. attach = kzalloc(alen, GFP_KERNEL);
  1075. if (attach == NULL)
  1076. return -ENOMEM;
  1077. #define WLAN_FC_TYPE_MGMT 0
  1078. #define WLAN_FC_STYPE_ASSOC_REQ 0
  1079. #define WLAN_FC_STYPE_REASSOC_REQ 2
  1080. /* Note: endianness is covered by mgt_set_varlen */
  1081. attach->type = (WLAN_FC_TYPE_MGMT << 2) |
  1082. (WLAN_FC_STYPE_ASSOC_REQ << 4);
  1083. attach->id = -1;
  1084. attach->size = priv->wpa_ie_len;
  1085. memcpy(attach->data, extra, priv->wpa_ie_len);
  1086. ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach,
  1087. priv->wpa_ie_len);
  1088. if (ret == 0) {
  1089. attach->type = (WLAN_FC_TYPE_MGMT << 2) |
  1090. (WLAN_FC_STYPE_REASSOC_REQ << 4);
  1091. ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach,
  1092. priv->wpa_ie_len);
  1093. if (ret == 0)
  1094. printk(KERN_DEBUG "%s: WPA IE Attachment was set\n",
  1095. ndev->name);
  1096. }
  1097. kfree(attach);
  1098. return ret;
  1099. }
  1100. static int prism54_get_genie(struct net_device *ndev,
  1101. struct iw_request_info *info,
  1102. struct iw_point *data, char *extra)
  1103. {
  1104. islpci_private *priv = netdev_priv(ndev);
  1105. int len = priv->wpa_ie_len;
  1106. if (len <= 0) {
  1107. data->length = 0;
  1108. return 0;
  1109. }
  1110. if (data->length < len)
  1111. return -E2BIG;
  1112. data->length = len;
  1113. memcpy(extra, priv->wpa_ie, len);
  1114. return 0;
  1115. }
  1116. static int prism54_set_auth(struct net_device *ndev,
  1117. struct iw_request_info *info,
  1118. union iwreq_data *wrqu, char *extra)
  1119. {
  1120. islpci_private *priv = netdev_priv(ndev);
  1121. struct iw_param *param = &wrqu->param;
  1122. u32 mlmelevel = 0, authen = 0, dot1x = 0;
  1123. u32 exunencrypt = 0, privinvoked = 0, wpa = 0;
  1124. u32 old_wpa;
  1125. int ret = 0;
  1126. union oid_res_t r;
  1127. if (islpci_get_state(priv) < PRV_STATE_INIT)
  1128. return 0;
  1129. /* first get the flags */
  1130. down_write(&priv->mib_sem);
  1131. wpa = old_wpa = priv->wpa;
  1132. up_write(&priv->mib_sem);
  1133. ret = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
  1134. authen = r.u;
  1135. ret = mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
  1136. privinvoked = r.u;
  1137. ret = mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
  1138. exunencrypt = r.u;
  1139. ret = mgt_get_request(priv, DOT11_OID_DOT1XENABLE, 0, NULL, &r);
  1140. dot1x = r.u;
  1141. ret = mgt_get_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, NULL, &r);
  1142. mlmelevel = r.u;
  1143. if (ret < 0)
  1144. goto out;
  1145. switch (param->flags & IW_AUTH_INDEX) {
  1146. case IW_AUTH_CIPHER_PAIRWISE:
  1147. case IW_AUTH_CIPHER_GROUP:
  1148. case IW_AUTH_KEY_MGMT:
  1149. break;
  1150. case IW_AUTH_WPA_ENABLED:
  1151. /* Do the same thing as IW_AUTH_WPA_VERSION */
  1152. if (param->value) {
  1153. wpa = 1;
  1154. privinvoked = 1; /* For privacy invoked */
  1155. exunencrypt = 1; /* Filter out all unencrypted frames */
  1156. dot1x = 0x01; /* To enable eap filter */
  1157. mlmelevel = DOT11_MLME_EXTENDED;
  1158. authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
  1159. } else {
  1160. wpa = 0;
  1161. privinvoked = 0;
  1162. exunencrypt = 0; /* Do not filter un-encrypted data */
  1163. dot1x = 0;
  1164. mlmelevel = DOT11_MLME_AUTO;
  1165. }
  1166. break;
  1167. case IW_AUTH_WPA_VERSION:
  1168. if (param->value & IW_AUTH_WPA_VERSION_DISABLED) {
  1169. wpa = 0;
  1170. privinvoked = 0;
  1171. exunencrypt = 0; /* Do not filter un-encrypted data */
  1172. dot1x = 0;
  1173. mlmelevel = DOT11_MLME_AUTO;
  1174. } else {
  1175. if (param->value & IW_AUTH_WPA_VERSION_WPA)
  1176. wpa = 1;
  1177. else if (param->value & IW_AUTH_WPA_VERSION_WPA2)
  1178. wpa = 2;
  1179. privinvoked = 1; /* For privacy invoked */
  1180. exunencrypt = 1; /* Filter out all unencrypted frames */
  1181. dot1x = 0x01; /* To enable eap filter */
  1182. mlmelevel = DOT11_MLME_EXTENDED;
  1183. authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
  1184. }
  1185. break;
  1186. case IW_AUTH_RX_UNENCRYPTED_EAPOL:
  1187. /* dot1x should be the opposite of RX_UNENCRYPTED_EAPOL;
  1188. * turn off dot1x when allowing receipt of unencrypted EAPOL
  1189. * frames, turn on dot1x when receipt should be disallowed
  1190. */
  1191. dot1x = param->value ? 0 : 0x01;
  1192. break;
  1193. case IW_AUTH_PRIVACY_INVOKED:
  1194. privinvoked = param->value ? 1 : 0;
  1195. break;
  1196. case IW_AUTH_DROP_UNENCRYPTED:
  1197. exunencrypt = param->value ? 1 : 0;
  1198. break;
  1199. case IW_AUTH_80211_AUTH_ALG:
  1200. if (param->value & IW_AUTH_ALG_SHARED_KEY) {
  1201. /* Only WEP uses _SK and _BOTH */
  1202. if (wpa > 0) {
  1203. ret = -EINVAL;
  1204. goto out;
  1205. }
  1206. authen = DOT11_AUTH_SK;
  1207. } else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) {
  1208. authen = DOT11_AUTH_OS;
  1209. } else {
  1210. ret = -EINVAL;
  1211. goto out;
  1212. }
  1213. break;
  1214. default:
  1215. return -EOPNOTSUPP;
  1216. }
  1217. /* Set all the values */
  1218. down_write(&priv->mib_sem);
  1219. priv->wpa = wpa;
  1220. up_write(&priv->mib_sem);
  1221. mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
  1222. mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &privinvoked);
  1223. mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, &exunencrypt);
  1224. mgt_set_request(priv, DOT11_OID_DOT1XENABLE, 0, &dot1x);
  1225. mgt_set_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, &mlmelevel);
  1226. out:
  1227. return ret;
  1228. }
  1229. static int prism54_get_auth(struct net_device *ndev,
  1230. struct iw_request_info *info,
  1231. union iwreq_data *wrqu, char *extra)
  1232. {
  1233. islpci_private *priv = netdev_priv(ndev);
  1234. struct iw_param *param = &wrqu->param;
  1235. u32 wpa = 0;
  1236. int ret = 0;
  1237. union oid_res_t r;
  1238. if (islpci_get_state(priv) < PRV_STATE_INIT)
  1239. return 0;
  1240. /* first get the flags */
  1241. down_write(&priv->mib_sem);
  1242. wpa = priv->wpa;
  1243. up_write(&priv->mib_sem);
  1244. switch (param->flags & IW_AUTH_INDEX) {
  1245. case IW_AUTH_CIPHER_PAIRWISE:
  1246. case IW_AUTH_CIPHER_GROUP:
  1247. case IW_AUTH_KEY_MGMT:
  1248. /*
  1249. * wpa_supplicant will control these internally
  1250. */
  1251. ret = -EOPNOTSUPP;
  1252. break;
  1253. case IW_AUTH_WPA_VERSION:
  1254. switch (wpa) {
  1255. case 1:
  1256. param->value = IW_AUTH_WPA_VERSION_WPA;
  1257. break;
  1258. case 2:
  1259. param->value = IW_AUTH_WPA_VERSION_WPA2;
  1260. break;
  1261. case 0:
  1262. default:
  1263. param->value = IW_AUTH_WPA_VERSION_DISABLED;
  1264. break;
  1265. }
  1266. break;
  1267. case IW_AUTH_DROP_UNENCRYPTED:
  1268. ret = mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
  1269. if (ret >= 0)
  1270. param->value = r.u > 0 ? 1 : 0;
  1271. break;
  1272. case IW_AUTH_80211_AUTH_ALG:
  1273. ret = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
  1274. if (ret >= 0) {
  1275. switch (r.u) {
  1276. case DOT11_AUTH_OS:
  1277. param->value = IW_AUTH_ALG_OPEN_SYSTEM;
  1278. break;
  1279. case DOT11_AUTH_BOTH:
  1280. case DOT11_AUTH_SK:
  1281. param->value = IW_AUTH_ALG_SHARED_KEY;
  1282. break;
  1283. case DOT11_AUTH_NONE:
  1284. default:
  1285. param->value = 0;
  1286. break;
  1287. }
  1288. }
  1289. break;
  1290. case IW_AUTH_WPA_ENABLED:
  1291. param->value = wpa > 0 ? 1 : 0;
  1292. break;
  1293. case IW_AUTH_RX_UNENCRYPTED_EAPOL:
  1294. ret = mgt_get_request(priv, DOT11_OID_DOT1XENABLE, 0, NULL, &r);
  1295. if (ret >= 0)
  1296. param->value = r.u > 0 ? 1 : 0;
  1297. break;
  1298. case IW_AUTH_PRIVACY_INVOKED:
  1299. ret = mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
  1300. if (ret >= 0)
  1301. param->value = r.u > 0 ? 1 : 0;
  1302. break;
  1303. default:
  1304. return -EOPNOTSUPP;
  1305. }
  1306. return ret;
  1307. }
  1308. static int prism54_set_encodeext(struct net_device *ndev,
  1309. struct iw_request_info *info,
  1310. union iwreq_data *wrqu,
  1311. char *extra)
  1312. {
  1313. islpci_private *priv = netdev_priv(ndev);
  1314. struct iw_point *encoding = &wrqu->encoding;
  1315. struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  1316. int idx, alg = ext->alg, set_key = 1;
  1317. union oid_res_t r;
  1318. int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
  1319. int ret = 0;
  1320. if (islpci_get_state(priv) < PRV_STATE_INIT)
  1321. return 0;
  1322. /* Determine and validate the key index */
  1323. idx = (encoding->flags & IW_ENCODE_INDEX) - 1;
  1324. if (idx) {
  1325. if (idx < 0 || idx > 3)
  1326. return -EINVAL;
  1327. } else {
  1328. ret = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
  1329. if (ret < 0)
  1330. goto out;
  1331. idx = r.u;
  1332. }
  1333. if (encoding->flags & IW_ENCODE_DISABLED)
  1334. alg = IW_ENCODE_ALG_NONE;
  1335. if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
  1336. /* Only set transmit key index here, actual
  1337. * key is set below if needed.
  1338. */
  1339. ret = mgt_set_request(priv, DOT11_OID_DEFKEYID, 0, &idx);
  1340. set_key = ext->key_len > 0 ? 1 : 0;
  1341. }
  1342. if (set_key) {
  1343. struct obj_key key = { DOT11_PRIV_WEP, 0, "" };
  1344. switch (alg) {
  1345. case IW_ENCODE_ALG_NONE:
  1346. break;
  1347. case IW_ENCODE_ALG_WEP:
  1348. if (ext->key_len > KEY_SIZE_WEP104) {
  1349. ret = -EINVAL;
  1350. goto out;
  1351. }
  1352. if (ext->key_len > KEY_SIZE_WEP40)
  1353. key.length = KEY_SIZE_WEP104;
  1354. else
  1355. key.length = KEY_SIZE_WEP40;
  1356. break;
  1357. case IW_ENCODE_ALG_TKIP:
  1358. if (ext->key_len > KEY_SIZE_TKIP) {
  1359. ret = -EINVAL;
  1360. goto out;
  1361. }
  1362. key.type = DOT11_PRIV_TKIP;
  1363. key.length = KEY_SIZE_TKIP;
  1364. break;
  1365. default:
  1366. return -EINVAL;
  1367. }
  1368. if (key.length) {
  1369. memset(key.key, 0, sizeof(key.key));
  1370. memcpy(key.key, ext->key, ext->key_len);
  1371. ret = mgt_set_request(priv, DOT11_OID_DEFKEYX, idx,
  1372. &key);
  1373. if (ret < 0)
  1374. goto out;
  1375. }
  1376. }
  1377. /* Read the flags */
  1378. if (encoding->flags & IW_ENCODE_DISABLED) {
  1379. /* Encoding disabled,
  1380. * authen = DOT11_AUTH_OS;
  1381. * invoke = 0;
  1382. * exunencrypt = 0; */
  1383. }
  1384. if (encoding->flags & IW_ENCODE_OPEN) {
  1385. /* Encode but accept non-encoded packets. No auth */
  1386. invoke = 1;
  1387. }
  1388. if (encoding->flags & IW_ENCODE_RESTRICTED) {
  1389. /* Refuse non-encoded packets. Auth */
  1390. authen = DOT11_AUTH_BOTH;
  1391. invoke = 1;
  1392. exunencrypt = 1;
  1393. }
  1394. /* do the change if requested */
  1395. if (encoding->flags & IW_ENCODE_MODE) {
  1396. ret = mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0,
  1397. &authen);
  1398. ret = mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0,
  1399. &invoke);
  1400. ret = mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
  1401. &exunencrypt);
  1402. }
  1403. out:
  1404. return ret;
  1405. }
  1406. static int prism54_get_encodeext(struct net_device *ndev,
  1407. struct iw_request_info *info,
  1408. union iwreq_data *wrqu,
  1409. char *extra)
  1410. {
  1411. islpci_private *priv = netdev_priv(ndev);
  1412. struct iw_point *encoding = &wrqu->encoding;
  1413. struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  1414. int idx, max_key_len;
  1415. union oid_res_t r;
  1416. int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0, wpa = 0;
  1417. int ret = 0;
  1418. if (islpci_get_state(priv) < PRV_STATE_INIT)
  1419. return 0;
  1420. /* first get the flags */
  1421. ret = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
  1422. authen = r.u;
  1423. ret = mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
  1424. invoke = r.u;
  1425. ret = mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
  1426. exunencrypt = r.u;
  1427. if (ret < 0)
  1428. goto out;
  1429. max_key_len = encoding->length - sizeof(*ext);
  1430. if (max_key_len < 0)
  1431. return -EINVAL;
  1432. idx = (encoding->flags & IW_ENCODE_INDEX) - 1;
  1433. if (idx) {
  1434. if (idx < 0 || idx > 3)
  1435. return -EINVAL;
  1436. } else {
  1437. ret = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
  1438. if (ret < 0)
  1439. goto out;
  1440. idx = r.u;
  1441. }
  1442. encoding->flags = idx + 1;
  1443. memset(ext, 0, sizeof(*ext));
  1444. switch (authen) {
  1445. case DOT11_AUTH_BOTH:
  1446. case DOT11_AUTH_SK:
  1447. wrqu->encoding.flags |= IW_ENCODE_RESTRICTED;
  1448. case DOT11_AUTH_OS:
  1449. default:
  1450. wrqu->encoding.flags |= IW_ENCODE_OPEN;
  1451. break;
  1452. }
  1453. down_write(&priv->mib_sem);
  1454. wpa = priv->wpa;
  1455. up_write(&priv->mib_sem);
  1456. if (authen == DOT11_AUTH_OS && !exunencrypt && !invoke && !wpa) {
  1457. /* No encryption */
  1458. ext->alg = IW_ENCODE_ALG_NONE;
  1459. ext->key_len = 0;
  1460. wrqu->encoding.flags |= IW_ENCODE_DISABLED;
  1461. } else {
  1462. struct obj_key *key;
  1463. ret = mgt_get_request(priv, DOT11_OID_DEFKEYX, idx, NULL, &r);
  1464. if (ret < 0)
  1465. goto out;
  1466. key = r.ptr;
  1467. if (max_key_len < key->length) {
  1468. ret = -E2BIG;
  1469. goto out;
  1470. }
  1471. memcpy(ext->key, key->key, key->length);
  1472. ext->key_len = key->length;
  1473. switch (key->type) {
  1474. case DOT11_PRIV_TKIP:
  1475. ext->alg = IW_ENCODE_ALG_TKIP;
  1476. break;
  1477. default:
  1478. case DOT11_PRIV_WEP:
  1479. ext->alg = IW_ENCODE_ALG_WEP;
  1480. break;
  1481. }
  1482. wrqu->encoding.flags |= IW_ENCODE_ENABLED;
  1483. }
  1484. out:
  1485. return ret;
  1486. }
  1487. static int
  1488. prism54_reset(struct net_device *ndev, struct iw_request_info *info,
  1489. __u32 * uwrq, char *extra)
  1490. {
  1491. islpci_reset(netdev_priv(ndev), 0);
  1492. return 0;
  1493. }
  1494. static int
  1495. prism54_get_oid(struct net_device *ndev, struct iw_request_info *info,
  1496. struct iw_point *dwrq, char *extra)
  1497. {
  1498. union oid_res_t r;
  1499. int rvalue;
  1500. enum oid_num_t n = dwrq->flags;
  1501. rvalue = mgt_get_request(netdev_priv(ndev), n, 0, NULL, &r);
  1502. dwrq->length = mgt_response_to_str(n, &r, extra);
  1503. if ((isl_oid[n].flags & OID_FLAG_TYPE) != OID_TYPE_U32)
  1504. kfree(r.ptr);
  1505. return rvalue;
  1506. }
  1507. static int
  1508. prism54_set_u32(struct net_device *ndev, struct iw_request_info *info,
  1509. __u32 * uwrq, char *extra)
  1510. {
  1511. u32 oid = uwrq[0], u = uwrq[1];
  1512. return mgt_set_request(netdev_priv(ndev), oid, 0, &u);
  1513. }
  1514. static int
  1515. prism54_set_raw(struct net_device *ndev, struct iw_request_info *info,
  1516. struct iw_point *dwrq, char *extra)
  1517. {
  1518. u32 oid = dwrq->flags;
  1519. return mgt_set_request(netdev_priv(ndev), oid, 0, extra);
  1520. }
  1521. void
  1522. prism54_acl_init(struct islpci_acl *acl)
  1523. {
  1524. mutex_init(&acl->lock);
  1525. INIT_LIST_HEAD(&acl->mac_list);
  1526. acl->size = 0;
  1527. acl->policy = MAC_POLICY_OPEN;
  1528. }
  1529. static void
  1530. prism54_clear_mac(struct islpci_acl *acl)
  1531. {
  1532. struct list_head *ptr, *next;
  1533. struct mac_entry *entry;
  1534. mutex_lock(&acl->lock);
  1535. if (acl->size == 0) {
  1536. mutex_unlock(&acl->lock);
  1537. return;
  1538. }
  1539. for (ptr = acl->mac_list.next, next = ptr->next;
  1540. ptr != &acl->mac_list; ptr = next, next = ptr->next) {
  1541. entry = list_entry(ptr, struct mac_entry, _list);
  1542. list_del(ptr);
  1543. kfree(entry);
  1544. }
  1545. acl->size = 0;
  1546. mutex_unlock(&acl->lock);
  1547. }
  1548. void
  1549. prism54_acl_clean(struct islpci_acl *acl)
  1550. {
  1551. prism54_clear_mac(acl);
  1552. }
  1553. static int
  1554. prism54_add_mac(struct net_device *ndev, struct iw_request_info *info,
  1555. struct sockaddr *awrq, char *extra)
  1556. {
  1557. islpci_private *priv = netdev_priv(ndev);
  1558. struct islpci_acl *acl = &priv->acl;
  1559. struct mac_entry *entry;
  1560. struct sockaddr *addr = (struct sockaddr *) extra;
  1561. if (addr->sa_family != ARPHRD_ETHER)
  1562. return -EOPNOTSUPP;
  1563. entry = kmalloc(sizeof (struct mac_entry), GFP_KERNEL);
  1564. if (entry == NULL)
  1565. return -ENOMEM;
  1566. memcpy(entry->addr, addr->sa_data, ETH_ALEN);
  1567. if (mutex_lock_interruptible(&acl->lock)) {
  1568. kfree(entry);
  1569. return -ERESTARTSYS;
  1570. }
  1571. list_add_tail(&entry->_list, &acl->mac_list);
  1572. acl->size++;
  1573. mutex_unlock(&acl->lock);
  1574. return 0;
  1575. }
  1576. static int
  1577. prism54_del_mac(struct net_device *ndev, struct iw_request_info *info,
  1578. struct sockaddr *awrq, char *extra)
  1579. {
  1580. islpci_private *priv = netdev_priv(ndev);
  1581. struct islpci_acl *acl = &priv->acl;
  1582. struct mac_entry *entry;
  1583. struct sockaddr *addr = (struct sockaddr *) extra;
  1584. if (addr->sa_family != ARPHRD_ETHER)
  1585. return -EOPNOTSUPP;
  1586. if (mutex_lock_interruptible(&acl->lock))
  1587. return -ERESTARTSYS;
  1588. list_for_each_entry(entry, &acl->mac_list, _list) {
  1589. if (ether_addr_equal(entry->addr, addr->sa_data)) {
  1590. list_del(&entry->_list);
  1591. acl->size--;
  1592. kfree(entry);
  1593. mutex_unlock(&acl->lock);
  1594. return 0;
  1595. }
  1596. }
  1597. mutex_unlock(&acl->lock);
  1598. return -EINVAL;
  1599. }
  1600. static int
  1601. prism54_get_mac(struct net_device *ndev, struct iw_request_info *info,
  1602. struct iw_point *dwrq, char *extra)
  1603. {
  1604. islpci_private *priv = netdev_priv(ndev);
  1605. struct islpci_acl *acl = &priv->acl;
  1606. struct mac_entry *entry;
  1607. struct sockaddr *dst = (struct sockaddr *) extra;
  1608. dwrq->length = 0;
  1609. if (mutex_lock_interruptible(&acl->lock))
  1610. return -ERESTARTSYS;
  1611. list_for_each_entry(entry, &acl->mac_list, _list) {
  1612. memcpy(dst->sa_data, entry->addr, ETH_ALEN);
  1613. dst->sa_family = ARPHRD_ETHER;
  1614. dwrq->length++;
  1615. dst++;
  1616. }
  1617. mutex_unlock(&acl->lock);
  1618. return 0;
  1619. }
  1620. /* Setting policy also clears the MAC acl, even if we don't change the default
  1621. * policy
  1622. */
  1623. static int
  1624. prism54_set_policy(struct net_device *ndev, struct iw_request_info *info,
  1625. __u32 * uwrq, char *extra)
  1626. {
  1627. islpci_private *priv = netdev_priv(ndev);
  1628. struct islpci_acl *acl = &priv->acl;
  1629. u32 mlmeautolevel;
  1630. prism54_clear_mac(acl);
  1631. if ((*uwrq < MAC_POLICY_OPEN) || (*uwrq > MAC_POLICY_REJECT))
  1632. return -EINVAL;
  1633. down_write(&priv->mib_sem);
  1634. acl->policy = *uwrq;
  1635. /* the ACL code needs an intermediate mlmeautolevel */
  1636. if ((priv->iw_mode == IW_MODE_MASTER) &&
  1637. (acl->policy != MAC_POLICY_OPEN))
  1638. mlmeautolevel = DOT11_MLME_INTERMEDIATE;
  1639. else
  1640. mlmeautolevel = CARD_DEFAULT_MLME_MODE;
  1641. if (priv->wpa)
  1642. mlmeautolevel = DOT11_MLME_EXTENDED;
  1643. mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlmeautolevel);
  1644. /* restart the card with our new policy */
  1645. if (mgt_commit(priv)) {
  1646. up_write(&priv->mib_sem);
  1647. return -EIO;
  1648. }
  1649. up_write(&priv->mib_sem);
  1650. return 0;
  1651. }
  1652. static int
  1653. prism54_get_policy(struct net_device *ndev, struct iw_request_info *info,
  1654. __u32 * uwrq, char *extra)
  1655. {
  1656. islpci_private *priv = netdev_priv(ndev);
  1657. struct islpci_acl *acl = &priv->acl;
  1658. *uwrq = acl->policy;
  1659. return 0;
  1660. }
  1661. /* Return 1 only if client should be accepted. */
  1662. static int
  1663. prism54_mac_accept(struct islpci_acl *acl, char *mac)
  1664. {
  1665. struct mac_entry *entry;
  1666. int res = 0;
  1667. if (mutex_lock_interruptible(&acl->lock))
  1668. return -ERESTARTSYS;
  1669. if (acl->policy == MAC_POLICY_OPEN) {
  1670. mutex_unlock(&acl->lock);
  1671. return 1;
  1672. }
  1673. list_for_each_entry(entry, &acl->mac_list, _list) {
  1674. if (memcmp(entry->addr, mac, ETH_ALEN) == 0) {
  1675. res = 1;
  1676. break;
  1677. }
  1678. }
  1679. res = (acl->policy == MAC_POLICY_ACCEPT) ? !res : res;
  1680. mutex_unlock(&acl->lock);
  1681. return res;
  1682. }
  1683. static int
  1684. prism54_kick_all(struct net_device *ndev, struct iw_request_info *info,
  1685. struct iw_point *dwrq, char *extra)
  1686. {
  1687. struct obj_mlme *mlme;
  1688. int rvalue;
  1689. mlme = kmalloc(sizeof (struct obj_mlme), GFP_KERNEL);
  1690. if (mlme == NULL)
  1691. return -ENOMEM;
  1692. /* Tell the card to kick every client */
  1693. mlme->id = 0;
  1694. rvalue =
  1695. mgt_set_request(netdev_priv(ndev), DOT11_OID_DISASSOCIATE, 0, mlme);
  1696. kfree(mlme);
  1697. return rvalue;
  1698. }
  1699. static int
  1700. prism54_kick_mac(struct net_device *ndev, struct iw_request_info *info,
  1701. struct sockaddr *awrq, char *extra)
  1702. {
  1703. struct obj_mlme *mlme;
  1704. struct sockaddr *addr = (struct sockaddr *) extra;
  1705. int rvalue;
  1706. if (addr->sa_family != ARPHRD_ETHER)
  1707. return -EOPNOTSUPP;
  1708. mlme = kmalloc(sizeof (struct obj_mlme), GFP_KERNEL);
  1709. if (mlme == NULL)
  1710. return -ENOMEM;
  1711. /* Tell the card to only kick the corresponding bastard */
  1712. memcpy(mlme->address, addr->sa_data, ETH_ALEN);
  1713. mlme->id = -1;
  1714. rvalue =
  1715. mgt_set_request(netdev_priv(ndev), DOT11_OID_DISASSOCIATE, 0, mlme);
  1716. kfree(mlme);
  1717. return rvalue;
  1718. }
  1719. /* Translate a TRAP oid into a wireless event. Called in islpci_mgt_receive. */
  1720. static void
  1721. format_event(islpci_private *priv, char *dest, const char *str,
  1722. const struct obj_mlme *mlme, u16 *length, int error)
  1723. {
  1724. int n = snprintf(dest, IW_CUSTOM_MAX,
  1725. "%s %s %pM %s (%2.2X)",
  1726. str,
  1727. ((priv->iw_mode == IW_MODE_MASTER) ? "from" : "to"),
  1728. mlme->address,
  1729. (error ? (mlme->code ? " : REJECTED " : " : ACCEPTED ")
  1730. : ""), mlme->code);
  1731. BUG_ON(n > IW_CUSTOM_MAX);
  1732. *length = n;
  1733. }
  1734. static void
  1735. send_formatted_event(islpci_private *priv, const char *str,
  1736. const struct obj_mlme *mlme, int error)
  1737. {
  1738. union iwreq_data wrqu;
  1739. char *memptr;
  1740. memptr = kmalloc(IW_CUSTOM_MAX, GFP_KERNEL);
  1741. if (!memptr)
  1742. return;
  1743. wrqu.data.pointer = memptr;
  1744. wrqu.data.length = 0;
  1745. format_event(priv, memptr, str, mlme, &wrqu.data.length,
  1746. error);
  1747. wireless_send_event(priv->ndev, IWEVCUSTOM, &wrqu, memptr);
  1748. kfree(memptr);
  1749. }
  1750. static void
  1751. send_simple_event(islpci_private *priv, const char *str)
  1752. {
  1753. union iwreq_data wrqu;
  1754. char *memptr;
  1755. int n = strlen(str);
  1756. memptr = kmalloc(IW_CUSTOM_MAX, GFP_KERNEL);
  1757. if (!memptr)
  1758. return;
  1759. BUG_ON(n >= IW_CUSTOM_MAX);
  1760. wrqu.data.pointer = memptr;
  1761. wrqu.data.length = n;
  1762. strcpy(memptr, str);
  1763. wireless_send_event(priv->ndev, IWEVCUSTOM, &wrqu, memptr);
  1764. kfree(memptr);
  1765. }
  1766. static void
  1767. link_changed(struct net_device *ndev, u32 bitrate)
  1768. {
  1769. islpci_private *priv = netdev_priv(ndev);
  1770. if (bitrate) {
  1771. netif_carrier_on(ndev);
  1772. if (priv->iw_mode == IW_MODE_INFRA) {
  1773. union iwreq_data uwrq;
  1774. prism54_get_wap(ndev, NULL, (struct sockaddr *) &uwrq,
  1775. NULL);
  1776. wireless_send_event(ndev, SIOCGIWAP, &uwrq, NULL);
  1777. } else
  1778. send_simple_event(netdev_priv(ndev),
  1779. "Link established");
  1780. } else {
  1781. netif_carrier_off(ndev);
  1782. send_simple_event(netdev_priv(ndev), "Link lost");
  1783. }
  1784. }
  1785. /* Beacon/ProbeResp payload header */
  1786. struct ieee80211_beacon_phdr {
  1787. u8 timestamp[8];
  1788. u16 beacon_int;
  1789. u16 capab_info;
  1790. } __packed;
  1791. #define WLAN_EID_GENERIC 0xdd
  1792. static u8 wpa_oid[4] = { 0x00, 0x50, 0xf2, 1 };
  1793. static void
  1794. prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
  1795. u8 *wpa_ie, size_t wpa_ie_len)
  1796. {
  1797. struct list_head *ptr;
  1798. struct islpci_bss_wpa_ie *bss = NULL;
  1799. if (wpa_ie_len > MAX_WPA_IE_LEN)
  1800. wpa_ie_len = MAX_WPA_IE_LEN;
  1801. mutex_lock(&priv->wpa_lock);
  1802. /* try to use existing entry */
  1803. list_for_each(ptr, &priv->bss_wpa_list) {
  1804. bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
  1805. if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0) {
  1806. list_move(&bss->list, &priv->bss_wpa_list);
  1807. break;
  1808. }
  1809. bss = NULL;
  1810. }
  1811. if (bss == NULL) {
  1812. /* add a new BSS entry; if max number of entries is already
  1813. * reached, replace the least recently updated */
  1814. if (priv->num_bss_wpa >= MAX_BSS_WPA_IE_COUNT) {
  1815. bss = list_entry(priv->bss_wpa_list.prev,
  1816. struct islpci_bss_wpa_ie, list);
  1817. list_del(&bss->list);
  1818. } else {
  1819. bss = kzalloc(sizeof (*bss), GFP_ATOMIC);
  1820. if (bss != NULL)
  1821. priv->num_bss_wpa++;
  1822. }
  1823. if (bss != NULL) {
  1824. memcpy(bss->bssid, bssid, ETH_ALEN);
  1825. list_add(&bss->list, &priv->bss_wpa_list);
  1826. }
  1827. }
  1828. if (bss != NULL) {
  1829. memcpy(bss->wpa_ie, wpa_ie, wpa_ie_len);
  1830. bss->wpa_ie_len = wpa_ie_len;
  1831. bss->last_update = jiffies;
  1832. } else {
  1833. printk(KERN_DEBUG "Failed to add BSS WPA entry for "
  1834. "%pM\n", bssid);
  1835. }
  1836. /* expire old entries from WPA list */
  1837. while (priv->num_bss_wpa > 0) {
  1838. bss = list_entry(priv->bss_wpa_list.prev,
  1839. struct islpci_bss_wpa_ie, list);
  1840. if (!time_after(jiffies, bss->last_update + 60 * HZ))
  1841. break;
  1842. list_del(&bss->list);
  1843. priv->num_bss_wpa--;
  1844. kfree(bss);
  1845. }
  1846. mutex_unlock(&priv->wpa_lock);
  1847. }
  1848. static size_t
  1849. prism54_wpa_bss_ie_get(islpci_private *priv, u8 *bssid, u8 *wpa_ie)
  1850. {
  1851. struct list_head *ptr;
  1852. struct islpci_bss_wpa_ie *bss = NULL;
  1853. size_t len = 0;
  1854. mutex_lock(&priv->wpa_lock);
  1855. list_for_each(ptr, &priv->bss_wpa_list) {
  1856. bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
  1857. if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0)
  1858. break;
  1859. bss = NULL;
  1860. }
  1861. if (bss) {
  1862. len = bss->wpa_ie_len;
  1863. memcpy(wpa_ie, bss->wpa_ie, len);
  1864. }
  1865. mutex_unlock(&priv->wpa_lock);
  1866. return len;
  1867. }
  1868. void
  1869. prism54_wpa_bss_ie_init(islpci_private *priv)
  1870. {
  1871. INIT_LIST_HEAD(&priv->bss_wpa_list);
  1872. mutex_init(&priv->wpa_lock);
  1873. }
  1874. void
  1875. prism54_wpa_bss_ie_clean(islpci_private *priv)
  1876. {
  1877. struct islpci_bss_wpa_ie *bss, *n;
  1878. list_for_each_entry_safe(bss, n, &priv->bss_wpa_list, list) {
  1879. kfree(bss);
  1880. }
  1881. }
  1882. static void
  1883. prism54_process_bss_data(islpci_private *priv, u32 oid, u8 *addr,
  1884. u8 *payload, size_t len)
  1885. {
  1886. struct ieee80211_beacon_phdr *hdr;
  1887. u8 *pos, *end;
  1888. if (!priv->wpa)
  1889. return;
  1890. hdr = (struct ieee80211_beacon_phdr *) payload;
  1891. pos = (u8 *) (hdr + 1);
  1892. end = payload + len;
  1893. while (pos < end) {
  1894. if (pos + 2 + pos[1] > end) {
  1895. printk(KERN_DEBUG "Parsing Beacon/ProbeResp failed "
  1896. "for %pM\n", addr);
  1897. return;
  1898. }
  1899. if (pos[0] == WLAN_EID_GENERIC && pos[1] >= 4 &&
  1900. memcmp(pos + 2, wpa_oid, 4) == 0) {
  1901. prism54_wpa_bss_ie_add(priv, addr, pos, pos[1] + 2);
  1902. return;
  1903. }
  1904. pos += 2 + pos[1];
  1905. }
  1906. }
  1907. static void
  1908. handle_request(islpci_private *priv, struct obj_mlme *mlme, enum oid_num_t oid)
  1909. {
  1910. if (((mlme->state == DOT11_STATE_AUTHING) ||
  1911. (mlme->state == DOT11_STATE_ASSOCING))
  1912. && mgt_mlme_answer(priv)) {
  1913. /* Someone is requesting auth and we must respond. Just send back
  1914. * the trap with error code set accordingly.
  1915. */
  1916. mlme->code = prism54_mac_accept(&priv->acl,
  1917. mlme->address) ? 0 : 1;
  1918. mgt_set_request(priv, oid, 0, mlme);
  1919. }
  1920. }
  1921. static int
  1922. prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
  1923. char *data)
  1924. {
  1925. struct obj_mlme *mlme = (struct obj_mlme *) data;
  1926. struct obj_mlmeex *mlmeex = (struct obj_mlmeex *) data;
  1927. struct obj_mlmeex *confirm;
  1928. u8 wpa_ie[MAX_WPA_IE_LEN];
  1929. int wpa_ie_len;
  1930. size_t len = 0; /* u16, better? */
  1931. u8 *payload = NULL, *pos = NULL;
  1932. int ret;
  1933. /* I think all trapable objects are listed here.
  1934. * Some oids have a EX version. The difference is that they are emitted
  1935. * in DOT11_MLME_EXTENDED mode (set with DOT11_OID_MLMEAUTOLEVEL)
  1936. * with more info.
  1937. * The few events already defined by the wireless tools are not really
  1938. * suited. We use the more flexible custom event facility.
  1939. */
  1940. if (oid >= DOT11_OID_BEACON) {
  1941. len = mlmeex->size;
  1942. payload = pos = mlmeex->data;
  1943. }
  1944. /* I fear prism54_process_bss_data won't work with big endian data */
  1945. if ((oid == DOT11_OID_BEACON) || (oid == DOT11_OID_PROBE))
  1946. prism54_process_bss_data(priv, oid, mlmeex->address,
  1947. payload, len);
  1948. mgt_le_to_cpu(isl_oid[oid].flags & OID_FLAG_TYPE, (void *) mlme);
  1949. switch (oid) {
  1950. case GEN_OID_LINKSTATE:
  1951. link_changed(priv->ndev, (u32) *data);
  1952. break;
  1953. case DOT11_OID_MICFAILURE:
  1954. send_simple_event(priv, "Mic failure");
  1955. break;
  1956. case DOT11_OID_DEAUTHENTICATE:
  1957. send_formatted_event(priv, "DeAuthenticate request", mlme, 0);
  1958. break;
  1959. case DOT11_OID_AUTHENTICATE:
  1960. handle_request(priv, mlme, oid);
  1961. send_formatted_event(priv, "Authenticate request", mlme, 1);
  1962. break;
  1963. case DOT11_OID_DISASSOCIATE:
  1964. send_formatted_event(priv, "Disassociate request", mlme, 0);
  1965. break;
  1966. case DOT11_OID_ASSOCIATE:
  1967. handle_request(priv, mlme, oid);
  1968. send_formatted_event(priv, "Associate request", mlme, 1);
  1969. break;
  1970. case DOT11_OID_REASSOCIATE:
  1971. handle_request(priv, mlme, oid);
  1972. send_formatted_event(priv, "ReAssociate request", mlme, 1);
  1973. break;
  1974. case DOT11_OID_BEACON:
  1975. send_formatted_event(priv,
  1976. "Received a beacon from an unknown AP",
  1977. mlme, 0);
  1978. break;
  1979. case DOT11_OID_PROBE:
  1980. /* we received a probe from a client. */
  1981. send_formatted_event(priv, "Received a probe from client", mlme,
  1982. 0);
  1983. break;
  1984. /* Note : "mlme" is actually a "struct obj_mlmeex *" here, but this
  1985. * is backward compatible layout-wise with "struct obj_mlme".
  1986. */
  1987. case DOT11_OID_DEAUTHENTICATEEX:
  1988. send_formatted_event(priv, "DeAuthenticate request", mlme, 0);
  1989. break;
  1990. case DOT11_OID_AUTHENTICATEEX:
  1991. handle_request(priv, mlme, oid);
  1992. send_formatted_event(priv, "Authenticate request (ex)", mlme, 1);
  1993. if (priv->iw_mode != IW_MODE_MASTER
  1994. && mlmeex->state != DOT11_STATE_AUTHING)
  1995. break;
  1996. confirm = kmalloc(sizeof(struct obj_mlmeex) + 6, GFP_ATOMIC);
  1997. if (!confirm)
  1998. break;
  1999. memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
  2000. printk(KERN_DEBUG "Authenticate from: address:\t%pM\n",
  2001. mlmeex->address);
  2002. confirm->id = -1; /* or mlmeex->id ? */
  2003. confirm->state = 0; /* not used */
  2004. confirm->code = 0;
  2005. confirm->size = 6;
  2006. confirm->data[0] = 0x00;
  2007. confirm->data[1] = 0x00;
  2008. confirm->data[2] = 0x02;
  2009. confirm->data[3] = 0x00;
  2010. confirm->data[4] = 0x00;
  2011. confirm->data[5] = 0x00;
  2012. ret = mgt_set_varlen(priv, DOT11_OID_ASSOCIATEEX, confirm, 6);
  2013. kfree(confirm);
  2014. if (ret)
  2015. return ret;
  2016. break;
  2017. case DOT11_OID_DISASSOCIATEEX:
  2018. send_formatted_event(priv, "Disassociate request (ex)", mlme, 0);
  2019. break;
  2020. case DOT11_OID_ASSOCIATEEX:
  2021. handle_request(priv, mlme, oid);
  2022. send_formatted_event(priv, "Associate request (ex)", mlme, 1);
  2023. if (priv->iw_mode != IW_MODE_MASTER
  2024. && mlmeex->state != DOT11_STATE_ASSOCING)
  2025. break;
  2026. confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
  2027. if (!confirm)
  2028. break;
  2029. memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
  2030. confirm->id = ((struct obj_mlmeex *)mlme)->id;
  2031. confirm->state = 0; /* not used */
  2032. confirm->code = 0;
  2033. wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
  2034. if (!wpa_ie_len) {
  2035. printk(KERN_DEBUG "No WPA IE found from address:\t%pM\n",
  2036. mlmeex->address);
  2037. kfree(confirm);
  2038. break;
  2039. }
  2040. confirm->size = wpa_ie_len;
  2041. memcpy(&confirm->data, wpa_ie, wpa_ie_len);
  2042. mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
  2043. kfree(confirm);
  2044. break;
  2045. case DOT11_OID_REASSOCIATEEX:
  2046. handle_request(priv, mlme, oid);
  2047. send_formatted_event(priv, "Reassociate request (ex)", mlme, 1);
  2048. if (priv->iw_mode != IW_MODE_MASTER
  2049. && mlmeex->state != DOT11_STATE_ASSOCING)
  2050. break;
  2051. confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
  2052. if (!confirm)
  2053. break;
  2054. memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
  2055. confirm->id = mlmeex->id;
  2056. confirm->state = 0; /* not used */
  2057. confirm->code = 0;
  2058. wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
  2059. if (!wpa_ie_len) {
  2060. printk(KERN_DEBUG "No WPA IE found from address:\t%pM\n",
  2061. mlmeex->address);
  2062. kfree(confirm);
  2063. break;
  2064. }
  2065. confirm->size = wpa_ie_len;
  2066. memcpy(&confirm->data, wpa_ie, wpa_ie_len);
  2067. mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
  2068. kfree(confirm);
  2069. break;
  2070. default:
  2071. return -EINVAL;
  2072. }
  2073. return 0;
  2074. }
  2075. /*
  2076. * Process a device trap. This is called via schedule_work(), outside of
  2077. * interrupt context, no locks held.
  2078. */
  2079. void
  2080. prism54_process_trap(struct work_struct *work)
  2081. {
  2082. struct islpci_mgmtframe *frame =
  2083. container_of(work, struct islpci_mgmtframe, ws);
  2084. struct net_device *ndev = frame->ndev;
  2085. enum oid_num_t n = mgt_oidtonum(frame->header->oid);
  2086. if (n != OID_NUM_LAST)
  2087. prism54_process_trap_helper(netdev_priv(ndev), n, frame->data);
  2088. islpci_mgt_release(frame);
  2089. }
  2090. int
  2091. prism54_set_mac_address(struct net_device *ndev, void *addr)
  2092. {
  2093. islpci_private *priv = netdev_priv(ndev);
  2094. int ret;
  2095. if (ndev->addr_len != 6)
  2096. return -EINVAL;
  2097. ret = mgt_set_request(priv, GEN_OID_MACADDRESS, 0,
  2098. &((struct sockaddr *) addr)->sa_data);
  2099. if (!ret)
  2100. memcpy(priv->ndev->dev_addr,
  2101. &((struct sockaddr *) addr)->sa_data, ETH_ALEN);
  2102. return ret;
  2103. }
  2104. #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
  2105. static int
  2106. prism54_set_wpa(struct net_device *ndev, struct iw_request_info *info,
  2107. __u32 * uwrq, char *extra)
  2108. {
  2109. islpci_private *priv = netdev_priv(ndev);
  2110. u32 mlme, authen, dot1x, filter, wep;
  2111. if (islpci_get_state(priv) < PRV_STATE_INIT)
  2112. return 0;
  2113. wep = 1; /* For privacy invoked */
  2114. filter = 1; /* Filter out all unencrypted frames */
  2115. dot1x = 0x01; /* To enable eap filter */
  2116. mlme = DOT11_MLME_EXTENDED;
  2117. authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
  2118. down_write(&priv->mib_sem);
  2119. priv->wpa = *uwrq;
  2120. switch (priv->wpa) {
  2121. default:
  2122. case 0: /* Clears/disables WPA and friends */
  2123. wep = 0;
  2124. filter = 0; /* Do not filter un-encrypted data */
  2125. dot1x = 0;
  2126. mlme = DOT11_MLME_AUTO;
  2127. printk("%s: Disabling WPA\n", ndev->name);
  2128. break;
  2129. case 2:
  2130. case 1: /* WPA */
  2131. printk("%s: Enabling WPA\n", ndev->name);
  2132. break;
  2133. }
  2134. up_write(&priv->mib_sem);
  2135. mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
  2136. mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &wep);
  2137. mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, &filter);
  2138. mgt_set_request(priv, DOT11_OID_DOT1XENABLE, 0, &dot1x);
  2139. mgt_set_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, &mlme);
  2140. return 0;
  2141. }
  2142. static int
  2143. prism54_get_wpa(struct net_device *ndev, struct iw_request_info *info,
  2144. __u32 * uwrq, char *extra)
  2145. {
  2146. islpci_private *priv = netdev_priv(ndev);
  2147. *uwrq = priv->wpa;
  2148. return 0;
  2149. }
  2150. static int
  2151. prism54_set_prismhdr(struct net_device *ndev, struct iw_request_info *info,
  2152. __u32 * uwrq, char *extra)
  2153. {
  2154. islpci_private *priv = netdev_priv(ndev);
  2155. priv->monitor_type =
  2156. (*uwrq ? ARPHRD_IEEE80211_PRISM : ARPHRD_IEEE80211);
  2157. if (priv->iw_mode == IW_MODE_MONITOR)
  2158. priv->ndev->type = priv->monitor_type;
  2159. return 0;
  2160. }
  2161. static int
  2162. prism54_get_prismhdr(struct net_device *ndev, struct iw_request_info *info,
  2163. __u32 * uwrq, char *extra)
  2164. {
  2165. islpci_private *priv = netdev_priv(ndev);
  2166. *uwrq = (priv->monitor_type == ARPHRD_IEEE80211_PRISM);
  2167. return 0;
  2168. }
  2169. static int
  2170. prism54_debug_oid(struct net_device *ndev, struct iw_request_info *info,
  2171. __u32 * uwrq, char *extra)
  2172. {
  2173. islpci_private *priv = netdev_priv(ndev);
  2174. priv->priv_oid = *uwrq;
  2175. printk("%s: oid 0x%08X\n", ndev->name, *uwrq);
  2176. return 0;
  2177. }
  2178. static int
  2179. prism54_debug_get_oid(struct net_device *ndev, struct iw_request_info *info,
  2180. struct iw_point *data, char *extra)
  2181. {
  2182. islpci_private *priv = netdev_priv(ndev);
  2183. struct islpci_mgmtframe *response;
  2184. int ret = -EIO;
  2185. printk("%s: get_oid 0x%08X\n", ndev->name, priv->priv_oid);
  2186. data->length = 0;
  2187. if (islpci_get_state(priv) >= PRV_STATE_INIT) {
  2188. ret =
  2189. islpci_mgt_transaction(priv->ndev, PIMFOR_OP_GET,
  2190. priv->priv_oid, extra, 256,
  2191. &response);
  2192. printk("%s: ret: %i\n", ndev->name, ret);
  2193. if (ret || !response
  2194. || response->header->operation == PIMFOR_OP_ERROR) {
  2195. if (response) {
  2196. islpci_mgt_release(response);
  2197. }
  2198. printk("%s: EIO\n", ndev->name);
  2199. ret = -EIO;
  2200. }
  2201. if (!ret) {
  2202. data->length = response->header->length;
  2203. memcpy(extra, response->data, data->length);
  2204. islpci_mgt_release(response);
  2205. printk("%s: len: %i\n", ndev->name, data->length);
  2206. }
  2207. }
  2208. return ret;
  2209. }
  2210. static int
  2211. prism54_debug_set_oid(struct net_device *ndev, struct iw_request_info *info,
  2212. struct iw_point *data, char *extra)
  2213. {
  2214. islpci_private *priv = netdev_priv(ndev);
  2215. struct islpci_mgmtframe *response;
  2216. int ret = 0, response_op = PIMFOR_OP_ERROR;
  2217. printk("%s: set_oid 0x%08X\tlen: %d\n", ndev->name, priv->priv_oid,
  2218. data->length);
  2219. if (islpci_get_state(priv) >= PRV_STATE_INIT) {
  2220. ret =
  2221. islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET,
  2222. priv->priv_oid, extra, data->length,
  2223. &response);
  2224. printk("%s: ret: %i\n", ndev->name, ret);
  2225. if (ret || !response
  2226. || response->header->operation == PIMFOR_OP_ERROR) {
  2227. if (response) {
  2228. islpci_mgt_release(response);
  2229. }
  2230. printk("%s: EIO\n", ndev->name);
  2231. ret = -EIO;
  2232. }
  2233. if (!ret) {
  2234. response_op = response->header->operation;
  2235. printk("%s: response_op: %i\n", ndev->name,
  2236. response_op);
  2237. islpci_mgt_release(response);
  2238. }
  2239. }
  2240. return (ret ? ret : -EINPROGRESS);
  2241. }
  2242. static int
  2243. prism54_set_spy(struct net_device *ndev,
  2244. struct iw_request_info *info,
  2245. union iwreq_data *uwrq, char *extra)
  2246. {
  2247. islpci_private *priv = netdev_priv(ndev);
  2248. u32 u;
  2249. enum oid_num_t oid = OID_INL_CONFIG;
  2250. down_write(&priv->mib_sem);
  2251. mgt_get(priv, OID_INL_CONFIG, &u);
  2252. if ((uwrq->data.length == 0) && (priv->spy_data.spy_number > 0))
  2253. /* disable spy */
  2254. u &= ~INL_CONFIG_RXANNEX;
  2255. else if ((uwrq->data.length > 0) && (priv->spy_data.spy_number == 0))
  2256. /* enable spy */
  2257. u |= INL_CONFIG_RXANNEX;
  2258. mgt_set(priv, OID_INL_CONFIG, &u);
  2259. mgt_commit_list(priv, &oid, 1);
  2260. up_write(&priv->mib_sem);
  2261. return iw_handler_set_spy(ndev, info, uwrq, extra);
  2262. }
  2263. static const iw_handler prism54_handler[] = {
  2264. (iw_handler) prism54_commit, /* SIOCSIWCOMMIT */
  2265. (iw_handler) prism54_get_name, /* SIOCGIWNAME */
  2266. (iw_handler) NULL, /* SIOCSIWNWID */
  2267. (iw_handler) NULL, /* SIOCGIWNWID */
  2268. (iw_handler) prism54_set_freq, /* SIOCSIWFREQ */
  2269. (iw_handler) prism54_get_freq, /* SIOCGIWFREQ */
  2270. (iw_handler) prism54_set_mode, /* SIOCSIWMODE */
  2271. (iw_handler) prism54_get_mode, /* SIOCGIWMODE */
  2272. (iw_handler) prism54_set_sens, /* SIOCSIWSENS */
  2273. (iw_handler) prism54_get_sens, /* SIOCGIWSENS */
  2274. (iw_handler) NULL, /* SIOCSIWRANGE */
  2275. (iw_handler) prism54_get_range, /* SIOCGIWRANGE */
  2276. (iw_handler) NULL, /* SIOCSIWPRIV */
  2277. (iw_handler) NULL, /* SIOCGIWPRIV */
  2278. (iw_handler) NULL, /* SIOCSIWSTATS */
  2279. (iw_handler) NULL, /* SIOCGIWSTATS */
  2280. prism54_set_spy, /* SIOCSIWSPY */
  2281. iw_handler_get_spy, /* SIOCGIWSPY */
  2282. iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
  2283. iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
  2284. (iw_handler) prism54_set_wap, /* SIOCSIWAP */
  2285. (iw_handler) prism54_get_wap, /* SIOCGIWAP */
  2286. (iw_handler) NULL, /* -- hole -- */
  2287. (iw_handler) NULL, /* SIOCGIWAPLIST deprecated */
  2288. (iw_handler) prism54_set_scan, /* SIOCSIWSCAN */
  2289. (iw_handler) prism54_get_scan, /* SIOCGIWSCAN */
  2290. (iw_handler) prism54_set_essid, /* SIOCSIWESSID */
  2291. (iw_handler) prism54_get_essid, /* SIOCGIWESSID */
  2292. (iw_handler) prism54_set_nick, /* SIOCSIWNICKN */
  2293. (iw_handler) prism54_get_nick, /* SIOCGIWNICKN */
  2294. (iw_handler) NULL, /* -- hole -- */
  2295. (iw_handler) NULL, /* -- hole -- */
  2296. (iw_handler) prism54_set_rate, /* SIOCSIWRATE */
  2297. (iw_handler) prism54_get_rate, /* SIOCGIWRATE */
  2298. (iw_handler) prism54_set_rts, /* SIOCSIWRTS */
  2299. (iw_handler) prism54_get_rts, /* SIOCGIWRTS */
  2300. (iw_handler) prism54_set_frag, /* SIOCSIWFRAG */
  2301. (iw_handler) prism54_get_frag, /* SIOCGIWFRAG */
  2302. (iw_handler) prism54_set_txpower, /* SIOCSIWTXPOW */
  2303. (iw_handler) prism54_get_txpower, /* SIOCGIWTXPOW */
  2304. (iw_handler) prism54_set_retry, /* SIOCSIWRETRY */
  2305. (iw_handler) prism54_get_retry, /* SIOCGIWRETRY */
  2306. (iw_handler) prism54_set_encode, /* SIOCSIWENCODE */
  2307. (iw_handler) prism54_get_encode, /* SIOCGIWENCODE */
  2308. (iw_handler) NULL, /* SIOCSIWPOWER */
  2309. (iw_handler) NULL, /* SIOCGIWPOWER */
  2310. NULL, /* -- hole -- */
  2311. NULL, /* -- hole -- */
  2312. (iw_handler) prism54_set_genie, /* SIOCSIWGENIE */
  2313. (iw_handler) prism54_get_genie, /* SIOCGIWGENIE */
  2314. (iw_handler) prism54_set_auth, /* SIOCSIWAUTH */
  2315. (iw_handler) prism54_get_auth, /* SIOCGIWAUTH */
  2316. (iw_handler) prism54_set_encodeext, /* SIOCSIWENCODEEXT */
  2317. (iw_handler) prism54_get_encodeext, /* SIOCGIWENCODEEXT */
  2318. NULL, /* SIOCSIWPMKSA */
  2319. };
  2320. /* The low order bit identify a SET (0) or a GET (1) ioctl. */
  2321. #define PRISM54_RESET SIOCIWFIRSTPRIV
  2322. #define PRISM54_GET_POLICY SIOCIWFIRSTPRIV+1
  2323. #define PRISM54_SET_POLICY SIOCIWFIRSTPRIV+2
  2324. #define PRISM54_GET_MAC SIOCIWFIRSTPRIV+3
  2325. #define PRISM54_ADD_MAC SIOCIWFIRSTPRIV+4
  2326. #define PRISM54_DEL_MAC SIOCIWFIRSTPRIV+6
  2327. #define PRISM54_KICK_MAC SIOCIWFIRSTPRIV+8
  2328. #define PRISM54_KICK_ALL SIOCIWFIRSTPRIV+10
  2329. #define PRISM54_GET_WPA SIOCIWFIRSTPRIV+11
  2330. #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
  2331. #define PRISM54_DBG_OID SIOCIWFIRSTPRIV+14
  2332. #define PRISM54_DBG_GET_OID SIOCIWFIRSTPRIV+15
  2333. #define PRISM54_DBG_SET_OID SIOCIWFIRSTPRIV+16
  2334. #define PRISM54_GET_OID SIOCIWFIRSTPRIV+17
  2335. #define PRISM54_SET_OID_U32 SIOCIWFIRSTPRIV+18
  2336. #define PRISM54_SET_OID_STR SIOCIWFIRSTPRIV+20
  2337. #define PRISM54_SET_OID_ADDR SIOCIWFIRSTPRIV+22
  2338. #define PRISM54_GET_PRISMHDR SIOCIWFIRSTPRIV+23
  2339. #define PRISM54_SET_PRISMHDR SIOCIWFIRSTPRIV+24
  2340. #define IWPRIV_SET_U32(n,x) { n, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
  2341. #define IWPRIV_SET_SSID(n,x) { n, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
  2342. #define IWPRIV_SET_ADDR(n,x) { n, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
  2343. #define IWPRIV_GET(n,x) { n, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, "g_"x }
  2344. #define IWPRIV_U32(n,x) IWPRIV_SET_U32(n,x), IWPRIV_GET(n,x)
  2345. #define IWPRIV_SSID(n,x) IWPRIV_SET_SSID(n,x), IWPRIV_GET(n,x)
  2346. #define IWPRIV_ADDR(n,x) IWPRIV_SET_ADDR(n,x), IWPRIV_GET(n,x)
  2347. /* Note : limited to 128 private ioctls (wireless tools 26) */
  2348. static const struct iw_priv_args prism54_private_args[] = {
  2349. /*{ cmd, set_args, get_args, name } */
  2350. {PRISM54_RESET, 0, 0, "reset"},
  2351. {PRISM54_GET_PRISMHDR, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  2352. "get_prismhdr"},
  2353. {PRISM54_SET_PRISMHDR, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
  2354. "set_prismhdr"},
  2355. {PRISM54_GET_POLICY, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  2356. "getPolicy"},
  2357. {PRISM54_SET_POLICY, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
  2358. "setPolicy"},
  2359. {PRISM54_GET_MAC, 0, IW_PRIV_TYPE_ADDR | 64, "getMac"},
  2360. {PRISM54_ADD_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
  2361. "addMac"},
  2362. {PRISM54_DEL_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
  2363. "delMac"},
  2364. {PRISM54_KICK_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
  2365. "kickMac"},
  2366. {PRISM54_KICK_ALL, 0, 0, "kickAll"},
  2367. {PRISM54_GET_WPA, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  2368. "get_wpa"},
  2369. {PRISM54_SET_WPA, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
  2370. "set_wpa"},
  2371. {PRISM54_DBG_OID, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
  2372. "dbg_oid"},
  2373. {PRISM54_DBG_GET_OID, 0, IW_PRIV_TYPE_BYTE | 256, "dbg_get_oid"},
  2374. {PRISM54_DBG_SET_OID, IW_PRIV_TYPE_BYTE | 256, 0, "dbg_set_oid"},
  2375. /* --- sub-ioctls handlers --- */
  2376. {PRISM54_GET_OID,
  2377. 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, ""},
  2378. {PRISM54_SET_OID_U32,
  2379. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, ""},
  2380. {PRISM54_SET_OID_STR,
  2381. IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 1, 0, ""},
  2382. {PRISM54_SET_OID_ADDR,
  2383. IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, ""},
  2384. /* --- sub-ioctls definitions --- */
  2385. IWPRIV_ADDR(GEN_OID_MACADDRESS, "addr"),
  2386. IWPRIV_GET(GEN_OID_LINKSTATE, "linkstate"),
  2387. IWPRIV_U32(DOT11_OID_BSSTYPE, "bsstype"),
  2388. IWPRIV_ADDR(DOT11_OID_BSSID, "bssid"),
  2389. IWPRIV_U32(DOT11_OID_STATE, "state"),
  2390. IWPRIV_U32(DOT11_OID_AID, "aid"),
  2391. IWPRIV_SSID(DOT11_OID_SSIDOVERRIDE, "ssidoverride"),
  2392. IWPRIV_U32(DOT11_OID_MEDIUMLIMIT, "medlimit"),
  2393. IWPRIV_U32(DOT11_OID_BEACONPERIOD, "beacon"),
  2394. IWPRIV_U32(DOT11_OID_DTIMPERIOD, "dtimperiod"),
  2395. IWPRIV_U32(DOT11_OID_AUTHENABLE, "authenable"),
  2396. IWPRIV_U32(DOT11_OID_PRIVACYINVOKED, "privinvok"),
  2397. IWPRIV_U32(DOT11_OID_EXUNENCRYPTED, "exunencrypt"),
  2398. IWPRIV_U32(DOT11_OID_REKEYTHRESHOLD, "rekeythresh"),
  2399. IWPRIV_U32(DOT11_OID_MAXTXLIFETIME, "maxtxlife"),
  2400. IWPRIV_U32(DOT11_OID_MAXRXLIFETIME, "maxrxlife"),
  2401. IWPRIV_U32(DOT11_OID_ALOFT_FIXEDRATE, "fixedrate"),
  2402. IWPRIV_U32(DOT11_OID_MAXFRAMEBURST, "frameburst"),
  2403. IWPRIV_U32(DOT11_OID_PSM, "psm"),
  2404. IWPRIV_U32(DOT11_OID_BRIDGELOCAL, "bridge"),
  2405. IWPRIV_U32(DOT11_OID_CLIENTS, "clients"),
  2406. IWPRIV_U32(DOT11_OID_CLIENTSASSOCIATED, "clientassoc"),
  2407. IWPRIV_U32(DOT11_OID_DOT1XENABLE, "dot1xenable"),
  2408. IWPRIV_U32(DOT11_OID_ANTENNARX, "rxant"),
  2409. IWPRIV_U32(DOT11_OID_ANTENNATX, "txant"),
  2410. IWPRIV_U32(DOT11_OID_ANTENNADIVERSITY, "antdivers"),
  2411. IWPRIV_U32(DOT11_OID_EDTHRESHOLD, "edthresh"),
  2412. IWPRIV_U32(DOT11_OID_PREAMBLESETTINGS, "preamble"),
  2413. IWPRIV_GET(DOT11_OID_RATES, "rates"),
  2414. IWPRIV_U32(DOT11_OID_OUTPUTPOWER, ".11outpower"),
  2415. IWPRIV_GET(DOT11_OID_SUPPORTEDRATES, "supprates"),
  2416. IWPRIV_GET(DOT11_OID_SUPPORTEDFREQUENCIES, "suppfreq"),
  2417. IWPRIV_U32(DOT11_OID_NOISEFLOOR, "noisefloor"),
  2418. IWPRIV_GET(DOT11_OID_FREQUENCYACTIVITY, "freqactivity"),
  2419. IWPRIV_U32(DOT11_OID_NONERPPROTECTION, "nonerpprotec"),
  2420. IWPRIV_U32(DOT11_OID_PROFILES, "profile"),
  2421. IWPRIV_GET(DOT11_OID_EXTENDEDRATES, "extrates"),
  2422. IWPRIV_U32(DOT11_OID_MLMEAUTOLEVEL, "mlmelevel"),
  2423. IWPRIV_GET(DOT11_OID_BSSS, "bsss"),
  2424. IWPRIV_GET(DOT11_OID_BSSLIST, "bsslist"),
  2425. IWPRIV_U32(OID_INL_MODE, "mode"),
  2426. IWPRIV_U32(OID_INL_CONFIG, "config"),
  2427. IWPRIV_U32(OID_INL_DOT11D_CONFORMANCE, ".11dconform"),
  2428. IWPRIV_GET(OID_INL_PHYCAPABILITIES, "phycapa"),
  2429. IWPRIV_U32(OID_INL_OUTPUTPOWER, "outpower"),
  2430. };
  2431. static const iw_handler prism54_private_handler[] = {
  2432. (iw_handler) prism54_reset,
  2433. (iw_handler) prism54_get_policy,
  2434. (iw_handler) prism54_set_policy,
  2435. (iw_handler) prism54_get_mac,
  2436. (iw_handler) prism54_add_mac,
  2437. (iw_handler) NULL,
  2438. (iw_handler) prism54_del_mac,
  2439. (iw_handler) NULL,
  2440. (iw_handler) prism54_kick_mac,
  2441. (iw_handler) NULL,
  2442. (iw_handler) prism54_kick_all,
  2443. (iw_handler) prism54_get_wpa,
  2444. (iw_handler) prism54_set_wpa,
  2445. (iw_handler) NULL,
  2446. (iw_handler) prism54_debug_oid,
  2447. (iw_handler) prism54_debug_get_oid,
  2448. (iw_handler) prism54_debug_set_oid,
  2449. (iw_handler) prism54_get_oid,
  2450. (iw_handler) prism54_set_u32,
  2451. (iw_handler) NULL,
  2452. (iw_handler) prism54_set_raw,
  2453. (iw_handler) NULL,
  2454. (iw_handler) prism54_set_raw,
  2455. (iw_handler) prism54_get_prismhdr,
  2456. (iw_handler) prism54_set_prismhdr,
  2457. };
  2458. const struct iw_handler_def prism54_handler_def = {
  2459. .num_standard = ARRAY_SIZE(prism54_handler),
  2460. .num_private = ARRAY_SIZE(prism54_private_handler),
  2461. .num_private_args = ARRAY_SIZE(prism54_private_args),
  2462. .standard = (iw_handler *) prism54_handler,
  2463. .private = (iw_handler *) prism54_private_handler,
  2464. .private_args = (struct iw_priv_args *) prism54_private_args,
  2465. .get_wireless_stats = prism54_get_wireless_stats,
  2466. };