diff options
Diffstat (limited to 'drivers/staging/vt6656/wpa2.c')
-rw-r--r-- | drivers/staging/vt6656/wpa2.c | 165 |
1 files changed, 18 insertions, 147 deletions
diff --git a/drivers/staging/vt6656/wpa2.c b/drivers/staging/vt6656/wpa2.c index a89456a..aa221618 100644 --- a/drivers/staging/vt6656/wpa2.c +++ b/drivers/staging/vt6656/wpa2.c @@ -34,28 +34,17 @@ #include "device.h" #include "wpa2.h" -/*--------------------- Static Definitions -------------------------*/ static int msglevel =MSG_LEVEL_INFO; //static int msglevel =MSG_LEVEL_DEBUG; -/*--------------------- Static Classes ----------------------------*/ -/*--------------------- Static Variables --------------------------*/ +const u8 abyOUIGK[4] = { 0x00, 0x0F, 0xAC, 0x00 }; +const u8 abyOUIWEP40[4] = { 0x00, 0x0F, 0xAC, 0x01 }; +const u8 abyOUIWEP104[4] = { 0x00, 0x0F, 0xAC, 0x05 }; +const u8 abyOUITKIP[4] = { 0x00, 0x0F, 0xAC, 0x02 }; +const u8 abyOUICCMP[4] = { 0x00, 0x0F, 0xAC, 0x04 }; -const BYTE abyOUIGK[4] = { 0x00, 0x0F, 0xAC, 0x00 }; -const BYTE abyOUIWEP40[4] = { 0x00, 0x0F, 0xAC, 0x01 }; -const BYTE abyOUIWEP104[4] = { 0x00, 0x0F, 0xAC, 0x05 }; -const BYTE abyOUITKIP[4] = { 0x00, 0x0F, 0xAC, 0x02 }; -const BYTE abyOUICCMP[4] = { 0x00, 0x0F, 0xAC, 0x04 }; - -const BYTE abyOUI8021X[4] = { 0x00, 0x0F, 0xAC, 0x01 }; -const BYTE abyOUIPSK[4] = { 0x00, 0x0F, 0xAC, 0x02 }; - - -/*--------------------- Static Functions --------------------------*/ - -/*--------------------- Export Variables --------------------------*/ - -/*--------------------- Export Functions --------------------------*/ +const u8 abyOUI8021X[4] = { 0x00, 0x0F, 0xAC, 0x01 }; +const u8 abyOUIPSK[4] = { 0x00, 0x0F, 0xAC, 0x02 }; /*+ * @@ -113,8 +102,8 @@ WPA2vParseRSN ( ) { int i, j; - WORD m = 0, n = 0; - PBYTE pbyOUI; + u16 m = 0, n = 0; + u8 * pbyOUI; bool bUseGK = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"WPA2_ParseRSN: [%d]\n", pRSN->len); @@ -163,11 +152,11 @@ WPA2vParseRSN ( } if (pRSN->len >= 8) { // ver(2) + GK(4) + PK count(2) - pBSSNode->wCSSPKCount = *((PWORD) &(pRSN->abyRSN[4])); + pBSSNode->wCSSPKCount = *((u16 *) &(pRSN->abyRSN[4])); j = 0; pbyOUI = &(pRSN->abyRSN[6]); - for (i = 0; (i < pBSSNode->wCSSPKCount) && (j < sizeof(pBSSNode->abyCSSPK)/sizeof(BYTE)); i++) { + for (i = 0; (i < pBSSNode->wCSSPKCount) && (j < sizeof(pBSSNode->abyCSSPK)/sizeof(u8)); i++) { if (pRSN->len >= 8+i*4+4) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*i) if ( !memcmp(pbyOUI, abyOUIGK, 4)) { @@ -208,17 +197,17 @@ WPA2vParseRSN ( // invalid CSS, No valid PK. return; } - pBSSNode->wCSSPKCount = (WORD)j; + pBSSNode->wCSSPKCount = (u16)j; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wCSSPKCount: %d\n", pBSSNode->wCSSPKCount); } - m = *((PWORD) &(pRSN->abyRSN[4])); + m = *((u16 *) &(pRSN->abyRSN[4])); if (pRSN->len >= 10+m*4) { // ver(2) + GK(4) + PK count(2) + PKS(4*m) + AKMSS count(2) - pBSSNode->wAKMSSAuthCount = *((PWORD) &(pRSN->abyRSN[6+4*m])); + pBSSNode->wAKMSSAuthCount = *((u16 *) &(pRSN->abyRSN[6+4*m])); j = 0; pbyOUI = &(pRSN->abyRSN[8+4*m]); - for (i = 0; (i < pBSSNode->wAKMSSAuthCount) && (j < sizeof(pBSSNode->abyAKMSSAuthType)/sizeof(BYTE)); i++) { + for (i = 0; (i < pBSSNode->wAKMSSAuthCount) && (j < sizeof(pBSSNode->abyAKMSSAuthType)/sizeof(u8)); i++) { if (pRSN->len >= 10+(m+i)*4+4) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSS(2)+AKS(4*i) if ( !memcmp(pbyOUI, abyOUI8021X, 4)) pBSSNode->abyAKMSSAuthType[j++] = WLAN_11i_AKMSS_802_1X; @@ -231,134 +220,16 @@ WPA2vParseRSN ( } else break; } - pBSSNode->wAKMSSAuthCount = (WORD)j; + pBSSNode->wAKMSSAuthCount = (u16)j; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAKMSSAuthCount: %d\n", pBSSNode->wAKMSSAuthCount); - n = *((PWORD) &(pRSN->abyRSN[6+4*m])); + n = *((u16 *) &(pRSN->abyRSN[6+4*m])); if (pRSN->len >= 12+4*m+4*n) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSSCnt(2)+AKMSS(4*n)+Cap(2) pBSSNode->sRSNCapObj.bRSNCapExist = true; - pBSSNode->sRSNCapObj.wRSNCap = *((PWORD) &(pRSN->abyRSN[8+4*m+4*n])); + pBSSNode->sRSNCapObj.wRSNCap = *((u16 *) &(pRSN->abyRSN[8+4*m+4*n])); } } //ignore PMKID lists bcs only (Re)Assocrequest has this field pBSSNode->bWPA2Valid = true; } } - - -/*+ - * - * Description: - * Set WPA IEs - * - * Parameters: - * In: - * pMgmtHandle - Pointer to management object - * Out: - * pRSNIEs - Pointer to the RSN IE to set. - * - * Return Value: length of IEs. - * --*/ -unsigned int WPA2uSetIEs(void *pMgmtHandle, PWLAN_IE_RSN pRSNIEs) -{ - struct vnt_manager *pMgmt = (struct vnt_manager *)pMgmtHandle; - u8 *pbyBuffer = NULL; - int ii = 0; - u16 *pwPMKID = NULL; - - if (pRSNIEs == NULL) - return 0; - - if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || - (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) && - (pMgmt->pCurrBSS != NULL)) { - /* WPA2 IE */ - pbyBuffer = (PBYTE) pRSNIEs; - pRSNIEs->byElementID = WLAN_EID_RSN; - pRSNIEs->len = 6; //Version(2)+GK(4) - pRSNIEs->wVersion = 1; - //Group Key Cipher Suite - pRSNIEs->abyRSN[0] = 0x00; - pRSNIEs->abyRSN[1] = 0x0F; - pRSNIEs->abyRSN[2] = 0xAC; - if (pMgmt->byCSSGK == KEY_CTL_WEP) { - pRSNIEs->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK; - } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) { - pRSNIEs->abyRSN[3] = WLAN_11i_CSS_TKIP; - } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) { - pRSNIEs->abyRSN[3] = WLAN_11i_CSS_CCMP; - } else { - pRSNIEs->abyRSN[3] = WLAN_11i_CSS_UNKNOWN; - } - - // Pairwise Key Cipher Suite - pRSNIEs->abyRSN[4] = 1; - pRSNIEs->abyRSN[5] = 0; - pRSNIEs->abyRSN[6] = 0x00; - pRSNIEs->abyRSN[7] = 0x0F; - pRSNIEs->abyRSN[8] = 0xAC; - if (pMgmt->byCSSPK == KEY_CTL_TKIP) { - pRSNIEs->abyRSN[9] = WLAN_11i_CSS_TKIP; - } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) { - pRSNIEs->abyRSN[9] = WLAN_11i_CSS_CCMP; - } else if (pMgmt->byCSSPK == KEY_CTL_NONE) { - pRSNIEs->abyRSN[9] = WLAN_11i_CSS_USE_GROUP; - } else { - pRSNIEs->abyRSN[9] = WLAN_11i_CSS_UNKNOWN; - } - pRSNIEs->len += 6; - - // Auth Key Management Suite - pRSNIEs->abyRSN[10] = 1; - pRSNIEs->abyRSN[11] = 0; - pRSNIEs->abyRSN[12] = 0x00; - pRSNIEs->abyRSN[13] = 0x0F; - pRSNIEs->abyRSN[14] = 0xAC; - if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) { - pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_PSK; - } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) { - pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_802_1X; - } else { - pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN; - } - pRSNIEs->len +=6; - - // RSN Capabilites - if (pMgmt->pCurrBSS->sRSNCapObj.bRSNCapExist == true) { - memcpy(&pRSNIEs->abyRSN[16], &pMgmt->pCurrBSS->sRSNCapObj.wRSNCap, 2); - } else { - pRSNIEs->abyRSN[16] = 0; - pRSNIEs->abyRSN[17] = 0; - } - pRSNIEs->len +=2; - - if ((pMgmt->gsPMKIDCache.BSSIDInfoCount > 0) && - (pMgmt->bRoaming == true) && - (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { - /* RSN PMKID, pointer to PMKID count */ - pwPMKID = (PWORD)(&pRSNIEs->abyRSN[18]); - *pwPMKID = 0; /* Initialize PMKID count */ - pbyBuffer = &pRSNIEs->abyRSN[20]; /* Point to PMKID list */ - for (ii = 0; ii < pMgmt->gsPMKIDCache.BSSIDInfoCount; ii++) { - if (!memcmp(&pMgmt-> - gsPMKIDCache.BSSIDInfo[ii].abyBSSID[0], - pMgmt->abyCurrBSSID, - ETH_ALEN)) { - (*pwPMKID)++; - memcpy(pbyBuffer, - pMgmt->gsPMKIDCache.BSSIDInfo[ii].abyPMKID, - 16); - pbyBuffer += 16; - } - } - if (*pwPMKID != 0) { - pRSNIEs->len += (2 + (*pwPMKID)*16); - } else { - pbyBuffer = &pRSNIEs->abyRSN[18]; - } - } - return(pRSNIEs->len + WLAN_IEHDR_LEN); - } - return(0); -} |