wext.c 58 KB

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