wext.c 57 KB

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