wext.c 58 KB

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