isl_ioctl.c 76 KB

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