Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ioctl.c
Go to the documentation of this file.
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: ioctl.c
20  *
21  * Purpose: private ioctl functions
22  *
23  * Author: Lyndon Chen
24  *
25  * Date: Auguest 20, 2003
26  *
27  * Functions:
28  *
29  * Revision History:
30  *
31  */
32 
33 #include "ioctl.h"
34 #include "iocmd.h"
35 #include "mac.h"
36 #include "card.h"
37 #include "hostap.h"
38 #include "wpactl.h"
39 #include "rf.h"
40 
41 static int msglevel = MSG_LEVEL_INFO;
42 
43 #ifdef WPA_SM_Transtatus
45 #endif
46 
47 int private_ioctl(PSDevice pDevice, struct ifreq *rq)
48 {
49  PSCmdRequest pReq = (PSCmdRequest)rq;
50  PSMgmtObject pMgmt = pDevice->pMgmt;
51  int result = 0;
52  PWLAN_IE_SSID pItemSSID;
53  SCmdBSSJoin sJoinCmd;
54  SCmdZoneTypeSet sZoneTypeCmd;
55  SCmdScan sScanCmd;
56  SCmdStartAP sStartAPCmd;
57  SCmdSetWEP sWEPCmd;
58  SCmdValue sValue;
59  SBSSIDList sList;
60  SNodeList sNodeList;
61  PSBSSIDList pList;
62  PSNodeList pNodeList;
63  unsigned int cbListCount;
64  PKnownBSS pBSS;
65  PKnownNodeDB pNode;
66  unsigned int ii, jj;
67  SCmdLinkStatus sLinkStatus;
68  unsigned char abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
69  unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
70  unsigned long dwKeyIndex = 0;
71  unsigned char abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
72  long ldBm;
73 
74  pReq->wResult = 0;
75 
76  switch (pReq->wCmdCode) {
77  case WLAN_CMD_BSS_SCAN:
78  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin\n");
79  if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) {
80  result = -EFAULT;
81  break;
82  }
83 
84  pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
85  if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
86  return -EINVAL;
87  if (pItemSSID->len != 0) {
88  memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
89  memcpy(abyScanSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
90  }
91 
92  if (pDevice->bMACSuspend == true) {
93  if (pDevice->bRadioOff == true)
94  CARDbRadioPowerOn(pDevice);
95  vMgrTimerInit(pDevice);
98  pDevice->bMACSuspend = false;
99  }
100  spin_lock_irq(&pDevice->lock);
101  if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0)
102  BSSvClearBSSList((void *)pDevice, false);
103  else
104  BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
105 
106  if (pItemSSID->len != 0)
107  bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
108  else
109  bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
110  spin_unlock_irq(&pDevice->lock);
111  break;
112 
114  /* mike add :can't support. */
115  result = -EOPNOTSUPP;
116  break;
117 
118  if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {
119  result = -EFAULT;
120  break;
121  }
122 
123  if (sZoneTypeCmd.bWrite == true) {
124  /* write zonetype */
125  if (sZoneTypeCmd.ZoneType == ZoneType_USA) {
126  /* set to USA */
127  printk("set_ZoneType:USA\n");
128  } else if (sZoneTypeCmd.ZoneType == ZoneType_Japan) {
129  /* set to Japan */
130  printk("set_ZoneType:Japan\n");
131  } else if (sZoneTypeCmd.ZoneType == ZoneType_Europe) {
132  /* set to Europe */
133  printk("set_ZoneType:Europe\n");
134  }
135  } else {
136  /* read zonetype */
137  unsigned char zonetype = 0;
138 
139  if (zonetype == 0x00) { /* USA */
140  sZoneTypeCmd.ZoneType = ZoneType_USA;
141  } else if (zonetype == 0x01) { /* Japan */
142  sZoneTypeCmd.ZoneType = ZoneType_Japan;
143  } else if (zonetype == 0x02) { /* Europe */
144  sZoneTypeCmd.ZoneType = ZoneType_Europe;
145  } else { /* Unknown ZoneType */
146  printk("Error:ZoneType[%x] Unknown ???\n", zonetype);
147  result = -EFAULT;
148  break;
149  }
150  if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) {
151  result = -EFAULT;
152  break;
153  }
154  }
155  break;
156 
157  case WLAN_CMD_BSS_JOIN:
158  if (pDevice->bMACSuspend == true) {
159  if (pDevice->bRadioOff == true)
160  CARDbRadioPowerOn(pDevice);
161  vMgrTimerInit(pDevice);
164  pDevice->bMACSuspend = false;
165  }
166 
167  if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
168  result = -EFAULT;
169  break;
170  }
171 
172  pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;
173  if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
174  return -EINVAL;
176  memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
177  if (sJoinCmd.wBSSType == ADHOC) {
179  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to adhoc mode\n");
180  } else {
182  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to STA mode\n");
183  }
184  if (sJoinCmd.bPSEnable == true) {
185  pDevice->ePSMode = WMAC_POWER_FAST;
186  pMgmt->wListenInterval = 2;
187  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving On\n");
188  } else {
189  pDevice->ePSMode = WMAC_POWER_CAM;
190  pMgmt->wListenInterval = 1;
191  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Power Saving Off\n");
192  }
193 
194  if (sJoinCmd.bShareKeyAuth == true) {
195  pMgmt->bShareKeyAlgorithm = true;
196  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n");
197  } else {
198  pMgmt->bShareKeyAlgorithm = false;
199  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n");
200  }
201  pDevice->uChannel = sJoinCmd.uChannel;
202  netif_stop_queue(pDevice->dev);
203  spin_lock_irq(&pDevice->lock);
204  pMgmt->eCurrState = WMAC_STATE_IDLE;
205  bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
206  bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL);
207  spin_unlock_irq(&pDevice->lock);
208  break;
209 
210  case WLAN_CMD_SET_WEP:
211  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WEP Key.\n");
212  memset(&sWEPCmd, 0, sizeof(SCmdSetWEP));
213  if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) {
214  result = -EFAULT;
215  break;
216  }
217  if (sWEPCmd.bEnableWep != true) {
218  pDevice->bEncryptionEnable = false;
221  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable.\n");
222  break;
223  }
224 
225  for (ii = 0; ii < WLAN_WEP_NKEYS; ii++) {
226  if (sWEPCmd.bWepKeyAvailable[ii]) {
227  if (ii == sWEPCmd.byKeyIndex)
228  dwKeyIndex = ii | (1 << 31);
229  else
230  dwKeyIndex = ii;
231 
232  KeybSetDefaultKey(&(pDevice->sKey),
233  dwKeyIndex,
234  sWEPCmd.auWepKeyLength[ii],
235  NULL,
236  (unsigned char *)&sWEPCmd.abyWepKey[ii][0],
237  KEY_CTL_WEP,
238  pDevice->PortOffset,
239  pDevice->byLocalID);
240  }
241  }
242  pDevice->byKeyIndex = sWEPCmd.byKeyIndex;
243  pDevice->bTransmitKey = true;
244  pDevice->bEncryptionEnable = true;
246  break;
247 
248  case WLAN_CMD_GET_LINK:
249  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_GET_LINK status.\n");
250 
251  memset(sLinkStatus.abySSID, 0 , WLAN_SSID_MAXLEN + 1);
252 
253  if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)
254  sLinkStatus.wBSSType = ADHOC;
255  else
256  sLinkStatus.wBSSType = INFRA;
257 
258  if (pMgmt->eCurrState == WMAC_STATE_JOINTED)
259  sLinkStatus.byState = ADHOC_JOINTED;
260  else
261  sLinkStatus.byState = ADHOC_STARTED;
262 
263  sLinkStatus.uChannel = pMgmt->uCurrChannel;
264  if (pDevice->bLinkPass == true) {
265  sLinkStatus.bLink = true;
266  pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
267  memcpy(sLinkStatus.abySSID, pItemSSID->abySSID, pItemSSID->len);
268  memcpy(sLinkStatus.abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
269  sLinkStatus.uLinkRate = pMgmt->sNodeDBTable[0].wTxDataRate;
270  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Link Success!\n");
271  } else {
272  sLinkStatus.bLink = false;
273  sLinkStatus.uLinkRate = 0;
274  }
275  if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) {
276  result = -EFAULT;
277  break;
278  }
279  break;
280 
282  cbListCount = 0;
283  pBSS = &(pMgmt->sBSSList[0]);
284  for (ii = 0; ii < MAX_BSS_NUM; ii++) {
285  pBSS = &(pMgmt->sBSSList[ii]);
286  if (!pBSS->bActive)
287  continue;
288  cbListCount++;
289  }
290  sList.uItem = cbListCount;
291  if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {
292  result = -EFAULT;
293  break;
294  }
295  pReq->wResult = 0;
296  break;
297 
298  case WLAN_CMD_GET_LIST:
299  if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {
300  result = -EFAULT;
301  break;
302  }
303  if (sList.uItem > (ULONG_MAX - sizeof(SBSSIDList)) / sizeof(SBSSIDItem)) {
304  result = -EINVAL;
305  break;
306  }
307  pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
308  if (pList == NULL) {
309  result = -ENOMEM;
310  break;
311  }
312  pList->uItem = sList.uItem;
313  pBSS = &(pMgmt->sBSSList[0]);
314  for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
315  pBSS = &(pMgmt->sBSSList[jj]);
316  if (pBSS->bActive) {
317  pList->sBSSIDList[ii].uChannel = pBSS->uChannel;
318  pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;
319  pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo;
320  /* pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; */
321  RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm);
322  pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm;
323  memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN);
324  pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
325  memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1);
326  memcpy(pList->sBSSIDList[ii].abySSID, pItemSSID->abySSID, pItemSSID->len);
327  if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo))
328  pList->sBSSIDList[ii].byNetType = INFRA;
329  else
330  pList->sBSSIDList[ii].byNetType = ADHOC;
331 
332  if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo))
333  pList->sBSSIDList[ii].bWEPOn = true;
334  else
335  pList->sBSSIDList[ii].bWEPOn = false;
336 
337  ii++;
338  if (ii >= pList->uItem)
339  break;
340  }
341  }
342 
343  if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {
344  result = -EFAULT;
345  break;
346  }
347  kfree(pList);
348  pReq->wResult = 0;
349  break;
350 
351  case WLAN_CMD_GET_MIB:
352  if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {
353  result = -EFAULT;
354  break;
355  }
356  break;
357 
358  case WLAN_CMD_GET_STAT:
359  if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
360  result = -EFAULT;
361  break;
362  }
363  break;
364 
365  case WLAN_CMD_STOP_MAC:
366  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");
367  netif_stop_queue(pDevice->dev);
368 
369  spin_lock_irq(&pDevice->lock);
370  if (pDevice->bRadioOff == false)
371  CARDbRadioPowerOff(pDevice);
372 
373  pDevice->bLinkPass = false;
374  memset(pMgmt->abyCurrBSSID, 0, 6);
375  pMgmt->eCurrState = WMAC_STATE_IDLE;
376  del_timer(&pDevice->sTimerCommand);
378  pDevice->bCmdRunning = false;
379  pDevice->bMACSuspend = true;
380  MACvIntDisable(pDevice->PortOffset);
381  spin_unlock_irq(&pDevice->lock);
382  break;
383 
384  case WLAN_CMD_START_MAC:
385  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n");
386 
387  if (pDevice->bMACSuspend == true) {
388  if (pDevice->bRadioOff == true)
389  CARDbRadioPowerOn(pDevice);
390  vMgrTimerInit(pDevice);
393  pDevice->bMACSuspend = false;
394  }
395  break;
396 
398  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n");
399 
400  if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
401  result = -EFAULT;
402  break;
403  }
404  if (sValue.dwValue == 1) {
405  if (vt6655_hostap_set_hostapd(pDevice, 1, 1) == 0) {
406  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
407  } else {
408  result = -EFAULT;
409  break;
410  }
411  } else {
412  vt6655_hostap_set_hostapd(pDevice, 0, 1);
413  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n");
414  }
415  break;
416 
418  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n");
419  break;
420 
421  case WLAN_CMD_SET_802_1X:
422  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n");
423  if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
424  result = -EFAULT;
425  break;
426  }
427 
428  if (sValue.dwValue == 1) {
429  pDevice->bEnable8021x = true;
430  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n");
431  } else {
432  pDevice->bEnable8021x = false;
433  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n");
434  }
435  break;
436 
438  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n");
439  if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
440  result = -EFAULT;
441  break;
442  }
443 
444  if (sValue.dwValue == 1) {
445  pDevice->bEnableHostWEP = true;
446  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n");
447  } else {
448  pDevice->bEnableHostWEP = false;
449  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n");
450  }
451  break;
452 
453  case WLAN_CMD_SET_WPA:
454  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n");
455 
456  if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
457  result = -EFAULT;
458  break;
459  }
460  if (sValue.dwValue == 1) {
461  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n");
462  memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, ETH_ALEN);
463  pDevice->bWPADEVUp = true;
464  } else {
465  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "close wpadev\n");
466  pDevice->bWPADEVUp = false;
467  }
468  break;
469 
470  case WLAN_CMD_AP_START:
471  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n");
472  if (pDevice->bRadioOff == true) {
473  CARDbRadioPowerOn(pDevice);
474  vMgrTimerInit(pDevice);
477  }
478  if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
479  result = -EFAULT;
480  break;
481  }
482 
483  if (sStartAPCmd.wBSSType == AP) {
484  pMgmt->eConfigMode = WMAC_CONFIG_AP;
485  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n");
486  } else {
487  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n");
488  result = -EFAULT;
489  break;
490  }
491 
492  if (sStartAPCmd.wBBPType == PHY80211g)
493  pMgmt->byAPBBType = PHY_TYPE_11G;
494  else if (sStartAPCmd.wBBPType == PHY80211a)
495  pMgmt->byAPBBType = PHY_TYPE_11A;
496  else
497  pMgmt->byAPBBType = PHY_TYPE_11B;
498 
499  pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;
500  if (pItemSSID->len > WLAN_SSID_MAXLEN + 1)
501  return -EINVAL;
503  memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
504 
505  if ((sStartAPCmd.uChannel > 0) && (sStartAPCmd.uChannel <= 14))
506  pDevice->uChannel = sStartAPCmd.uChannel;
507 
508  if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000))
509  pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt;
510  else
511  pMgmt->wIBSSBeaconPeriod = 100;
512 
513  if (sStartAPCmd.bShareKeyAuth == true) {
514  pMgmt->bShareKeyAlgorithm = true;
515  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key\n");
516  } else {
517  pMgmt->bShareKeyAlgorithm = false;
518  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System\n");
519  }
520  memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6);
521 
522  if (sStartAPCmd.byBasicRate & BIT3) {
523  pMgmt->abyIBSSSuppRates[2] |= BIT7;
524  pMgmt->abyIBSSSuppRates[3] |= BIT7;
525  pMgmt->abyIBSSSuppRates[4] |= BIT7;
526  pMgmt->abyIBSSSuppRates[5] |= BIT7;
527  } else if (sStartAPCmd.byBasicRate & BIT2) {
528  pMgmt->abyIBSSSuppRates[2] |= BIT7;
529  pMgmt->abyIBSSSuppRates[3] |= BIT7;
530  pMgmt->abyIBSSSuppRates[4] |= BIT7;
531  } else if (sStartAPCmd.byBasicRate & BIT1) {
532  pMgmt->abyIBSSSuppRates[2] |= BIT7;
533  pMgmt->abyIBSSSuppRates[3] |= BIT7;
534  } else if (sStartAPCmd.byBasicRate & BIT1) {
535  pMgmt->abyIBSSSuppRates[2] |= BIT7;
536  } else {
537  /* default 1,2M */
538  pMgmt->abyIBSSSuppRates[2] |= BIT7;
539  pMgmt->abyIBSSSuppRates[3] |= BIT7;
540  }
541 
542  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %*ph\n",
543  4, pMgmt->abyIBSSSuppRates + 2);
544 
545  netif_stop_queue(pDevice->dev);
546  spin_lock_irq(&pDevice->lock);
547  bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL);
548  spin_unlock_irq(&pDevice->lock);
549  break;
550 
552  cbListCount = 0;
553  pNode = &(pMgmt->sNodeDBTable[0]);
554  for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
555  pNode = &(pMgmt->sNodeDBTable[ii]);
556  if (!pNode->bActive)
557  continue;
558  cbListCount++;
559  }
560 
561  sNodeList.uItem = cbListCount;
562  if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
563  result = -EFAULT;
564  break;
565  }
566  pReq->wResult = 0;
567  break;
568 
570  if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
571  result = -EFAULT;
572  break;
573  }
574  if (sNodeList.uItem > (ULONG_MAX - sizeof(SNodeList)) / sizeof(SNodeItem)) {
575  result = -EINVAL;
576  break;
577  }
578  pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
579  if (pNodeList == NULL) {
580  result = -ENOMEM;
581  break;
582  }
583  pNodeList->uItem = sNodeList.uItem;
584  pNode = &(pMgmt->sNodeDBTable[0]);
585  for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) {
586  pNode = &(pMgmt->sNodeDBTable[ii]);
587  if (pNode->bActive) {
588  pNodeList->sNodeList[jj].wAID = pNode->wAID;
589  memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN);
590  pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate;
591  pNodeList->sNodeList[jj].wInActiveCount = (unsigned short)pNode->uInActiveCount;
592  pNodeList->sNodeList[jj].wEnQueueCnt = (unsigned short)pNode->wEnQueueCnt;
593  pNodeList->sNodeList[jj].wFlags = (unsigned short)pNode->dwFlags;
594  pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable;
595  pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex;
596  pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength;
597  memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN);
598  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
599  pNodeList->sNodeList[jj].abyWepKey[0],
600  pNodeList->sNodeList[jj].abyWepKey[1],
601  pNodeList->sNodeList[jj].abyWepKey[2],
602  pNodeList->sNodeList[jj].abyWepKey[3],
603  pNodeList->sNodeList[jj].abyWepKey[4]);
604  pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback;
605  pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures;
606  pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts;
607  pNodeList->sNodeList[jj].wFailureRatio = (unsigned short)pNode->uFailureRatio;
608  jj++;
609  if (jj >= pNodeList->uItem)
610  break;
611  }
612  }
613  if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
614  result = -EFAULT;
615  break;
616  }
617  kfree(pNodeList);
618  pReq->wResult = 0;
619  break;
620 
621 #ifdef WPA_SM_Transtatus
622  case 0xFF:
623  memset(wpa_Result.ifname, 0, sizeof(wpa_Result.ifname));
624  wpa_Result.proto = 0;
625  wpa_Result.key_mgmt = 0;
626  wpa_Result.eap_type = 0;
627  wpa_Result.authenticated = false;
628  pDevice->fWPA_Authened = false;
629  if (copy_from_user(&wpa_Result, pReq->data, sizeof(wpa_Result))) {
630  result = -EFAULT;
631  break;
632  }
633 
634  if (wpa_Result.authenticated == true) {
635 #ifdef SndEvt_ToAPI
636  {
637  union iwreq_data wrqu;
638 
639  pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
640 
641  memset(&wrqu, 0, sizeof(wrqu));
642  wrqu.data.flags = RT_WPACONNECTED_EVENT_FLAG;
643  wrqu.data.length = pItemSSID->len;
644  wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pItemSSID->abySSID);
645  }
646 #endif
647  pDevice->fWPA_Authened = true; /* is successful peer to wpa_Result.authenticated? */
648  }
649  pReq->wResult = 0;
650  break;
651 #endif
652 
653  default:
654  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n");
655  }
656 
657  return result;
658 }