isl_ioctl.c 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912
  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 <linux/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. /* fall through */
  1449. case DOT11_AUTH_OS:
  1450. default:
  1451. wrqu->encoding.flags |= IW_ENCODE_OPEN;
  1452. break;
  1453. }
  1454. down_write(&priv->mib_sem);
  1455. wpa = priv->wpa;
  1456. up_write(&priv->mib_sem);
  1457. if (authen == DOT11_AUTH_OS && !exunencrypt && !invoke && !wpa) {
  1458. /* No encryption */
  1459. ext->alg = IW_ENCODE_ALG_NONE;
  1460. ext->key_len = 0;
  1461. wrqu->encoding.flags |= IW_ENCODE_DISABLED;
  1462. } else {
  1463. struct obj_key *key;
  1464. ret = mgt_get_request(priv, DOT11_OID_DEFKEYX, idx, NULL, &r);
  1465. if (ret < 0)
  1466. goto out;
  1467. key = r.ptr;
  1468. if (max_key_len < key->length) {
  1469. ret = -E2BIG;
  1470. goto out;
  1471. }
  1472. memcpy(ext->key, key->key, key->length);
  1473. ext->key_len = key->length;
  1474. switch (key->type) {
  1475. case DOT11_PRIV_TKIP:
  1476. ext->alg = IW_ENCODE_ALG_TKIP;
  1477. break;
  1478. default:
  1479. case DOT11_PRIV_WEP:
  1480. ext->alg = IW_ENCODE_ALG_WEP;
  1481. break;
  1482. }
  1483. wrqu->encoding.flags |= IW_ENCODE_ENABLED;
  1484. }
  1485. out:
  1486. return ret;
  1487. }
  1488. static int
  1489. prism54_reset(struct net_device *ndev, struct iw_request_info *info,
  1490. __u32 * uwrq, char *extra)
  1491. {
  1492. islpci_reset(netdev_priv(ndev), 0);
  1493. return 0;
  1494. }
  1495. static int
  1496. prism54_get_oid(struct net_device *ndev, struct iw_request_info *info,
  1497. struct iw_point *dwrq, char *extra)
  1498. {
  1499. union oid_res_t r;
  1500. int rvalue;
  1501. enum oid_num_t n = dwrq->flags;
  1502. rvalue = mgt_get_request(netdev_priv(ndev), n, 0, NULL, &r);
  1503. dwrq->length = mgt_response_to_str(n, &r, extra);
  1504. if ((isl_oid[n].flags & OID_FLAG_TYPE) != OID_TYPE_U32)
  1505. kfree(r.ptr);
  1506. return rvalue;
  1507. }
  1508. static int
  1509. prism54_set_u32(struct net_device *ndev, struct iw_request_info *info,
  1510. __u32 * uwrq, char *extra)
  1511. {
  1512. u32 oid = uwrq[0], u = uwrq[1];
  1513. return mgt_set_request(netdev_priv(ndev), oid, 0, &u);
  1514. }
  1515. static int
  1516. prism54_set_raw(struct net_device *ndev, struct iw_request_info *info,
  1517. struct iw_point *dwrq, char *extra)
  1518. {
  1519. u32 oid = dwrq->flags;
  1520. return mgt_set_request(netdev_priv(ndev), oid, 0, extra);
  1521. }
  1522. void
  1523. prism54_acl_init(struct islpci_acl *acl)
  1524. {
  1525. mutex_init(&acl->lock);
  1526. INIT_LIST_HEAD(&acl->mac_list);
  1527. acl->size = 0;
  1528. acl->policy = MAC_POLICY_OPEN;
  1529. }
  1530. static void
  1531. prism54_clear_mac(struct islpci_acl *acl)
  1532. {
  1533. struct list_head *ptr, *next;
  1534. struct mac_entry *entry;
  1535. mutex_lock(&acl->lock);
  1536. if (acl->size == 0) {
  1537. mutex_unlock(&acl->lock);
  1538. return;
  1539. }
  1540. for (ptr = acl->mac_list.next, next = ptr->next;
  1541. ptr != &acl->mac_list; ptr = next, next = ptr->next) {
  1542. entry = list_entry(ptr, struct mac_entry, _list);
  1543. list_del(ptr);
  1544. kfree(entry);
  1545. }
  1546. acl->size = 0;
  1547. mutex_unlock(&acl->lock);
  1548. }
  1549. void
  1550. prism54_acl_clean(struct islpci_acl *acl)
  1551. {
  1552. prism54_clear_mac(acl);
  1553. }
  1554. static int
  1555. prism54_add_mac(struct net_device *ndev, struct iw_request_info *info,
  1556. struct sockaddr *awrq, char *extra)
  1557. {
  1558. islpci_private *priv = netdev_priv(ndev);
  1559. struct islpci_acl *acl = &priv->acl;
  1560. struct mac_entry *entry;
  1561. struct sockaddr *addr = (struct sockaddr *) extra;
  1562. if (addr->sa_family != ARPHRD_ETHER)
  1563. return -EOPNOTSUPP;
  1564. entry = kmalloc(sizeof (struct mac_entry), GFP_KERNEL);
  1565. if (entry == NULL)
  1566. return -ENOMEM;
  1567. memcpy(entry->addr, addr->sa_data, ETH_ALEN);
  1568. if (mutex_lock_interruptible(&acl->lock)) {
  1569. kfree(entry);
  1570. return -ERESTARTSYS;
  1571. }
  1572. list_add_tail(&entry->_list, &acl->mac_list);
  1573. acl->size++;
  1574. mutex_unlock(&acl->lock);
  1575. return 0;
  1576. }
  1577. static int
  1578. prism54_del_mac(struct net_device *ndev, struct iw_request_info *info,
  1579. struct sockaddr *awrq, char *extra)
  1580. {
  1581. islpci_private *priv = netdev_priv(ndev);
  1582. struct islpci_acl *acl = &priv->acl;
  1583. struct mac_entry *entry;
  1584. struct sockaddr *addr = (struct sockaddr *) extra;
  1585. if (addr->sa_family != ARPHRD_ETHER)
  1586. return -EOPNOTSUPP;
  1587. if (mutex_lock_interruptible(&acl->lock))
  1588. return -ERESTARTSYS;
  1589. list_for_each_entry(entry, &acl->mac_list, _list) {
  1590. if (ether_addr_equal(entry->addr, addr->sa_data)) {
  1591. list_del(&entry->_list);
  1592. acl->size--;
  1593. kfree(entry);
  1594. mutex_unlock(&acl->lock);
  1595. return 0;
  1596. }
  1597. }
  1598. mutex_unlock(&acl->lock);
  1599. return -EINVAL;
  1600. }
  1601. static int
  1602. prism54_get_mac(struct net_device *ndev, struct iw_request_info *info,
  1603. struct iw_point *dwrq, char *extra)
  1604. {
  1605. islpci_private *priv = netdev_priv(ndev);
  1606. struct islpci_acl *acl = &priv->acl;
  1607. struct mac_entry *entry;
  1608. struct sockaddr *dst = (struct sockaddr *) extra;
  1609. dwrq->length = 0;
  1610. if (mutex_lock_interruptible(&acl->lock))
  1611. return -ERESTARTSYS;
  1612. list_for_each_entry(entry, &acl->mac_list, _list) {
  1613. memcpy(dst->sa_data, entry->addr, ETH_ALEN);
  1614. dst->sa_family = ARPHRD_ETHER;
  1615. dwrq->length++;
  1616. dst++;
  1617. }
  1618. mutex_unlock(&acl->lock);
  1619. return 0;
  1620. }
  1621. /* Setting policy also clears the MAC acl, even if we don't change the default
  1622. * policy
  1623. */
  1624. static int
  1625. prism54_set_policy(struct net_device *ndev, struct iw_request_info *info,
  1626. __u32 * uwrq, char *extra)
  1627. {
  1628. islpci_private *priv = netdev_priv(ndev);
  1629. struct islpci_acl *acl = &priv->acl;
  1630. u32 mlmeautolevel;
  1631. prism54_clear_mac(acl);
  1632. if ((*uwrq < MAC_POLICY_OPEN) || (*uwrq > MAC_POLICY_REJECT))
  1633. return -EINVAL;
  1634. down_write(&priv->mib_sem);
  1635. acl->policy = *uwrq;
  1636. /* the ACL code needs an intermediate mlmeautolevel */
  1637. if ((priv->iw_mode == IW_MODE_MASTER) &&
  1638. (acl->policy != MAC_POLICY_OPEN))
  1639. mlmeautolevel = DOT11_MLME_INTERMEDIATE;
  1640. else
  1641. mlmeautolevel = CARD_DEFAULT_MLME_MODE;
  1642. if (priv->wpa)
  1643. mlmeautolevel = DOT11_MLME_EXTENDED;
  1644. mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlmeautolevel);
  1645. /* restart the card with our new policy */
  1646. if (mgt_commit(priv)) {
  1647. up_write(&priv->mib_sem);
  1648. return -EIO;
  1649. }
  1650. up_write(&priv->mib_sem);
  1651. return 0;
  1652. }
  1653. static int
  1654. prism54_get_policy(struct net_device *ndev, struct iw_request_info *info,
  1655. __u32 * uwrq, char *extra)
  1656. {
  1657. islpci_private *priv = netdev_priv(ndev);
  1658. struct islpci_acl *acl = &priv->acl;
  1659. *uwrq = acl->policy;
  1660. return 0;
  1661. }
  1662. /* Return 1 only if client should be accepted. */
  1663. static int
  1664. prism54_mac_accept(struct islpci_acl *acl, char *mac)
  1665. {
  1666. struct mac_entry *entry;
  1667. int res = 0;
  1668. if (mutex_lock_interruptible(&acl->lock))
  1669. return -ERESTARTSYS;
  1670. if (acl->policy == MAC_POLICY_OPEN) {
  1671. mutex_unlock(&acl->lock);
  1672. return 1;
  1673. }
  1674. list_for_each_entry(entry, &acl->mac_list, _list) {
  1675. if (memcmp(entry->addr, mac, ETH_ALEN) == 0) {
  1676. res = 1;
  1677. break;
  1678. }
  1679. }
  1680. res = (acl->policy == MAC_POLICY_ACCEPT) ? !res : res;
  1681. mutex_unlock(&acl->lock);
  1682. return res;
  1683. }
  1684. static int
  1685. prism54_kick_all(struct net_device *ndev, struct iw_request_info *info,
  1686. struct iw_point *dwrq, char *extra)
  1687. {
  1688. struct obj_mlme *mlme;
  1689. int rvalue;
  1690. mlme = kmalloc(sizeof (struct obj_mlme), GFP_KERNEL);
  1691. if (mlme == NULL)
  1692. return -ENOMEM;
  1693. /* Tell the card to kick every client */
  1694. mlme->id = 0;
  1695. rvalue =
  1696. mgt_set_request(netdev_priv(ndev), DOT11_OID_DISASSOCIATE, 0, mlme);
  1697. kfree(mlme);
  1698. return rvalue;
  1699. }
  1700. static int
  1701. prism54_kick_mac(struct net_device *ndev, struct iw_request_info *info,
  1702. struct sockaddr *awrq, char *extra)
  1703. {
  1704. struct obj_mlme *mlme;
  1705. struct sockaddr *addr = (struct sockaddr *) extra;
  1706. int rvalue;
  1707. if (addr->sa_family != ARPHRD_ETHER)
  1708. return -EOPNOTSUPP;
  1709. mlme = kmalloc(sizeof (struct obj_mlme), GFP_KERNEL);
  1710. if (mlme == NULL)
  1711. return -ENOMEM;
  1712. /* Tell the card to only kick the corresponding bastard */
  1713. memcpy(mlme->address, addr->sa_data, ETH_ALEN);
  1714. mlme->id = -1;
  1715. rvalue =
  1716. mgt_set_request(netdev_priv(ndev), DOT11_OID_DISASSOCIATE, 0, mlme);
  1717. kfree(mlme);
  1718. return rvalue;
  1719. }
  1720. /* Translate a TRAP oid into a wireless event. Called in islpci_mgt_receive. */
  1721. static void
  1722. format_event(islpci_private *priv, char *dest, const char *str,
  1723. const struct obj_mlme *mlme, u16 *length, int error)
  1724. {
  1725. int n = snprintf(dest, IW_CUSTOM_MAX,
  1726. "%s %s %pM %s (%2.2X)",
  1727. str,
  1728. ((priv->iw_mode == IW_MODE_MASTER) ? "from" : "to"),
  1729. mlme->address,
  1730. (error ? (mlme->code ? " : REJECTED " : " : ACCEPTED ")
  1731. : ""), mlme->code);
  1732. WARN_ON(n >= IW_CUSTOM_MAX);
  1733. *length = n;
  1734. }
  1735. static void
  1736. send_formatted_event(islpci_private *priv, const char *str,
  1737. const struct obj_mlme *mlme, int error)
  1738. {
  1739. union iwreq_data wrqu;
  1740. char *memptr;
  1741. memptr = kmalloc(IW_CUSTOM_MAX, GFP_KERNEL);
  1742. if (!memptr)
  1743. return;
  1744. wrqu.data.pointer = memptr;
  1745. wrqu.data.length = 0;
  1746. format_event(priv, memptr, str, mlme, &wrqu.data.length,
  1747. error);
  1748. wireless_send_event(priv->ndev, IWEVCUSTOM, &wrqu, memptr);
  1749. kfree(memptr);
  1750. }
  1751. static void
  1752. send_simple_event(islpci_private *priv, const char *str)
  1753. {
  1754. union iwreq_data wrqu;
  1755. char *memptr;
  1756. int n = strlen(str);
  1757. memptr = kmalloc(IW_CUSTOM_MAX, GFP_KERNEL);
  1758. if (!memptr)
  1759. return;
  1760. BUG_ON(n >= IW_CUSTOM_MAX);
  1761. wrqu.data.pointer = memptr;
  1762. wrqu.data.length = n;
  1763. strcpy(memptr, str);
  1764. wireless_send_event(priv->ndev, IWEVCUSTOM, &wrqu, memptr);
  1765. kfree(memptr);
  1766. }
  1767. static void
  1768. link_changed(struct net_device *ndev, u32 bitrate)
  1769. {
  1770. islpci_private *priv = netdev_priv(ndev);
  1771. if (bitrate) {
  1772. netif_carrier_on(ndev);
  1773. if (priv->iw_mode == IW_MODE_INFRA) {
  1774. union iwreq_data uwrq;
  1775. prism54_get_wap(ndev, NULL, (struct sockaddr *) &uwrq,
  1776. NULL);
  1777. wireless_send_event(ndev, SIOCGIWAP, &uwrq, NULL);
  1778. } else
  1779. send_simple_event(netdev_priv(ndev),
  1780. "Link established");
  1781. } else {
  1782. netif_carrier_off(ndev);
  1783. send_simple_event(netdev_priv(ndev), "Link lost");
  1784. }
  1785. }
  1786. /* Beacon/ProbeResp payload header */
  1787. struct ieee80211_beacon_phdr {
  1788. u8 timestamp[8];
  1789. u16 beacon_int;
  1790. u16 capab_info;
  1791. } __packed;
  1792. #define WLAN_EID_GENERIC 0xdd
  1793. static u8 wpa_oid[4] = { 0x00, 0x50, 0xf2, 1 };
  1794. static void
  1795. prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
  1796. u8 *wpa_ie, size_t wpa_ie_len)
  1797. {
  1798. struct list_head *ptr;
  1799. struct islpci_bss_wpa_ie *bss = NULL;
  1800. if (wpa_ie_len > MAX_WPA_IE_LEN)
  1801. wpa_ie_len = MAX_WPA_IE_LEN;
  1802. mutex_lock(&priv->wpa_lock);
  1803. /* try to use existing entry */
  1804. list_for_each(ptr, &priv->bss_wpa_list) {
  1805. bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
  1806. if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0) {
  1807. list_move(&bss->list, &priv->bss_wpa_list);
  1808. break;
  1809. }
  1810. bss = NULL;
  1811. }
  1812. if (bss == NULL) {
  1813. /* add a new BSS entry; if max number of entries is already
  1814. * reached, replace the least recently updated */
  1815. if (priv->num_bss_wpa >= MAX_BSS_WPA_IE_COUNT) {
  1816. bss = list_entry(priv->bss_wpa_list.prev,
  1817. struct islpci_bss_wpa_ie, list);
  1818. list_del(&bss->list);
  1819. } else {
  1820. bss = kzalloc(sizeof (*bss), GFP_ATOMIC);
  1821. if (bss != NULL)
  1822. priv->num_bss_wpa++;
  1823. }
  1824. if (bss != NULL) {
  1825. memcpy(bss->bssid, bssid, ETH_ALEN);
  1826. list_add(&bss->list, &priv->bss_wpa_list);
  1827. }
  1828. }
  1829. if (bss != NULL) {
  1830. memcpy(bss->wpa_ie, wpa_ie, wpa_ie_len);
  1831. bss->wpa_ie_len = wpa_ie_len;
  1832. bss->last_update = jiffies;
  1833. } else {
  1834. printk(KERN_DEBUG "Failed to add BSS WPA entry for "
  1835. "%pM\n", bssid);
  1836. }
  1837. /* expire old entries from WPA list */
  1838. while (priv->num_bss_wpa > 0) {
  1839. bss = list_entry(priv->bss_wpa_list.prev,
  1840. struct islpci_bss_wpa_ie, list);
  1841. if (!time_after(jiffies, bss->last_update + 60 * HZ))
  1842. break;
  1843. list_del(&bss->list);
  1844. priv->num_bss_wpa--;
  1845. kfree(bss);
  1846. }
  1847. mutex_unlock(&priv->wpa_lock);
  1848. }
  1849. static size_t
  1850. prism54_wpa_bss_ie_get(islpci_private *priv, u8 *bssid, u8 *wpa_ie)
  1851. {
  1852. struct list_head *ptr;
  1853. struct islpci_bss_wpa_ie *bss = NULL;
  1854. size_t len = 0;
  1855. mutex_lock(&priv->wpa_lock);
  1856. list_for_each(ptr, &priv->bss_wpa_list) {
  1857. bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
  1858. if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0)
  1859. break;
  1860. bss = NULL;
  1861. }
  1862. if (bss) {
  1863. len = bss->wpa_ie_len;
  1864. memcpy(wpa_ie, bss->wpa_ie, len);
  1865. }
  1866. mutex_unlock(&priv->wpa_lock);
  1867. return len;
  1868. }
  1869. void
  1870. prism54_wpa_bss_ie_init(islpci_private *priv)
  1871. {
  1872. INIT_LIST_HEAD(&priv->bss_wpa_list);
  1873. mutex_init(&priv->wpa_lock);
  1874. }
  1875. void
  1876. prism54_wpa_bss_ie_clean(islpci_private *priv)
  1877. {
  1878. struct islpci_bss_wpa_ie *bss, *n;
  1879. list_for_each_entry_safe(bss, n, &priv->bss_wpa_list, list) {
  1880. kfree(bss);
  1881. }
  1882. }
  1883. static void
  1884. prism54_process_bss_data(islpci_private *priv, u32 oid, u8 *addr,
  1885. u8 *payload, size_t len)
  1886. {
  1887. struct ieee80211_beacon_phdr *hdr;
  1888. u8 *pos, *end;
  1889. if (!priv->wpa)
  1890. return;
  1891. hdr = (struct ieee80211_beacon_phdr *) payload;
  1892. pos = (u8 *) (hdr + 1);
  1893. end = payload + len;
  1894. while (pos < end) {
  1895. if (pos + 2 + pos[1] > end) {
  1896. printk(KERN_DEBUG "Parsing Beacon/ProbeResp failed "
  1897. "for %pM\n", addr);
  1898. return;
  1899. }
  1900. if (pos[0] == WLAN_EID_GENERIC && pos[1] >= 4 &&
  1901. memcmp(pos + 2, wpa_oid, 4) == 0) {
  1902. prism54_wpa_bss_ie_add(priv, addr, pos, pos[1] + 2);
  1903. return;
  1904. }
  1905. pos += 2 + pos[1];
  1906. }
  1907. }
  1908. static void
  1909. handle_request(islpci_private *priv, struct obj_mlme *mlme, enum oid_num_t oid)
  1910. {
  1911. if (((mlme->state == DOT11_STATE_AUTHING) ||
  1912. (mlme->state == DOT11_STATE_ASSOCING))
  1913. && mgt_mlme_answer(priv)) {
  1914. /* Someone is requesting auth and we must respond. Just send back
  1915. * the trap with error code set accordingly.
  1916. */
  1917. mlme->code = prism54_mac_accept(&priv->acl,
  1918. mlme->address) ? 0 : 1;
  1919. mgt_set_request(priv, oid, 0, mlme);
  1920. }
  1921. }
  1922. static int
  1923. prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
  1924. char *data)
  1925. {
  1926. struct obj_mlme *mlme = (struct obj_mlme *) data;
  1927. struct obj_mlmeex *mlmeex = (struct obj_mlmeex *) data;
  1928. struct obj_mlmeex *confirm;
  1929. u8 wpa_ie[MAX_WPA_IE_LEN];
  1930. int wpa_ie_len;
  1931. size_t len = 0; /* u16, better? */
  1932. u8 *payload = NULL, *pos = NULL;
  1933. int ret;
  1934. /* I think all trapable objects are listed here.
  1935. * Some oids have a EX version. The difference is that they are emitted
  1936. * in DOT11_MLME_EXTENDED mode (set with DOT11_OID_MLMEAUTOLEVEL)
  1937. * with more info.
  1938. * The few events already defined by the wireless tools are not really
  1939. * suited. We use the more flexible custom event facility.
  1940. */
  1941. if (oid >= DOT11_OID_BEACON) {
  1942. len = mlmeex->size;
  1943. payload = pos = mlmeex->data;
  1944. }
  1945. /* I fear prism54_process_bss_data won't work with big endian data */
  1946. if ((oid == DOT11_OID_BEACON) || (oid == DOT11_OID_PROBE))
  1947. prism54_process_bss_data(priv, oid, mlmeex->address,
  1948. payload, len);
  1949. mgt_le_to_cpu(isl_oid[oid].flags & OID_FLAG_TYPE, (void *) mlme);
  1950. switch (oid) {
  1951. case GEN_OID_LINKSTATE:
  1952. link_changed(priv->ndev, (u32) *data);
  1953. break;
  1954. case DOT11_OID_MICFAILURE:
  1955. send_simple_event(priv, "Mic failure");
  1956. break;
  1957. case DOT11_OID_DEAUTHENTICATE:
  1958. send_formatted_event(priv, "DeAuthenticate request", mlme, 0);
  1959. break;
  1960. case DOT11_OID_AUTHENTICATE:
  1961. handle_request(priv, mlme, oid);
  1962. send_formatted_event(priv, "Authenticate request", mlme, 1);
  1963. break;
  1964. case DOT11_OID_DISASSOCIATE:
  1965. send_formatted_event(priv, "Disassociate request", mlme, 0);
  1966. break;
  1967. case DOT11_OID_ASSOCIATE:
  1968. handle_request(priv, mlme, oid);
  1969. send_formatted_event(priv, "Associate request", mlme, 1);
  1970. break;
  1971. case DOT11_OID_REASSOCIATE:
  1972. handle_request(priv, mlme, oid);
  1973. send_formatted_event(priv, "ReAssociate request", mlme, 1);
  1974. break;
  1975. case DOT11_OID_BEACON:
  1976. send_formatted_event(priv,
  1977. "Received a beacon from an unknown AP",
  1978. mlme, 0);
  1979. break;
  1980. case DOT11_OID_PROBE:
  1981. /* we received a probe from a client. */
  1982. send_formatted_event(priv, "Received a probe from client", mlme,
  1983. 0);
  1984. break;
  1985. /* Note : "mlme" is actually a "struct obj_mlmeex *" here, but this
  1986. * is backward compatible layout-wise with "struct obj_mlme".
  1987. */
  1988. case DOT11_OID_DEAUTHENTICATEEX:
  1989. send_formatted_event(priv, "DeAuthenticate request", mlme, 0);
  1990. break;
  1991. case DOT11_OID_AUTHENTICATEEX:
  1992. handle_request(priv, mlme, oid);
  1993. send_formatted_event(priv, "Authenticate request (ex)", mlme, 1);
  1994. if (priv->iw_mode != IW_MODE_MASTER
  1995. && mlmeex->state != DOT11_STATE_AUTHING)
  1996. break;
  1997. confirm = kmalloc(sizeof(struct obj_mlmeex) + 6, GFP_ATOMIC);
  1998. if (!confirm)
  1999. break;
  2000. memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
  2001. printk(KERN_DEBUG "Authenticate from: address:\t%pM\n",
  2002. mlmeex->address);
  2003. confirm->id = -1; /* or mlmeex->id ? */
  2004. confirm->state = 0; /* not used */
  2005. confirm->code = 0;
  2006. confirm->size = 6;
  2007. confirm->data[0] = 0x00;
  2008. confirm->data[1] = 0x00;
  2009. confirm->data[2] = 0x02;
  2010. confirm->data[3] = 0x00;
  2011. confirm->data[4] = 0x00;
  2012. confirm->data[5] = 0x00;
  2013. ret = mgt_set_varlen(priv, DOT11_OID_ASSOCIATEEX, confirm, 6);
  2014. kfree(confirm);
  2015. if (ret)
  2016. return ret;
  2017. break;
  2018. case DOT11_OID_DISASSOCIATEEX:
  2019. send_formatted_event(priv, "Disassociate request (ex)", mlme, 0);
  2020. break;
  2021. case DOT11_OID_ASSOCIATEEX:
  2022. handle_request(priv, mlme, oid);
  2023. send_formatted_event(priv, "Associate request (ex)", mlme, 1);
  2024. if (priv->iw_mode != IW_MODE_MASTER
  2025. && mlmeex->state != DOT11_STATE_ASSOCING)
  2026. break;
  2027. confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
  2028. if (!confirm)
  2029. break;
  2030. memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
  2031. confirm->id = ((struct obj_mlmeex *)mlme)->id;
  2032. confirm->state = 0; /* not used */
  2033. confirm->code = 0;
  2034. wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
  2035. if (!wpa_ie_len) {
  2036. printk(KERN_DEBUG "No WPA IE found from address:\t%pM\n",
  2037. mlmeex->address);
  2038. kfree(confirm);
  2039. break;
  2040. }
  2041. confirm->size = wpa_ie_len;
  2042. memcpy(&confirm->data, wpa_ie, wpa_ie_len);
  2043. mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
  2044. kfree(confirm);
  2045. break;
  2046. case DOT11_OID_REASSOCIATEEX:
  2047. handle_request(priv, mlme, oid);
  2048. send_formatted_event(priv, "Reassociate request (ex)", mlme, 1);
  2049. if (priv->iw_mode != IW_MODE_MASTER
  2050. && mlmeex->state != DOT11_STATE_ASSOCING)
  2051. break;
  2052. confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
  2053. if (!confirm)
  2054. break;
  2055. memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
  2056. confirm->id = mlmeex->id;
  2057. confirm->state = 0; /* not used */
  2058. confirm->code = 0;
  2059. wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
  2060. if (!wpa_ie_len) {
  2061. printk(KERN_DEBUG "No WPA IE found from address:\t%pM\n",
  2062. mlmeex->address);
  2063. kfree(confirm);
  2064. break;
  2065. }
  2066. confirm->size = wpa_ie_len;
  2067. memcpy(&confirm->data, wpa_ie, wpa_ie_len);
  2068. mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
  2069. kfree(confirm);
  2070. break;
  2071. default:
  2072. return -EINVAL;
  2073. }
  2074. return 0;
  2075. }
  2076. /*
  2077. * Process a device trap. This is called via schedule_work(), outside of
  2078. * interrupt context, no locks held.
  2079. */
  2080. void
  2081. prism54_process_trap(struct work_struct *work)
  2082. {
  2083. struct islpci_mgmtframe *frame =
  2084. container_of(work, struct islpci_mgmtframe, ws);
  2085. struct net_device *ndev = frame->ndev;
  2086. enum oid_num_t n = mgt_oidtonum(frame->header->oid);
  2087. if (n != OID_NUM_LAST)
  2088. prism54_process_trap_helper(netdev_priv(ndev), n, frame->data);
  2089. islpci_mgt_release(frame);
  2090. }
  2091. int
  2092. prism54_set_mac_address(struct net_device *ndev, void *addr)
  2093. {
  2094. islpci_private *priv = netdev_priv(ndev);
  2095. int ret;
  2096. if (ndev->addr_len != 6)
  2097. return -EINVAL;
  2098. ret = mgt_set_request(priv, GEN_OID_MACADDRESS, 0,
  2099. &((struct sockaddr *) addr)->sa_data);
  2100. if (!ret)
  2101. memcpy(priv->ndev->dev_addr,
  2102. &((struct sockaddr *) addr)->sa_data, ETH_ALEN);
  2103. return ret;
  2104. }
  2105. #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
  2106. static int
  2107. prism54_set_wpa(struct net_device *ndev, struct iw_request_info *info,
  2108. __u32 * uwrq, char *extra)
  2109. {
  2110. islpci_private *priv = netdev_priv(ndev);
  2111. u32 mlme, authen, dot1x, filter, wep;
  2112. if (islpci_get_state(priv) < PRV_STATE_INIT)
  2113. return 0;
  2114. wep = 1; /* For privacy invoked */
  2115. filter = 1; /* Filter out all unencrypted frames */
  2116. dot1x = 0x01; /* To enable eap filter */
  2117. mlme = DOT11_MLME_EXTENDED;
  2118. authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
  2119. down_write(&priv->mib_sem);
  2120. priv->wpa = *uwrq;
  2121. switch (priv->wpa) {
  2122. default:
  2123. case 0: /* Clears/disables WPA and friends */
  2124. wep = 0;
  2125. filter = 0; /* Do not filter un-encrypted data */
  2126. dot1x = 0;
  2127. mlme = DOT11_MLME_AUTO;
  2128. printk("%s: Disabling WPA\n", ndev->name);
  2129. break;
  2130. case 2:
  2131. case 1: /* WPA */
  2132. printk("%s: Enabling WPA\n", ndev->name);
  2133. break;
  2134. }
  2135. up_write(&priv->mib_sem);
  2136. mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
  2137. mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &wep);
  2138. mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, &filter);
  2139. mgt_set_request(priv, DOT11_OID_DOT1XENABLE, 0, &dot1x);
  2140. mgt_set_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, &mlme);
  2141. return 0;
  2142. }
  2143. static int
  2144. prism54_get_wpa(struct net_device *ndev, struct iw_request_info *info,
  2145. __u32 * uwrq, char *extra)
  2146. {
  2147. islpci_private *priv = netdev_priv(ndev);
  2148. *uwrq = priv->wpa;
  2149. return 0;
  2150. }
  2151. static int
  2152. prism54_set_prismhdr(struct net_device *ndev, struct iw_request_info *info,
  2153. __u32 * uwrq, char *extra)
  2154. {
  2155. islpci_private *priv = netdev_priv(ndev);
  2156. priv->monitor_type =
  2157. (*uwrq ? ARPHRD_IEEE80211_PRISM : ARPHRD_IEEE80211);
  2158. if (priv->iw_mode == IW_MODE_MONITOR)
  2159. priv->ndev->type = priv->monitor_type;
  2160. return 0;
  2161. }
  2162. static int
  2163. prism54_get_prismhdr(struct net_device *ndev, struct iw_request_info *info,
  2164. __u32 * uwrq, char *extra)
  2165. {
  2166. islpci_private *priv = netdev_priv(ndev);
  2167. *uwrq = (priv->monitor_type == ARPHRD_IEEE80211_PRISM);
  2168. return 0;
  2169. }
  2170. static int
  2171. prism54_debug_oid(struct net_device *ndev, struct iw_request_info *info,
  2172. __u32 * uwrq, char *extra)
  2173. {
  2174. islpci_private *priv = netdev_priv(ndev);
  2175. priv->priv_oid = *uwrq;
  2176. printk("%s: oid 0x%08X\n", ndev->name, *uwrq);
  2177. return 0;
  2178. }
  2179. static int
  2180. prism54_debug_get_oid(struct net_device *ndev, struct iw_request_info *info,
  2181. struct iw_point *data, char *extra)
  2182. {
  2183. islpci_private *priv = netdev_priv(ndev);
  2184. struct islpci_mgmtframe *response;
  2185. int ret = -EIO;
  2186. printk("%s: get_oid 0x%08X\n", ndev->name, priv->priv_oid);
  2187. data->length = 0;
  2188. if (islpci_get_state(priv) >= PRV_STATE_INIT) {
  2189. ret =
  2190. islpci_mgt_transaction(priv->ndev, PIMFOR_OP_GET,
  2191. priv->priv_oid, extra, 256,
  2192. &response);
  2193. printk("%s: ret: %i\n", ndev->name, ret);
  2194. if (ret || !response
  2195. || response->header->operation == PIMFOR_OP_ERROR) {
  2196. if (response) {
  2197. islpci_mgt_release(response);
  2198. }
  2199. printk("%s: EIO\n", ndev->name);
  2200. ret = -EIO;
  2201. }
  2202. if (!ret) {
  2203. data->length = response->header->length;
  2204. memcpy(extra, response->data, data->length);
  2205. islpci_mgt_release(response);
  2206. printk("%s: len: %i\n", ndev->name, data->length);
  2207. }
  2208. }
  2209. return ret;
  2210. }
  2211. static int
  2212. prism54_debug_set_oid(struct net_device *ndev, struct iw_request_info *info,
  2213. struct iw_point *data, char *extra)
  2214. {
  2215. islpci_private *priv = netdev_priv(ndev);
  2216. struct islpci_mgmtframe *response;
  2217. int ret = 0, response_op = PIMFOR_OP_ERROR;
  2218. printk("%s: set_oid 0x%08X\tlen: %d\n", ndev->name, priv->priv_oid,
  2219. data->length);
  2220. if (islpci_get_state(priv) >= PRV_STATE_INIT) {
  2221. ret =
  2222. islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET,
  2223. priv->priv_oid, extra, data->length,
  2224. &response);
  2225. printk("%s: ret: %i\n", ndev->name, ret);
  2226. if (ret || !response
  2227. || response->header->operation == PIMFOR_OP_ERROR) {
  2228. if (response) {
  2229. islpci_mgt_release(response);
  2230. }
  2231. printk("%s: EIO\n", ndev->name);
  2232. ret = -EIO;
  2233. }
  2234. if (!ret) {
  2235. response_op = response->header->operation;
  2236. printk("%s: response_op: %i\n", ndev->name,
  2237. response_op);
  2238. islpci_mgt_release(response);
  2239. }
  2240. }
  2241. return (ret ? ret : -EINPROGRESS);
  2242. }
  2243. static int
  2244. prism54_set_spy(struct net_device *ndev,
  2245. struct iw_request_info *info,
  2246. union iwreq_data *uwrq, char *extra)
  2247. {
  2248. islpci_private *priv = netdev_priv(ndev);
  2249. u32 u;
  2250. enum oid_num_t oid = OID_INL_CONFIG;
  2251. down_write(&priv->mib_sem);
  2252. mgt_get(priv, OID_INL_CONFIG, &u);
  2253. if ((uwrq->data.length == 0) && (priv->spy_data.spy_number > 0))
  2254. /* disable spy */
  2255. u &= ~INL_CONFIG_RXANNEX;
  2256. else if ((uwrq->data.length > 0) && (priv->spy_data.spy_number == 0))
  2257. /* enable spy */
  2258. u |= INL_CONFIG_RXANNEX;
  2259. mgt_set(priv, OID_INL_CONFIG, &u);
  2260. mgt_commit_list(priv, &oid, 1);
  2261. up_write(&priv->mib_sem);
  2262. return iw_handler_set_spy(ndev, info, uwrq, extra);
  2263. }
  2264. static const iw_handler prism54_handler[] = {
  2265. (iw_handler) prism54_commit, /* SIOCSIWCOMMIT */
  2266. (iw_handler) prism54_get_name, /* SIOCGIWNAME */
  2267. (iw_handler) NULL, /* SIOCSIWNWID */
  2268. (iw_handler) NULL, /* SIOCGIWNWID */
  2269. (iw_handler) prism54_set_freq, /* SIOCSIWFREQ */
  2270. (iw_handler) prism54_get_freq, /* SIOCGIWFREQ */
  2271. (iw_handler) prism54_set_mode, /* SIOCSIWMODE */
  2272. (iw_handler) prism54_get_mode, /* SIOCGIWMODE */
  2273. (iw_handler) prism54_set_sens, /* SIOCSIWSENS */
  2274. (iw_handler) prism54_get_sens, /* SIOCGIWSENS */
  2275. (iw_handler) NULL, /* SIOCSIWRANGE */
  2276. (iw_handler) prism54_get_range, /* SIOCGIWRANGE */
  2277. (iw_handler) NULL, /* SIOCSIWPRIV */
  2278. (iw_handler) NULL, /* SIOCGIWPRIV */
  2279. (iw_handler) NULL, /* SIOCSIWSTATS */
  2280. (iw_handler) NULL, /* SIOCGIWSTATS */
  2281. prism54_set_spy, /* SIOCSIWSPY */
  2282. iw_handler_get_spy, /* SIOCGIWSPY */
  2283. iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
  2284. iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
  2285. (iw_handler) prism54_set_wap, /* SIOCSIWAP */
  2286. (iw_handler) prism54_get_wap, /* SIOCGIWAP */
  2287. (iw_handler) NULL, /* -- hole -- */
  2288. (iw_handler) NULL, /* SIOCGIWAPLIST deprecated */
  2289. (iw_handler) prism54_set_scan, /* SIOCSIWSCAN */
  2290. (iw_handler) prism54_get_scan, /* SIOCGIWSCAN */
  2291. (iw_handler) prism54_set_essid, /* SIOCSIWESSID */
  2292. (iw_handler) prism54_get_essid, /* SIOCGIWESSID */
  2293. (iw_handler) prism54_set_nick, /* SIOCSIWNICKN */
  2294. (iw_handler) prism54_get_nick, /* SIOCGIWNICKN */
  2295. (iw_handler) NULL, /* -- hole -- */
  2296. (iw_handler) NULL, /* -- hole -- */
  2297. (iw_handler) prism54_set_rate, /* SIOCSIWRATE */
  2298. (iw_handler) prism54_get_rate, /* SIOCGIWRATE */
  2299. (iw_handler) prism54_set_rts, /* SIOCSIWRTS */
  2300. (iw_handler) prism54_get_rts, /* SIOCGIWRTS */
  2301. (iw_handler) prism54_set_frag, /* SIOCSIWFRAG */
  2302. (iw_handler) prism54_get_frag, /* SIOCGIWFRAG */
  2303. (iw_handler) prism54_set_txpower, /* SIOCSIWTXPOW */
  2304. (iw_handler) prism54_get_txpower, /* SIOCGIWTXPOW */
  2305. (iw_handler) prism54_set_retry, /* SIOCSIWRETRY */
  2306. (iw_handler) prism54_get_retry, /* SIOCGIWRETRY */
  2307. (iw_handler) prism54_set_encode, /* SIOCSIWENCODE */
  2308. (iw_handler) prism54_get_encode, /* SIOCGIWENCODE */
  2309. (iw_handler) NULL, /* SIOCSIWPOWER */
  2310. (iw_handler) NULL, /* SIOCGIWPOWER */
  2311. NULL, /* -- hole -- */
  2312. NULL, /* -- hole -- */
  2313. (iw_handler) prism54_set_genie, /* SIOCSIWGENIE */
  2314. (iw_handler) prism54_get_genie, /* SIOCGIWGENIE */
  2315. (iw_handler) prism54_set_auth, /* SIOCSIWAUTH */
  2316. (iw_handler) prism54_get_auth, /* SIOCGIWAUTH */
  2317. (iw_handler) prism54_set_encodeext, /* SIOCSIWENCODEEXT */
  2318. (iw_handler) prism54_get_encodeext, /* SIOCGIWENCODEEXT */
  2319. NULL, /* SIOCSIWPMKSA */
  2320. };
  2321. /* The low order bit identify a SET (0) or a GET (1) ioctl. */
  2322. #define PRISM54_RESET SIOCIWFIRSTPRIV
  2323. #define PRISM54_GET_POLICY SIOCIWFIRSTPRIV+1
  2324. #define PRISM54_SET_POLICY SIOCIWFIRSTPRIV+2
  2325. #define PRISM54_GET_MAC SIOCIWFIRSTPRIV+3
  2326. #define PRISM54_ADD_MAC SIOCIWFIRSTPRIV+4
  2327. #define PRISM54_DEL_MAC SIOCIWFIRSTPRIV+6
  2328. #define PRISM54_KICK_MAC SIOCIWFIRSTPRIV+8
  2329. #define PRISM54_KICK_ALL SIOCIWFIRSTPRIV+10
  2330. #define PRISM54_GET_WPA SIOCIWFIRSTPRIV+11
  2331. #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
  2332. #define PRISM54_DBG_OID SIOCIWFIRSTPRIV+14
  2333. #define PRISM54_DBG_GET_OID SIOCIWFIRSTPRIV+15
  2334. #define PRISM54_DBG_SET_OID SIOCIWFIRSTPRIV+16
  2335. #define PRISM54_GET_OID SIOCIWFIRSTPRIV+17
  2336. #define PRISM54_SET_OID_U32 SIOCIWFIRSTPRIV+18
  2337. #define PRISM54_SET_OID_STR SIOCIWFIRSTPRIV+20
  2338. #define PRISM54_SET_OID_ADDR SIOCIWFIRSTPRIV+22
  2339. #define PRISM54_GET_PRISMHDR SIOCIWFIRSTPRIV+23
  2340. #define PRISM54_SET_PRISMHDR SIOCIWFIRSTPRIV+24
  2341. #define IWPRIV_SET_U32(n,x) { n, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
  2342. #define IWPRIV_SET_SSID(n,x) { n, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
  2343. #define IWPRIV_SET_ADDR(n,x) { n, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
  2344. #define IWPRIV_GET(n,x) { n, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, "g_"x }
  2345. #define IWPRIV_U32(n,x) IWPRIV_SET_U32(n,x), IWPRIV_GET(n,x)
  2346. #define IWPRIV_SSID(n,x) IWPRIV_SET_SSID(n,x), IWPRIV_GET(n,x)
  2347. #define IWPRIV_ADDR(n,x) IWPRIV_SET_ADDR(n,x), IWPRIV_GET(n,x)
  2348. /* Note : limited to 128 private ioctls (wireless tools 26) */
  2349. static const struct iw_priv_args prism54_private_args[] = {
  2350. /*{ cmd, set_args, get_args, name } */
  2351. {PRISM54_RESET, 0, 0, "reset"},
  2352. {PRISM54_GET_PRISMHDR, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  2353. "get_prismhdr"},
  2354. {PRISM54_SET_PRISMHDR, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
  2355. "set_prismhdr"},
  2356. {PRISM54_GET_POLICY, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  2357. "getPolicy"},
  2358. {PRISM54_SET_POLICY, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
  2359. "setPolicy"},
  2360. {PRISM54_GET_MAC, 0, IW_PRIV_TYPE_ADDR | 64, "getMac"},
  2361. {PRISM54_ADD_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
  2362. "addMac"},
  2363. {PRISM54_DEL_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
  2364. "delMac"},
  2365. {PRISM54_KICK_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
  2366. "kickMac"},
  2367. {PRISM54_KICK_ALL, 0, 0, "kickAll"},
  2368. {PRISM54_GET_WPA, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  2369. "get_wpa"},
  2370. {PRISM54_SET_WPA, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
  2371. "set_wpa"},
  2372. {PRISM54_DBG_OID, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
  2373. "dbg_oid"},
  2374. {PRISM54_DBG_GET_OID, 0, IW_PRIV_TYPE_BYTE | 256, "dbg_get_oid"},
  2375. {PRISM54_DBG_SET_OID, IW_PRIV_TYPE_BYTE | 256, 0, "dbg_set_oid"},
  2376. /* --- sub-ioctls handlers --- */
  2377. {PRISM54_GET_OID,
  2378. 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, ""},
  2379. {PRISM54_SET_OID_U32,
  2380. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, ""},
  2381. {PRISM54_SET_OID_STR,
  2382. IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 1, 0, ""},
  2383. {PRISM54_SET_OID_ADDR,
  2384. IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, ""},
  2385. /* --- sub-ioctls definitions --- */
  2386. IWPRIV_ADDR(GEN_OID_MACADDRESS, "addr"),
  2387. IWPRIV_GET(GEN_OID_LINKSTATE, "linkstate"),
  2388. IWPRIV_U32(DOT11_OID_BSSTYPE, "bsstype"),
  2389. IWPRIV_ADDR(DOT11_OID_BSSID, "bssid"),
  2390. IWPRIV_U32(DOT11_OID_STATE, "state"),
  2391. IWPRIV_U32(DOT11_OID_AID, "aid"),
  2392. IWPRIV_SSID(DOT11_OID_SSIDOVERRIDE, "ssidoverride"),
  2393. IWPRIV_U32(DOT11_OID_MEDIUMLIMIT, "medlimit"),
  2394. IWPRIV_U32(DOT11_OID_BEACONPERIOD, "beacon"),
  2395. IWPRIV_U32(DOT11_OID_DTIMPERIOD, "dtimperiod"),
  2396. IWPRIV_U32(DOT11_OID_AUTHENABLE, "authenable"),
  2397. IWPRIV_U32(DOT11_OID_PRIVACYINVOKED, "privinvok"),
  2398. IWPRIV_U32(DOT11_OID_EXUNENCRYPTED, "exunencrypt"),
  2399. IWPRIV_U32(DOT11_OID_REKEYTHRESHOLD, "rekeythresh"),
  2400. IWPRIV_U32(DOT11_OID_MAXTXLIFETIME, "maxtxlife"),
  2401. IWPRIV_U32(DOT11_OID_MAXRXLIFETIME, "maxrxlife"),
  2402. IWPRIV_U32(DOT11_OID_ALOFT_FIXEDRATE, "fixedrate"),
  2403. IWPRIV_U32(DOT11_OID_MAXFRAMEBURST, "frameburst"),
  2404. IWPRIV_U32(DOT11_OID_PSM, "psm"),
  2405. IWPRIV_U32(DOT11_OID_BRIDGELOCAL, "bridge"),
  2406. IWPRIV_U32(DOT11_OID_CLIENTS, "clients"),
  2407. IWPRIV_U32(DOT11_OID_CLIENTSASSOCIATED, "clientassoc"),
  2408. IWPRIV_U32(DOT11_OID_DOT1XENABLE, "dot1xenable"),
  2409. IWPRIV_U32(DOT11_OID_ANTENNARX, "rxant"),
  2410. IWPRIV_U32(DOT11_OID_ANTENNATX, "txant"),
  2411. IWPRIV_U32(DOT11_OID_ANTENNADIVERSITY, "antdivers"),
  2412. IWPRIV_U32(DOT11_OID_EDTHRESHOLD, "edthresh"),
  2413. IWPRIV_U32(DOT11_OID_PREAMBLESETTINGS, "preamble"),
  2414. IWPRIV_GET(DOT11_OID_RATES, "rates"),
  2415. IWPRIV_U32(DOT11_OID_OUTPUTPOWER, ".11outpower"),
  2416. IWPRIV_GET(DOT11_OID_SUPPORTEDRATES, "supprates"),
  2417. IWPRIV_GET(DOT11_OID_SUPPORTEDFREQUENCIES, "suppfreq"),
  2418. IWPRIV_U32(DOT11_OID_NOISEFLOOR, "noisefloor"),
  2419. IWPRIV_GET(DOT11_OID_FREQUENCYACTIVITY, "freqactivity"),
  2420. IWPRIV_U32(DOT11_OID_NONERPPROTECTION, "nonerpprotec"),
  2421. IWPRIV_U32(DOT11_OID_PROFILES, "profile"),
  2422. IWPRIV_GET(DOT11_OID_EXTENDEDRATES, "extrates"),
  2423. IWPRIV_U32(DOT11_OID_MLMEAUTOLEVEL, "mlmelevel"),
  2424. IWPRIV_GET(DOT11_OID_BSSS, "bsss"),
  2425. IWPRIV_GET(DOT11_OID_BSSLIST, "bsslist"),
  2426. IWPRIV_U32(OID_INL_MODE, "mode"),
  2427. IWPRIV_U32(OID_INL_CONFIG, "config"),
  2428. IWPRIV_U32(OID_INL_DOT11D_CONFORMANCE, ".11dconform"),
  2429. IWPRIV_GET(OID_INL_PHYCAPABILITIES, "phycapa"),
  2430. IWPRIV_U32(OID_INL_OUTPUTPOWER, "outpower"),
  2431. };
  2432. static const iw_handler prism54_private_handler[] = {
  2433. (iw_handler) prism54_reset,
  2434. (iw_handler) prism54_get_policy,
  2435. (iw_handler) prism54_set_policy,
  2436. (iw_handler) prism54_get_mac,
  2437. (iw_handler) prism54_add_mac,
  2438. (iw_handler) NULL,
  2439. (iw_handler) prism54_del_mac,
  2440. (iw_handler) NULL,
  2441. (iw_handler) prism54_kick_mac,
  2442. (iw_handler) NULL,
  2443. (iw_handler) prism54_kick_all,
  2444. (iw_handler) prism54_get_wpa,
  2445. (iw_handler) prism54_set_wpa,
  2446. (iw_handler) NULL,
  2447. (iw_handler) prism54_debug_oid,
  2448. (iw_handler) prism54_debug_get_oid,
  2449. (iw_handler) prism54_debug_set_oid,
  2450. (iw_handler) prism54_get_oid,
  2451. (iw_handler) prism54_set_u32,
  2452. (iw_handler) NULL,
  2453. (iw_handler) prism54_set_raw,
  2454. (iw_handler) NULL,
  2455. (iw_handler) prism54_set_raw,
  2456. (iw_handler) prism54_get_prismhdr,
  2457. (iw_handler) prism54_set_prismhdr,
  2458. };
  2459. const struct iw_handler_def prism54_handler_def = {
  2460. .num_standard = ARRAY_SIZE(prism54_handler),
  2461. .num_private = ARRAY_SIZE(prism54_private_handler),
  2462. .num_private_args = ARRAY_SIZE(prism54_private_args),
  2463. .standard = (iw_handler *) prism54_handler,
  2464. .private = (iw_handler *) prism54_private_handler,
  2465. .private_args = (struct iw_priv_args *) prism54_private_args,
  2466. .get_wireless_stats = prism54_get_wireless_stats,
  2467. };