iwctl.c 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279
  1. /*
  2. * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. * File: iwctl.c
  20. *
  21. * Purpose: wireless ext & ioctl functions
  22. *
  23. * Author: Lyndon Chen
  24. *
  25. * Date: July 5, 2006
  26. *
  27. * Functions:
  28. *
  29. * Revision History:
  30. *
  31. */
  32. #include "device.h"
  33. #include "ioctl.h"
  34. #include "iocmd.h"
  35. #include "mac.h"
  36. #include "card.h"
  37. #include "hostap.h"
  38. #include "power.h"
  39. #include "rf.h"
  40. #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
  41. #include "iowpa.h"
  42. #include "wpactl.h"
  43. #endif
  44. #include <net/iw_handler.h>
  45. extern unsigned short TxRate_iwconfig;//2008-5-8 <add> by chester
  46. /*--------------------- Static Definitions -------------------------*/
  47. //2008-0409-07, <Add> by Einsn Liu
  48. #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
  49. #define SUPPORTED_WIRELESS_EXT 18
  50. #else
  51. #define SUPPORTED_WIRELESS_EXT 17
  52. #endif
  53. static const long frequency_list[] = {
  54. 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
  55. 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
  56. 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
  57. 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
  58. 5700, 5745, 5765, 5785, 5805, 5825
  59. };
  60. /*--------------------- Static Classes ----------------------------*/
  61. //static int msglevel =MSG_LEVEL_DEBUG;
  62. static int msglevel =MSG_LEVEL_INFO;
  63. /*--------------------- Static Variables --------------------------*/
  64. /*--------------------- Static Functions --------------------------*/
  65. /*--------------------- Export Variables --------------------------*/
  66. struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
  67. {
  68. PSDevice pDevice = netdev_priv(dev);
  69. long ldBm;
  70. pDevice->wstats.status = pDevice->eOPMode;
  71. #ifdef Calcu_LinkQual
  72. #if 0
  73. if(pDevice->byBBType == BB_TYPE_11B) {
  74. if(pDevice->byCurrSQ > 120)
  75. pDevice->scStatistic.LinkQuality = 100;
  76. else
  77. pDevice->scStatistic.LinkQuality = pDevice->byCurrSQ*100/120;
  78. }
  79. else if(pDevice->byBBType == BB_TYPE_11G) {
  80. if(pDevice->byCurrSQ < 20)
  81. pDevice->scStatistic.LinkQuality = 100;
  82. else if(pDevice->byCurrSQ >96)
  83. pDevice->scStatistic.LinkQuality = 0;
  84. else
  85. pDevice->scStatistic.LinkQuality = (96-pDevice->byCurrSQ)*100/76;
  86. }
  87. if(pDevice->bLinkPass !=true)
  88. pDevice->scStatistic.LinkQuality = 0;
  89. #endif
  90. if(pDevice->scStatistic.LinkQuality > 100)
  91. pDevice->scStatistic.LinkQuality = 100;
  92. pDevice->wstats.qual.qual =(unsigned char) pDevice->scStatistic.LinkQuality;
  93. #else
  94. pDevice->wstats.qual.qual = pDevice->byCurrSQ;
  95. #endif
  96. RFvRSSITodBm(pDevice, (unsigned char)(pDevice->uCurrRSSI), &ldBm);
  97. pDevice->wstats.qual.level = ldBm;
  98. //pDevice->wstats.qual.level = 0x100 - pDevice->uCurrRSSI;
  99. pDevice->wstats.qual.noise = 0;
  100. pDevice->wstats.qual.updated = 1;
  101. pDevice->wstats.discard.nwid = 0;
  102. pDevice->wstats.discard.code = 0;
  103. pDevice->wstats.discard.fragment = 0;
  104. pDevice->wstats.discard.retries = (unsigned long)pDevice->scStatistic.dwTsrErr;
  105. pDevice->wstats.discard.misc = 0;
  106. pDevice->wstats.miss.beacon = 0;
  107. return &pDevice->wstats;
  108. }
  109. /*------------------------------------------------------------------*/
  110. static int iwctl_commit(struct net_device *dev,
  111. struct iw_request_info *info,
  112. void *wrq,
  113. char *extra)
  114. {
  115. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWCOMMIT \n");
  116. return 0;
  117. }
  118. /*
  119. * Wireless Handler : get protocol name
  120. */
  121. int iwctl_giwname(struct net_device *dev,
  122. struct iw_request_info *info,
  123. char *wrq,
  124. char *extra)
  125. {
  126. strcpy(wrq, "802.11-a/b/g");
  127. return 0;
  128. }
  129. int iwctl_giwnwid(struct net_device *dev,
  130. struct iw_request_info *info,
  131. struct iw_param *wrq,
  132. char *extra)
  133. {
  134. //wrq->value = 0x100;
  135. //wrq->disabled = 0;
  136. //wrq->fixed = 1;
  137. //return 0;
  138. return -EOPNOTSUPP;
  139. }
  140. /*
  141. * Wireless Handler : set scan
  142. */
  143. int iwctl_siwscan(struct net_device *dev,
  144. struct iw_request_info *info,
  145. struct iw_point *wrq,
  146. char *extra)
  147. {
  148. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  149. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  150. struct iw_scan_req *req = (struct iw_scan_req *)extra;
  151. unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
  152. PWLAN_IE_SSID pItemSSID=NULL;
  153. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSCAN \n");
  154. if(pDevice->byReAssocCount > 0) { //reject scan when re-associating!
  155. //send scan event to wpa_Supplicant
  156. union iwreq_data wrqu;
  157. PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
  158. memset(&wrqu, 0, sizeof(wrqu));
  159. wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
  160. return 0;
  161. }
  162. spin_lock_irq(&pDevice->lock);
  163. BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
  164. //mike add: active scan OR passive scan OR desire_ssid scan
  165. if(wrq->length == sizeof(struct iw_scan_req)) {
  166. if (wrq->flags & IW_SCAN_THIS_ESSID) { //desire_ssid scan
  167. memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
  168. pItemSSID = (PWLAN_IE_SSID)abyScanSSID;
  169. pItemSSID->byElementID = WLAN_EID_SSID;
  170. memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len);
  171. if (pItemSSID->abySSID[req->essid_len - 1] == '\0') {
  172. if(req->essid_len>0)
  173. pItemSSID->len = req->essid_len - 1;
  174. }
  175. else
  176. pItemSSID->len = req->essid_len;
  177. pMgmt->eScanType = WMAC_SCAN_PASSIVE;
  178. PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID)abyScanSSID)->abySSID,
  179. ((PWLAN_IE_SSID)abyScanSSID)->len);
  180. bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
  181. spin_unlock_irq(&pDevice->lock);
  182. return 0;
  183. }
  184. else if(req->scan_type == IW_SCAN_TYPE_PASSIVE) { //passive scan
  185. pMgmt->eScanType = WMAC_SCAN_PASSIVE;
  186. }
  187. }
  188. else { //active scan
  189. pMgmt->eScanType = WMAC_SCAN_ACTIVE;
  190. }
  191. pMgmt->eScanType = WMAC_SCAN_PASSIVE;
  192. //printk("SIOCSIWSCAN:WLAN_CMD_BSSID_SCAN\n");
  193. bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
  194. spin_unlock_irq(&pDevice->lock);
  195. return 0;
  196. }
  197. /*
  198. * Wireless Handler : get scan results
  199. */
  200. int iwctl_giwscan(struct net_device *dev,
  201. struct iw_request_info *info,
  202. struct iw_point *wrq,
  203. char *extra)
  204. {
  205. int ii, jj, kk;
  206. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  207. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  208. PKnownBSS pBSS;
  209. PWLAN_IE_SSID pItemSSID;
  210. PWLAN_IE_SUPP_RATES pSuppRates, pExtSuppRates;
  211. char *current_ev = extra;
  212. char *end_buf = extra + IW_SCAN_MAX_DATA;
  213. char *current_val = NULL;
  214. struct iw_event iwe;
  215. long ldBm;
  216. char buf[MAX_WPA_IE_LEN * 2 + 30];
  217. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSCAN \n");
  218. if (pMgmt->eScanState == WMAC_IS_SCANNING) {
  219. // In scanning..
  220. return -EAGAIN;
  221. }
  222. pBSS = &(pMgmt->sBSSList[0]);
  223. for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
  224. if (current_ev >= end_buf)
  225. break;
  226. pBSS = &(pMgmt->sBSSList[jj]);
  227. if (pBSS->bActive) {
  228. //ADD mac address
  229. memset(&iwe, 0, sizeof(iwe));
  230. iwe.cmd = SIOCGIWAP;
  231. iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
  232. memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN);
  233. current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
  234. //ADD ssid
  235. memset(&iwe, 0, sizeof(iwe));
  236. iwe.cmd = SIOCGIWESSID;
  237. pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
  238. iwe.u.data.length = pItemSSID->len;
  239. iwe.u.data.flags = 1;
  240. current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
  241. //ADD mode
  242. memset(&iwe, 0, sizeof(iwe));
  243. iwe.cmd = SIOCGIWMODE;
  244. if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
  245. iwe.u.mode = IW_MODE_INFRA;
  246. }
  247. else {
  248. iwe.u.mode = IW_MODE_ADHOC;
  249. }
  250. iwe.len = IW_EV_UINT_LEN;
  251. current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
  252. //ADD frequency
  253. pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates;
  254. pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates;
  255. memset(&iwe, 0, sizeof(iwe));
  256. iwe.cmd = SIOCGIWFREQ;
  257. iwe.u.freq.m = pBSS->uChannel;
  258. iwe.u.freq.e = 0;
  259. iwe.u.freq.i = 0;
  260. current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
  261. //2008-0409-04, <Add> by Einsn Liu
  262. {
  263. int f = (int)pBSS->uChannel - 1;
  264. if(f < 0)f = 0;
  265. iwe.u.freq.m = frequency_list[f] * 100000;
  266. iwe.u.freq.e = 1;
  267. }
  268. current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
  269. //ADD quality
  270. memset(&iwe, 0, sizeof(iwe));
  271. iwe.cmd = IWEVQUAL;
  272. RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm);
  273. iwe.u.qual.level = ldBm;
  274. iwe.u.qual.noise = 0;
  275. //2008-0409-01, <Add> by Einsn Liu
  276. if(-ldBm<50){
  277. iwe.u.qual.qual = 100;
  278. }else if(-ldBm > 90) {
  279. iwe.u.qual.qual = 0;
  280. }else {
  281. iwe.u.qual.qual=(40-(-ldBm-50))*100/40;
  282. }
  283. iwe.u.qual.updated=7;
  284. // iwe.u.qual.qual = 0;
  285. current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
  286. memset(&iwe, 0, sizeof(iwe));
  287. iwe.cmd = SIOCGIWENCODE;
  288. iwe.u.data.length = 0;
  289. if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
  290. iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
  291. }else {
  292. iwe.u.data.flags = IW_ENCODE_DISABLED;
  293. }
  294. current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
  295. memset(&iwe, 0, sizeof(iwe));
  296. iwe.cmd = SIOCGIWRATE;
  297. iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
  298. current_val = current_ev + IW_EV_LCP_LEN;
  299. for (kk = 0 ; kk < 12 ; kk++) {
  300. if (pSuppRates->abyRates[kk] == 0)
  301. break;
  302. // Bit rate given in 500 kb/s units (+ 0x80)
  303. iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000);
  304. current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
  305. }
  306. for (kk = 0 ; kk < 8 ; kk++) {
  307. if (pExtSuppRates->abyRates[kk] == 0)
  308. break;
  309. // Bit rate given in 500 kb/s units (+ 0x80)
  310. iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000);
  311. current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
  312. }
  313. if((current_val - current_ev) > IW_EV_LCP_LEN)
  314. current_ev = current_val;
  315. memset(&iwe, 0, sizeof(iwe));
  316. iwe.cmd = IWEVCUSTOM;
  317. sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval);
  318. iwe.u.data.length = strlen(buf);
  319. current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
  320. if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
  321. memset(&iwe, 0, sizeof(iwe));
  322. iwe.cmd = IWEVGENIE;
  323. iwe.u.data.length = pBSS->wWPALen;
  324. current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byWPAIE);
  325. }
  326. if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
  327. memset(&iwe, 0, sizeof(iwe));
  328. iwe.cmd = IWEVGENIE;
  329. iwe.u.data.length = pBSS->wRSNLen;
  330. current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byRSNIE);
  331. }
  332. }
  333. }// for
  334. wrq->length = current_ev - extra;
  335. return 0;
  336. }
  337. /*
  338. * Wireless Handler : set frequence or channel
  339. */
  340. int iwctl_siwfreq(struct net_device *dev,
  341. struct iw_request_info *info,
  342. struct iw_freq *wrq,
  343. char *extra)
  344. {
  345. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  346. int rc = 0;
  347. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFREQ \n");
  348. // If setting by frequency, convert to a channel
  349. if((wrq->e == 1) &&
  350. (wrq->m >= (int) 2.412e8) &&
  351. (wrq->m <= (int) 2.487e8)) {
  352. int f = wrq->m / 100000;
  353. int c = 0;
  354. while((c < 14) && (f != frequency_list[c]))
  355. c++;
  356. wrq->e = 0;
  357. wrq->m = c + 1;
  358. }
  359. // Setting by channel number
  360. if((wrq->m > 14) || (wrq->e > 0))
  361. rc = -EOPNOTSUPP;
  362. else {
  363. int channel = wrq->m;
  364. if((channel < 1) || (channel > 14)) {
  365. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: New channel value of %d is invalid!\n", dev->name, wrq->m);
  366. rc = -EINVAL;
  367. } else {
  368. // Yes ! We can set it !!!
  369. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set to channel = %d\n", channel);
  370. pDevice->uChannel = channel;
  371. //2007-0207-04,<Add> by EinsnLiu
  372. //Make change effect at once
  373. pDevice->bCommit = true;
  374. }
  375. }
  376. return rc;
  377. }
  378. /*
  379. * Wireless Handler : get frequence or channel
  380. */
  381. int iwctl_giwfreq(struct net_device *dev,
  382. struct iw_request_info *info,
  383. struct iw_freq *wrq,
  384. char *extra)
  385. {
  386. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  387. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  388. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ \n");
  389. #ifdef WEXT_USECHANNELS
  390. wrq->m = (int)pMgmt->uCurrChannel;
  391. wrq->e = 0;
  392. #else
  393. {
  394. int f = (int)pMgmt->uCurrChannel - 1;
  395. if(f < 0)
  396. f = 0;
  397. wrq->m = frequency_list[f] * 100000;
  398. wrq->e = 1;
  399. }
  400. #endif
  401. return 0;
  402. }
  403. /*
  404. * Wireless Handler : set operation mode
  405. */
  406. int iwctl_siwmode(struct net_device *dev,
  407. struct iw_request_info *info,
  408. __u32 *wmode,
  409. char *extra)
  410. {
  411. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  412. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  413. int rc = 0;
  414. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE \n");
  415. if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) {
  416. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Can't set operation mode, hostapd is running \n");
  417. return rc;
  418. }
  419. switch(*wmode) {
  420. case IW_MODE_ADHOC:
  421. if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) {
  422. pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
  423. if (pDevice->flags & DEVICE_FLAGS_OPENED) {
  424. pDevice->bCommit = true;
  425. }
  426. }
  427. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n");
  428. break;
  429. case IW_MODE_AUTO:
  430. case IW_MODE_INFRA:
  431. if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) {
  432. pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
  433. if (pDevice->flags & DEVICE_FLAGS_OPENED) {
  434. pDevice->bCommit = true;
  435. }
  436. }
  437. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n");
  438. break;
  439. case IW_MODE_MASTER:
  440. pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
  441. rc = -EOPNOTSUPP;
  442. break;
  443. if (pMgmt->eConfigMode != WMAC_CONFIG_AP) {
  444. pMgmt->eConfigMode = WMAC_CONFIG_AP;
  445. if (pDevice->flags & DEVICE_FLAGS_OPENED) {
  446. pDevice->bCommit = true;
  447. }
  448. }
  449. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n");
  450. break;
  451. case IW_MODE_REPEAT:
  452. pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
  453. rc = -EOPNOTSUPP;
  454. break;
  455. default:
  456. rc = -EINVAL;
  457. }
  458. return rc;
  459. }
  460. /*
  461. * Wireless Handler : get operation mode
  462. */
  463. int iwctl_giwmode(struct net_device *dev,
  464. struct iw_request_info *info,
  465. __u32 *wmode,
  466. char *extra)
  467. {
  468. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  469. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  470. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE \n");
  471. // If not managed, assume it's ad-hoc
  472. switch (pMgmt->eConfigMode) {
  473. case WMAC_CONFIG_ESS_STA:
  474. *wmode = IW_MODE_INFRA;
  475. break;
  476. case WMAC_CONFIG_IBSS_STA:
  477. *wmode = IW_MODE_ADHOC;
  478. break;
  479. case WMAC_CONFIG_AUTO:
  480. *wmode = IW_MODE_INFRA;
  481. break;
  482. case WMAC_CONFIG_AP:
  483. *wmode = IW_MODE_MASTER;
  484. break;
  485. default:
  486. *wmode = IW_MODE_ADHOC;
  487. }
  488. return 0;
  489. }
  490. /*
  491. * Wireless Handler : get capability range
  492. */
  493. int iwctl_giwrange(struct net_device *dev,
  494. struct iw_request_info *info,
  495. struct iw_point *wrq,
  496. char *extra)
  497. {
  498. struct iw_range *range = (struct iw_range *) extra;
  499. int i,k;
  500. unsigned char abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
  501. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRANGE \n");
  502. if (wrq->pointer) {
  503. wrq->length = sizeof(struct iw_range);
  504. memset(range, 0, sizeof(struct iw_range));
  505. range->min_nwid = 0x0000;
  506. range->max_nwid = 0x0000;
  507. range->num_channels = 14;
  508. // Should be based on cap_rid.country to give only
  509. // what the current card support
  510. k = 0;
  511. for(i = 0; i < 14; i++) {
  512. range->freq[k].i = i + 1; // List index
  513. range->freq[k].m = frequency_list[i] * 100000;
  514. range->freq[k++].e = 1; // Values in table in MHz -> * 10^5 * 10
  515. }
  516. range->num_frequency = k;
  517. // Hum... Should put the right values there
  518. #ifdef Calcu_LinkQual
  519. range->max_qual.qual = 100;
  520. #else
  521. range->max_qual.qual = 255;
  522. #endif
  523. range->max_qual.level = 0;
  524. range->max_qual.noise = 0;
  525. range->sensitivity = 255;
  526. for(i = 0 ; i < 13 ; i++) {
  527. range->bitrate[i] = abySupportedRates[i] * 500000;
  528. if(range->bitrate[i] == 0)
  529. break;
  530. }
  531. range->num_bitrates = i;
  532. // Set an indication of the max TCP throughput
  533. // in bit/s that we can expect using this interface.
  534. // May be use for QoS stuff... Jean II
  535. if(i > 2)
  536. range->throughput = 5 * 1000 * 1000;
  537. else
  538. range->throughput = 1.5 * 1000 * 1000;
  539. range->min_rts = 0;
  540. range->max_rts = 2312;
  541. range->min_frag = 256;
  542. range->max_frag = 2312;
  543. // the encoding capabilities
  544. range->num_encoding_sizes = 3;
  545. // 64(40) bits WEP
  546. range->encoding_size[0] = 5;
  547. // 128(104) bits WEP
  548. range->encoding_size[1] = 13;
  549. // 256 bits for WPA-PSK
  550. range->encoding_size[2] = 32;
  551. // 4 keys are allowed
  552. range->max_encoding_tokens = 4;
  553. range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
  554. IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
  555. range->min_pmp = 0;
  556. range->max_pmp = 1000000;// 1 secs
  557. range->min_pmt = 0;
  558. range->max_pmt = 1000000;// 1 secs
  559. range->pmp_flags = IW_POWER_PERIOD;
  560. range->pmt_flags = IW_POWER_TIMEOUT;
  561. range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
  562. // Transmit Power - values are in mW
  563. range->txpower[0] = 100;
  564. range->num_txpower = 1;
  565. range->txpower_capa = IW_TXPOW_MWATT;
  566. range->we_version_source = SUPPORTED_WIRELESS_EXT;
  567. range->we_version_compiled = WIRELESS_EXT;
  568. range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
  569. range->retry_flags = IW_RETRY_LIMIT;
  570. range->r_time_flags = IW_RETRY_LIFETIME;
  571. range->min_retry = 1;
  572. range->max_retry = 65535;
  573. range->min_r_time = 1024;
  574. range->max_r_time = 65535 * 1024;
  575. // Experimental measurements - boundary 11/5.5 Mb/s
  576. // Note : with or without the (local->rssi), results
  577. // are somewhat different. - Jean II
  578. range->avg_qual.qual = 6;
  579. range->avg_qual.level = 176; // -80 dBm
  580. range->avg_qual.noise = 0;
  581. }
  582. return 0;
  583. }
  584. /*
  585. * Wireless Handler : set ap mac address
  586. */
  587. int iwctl_siwap(struct net_device *dev,
  588. struct iw_request_info *info,
  589. struct sockaddr *wrq,
  590. char *extra)
  591. {
  592. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  593. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  594. int rc = 0;
  595. unsigned char ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00};
  596. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAP \n");
  597. if (pMgmt->eScanState == WMAC_IS_SCANNING) {
  598. // In scanning..
  599. printk("SIOCSIWAP(??)-->In scanning...\n");
  600. // return -EAGAIN;
  601. }
  602. if (wrq->sa_family != ARPHRD_ETHER)
  603. rc = -EINVAL;
  604. else {
  605. memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6);
  606. //2008-0409-05, <Add> by Einsn Liu
  607. if((pDevice->bLinkPass == true) &&
  608. (memcmp(pMgmt->abyDesireBSSID, pMgmt->abyCurrBSSID, 6)== 0)){
  609. return rc;
  610. }
  611. //mike :add
  612. if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) ||
  613. (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)){
  614. PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
  615. return rc;
  616. }
  617. //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
  618. // then ignore,because you don't known which one to be connect with??
  619. {
  620. unsigned int ii , uSameBssidNum=0;
  621. for (ii = 0; ii < MAX_BSS_NUM; ii++) {
  622. if (pMgmt->sBSSList[ii].bActive &&
  623. !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID, pMgmt->abyDesireBSSID)) {
  624. uSameBssidNum++;
  625. }
  626. }
  627. if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
  628. PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n");
  629. return rc;
  630. }
  631. }
  632. if (pDevice->flags & DEVICE_FLAGS_OPENED) {
  633. pDevice->bCommit = true;
  634. }
  635. }
  636. return rc;
  637. }
  638. /*
  639. * Wireless Handler : get ap mac address
  640. */
  641. int iwctl_giwap(struct net_device *dev,
  642. struct iw_request_info *info,
  643. struct sockaddr *wrq,
  644. char *extra)
  645. {
  646. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  647. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  648. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP \n");
  649. memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
  650. //2008-0410,<Modify> by Einsn Liu
  651. if ((pDevice->bLinkPass == false) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP))
  652. memset(wrq->sa_data, 0, 6);
  653. if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
  654. memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
  655. }
  656. wrq->sa_family = ARPHRD_ETHER;
  657. return 0;
  658. }
  659. /*
  660. * Wireless Handler : get ap list
  661. */
  662. int iwctl_giwaplist(struct net_device *dev,
  663. struct iw_request_info *info,
  664. struct iw_point *wrq,
  665. char *extra)
  666. {
  667. int ii,jj, rc = 0;
  668. struct sockaddr sock[IW_MAX_AP];
  669. struct iw_quality qual[IW_MAX_AP];
  670. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  671. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  672. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n");
  673. // Only super-user can see AP list
  674. if (!capable(CAP_NET_ADMIN)) {
  675. rc = -EPERM;
  676. return rc;
  677. }
  678. if (wrq->pointer) {
  679. PKnownBSS pBSS = &(pMgmt->sBSSList[0]);
  680. for (ii = 0, jj= 0; ii < MAX_BSS_NUM; ii++) {
  681. pBSS = &(pMgmt->sBSSList[ii]);
  682. if (!pBSS->bActive)
  683. continue;
  684. if ( jj >= IW_MAX_AP)
  685. break;
  686. memcpy(sock[jj].sa_data, pBSS->abyBSSID, 6);
  687. sock[jj].sa_family = ARPHRD_ETHER;
  688. qual[jj].level = pBSS->uRSSI;
  689. qual[jj].qual = qual[jj].noise = 0;
  690. qual[jj].updated = 2;
  691. jj++;
  692. }
  693. wrq->flags = 1; // Should be define'd
  694. wrq->length = jj;
  695. memcpy(extra, sock, sizeof(struct sockaddr)*jj);
  696. memcpy(extra + sizeof(struct sockaddr)*jj, qual, sizeof(struct iw_quality)*jj);
  697. }
  698. return rc;
  699. }
  700. /*
  701. * Wireless Handler : set essid
  702. */
  703. int iwctl_siwessid(struct net_device *dev,
  704. struct iw_request_info *info,
  705. struct iw_point *wrq,
  706. char *extra)
  707. {
  708. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  709. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  710. PWLAN_IE_SSID pItemSSID;
  711. //2008-0409-05, <Add> by Einsn Liu
  712. unsigned char len;
  713. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID \n");
  714. pDevice->fWPA_Authened = false;
  715. if (pMgmt->eScanState == WMAC_IS_SCANNING) {
  716. // In scanning..
  717. printk("SIOCSIWESSID(??)-->In scanning...\n");
  718. // return -EAGAIN;
  719. }
  720. // Check if we asked for `any'
  721. if(wrq->flags == 0) {
  722. // Just send an empty SSID list
  723. memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
  724. memset(pMgmt->abyDesireBSSID, 0xFF,6);
  725. PRINT_K("set essid to 'any' \n");
  726. #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
  727. //Unknown desired AP,so here need not associate??
  728. //if(pDevice->bWPASuppWextEnabled == true) {
  729. return 0;
  730. // }
  731. #endif
  732. } else {
  733. // Set the SSID
  734. memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
  735. pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
  736. pItemSSID->byElementID = WLAN_EID_SSID;
  737. memcpy(pItemSSID->abySSID, extra, wrq->length);
  738. if (pItemSSID->abySSID[wrq->length - 1] == '\0') {
  739. if(wrq->length>0)
  740. pItemSSID->len = wrq->length - 1;
  741. }
  742. else
  743. pItemSSID->len = wrq->length;
  744. printk("set essid to %s \n",pItemSSID->abySSID);
  745. //2008-0409-05, <Add> by Einsn Liu
  746. len=(pItemSSID->len > ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len)?pItemSSID->len:((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len;
  747. if((pDevice->bLinkPass == true) &&
  748. (memcmp(pItemSSID->abySSID,((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID,len)==0))
  749. return 0;
  750. //mike:need clear desiredBSSID
  751. if(pItemSSID->len==0) {
  752. memset(pMgmt->abyDesireBSSID, 0xFF,6);
  753. return 0;
  754. }
  755. #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
  756. //Wext wil order another command of siwap to link with desired AP,
  757. //so here need not associate??
  758. if(pDevice->bWPASuppWextEnabled == true) {
  759. /*******search if in hidden ssid mode ****/
  760. {
  761. PKnownBSS pCurr = NULL;
  762. unsigned char abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
  763. unsigned int ii , uSameBssidNum=0;
  764. memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID));
  765. pCurr = BSSpSearchBSSList(pDevice,
  766. NULL,
  767. abyTmpDesireSSID,
  768. pMgmt->eConfigPHYMode
  769. );
  770. if (pCurr == NULL){
  771. PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
  772. vResetCommandTimer((void *) pDevice);
  773. pMgmt->eScanType = WMAC_SCAN_ACTIVE;
  774. bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
  775. bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
  776. }
  777. else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
  778. // by means of judging if there are two same BSSID exist in list ?
  779. for (ii = 0; ii < MAX_BSS_NUM; ii++) {
  780. if (pMgmt->sBSSList[ii].bActive &&
  781. !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) {
  782. uSameBssidNum++;
  783. }
  784. }
  785. if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
  786. printk("SIOCSIWESSID:hidden ssid directly associate.......\n");
  787. vResetCommandTimer((void *) pDevice);
  788. pMgmt->eScanType = WMAC_SCAN_PASSIVE; //this scan type,you'll submit scan result!
  789. bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
  790. bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
  791. }
  792. }
  793. }
  794. return 0;
  795. }
  796. #endif
  797. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID);
  798. }
  799. if (pDevice->flags & DEVICE_FLAGS_OPENED) {
  800. pDevice->bCommit = true;
  801. }
  802. return 0;
  803. }
  804. /*
  805. * Wireless Handler : get essid
  806. */
  807. int iwctl_giwessid(struct net_device *dev,
  808. struct iw_request_info *info,
  809. struct iw_point *wrq,
  810. char *extra)
  811. {
  812. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  813. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  814. PWLAN_IE_SSID pItemSSID;
  815. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n");
  816. // Note : if wrq->u.data.flags != 0, we should
  817. // get the relevant SSID from the SSID list...
  818. // Get the current SSID
  819. pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
  820. //pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
  821. memcpy(extra, pItemSSID->abySSID , pItemSSID->len);
  822. extra[pItemSSID->len] = '\0';
  823. wrq->length = pItemSSID->len + 1;
  824. //2008-0409-03, <Add> by Einsn Liu
  825. wrq->length = pItemSSID->len;
  826. wrq->flags = 1; // active
  827. return 0;
  828. }
  829. /*
  830. * Wireless Handler : set data rate
  831. */
  832. int iwctl_siwrate(struct net_device *dev,
  833. struct iw_request_info *info,
  834. struct iw_param *wrq,
  835. char *extra)
  836. {
  837. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  838. int rc = 0;
  839. u8 brate = 0;
  840. int i;
  841. unsigned char abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
  842. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE \n");
  843. if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
  844. rc = -EINVAL;
  845. return rc;
  846. }
  847. // First : get a valid bit rate value
  848. // Which type of value
  849. if((wrq->value < 13) &&
  850. (wrq->value >= 0)) {
  851. // Setting by rate index
  852. // Find value in the magic rate table
  853. brate = wrq->value;
  854. } else {
  855. // Setting by frequency value
  856. u8 normvalue = (u8) (wrq->value/500000);
  857. // Check if rate is valid
  858. for(i = 0 ; i < 13 ; i++) {
  859. if(normvalue == abySupportedRates[i]) {
  860. brate = i;
  861. break;
  862. }
  863. }
  864. }
  865. // -1 designed the max rate (mostly auto mode)
  866. if(wrq->value == -1) {
  867. // Get the highest available rate
  868. for(i = 0 ; i < 13 ; i++) {
  869. if(abySupportedRates[i] == 0)
  870. break;
  871. }
  872. if(i != 0)
  873. brate = i - 1;
  874. }
  875. // Check that it is valid
  876. // brate is index of abySupportedRates[]
  877. if(brate > 13 ) {
  878. rc = -EINVAL;
  879. return rc;
  880. }
  881. // Now, check if we want a fixed or auto value
  882. if(wrq->fixed != 0) {
  883. // Fixed mode
  884. // One rate, fixed
  885. printk("Rate Fix\n");
  886. pDevice->bFixRate = true;
  887. if ((pDevice->byBBType == BB_TYPE_11B)&& (brate > 3)) {
  888. pDevice->uConnectionRate = 3;
  889. }
  890. else {
  891. pDevice->uConnectionRate = brate;
  892. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate);
  893. }
  894. }
  895. else {
  896. pDevice->bFixRate = false;
  897. pDevice->uConnectionRate = 13;
  898. printk("auto rate:connection_rate is 13\n");
  899. }
  900. return rc;
  901. }
  902. /*
  903. * Wireless Handler : get data rate
  904. */
  905. int iwctl_giwrate(struct net_device *dev,
  906. struct iw_request_info *info,
  907. struct iw_param *wrq,
  908. char *extra)
  909. {
  910. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  911. //2007-0118-05,<Mark> by EinsnLiu
  912. //Mark the unnecessary sentences.
  913. // PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  914. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE \n");
  915. {
  916. unsigned char abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
  917. int brate = 0;
  918. //2008-5-8 <modify> by chester
  919. if(pDevice->bLinkPass){
  920. if(pDevice->bFixRate == true){
  921. if (pDevice->uConnectionRate < 13) {
  922. brate = abySupportedRates[pDevice->uConnectionRate];
  923. }else {
  924. if (pDevice->byBBType == BB_TYPE_11B)
  925. brate = 0x16;
  926. if (pDevice->byBBType == BB_TYPE_11G)
  927. brate = 0x6C;
  928. if (pDevice->byBBType == BB_TYPE_11A)
  929. brate = 0x6C;
  930. }
  931. }
  932. else
  933. {
  934. brate = abySupportedRates[TxRate_iwconfig];
  935. }
  936. }
  937. else brate =0;
  938. //2007-0118-05,<Mark> by EinsnLiu
  939. //Mark the unnecessary sentences.
  940. /*
  941. if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
  942. if (pDevice->byBBType == BB_TYPE_11B)
  943. brate = 0x16;
  944. if (pDevice->byBBType == BB_TYPE_11G)
  945. brate = 0x6C;
  946. if (pDevice->byBBType == BB_TYPE_11A)
  947. brate = 0x6C;
  948. }
  949. */
  950. // if (pDevice->uConnectionRate == 13)
  951. // brate = abySupportedRates[pDevice->wCurrentRate];
  952. wrq->value = brate * 500000;
  953. // If more than one rate, set auto
  954. if (pDevice->bFixRate == true)
  955. wrq->fixed = true;
  956. }
  957. return 0;
  958. }
  959. /*
  960. * Wireless Handler : set rts threshold
  961. */
  962. int iwctl_siwrts(struct net_device *dev,
  963. struct iw_request_info *info,
  964. struct iw_param *wrq,
  965. char *extra)
  966. {
  967. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  968. int rc = 0;
  969. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRTS \n");
  970. {
  971. int rthr = wrq->value;
  972. if(wrq->disabled)
  973. rthr = 2312;
  974. if((rthr < 0) || (rthr > 2312)) {
  975. rc = -EINVAL;
  976. }else {
  977. pDevice->wRTSThreshold = rthr;
  978. }
  979. }
  980. return 0;
  981. }
  982. /*
  983. * Wireless Handler : get rts
  984. */
  985. int iwctl_giwrts(struct net_device *dev,
  986. struct iw_request_info *info,
  987. struct iw_param *wrq,
  988. char *extra)
  989. {
  990. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  991. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS \n");
  992. wrq->value = pDevice->wRTSThreshold;
  993. wrq->disabled = (wrq->value >= 2312);
  994. wrq->fixed = 1;
  995. return 0;
  996. }
  997. /*
  998. * Wireless Handler : set fragment threshold
  999. */
  1000. int iwctl_siwfrag(struct net_device *dev,
  1001. struct iw_request_info *info,
  1002. struct iw_param *wrq,
  1003. char *extra)
  1004. {
  1005. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1006. int rc = 0;
  1007. int fthr = wrq->value;
  1008. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG \n");
  1009. if (wrq->disabled)
  1010. fthr = 2312;
  1011. if((fthr < 256) || (fthr > 2312)) {
  1012. rc = -EINVAL;
  1013. }else {
  1014. fthr &= ~0x1; // Get an even value
  1015. pDevice->wFragmentationThreshold = (u16)fthr;
  1016. }
  1017. return rc;
  1018. }
  1019. /*
  1020. * Wireless Handler : get fragment threshold
  1021. */
  1022. int iwctl_giwfrag(struct net_device *dev,
  1023. struct iw_request_info *info,
  1024. struct iw_param *wrq,
  1025. char *extra)
  1026. {
  1027. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1028. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG \n");
  1029. wrq->value = pDevice->wFragmentationThreshold;
  1030. wrq->disabled = (wrq->value >= 2312);
  1031. wrq->fixed = 1;
  1032. return 0;
  1033. }
  1034. /*
  1035. * Wireless Handler : set retry threshold
  1036. */
  1037. int iwctl_siwretry(struct net_device *dev,
  1038. struct iw_request_info *info,
  1039. struct iw_param *wrq,
  1040. char *extra)
  1041. {
  1042. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1043. int rc = 0;
  1044. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY \n");
  1045. if (wrq->disabled) {
  1046. rc = -EINVAL;
  1047. return rc;
  1048. }
  1049. if (wrq->flags & IW_RETRY_LIMIT) {
  1050. if(wrq->flags & IW_RETRY_MAX)
  1051. pDevice->byLongRetryLimit = wrq->value;
  1052. else if (wrq->flags & IW_RETRY_MIN)
  1053. pDevice->byShortRetryLimit = wrq->value;
  1054. else {
  1055. // No modifier : set both
  1056. pDevice->byShortRetryLimit = wrq->value;
  1057. pDevice->byLongRetryLimit = wrq->value;
  1058. }
  1059. }
  1060. if (wrq->flags & IW_RETRY_LIFETIME) {
  1061. pDevice->wMaxTransmitMSDULifetime = wrq->value;
  1062. }
  1063. return rc;
  1064. }
  1065. /*
  1066. * Wireless Handler : get retry threshold
  1067. */
  1068. int iwctl_giwretry(struct net_device *dev,
  1069. struct iw_request_info *info,
  1070. struct iw_param *wrq,
  1071. char *extra)
  1072. {
  1073. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1074. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY \n");
  1075. wrq->disabled = 0; // Can't be disabled
  1076. // Note : by default, display the min retry number
  1077. if((wrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
  1078. wrq->flags = IW_RETRY_LIFETIME;
  1079. wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; //ms
  1080. } else if((wrq->flags & IW_RETRY_MAX)) {
  1081. wrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
  1082. wrq->value = (int)pDevice->byLongRetryLimit;
  1083. } else {
  1084. wrq->flags = IW_RETRY_LIMIT;
  1085. wrq->value = (int)pDevice->byShortRetryLimit;
  1086. if((int)pDevice->byShortRetryLimit != (int)pDevice->byLongRetryLimit)
  1087. wrq->flags |= IW_RETRY_MIN;
  1088. }
  1089. return 0;
  1090. }
  1091. /*
  1092. * Wireless Handler : set encode mode
  1093. */
  1094. int iwctl_siwencode(struct net_device *dev,
  1095. struct iw_request_info *info,
  1096. struct iw_point *wrq,
  1097. char *extra)
  1098. {
  1099. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1100. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  1101. unsigned long dwKeyIndex = (unsigned long)(wrq->flags & IW_ENCODE_INDEX);
  1102. int ii,uu, rc = 0;
  1103. int index = (wrq->flags & IW_ENCODE_INDEX);
  1104. //2007-0207-07,<Modify> by EinsnLiu
  1105. //There are some problems when using iwconfig encode/key command to set the WEP key.
  1106. //I almost rewrite this function.
  1107. //now it support:(assume the wireless interface's name is eth0)
  1108. //iwconfig eth0 key [1] 1122334455 open /*set key stirng to index 1,and driver using key index is set to 1*/
  1109. //iwconfig eth0 key [3] /*set driver using key index to 3,the key string no change */
  1110. //iwconfig eth0 key 1122334455 /*set key string to driver using index*/
  1111. //iwconfig eth0 key restricted /*enable share key*/
  1112. PSKeyTable pkeytab;
  1113. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
  1114. if((wrq->flags & IW_ENCODE_DISABLED)==0){
  1115. //Not disable encryption
  1116. if (dwKeyIndex > WLAN_WEP_NKEYS) {
  1117. rc = -EINVAL;
  1118. return rc;
  1119. }
  1120. if(dwKeyIndex<1&&((wrq->flags&IW_ENCODE_NOKEY)==0)){//set default key
  1121. if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
  1122. dwKeyIndex=pDevice->byKeyIndex;
  1123. }
  1124. else dwKeyIndex=0;
  1125. }else dwKeyIndex--;
  1126. // Check the size of the key
  1127. if (wrq->length > WLAN_WEP232_KEYLEN) {
  1128. rc = -EINVAL;
  1129. return rc;
  1130. }
  1131. if(wrq->length>0){//have key
  1132. if (wrq->length == WLAN_WEP232_KEYLEN) {
  1133. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
  1134. }
  1135. else if (wrq->length == WLAN_WEP104_KEYLEN) {
  1136. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
  1137. }
  1138. else if (wrq->length == WLAN_WEP40_KEYLEN) {
  1139. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
  1140. }else {//no support length
  1141. rc = -EINVAL;
  1142. return rc;
  1143. }
  1144. memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
  1145. memcpy(pDevice->abyKey, extra, wrq->length);
  1146. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
  1147. for (ii = 0; ii < wrq->length; ii++) {
  1148. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
  1149. }
  1150. if (pDevice->flags & DEVICE_FLAGS_OPENED) {
  1151. spin_lock_irq(&pDevice->lock);
  1152. KeybSetDefaultKey(&(pDevice->sKey),
  1153. (unsigned long)(dwKeyIndex | (1 << 31)),
  1154. wrq->length,
  1155. NULL,
  1156. pDevice->abyKey,
  1157. KEY_CTL_WEP,
  1158. pDevice->PortOffset,
  1159. pDevice->byLocalID
  1160. );
  1161. spin_unlock_irq(&pDevice->lock);
  1162. }
  1163. pDevice->byKeyIndex = (unsigned char)dwKeyIndex;
  1164. pDevice->uKeyLength = wrq->length;
  1165. pDevice->bTransmitKey = true;
  1166. pDevice->bEncryptionEnable = true;
  1167. pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
  1168. }else if(index>0){
  1169. //when the length is 0 the request only changes the default transmit key index
  1170. //check the new key has a non zero lenget
  1171. if(pDevice->bEncryptionEnable==false)
  1172. {
  1173. rc = -EINVAL;
  1174. return rc;
  1175. }
  1176. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Just set Default key Index:\n");
  1177. pkeytab=&(pDevice->sKey.KeyTable[MAX_KEY_TABLE-1]);
  1178. if(pkeytab->GroupKey[(unsigned char)dwKeyIndex].uKeyLength==0){
  1179. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Default key len is 0\n");
  1180. rc = -EINVAL;
  1181. return rc;
  1182. }
  1183. pDevice->byKeyIndex =(unsigned char)dwKeyIndex;
  1184. pkeytab->dwGTKeyIndex =dwKeyIndex | (1 << 31);
  1185. pkeytab->GroupKey[(unsigned char)dwKeyIndex].dwKeyIndex=dwKeyIndex | (1 << 31);
  1186. }
  1187. }else {//disable the key
  1188. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
  1189. if(pDevice->bEncryptionEnable==false)
  1190. return 0;
  1191. pMgmt->bShareKeyAlgorithm = false;
  1192. pDevice->bEncryptionEnable = false;
  1193. pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
  1194. if (pDevice->flags & DEVICE_FLAGS_OPENED) {
  1195. spin_lock_irq(&pDevice->lock);
  1196. for(uu=0;uu<MAX_KEY_TABLE;uu++)
  1197. MACvDisableKeyEntry(pDevice->PortOffset, uu);
  1198. spin_unlock_irq(&pDevice->lock);
  1199. }
  1200. }
  1201. //End Modify,Einsn
  1202. /*
  1203. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
  1204. // Check the size of the key
  1205. if (wrq->length > WLAN_WEP232_KEYLEN) {
  1206. rc = -EINVAL;
  1207. return rc;
  1208. }
  1209. if (dwKeyIndex > WLAN_WEP_NKEYS) {
  1210. rc = -EINVAL;
  1211. return rc;
  1212. }
  1213. if (dwKeyIndex > 0)
  1214. dwKeyIndex--;
  1215. // Send the key to the card
  1216. if (wrq->length > 0) {
  1217. if (wrq->length == WLAN_WEP232_KEYLEN) {
  1218. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
  1219. }
  1220. else if (wrq->length == WLAN_WEP104_KEYLEN) {
  1221. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
  1222. }
  1223. else if (wrq->length == WLAN_WEP40_KEYLEN) {
  1224. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
  1225. }
  1226. memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
  1227. memcpy(pDevice->abyKey, extra, wrq->length);
  1228. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
  1229. for (ii = 0; ii < wrq->length; ii++) {
  1230. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
  1231. }
  1232. if (pDevice->flags & DEVICE_FLAGS_OPENED) {
  1233. spin_lock_irq(&pDevice->lock);
  1234. KeybSetDefaultKey(&(pDevice->sKey),
  1235. (unsigned long)(pDevice->byKeyIndex | (1 << 31)),
  1236. pDevice->uKeyLength,
  1237. NULL,
  1238. pDevice->abyKey,
  1239. KEY_CTL_WEP,
  1240. pDevice->PortOffset,
  1241. pDevice->byLocalID
  1242. );
  1243. spin_unlock_irq(&pDevice->lock);
  1244. }
  1245. pDevice->byKeyIndex = (unsigned char)dwKeyIndex;
  1246. pDevice->uKeyLength = wrq->length;
  1247. pDevice->bTransmitKey = true;
  1248. pDevice->bEncryptionEnable = true;
  1249. pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
  1250. // Do we want to just set the transmit key index ?
  1251. if ( index < 4 ) {
  1252. pDevice->byKeyIndex = index;
  1253. }
  1254. else if(!(wrq->flags & IW_ENCODE_MODE)) {
  1255. rc = -EINVAL;
  1256. return rc;
  1257. }
  1258. }
  1259. // Read the flags
  1260. if(wrq->flags & IW_ENCODE_DISABLED){
  1261. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
  1262. pMgmt->bShareKeyAlgorithm = false;
  1263. pDevice->bEncryptionEnable = false;
  1264. pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
  1265. if (pDevice->flags & DEVICE_FLAGS_OPENED) {
  1266. spin_lock_irq(&pDevice->lock);
  1267. for(uu=0;uu<MAX_KEY_TABLE;uu++)
  1268. MACvDisableKeyEntry(pDevice->PortOffset, uu);
  1269. spin_unlock_irq(&pDevice->lock);
  1270. }
  1271. }
  1272. */
  1273. if(wrq->flags & IW_ENCODE_RESTRICTED) {
  1274. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n");
  1275. pMgmt->bShareKeyAlgorithm = true;
  1276. }
  1277. if(wrq->flags & IW_ENCODE_OPEN) {
  1278. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n");
  1279. pMgmt->bShareKeyAlgorithm = false;
  1280. }
  1281. return rc;
  1282. }
  1283. /*
  1284. * Wireless Handler : get encode mode
  1285. */
  1286. /*
  1287. int iwctl_giwencode(struct net_device *dev,
  1288. struct iw_request_info *info,
  1289. struct iw_point *wrq,
  1290. char *extra)
  1291. {
  1292. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1293. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  1294. int rc = 0;
  1295. char abyKey[WLAN_WEP232_KEYLEN];
  1296. unsigned int index = (unsigned int)(wrq->flags & IW_ENCODE_INDEX);
  1297. PSKeyItem pKey = NULL;
  1298. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
  1299. //2007-0207-06,<Add> by EinsnLiu
  1300. //the key index in iwconfig is 1-4 when our driver is 0-3
  1301. //so it can't be used directly.
  1302. //if the index is 0,we should used the index set by driver.
  1303. if (index > WLAN_WEP_NKEYS) {
  1304. rc = -EINVAL;
  1305. return rc;
  1306. }
  1307. if(index<1){//set default key
  1308. if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
  1309. index=pDevice->byKeyIndex;
  1310. }
  1311. else index=0;
  1312. }else index--;
  1313. //End Add,Einsn
  1314. memset(abyKey, 0, sizeof(abyKey));
  1315. // Check encryption mode
  1316. wrq->flags = IW_ENCODE_NOKEY;
  1317. // Is WEP enabled ???
  1318. if (pDevice->bEncryptionEnable)
  1319. wrq->flags |= IW_ENCODE_ENABLED;
  1320. else
  1321. wrq->flags |= IW_ENCODE_DISABLED;
  1322. if (pMgmt->bShareKeyAlgorithm)
  1323. wrq->flags |= IW_ENCODE_RESTRICTED;
  1324. else
  1325. wrq->flags |= IW_ENCODE_OPEN;
  1326. if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (unsigned char)index , &pKey)){
  1327. wrq->length = pKey->uKeyLength;
  1328. memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
  1329. //2007-0207-06,<Modify> by EinsnLiu
  1330. //only get key success need to copy data
  1331. //index should +1.
  1332. //there is not necessary to return -EINVAL when get key failed
  1333. //if return -EINVAL,the encryption item can't be display by the command "iwconfig".
  1334. wrq->flags |= index+1;
  1335. memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
  1336. }
  1337. //else {
  1338. // rc = -EINVAL;
  1339. // return rc;
  1340. // }
  1341. //End Modify,Einsn
  1342. return 0;
  1343. }
  1344. */
  1345. //2008-0409-06, <Add> by Einsn Liu
  1346. int iwctl_giwencode(struct net_device *dev,
  1347. struct iw_request_info *info,
  1348. struct iw_point *wrq,
  1349. char *extra)
  1350. {
  1351. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1352. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  1353. char abyKey[WLAN_WEP232_KEYLEN];
  1354. unsigned int index = (unsigned int)(wrq->flags & IW_ENCODE_INDEX);
  1355. PSKeyItem pKey = NULL;
  1356. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
  1357. if (index > WLAN_WEP_NKEYS) {
  1358. return -EINVAL;
  1359. }
  1360. if(index<1){//get default key
  1361. if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
  1362. index=pDevice->byKeyIndex;
  1363. } else
  1364. index=0;
  1365. }else
  1366. index--;
  1367. memset(abyKey, 0, WLAN_WEP232_KEYLEN);
  1368. // Check encryption mode
  1369. wrq->flags = IW_ENCODE_NOKEY;
  1370. // Is WEP enabled ???
  1371. if (pDevice->bEncryptionEnable)
  1372. wrq->flags |= IW_ENCODE_ENABLED;
  1373. else
  1374. wrq->flags |= IW_ENCODE_DISABLED;
  1375. if (pMgmt->bShareKeyAlgorithm)
  1376. wrq->flags |= IW_ENCODE_RESTRICTED;
  1377. else
  1378. wrq->flags |= IW_ENCODE_OPEN;
  1379. wrq->length=0;
  1380. if((index==0)&&(pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled||
  1381. pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)){//get wpa pairwise key
  1382. if (KeybGetKey(&(pDevice->sKey),pMgmt->abyCurrBSSID, 0xffffffff, &pKey)){
  1383. wrq->length = pKey->uKeyLength;
  1384. memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
  1385. memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
  1386. }
  1387. }else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (unsigned char)index , &pKey)){
  1388. wrq->length = pKey->uKeyLength;
  1389. memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
  1390. memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
  1391. }
  1392. wrq->flags |= index+1;
  1393. return 0;
  1394. }
  1395. /*
  1396. * Wireless Handler : set power mode
  1397. */
  1398. int iwctl_siwpower(struct net_device *dev,
  1399. struct iw_request_info *info,
  1400. struct iw_param *wrq,
  1401. char *extra)
  1402. {
  1403. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1404. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  1405. int rc = 0;
  1406. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER \n");
  1407. if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
  1408. rc = -EINVAL;
  1409. return rc;
  1410. }
  1411. if (wrq->disabled) {
  1412. pDevice->ePSMode = WMAC_POWER_CAM;
  1413. PSvDisablePowerSaving(pDevice);
  1414. return rc;
  1415. }
  1416. if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
  1417. pDevice->ePSMode = WMAC_POWER_FAST;
  1418. PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval);
  1419. } else if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
  1420. pDevice->ePSMode = WMAC_POWER_FAST;
  1421. PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval);
  1422. }
  1423. switch (wrq->flags & IW_POWER_MODE) {
  1424. case IW_POWER_UNICAST_R:
  1425. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
  1426. rc = -EINVAL;
  1427. break;
  1428. case IW_POWER_ALL_R:
  1429. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n");
  1430. rc = -EINVAL;
  1431. case IW_POWER_ON:
  1432. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON \n");
  1433. break;
  1434. default:
  1435. rc = -EINVAL;
  1436. }
  1437. return rc;
  1438. }
  1439. /*
  1440. * Wireless Handler : get power mode
  1441. */
  1442. int iwctl_giwpower(struct net_device *dev,
  1443. struct iw_request_info *info,
  1444. struct iw_param *wrq,
  1445. char *extra)
  1446. {
  1447. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1448. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  1449. int mode = pDevice->ePSMode;
  1450. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n");
  1451. wrq->disabled = (mode == WMAC_POWER_CAM);
  1452. if (wrq->disabled)
  1453. return 0;
  1454. if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
  1455. wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
  1456. wrq->flags = IW_POWER_TIMEOUT;
  1457. } else {
  1458. wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
  1459. wrq->flags = IW_POWER_PERIOD;
  1460. }
  1461. wrq->flags |= IW_POWER_ALL_R;
  1462. return 0;
  1463. }
  1464. /*
  1465. * Wireless Handler : get Sensitivity
  1466. */
  1467. int iwctl_giwsens(struct net_device *dev,
  1468. struct iw_request_info *info,
  1469. struct iw_param *wrq,
  1470. char *extra)
  1471. {
  1472. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1473. long ldBm;
  1474. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n");
  1475. if (pDevice->bLinkPass == true) {
  1476. RFvRSSITodBm(pDevice, (unsigned char)(pDevice->uCurrRSSI), &ldBm);
  1477. wrq->value = ldBm;
  1478. }
  1479. else {
  1480. wrq->value = 0;
  1481. };
  1482. wrq->disabled = (wrq->value == 0);
  1483. wrq->fixed = 1;
  1484. return 0;
  1485. }
  1486. //2008-0409-07, <Add> by Einsn Liu
  1487. #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
  1488. int iwctl_siwauth(struct net_device *dev,
  1489. struct iw_request_info *info,
  1490. struct iw_param *wrq,
  1491. char *extra)
  1492. {
  1493. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1494. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  1495. int ret=0;
  1496. static int wpa_version=0; //must be static to save the last value,einsn liu
  1497. static int pairwise=0;
  1498. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
  1499. switch (wrq->flags & IW_AUTH_INDEX) {
  1500. case IW_AUTH_WPA_VERSION:
  1501. wpa_version = wrq->value;
  1502. if(wrq->value == IW_AUTH_WPA_VERSION_DISABLED) {
  1503. PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n");
  1504. //pDevice->bWPADevEnable = false;
  1505. }
  1506. else if(wrq->value == IW_AUTH_WPA_VERSION_WPA) {
  1507. PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n");
  1508. }
  1509. else {
  1510. PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n");
  1511. }
  1512. //pDevice->bWPASuppWextEnabled =true;
  1513. break;
  1514. case IW_AUTH_CIPHER_PAIRWISE:
  1515. pairwise = wrq->value;
  1516. if(pairwise == IW_AUTH_CIPHER_CCMP){
  1517. pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
  1518. }else if(pairwise == IW_AUTH_CIPHER_TKIP){
  1519. pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
  1520. }else if(pairwise == IW_AUTH_CIPHER_WEP40||pairwise == IW_AUTH_CIPHER_WEP104){
  1521. pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
  1522. }else if(pairwise == IW_AUTH_CIPHER_NONE){
  1523. //do nothing,einsn liu
  1524. }else pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
  1525. break;
  1526. case IW_AUTH_CIPHER_GROUP:
  1527. if(wpa_version == IW_AUTH_WPA_VERSION_DISABLED)
  1528. break;
  1529. if(pairwise == IW_AUTH_CIPHER_NONE){
  1530. if(wrq->value == IW_AUTH_CIPHER_CCMP){
  1531. pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
  1532. }else {
  1533. pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
  1534. }
  1535. }
  1536. break;
  1537. case IW_AUTH_KEY_MGMT:
  1538. if(wpa_version == IW_AUTH_WPA_VERSION_WPA2){
  1539. if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
  1540. pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
  1541. else pMgmt->eAuthenMode = WMAC_AUTH_WPA2;
  1542. }else if(wpa_version == IW_AUTH_WPA_VERSION_WPA){
  1543. if(wrq->value == 0){
  1544. pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
  1545. }else if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
  1546. pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
  1547. else pMgmt->eAuthenMode = WMAC_AUTH_WPA;
  1548. }
  1549. break;
  1550. case IW_AUTH_TKIP_COUNTERMEASURES:
  1551. break; /* FIXME */
  1552. case IW_AUTH_DROP_UNENCRYPTED:
  1553. break;
  1554. case IW_AUTH_80211_AUTH_ALG:
  1555. if(wrq->value==IW_AUTH_ALG_OPEN_SYSTEM){
  1556. pMgmt->bShareKeyAlgorithm=false;
  1557. }else if(wrq->value==IW_AUTH_ALG_SHARED_KEY){
  1558. pMgmt->bShareKeyAlgorithm=true;
  1559. }
  1560. break;
  1561. case IW_AUTH_WPA_ENABLED:
  1562. //pDevice->bWPADevEnable = !! wrq->value;
  1563. break;
  1564. case IW_AUTH_RX_UNENCRYPTED_EAPOL:
  1565. break;
  1566. case IW_AUTH_ROAMING_CONTROL:
  1567. ret = -EOPNOTSUPP;
  1568. break;
  1569. case IW_AUTH_PRIVACY_INVOKED:
  1570. pDevice->bEncryptionEnable = !!wrq->value;
  1571. if(pDevice->bEncryptionEnable == false){
  1572. wpa_version = 0;
  1573. pairwise = 0;
  1574. pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
  1575. pMgmt->bShareKeyAlgorithm = false;
  1576. pMgmt->eAuthenMode = false;
  1577. //pDevice->bWPADevEnable = false;
  1578. }
  1579. break;
  1580. default:
  1581. ret = -EOPNOTSUPP;
  1582. break;
  1583. }
  1584. /*
  1585. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version);
  1586. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise);
  1587. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus);
  1588. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode = %d\n",pMgmt->eAuthenMode);
  1589. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"true":"false");
  1590. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"true":"false");
  1591. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADevEnable = %s\n",pDevice->bWPADevEnable?"true":"false");
  1592. */
  1593. return ret;
  1594. }
  1595. int iwctl_giwauth(struct net_device *dev,
  1596. struct iw_request_info *info,
  1597. struct iw_param *wrq,
  1598. char *extra)
  1599. {
  1600. return -EOPNOTSUPP;
  1601. }
  1602. int iwctl_siwgenie(struct net_device *dev,
  1603. struct iw_request_info *info,
  1604. struct iw_point *wrq,
  1605. char *extra)
  1606. {
  1607. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1608. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  1609. int ret=0;
  1610. if(wrq->length){
  1611. if ((wrq->length < 2) || (extra[1]+2 != wrq->length)) {
  1612. ret = -EINVAL;
  1613. goto out;
  1614. }
  1615. if(wrq->length > MAX_WPA_IE_LEN){
  1616. ret = -ENOMEM;
  1617. goto out;
  1618. }
  1619. memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
  1620. if(copy_from_user(pMgmt->abyWPAIE, extra, wrq->length)){
  1621. ret = -EFAULT;
  1622. goto out;
  1623. }
  1624. pMgmt->wWPAIELen = wrq->length;
  1625. }else {
  1626. memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
  1627. pMgmt->wWPAIELen = 0;
  1628. }
  1629. out://not completely ...not necessary in wpa_supplicant 0.5.8
  1630. return ret;
  1631. }
  1632. int iwctl_giwgenie(struct net_device *dev,
  1633. struct iw_request_info *info,
  1634. struct iw_point *wrq,
  1635. char *extra)
  1636. {
  1637. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1638. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  1639. int ret=0;
  1640. int space = wrq->length;
  1641. wrq->length = 0;
  1642. if(pMgmt->wWPAIELen > 0){
  1643. wrq->length = pMgmt->wWPAIELen;
  1644. if(pMgmt->wWPAIELen <= space){
  1645. if(copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)){
  1646. ret = -EFAULT;
  1647. }
  1648. }else
  1649. ret = -E2BIG;
  1650. }
  1651. return ret;
  1652. }
  1653. int iwctl_siwencodeext(struct net_device *dev,
  1654. struct iw_request_info *info,
  1655. struct iw_point *wrq,
  1656. char *extra)
  1657. {
  1658. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1659. struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
  1660. struct viawget_wpa_param *param=NULL;
  1661. //original member
  1662. wpa_alg alg_name;
  1663. u8 addr[6];
  1664. int key_idx, set_tx=0;
  1665. u8 seq[IW_ENCODE_SEQ_MAX_SIZE];
  1666. u8 key[64];
  1667. size_t seq_len=0,key_len=0;
  1668. //
  1669. // int ii;
  1670. u8 *buf;
  1671. size_t blen;
  1672. u8 key_array[64];
  1673. int ret=0;
  1674. PRINT_K("SIOCSIWENCODEEXT...... \n");
  1675. blen = sizeof(*param);
  1676. buf = kmalloc((int)blen, (int)GFP_KERNEL);
  1677. if (buf == NULL)
  1678. return -ENOMEM;
  1679. memset(buf, 0, blen);
  1680. param = (struct viawget_wpa_param *) buf;
  1681. //recover alg_name
  1682. switch (ext->alg) {
  1683. case IW_ENCODE_ALG_NONE:
  1684. alg_name = WPA_ALG_NONE;
  1685. break;
  1686. case IW_ENCODE_ALG_WEP:
  1687. alg_name = WPA_ALG_WEP;
  1688. break;
  1689. case IW_ENCODE_ALG_TKIP:
  1690. alg_name = WPA_ALG_TKIP;
  1691. break;
  1692. case IW_ENCODE_ALG_CCMP:
  1693. alg_name = WPA_ALG_CCMP;
  1694. break;
  1695. default:
  1696. PRINT_K("Unknown alg = %d\n",ext->alg);
  1697. ret= -ENOMEM;
  1698. goto error;
  1699. }
  1700. //recover addr
  1701. memcpy(addr, ext->addr.sa_data, ETH_ALEN);
  1702. //recover key_idx
  1703. key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1;
  1704. //recover set_tx
  1705. if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
  1706. set_tx = 1;
  1707. //recover seq,seq_len
  1708. if(ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
  1709. seq_len=IW_ENCODE_SEQ_MAX_SIZE;
  1710. memcpy(seq, ext->rx_seq, seq_len);
  1711. }
  1712. //recover key,key_len
  1713. if(ext->key_len) {
  1714. key_len=ext->key_len;
  1715. memcpy(key, &ext->key[0], key_len);
  1716. }
  1717. memset(key_array, 0, 64);
  1718. if ( key_len > 0) {
  1719. memcpy(key_array, key, key_len);
  1720. if (key_len == 32) {
  1721. // notice ! the oder
  1722. memcpy(&key_array[16], &key[24], 8);
  1723. memcpy(&key_array[24], &key[16], 8);
  1724. }
  1725. }
  1726. /**************Translate iw_encode_ext to viawget_wpa_param****************/
  1727. memcpy(param->addr, addr, ETH_ALEN);
  1728. param->u.wpa_key.alg_name = (int)alg_name;
  1729. param->u.wpa_key.set_tx = set_tx;
  1730. param->u.wpa_key.key_index = key_idx;
  1731. param->u.wpa_key.key_len = key_len;
  1732. param->u.wpa_key.key = (u8 *)key_array;
  1733. param->u.wpa_key.seq = (u8 *)seq;
  1734. param->u.wpa_key.seq_len = seq_len;
  1735. #if 0
  1736. printk("param->u.wpa_key.alg_name =%d\n",param->u.wpa_key.alg_name);
  1737. printk(KERN_DEBUG "param->addr=%pM\n", param->addr);
  1738. printk("param->u.wpa_key.set_tx =%d\n",param->u.wpa_key.set_tx);
  1739. printk("param->u.wpa_key.key_index =%d\n",param->u.wpa_key.key_index);
  1740. printk("param->u.wpa_key.key_len =%d\n",param->u.wpa_key.key_len);
  1741. printk("param->u.wpa_key.key =");
  1742. for(ii=0;ii<param->u.wpa_key.key_len;ii++)
  1743. printk("%02x:",param->u.wpa_key.key[ii]);
  1744. printk("\n");
  1745. printk("param->u.wpa_key.seq_len =%d\n",param->u.wpa_key.seq_len);
  1746. printk("param->u.wpa_key.seq =");
  1747. for(ii=0;ii<param->u.wpa_key.seq_len;ii++)
  1748. printk("%02x:",param->u.wpa_key.seq[ii]);
  1749. printk("\n");
  1750. printk("...........\n");
  1751. #endif
  1752. //****set if current action is Network Manager count??
  1753. //****this method is so foolish,but there is no other way???
  1754. if(param->u.wpa_key.alg_name == WPA_ALG_NONE) {
  1755. if(param->u.wpa_key.key_index ==0) {
  1756. pDevice->bwextcount++;
  1757. }
  1758. if((pDevice->bwextcount == 1)&&(param->u.wpa_key.key_index ==1)) {
  1759. pDevice->bwextcount++;
  1760. }
  1761. if((pDevice->bwextcount ==2)&&(param->u.wpa_key.key_index ==2)) {
  1762. pDevice->bwextcount++;
  1763. }
  1764. if((pDevice->bwextcount ==3)&&(param->u.wpa_key.key_index ==3)) {
  1765. pDevice->bwextcount++;
  1766. }
  1767. }
  1768. if( pDevice->bwextcount == 4) {
  1769. printk("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
  1770. pDevice->bwextcount=0;
  1771. pDevice->bWPASuppWextEnabled = true;
  1772. }
  1773. //******
  1774. spin_lock_irq(&pDevice->lock);
  1775. ret = wpa_set_keys(pDevice, param, true);
  1776. spin_unlock_irq(&pDevice->lock);
  1777. error:
  1778. kfree(param);
  1779. return ret;
  1780. }
  1781. int iwctl_giwencodeext(struct net_device *dev,
  1782. struct iw_request_info *info,
  1783. struct iw_point *wrq,
  1784. char *extra)
  1785. {
  1786. return -EOPNOTSUPP;
  1787. }
  1788. int iwctl_siwmlme(struct net_device *dev,
  1789. struct iw_request_info * info,
  1790. struct iw_point *wrq,
  1791. char *extra)
  1792. {
  1793. PSDevice pDevice = (PSDevice)netdev_priv(dev);
  1794. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  1795. struct iw_mlme *mlme = (struct iw_mlme *)extra;
  1796. //u16 reason = cpu_to_le16(mlme->reason_code);
  1797. int ret = 0;
  1798. if(memcmp(pMgmt->abyCurrBSSID, mlme->addr.sa_data, ETH_ALEN)){
  1799. ret = -EINVAL;
  1800. return ret;
  1801. }
  1802. switch(mlme->cmd){
  1803. case IW_MLME_DEAUTH:
  1804. //this command seems to be not complete,please test it --einsnliu
  1805. //bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (unsigned char *)&reason);
  1806. break;
  1807. case IW_MLME_DISASSOC:
  1808. if(pDevice->bLinkPass == true){
  1809. printk("iwctl_siwmlme--->send DISASSOCIATE\n");
  1810. //clear related flags
  1811. memset(pMgmt->abyDesireBSSID, 0xFF,6);
  1812. KeyvInitTable(&pDevice->sKey, pDevice->PortOffset);
  1813. bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
  1814. }
  1815. break;
  1816. default:
  1817. ret = -EOPNOTSUPP;
  1818. }
  1819. return ret;
  1820. }
  1821. #endif
  1822. /*------------------------------------------------------------------*/
  1823. /*
  1824. * Structures to export the Wireless Handlers
  1825. */
  1826. /*
  1827. static const iw_handler iwctl_handler[] =
  1828. {
  1829. (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
  1830. (iw_handler) iwctl_giwname, // SIOCGIWNAME
  1831. (iw_handler) NULL, // SIOCSIWNWID
  1832. (iw_handler) NULL, // SIOCGIWNWID
  1833. (iw_handler) iwctl_siwfreq, // SIOCSIWFREQ
  1834. (iw_handler) iwctl_giwfreq, // SIOCGIWFREQ
  1835. (iw_handler) iwctl_siwmode, // SIOCSIWMODE
  1836. (iw_handler) iwctl_giwmode, // SIOCGIWMODE
  1837. (iw_handler) NULL, // SIOCSIWSENS
  1838. (iw_handler) iwctl_giwsens, // SIOCGIWSENS
  1839. (iw_handler) NULL, // SIOCSIWRANGE
  1840. (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
  1841. (iw_handler) NULL, // SIOCSIWPRIV
  1842. (iw_handler) NULL, // SIOCGIWPRIV
  1843. (iw_handler) NULL, // SIOCSIWSTATS
  1844. (iw_handler) NULL, // SIOCGIWSTATS
  1845. (iw_handler) NULL, // SIOCSIWSPY
  1846. (iw_handler) NULL, // SIOCGIWSPY
  1847. (iw_handler) NULL, // -- hole --
  1848. (iw_handler) NULL, // -- hole --
  1849. (iw_handler) iwctl_siwap, // SIOCSIWAP
  1850. (iw_handler) iwctl_giwap, // SIOCGIWAP
  1851. (iw_handler) NULL, // -- hole -- 0x16
  1852. (iw_handler) iwctl_giwaplist, // SIOCGIWAPLIST
  1853. (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
  1854. (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
  1855. (iw_handler) iwctl_siwessid, // SIOCSIWESSID
  1856. (iw_handler) iwctl_giwessid, // SIOCGIWESSID
  1857. (iw_handler) NULL, // SIOCSIWNICKN
  1858. (iw_handler) NULL, // SIOCGIWNICKN
  1859. (iw_handler) NULL, // -- hole --
  1860. (iw_handler) NULL, // -- hole --
  1861. (iw_handler) iwctl_siwrate, // SIOCSIWRATE 0x20
  1862. (iw_handler) iwctl_giwrate, // SIOCGIWRATE
  1863. (iw_handler) iwctl_siwrts, // SIOCSIWRTS
  1864. (iw_handler) iwctl_giwrts, // SIOCGIWRTS
  1865. (iw_handler) iwctl_siwfrag, // SIOCSIWFRAG
  1866. (iw_handler) iwctl_giwfrag, // SIOCGIWFRAG
  1867. (iw_handler) NULL, // SIOCSIWTXPOW
  1868. (iw_handler) NULL, // SIOCGIWTXPOW
  1869. (iw_handler) iwctl_siwretry, // SIOCSIWRETRY
  1870. (iw_handler) iwctl_giwretry, // SIOCGIWRETRY
  1871. (iw_handler) iwctl_siwencode, // SIOCSIWENCODE
  1872. (iw_handler) iwctl_giwencode, // SIOCGIWENCODE
  1873. (iw_handler) iwctl_siwpower, // SIOCSIWPOWER
  1874. (iw_handler) iwctl_giwpower, // SIOCGIWPOWER
  1875. (iw_handler) NULL, // -- hole --
  1876. (iw_handler) NULL, // -- hole --
  1877. (iw_handler) iwctl_siwgenie, // SIOCSIWGENIE
  1878. (iw_handler) iwctl_giwgenie, // SIOCGIWGENIE
  1879. (iw_handler) iwctl_siwauth, // SIOCSIWAUTH
  1880. (iw_handler) iwctl_giwauth, // SIOCGIWAUTH
  1881. (iw_handler) iwctl_siwencodeext, // SIOCSIWENCODEEXT
  1882. (iw_handler) iwctl_giwencodeext, // SIOCGIWENCODEEXT
  1883. (iw_handler) NULL, // SIOCSIWPMKSA
  1884. (iw_handler) NULL, // -- hole --
  1885. };
  1886. */
  1887. static const iw_handler iwctl_handler[] =
  1888. {
  1889. (iw_handler) iwctl_commit, // SIOCSIWCOMMIT
  1890. (iw_handler) NULL, // SIOCGIWNAME
  1891. (iw_handler) NULL, // SIOCSIWNWID
  1892. (iw_handler) NULL, // SIOCGIWNWID
  1893. (iw_handler) NULL, // SIOCSIWFREQ
  1894. (iw_handler) NULL, // SIOCGIWFREQ
  1895. (iw_handler) NULL, // SIOCSIWMODE
  1896. (iw_handler) NULL, // SIOCGIWMODE
  1897. (iw_handler) NULL, // SIOCSIWSENS
  1898. (iw_handler) NULL, // SIOCGIWSENS
  1899. (iw_handler) NULL, // SIOCSIWRANGE
  1900. (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
  1901. (iw_handler) NULL, // SIOCSIWPRIV
  1902. (iw_handler) NULL, // SIOCGIWPRIV
  1903. (iw_handler) NULL, // SIOCSIWSTATS
  1904. (iw_handler) NULL, // SIOCGIWSTATS
  1905. (iw_handler) NULL, // SIOCSIWSPY
  1906. (iw_handler) NULL, // SIOCGIWSPY
  1907. (iw_handler) NULL, // -- hole --
  1908. (iw_handler) NULL, // -- hole --
  1909. (iw_handler) NULL, // SIOCSIWAP
  1910. (iw_handler) NULL, // SIOCGIWAP
  1911. (iw_handler) NULL, // -- hole -- 0x16
  1912. (iw_handler) NULL, // SIOCGIWAPLIST
  1913. (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
  1914. (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
  1915. (iw_handler) NULL, // SIOCSIWESSID
  1916. (iw_handler) NULL, // SIOCGIWESSID
  1917. (iw_handler) NULL, // SIOCSIWNICKN
  1918. (iw_handler) NULL, // SIOCGIWNICKN
  1919. (iw_handler) NULL, // -- hole --
  1920. (iw_handler) NULL, // -- hole --
  1921. (iw_handler) NULL, // SIOCSIWRATE 0x20
  1922. (iw_handler) NULL, // SIOCGIWRATE
  1923. (iw_handler) NULL, // SIOCSIWRTS
  1924. (iw_handler) NULL, // SIOCGIWRTS
  1925. (iw_handler) NULL, // SIOCSIWFRAG
  1926. (iw_handler) NULL, // SIOCGIWFRAG
  1927. (iw_handler) NULL, // SIOCSIWTXPOW
  1928. (iw_handler) NULL, // SIOCGIWTXPOW
  1929. (iw_handler) NULL, // SIOCSIWRETRY
  1930. (iw_handler) NULL, // SIOCGIWRETRY
  1931. (iw_handler) NULL, // SIOCSIWENCODE
  1932. (iw_handler) NULL, // SIOCGIWENCODE
  1933. (iw_handler) NULL, // SIOCSIWPOWER
  1934. (iw_handler) NULL, // SIOCGIWPOWER
  1935. //2008-0409-07, <Add> by Einsn Liu
  1936. (iw_handler) NULL, // -- hole --
  1937. (iw_handler) NULL, // -- hole --
  1938. (iw_handler) NULL, // SIOCSIWGENIE
  1939. (iw_handler) NULL, // SIOCGIWGENIE
  1940. (iw_handler) NULL, // SIOCSIWAUTH
  1941. (iw_handler) NULL, // SIOCGIWAUTH
  1942. (iw_handler) NULL, // SIOCSIWENCODEEXT
  1943. (iw_handler) NULL, // SIOCGIWENCODEEXT
  1944. (iw_handler) NULL, // SIOCSIWPMKSA
  1945. (iw_handler) NULL, // -- hole --
  1946. };
  1947. static const iw_handler iwctl_private_handler[] =
  1948. {
  1949. NULL, // SIOCIWFIRSTPRIV
  1950. };
  1951. struct iw_priv_args iwctl_private_args[] = {
  1952. { IOCTL_CMD_SET,
  1953. IW_PRIV_TYPE_CHAR | 1024, 0,
  1954. "set"},
  1955. };
  1956. const struct iw_handler_def iwctl_handler_def =
  1957. {
  1958. .get_wireless_stats = &iwctl_get_wireless_stats,
  1959. .num_standard = sizeof(iwctl_handler)/sizeof(iw_handler),
  1960. // .num_private = sizeof(iwctl_private_handler)/sizeof(iw_handler),
  1961. // .num_private_args = sizeof(iwctl_private_args)/sizeof(struct iw_priv_args),
  1962. .num_private = 0,
  1963. .num_private_args = 0,
  1964. .standard = (iw_handler *) iwctl_handler,
  1965. // .private = (iw_handler *) iwctl_private_handler,
  1966. // .private_args = (struct iw_priv_args *)iwctl_private_args,
  1967. .private = NULL,
  1968. .private_args = NULL,
  1969. };