wext.c 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338
  1. /**
  2. * This file contains ioctl functions
  3. */
  4. #include <linux/ctype.h>
  5. #include <linux/delay.h>
  6. #include <linux/if.h>
  7. #include <linux/if_arp.h>
  8. #include <linux/wireless.h>
  9. #include <linux/bitops.h>
  10. #include <net/lib80211.h>
  11. #include <net/iw_handler.h>
  12. #include "host.h"
  13. #include "radiotap.h"
  14. #include "decl.h"
  15. #include "defs.h"
  16. #include "dev.h"
  17. #include "wext.h"
  18. #include "scan.h"
  19. #include "assoc.h"
  20. #include "cmd.h"
  21. static inline void lbs_postpone_association_work(struct lbs_private *priv)
  22. {
  23. if (priv->surpriseremoved)
  24. return;
  25. cancel_delayed_work(&priv->assoc_work);
  26. queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2);
  27. }
  28. static inline void lbs_do_association_work(struct lbs_private *priv)
  29. {
  30. if (priv->surpriseremoved)
  31. return;
  32. cancel_delayed_work(&priv->assoc_work);
  33. queue_delayed_work(priv->work_thread, &priv->assoc_work, 0);
  34. }
  35. static inline void lbs_cancel_association_work(struct lbs_private *priv)
  36. {
  37. cancel_delayed_work(&priv->assoc_work);
  38. kfree(priv->pending_assoc_req);
  39. priv->pending_assoc_req = NULL;
  40. }
  41. void lbs_send_disconnect_notification(struct lbs_private *priv)
  42. {
  43. union iwreq_data wrqu;
  44. memset(wrqu.ap_addr.sa_data, 0x00, ETH_ALEN);
  45. wrqu.ap_addr.sa_family = ARPHRD_ETHER;
  46. wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
  47. }
  48. static void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str)
  49. {
  50. union iwreq_data iwrq;
  51. u8 buf[50];
  52. lbs_deb_enter(LBS_DEB_WEXT);
  53. memset(&iwrq, 0, sizeof(union iwreq_data));
  54. memset(buf, 0, sizeof(buf));
  55. snprintf(buf, sizeof(buf) - 1, "%s", str);
  56. iwrq.data.length = strlen(buf) + 1 + IW_EV_LCP_LEN;
  57. /* Send Event to upper layer */
  58. lbs_deb_wext("event indication string %s\n", (char *)buf);
  59. lbs_deb_wext("event indication length %d\n", iwrq.data.length);
  60. lbs_deb_wext("sending wireless event IWEVCUSTOM for %s\n", str);
  61. wireless_send_event(priv->dev, IWEVCUSTOM, &iwrq, buf);
  62. lbs_deb_leave(LBS_DEB_WEXT);
  63. }
  64. /**
  65. * @brief This function handles MIC failure event.
  66. *
  67. * @param priv A pointer to struct lbs_private structure
  68. * @para event the event id
  69. * @return n/a
  70. */
  71. void lbs_send_mic_failureevent(struct lbs_private *priv, u32 event)
  72. {
  73. char buf[50];
  74. lbs_deb_enter(LBS_DEB_CMD);
  75. memset(buf, 0, sizeof(buf));
  76. sprintf(buf, "%s", "MLME-MICHAELMICFAILURE.indication ");
  77. if (event == MACREG_INT_CODE_MIC_ERR_UNICAST)
  78. strcat(buf, "unicast ");
  79. else
  80. strcat(buf, "multicast ");
  81. lbs_send_iwevcustom_event(priv, buf);
  82. lbs_deb_leave(LBS_DEB_CMD);
  83. }
  84. /**
  85. * @brief Find the channel frequency power info with specific channel
  86. *
  87. * @param priv A pointer to struct lbs_private structure
  88. * @param band it can be BAND_A, BAND_G or BAND_B
  89. * @param channel the channel for looking
  90. * @return A pointer to struct chan_freq_power structure or NULL if not find.
  91. */
  92. struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
  93. struct lbs_private *priv,
  94. u8 band,
  95. u16 channel)
  96. {
  97. struct chan_freq_power *cfp = NULL;
  98. struct region_channel *rc;
  99. int i, j;
  100. for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
  101. rc = &priv->region_channel[j];
  102. if (!rc->valid || !rc->CFP)
  103. continue;
  104. if (rc->band != band)
  105. continue;
  106. for (i = 0; i < rc->nrcfp; i++) {
  107. if (rc->CFP[i].channel == channel) {
  108. cfp = &rc->CFP[i];
  109. break;
  110. }
  111. }
  112. }
  113. if (!cfp && channel)
  114. lbs_deb_wext("lbs_find_cfp_by_band_and_channel: can't find "
  115. "cfp by band %d / channel %d\n", band, channel);
  116. return cfp;
  117. }
  118. /**
  119. * @brief Find the channel frequency power info with specific frequency
  120. *
  121. * @param priv A pointer to struct lbs_private structure
  122. * @param band it can be BAND_A, BAND_G or BAND_B
  123. * @param freq the frequency for looking
  124. * @return A pointer to struct chan_freq_power structure or NULL if not find.
  125. */
  126. static struct chan_freq_power *find_cfp_by_band_and_freq(
  127. struct lbs_private *priv,
  128. u8 band,
  129. u32 freq)
  130. {
  131. struct chan_freq_power *cfp = NULL;
  132. struct region_channel *rc;
  133. int i, j;
  134. for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
  135. rc = &priv->region_channel[j];
  136. if (!rc->valid || !rc->CFP)
  137. continue;
  138. if (rc->band != band)
  139. continue;
  140. for (i = 0; i < rc->nrcfp; i++) {
  141. if (rc->CFP[i].freq == freq) {
  142. cfp = &rc->CFP[i];
  143. break;
  144. }
  145. }
  146. }
  147. if (!cfp && freq)
  148. lbs_deb_wext("find_cfp_by_band_and_freql: can't find cfp by "
  149. "band %d / freq %d\n", band, freq);
  150. return cfp;
  151. }
  152. /**
  153. * @brief Copy active data rates based on adapter mode and status
  154. *
  155. * @param priv A pointer to struct lbs_private structure
  156. * @param rate The buf to return the active rates
  157. */
  158. static void copy_active_data_rates(struct lbs_private *priv, u8 *rates)
  159. {
  160. lbs_deb_enter(LBS_DEB_WEXT);
  161. if ((priv->connect_status != LBS_CONNECTED) &&
  162. (priv->mesh_connect_status != LBS_CONNECTED))
  163. memcpy(rates, lbs_bg_rates, MAX_RATES);
  164. else
  165. memcpy(rates, priv->curbssparams.rates, MAX_RATES);
  166. lbs_deb_leave(LBS_DEB_WEXT);
  167. }
  168. static int lbs_get_name(struct net_device *dev, struct iw_request_info *info,
  169. char *cwrq, char *extra)
  170. {
  171. lbs_deb_enter(LBS_DEB_WEXT);
  172. /* We could add support for 802.11n here as needed. Jean II */
  173. snprintf(cwrq, IFNAMSIZ, "IEEE 802.11b/g");
  174. lbs_deb_leave(LBS_DEB_WEXT);
  175. return 0;
  176. }
  177. static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info,
  178. struct iw_freq *fwrq, char *extra)
  179. {
  180. struct lbs_private *priv = dev->ml_priv;
  181. struct chan_freq_power *cfp;
  182. lbs_deb_enter(LBS_DEB_WEXT);
  183. cfp = lbs_find_cfp_by_band_and_channel(priv, 0,
  184. priv->channel);
  185. if (!cfp) {
  186. if (priv->channel)
  187. lbs_deb_wext("invalid channel %d\n",
  188. priv->channel);
  189. return -EINVAL;
  190. }
  191. fwrq->m = (long)cfp->freq * 100000;
  192. fwrq->e = 1;
  193. lbs_deb_wext("freq %u\n", fwrq->m);
  194. lbs_deb_leave(LBS_DEB_WEXT);
  195. return 0;
  196. }
  197. static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info,
  198. struct sockaddr *awrq, char *extra)
  199. {
  200. struct lbs_private *priv = dev->ml_priv;
  201. lbs_deb_enter(LBS_DEB_WEXT);
  202. if (priv->connect_status == LBS_CONNECTED) {
  203. memcpy(awrq->sa_data, priv->curbssparams.bssid, ETH_ALEN);
  204. } else {
  205. memset(awrq->sa_data, 0, ETH_ALEN);
  206. }
  207. awrq->sa_family = ARPHRD_ETHER;
  208. lbs_deb_leave(LBS_DEB_WEXT);
  209. return 0;
  210. }
  211. static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info,
  212. struct iw_point *dwrq, char *extra)
  213. {
  214. struct lbs_private *priv = dev->ml_priv;
  215. lbs_deb_enter(LBS_DEB_WEXT);
  216. /*
  217. * Check the size of the string
  218. */
  219. if (dwrq->length > 16) {
  220. return -E2BIG;
  221. }
  222. mutex_lock(&priv->lock);
  223. memset(priv->nodename, 0, sizeof(priv->nodename));
  224. memcpy(priv->nodename, extra, dwrq->length);
  225. mutex_unlock(&priv->lock);
  226. lbs_deb_leave(LBS_DEB_WEXT);
  227. return 0;
  228. }
  229. static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info,
  230. struct iw_point *dwrq, char *extra)
  231. {
  232. struct lbs_private *priv = dev->ml_priv;
  233. lbs_deb_enter(LBS_DEB_WEXT);
  234. dwrq->length = strlen(priv->nodename);
  235. memcpy(extra, priv->nodename, dwrq->length);
  236. extra[dwrq->length] = '\0';
  237. dwrq->flags = 1; /* active */
  238. lbs_deb_leave(LBS_DEB_WEXT);
  239. return 0;
  240. }
  241. static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info,
  242. struct iw_point *dwrq, char *extra)
  243. {
  244. struct lbs_private *priv = dev->ml_priv;
  245. lbs_deb_enter(LBS_DEB_WEXT);
  246. /* Use nickname to indicate that mesh is on */
  247. if (priv->mesh_connect_status == LBS_CONNECTED) {
  248. strncpy(extra, "Mesh", 12);
  249. extra[12] = '\0';
  250. dwrq->length = strlen(extra);
  251. }
  252. else {
  253. extra[0] = '\0';
  254. dwrq->length = 0;
  255. }
  256. lbs_deb_leave(LBS_DEB_WEXT);
  257. return 0;
  258. }
  259. static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
  260. struct iw_param *vwrq, char *extra)
  261. {
  262. int ret = 0;
  263. struct lbs_private *priv = dev->ml_priv;
  264. u32 val = vwrq->value;
  265. lbs_deb_enter(LBS_DEB_WEXT);
  266. if (vwrq->disabled)
  267. val = MRVDRV_RTS_MAX_VALUE;
  268. if (val > MRVDRV_RTS_MAX_VALUE) /* min rts value is 0 */
  269. return -EINVAL;
  270. ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, (u16) val);
  271. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  272. return ret;
  273. }
  274. static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info,
  275. struct iw_param *vwrq, char *extra)
  276. {
  277. struct lbs_private *priv = dev->ml_priv;
  278. int ret = 0;
  279. u16 val = 0;
  280. lbs_deb_enter(LBS_DEB_WEXT);
  281. ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, &val);
  282. if (ret)
  283. goto out;
  284. vwrq->value = val;
  285. vwrq->disabled = val > MRVDRV_RTS_MAX_VALUE; /* min rts value is 0 */
  286. vwrq->fixed = 1;
  287. out:
  288. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  289. return ret;
  290. }
  291. static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
  292. struct iw_param *vwrq, char *extra)
  293. {
  294. struct lbs_private *priv = dev->ml_priv;
  295. int ret = 0;
  296. u32 val = vwrq->value;
  297. lbs_deb_enter(LBS_DEB_WEXT);
  298. if (vwrq->disabled)
  299. val = MRVDRV_FRAG_MAX_VALUE;
  300. if (val < MRVDRV_FRAG_MIN_VALUE || val > MRVDRV_FRAG_MAX_VALUE)
  301. return -EINVAL;
  302. ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, (u16) val);
  303. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  304. return ret;
  305. }
  306. static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info,
  307. struct iw_param *vwrq, char *extra)
  308. {
  309. struct lbs_private *priv = dev->ml_priv;
  310. int ret = 0;
  311. u16 val = 0;
  312. lbs_deb_enter(LBS_DEB_WEXT);
  313. ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, &val);
  314. if (ret)
  315. goto out;
  316. vwrq->value = val;
  317. vwrq->disabled = ((val < MRVDRV_FRAG_MIN_VALUE)
  318. || (val > MRVDRV_FRAG_MAX_VALUE));
  319. vwrq->fixed = 1;
  320. out:
  321. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  322. return ret;
  323. }
  324. static int lbs_get_mode(struct net_device *dev,
  325. struct iw_request_info *info, u32 * uwrq, char *extra)
  326. {
  327. struct lbs_private *priv = dev->ml_priv;
  328. lbs_deb_enter(LBS_DEB_WEXT);
  329. *uwrq = priv->mode;
  330. lbs_deb_leave(LBS_DEB_WEXT);
  331. return 0;
  332. }
  333. static int mesh_wlan_get_mode(struct net_device *dev,
  334. struct iw_request_info *info, u32 * uwrq,
  335. char *extra)
  336. {
  337. lbs_deb_enter(LBS_DEB_WEXT);
  338. *uwrq = IW_MODE_REPEAT;
  339. lbs_deb_leave(LBS_DEB_WEXT);
  340. return 0;
  341. }
  342. static int lbs_get_txpow(struct net_device *dev,
  343. struct iw_request_info *info,
  344. struct iw_param *vwrq, char *extra)
  345. {
  346. struct lbs_private *priv = dev->ml_priv;
  347. s16 curlevel = 0;
  348. int ret = 0;
  349. lbs_deb_enter(LBS_DEB_WEXT);
  350. if (!priv->radio_on) {
  351. lbs_deb_wext("tx power off\n");
  352. vwrq->value = 0;
  353. vwrq->disabled = 1;
  354. goto out;
  355. }
  356. ret = lbs_get_tx_power(priv, &curlevel, NULL, NULL);
  357. if (ret)
  358. goto out;
  359. lbs_deb_wext("tx power level %d dbm\n", curlevel);
  360. priv->txpower_cur = curlevel;
  361. vwrq->value = curlevel;
  362. vwrq->fixed = 1;
  363. vwrq->disabled = 0;
  364. vwrq->flags = IW_TXPOW_DBM;
  365. out:
  366. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  367. return ret;
  368. }
  369. static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info,
  370. struct iw_param *vwrq, char *extra)
  371. {
  372. struct lbs_private *priv = dev->ml_priv;
  373. int ret = 0;
  374. u16 slimit = 0, llimit = 0;
  375. lbs_deb_enter(LBS_DEB_WEXT);
  376. if ((vwrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
  377. return -EOPNOTSUPP;
  378. /* The MAC has a 4-bit Total_Tx_Count register
  379. Total_Tx_Count = 1 + Tx_Retry_Count */
  380. #define TX_RETRY_MIN 0
  381. #define TX_RETRY_MAX 14
  382. if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX)
  383. return -EINVAL;
  384. /* Add 1 to convert retry count to try count */
  385. if (vwrq->flags & IW_RETRY_SHORT)
  386. slimit = (u16) (vwrq->value + 1);
  387. else if (vwrq->flags & IW_RETRY_LONG)
  388. llimit = (u16) (vwrq->value + 1);
  389. else
  390. slimit = llimit = (u16) (vwrq->value + 1); /* set both */
  391. if (llimit) {
  392. ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT,
  393. llimit);
  394. if (ret)
  395. goto out;
  396. }
  397. if (slimit) {
  398. /* txretrycount follows the short retry limit */
  399. priv->txretrycount = slimit;
  400. ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT,
  401. slimit);
  402. if (ret)
  403. goto out;
  404. }
  405. out:
  406. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  407. return ret;
  408. }
  409. static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info,
  410. struct iw_param *vwrq, char *extra)
  411. {
  412. struct lbs_private *priv = dev->ml_priv;
  413. int ret = 0;
  414. u16 val = 0;
  415. lbs_deb_enter(LBS_DEB_WEXT);
  416. vwrq->disabled = 0;
  417. if (vwrq->flags & IW_RETRY_LONG) {
  418. ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT, &val);
  419. if (ret)
  420. goto out;
  421. /* Subtract 1 to convert try count to retry count */
  422. vwrq->value = val - 1;
  423. vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
  424. } else {
  425. ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT, &val);
  426. if (ret)
  427. goto out;
  428. /* txretry count follows the short retry limit */
  429. priv->txretrycount = val;
  430. /* Subtract 1 to convert try count to retry count */
  431. vwrq->value = val - 1;
  432. vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
  433. }
  434. out:
  435. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  436. return ret;
  437. }
  438. static inline void sort_channels(struct iw_freq *freq, int num)
  439. {
  440. int i, j;
  441. struct iw_freq temp;
  442. for (i = 0; i < num; i++)
  443. for (j = i + 1; j < num; j++)
  444. if (freq[i].i > freq[j].i) {
  445. temp.i = freq[i].i;
  446. temp.m = freq[i].m;
  447. freq[i].i = freq[j].i;
  448. freq[i].m = freq[j].m;
  449. freq[j].i = temp.i;
  450. freq[j].m = temp.m;
  451. }
  452. }
  453. /* data rate listing
  454. MULTI_BANDS:
  455. abg a b b/g
  456. Infra G(12) A(8) B(4) G(12)
  457. Adhoc A+B(12) A(8) B(4) B(4)
  458. non-MULTI_BANDS:
  459. b b/g
  460. Infra B(4) G(12)
  461. Adhoc B(4) B(4)
  462. */
  463. /**
  464. * @brief Get Range Info
  465. *
  466. * @param dev A pointer to net_device structure
  467. * @param info A pointer to iw_request_info structure
  468. * @param vwrq A pointer to iw_param structure
  469. * @param extra A pointer to extra data buf
  470. * @return 0 --success, otherwise fail
  471. */
  472. static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
  473. struct iw_point *dwrq, char *extra)
  474. {
  475. int i, j;
  476. struct lbs_private *priv = dev->ml_priv;
  477. struct iw_range *range = (struct iw_range *)extra;
  478. struct chan_freq_power *cfp;
  479. u8 rates[MAX_RATES + 1];
  480. lbs_deb_enter(LBS_DEB_WEXT);
  481. dwrq->length = sizeof(struct iw_range);
  482. memset(range, 0, sizeof(struct iw_range));
  483. range->min_nwid = 0;
  484. range->max_nwid = 0;
  485. memset(rates, 0, sizeof(rates));
  486. copy_active_data_rates(priv, rates);
  487. range->num_bitrates = strnlen(rates, IW_MAX_BITRATES);
  488. for (i = 0; i < range->num_bitrates; i++)
  489. range->bitrate[i] = rates[i] * 500000;
  490. range->num_bitrates = i;
  491. lbs_deb_wext("IW_MAX_BITRATES %d, num_bitrates %d\n", IW_MAX_BITRATES,
  492. range->num_bitrates);
  493. range->num_frequency = 0;
  494. range->scan_capa = IW_SCAN_CAPA_ESSID;
  495. for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
  496. && (j < ARRAY_SIZE(priv->region_channel)); j++) {
  497. cfp = priv->region_channel[j].CFP;
  498. for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
  499. && priv->region_channel[j].valid
  500. && cfp
  501. && (i < priv->region_channel[j].nrcfp); i++) {
  502. range->freq[range->num_frequency].i =
  503. (long)cfp->channel;
  504. range->freq[range->num_frequency].m =
  505. (long)cfp->freq * 100000;
  506. range->freq[range->num_frequency].e = 1;
  507. cfp++;
  508. range->num_frequency++;
  509. }
  510. }
  511. lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n",
  512. IW_MAX_FREQUENCIES, range->num_frequency);
  513. range->num_channels = range->num_frequency;
  514. sort_channels(&range->freq[0], range->num_frequency);
  515. /*
  516. * Set an indication of the max TCP throughput in bit/s that we can
  517. * expect using this interface
  518. */
  519. if (i > 2)
  520. range->throughput = 5000 * 1000;
  521. else
  522. range->throughput = 1500 * 1000;
  523. range->min_rts = MRVDRV_RTS_MIN_VALUE;
  524. range->max_rts = MRVDRV_RTS_MAX_VALUE;
  525. range->min_frag = MRVDRV_FRAG_MIN_VALUE;
  526. range->max_frag = MRVDRV_FRAG_MAX_VALUE;
  527. range->encoding_size[0] = 5;
  528. range->encoding_size[1] = 13;
  529. range->num_encoding_sizes = 2;
  530. range->max_encoding_tokens = 4;
  531. /*
  532. * Right now we support only "iwconfig ethX power on|off"
  533. */
  534. range->pm_capa = IW_POWER_ON;
  535. /*
  536. * Minimum version we recommend
  537. */
  538. range->we_version_source = 15;
  539. /*
  540. * Version we are compiled with
  541. */
  542. range->we_version_compiled = WIRELESS_EXT;
  543. range->retry_capa = IW_RETRY_LIMIT;
  544. range->retry_flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
  545. range->min_retry = TX_RETRY_MIN;
  546. range->max_retry = TX_RETRY_MAX;
  547. /*
  548. * Set the qual, level and noise range values
  549. */
  550. range->max_qual.qual = 100;
  551. range->max_qual.level = 0;
  552. range->max_qual.noise = 0;
  553. range->max_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
  554. range->avg_qual.qual = 70;
  555. /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
  556. range->avg_qual.level = 0;
  557. range->avg_qual.noise = 0;
  558. range->avg_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
  559. range->sensitivity = 0;
  560. /* Setup the supported power level ranges */
  561. memset(range->txpower, 0, sizeof(range->txpower));
  562. range->txpower_capa = IW_TXPOW_DBM | IW_TXPOW_RANGE;
  563. range->txpower[0] = priv->txpower_min;
  564. range->txpower[1] = priv->txpower_max;
  565. range->num_txpower = 2;
  566. range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
  567. IW_EVENT_CAPA_MASK(SIOCGIWAP) |
  568. IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
  569. range->event_capa[1] = IW_EVENT_CAPA_K_1;
  570. if (priv->fwcapinfo & FW_CAPINFO_WPA) {
  571. range->enc_capa = IW_ENC_CAPA_WPA
  572. | IW_ENC_CAPA_WPA2
  573. | IW_ENC_CAPA_CIPHER_TKIP
  574. | IW_ENC_CAPA_CIPHER_CCMP;
  575. }
  576. lbs_deb_leave(LBS_DEB_WEXT);
  577. return 0;
  578. }
  579. static int lbs_set_power(struct net_device *dev, struct iw_request_info *info,
  580. struct iw_param *vwrq, char *extra)
  581. {
  582. struct lbs_private *priv = dev->ml_priv;
  583. int ret = 0;
  584. lbs_deb_enter(LBS_DEB_WEXT);
  585. if (!(priv->fwcapinfo & FW_CAPINFO_PS)) {
  586. if (vwrq->disabled)
  587. return 0;
  588. else
  589. return -EINVAL;
  590. }
  591. /* PS is currently supported only in Infrastructure mode
  592. * Remove this check if it is to be supported in IBSS mode also
  593. */
  594. if (vwrq->disabled) {
  595. priv->psmode = LBS802_11POWERMODECAM;
  596. if (priv->psstate != PS_STATE_FULL_POWER) {
  597. lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
  598. }
  599. return 0;
  600. }
  601. if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
  602. lbs_deb_wext(
  603. "setting power timeout is not supported\n");
  604. return -EINVAL;
  605. } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
  606. vwrq->value = vwrq->value / 1000;
  607. if (!priv->enter_deep_sleep) {
  608. lbs_pr_err("deep sleep feature is not implemented "
  609. "for this interface driver\n");
  610. return -EINVAL;
  611. }
  612. if (priv->connect_status == LBS_CONNECTED) {
  613. if ((priv->is_auto_deep_sleep_enabled) &&
  614. (vwrq->value == -1000)) {
  615. lbs_exit_auto_deep_sleep(priv);
  616. return 0;
  617. } else {
  618. lbs_pr_err("can't use deep sleep cmd in "
  619. "connected state\n");
  620. return -EINVAL;
  621. }
  622. }
  623. if ((vwrq->value < 0) && (vwrq->value != -1000)) {
  624. lbs_pr_err("unknown option\n");
  625. return -EINVAL;
  626. }
  627. if (vwrq->value > 0) {
  628. if (!priv->is_auto_deep_sleep_enabled) {
  629. priv->is_activity_detected = 0;
  630. priv->auto_deep_sleep_timeout = vwrq->value;
  631. lbs_enter_auto_deep_sleep(priv);
  632. } else {
  633. priv->auto_deep_sleep_timeout = vwrq->value;
  634. lbs_deb_debugfs("auto deep sleep: "
  635. "already enabled\n");
  636. }
  637. return 0;
  638. } else {
  639. if (priv->is_auto_deep_sleep_enabled) {
  640. lbs_exit_auto_deep_sleep(priv);
  641. /* Try to exit deep sleep if auto */
  642. /*deep sleep disabled */
  643. ret = lbs_set_deep_sleep(priv, 0);
  644. }
  645. if (vwrq->value == 0)
  646. ret = lbs_set_deep_sleep(priv, 1);
  647. else if (vwrq->value == -1000)
  648. ret = lbs_set_deep_sleep(priv, 0);
  649. return ret;
  650. }
  651. }
  652. if (priv->psmode != LBS802_11POWERMODECAM) {
  653. return 0;
  654. }
  655. priv->psmode = LBS802_11POWERMODEMAX_PSP;
  656. if (priv->connect_status == LBS_CONNECTED) {
  657. lbs_ps_sleep(priv, CMD_OPTION_WAITFORRSP);
  658. }
  659. lbs_deb_leave(LBS_DEB_WEXT);
  660. return 0;
  661. }
  662. static int lbs_get_power(struct net_device *dev, struct iw_request_info *info,
  663. struct iw_param *vwrq, char *extra)
  664. {
  665. struct lbs_private *priv = dev->ml_priv;
  666. lbs_deb_enter(LBS_DEB_WEXT);
  667. vwrq->value = 0;
  668. vwrq->flags = 0;
  669. vwrq->disabled = priv->psmode == LBS802_11POWERMODECAM
  670. || priv->connect_status == LBS_DISCONNECTED;
  671. lbs_deb_leave(LBS_DEB_WEXT);
  672. return 0;
  673. }
  674. static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
  675. {
  676. enum {
  677. POOR = 30,
  678. FAIR = 60,
  679. GOOD = 80,
  680. VERY_GOOD = 90,
  681. EXCELLENT = 95,
  682. PERFECT = 100
  683. };
  684. struct lbs_private *priv = dev->ml_priv;
  685. u32 rssi_qual;
  686. u32 tx_qual;
  687. u32 quality = 0;
  688. int ret, stats_valid = 0;
  689. u8 rssi;
  690. u32 tx_retries;
  691. struct cmd_ds_802_11_get_log log;
  692. lbs_deb_enter(LBS_DEB_WEXT);
  693. priv->wstats.status = priv->mode;
  694. /* If we're not associated, all quality values are meaningless */
  695. if ((priv->connect_status != LBS_CONNECTED) &&
  696. (priv->mesh_connect_status != LBS_CONNECTED))
  697. goto out;
  698. /* Quality by RSSI */
  699. priv->wstats.qual.level =
  700. CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
  701. priv->NF[TYPE_BEACON][TYPE_NOAVG]);
  702. if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
  703. priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
  704. } else {
  705. priv->wstats.qual.noise =
  706. CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]);
  707. }
  708. lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level);
  709. lbs_deb_wext("noise %#x\n", priv->wstats.qual.noise);
  710. rssi = priv->wstats.qual.level - priv->wstats.qual.noise;
  711. if (rssi < 15)
  712. rssi_qual = rssi * POOR / 10;
  713. else if (rssi < 20)
  714. rssi_qual = (rssi - 15) * (FAIR - POOR) / 5 + POOR;
  715. else if (rssi < 30)
  716. rssi_qual = (rssi - 20) * (GOOD - FAIR) / 5 + FAIR;
  717. else if (rssi < 40)
  718. rssi_qual = (rssi - 30) * (VERY_GOOD - GOOD) /
  719. 10 + GOOD;
  720. else
  721. rssi_qual = (rssi - 40) * (PERFECT - VERY_GOOD) /
  722. 10 + VERY_GOOD;
  723. quality = rssi_qual;
  724. /* Quality by TX errors */
  725. priv->wstats.discard.retries = dev->stats.tx_errors;
  726. memset(&log, 0, sizeof(log));
  727. log.hdr.size = cpu_to_le16(sizeof(log));
  728. ret = lbs_cmd_with_response(priv, CMD_802_11_GET_LOG, &log);
  729. if (ret)
  730. goto out;
  731. tx_retries = le32_to_cpu(log.retry);
  732. if (tx_retries > 75)
  733. tx_qual = (90 - tx_retries) * POOR / 15;
  734. else if (tx_retries > 70)
  735. tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR;
  736. else if (tx_retries > 65)
  737. tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR;
  738. else if (tx_retries > 50)
  739. tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) /
  740. 15 + GOOD;
  741. else
  742. tx_qual = (50 - tx_retries) *
  743. (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
  744. quality = min(quality, tx_qual);
  745. priv->wstats.discard.code = le32_to_cpu(log.wepundecryptable);
  746. priv->wstats.discard.retries = tx_retries;
  747. priv->wstats.discard.misc = le32_to_cpu(log.ackfailure);
  748. /* Calculate quality */
  749. priv->wstats.qual.qual = min_t(u8, quality, 100);
  750. priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
  751. stats_valid = 1;
  752. /* update stats asynchronously for future calls */
  753. ret = lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
  754. 0, 0, NULL);
  755. if (ret)
  756. lbs_pr_err("RSSI command failed\n");
  757. out:
  758. if (!stats_valid) {
  759. priv->wstats.miss.beacon = 0;
  760. priv->wstats.discard.retries = 0;
  761. priv->wstats.qual.qual = 0;
  762. priv->wstats.qual.level = 0;
  763. priv->wstats.qual.noise = 0;
  764. priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED;
  765. priv->wstats.qual.updated |= IW_QUAL_NOISE_INVALID |
  766. IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
  767. }
  768. lbs_deb_leave(LBS_DEB_WEXT);
  769. return &priv->wstats;
  770. }
  771. static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info,
  772. struct iw_freq *fwrq, char *extra)
  773. {
  774. int ret = -EINVAL;
  775. struct lbs_private *priv = dev->ml_priv;
  776. struct chan_freq_power *cfp;
  777. struct assoc_request * assoc_req;
  778. lbs_deb_enter(LBS_DEB_WEXT);
  779. mutex_lock(&priv->lock);
  780. assoc_req = lbs_get_association_request(priv);
  781. if (!assoc_req) {
  782. ret = -ENOMEM;
  783. goto out;
  784. }
  785. /* If setting by frequency, convert to a channel */
  786. if (fwrq->e == 1) {
  787. long f = fwrq->m / 100000;
  788. cfp = find_cfp_by_band_and_freq(priv, 0, f);
  789. if (!cfp) {
  790. lbs_deb_wext("invalid freq %ld\n", f);
  791. goto out;
  792. }
  793. fwrq->e = 0;
  794. fwrq->m = (int) cfp->channel;
  795. }
  796. /* Setting by channel number */
  797. if (fwrq->m > 1000 || fwrq->e > 0) {
  798. goto out;
  799. }
  800. cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
  801. if (!cfp) {
  802. goto out;
  803. }
  804. assoc_req->channel = fwrq->m;
  805. ret = 0;
  806. out:
  807. if (ret == 0) {
  808. set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags);
  809. lbs_postpone_association_work(priv);
  810. } else {
  811. lbs_cancel_association_work(priv);
  812. }
  813. mutex_unlock(&priv->lock);
  814. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  815. return ret;
  816. }
  817. static int lbs_mesh_set_freq(struct net_device *dev,
  818. struct iw_request_info *info,
  819. struct iw_freq *fwrq, char *extra)
  820. {
  821. struct lbs_private *priv = dev->ml_priv;
  822. struct chan_freq_power *cfp;
  823. int ret = -EINVAL;
  824. lbs_deb_enter(LBS_DEB_WEXT);
  825. /* If setting by frequency, convert to a channel */
  826. if (fwrq->e == 1) {
  827. long f = fwrq->m / 100000;
  828. cfp = find_cfp_by_band_and_freq(priv, 0, f);
  829. if (!cfp) {
  830. lbs_deb_wext("invalid freq %ld\n", f);
  831. goto out;
  832. }
  833. fwrq->e = 0;
  834. fwrq->m = (int) cfp->channel;
  835. }
  836. /* Setting by channel number */
  837. if (fwrq->m > 1000 || fwrq->e > 0) {
  838. goto out;
  839. }
  840. cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
  841. if (!cfp) {
  842. goto out;
  843. }
  844. if (fwrq->m != priv->channel) {
  845. lbs_deb_wext("mesh channel change forces eth disconnect\n");
  846. if (priv->mode == IW_MODE_INFRA)
  847. lbs_cmd_80211_deauthenticate(priv,
  848. priv->curbssparams.bssid,
  849. WLAN_REASON_DEAUTH_LEAVING);
  850. else if (priv->mode == IW_MODE_ADHOC)
  851. lbs_adhoc_stop(priv);
  852. }
  853. lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START, fwrq->m);
  854. lbs_update_channel(priv);
  855. ret = 0;
  856. out:
  857. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  858. return ret;
  859. }
  860. static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info,
  861. struct iw_param *vwrq, char *extra)
  862. {
  863. struct lbs_private *priv = dev->ml_priv;
  864. u8 new_rate = 0;
  865. int ret = -EINVAL;
  866. u8 rates[MAX_RATES + 1];
  867. lbs_deb_enter(LBS_DEB_WEXT);
  868. lbs_deb_wext("vwrq->value %d\n", vwrq->value);
  869. lbs_deb_wext("vwrq->fixed %d\n", vwrq->fixed);
  870. if (vwrq->fixed && vwrq->value == -1)
  871. goto out;
  872. /* Auto rate? */
  873. priv->enablehwauto = !vwrq->fixed;
  874. if (vwrq->value == -1)
  875. priv->cur_rate = 0;
  876. else {
  877. if (vwrq->value % 100000)
  878. goto out;
  879. new_rate = vwrq->value / 500000;
  880. priv->cur_rate = new_rate;
  881. /* the rest is only needed for lbs_set_data_rate() */
  882. memset(rates, 0, sizeof(rates));
  883. copy_active_data_rates(priv, rates);
  884. if (!memchr(rates, new_rate, sizeof(rates))) {
  885. lbs_pr_alert("fixed data rate 0x%X out of range\n",
  886. new_rate);
  887. goto out;
  888. }
  889. if (priv->fwrelease < 0x09000000) {
  890. ret = lbs_set_power_adapt_cfg(priv, 0,
  891. POW_ADAPT_DEFAULT_P0,
  892. POW_ADAPT_DEFAULT_P1,
  893. POW_ADAPT_DEFAULT_P2);
  894. if (ret)
  895. goto out;
  896. }
  897. ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
  898. TPC_DEFAULT_P2, 1);
  899. if (ret)
  900. goto out;
  901. }
  902. /* Try the newer command first (Firmware Spec 5.1 and above) */
  903. ret = lbs_cmd_802_11_rate_adapt_rateset(priv, CMD_ACT_SET);
  904. /* Fallback to older version */
  905. if (ret)
  906. ret = lbs_set_data_rate(priv, new_rate);
  907. out:
  908. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  909. return ret;
  910. }
  911. static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info,
  912. struct iw_param *vwrq, char *extra)
  913. {
  914. struct lbs_private *priv = dev->ml_priv;
  915. lbs_deb_enter(LBS_DEB_WEXT);
  916. if (priv->connect_status == LBS_CONNECTED) {
  917. vwrq->value = priv->cur_rate * 500000;
  918. if (priv->enablehwauto)
  919. vwrq->fixed = 0;
  920. else
  921. vwrq->fixed = 1;
  922. } else {
  923. vwrq->fixed = 0;
  924. vwrq->value = 0;
  925. }
  926. lbs_deb_leave(LBS_DEB_WEXT);
  927. return 0;
  928. }
  929. static int lbs_set_mode(struct net_device *dev,
  930. struct iw_request_info *info, u32 * uwrq, char *extra)
  931. {
  932. int ret = 0;
  933. struct lbs_private *priv = dev->ml_priv;
  934. struct assoc_request * assoc_req;
  935. lbs_deb_enter(LBS_DEB_WEXT);
  936. if ( (*uwrq != IW_MODE_ADHOC)
  937. && (*uwrq != IW_MODE_INFRA)
  938. && (*uwrq != IW_MODE_AUTO)) {
  939. lbs_deb_wext("Invalid mode: 0x%x\n", *uwrq);
  940. ret = -EINVAL;
  941. goto out;
  942. }
  943. mutex_lock(&priv->lock);
  944. assoc_req = lbs_get_association_request(priv);
  945. if (!assoc_req) {
  946. ret = -ENOMEM;
  947. lbs_cancel_association_work(priv);
  948. } else {
  949. assoc_req->mode = *uwrq;
  950. set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
  951. lbs_postpone_association_work(priv);
  952. lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq);
  953. }
  954. mutex_unlock(&priv->lock);
  955. out:
  956. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  957. return ret;
  958. }
  959. /**
  960. * @brief Get Encryption key
  961. *
  962. * @param dev A pointer to net_device structure
  963. * @param info A pointer to iw_request_info structure
  964. * @param vwrq A pointer to iw_param structure
  965. * @param extra A pointer to extra data buf
  966. * @return 0 --success, otherwise fail
  967. */
  968. static int lbs_get_encode(struct net_device *dev,
  969. struct iw_request_info *info,
  970. struct iw_point *dwrq, u8 * extra)
  971. {
  972. struct lbs_private *priv = dev->ml_priv;
  973. int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
  974. lbs_deb_enter(LBS_DEB_WEXT);
  975. lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n",
  976. dwrq->flags, index, dwrq->length, priv->wep_tx_keyidx);
  977. dwrq->flags = 0;
  978. /* Authentication method */
  979. switch (priv->secinfo.auth_mode) {
  980. case IW_AUTH_ALG_OPEN_SYSTEM:
  981. dwrq->flags = IW_ENCODE_OPEN;
  982. break;
  983. case IW_AUTH_ALG_SHARED_KEY:
  984. case IW_AUTH_ALG_LEAP:
  985. dwrq->flags = IW_ENCODE_RESTRICTED;
  986. break;
  987. default:
  988. dwrq->flags = IW_ENCODE_DISABLED | IW_ENCODE_OPEN;
  989. break;
  990. }
  991. memset(extra, 0, 16);
  992. mutex_lock(&priv->lock);
  993. /* Default to returning current transmit key */
  994. if (index < 0)
  995. index = priv->wep_tx_keyidx;
  996. if ((priv->wep_keys[index].len) && priv->secinfo.wep_enabled) {
  997. memcpy(extra, priv->wep_keys[index].key,
  998. priv->wep_keys[index].len);
  999. dwrq->length = priv->wep_keys[index].len;
  1000. dwrq->flags |= (index + 1);
  1001. /* Return WEP enabled */
  1002. dwrq->flags &= ~IW_ENCODE_DISABLED;
  1003. } else if ((priv->secinfo.WPAenabled)
  1004. || (priv->secinfo.WPA2enabled)) {
  1005. /* return WPA enabled */
  1006. dwrq->flags &= ~IW_ENCODE_DISABLED;
  1007. dwrq->flags |= IW_ENCODE_NOKEY;
  1008. } else {
  1009. dwrq->flags |= IW_ENCODE_DISABLED;
  1010. }
  1011. mutex_unlock(&priv->lock);
  1012. lbs_deb_wext("key: %02x:%02x:%02x:%02x:%02x:%02x, keylen %d\n",
  1013. extra[0], extra[1], extra[2],
  1014. extra[3], extra[4], extra[5], dwrq->length);
  1015. lbs_deb_wext("return flags 0x%x\n", dwrq->flags);
  1016. lbs_deb_leave(LBS_DEB_WEXT);
  1017. return 0;
  1018. }
  1019. /**
  1020. * @brief Set Encryption key (internal)
  1021. *
  1022. * @param priv A pointer to private card structure
  1023. * @param key_material A pointer to key material
  1024. * @param key_length length of key material
  1025. * @param index key index to set
  1026. * @param set_tx_key Force set TX key (1 = yes, 0 = no)
  1027. * @return 0 --success, otherwise fail
  1028. */
  1029. static int lbs_set_wep_key(struct assoc_request *assoc_req,
  1030. const char *key_material,
  1031. u16 key_length,
  1032. u16 index,
  1033. int set_tx_key)
  1034. {
  1035. int ret = 0;
  1036. struct enc_key *pkey;
  1037. lbs_deb_enter(LBS_DEB_WEXT);
  1038. /* Paranoid validation of key index */
  1039. if (index > 3) {
  1040. ret = -EINVAL;
  1041. goto out;
  1042. }
  1043. /* validate max key length */
  1044. if (key_length > KEY_LEN_WEP_104) {
  1045. ret = -EINVAL;
  1046. goto out;
  1047. }
  1048. pkey = &assoc_req->wep_keys[index];
  1049. if (key_length > 0) {
  1050. memset(pkey, 0, sizeof(struct enc_key));
  1051. pkey->type = KEY_TYPE_ID_WEP;
  1052. /* Standardize the key length */
  1053. pkey->len = (key_length > KEY_LEN_WEP_40) ?
  1054. KEY_LEN_WEP_104 : KEY_LEN_WEP_40;
  1055. memcpy(pkey->key, key_material, key_length);
  1056. }
  1057. if (set_tx_key) {
  1058. /* Ensure the chosen key is valid */
  1059. if (!pkey->len) {
  1060. lbs_deb_wext("key not set, so cannot enable it\n");
  1061. ret = -EINVAL;
  1062. goto out;
  1063. }
  1064. assoc_req->wep_tx_keyidx = index;
  1065. }
  1066. assoc_req->secinfo.wep_enabled = 1;
  1067. out:
  1068. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1069. return ret;
  1070. }
  1071. static int validate_key_index(u16 def_index, u16 raw_index,
  1072. u16 *out_index, u16 *is_default)
  1073. {
  1074. if (!out_index || !is_default)
  1075. return -EINVAL;
  1076. /* Verify index if present, otherwise use default TX key index */
  1077. if (raw_index > 0) {
  1078. if (raw_index > 4)
  1079. return -EINVAL;
  1080. *out_index = raw_index - 1;
  1081. } else {
  1082. *out_index = def_index;
  1083. *is_default = 1;
  1084. }
  1085. return 0;
  1086. }
  1087. static void disable_wep(struct assoc_request *assoc_req)
  1088. {
  1089. int i;
  1090. lbs_deb_enter(LBS_DEB_WEXT);
  1091. /* Set Open System auth mode */
  1092. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1093. /* Clear WEP keys and mark WEP as disabled */
  1094. assoc_req->secinfo.wep_enabled = 0;
  1095. for (i = 0; i < 4; i++)
  1096. assoc_req->wep_keys[i].len = 0;
  1097. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1098. set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
  1099. lbs_deb_leave(LBS_DEB_WEXT);
  1100. }
  1101. static void disable_wpa(struct assoc_request *assoc_req)
  1102. {
  1103. lbs_deb_enter(LBS_DEB_WEXT);
  1104. memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct enc_key));
  1105. assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST;
  1106. set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
  1107. memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct enc_key));
  1108. assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST;
  1109. set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
  1110. assoc_req->secinfo.WPAenabled = 0;
  1111. assoc_req->secinfo.WPA2enabled = 0;
  1112. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1113. lbs_deb_leave(LBS_DEB_WEXT);
  1114. }
  1115. /**
  1116. * @brief Set Encryption key
  1117. *
  1118. * @param dev A pointer to net_device structure
  1119. * @param info A pointer to iw_request_info structure
  1120. * @param vwrq A pointer to iw_param structure
  1121. * @param extra A pointer to extra data buf
  1122. * @return 0 --success, otherwise fail
  1123. */
  1124. static int lbs_set_encode(struct net_device *dev,
  1125. struct iw_request_info *info,
  1126. struct iw_point *dwrq, char *extra)
  1127. {
  1128. int ret = 0;
  1129. struct lbs_private *priv = dev->ml_priv;
  1130. struct assoc_request * assoc_req;
  1131. u16 is_default = 0, index = 0, set_tx_key = 0;
  1132. lbs_deb_enter(LBS_DEB_WEXT);
  1133. mutex_lock(&priv->lock);
  1134. assoc_req = lbs_get_association_request(priv);
  1135. if (!assoc_req) {
  1136. ret = -ENOMEM;
  1137. goto out;
  1138. }
  1139. if (dwrq->flags & IW_ENCODE_DISABLED) {
  1140. disable_wep (assoc_req);
  1141. disable_wpa (assoc_req);
  1142. goto out;
  1143. }
  1144. ret = validate_key_index(assoc_req->wep_tx_keyidx,
  1145. (dwrq->flags & IW_ENCODE_INDEX),
  1146. &index, &is_default);
  1147. if (ret) {
  1148. ret = -EINVAL;
  1149. goto out;
  1150. }
  1151. /* If WEP isn't enabled, or if there is no key data but a valid
  1152. * index, set the TX key.
  1153. */
  1154. if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default))
  1155. set_tx_key = 1;
  1156. ret = lbs_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
  1157. if (ret)
  1158. goto out;
  1159. if (dwrq->length)
  1160. set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
  1161. if (set_tx_key)
  1162. set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
  1163. if (dwrq->flags & IW_ENCODE_RESTRICTED) {
  1164. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
  1165. } else if (dwrq->flags & IW_ENCODE_OPEN) {
  1166. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1167. }
  1168. out:
  1169. if (ret == 0) {
  1170. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1171. lbs_postpone_association_work(priv);
  1172. } else {
  1173. lbs_cancel_association_work(priv);
  1174. }
  1175. mutex_unlock(&priv->lock);
  1176. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1177. return ret;
  1178. }
  1179. /**
  1180. * @brief Get Extended Encryption key (WPA/802.1x and WEP)
  1181. *
  1182. * @param dev A pointer to net_device structure
  1183. * @param info A pointer to iw_request_info structure
  1184. * @param vwrq A pointer to iw_param structure
  1185. * @param extra A pointer to extra data buf
  1186. * @return 0 on success, otherwise failure
  1187. */
  1188. static int lbs_get_encodeext(struct net_device *dev,
  1189. struct iw_request_info *info,
  1190. struct iw_point *dwrq,
  1191. char *extra)
  1192. {
  1193. int ret = -EINVAL;
  1194. struct lbs_private *priv = dev->ml_priv;
  1195. struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  1196. int index, max_key_len;
  1197. lbs_deb_enter(LBS_DEB_WEXT);
  1198. max_key_len = dwrq->length - sizeof(*ext);
  1199. if (max_key_len < 0)
  1200. goto out;
  1201. index = dwrq->flags & IW_ENCODE_INDEX;
  1202. if (index) {
  1203. if (index < 1 || index > 4)
  1204. goto out;
  1205. index--;
  1206. } else {
  1207. index = priv->wep_tx_keyidx;
  1208. }
  1209. if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) &&
  1210. ext->alg != IW_ENCODE_ALG_WEP) {
  1211. if (index != 0 || priv->mode != IW_MODE_INFRA)
  1212. goto out;
  1213. }
  1214. dwrq->flags = index + 1;
  1215. memset(ext, 0, sizeof(*ext));
  1216. if ( !priv->secinfo.wep_enabled
  1217. && !priv->secinfo.WPAenabled
  1218. && !priv->secinfo.WPA2enabled) {
  1219. ext->alg = IW_ENCODE_ALG_NONE;
  1220. ext->key_len = 0;
  1221. dwrq->flags |= IW_ENCODE_DISABLED;
  1222. } else {
  1223. u8 *key = NULL;
  1224. if ( priv->secinfo.wep_enabled
  1225. && !priv->secinfo.WPAenabled
  1226. && !priv->secinfo.WPA2enabled) {
  1227. /* WEP */
  1228. ext->alg = IW_ENCODE_ALG_WEP;
  1229. ext->key_len = priv->wep_keys[index].len;
  1230. key = &priv->wep_keys[index].key[0];
  1231. } else if ( !priv->secinfo.wep_enabled
  1232. && (priv->secinfo.WPAenabled ||
  1233. priv->secinfo.WPA2enabled)) {
  1234. /* WPA */
  1235. struct enc_key * pkey = NULL;
  1236. if ( priv->wpa_mcast_key.len
  1237. && (priv->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
  1238. pkey = &priv->wpa_mcast_key;
  1239. else if ( priv->wpa_unicast_key.len
  1240. && (priv->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED))
  1241. pkey = &priv->wpa_unicast_key;
  1242. if (pkey) {
  1243. if (pkey->type == KEY_TYPE_ID_AES) {
  1244. ext->alg = IW_ENCODE_ALG_CCMP;
  1245. } else {
  1246. ext->alg = IW_ENCODE_ALG_TKIP;
  1247. }
  1248. ext->key_len = pkey->len;
  1249. key = &pkey->key[0];
  1250. } else {
  1251. ext->alg = IW_ENCODE_ALG_TKIP;
  1252. ext->key_len = 0;
  1253. }
  1254. } else {
  1255. goto out;
  1256. }
  1257. if (ext->key_len > max_key_len) {
  1258. ret = -E2BIG;
  1259. goto out;
  1260. }
  1261. if (ext->key_len)
  1262. memcpy(ext->key, key, ext->key_len);
  1263. else
  1264. dwrq->flags |= IW_ENCODE_NOKEY;
  1265. dwrq->flags |= IW_ENCODE_ENABLED;
  1266. }
  1267. ret = 0;
  1268. out:
  1269. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1270. return ret;
  1271. }
  1272. /**
  1273. * @brief Set Encryption key Extended (WPA/802.1x and WEP)
  1274. *
  1275. * @param dev A pointer to net_device structure
  1276. * @param info A pointer to iw_request_info structure
  1277. * @param vwrq A pointer to iw_param structure
  1278. * @param extra A pointer to extra data buf
  1279. * @return 0 --success, otherwise fail
  1280. */
  1281. static int lbs_set_encodeext(struct net_device *dev,
  1282. struct iw_request_info *info,
  1283. struct iw_point *dwrq,
  1284. char *extra)
  1285. {
  1286. int ret = 0;
  1287. struct lbs_private *priv = dev->ml_priv;
  1288. struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  1289. int alg = ext->alg;
  1290. struct assoc_request * assoc_req;
  1291. lbs_deb_enter(LBS_DEB_WEXT);
  1292. mutex_lock(&priv->lock);
  1293. assoc_req = lbs_get_association_request(priv);
  1294. if (!assoc_req) {
  1295. ret = -ENOMEM;
  1296. goto out;
  1297. }
  1298. if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) {
  1299. disable_wep (assoc_req);
  1300. disable_wpa (assoc_req);
  1301. } else if (alg == IW_ENCODE_ALG_WEP) {
  1302. u16 is_default = 0, index, set_tx_key = 0;
  1303. ret = validate_key_index(assoc_req->wep_tx_keyidx,
  1304. (dwrq->flags & IW_ENCODE_INDEX),
  1305. &index, &is_default);
  1306. if (ret)
  1307. goto out;
  1308. /* If WEP isn't enabled, or if there is no key data but a valid
  1309. * index, or if the set-TX-key flag was passed, set the TX key.
  1310. */
  1311. if ( !assoc_req->secinfo.wep_enabled
  1312. || (dwrq->length == 0 && !is_default)
  1313. || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY))
  1314. set_tx_key = 1;
  1315. /* Copy key to driver */
  1316. ret = lbs_set_wep_key(assoc_req, ext->key, ext->key_len, index,
  1317. set_tx_key);
  1318. if (ret)
  1319. goto out;
  1320. if (dwrq->flags & IW_ENCODE_RESTRICTED) {
  1321. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
  1322. } else if (dwrq->flags & IW_ENCODE_OPEN) {
  1323. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1324. }
  1325. /* Mark the various WEP bits as modified */
  1326. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1327. if (dwrq->length)
  1328. set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
  1329. if (set_tx_key)
  1330. set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
  1331. } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
  1332. struct enc_key * pkey;
  1333. /* validate key length */
  1334. if (((alg == IW_ENCODE_ALG_TKIP)
  1335. && (ext->key_len != KEY_LEN_WPA_TKIP))
  1336. || ((alg == IW_ENCODE_ALG_CCMP)
  1337. && (ext->key_len != KEY_LEN_WPA_AES))) {
  1338. lbs_deb_wext("invalid size %d for key of alg "
  1339. "type %d\n",
  1340. ext->key_len,
  1341. alg);
  1342. ret = -EINVAL;
  1343. goto out;
  1344. }
  1345. if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
  1346. pkey = &assoc_req->wpa_mcast_key;
  1347. set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
  1348. } else {
  1349. pkey = &assoc_req->wpa_unicast_key;
  1350. set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
  1351. }
  1352. memset(pkey, 0, sizeof (struct enc_key));
  1353. memcpy(pkey->key, ext->key, ext->key_len);
  1354. pkey->len = ext->key_len;
  1355. if (pkey->len)
  1356. pkey->flags |= KEY_INFO_WPA_ENABLED;
  1357. /* Do this after zeroing key structure */
  1358. if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
  1359. pkey->flags |= KEY_INFO_WPA_MCAST;
  1360. } else {
  1361. pkey->flags |= KEY_INFO_WPA_UNICAST;
  1362. }
  1363. if (alg == IW_ENCODE_ALG_TKIP) {
  1364. pkey->type = KEY_TYPE_ID_TKIP;
  1365. } else if (alg == IW_ENCODE_ALG_CCMP) {
  1366. pkey->type = KEY_TYPE_ID_AES;
  1367. }
  1368. /* If WPA isn't enabled yet, do that now */
  1369. if ( assoc_req->secinfo.WPAenabled == 0
  1370. && assoc_req->secinfo.WPA2enabled == 0) {
  1371. assoc_req->secinfo.WPAenabled = 1;
  1372. assoc_req->secinfo.WPA2enabled = 1;
  1373. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1374. }
  1375. /* Only disable wep if necessary: can't waste time here. */
  1376. if (priv->mac_control & CMD_ACT_MAC_WEP_ENABLE)
  1377. disable_wep(assoc_req);
  1378. }
  1379. out:
  1380. if (ret == 0) {
  1381. /* 802.1x and WPA rekeying must happen as quickly as possible,
  1382. * especially during the 4-way handshake; thus if in
  1383. * infrastructure mode, and either (a) 802.1x is enabled or
  1384. * (b) WPA is being used, set the key right away.
  1385. */
  1386. if (assoc_req->mode == IW_MODE_INFRA &&
  1387. ((assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_802_1X) ||
  1388. (assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_PSK) ||
  1389. assoc_req->secinfo.WPAenabled ||
  1390. assoc_req->secinfo.WPA2enabled)) {
  1391. lbs_do_association_work(priv);
  1392. } else
  1393. lbs_postpone_association_work(priv);
  1394. } else {
  1395. lbs_cancel_association_work(priv);
  1396. }
  1397. mutex_unlock(&priv->lock);
  1398. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1399. return ret;
  1400. }
  1401. static int lbs_set_genie(struct net_device *dev,
  1402. struct iw_request_info *info,
  1403. struct iw_point *dwrq,
  1404. char *extra)
  1405. {
  1406. struct lbs_private *priv = dev->ml_priv;
  1407. int ret = 0;
  1408. struct assoc_request * assoc_req;
  1409. lbs_deb_enter(LBS_DEB_WEXT);
  1410. mutex_lock(&priv->lock);
  1411. assoc_req = lbs_get_association_request(priv);
  1412. if (!assoc_req) {
  1413. ret = -ENOMEM;
  1414. goto out;
  1415. }
  1416. if (dwrq->length > MAX_WPA_IE_LEN ||
  1417. (dwrq->length && extra == NULL)) {
  1418. ret = -EINVAL;
  1419. goto out;
  1420. }
  1421. if (dwrq->length) {
  1422. memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length);
  1423. assoc_req->wpa_ie_len = dwrq->length;
  1424. } else {
  1425. memset(&assoc_req->wpa_ie[0], 0, sizeof(priv->wpa_ie));
  1426. assoc_req->wpa_ie_len = 0;
  1427. }
  1428. out:
  1429. if (ret == 0) {
  1430. set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
  1431. lbs_postpone_association_work(priv);
  1432. } else {
  1433. lbs_cancel_association_work(priv);
  1434. }
  1435. mutex_unlock(&priv->lock);
  1436. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1437. return ret;
  1438. }
  1439. static int lbs_get_genie(struct net_device *dev,
  1440. struct iw_request_info *info,
  1441. struct iw_point *dwrq,
  1442. char *extra)
  1443. {
  1444. int ret = 0;
  1445. struct lbs_private *priv = dev->ml_priv;
  1446. lbs_deb_enter(LBS_DEB_WEXT);
  1447. if (priv->wpa_ie_len == 0) {
  1448. dwrq->length = 0;
  1449. goto out;
  1450. }
  1451. if (dwrq->length < priv->wpa_ie_len) {
  1452. ret = -E2BIG;
  1453. goto out;
  1454. }
  1455. dwrq->length = priv->wpa_ie_len;
  1456. memcpy(extra, &priv->wpa_ie[0], priv->wpa_ie_len);
  1457. out:
  1458. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1459. return ret;
  1460. }
  1461. static int lbs_set_auth(struct net_device *dev,
  1462. struct iw_request_info *info,
  1463. struct iw_param *dwrq,
  1464. char *extra)
  1465. {
  1466. struct lbs_private *priv = dev->ml_priv;
  1467. struct assoc_request * assoc_req;
  1468. int ret = 0;
  1469. int updated = 0;
  1470. lbs_deb_enter(LBS_DEB_WEXT);
  1471. mutex_lock(&priv->lock);
  1472. assoc_req = lbs_get_association_request(priv);
  1473. if (!assoc_req) {
  1474. ret = -ENOMEM;
  1475. goto out;
  1476. }
  1477. switch (dwrq->flags & IW_AUTH_INDEX) {
  1478. case IW_AUTH_PRIVACY_INVOKED:
  1479. case IW_AUTH_RX_UNENCRYPTED_EAPOL:
  1480. case IW_AUTH_TKIP_COUNTERMEASURES:
  1481. case IW_AUTH_CIPHER_PAIRWISE:
  1482. case IW_AUTH_CIPHER_GROUP:
  1483. case IW_AUTH_DROP_UNENCRYPTED:
  1484. /*
  1485. * libertas does not use these parameters
  1486. */
  1487. break;
  1488. case IW_AUTH_KEY_MGMT:
  1489. assoc_req->secinfo.key_mgmt = dwrq->value;
  1490. updated = 1;
  1491. break;
  1492. case IW_AUTH_WPA_VERSION:
  1493. if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) {
  1494. assoc_req->secinfo.WPAenabled = 0;
  1495. assoc_req->secinfo.WPA2enabled = 0;
  1496. disable_wpa (assoc_req);
  1497. }
  1498. if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
  1499. assoc_req->secinfo.WPAenabled = 1;
  1500. assoc_req->secinfo.wep_enabled = 0;
  1501. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1502. }
  1503. if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) {
  1504. assoc_req->secinfo.WPA2enabled = 1;
  1505. assoc_req->secinfo.wep_enabled = 0;
  1506. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1507. }
  1508. updated = 1;
  1509. break;
  1510. case IW_AUTH_80211_AUTH_ALG:
  1511. if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
  1512. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
  1513. } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) {
  1514. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1515. } else if (dwrq->value & IW_AUTH_ALG_LEAP) {
  1516. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP;
  1517. } else {
  1518. ret = -EINVAL;
  1519. }
  1520. updated = 1;
  1521. break;
  1522. case IW_AUTH_WPA_ENABLED:
  1523. if (dwrq->value) {
  1524. if (!assoc_req->secinfo.WPAenabled &&
  1525. !assoc_req->secinfo.WPA2enabled) {
  1526. assoc_req->secinfo.WPAenabled = 1;
  1527. assoc_req->secinfo.WPA2enabled = 1;
  1528. assoc_req->secinfo.wep_enabled = 0;
  1529. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1530. }
  1531. } else {
  1532. assoc_req->secinfo.WPAenabled = 0;
  1533. assoc_req->secinfo.WPA2enabled = 0;
  1534. disable_wpa (assoc_req);
  1535. }
  1536. updated = 1;
  1537. break;
  1538. default:
  1539. ret = -EOPNOTSUPP;
  1540. break;
  1541. }
  1542. out:
  1543. if (ret == 0) {
  1544. if (updated)
  1545. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1546. lbs_postpone_association_work(priv);
  1547. } else if (ret != -EOPNOTSUPP) {
  1548. lbs_cancel_association_work(priv);
  1549. }
  1550. mutex_unlock(&priv->lock);
  1551. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1552. return ret;
  1553. }
  1554. static int lbs_get_auth(struct net_device *dev,
  1555. struct iw_request_info *info,
  1556. struct iw_param *dwrq,
  1557. char *extra)
  1558. {
  1559. int ret = 0;
  1560. struct lbs_private *priv = dev->ml_priv;
  1561. lbs_deb_enter(LBS_DEB_WEXT);
  1562. switch (dwrq->flags & IW_AUTH_INDEX) {
  1563. case IW_AUTH_KEY_MGMT:
  1564. dwrq->value = priv->secinfo.key_mgmt;
  1565. break;
  1566. case IW_AUTH_WPA_VERSION:
  1567. dwrq->value = 0;
  1568. if (priv->secinfo.WPAenabled)
  1569. dwrq->value |= IW_AUTH_WPA_VERSION_WPA;
  1570. if (priv->secinfo.WPA2enabled)
  1571. dwrq->value |= IW_AUTH_WPA_VERSION_WPA2;
  1572. if (!dwrq->value)
  1573. dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
  1574. break;
  1575. case IW_AUTH_80211_AUTH_ALG:
  1576. dwrq->value = priv->secinfo.auth_mode;
  1577. break;
  1578. case IW_AUTH_WPA_ENABLED:
  1579. if (priv->secinfo.WPAenabled && priv->secinfo.WPA2enabled)
  1580. dwrq->value = 1;
  1581. break;
  1582. default:
  1583. ret = -EOPNOTSUPP;
  1584. }
  1585. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1586. return ret;
  1587. }
  1588. static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
  1589. struct iw_param *vwrq, char *extra)
  1590. {
  1591. int ret = 0;
  1592. struct lbs_private *priv = dev->ml_priv;
  1593. s16 dbm = (s16) vwrq->value;
  1594. lbs_deb_enter(LBS_DEB_WEXT);
  1595. if (vwrq->disabled) {
  1596. lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 0);
  1597. goto out;
  1598. }
  1599. if (vwrq->fixed == 0) {
  1600. /* User requests automatic tx power control, however there are
  1601. * many auto tx settings. For now use firmware defaults until
  1602. * we come up with a good way to expose these to the user. */
  1603. if (priv->fwrelease < 0x09000000) {
  1604. ret = lbs_set_power_adapt_cfg(priv, 1,
  1605. POW_ADAPT_DEFAULT_P0,
  1606. POW_ADAPT_DEFAULT_P1,
  1607. POW_ADAPT_DEFAULT_P2);
  1608. if (ret)
  1609. goto out;
  1610. }
  1611. ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
  1612. TPC_DEFAULT_P2, 1);
  1613. if (ret)
  1614. goto out;
  1615. dbm = priv->txpower_max;
  1616. } else {
  1617. /* Userspace check in iwrange if it should use dBm or mW,
  1618. * therefore this should never happen... Jean II */
  1619. if ((vwrq->flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) {
  1620. ret = -EOPNOTSUPP;
  1621. goto out;
  1622. }
  1623. /* Validate requested power level against firmware allowed
  1624. * levels */
  1625. if (priv->txpower_min && (dbm < priv->txpower_min)) {
  1626. ret = -EINVAL;
  1627. goto out;
  1628. }
  1629. if (priv->txpower_max && (dbm > priv->txpower_max)) {
  1630. ret = -EINVAL;
  1631. goto out;
  1632. }
  1633. if (priv->fwrelease < 0x09000000) {
  1634. ret = lbs_set_power_adapt_cfg(priv, 0,
  1635. POW_ADAPT_DEFAULT_P0,
  1636. POW_ADAPT_DEFAULT_P1,
  1637. POW_ADAPT_DEFAULT_P2);
  1638. if (ret)
  1639. goto out;
  1640. }
  1641. ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
  1642. TPC_DEFAULT_P2, 1);
  1643. if (ret)
  1644. goto out;
  1645. }
  1646. /* If the radio was off, turn it on */
  1647. if (!priv->radio_on) {
  1648. ret = lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 1);
  1649. if (ret)
  1650. goto out;
  1651. }
  1652. lbs_deb_wext("txpower set %d dBm\n", dbm);
  1653. ret = lbs_set_tx_power(priv, dbm);
  1654. out:
  1655. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1656. return ret;
  1657. }
  1658. static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
  1659. struct iw_point *dwrq, char *extra)
  1660. {
  1661. struct lbs_private *priv = dev->ml_priv;
  1662. lbs_deb_enter(LBS_DEB_WEXT);
  1663. /*
  1664. * Note : if dwrq->flags != 0, we should get the relevant SSID from
  1665. * the SSID list...
  1666. */
  1667. /*
  1668. * Get the current SSID
  1669. */
  1670. if (priv->connect_status == LBS_CONNECTED) {
  1671. memcpy(extra, priv->curbssparams.ssid,
  1672. priv->curbssparams.ssid_len);
  1673. } else {
  1674. memset(extra, 0, 32);
  1675. }
  1676. /*
  1677. * If none, we may want to get the one that was set
  1678. */
  1679. dwrq->length = priv->curbssparams.ssid_len;
  1680. dwrq->flags = 1; /* active */
  1681. lbs_deb_leave(LBS_DEB_WEXT);
  1682. return 0;
  1683. }
  1684. static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
  1685. struct iw_point *dwrq, char *extra)
  1686. {
  1687. struct lbs_private *priv = dev->ml_priv;
  1688. int ret = 0;
  1689. u8 ssid[IEEE80211_MAX_SSID_LEN];
  1690. u8 ssid_len = 0;
  1691. struct assoc_request * assoc_req;
  1692. int in_ssid_len = dwrq->length;
  1693. DECLARE_SSID_BUF(ssid_buf);
  1694. lbs_deb_enter(LBS_DEB_WEXT);
  1695. if (!priv->radio_on) {
  1696. ret = -EINVAL;
  1697. goto out;
  1698. }
  1699. /* Check the size of the string */
  1700. if (in_ssid_len > IEEE80211_MAX_SSID_LEN) {
  1701. ret = -E2BIG;
  1702. goto out;
  1703. }
  1704. memset(&ssid, 0, sizeof(ssid));
  1705. if (!dwrq->flags || !in_ssid_len) {
  1706. /* "any" SSID requested; leave SSID blank */
  1707. } else {
  1708. /* Specific SSID requested */
  1709. memcpy(&ssid, extra, in_ssid_len);
  1710. ssid_len = in_ssid_len;
  1711. }
  1712. if (!ssid_len) {
  1713. lbs_deb_wext("requested any SSID\n");
  1714. } else {
  1715. lbs_deb_wext("requested SSID '%s'\n",
  1716. print_ssid(ssid_buf, ssid, ssid_len));
  1717. }
  1718. out:
  1719. mutex_lock(&priv->lock);
  1720. if (ret == 0) {
  1721. /* Get or create the current association request */
  1722. assoc_req = lbs_get_association_request(priv);
  1723. if (!assoc_req) {
  1724. ret = -ENOMEM;
  1725. } else {
  1726. /* Copy the SSID to the association request */
  1727. memcpy(&assoc_req->ssid, &ssid, IEEE80211_MAX_SSID_LEN);
  1728. assoc_req->ssid_len = ssid_len;
  1729. set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
  1730. lbs_postpone_association_work(priv);
  1731. }
  1732. }
  1733. /* Cancel the association request if there was an error */
  1734. if (ret != 0) {
  1735. lbs_cancel_association_work(priv);
  1736. }
  1737. mutex_unlock(&priv->lock);
  1738. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1739. return ret;
  1740. }
  1741. static int lbs_mesh_get_essid(struct net_device *dev,
  1742. struct iw_request_info *info,
  1743. struct iw_point *dwrq, char *extra)
  1744. {
  1745. struct lbs_private *priv = dev->ml_priv;
  1746. lbs_deb_enter(LBS_DEB_WEXT);
  1747. memcpy(extra, priv->mesh_ssid, priv->mesh_ssid_len);
  1748. dwrq->length = priv->mesh_ssid_len;
  1749. dwrq->flags = 1; /* active */
  1750. lbs_deb_leave(LBS_DEB_WEXT);
  1751. return 0;
  1752. }
  1753. static int lbs_mesh_set_essid(struct net_device *dev,
  1754. struct iw_request_info *info,
  1755. struct iw_point *dwrq, char *extra)
  1756. {
  1757. struct lbs_private *priv = dev->ml_priv;
  1758. int ret = 0;
  1759. lbs_deb_enter(LBS_DEB_WEXT);
  1760. if (!priv->radio_on) {
  1761. ret = -EINVAL;
  1762. goto out;
  1763. }
  1764. /* Check the size of the string */
  1765. if (dwrq->length > IEEE80211_MAX_SSID_LEN) {
  1766. ret = -E2BIG;
  1767. goto out;
  1768. }
  1769. if (!dwrq->flags || !dwrq->length) {
  1770. ret = -EINVAL;
  1771. goto out;
  1772. } else {
  1773. /* Specific SSID requested */
  1774. memcpy(priv->mesh_ssid, extra, dwrq->length);
  1775. priv->mesh_ssid_len = dwrq->length;
  1776. }
  1777. lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
  1778. priv->channel);
  1779. out:
  1780. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1781. return ret;
  1782. }
  1783. /**
  1784. * @brief Connect to the AP or Ad-hoc Network with specific bssid
  1785. *
  1786. * @param dev A pointer to net_device structure
  1787. * @param info A pointer to iw_request_info structure
  1788. * @param awrq A pointer to iw_param structure
  1789. * @param extra A pointer to extra data buf
  1790. * @return 0 --success, otherwise fail
  1791. */
  1792. static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
  1793. struct sockaddr *awrq, char *extra)
  1794. {
  1795. struct lbs_private *priv = dev->ml_priv;
  1796. struct assoc_request * assoc_req;
  1797. int ret = 0;
  1798. lbs_deb_enter(LBS_DEB_WEXT);
  1799. if (!priv->radio_on)
  1800. return -EINVAL;
  1801. if (awrq->sa_family != ARPHRD_ETHER)
  1802. return -EINVAL;
  1803. lbs_deb_wext("ASSOC: WAP: sa_data %pM\n", awrq->sa_data);
  1804. mutex_lock(&priv->lock);
  1805. /* Get or create the current association request */
  1806. assoc_req = lbs_get_association_request(priv);
  1807. if (!assoc_req) {
  1808. lbs_cancel_association_work(priv);
  1809. ret = -ENOMEM;
  1810. } else {
  1811. /* Copy the BSSID to the association request */
  1812. memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
  1813. set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
  1814. lbs_postpone_association_work(priv);
  1815. }
  1816. mutex_unlock(&priv->lock);
  1817. return ret;
  1818. }
  1819. /*
  1820. * iwconfig settable callbacks
  1821. */
  1822. static const iw_handler lbs_handler[] = {
  1823. (iw_handler) NULL, /* SIOCSIWCOMMIT */
  1824. (iw_handler) lbs_get_name, /* SIOCGIWNAME */
  1825. (iw_handler) NULL, /* SIOCSIWNWID */
  1826. (iw_handler) NULL, /* SIOCGIWNWID */
  1827. (iw_handler) lbs_set_freq, /* SIOCSIWFREQ */
  1828. (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
  1829. (iw_handler) lbs_set_mode, /* SIOCSIWMODE */
  1830. (iw_handler) lbs_get_mode, /* SIOCGIWMODE */
  1831. (iw_handler) NULL, /* SIOCSIWSENS */
  1832. (iw_handler) NULL, /* SIOCGIWSENS */
  1833. (iw_handler) NULL, /* SIOCSIWRANGE */
  1834. (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
  1835. (iw_handler) NULL, /* SIOCSIWPRIV */
  1836. (iw_handler) NULL, /* SIOCGIWPRIV */
  1837. (iw_handler) NULL, /* SIOCSIWSTATS */
  1838. (iw_handler) NULL, /* SIOCGIWSTATS */
  1839. iw_handler_set_spy, /* SIOCSIWSPY */
  1840. iw_handler_get_spy, /* SIOCGIWSPY */
  1841. iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
  1842. iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
  1843. (iw_handler) lbs_set_wap, /* SIOCSIWAP */
  1844. (iw_handler) lbs_get_wap, /* SIOCGIWAP */
  1845. (iw_handler) NULL, /* SIOCSIWMLME */
  1846. (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
  1847. (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
  1848. (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
  1849. (iw_handler) lbs_set_essid, /* SIOCSIWESSID */
  1850. (iw_handler) lbs_get_essid, /* SIOCGIWESSID */
  1851. (iw_handler) lbs_set_nick, /* SIOCSIWNICKN */
  1852. (iw_handler) lbs_get_nick, /* SIOCGIWNICKN */
  1853. (iw_handler) NULL, /* -- hole -- */
  1854. (iw_handler) NULL, /* -- hole -- */
  1855. (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
  1856. (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
  1857. (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
  1858. (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
  1859. (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
  1860. (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
  1861. (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
  1862. (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
  1863. (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
  1864. (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
  1865. (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
  1866. (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
  1867. (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
  1868. (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
  1869. (iw_handler) NULL, /* -- hole -- */
  1870. (iw_handler) NULL, /* -- hole -- */
  1871. (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
  1872. (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
  1873. (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
  1874. (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
  1875. (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
  1876. (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
  1877. (iw_handler) NULL, /* SIOCSIWPMKSA */
  1878. };
  1879. static const iw_handler mesh_wlan_handler[] = {
  1880. (iw_handler) NULL, /* SIOCSIWCOMMIT */
  1881. (iw_handler) lbs_get_name, /* SIOCGIWNAME */
  1882. (iw_handler) NULL, /* SIOCSIWNWID */
  1883. (iw_handler) NULL, /* SIOCGIWNWID */
  1884. (iw_handler) lbs_mesh_set_freq, /* SIOCSIWFREQ */
  1885. (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
  1886. (iw_handler) NULL, /* SIOCSIWMODE */
  1887. (iw_handler) mesh_wlan_get_mode, /* SIOCGIWMODE */
  1888. (iw_handler) NULL, /* SIOCSIWSENS */
  1889. (iw_handler) NULL, /* SIOCGIWSENS */
  1890. (iw_handler) NULL, /* SIOCSIWRANGE */
  1891. (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
  1892. (iw_handler) NULL, /* SIOCSIWPRIV */
  1893. (iw_handler) NULL, /* SIOCGIWPRIV */
  1894. (iw_handler) NULL, /* SIOCSIWSTATS */
  1895. (iw_handler) NULL, /* SIOCGIWSTATS */
  1896. iw_handler_set_spy, /* SIOCSIWSPY */
  1897. iw_handler_get_spy, /* SIOCGIWSPY */
  1898. iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
  1899. iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
  1900. (iw_handler) NULL, /* SIOCSIWAP */
  1901. (iw_handler) NULL, /* SIOCGIWAP */
  1902. (iw_handler) NULL, /* SIOCSIWMLME */
  1903. (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
  1904. (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
  1905. (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
  1906. (iw_handler) lbs_mesh_set_essid,/* SIOCSIWESSID */
  1907. (iw_handler) lbs_mesh_get_essid,/* SIOCGIWESSID */
  1908. (iw_handler) NULL, /* SIOCSIWNICKN */
  1909. (iw_handler) mesh_get_nick, /* SIOCGIWNICKN */
  1910. (iw_handler) NULL, /* -- hole -- */
  1911. (iw_handler) NULL, /* -- hole -- */
  1912. (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
  1913. (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
  1914. (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
  1915. (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
  1916. (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
  1917. (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
  1918. (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
  1919. (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
  1920. (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
  1921. (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
  1922. (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
  1923. (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
  1924. (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
  1925. (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
  1926. (iw_handler) NULL, /* -- hole -- */
  1927. (iw_handler) NULL, /* -- hole -- */
  1928. (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
  1929. (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
  1930. (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
  1931. (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
  1932. (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
  1933. (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
  1934. (iw_handler) NULL, /* SIOCSIWPMKSA */
  1935. };
  1936. struct iw_handler_def lbs_handler_def = {
  1937. .num_standard = ARRAY_SIZE(lbs_handler),
  1938. .standard = (iw_handler *) lbs_handler,
  1939. .get_wireless_stats = lbs_get_wireless_stats,
  1940. };
  1941. struct iw_handler_def mesh_handler_def = {
  1942. .num_standard = ARRAY_SIZE(mesh_wlan_handler),
  1943. .standard = (iw_handler *) mesh_wlan_handler,
  1944. .get_wireless_stats = lbs_get_wireless_stats,
  1945. };