wext.c 58 KB

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