Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: vt6655: dead code remove wpactl.c/h

All these functions are now dead.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Malcolm Priestley and committed by
Greg Kroah-Hartman
2759e217 ee146490

-959
-1
drivers/staging/vt6655/Makefile
··· 27 27 michael.o \ 28 28 wroute.o \ 29 29 rf.o \ 30 - wpactl.o \ 31 30 wpa2.o \ 32 31 aes_ccmp.o \ 33 32 vntwifi.o \
-1
drivers/staging/vt6655/device_main.c
··· 68 68 #include "rxtx.h" 69 69 #include "wroute.h" 70 70 #include "bssdb.h" 71 - #include "wpactl.h" 72 71 #include "dpc.h" 73 72 #include "datarate.h" 74 73 #include "rf.h"
-893
drivers/staging/vt6655/wpactl.c
··· 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 - * 20 - * File: wpactl.c 21 - * 22 - * Purpose: handle wpa supplicant ioctl input/out functions 23 - * 24 - * Author: Lyndon Chen 25 - * 26 - * Date: Oct. 20, 2003 27 - * 28 - * Functions: 29 - * 30 - * Revision History: 31 - * 32 - */ 33 - 34 - #include "wpactl.h" 35 - #include "key.h" 36 - #include "mac.h" 37 - #include "device.h" 38 - #include "wmgr.h" 39 - #include "iocmd.h" 40 - #include "iowpa.h" 41 - #include "rf.h" 42 - 43 - /*--------------------- Static Definitions -------------------------*/ 44 - 45 - #define VIAWGET_WPA_MAX_BUF_SIZE 1024 46 - 47 - static const int frequency_list[] = { 48 - 2412, 2417, 2422, 2427, 2432, 2437, 2442, 49 - 2447, 2452, 2457, 2462, 2467, 2472, 2484 50 - }; 51 - /*--------------------- Static Classes ----------------------------*/ 52 - 53 - /*--------------------- Static Functions --------------------------*/ 54 - 55 - /*--------------------- Export Variables --------------------------*/ 56 - static void wpadev_setup(struct net_device *dev) 57 - { 58 - dev->type = ARPHRD_IEEE80211; 59 - dev->hard_header_len = ETH_HLEN; 60 - dev->mtu = 2048; 61 - dev->addr_len = ETH_ALEN; 62 - dev->tx_queue_len = 1000; 63 - 64 - memset(dev->broadcast, 0xFF, ETH_ALEN); 65 - 66 - dev->flags = IFF_BROADCAST|IFF_MULTICAST; 67 - } 68 - 69 - /* 70 - * Description: 71 - * register netdev for wpa supplicant daemon 72 - * 73 - * Parameters: 74 - * In: 75 - * pDevice - 76 - * enable - 77 - * Out: 78 - * 79 - * Return Value: 80 - * 81 - */ 82 - 83 - static int wpa_init_wpadev(struct vnt_private *pDevice) 84 - { 85 - struct vnt_private *wpadev_priv; 86 - struct net_device *dev = pDevice->dev; 87 - int ret = 0; 88 - 89 - pDevice->wpadev = alloc_netdev(sizeof(*wpadev_priv), "vntwpa", 90 - NET_NAME_UNKNOWN, wpadev_setup); 91 - if (pDevice->wpadev == NULL) 92 - return -ENOMEM; 93 - 94 - wpadev_priv = netdev_priv(pDevice->wpadev); 95 - *wpadev_priv = *pDevice; 96 - eth_hw_addr_inherit(pDevice->wpadev, dev); 97 - pDevice->wpadev->base_addr = dev->base_addr; 98 - pDevice->wpadev->irq = dev->irq; 99 - pDevice->wpadev->mem_start = dev->mem_start; 100 - pDevice->wpadev->mem_end = dev->mem_end; 101 - ret = register_netdev(pDevice->wpadev); 102 - if (ret) { 103 - pr_debug("%s: register_netdev(WPA) failed!\n", dev->name); 104 - free_netdev(pDevice->wpadev); 105 - return -1; 106 - } 107 - 108 - if (pDevice->skb == NULL) { 109 - pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); 110 - if (pDevice->skb == NULL) 111 - return -ENOMEM; 112 - } 113 - 114 - pr_debug("%s: Registered netdev %s for WPA management\n", 115 - dev->name, pDevice->wpadev->name); 116 - 117 - return 0; 118 - } 119 - 120 - /* 121 - * Description: 122 - * unregister net_device (wpadev) 123 - * 124 - * Parameters: 125 - * In: 126 - * pDevice - 127 - * Out: 128 - * 129 - * Return Value: 130 - * 131 - */ 132 - 133 - static int wpa_release_wpadev(struct vnt_private *pDevice) 134 - { 135 - if (pDevice->skb) { 136 - dev_kfree_skb(pDevice->skb); 137 - pDevice->skb = NULL; 138 - } 139 - 140 - if (pDevice->wpadev) { 141 - pr_debug("%s: Netdevice %s unregistered\n", 142 - pDevice->dev->name, pDevice->wpadev->name); 143 - unregister_netdev(pDevice->wpadev); 144 - free_netdev(pDevice->wpadev); 145 - pDevice->wpadev = NULL; 146 - } 147 - 148 - return 0; 149 - } 150 - 151 - /* 152 - * Description: 153 - * Set enable/disable dev for wpa supplicant daemon 154 - * 155 - * Parameters: 156 - * In: 157 - * pDevice - 158 - * val - 159 - * Out: 160 - * 161 - * Return Value: 162 - * 163 - */ 164 - 165 - int wpa_set_wpadev(struct vnt_private *pDevice, int val) 166 - { 167 - if (val) 168 - return wpa_init_wpadev(pDevice); 169 - else 170 - return wpa_release_wpadev(pDevice); 171 - } 172 - 173 - /* 174 - * Description: 175 - * Set WPA algorithm & keys 176 - * 177 - * Parameters: 178 - * In: 179 - * pDevice - 180 - * param - 181 - * Out: 182 - * 183 - * Return Value: 184 - * 185 - */ 186 - 187 - int wpa_set_keys(struct vnt_private *pDevice, void *ctx, 188 - bool fcpfkernel) __must_hold(&pDevice->lock) 189 - { 190 - struct viawget_wpa_param *param = ctx; 191 - PSMgmtObject pMgmt = pDevice->pMgmt; 192 - unsigned long dwKeyIndex = 0; 193 - unsigned char abyKey[MAX_KEY_LEN]; 194 - unsigned char abySeq[MAX_KEY_LEN]; 195 - u64 KeyRSC; 196 - unsigned char byKeyDecMode = KEY_CTL_WEP; 197 - int ret = 0; 198 - int uu, ii; 199 - 200 - if (param->u.wpa_key.alg_name > WPA_ALG_CCMP || 201 - param->u.wpa_key.key_len > MAX_KEY_LEN || 202 - param->u.wpa_key.seq_len > MAX_KEY_LEN) 203 - return -EINVAL; 204 - 205 - pr_debug("param->u.wpa_key.alg_name = %d\n", param->u.wpa_key.alg_name); 206 - if (param->u.wpa_key.alg_name == WPA_ALG_NONE) { 207 - pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; 208 - pDevice->bEncryptionEnable = false; 209 - pDevice->byKeyIndex = 0; 210 - pDevice->bTransmitKey = false; 211 - KeyvRemoveAllWEPKey(&(pDevice->sKey), pDevice->PortOffset); 212 - for (uu = 0; uu < MAX_KEY_TABLE; uu++) 213 - MACvDisableKeyEntry(pDevice->PortOffset, uu); 214 - 215 - return ret; 216 - } 217 - 218 - if (param->u.wpa_key.key && fcpfkernel) { 219 - memcpy(&abyKey[0], param->u.wpa_key.key, param->u.wpa_key.key_len); 220 - } else { 221 - spin_unlock_irq(&pDevice->lock); 222 - if (param->u.wpa_key.key && 223 - copy_from_user(&abyKey[0], 224 - (void __user *)param->u.wpa_key.key, 225 - param->u.wpa_key.key_len)) { 226 - spin_lock_irq(&pDevice->lock); 227 - return -EINVAL; 228 - } 229 - spin_lock_irq(&pDevice->lock); 230 - } 231 - 232 - dwKeyIndex = (unsigned long)(param->u.wpa_key.key_index); 233 - 234 - if (param->u.wpa_key.alg_name == WPA_ALG_WEP) { 235 - if (dwKeyIndex > 3) { 236 - return -EINVAL; 237 - } else { 238 - if (param->u.wpa_key.set_tx) { 239 - pDevice->byKeyIndex = (unsigned char)dwKeyIndex; 240 - pDevice->bTransmitKey = true; 241 - dwKeyIndex |= (1 << 31); 242 - } 243 - KeybSetDefaultKey(&(pDevice->sKey), 244 - dwKeyIndex & ~(BIT30 | USE_KEYRSC), 245 - param->u.wpa_key.key_len, 246 - NULL, 247 - abyKey, 248 - KEY_CTL_WEP, 249 - pDevice->PortOffset, 250 - pDevice->byLocalID); 251 - 252 - } 253 - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; 254 - pDevice->bEncryptionEnable = true; 255 - return ret; 256 - } 257 - 258 - if (param->u.wpa_key.seq && fcpfkernel) { 259 - memcpy(&abySeq[0], param->u.wpa_key.seq, param->u.wpa_key.seq_len); 260 - } else { 261 - spin_unlock_irq(&pDevice->lock); 262 - if (param->u.wpa_key.seq && 263 - copy_from_user(&abySeq[0], 264 - (void __user *)param->u.wpa_key.seq, 265 - param->u.wpa_key.seq_len)) { 266 - spin_lock_irq(&pDevice->lock); 267 - return -EINVAL; 268 - } 269 - spin_lock_irq(&pDevice->lock); 270 - } 271 - 272 - if (param->u.wpa_key.seq_len > 0) { 273 - for (ii = 0; ii < param->u.wpa_key.seq_len; ii++) { 274 - if (ii < 4) 275 - KeyRSC |= (u64)(abySeq[ii] << (ii * 8)); 276 - else 277 - KeyRSC |= (u64)(abySeq[ii] << ((ii-4) * 8)); 278 - } 279 - dwKeyIndex |= 1 << 29; 280 - } 281 - 282 - if (param->u.wpa_key.key_index >= MAX_GROUP_KEY) { 283 - pr_debug("return dwKeyIndex > 3\n"); 284 - return -EINVAL; 285 - } 286 - 287 - if (param->u.wpa_key.alg_name == WPA_ALG_TKIP) 288 - pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; 289 - 290 - if (param->u.wpa_key.alg_name == WPA_ALG_CCMP) 291 - pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; 292 - 293 - if (param->u.wpa_key.set_tx) 294 - dwKeyIndex |= (1 << 31); 295 - 296 - if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) 297 - byKeyDecMode = KEY_CTL_CCMP; 298 - else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) 299 - byKeyDecMode = KEY_CTL_TKIP; 300 - else 301 - byKeyDecMode = KEY_CTL_WEP; 302 - 303 - /* Fix HCT test that set 256 bits KEY and Ndis802_11Encryption3Enabled */ 304 - if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { 305 - if (param->u.wpa_key.key_len == MAX_KEY_LEN) 306 - byKeyDecMode = KEY_CTL_TKIP; 307 - else if (param->u.wpa_key.key_len == WLAN_WEP40_KEYLEN) 308 - byKeyDecMode = KEY_CTL_WEP; 309 - else if (param->u.wpa_key.key_len == WLAN_WEP104_KEYLEN) 310 - byKeyDecMode = KEY_CTL_WEP; 311 - } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { 312 - if (param->u.wpa_key.key_len == WLAN_WEP40_KEYLEN) 313 - byKeyDecMode = KEY_CTL_WEP; 314 - else if (param->u.wpa_key.key_len == WLAN_WEP104_KEYLEN) 315 - byKeyDecMode = KEY_CTL_WEP; 316 - } 317 - 318 - /* Check TKIP key length */ 319 - if ((byKeyDecMode == KEY_CTL_TKIP) && 320 - (param->u.wpa_key.key_len != MAX_KEY_LEN)) { 321 - /* TKIP Key must be 256 bits */ 322 - pr_debug("return- TKIP Key must be 256 bits!\n"); 323 - return -EINVAL; 324 - } 325 - /* Check AES key length */ 326 - if ((byKeyDecMode == KEY_CTL_CCMP) && 327 - (param->u.wpa_key.key_len != AES_KEY_LEN)) { 328 - /* AES Key must be 128 bits */ 329 - return -EINVAL; 330 - } 331 - 332 - /* spin_lock_irq(&pDevice->lock); */ 333 - if (is_broadcast_ether_addr(&param->addr[0]) || (param->addr == NULL)) { 334 - /* If is_broadcast_ether_addr, set the key as every key entry's group key. */ 335 - pr_debug("Groupe Key Assign\n"); 336 - 337 - if (KeybSetAllGroupKey(&(pDevice->sKey), 338 - dwKeyIndex, 339 - param->u.wpa_key.key_len, 340 - (u64 *) &KeyRSC, 341 - (unsigned char *)abyKey, 342 - byKeyDecMode, 343 - pDevice->PortOffset, 344 - pDevice->byLocalID) && 345 - KeybSetDefaultKey(&(pDevice->sKey), 346 - dwKeyIndex, 347 - param->u.wpa_key.key_len, 348 - (u64 *) &KeyRSC, 349 - (unsigned char *)abyKey, 350 - byKeyDecMode, 351 - pDevice->PortOffset, 352 - pDevice->byLocalID)) { 353 - pr_debug("GROUP Key Assign\n"); 354 - 355 - } else { 356 - return -EINVAL; 357 - } 358 - 359 - } else { 360 - pr_debug("Pairwise Key Assign\n"); 361 - /* BSSID not 0xffffffffffff */ 362 - /* Pairwise Key can't be WEP */ 363 - if (byKeyDecMode == KEY_CTL_WEP) { 364 - pr_debug("Pairwise Key can't be WEP\n"); 365 - return -EINVAL; 366 - } 367 - 368 - dwKeyIndex |= (1 << 30); /* set pairwise key */ 369 - if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) 370 - return -EINVAL; 371 - 372 - if (KeybSetKey(&(pDevice->sKey), 373 - &param->addr[0], 374 - dwKeyIndex, 375 - param->u.wpa_key.key_len, 376 - (u64 *) &KeyRSC, 377 - (unsigned char *)abyKey, 378 - byKeyDecMode, 379 - pDevice->PortOffset, 380 - pDevice->byLocalID)) { 381 - pr_debug("Pairwise Key Set\n"); 382 - 383 - } else { 384 - /* Key Table Full */ 385 - return -EINVAL; 386 - } 387 - } /* BSSID not 0xffffffffffff */ 388 - if ((ret == 0) && ((param->u.wpa_key.set_tx) != 0)) { 389 - pDevice->byKeyIndex = (unsigned char)param->u.wpa_key.key_index; 390 - pDevice->bTransmitKey = true; 391 - } 392 - pDevice->bEncryptionEnable = true; 393 - 394 - return ret; 395 - } 396 - 397 - /* 398 - * Description: 399 - * enable wpa auth & mode 400 - * 401 - * Parameters: 402 - * In: 403 - * pDevice - 404 - * param - 405 - * Out: 406 - * 407 - * Return Value: 408 - * 409 - */ 410 - 411 - static int wpa_set_wpa(struct vnt_private *pDevice, 412 - struct viawget_wpa_param *param) 413 - { 414 - PSMgmtObject pMgmt = pDevice->pMgmt; 415 - 416 - pMgmt->eAuthenMode = WMAC_AUTH_OPEN; 417 - pMgmt->bShareKeyAlgorithm = false; 418 - 419 - return 0; 420 - } 421 - 422 - /* 423 - * Description: 424 - * set disassociate 425 - * 426 - * Parameters: 427 - * In: 428 - * pDevice - 429 - * param - 430 - * Out: 431 - * 432 - * Return Value: 433 - * 434 - */ 435 - 436 - static int wpa_set_disassociate(struct vnt_private *pDevice, 437 - struct viawget_wpa_param *param) 438 - { 439 - PSMgmtObject pMgmt = pDevice->pMgmt; 440 - 441 - spin_lock_irq(&pDevice->lock); 442 - if (pDevice->bLinkPass) { 443 - if (!memcmp(param->addr, pMgmt->abyCurrBSSID, 6)) 444 - bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL); 445 - } 446 - spin_unlock_irq(&pDevice->lock); 447 - 448 - return 0; 449 - } 450 - 451 - /* 452 - * Description: 453 - * enable scan process 454 - * 455 - * Parameters: 456 - * In: 457 - * pDevice - 458 - * param - 459 - * Out: 460 - * 461 - * Return Value: 462 - * 463 - */ 464 - 465 - static int wpa_set_scan(struct vnt_private *pDevice, 466 - struct viawget_wpa_param *param) 467 - { 468 - spin_lock_irq(&pDevice->lock); 469 - BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); 470 - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL); 471 - spin_unlock_irq(&pDevice->lock); 472 - 473 - return 0; 474 - } 475 - 476 - /* 477 - * Description: 478 - * get bssid 479 - * 480 - * Parameters: 481 - * In: 482 - * pDevice - 483 - * param - 484 - * Out: 485 - * 486 - * Return Value: 487 - * 488 - */ 489 - 490 - static int wpa_get_bssid(struct vnt_private *pDevice, 491 - struct viawget_wpa_param *param) 492 - { 493 - PSMgmtObject pMgmt = pDevice->pMgmt; 494 - 495 - memcpy(param->u.wpa_associate.bssid, pMgmt->abyCurrBSSID , 6); 496 - 497 - return 0; 498 - } 499 - 500 - /* 501 - * Description: 502 - * get bssid 503 - * 504 - * Parameters: 505 - * In: 506 - * pDevice - 507 - * param - 508 - * Out: 509 - * 510 - * Return Value: 511 - * 512 - */ 513 - 514 - static int wpa_get_ssid(struct vnt_private *pDevice, 515 - struct viawget_wpa_param *param) 516 - { 517 - PSMgmtObject pMgmt = pDevice->pMgmt; 518 - PWLAN_IE_SSID pItemSSID; 519 - 520 - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; 521 - 522 - memcpy(param->u.wpa_associate.ssid, pItemSSID->abySSID , pItemSSID->len); 523 - param->u.wpa_associate.ssid_len = pItemSSID->len; 524 - 525 - return 0; 526 - } 527 - 528 - /* 529 - * Description: 530 - * get scan results 531 - * 532 - * Parameters: 533 - * In: 534 - * pDevice - 535 - * param - 536 - * Out: 537 - * 538 - * Return Value: 539 - * 540 - */ 541 - 542 - static int wpa_get_scan(struct vnt_private *pDevice, 543 - struct viawget_wpa_param *param) 544 - { 545 - struct viawget_scan_result *scan_buf; 546 - PSMgmtObject pMgmt = pDevice->pMgmt; 547 - PWLAN_IE_SSID pItemSSID; 548 - PKnownBSS pBSS; 549 - unsigned char *pBuf; 550 - int ret = 0; 551 - u16 count = 0; 552 - u16 ii, jj; 553 - unsigned char *ptempBSS; 554 - 555 - ptempBSS = kmalloc(sizeof(KnownBSS), GFP_ATOMIC); 556 - 557 - if (ptempBSS == NULL) { 558 - pr_err("bubble sort kmalloc memory fail@@@\n"); 559 - 560 - ret = -ENOMEM; 561 - 562 - return ret; 563 - 564 - } 565 - 566 - for (ii = 0; ii < MAX_BSS_NUM; ii++) { 567 - for (jj = 0; jj < MAX_BSS_NUM - ii - 1; jj++) { 568 - if ((pMgmt->sBSSList[jj].bActive != true) || 569 - 570 - ((pMgmt->sBSSList[jj].uRSSI > pMgmt->sBSSList[jj + 1].uRSSI) && (pMgmt->sBSSList[jj + 1].bActive != false))) { 571 - memcpy(ptempBSS, &pMgmt->sBSSList[jj], sizeof(KnownBSS)); 572 - 573 - memcpy(&pMgmt->sBSSList[jj], &pMgmt->sBSSList[jj + 1], sizeof(KnownBSS)); 574 - 575 - memcpy(&pMgmt->sBSSList[jj + 1], ptempBSS, sizeof(KnownBSS)); 576 - 577 - } 578 - 579 - } 580 - 581 - } 582 - 583 - kfree(ptempBSS); 584 - 585 - //******mike:bubble sort by stronger RSSI*****// 586 - 587 - count = 0; 588 - pBSS = &(pMgmt->sBSSList[0]); 589 - for (ii = 0; ii < MAX_BSS_NUM; ii++) { 590 - pBSS = &(pMgmt->sBSSList[ii]); 591 - if (!pBSS->bActive) 592 - continue; 593 - count++; 594 - } 595 - 596 - pBuf = kcalloc(count, sizeof(struct viawget_scan_result), GFP_ATOMIC); 597 - 598 - if (pBuf == NULL) { 599 - ret = -ENOMEM; 600 - return ret; 601 - } 602 - scan_buf = (struct viawget_scan_result *)pBuf; 603 - pBSS = &(pMgmt->sBSSList[0]); 604 - for (ii = 0, jj = 0; ii < MAX_BSS_NUM; ii++) { 605 - pBSS = &(pMgmt->sBSSList[ii]); 606 - if (pBSS->bActive) { 607 - if (jj >= count) 608 - break; 609 - memcpy(scan_buf->bssid, pBSS->abyBSSID, WLAN_BSSID_LEN); 610 - pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; 611 - memcpy(scan_buf->ssid, pItemSSID->abySSID, pItemSSID->len); 612 - scan_buf->ssid_len = pItemSSID->len; 613 - scan_buf->freq = frequency_list[pBSS->uChannel-1]; 614 - scan_buf->caps = pBSS->wCapInfo; 615 - 616 - if (pBSS->wWPALen != 0) { 617 - scan_buf->wpa_ie_len = pBSS->wWPALen; 618 - memcpy(scan_buf->wpa_ie, pBSS->byWPAIE, pBSS->wWPALen); 619 - } 620 - if (pBSS->wRSNLen != 0) { 621 - scan_buf->rsn_ie_len = pBSS->wRSNLen; 622 - memcpy(scan_buf->rsn_ie, pBSS->byRSNIE, pBSS->wRSNLen); 623 - } 624 - scan_buf = (struct viawget_scan_result *)((unsigned char *)scan_buf + sizeof(struct viawget_scan_result)); 625 - jj++; 626 - } 627 - } 628 - 629 - if (jj < count) 630 - count = jj; 631 - 632 - if (copy_to_user(param->u.scan_results.buf, pBuf, sizeof(struct viawget_scan_result) * count)) 633 - ret = -EFAULT; 634 - 635 - param->u.scan_results.scan_count = count; 636 - pr_debug(" param->u.scan_results.scan_count = %d\n", count); 637 - 638 - kfree(pBuf); 639 - return ret; 640 - } 641 - 642 - /* 643 - * Description: 644 - * set associate with AP 645 - * 646 - * Parameters: 647 - * In: 648 - * pDevice - 649 - * param - 650 - * Out: 651 - * 652 - * Return Value: 653 - * 654 - */ 655 - 656 - static int wpa_set_associate(struct vnt_private *pDevice, 657 - struct viawget_wpa_param *param) 658 - { 659 - PSMgmtObject pMgmt = pDevice->pMgmt; 660 - PWLAN_IE_SSID pItemSSID; 661 - unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 662 - unsigned char abyWPAIE[64]; 663 - bool bWepEnabled = false; 664 - 665 - /* set key type & algorithm */ 666 - pr_debug("pairwise_suite = %d\n", 667 - param->u.wpa_associate.pairwise_suite); 668 - pr_debug("group_suite = %d\n", param->u.wpa_associate.group_suite); 669 - pr_debug("key_mgmt_suite = %d\n", 670 - param->u.wpa_associate.key_mgmt_suite); 671 - pr_debug("auth_alg = %d\n", param->u.wpa_associate.auth_alg); 672 - pr_debug("mode = %d\n", param->u.wpa_associate.mode); 673 - pr_debug("wpa_ie_len = %d\n", param->u.wpa_associate.wpa_ie_len); 674 - 675 - if (param->u.wpa_associate.wpa_ie_len) { 676 - if (!param->u.wpa_associate.wpa_ie) 677 - return -EINVAL; 678 - if (param->u.wpa_associate.wpa_ie_len > sizeof(abyWPAIE)) 679 - return -EINVAL; 680 - if (copy_from_user(&abyWPAIE[0], param->u.wpa_associate.wpa_ie, param->u.wpa_associate.wpa_ie_len)) 681 - return -EFAULT; 682 - } 683 - 684 - if (param->u.wpa_associate.mode == 1) 685 - pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; 686 - else 687 - pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; 688 - /* set ssid */ 689 - memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); 690 - pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; 691 - pItemSSID->byElementID = WLAN_EID_SSID; 692 - pItemSSID->len = param->u.wpa_associate.ssid_len; 693 - memcpy(pItemSSID->abySSID, param->u.wpa_associate.ssid, pItemSSID->len); 694 - /* set bssid */ 695 - if (memcmp(param->u.wpa_associate.bssid, &abyNullAddr[0], 6) != 0) 696 - memcpy(pMgmt->abyDesireBSSID, param->u.wpa_associate.bssid, 6); 697 - else 698 - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pItemSSID->abySSID); 699 - 700 - if (param->u.wpa_associate.wpa_ie_len == 0) { 701 - if (param->u.wpa_associate.auth_alg & AUTH_ALG_SHARED_KEY) 702 - pMgmt->eAuthenMode = WMAC_AUTH_SHAREKEY; 703 - else 704 - pMgmt->eAuthenMode = WMAC_AUTH_OPEN; 705 - } else if (abyWPAIE[0] == RSN_INFO_ELEM) { 706 - if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_PSK) 707 - pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK; 708 - else 709 - pMgmt->eAuthenMode = WMAC_AUTH_WPA2; 710 - } else { 711 - if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_WPA_NONE) 712 - pMgmt->eAuthenMode = WMAC_AUTH_WPANONE; 713 - else if (param->u.wpa_associate.key_mgmt_suite == KEY_MGMT_PSK) 714 - pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK; 715 - else 716 - pMgmt->eAuthenMode = WMAC_AUTH_WPA; 717 - } 718 - 719 - switch (param->u.wpa_associate.pairwise_suite) { 720 - case CIPHER_CCMP: 721 - pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; 722 - break; 723 - case CIPHER_TKIP: 724 - pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; 725 - break; 726 - case CIPHER_WEP40: 727 - case CIPHER_WEP104: 728 - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; 729 - bWepEnabled = true; 730 - break; 731 - case CIPHER_NONE: 732 - if (param->u.wpa_associate.group_suite == CIPHER_CCMP) 733 - pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; 734 - else 735 - pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; 736 - break; 737 - default: 738 - pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; 739 - } 740 - 741 - //DavidWang add for WPA_supplicant support open/share mode 742 - 743 - if (pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) { 744 - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; 745 - pMgmt->bShareKeyAlgorithm = true; 746 - } else if (pMgmt->eAuthenMode == WMAC_AUTH_OPEN) { 747 - if (!bWepEnabled) pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; 748 - else pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; 749 - } 750 - //mike save old encryption status 751 - pDevice->eOldEncryptionStatus = pDevice->eEncryptionStatus; 752 - 753 - if (pDevice->eEncryptionStatus != Ndis802_11EncryptionDisabled) 754 - pDevice->bEncryptionEnable = true; 755 - else 756 - pDevice->bEncryptionEnable = false; 757 - if (!((pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) || 758 - ((pMgmt->eAuthenMode == WMAC_AUTH_OPEN) && bWepEnabled))) //DavidWang //20080717-06,<Modify> by chester//Not to initial WEP 759 - KeyvInitTable(&pDevice->sKey, pDevice->PortOffset); 760 - spin_lock_irq(&pDevice->lock); 761 - pDevice->bLinkPass = false; 762 - memset(pMgmt->abyCurrBSSID, 0, 6); 763 - pMgmt->eCurrState = WMAC_STATE_IDLE; 764 - netif_stop_queue(pDevice->dev); 765 - //20080701-02,<Add> by Mike Liu 766 - /*******search if ap_scan=2 ,which is associating request in hidden ssid mode ****/ 767 - { 768 - PKnownBSS pCurr = NULL; 769 - 770 - pCurr = BSSpSearchBSSList(pDevice, 771 - pMgmt->abyDesireBSSID, 772 - pMgmt->abyDesireSSID, 773 - pMgmt->eConfigPHYMode 774 - ); 775 - 776 - if (pCurr == NULL) { 777 - pr_debug("wpa_set_associate---->hidden mode site survey before associate.......\n"); 778 - bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); 779 - } 780 - } 781 - /****************************************************************/ 782 - bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL); 783 - spin_unlock_irq(&pDevice->lock); 784 - 785 - return 0; 786 - } 787 - 788 - /* 789 - * Description: 790 - * wpa_ioctl main function supported for wpa supplicant 791 - * 792 - * Parameters: 793 - * In: 794 - * pDevice - 795 - * iw_point - 796 - * Out: 797 - * 798 - * Return Value: 799 - * 800 - */ 801 - 802 - int wpa_ioctl(struct vnt_private *pDevice, struct iw_point *p) 803 - { 804 - struct viawget_wpa_param *param; 805 - int ret = 0; 806 - int wpa_ioctl = 0; 807 - 808 - if (p->length < sizeof(struct viawget_wpa_param) || 809 - p->length > VIAWGET_WPA_MAX_BUF_SIZE || !p->pointer) 810 - return -EINVAL; 811 - 812 - param = kmalloc((int)p->length, GFP_KERNEL); 813 - if (param == NULL) 814 - return -ENOMEM; 815 - 816 - if (copy_from_user(param, p->pointer, p->length)) { 817 - ret = -EFAULT; 818 - goto out; 819 - } 820 - 821 - switch (param->cmd) { 822 - case VIAWGET_SET_WPA: 823 - ret = wpa_set_wpa(pDevice, param); 824 - pr_debug("VIAWGET_SET_WPA\n"); 825 - break; 826 - 827 - case VIAWGET_SET_KEY: 828 - pr_debug("VIAWGET_SET_KEY\n"); 829 - spin_lock_irq(&pDevice->lock); 830 - ret = wpa_set_keys(pDevice, param, false); 831 - spin_unlock_irq(&pDevice->lock); 832 - break; 833 - 834 - case VIAWGET_SET_SCAN: 835 - pr_debug("VIAWGET_SET_SCAN\n"); 836 - ret = wpa_set_scan(pDevice, param); 837 - break; 838 - 839 - case VIAWGET_GET_SCAN: 840 - pr_debug("VIAWGET_GET_SCAN\n"); 841 - ret = wpa_get_scan(pDevice, param); 842 - wpa_ioctl = 1; 843 - break; 844 - 845 - case VIAWGET_GET_SSID: 846 - pr_debug("VIAWGET_GET_SSID\n"); 847 - ret = wpa_get_ssid(pDevice, param); 848 - wpa_ioctl = 1; 849 - break; 850 - 851 - case VIAWGET_GET_BSSID: 852 - pr_debug("VIAWGET_GET_BSSID\n"); 853 - ret = wpa_get_bssid(pDevice, param); 854 - wpa_ioctl = 1; 855 - break; 856 - 857 - case VIAWGET_SET_ASSOCIATE: 858 - pr_debug("VIAWGET_SET_ASSOCIATE\n"); 859 - ret = wpa_set_associate(pDevice, param); 860 - break; 861 - 862 - case VIAWGET_SET_DISASSOCIATE: 863 - pr_debug("VIAWGET_SET_DISASSOCIATE\n"); 864 - ret = wpa_set_disassociate(pDevice, param); 865 - break; 866 - 867 - case VIAWGET_SET_DROP_UNENCRYPT: 868 - pr_debug("VIAWGET_SET_DROP_UNENCRYPT\n"); 869 - break; 870 - 871 - case VIAWGET_SET_DEAUTHENTICATE: 872 - pr_debug("VIAWGET_SET_DEAUTHENTICATE\n"); 873 - break; 874 - 875 - default: 876 - pr_debug("wpa_ioctl: unknown cmd=%d\n", 877 - param->cmd); 878 - ret = -EOPNOTSUPP; 879 - goto out; 880 - } 881 - 882 - if ((ret == 0) && wpa_ioctl) { 883 - if (copy_to_user(p->pointer, param, p->length)) { 884 - ret = -EFAULT; 885 - goto out; 886 - } 887 - } 888 - 889 - out: 890 - kfree(param); 891 - 892 - return ret; 893 - }
-64
drivers/staging/vt6655/wpactl.h
··· 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: wpactl.h 20 - * 21 - * Purpose: 22 - * 23 - * Author: Lyndon Chen 24 - * 25 - * Date: March 1, 2005 26 - * 27 - */ 28 - 29 - #ifndef __WPACTL_H__ 30 - #define __WPACTL_H__ 31 - 32 - #include "device.h" 33 - #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT 34 - #include "iowpa.h" 35 - #endif 36 - 37 - /*--------------------- Export Definitions -------------------------*/ 38 - 39 - //WPA related 40 - 41 - enum wpa_alg { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP }; 42 - enum wpa_cipher { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP, 43 - CIPHER_WEP104 }; 44 - enum wpa_key_mgmt { KEY_MGMT_802_1X, KEY_MGMT_CCKM, KEY_MGMT_PSK, KEY_MGMT_NONE, 45 - KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE }; 46 - 47 - #define AUTH_ALG_OPEN_SYSTEM 0x01 48 - #define AUTH_ALG_SHARED_KEY 0x02 49 - #define AUTH_ALG_LEAP 0x04 50 - 51 - #define GENERIC_INFO_ELEM 0xdd 52 - #define RSN_INFO_ELEM 0x30 53 - 54 - /*--------------------- Export Classes ----------------------------*/ 55 - 56 - /*--------------------- Export Variables --------------------------*/ 57 - 58 - /*--------------------- Export Functions --------------------------*/ 59 - 60 - int wpa_set_wpadev(struct vnt_private *, int val); 61 - int wpa_ioctl(struct vnt_private *, struct iw_point *p); 62 - int wpa_set_keys(struct vnt_private *, void *ctx, bool fcpfkernel); 63 - 64 - #endif // __WPACL_H__