diff options
Diffstat (limited to 'drivers/staging/vt6655/wpactl.c')
| -rw-r--r-- | drivers/staging/vt6655/wpactl.c | 137 |
1 files changed, 44 insertions, 93 deletions
diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c index e8d9ecd2913..8392d4d1d5e 100644 --- a/drivers/staging/vt6655/wpactl.c +++ b/drivers/staging/vt6655/wpactl.c @@ -51,7 +51,6 @@ static const int frequency_list[] = { /*--------------------- Static Classes ----------------------------*/ /*--------------------- Static Variables --------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO; /*--------------------- Static Functions --------------------------*/ @@ -188,7 +187,8 @@ int wpa_set_wpadev(PSDevice pDevice, int val) * */ -int wpa_set_keys(PSDevice pDevice, void *ctx, bool fcpfkernel) +int wpa_set_keys(PSDevice pDevice, void *ctx, + bool fcpfkernel) __must_hold(&pDevice->lock) { struct viawget_wpa_param *param = ctx; PSMgmtObject pMgmt = pDevice->pMgmt; @@ -196,30 +196,28 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, bool fcpfkernel) unsigned char abyKey[MAX_KEY_LEN]; unsigned char abySeq[MAX_KEY_LEN]; QWORD KeyRSC; -// NDIS_802_11_KEY_RSC KeyRSC; unsigned char byKeyDecMode = KEY_CTL_WEP; int ret = 0; int uu, ii; if (param->u.wpa_key.alg_name > WPA_ALG_CCMP || - param->u.wpa_key.key_len >= MAX_KEY_LEN || - param->u.wpa_key.seq_len >= MAX_KEY_LEN) + param->u.wpa_key.key_len > MAX_KEY_LEN || + param->u.wpa_key.seq_len > MAX_KEY_LEN) return -EINVAL; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "param->u.wpa_key.alg_name = %d \n", param->u.wpa_key.alg_name); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "param->u.wpa_key.alg_name = %d\n", param->u.wpa_key.alg_name); if (param->u.wpa_key.alg_name == WPA_ALG_NONE) { pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; pDevice->bEncryptionEnable = false; pDevice->byKeyIndex = 0; pDevice->bTransmitKey = false; KeyvRemoveAllWEPKey(&(pDevice->sKey), pDevice->PortOffset); - for (uu = 0; uu < MAX_KEY_TABLE; uu++) { + for (uu = 0; uu < MAX_KEY_TABLE; uu++) MACvDisableKeyEntry(pDevice->PortOffset, uu); - } + return ret; } - //spin_unlock_irq(&pDevice->lock); if (param->u.wpa_key.key && fcpfkernel) { memcpy(&abyKey[0], param->u.wpa_key.key, param->u.wpa_key.key_len); } else { @@ -258,7 +256,6 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, bool fcpfkernel) return ret; } - //spin_unlock_irq(&pDevice->lock); if (param->u.wpa_key.seq && fcpfkernel) { memcpy(&abySeq[0], param->u.wpa_key.seq, param->u.wpa_key.seq_len); } else { @@ -277,7 +274,6 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, bool fcpfkernel) LODWORD(KeyRSC) |= (abySeq[ii] << (ii * 8)); else HIDWORD(KeyRSC) |= (abySeq[ii] << ((ii-4) * 8)); - //KeyRSC |= (abySeq[ii] << (ii * 8)); } dwKeyIndex |= 1 << 29; } @@ -287,13 +283,11 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, bool fcpfkernel) return -EINVAL; } - if (param->u.wpa_key.alg_name == WPA_ALG_TKIP) { + if (param->u.wpa_key.alg_name == WPA_ALG_TKIP) pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; - } - if (param->u.wpa_key.alg_name == WPA_ALG_CCMP) { + if (param->u.wpa_key.alg_name == WPA_ALG_CCMP) pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; - } if (param->u.wpa_key.set_tx) dwKeyIndex |= (1 << 31); @@ -324,7 +318,6 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, bool fcpfkernel) if ((byKeyDecMode == KEY_CTL_TKIP) && (param->u.wpa_key.key_len != MAX_KEY_LEN)) { // TKIP Key must be 256 bits - //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - TKIP Key must be 256 bits\n")); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "return- TKIP Key must be 256 bits!\n"); return -EINVAL; } @@ -332,7 +325,6 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, bool fcpfkernel) if ((byKeyDecMode == KEY_CTL_CCMP) && (param->u.wpa_key.key_len != AES_KEY_LEN)) { // AES Key must be 128 bits - //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - AES Key must be 128 bits\n")); return -EINVAL; } @@ -341,27 +333,25 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, bool fcpfkernel) // If is_broadcast_ether_addr, set the key as every key entry's group key. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Groupe Key Assign.\n"); - if ((KeybSetAllGroupKey(&(pDevice->sKey), + if (KeybSetAllGroupKey(&(pDevice->sKey), dwKeyIndex, param->u.wpa_key.key_len, (PQWORD) &(KeyRSC), (unsigned char *)abyKey, byKeyDecMode, pDevice->PortOffset, - pDevice->byLocalID) == true) && - (KeybSetDefaultKey(&(pDevice->sKey), + pDevice->byLocalID) && + KeybSetDefaultKey(&(pDevice->sKey), dwKeyIndex, param->u.wpa_key.key_len, (PQWORD) &(KeyRSC), (unsigned char *)abyKey, byKeyDecMode, pDevice->PortOffset, - pDevice->byLocalID) == true)) { + pDevice->byLocalID)) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "GROUP Key Assign.\n"); } else { - //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -KeybSetDefaultKey Fail.0\n")); - // spin_unlock_irq(&pDevice->lock); return -EINVAL; } @@ -371,16 +361,13 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, bool fcpfkernel) // Pairwise Key can't be WEP if (byKeyDecMode == KEY_CTL_WEP) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key can't be WEP\n"); - //spin_unlock_irq(&pDevice->lock); return -EINVAL; } dwKeyIndex |= (1 << 30); // set pairwise key - if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) { - //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - WMAC_CONFIG_IBSS_STA\n")); - //spin_unlock_irq(&pDevice->lock); + if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) return -EINVAL; - } + if (KeybSetKey(&(pDevice->sKey), ¶m->addr[0], dwKeyIndex, @@ -389,22 +376,12 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, bool fcpfkernel) (unsigned char *)abyKey, byKeyDecMode, pDevice->PortOffset, - pDevice->byLocalID) == true) { + pDevice->byLocalID)) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key Set\n"); } else { // Key Table Full - if (!compare_ether_addr(¶m->addr[0], pDevice->abyBSSID)) { - //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -Key Table Full.2\n")); - //spin_unlock_irq(&pDevice->lock); - return -EINVAL; - - } else { - // Save Key and configure just before associate/reassociate to BSSID - // we do not implement now - //spin_unlock_irq(&pDevice->lock); - return -EINVAL; - } + return -EINVAL; } } // BSSID not 0xffffffffffff if ((ret == 0) && ((param->u.wpa_key.set_tx) != 0)) { @@ -412,17 +389,6 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, bool fcpfkernel) pDevice->bTransmitKey = true; } pDevice->bEncryptionEnable = true; - //spin_unlock_irq(&pDevice->lock); - -/* - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " key=%x-%x-%x-%x-%x-xxxxx \n", - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][0], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][1], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][2], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][3], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][4] -); -*/ return ret; } @@ -445,12 +411,11 @@ static int wpa_set_wpa(PSDevice pDevice, struct viawget_wpa_param *param) { PSMgmtObject pMgmt = pDevice->pMgmt; - int ret = 0; pMgmt->eAuthenMode = WMAC_AUTH_OPEN; pMgmt->bShareKeyAlgorithm = false; - return ret; + return 0; } /* @@ -471,7 +436,6 @@ static int wpa_set_disassociate(PSDevice pDevice, struct viawget_wpa_param *param) { PSMgmtObject pMgmt = pDevice->pMgmt; - int ret = 0; spin_lock_irq(&pDevice->lock); if (pDevice->bLinkPass) { @@ -480,7 +444,7 @@ static int wpa_set_disassociate(PSDevice pDevice, } spin_unlock_irq(&pDevice->lock); - return ret; + return 0; } /* @@ -500,14 +464,12 @@ static int wpa_set_disassociate(PSDevice pDevice, static int wpa_set_scan(PSDevice pDevice, struct viawget_wpa_param *param) { - int ret = 0; - spin_lock_irq(&pDevice->lock); BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL); spin_unlock_irq(&pDevice->lock); - return ret; + return 0; } /* @@ -528,11 +490,10 @@ static int wpa_get_bssid(PSDevice pDevice, struct viawget_wpa_param *param) { PSMgmtObject pMgmt = pDevice->pMgmt; - int ret = 0; memcpy(param->u.wpa_associate.bssid, pMgmt->abyCurrBSSID , 6); - return ret; + return 0; } /* @@ -554,14 +515,13 @@ static int wpa_get_ssid(PSDevice pDevice, { PSMgmtObject pMgmt = pDevice->pMgmt; PWLAN_IE_SSID pItemSSID; - int ret = 0; pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; memcpy(param->u.wpa_associate.ssid, pItemSSID->abySSID , pItemSSID->len); param->u.wpa_associate.ssid_len = pItemSSID->len; - return ret; + return 0; } /* @@ -593,10 +553,10 @@ static int wpa_get_scan(PSDevice pDevice, unsigned char *ptempBSS; - ptempBSS = kmalloc(sizeof(KnownBSS), (int)GFP_ATOMIC); + ptempBSS = kmalloc(sizeof(KnownBSS), GFP_ATOMIC); if (ptempBSS == NULL) { - printk("bubble sort kmalloc memory fail@@@\n"); + printk(KERN_ERR "bubble sort kmalloc memory fail@@@\n"); ret = -ENOMEM; @@ -635,7 +595,7 @@ static int wpa_get_scan(PSDevice pDevice, count++; } - pBuf = kcalloc(count, sizeof(struct viawget_scan_result), (int)GFP_ATOMIC); + pBuf = kcalloc(count, sizeof(struct viawget_scan_result), GFP_ATOMIC); if (pBuf == NULL) { ret = -ENOMEM; @@ -654,11 +614,7 @@ static int wpa_get_scan(PSDevice pDevice, scan_buf->ssid_len = pItemSSID->len; scan_buf->freq = frequency_list[pBSS->uChannel-1]; scan_buf->caps = pBSS->wCapInfo; - //scan_buf->caps = pBSS->wCapInfo; - //scan_buf->qual = - //scan_buf->noise = - //scan_buf->level = - //scan_buf->maxrate = + if (pBSS->wWPALen != 0) { scan_buf->wpa_ie_len = pBSS->wWPALen; memcpy(scan_buf->wpa_ie, pBSS->byWPAIE, pBSS->wWPALen); @@ -675,11 +631,11 @@ static int wpa_get_scan(PSDevice pDevice, if (jj < count) count = jj; - if (copy_to_user(param->u.scan_results.buf, pBuf, sizeof(struct viawget_scan_result) * count)) { + if (copy_to_user(param->u.scan_results.buf, pBuf, sizeof(struct viawget_scan_result) * count)) ret = -EFAULT; - } + param->u.scan_results.scan_count = count; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " param->u.scan_results.scan_count = %d\n", count) + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " param->u.scan_results.scan_count = %d\n", count); kfree(pBuf); return ret; @@ -706,7 +662,6 @@ static int wpa_set_associate(PSDevice pDevice, PWLAN_IE_SSID pItemSSID; unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; unsigned char abyWPAIE[64]; - int ret = 0; bool bWepEnabled = false; // set key type & algorithm @@ -739,9 +694,8 @@ static int wpa_set_associate(PSDevice pDevice, // set bssid if (memcmp(param->u.wpa_associate.bssid, &abyNullAddr[0], 6) != 0) memcpy(pMgmt->abyDesireBSSID, param->u.wpa_associate.bssid, 6); - else { + else bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pItemSSID->abySSID); - } if (param->u.wpa_associate.wpa_ie_len == 0) { if (param->u.wpa_associate.auth_alg & AUTH_ALG_SHARED_KEY) @@ -788,13 +742,10 @@ static int wpa_set_associate(PSDevice pDevice, if (pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) { pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - //pMgmt->eAuthenMode = WMAC_AUTH_SHAREKEY; pMgmt->bShareKeyAlgorithm = true; } else if (pMgmt->eAuthenMode == WMAC_AUTH_OPEN) { if (!bWepEnabled) pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; else pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - //pMgmt->eAuthenMode = WMAC_AUTH_OPEN; - //pMgmt->bShareKeyAlgorithm = false; //20080717-06,<Modify> by chester//Fix Open mode, WEP encryption } //mike save old encryption status pDevice->eOldEncryptionStatus = pDevice->eEncryptionStatus; @@ -804,7 +755,7 @@ static int wpa_set_associate(PSDevice pDevice, else pDevice->bEncryptionEnable = false; if (!((pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) || - ((pMgmt->eAuthenMode == WMAC_AUTH_OPEN) && (bWepEnabled == true)))) //DavidWang //20080717-06,<Modify> by chester//Not to initial WEP + ((pMgmt->eAuthenMode == WMAC_AUTH_OPEN) && bWepEnabled))) //DavidWang //20080717-06,<Modify> by chester//Not to initial WEP KeyvInitTable(&pDevice->sKey, pDevice->PortOffset); spin_lock_irq(&pDevice->lock); pDevice->bLinkPass = false; @@ -830,7 +781,7 @@ static int wpa_set_associate(PSDevice pDevice, bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL); spin_unlock_irq(&pDevice->lock); - return ret; + return 0; } /* @@ -857,7 +808,7 @@ int wpa_ioctl(PSDevice pDevice, struct iw_point *p) p->length > VIAWGET_WPA_MAX_BUF_SIZE || !p->pointer) return -EINVAL; - param = kmalloc((int)p->length, (int)GFP_KERNEL); + param = kmalloc((int)p->length, GFP_KERNEL); if (param == NULL) return -ENOMEM; @@ -869,18 +820,18 @@ int wpa_ioctl(PSDevice pDevice, struct iw_point *p) switch (param->cmd) { case VIAWGET_SET_WPA: ret = wpa_set_wpa(pDevice, param); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_WPA \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_WPA\n"); break; case VIAWGET_SET_KEY: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_KEY \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_KEY\n"); spin_lock_irq(&pDevice->lock); ret = wpa_set_keys(pDevice, param, false); spin_unlock_irq(&pDevice->lock); break; case VIAWGET_SET_SCAN: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_SCAN \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_SCAN\n"); ret = wpa_set_scan(pDevice, param); break; @@ -891,40 +842,40 @@ int wpa_ioctl(PSDevice pDevice, struct iw_point *p) break; case VIAWGET_GET_SSID: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_GET_SSID \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_GET_SSID\n"); ret = wpa_get_ssid(pDevice, param); wpa_ioctl = 1; break; case VIAWGET_GET_BSSID: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_GET_BSSID \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_GET_BSSID\n"); ret = wpa_get_bssid(pDevice, param); wpa_ioctl = 1; break; case VIAWGET_SET_ASSOCIATE: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_ASSOCIATE \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_ASSOCIATE\n"); ret = wpa_set_associate(pDevice, param); break; case VIAWGET_SET_DISASSOCIATE: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_DISASSOCIATE \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_DISASSOCIATE\n"); ret = wpa_set_disassociate(pDevice, param); break; case VIAWGET_SET_DROP_UNENCRYPT: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_DROP_UNENCRYPT \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_DROP_UNENCRYPT\n"); break; case VIAWGET_SET_DEAUTHENTICATE: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_DEAUTHENTICATE \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_SET_DEAUTHENTICATE\n"); break; default: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_ioctl: unknown cmd=%d\n", param->cmd); - return -EOPNOTSUPP; - break; + ret = -EOPNOTSUPP; + goto out; } if ((ret == 0) && wpa_ioctl) { |
