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