wext.c 58 KB

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