wext.c 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349
  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. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
  1172. } else if (dwrq->flags & IW_ENCODE_OPEN) {
  1173. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1174. }
  1175. out:
  1176. if (ret == 0) {
  1177. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1178. lbs_postpone_association_work(priv);
  1179. } else {
  1180. lbs_cancel_association_work(priv);
  1181. }
  1182. mutex_unlock(&priv->lock);
  1183. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1184. return ret;
  1185. }
  1186. /**
  1187. * @brief Get Extended Encryption key (WPA/802.1x and WEP)
  1188. *
  1189. * @param dev A pointer to net_device structure
  1190. * @param info A pointer to iw_request_info structure
  1191. * @param vwrq A pointer to iw_param structure
  1192. * @param extra A pointer to extra data buf
  1193. * @return 0 on success, otherwise failure
  1194. */
  1195. static int lbs_get_encodeext(struct net_device *dev,
  1196. struct iw_request_info *info,
  1197. struct iw_point *dwrq,
  1198. char *extra)
  1199. {
  1200. int ret = -EINVAL;
  1201. struct lbs_private *priv = dev->ml_priv;
  1202. struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  1203. int index, max_key_len;
  1204. lbs_deb_enter(LBS_DEB_WEXT);
  1205. max_key_len = dwrq->length - sizeof(*ext);
  1206. if (max_key_len < 0)
  1207. goto out;
  1208. index = dwrq->flags & IW_ENCODE_INDEX;
  1209. if (index) {
  1210. if (index < 1 || index > 4)
  1211. goto out;
  1212. index--;
  1213. } else {
  1214. index = priv->wep_tx_keyidx;
  1215. }
  1216. if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) &&
  1217. ext->alg != IW_ENCODE_ALG_WEP) {
  1218. if (index != 0 || priv->mode != IW_MODE_INFRA)
  1219. goto out;
  1220. }
  1221. dwrq->flags = index + 1;
  1222. memset(ext, 0, sizeof(*ext));
  1223. if ( !priv->secinfo.wep_enabled
  1224. && !priv->secinfo.WPAenabled
  1225. && !priv->secinfo.WPA2enabled) {
  1226. ext->alg = IW_ENCODE_ALG_NONE;
  1227. ext->key_len = 0;
  1228. dwrq->flags |= IW_ENCODE_DISABLED;
  1229. } else {
  1230. u8 *key = NULL;
  1231. if ( priv->secinfo.wep_enabled
  1232. && !priv->secinfo.WPAenabled
  1233. && !priv->secinfo.WPA2enabled) {
  1234. /* WEP */
  1235. ext->alg = IW_ENCODE_ALG_WEP;
  1236. ext->key_len = priv->wep_keys[index].len;
  1237. key = &priv->wep_keys[index].key[0];
  1238. } else if ( !priv->secinfo.wep_enabled
  1239. && (priv->secinfo.WPAenabled ||
  1240. priv->secinfo.WPA2enabled)) {
  1241. /* WPA */
  1242. struct enc_key * pkey = NULL;
  1243. if ( priv->wpa_mcast_key.len
  1244. && (priv->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
  1245. pkey = &priv->wpa_mcast_key;
  1246. else if ( priv->wpa_unicast_key.len
  1247. && (priv->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED))
  1248. pkey = &priv->wpa_unicast_key;
  1249. if (pkey) {
  1250. if (pkey->type == KEY_TYPE_ID_AES) {
  1251. ext->alg = IW_ENCODE_ALG_CCMP;
  1252. } else {
  1253. ext->alg = IW_ENCODE_ALG_TKIP;
  1254. }
  1255. ext->key_len = pkey->len;
  1256. key = &pkey->key[0];
  1257. } else {
  1258. ext->alg = IW_ENCODE_ALG_TKIP;
  1259. ext->key_len = 0;
  1260. }
  1261. } else {
  1262. goto out;
  1263. }
  1264. if (ext->key_len > max_key_len) {
  1265. ret = -E2BIG;
  1266. goto out;
  1267. }
  1268. if (ext->key_len)
  1269. memcpy(ext->key, key, ext->key_len);
  1270. else
  1271. dwrq->flags |= IW_ENCODE_NOKEY;
  1272. dwrq->flags |= IW_ENCODE_ENABLED;
  1273. }
  1274. ret = 0;
  1275. out:
  1276. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1277. return ret;
  1278. }
  1279. /**
  1280. * @brief Set Encryption key Extended (WPA/802.1x and WEP)
  1281. *
  1282. * @param dev A pointer to net_device structure
  1283. * @param info A pointer to iw_request_info structure
  1284. * @param vwrq A pointer to iw_param structure
  1285. * @param extra A pointer to extra data buf
  1286. * @return 0 --success, otherwise fail
  1287. */
  1288. static int lbs_set_encodeext(struct net_device *dev,
  1289. struct iw_request_info *info,
  1290. struct iw_point *dwrq,
  1291. char *extra)
  1292. {
  1293. int ret = 0;
  1294. struct lbs_private *priv = dev->ml_priv;
  1295. struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
  1296. int alg = ext->alg;
  1297. struct assoc_request * assoc_req;
  1298. lbs_deb_enter(LBS_DEB_WEXT);
  1299. mutex_lock(&priv->lock);
  1300. assoc_req = lbs_get_association_request(priv);
  1301. if (!assoc_req) {
  1302. ret = -ENOMEM;
  1303. goto out;
  1304. }
  1305. if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) {
  1306. disable_wep (assoc_req);
  1307. disable_wpa (assoc_req);
  1308. } else if (alg == IW_ENCODE_ALG_WEP) {
  1309. u16 is_default = 0, index, set_tx_key = 0;
  1310. ret = validate_key_index(assoc_req->wep_tx_keyidx,
  1311. (dwrq->flags & IW_ENCODE_INDEX),
  1312. &index, &is_default);
  1313. if (ret)
  1314. goto out;
  1315. /* If WEP isn't enabled, or if there is no key data but a valid
  1316. * index, or if the set-TX-key flag was passed, set the TX key.
  1317. */
  1318. if ( !assoc_req->secinfo.wep_enabled
  1319. || (dwrq->length == 0 && !is_default)
  1320. || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY))
  1321. set_tx_key = 1;
  1322. /* Copy key to driver */
  1323. ret = lbs_set_wep_key(assoc_req, ext->key, ext->key_len, index,
  1324. set_tx_key);
  1325. if (ret)
  1326. goto out;
  1327. if (dwrq->flags & IW_ENCODE_RESTRICTED) {
  1328. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
  1329. } else if (dwrq->flags & IW_ENCODE_OPEN) {
  1330. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1331. }
  1332. /* Mark the various WEP bits as modified */
  1333. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1334. if (dwrq->length)
  1335. set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
  1336. if (set_tx_key)
  1337. set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
  1338. } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
  1339. struct enc_key * pkey;
  1340. /* validate key length */
  1341. if (((alg == IW_ENCODE_ALG_TKIP)
  1342. && (ext->key_len != KEY_LEN_WPA_TKIP))
  1343. || ((alg == IW_ENCODE_ALG_CCMP)
  1344. && (ext->key_len != KEY_LEN_WPA_AES))) {
  1345. lbs_deb_wext("invalid size %d for key of alg "
  1346. "type %d\n",
  1347. ext->key_len,
  1348. alg);
  1349. ret = -EINVAL;
  1350. goto out;
  1351. }
  1352. if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
  1353. pkey = &assoc_req->wpa_mcast_key;
  1354. set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
  1355. } else {
  1356. pkey = &assoc_req->wpa_unicast_key;
  1357. set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
  1358. }
  1359. memset(pkey, 0, sizeof (struct enc_key));
  1360. memcpy(pkey->key, ext->key, ext->key_len);
  1361. pkey->len = ext->key_len;
  1362. if (pkey->len)
  1363. pkey->flags |= KEY_INFO_WPA_ENABLED;
  1364. /* Do this after zeroing key structure */
  1365. if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
  1366. pkey->flags |= KEY_INFO_WPA_MCAST;
  1367. } else {
  1368. pkey->flags |= KEY_INFO_WPA_UNICAST;
  1369. }
  1370. if (alg == IW_ENCODE_ALG_TKIP) {
  1371. pkey->type = KEY_TYPE_ID_TKIP;
  1372. } else if (alg == IW_ENCODE_ALG_CCMP) {
  1373. pkey->type = KEY_TYPE_ID_AES;
  1374. }
  1375. /* If WPA isn't enabled yet, do that now */
  1376. if ( assoc_req->secinfo.WPAenabled == 0
  1377. && assoc_req->secinfo.WPA2enabled == 0) {
  1378. assoc_req->secinfo.WPAenabled = 1;
  1379. assoc_req->secinfo.WPA2enabled = 1;
  1380. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1381. }
  1382. /* Only disable wep if necessary: can't waste time here. */
  1383. if (priv->mac_control & CMD_ACT_MAC_WEP_ENABLE)
  1384. disable_wep(assoc_req);
  1385. }
  1386. out:
  1387. if (ret == 0) {
  1388. /* 802.1x and WPA rekeying must happen as quickly as possible,
  1389. * especially during the 4-way handshake; thus if in
  1390. * infrastructure mode, and either (a) 802.1x is enabled or
  1391. * (b) WPA is being used, set the key right away.
  1392. */
  1393. if (assoc_req->mode == IW_MODE_INFRA &&
  1394. ((assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_802_1X) ||
  1395. (assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_PSK) ||
  1396. assoc_req->secinfo.WPAenabled ||
  1397. assoc_req->secinfo.WPA2enabled)) {
  1398. lbs_do_association_work(priv);
  1399. } else
  1400. lbs_postpone_association_work(priv);
  1401. } else {
  1402. lbs_cancel_association_work(priv);
  1403. }
  1404. mutex_unlock(&priv->lock);
  1405. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1406. return ret;
  1407. }
  1408. static int lbs_set_genie(struct net_device *dev,
  1409. struct iw_request_info *info,
  1410. struct iw_point *dwrq,
  1411. char *extra)
  1412. {
  1413. struct lbs_private *priv = dev->ml_priv;
  1414. int ret = 0;
  1415. struct assoc_request * assoc_req;
  1416. lbs_deb_enter(LBS_DEB_WEXT);
  1417. mutex_lock(&priv->lock);
  1418. assoc_req = lbs_get_association_request(priv);
  1419. if (!assoc_req) {
  1420. ret = -ENOMEM;
  1421. goto out;
  1422. }
  1423. if (dwrq->length > MAX_WPA_IE_LEN ||
  1424. (dwrq->length && extra == NULL)) {
  1425. ret = -EINVAL;
  1426. goto out;
  1427. }
  1428. if (dwrq->length) {
  1429. memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length);
  1430. assoc_req->wpa_ie_len = dwrq->length;
  1431. } else {
  1432. memset(&assoc_req->wpa_ie[0], 0, sizeof(priv->wpa_ie));
  1433. assoc_req->wpa_ie_len = 0;
  1434. }
  1435. out:
  1436. if (ret == 0) {
  1437. set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
  1438. lbs_postpone_association_work(priv);
  1439. } else {
  1440. lbs_cancel_association_work(priv);
  1441. }
  1442. mutex_unlock(&priv->lock);
  1443. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1444. return ret;
  1445. }
  1446. static int lbs_get_genie(struct net_device *dev,
  1447. struct iw_request_info *info,
  1448. struct iw_point *dwrq,
  1449. char *extra)
  1450. {
  1451. int ret = 0;
  1452. struct lbs_private *priv = dev->ml_priv;
  1453. lbs_deb_enter(LBS_DEB_WEXT);
  1454. if (priv->wpa_ie_len == 0) {
  1455. dwrq->length = 0;
  1456. goto out;
  1457. }
  1458. if (dwrq->length < priv->wpa_ie_len) {
  1459. ret = -E2BIG;
  1460. goto out;
  1461. }
  1462. dwrq->length = priv->wpa_ie_len;
  1463. memcpy(extra, &priv->wpa_ie[0], priv->wpa_ie_len);
  1464. out:
  1465. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1466. return ret;
  1467. }
  1468. static int lbs_set_auth(struct net_device *dev,
  1469. struct iw_request_info *info,
  1470. struct iw_param *dwrq,
  1471. char *extra)
  1472. {
  1473. struct lbs_private *priv = dev->ml_priv;
  1474. struct assoc_request * assoc_req;
  1475. int ret = 0;
  1476. int updated = 0;
  1477. lbs_deb_enter(LBS_DEB_WEXT);
  1478. mutex_lock(&priv->lock);
  1479. assoc_req = lbs_get_association_request(priv);
  1480. if (!assoc_req) {
  1481. ret = -ENOMEM;
  1482. goto out;
  1483. }
  1484. switch (dwrq->flags & IW_AUTH_INDEX) {
  1485. case IW_AUTH_PRIVACY_INVOKED:
  1486. case IW_AUTH_RX_UNENCRYPTED_EAPOL:
  1487. case IW_AUTH_TKIP_COUNTERMEASURES:
  1488. case IW_AUTH_CIPHER_PAIRWISE:
  1489. case IW_AUTH_CIPHER_GROUP:
  1490. case IW_AUTH_DROP_UNENCRYPTED:
  1491. /*
  1492. * libertas does not use these parameters
  1493. */
  1494. break;
  1495. case IW_AUTH_KEY_MGMT:
  1496. assoc_req->secinfo.key_mgmt = dwrq->value;
  1497. updated = 1;
  1498. break;
  1499. case IW_AUTH_WPA_VERSION:
  1500. if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) {
  1501. assoc_req->secinfo.WPAenabled = 0;
  1502. assoc_req->secinfo.WPA2enabled = 0;
  1503. disable_wpa (assoc_req);
  1504. }
  1505. if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
  1506. assoc_req->secinfo.WPAenabled = 1;
  1507. assoc_req->secinfo.wep_enabled = 0;
  1508. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1509. }
  1510. if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) {
  1511. assoc_req->secinfo.WPA2enabled = 1;
  1512. assoc_req->secinfo.wep_enabled = 0;
  1513. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1514. }
  1515. updated = 1;
  1516. break;
  1517. case IW_AUTH_80211_AUTH_ALG:
  1518. if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
  1519. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
  1520. } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) {
  1521. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1522. } else if (dwrq->value & IW_AUTH_ALG_LEAP) {
  1523. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP;
  1524. } else {
  1525. ret = -EINVAL;
  1526. }
  1527. updated = 1;
  1528. break;
  1529. case IW_AUTH_WPA_ENABLED:
  1530. if (dwrq->value) {
  1531. if (!assoc_req->secinfo.WPAenabled &&
  1532. !assoc_req->secinfo.WPA2enabled) {
  1533. assoc_req->secinfo.WPAenabled = 1;
  1534. assoc_req->secinfo.WPA2enabled = 1;
  1535. assoc_req->secinfo.wep_enabled = 0;
  1536. assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
  1537. }
  1538. } else {
  1539. assoc_req->secinfo.WPAenabled = 0;
  1540. assoc_req->secinfo.WPA2enabled = 0;
  1541. disable_wpa (assoc_req);
  1542. }
  1543. updated = 1;
  1544. break;
  1545. default:
  1546. ret = -EOPNOTSUPP;
  1547. break;
  1548. }
  1549. out:
  1550. if (ret == 0) {
  1551. if (updated)
  1552. set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
  1553. lbs_postpone_association_work(priv);
  1554. } else if (ret != -EOPNOTSUPP) {
  1555. lbs_cancel_association_work(priv);
  1556. }
  1557. mutex_unlock(&priv->lock);
  1558. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1559. return ret;
  1560. }
  1561. static int lbs_get_auth(struct net_device *dev,
  1562. struct iw_request_info *info,
  1563. struct iw_param *dwrq,
  1564. char *extra)
  1565. {
  1566. int ret = 0;
  1567. struct lbs_private *priv = dev->ml_priv;
  1568. lbs_deb_enter(LBS_DEB_WEXT);
  1569. switch (dwrq->flags & IW_AUTH_INDEX) {
  1570. case IW_AUTH_KEY_MGMT:
  1571. dwrq->value = priv->secinfo.key_mgmt;
  1572. break;
  1573. case IW_AUTH_WPA_VERSION:
  1574. dwrq->value = 0;
  1575. if (priv->secinfo.WPAenabled)
  1576. dwrq->value |= IW_AUTH_WPA_VERSION_WPA;
  1577. if (priv->secinfo.WPA2enabled)
  1578. dwrq->value |= IW_AUTH_WPA_VERSION_WPA2;
  1579. if (!dwrq->value)
  1580. dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
  1581. break;
  1582. case IW_AUTH_80211_AUTH_ALG:
  1583. dwrq->value = priv->secinfo.auth_mode;
  1584. break;
  1585. case IW_AUTH_WPA_ENABLED:
  1586. if (priv->secinfo.WPAenabled && priv->secinfo.WPA2enabled)
  1587. dwrq->value = 1;
  1588. break;
  1589. default:
  1590. ret = -EOPNOTSUPP;
  1591. }
  1592. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1593. return ret;
  1594. }
  1595. static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
  1596. struct iw_param *vwrq, char *extra)
  1597. {
  1598. int ret = 0;
  1599. struct lbs_private *priv = dev->ml_priv;
  1600. s16 dbm = (s16) vwrq->value;
  1601. lbs_deb_enter(LBS_DEB_WEXT);
  1602. if (vwrq->disabled) {
  1603. lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 0);
  1604. goto out;
  1605. }
  1606. if (vwrq->fixed == 0) {
  1607. /* User requests automatic tx power control, however there are
  1608. * many auto tx settings. For now use firmware defaults until
  1609. * we come up with a good way to expose these to the user. */
  1610. if (priv->fwrelease < 0x09000000) {
  1611. ret = lbs_set_power_adapt_cfg(priv, 1,
  1612. POW_ADAPT_DEFAULT_P0,
  1613. POW_ADAPT_DEFAULT_P1,
  1614. POW_ADAPT_DEFAULT_P2);
  1615. if (ret)
  1616. goto out;
  1617. }
  1618. ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
  1619. TPC_DEFAULT_P2, 1);
  1620. if (ret)
  1621. goto out;
  1622. dbm = priv->txpower_max;
  1623. } else {
  1624. /* Userspace check in iwrange if it should use dBm or mW,
  1625. * therefore this should never happen... Jean II */
  1626. if ((vwrq->flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) {
  1627. ret = -EOPNOTSUPP;
  1628. goto out;
  1629. }
  1630. /* Validate requested power level against firmware allowed
  1631. * levels */
  1632. if (priv->txpower_min && (dbm < priv->txpower_min)) {
  1633. ret = -EINVAL;
  1634. goto out;
  1635. }
  1636. if (priv->txpower_max && (dbm > priv->txpower_max)) {
  1637. ret = -EINVAL;
  1638. goto out;
  1639. }
  1640. if (priv->fwrelease < 0x09000000) {
  1641. ret = lbs_set_power_adapt_cfg(priv, 0,
  1642. POW_ADAPT_DEFAULT_P0,
  1643. POW_ADAPT_DEFAULT_P1,
  1644. POW_ADAPT_DEFAULT_P2);
  1645. if (ret)
  1646. goto out;
  1647. }
  1648. ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
  1649. TPC_DEFAULT_P2, 1);
  1650. if (ret)
  1651. goto out;
  1652. }
  1653. /* If the radio was off, turn it on */
  1654. if (!priv->radio_on) {
  1655. ret = lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 1);
  1656. if (ret)
  1657. goto out;
  1658. }
  1659. lbs_deb_wext("txpower set %d dBm\n", dbm);
  1660. ret = lbs_set_tx_power(priv, dbm);
  1661. out:
  1662. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1663. return ret;
  1664. }
  1665. static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
  1666. struct iw_point *dwrq, char *extra)
  1667. {
  1668. struct lbs_private *priv = dev->ml_priv;
  1669. lbs_deb_enter(LBS_DEB_WEXT);
  1670. /*
  1671. * Note : if dwrq->flags != 0, we should get the relevant SSID from
  1672. * the SSID list...
  1673. */
  1674. /*
  1675. * Get the current SSID
  1676. */
  1677. if (priv->connect_status == LBS_CONNECTED) {
  1678. memcpy(extra, priv->curbssparams.ssid,
  1679. priv->curbssparams.ssid_len);
  1680. } else {
  1681. memset(extra, 0, 32);
  1682. }
  1683. /*
  1684. * If none, we may want to get the one that was set
  1685. */
  1686. dwrq->length = priv->curbssparams.ssid_len;
  1687. dwrq->flags = 1; /* active */
  1688. lbs_deb_leave(LBS_DEB_WEXT);
  1689. return 0;
  1690. }
  1691. static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
  1692. struct iw_point *dwrq, char *extra)
  1693. {
  1694. struct lbs_private *priv = dev->ml_priv;
  1695. int ret = 0;
  1696. u8 ssid[IEEE80211_MAX_SSID_LEN];
  1697. u8 ssid_len = 0;
  1698. struct assoc_request * assoc_req;
  1699. int in_ssid_len = dwrq->length;
  1700. DECLARE_SSID_BUF(ssid_buf);
  1701. lbs_deb_enter(LBS_DEB_WEXT);
  1702. if (!priv->radio_on) {
  1703. ret = -EINVAL;
  1704. goto out;
  1705. }
  1706. /* Check the size of the string */
  1707. if (in_ssid_len > IEEE80211_MAX_SSID_LEN) {
  1708. ret = -E2BIG;
  1709. goto out;
  1710. }
  1711. memset(&ssid, 0, sizeof(ssid));
  1712. if (!dwrq->flags || !in_ssid_len) {
  1713. /* "any" SSID requested; leave SSID blank */
  1714. } else {
  1715. /* Specific SSID requested */
  1716. memcpy(&ssid, extra, in_ssid_len);
  1717. ssid_len = in_ssid_len;
  1718. }
  1719. if (!ssid_len) {
  1720. lbs_deb_wext("requested any SSID\n");
  1721. } else {
  1722. lbs_deb_wext("requested SSID '%s'\n",
  1723. print_ssid(ssid_buf, ssid, ssid_len));
  1724. }
  1725. out:
  1726. mutex_lock(&priv->lock);
  1727. if (ret == 0) {
  1728. /* Get or create the current association request */
  1729. assoc_req = lbs_get_association_request(priv);
  1730. if (!assoc_req) {
  1731. ret = -ENOMEM;
  1732. } else {
  1733. /* Copy the SSID to the association request */
  1734. memcpy(&assoc_req->ssid, &ssid, IEEE80211_MAX_SSID_LEN);
  1735. assoc_req->ssid_len = ssid_len;
  1736. set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
  1737. lbs_postpone_association_work(priv);
  1738. }
  1739. }
  1740. /* Cancel the association request if there was an error */
  1741. if (ret != 0) {
  1742. lbs_cancel_association_work(priv);
  1743. }
  1744. mutex_unlock(&priv->lock);
  1745. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1746. return ret;
  1747. }
  1748. #ifdef CONFIG_LIBERTAS_MESH
  1749. static int lbs_mesh_get_essid(struct net_device *dev,
  1750. struct iw_request_info *info,
  1751. struct iw_point *dwrq, char *extra)
  1752. {
  1753. struct lbs_private *priv = dev->ml_priv;
  1754. lbs_deb_enter(LBS_DEB_WEXT);
  1755. memcpy(extra, priv->mesh_ssid, priv->mesh_ssid_len);
  1756. dwrq->length = priv->mesh_ssid_len;
  1757. dwrq->flags = 1; /* active */
  1758. lbs_deb_leave(LBS_DEB_WEXT);
  1759. return 0;
  1760. }
  1761. static int lbs_mesh_set_essid(struct net_device *dev,
  1762. struct iw_request_info *info,
  1763. struct iw_point *dwrq, char *extra)
  1764. {
  1765. struct lbs_private *priv = dev->ml_priv;
  1766. int ret = 0;
  1767. lbs_deb_enter(LBS_DEB_WEXT);
  1768. if (!priv->radio_on) {
  1769. ret = -EINVAL;
  1770. goto out;
  1771. }
  1772. /* Check the size of the string */
  1773. if (dwrq->length > IEEE80211_MAX_SSID_LEN) {
  1774. ret = -E2BIG;
  1775. goto out;
  1776. }
  1777. if (!dwrq->flags || !dwrq->length) {
  1778. ret = -EINVAL;
  1779. goto out;
  1780. } else {
  1781. /* Specific SSID requested */
  1782. memcpy(priv->mesh_ssid, extra, dwrq->length);
  1783. priv->mesh_ssid_len = dwrq->length;
  1784. }
  1785. lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
  1786. priv->channel);
  1787. out:
  1788. lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
  1789. return ret;
  1790. }
  1791. #endif
  1792. /**
  1793. * @brief Connect to the AP or Ad-hoc Network with specific bssid
  1794. *
  1795. * @param dev A pointer to net_device structure
  1796. * @param info A pointer to iw_request_info structure
  1797. * @param awrq A pointer to iw_param structure
  1798. * @param extra A pointer to extra data buf
  1799. * @return 0 --success, otherwise fail
  1800. */
  1801. static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
  1802. struct sockaddr *awrq, char *extra)
  1803. {
  1804. struct lbs_private *priv = dev->ml_priv;
  1805. struct assoc_request * assoc_req;
  1806. int ret = 0;
  1807. lbs_deb_enter(LBS_DEB_WEXT);
  1808. if (!priv->radio_on)
  1809. return -EINVAL;
  1810. if (awrq->sa_family != ARPHRD_ETHER)
  1811. return -EINVAL;
  1812. lbs_deb_wext("ASSOC: WAP: sa_data %pM\n", awrq->sa_data);
  1813. mutex_lock(&priv->lock);
  1814. /* Get or create the current association request */
  1815. assoc_req = lbs_get_association_request(priv);
  1816. if (!assoc_req) {
  1817. lbs_cancel_association_work(priv);
  1818. ret = -ENOMEM;
  1819. } else {
  1820. /* Copy the BSSID to the association request */
  1821. memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
  1822. set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
  1823. lbs_postpone_association_work(priv);
  1824. }
  1825. mutex_unlock(&priv->lock);
  1826. return ret;
  1827. }
  1828. /*
  1829. * iwconfig settable callbacks
  1830. */
  1831. static const iw_handler lbs_handler[] = {
  1832. (iw_handler) NULL, /* SIOCSIWCOMMIT */
  1833. (iw_handler) lbs_get_name, /* SIOCGIWNAME */
  1834. (iw_handler) NULL, /* SIOCSIWNWID */
  1835. (iw_handler) NULL, /* SIOCGIWNWID */
  1836. (iw_handler) lbs_set_freq, /* SIOCSIWFREQ */
  1837. (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
  1838. (iw_handler) lbs_set_mode, /* SIOCSIWMODE */
  1839. (iw_handler) lbs_get_mode, /* SIOCGIWMODE */
  1840. (iw_handler) NULL, /* SIOCSIWSENS */
  1841. (iw_handler) NULL, /* SIOCGIWSENS */
  1842. (iw_handler) NULL, /* SIOCSIWRANGE */
  1843. (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
  1844. (iw_handler) NULL, /* SIOCSIWPRIV */
  1845. (iw_handler) NULL, /* SIOCGIWPRIV */
  1846. (iw_handler) NULL, /* SIOCSIWSTATS */
  1847. (iw_handler) NULL, /* SIOCGIWSTATS */
  1848. iw_handler_set_spy, /* SIOCSIWSPY */
  1849. iw_handler_get_spy, /* SIOCGIWSPY */
  1850. iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
  1851. iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
  1852. (iw_handler) lbs_set_wap, /* SIOCSIWAP */
  1853. (iw_handler) lbs_get_wap, /* SIOCGIWAP */
  1854. (iw_handler) NULL, /* SIOCSIWMLME */
  1855. (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
  1856. (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
  1857. (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
  1858. (iw_handler) lbs_set_essid, /* SIOCSIWESSID */
  1859. (iw_handler) lbs_get_essid, /* SIOCGIWESSID */
  1860. (iw_handler) lbs_set_nick, /* SIOCSIWNICKN */
  1861. (iw_handler) lbs_get_nick, /* SIOCGIWNICKN */
  1862. (iw_handler) NULL, /* -- hole -- */
  1863. (iw_handler) NULL, /* -- hole -- */
  1864. (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
  1865. (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
  1866. (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
  1867. (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
  1868. (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
  1869. (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
  1870. (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
  1871. (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
  1872. (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
  1873. (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
  1874. (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
  1875. (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
  1876. (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
  1877. (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
  1878. (iw_handler) NULL, /* -- hole -- */
  1879. (iw_handler) NULL, /* -- hole -- */
  1880. (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
  1881. (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
  1882. (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
  1883. (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
  1884. (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
  1885. (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
  1886. (iw_handler) NULL, /* SIOCSIWPMKSA */
  1887. };
  1888. struct iw_handler_def lbs_handler_def = {
  1889. .num_standard = ARRAY_SIZE(lbs_handler),
  1890. .standard = (iw_handler *) lbs_handler,
  1891. .get_wireless_stats = lbs_get_wireless_stats,
  1892. };
  1893. #ifdef CONFIG_LIBERTAS_MESH
  1894. static const iw_handler mesh_wlan_handler[] = {
  1895. (iw_handler) NULL, /* SIOCSIWCOMMIT */
  1896. (iw_handler) lbs_get_name, /* SIOCGIWNAME */
  1897. (iw_handler) NULL, /* SIOCSIWNWID */
  1898. (iw_handler) NULL, /* SIOCGIWNWID */
  1899. (iw_handler) lbs_mesh_set_freq, /* SIOCSIWFREQ */
  1900. (iw_handler) lbs_get_freq, /* SIOCGIWFREQ */
  1901. (iw_handler) NULL, /* SIOCSIWMODE */
  1902. (iw_handler) mesh_wlan_get_mode, /* SIOCGIWMODE */
  1903. (iw_handler) NULL, /* SIOCSIWSENS */
  1904. (iw_handler) NULL, /* SIOCGIWSENS */
  1905. (iw_handler) NULL, /* SIOCSIWRANGE */
  1906. (iw_handler) lbs_get_range, /* SIOCGIWRANGE */
  1907. (iw_handler) NULL, /* SIOCSIWPRIV */
  1908. (iw_handler) NULL, /* SIOCGIWPRIV */
  1909. (iw_handler) NULL, /* SIOCSIWSTATS */
  1910. (iw_handler) NULL, /* SIOCGIWSTATS */
  1911. iw_handler_set_spy, /* SIOCSIWSPY */
  1912. iw_handler_get_spy, /* SIOCGIWSPY */
  1913. iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
  1914. iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
  1915. (iw_handler) NULL, /* SIOCSIWAP */
  1916. (iw_handler) NULL, /* SIOCGIWAP */
  1917. (iw_handler) NULL, /* SIOCSIWMLME */
  1918. (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
  1919. (iw_handler) lbs_set_scan, /* SIOCSIWSCAN */
  1920. (iw_handler) lbs_get_scan, /* SIOCGIWSCAN */
  1921. (iw_handler) lbs_mesh_set_essid,/* SIOCSIWESSID */
  1922. (iw_handler) lbs_mesh_get_essid,/* SIOCGIWESSID */
  1923. (iw_handler) NULL, /* SIOCSIWNICKN */
  1924. (iw_handler) mesh_get_nick, /* SIOCGIWNICKN */
  1925. (iw_handler) NULL, /* -- hole -- */
  1926. (iw_handler) NULL, /* -- hole -- */
  1927. (iw_handler) lbs_set_rate, /* SIOCSIWRATE */
  1928. (iw_handler) lbs_get_rate, /* SIOCGIWRATE */
  1929. (iw_handler) lbs_set_rts, /* SIOCSIWRTS */
  1930. (iw_handler) lbs_get_rts, /* SIOCGIWRTS */
  1931. (iw_handler) lbs_set_frag, /* SIOCSIWFRAG */
  1932. (iw_handler) lbs_get_frag, /* SIOCGIWFRAG */
  1933. (iw_handler) lbs_set_txpow, /* SIOCSIWTXPOW */
  1934. (iw_handler) lbs_get_txpow, /* SIOCGIWTXPOW */
  1935. (iw_handler) lbs_set_retry, /* SIOCSIWRETRY */
  1936. (iw_handler) lbs_get_retry, /* SIOCGIWRETRY */
  1937. (iw_handler) lbs_set_encode, /* SIOCSIWENCODE */
  1938. (iw_handler) lbs_get_encode, /* SIOCGIWENCODE */
  1939. (iw_handler) lbs_set_power, /* SIOCSIWPOWER */
  1940. (iw_handler) lbs_get_power, /* SIOCGIWPOWER */
  1941. (iw_handler) NULL, /* -- hole -- */
  1942. (iw_handler) NULL, /* -- hole -- */
  1943. (iw_handler) lbs_set_genie, /* SIOCSIWGENIE */
  1944. (iw_handler) lbs_get_genie, /* SIOCGIWGENIE */
  1945. (iw_handler) lbs_set_auth, /* SIOCSIWAUTH */
  1946. (iw_handler) lbs_get_auth, /* SIOCGIWAUTH */
  1947. (iw_handler) lbs_set_encodeext,/* SIOCSIWENCODEEXT */
  1948. (iw_handler) lbs_get_encodeext,/* SIOCGIWENCODEEXT */
  1949. (iw_handler) NULL, /* SIOCSIWPMKSA */
  1950. };
  1951. struct iw_handler_def mesh_handler_def = {
  1952. .num_standard = ARRAY_SIZE(mesh_wlan_handler),
  1953. .standard = (iw_handler *) mesh_wlan_handler,
  1954. .get_wireless_stats = lbs_get_wireless_stats,
  1955. };
  1956. #endif