From d82adcabc603ce1d2c2ef86e33fb50214dfcf4d8 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 18 Mar 2013 10:44:54 -0700 Subject: [PATCH] staging:vt6655:key: Whitespace cleanups Neatening only. git diff -w shows no differences. Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/key.c | 1160 +++++++++++++++++----------------- drivers/staging/vt6655/key.h | 168 ++--- 2 files changed, 664 insertions(+), 664 deletions(-) diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index 194fedc715f..63ef58f0ad6 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -45,7 +45,7 @@ /*--------------------- Static Classes ----------------------------*/ /*--------------------- Static Variables --------------------------*/ -static int msglevel =MSG_LEVEL_INFO; +static int msglevel = MSG_LEVEL_INFO; //static int msglevel =MSG_LEVEL_DEBUG; /*--------------------- Static Functions --------------------------*/ @@ -59,25 +59,25 @@ static int msglevel =MSG_LEVEL_INFO; /*--------------------- Static Functions --------------------------*/ static void -s_vCheckKeyTableValid (PSKeyManagement pTable, unsigned long dwIoBase) +s_vCheckKeyTableValid(PSKeyManagement pTable, unsigned long dwIoBase) { - int i; - - for (i=0;iKeyTable[i].bInUse == true) && - (pTable->KeyTable[i].PairwiseKey.bKeyValid == false) && - (pTable->KeyTable[i].GroupKey[0].bKeyValid == false) && - (pTable->KeyTable[i].GroupKey[1].bKeyValid == false) && - (pTable->KeyTable[i].GroupKey[2].bKeyValid == false) && - (pTable->KeyTable[i].GroupKey[3].bKeyValid == false) - ) { - - pTable->KeyTable[i].bInUse = false; - pTable->KeyTable[i].wKeyCtl = 0; - pTable->KeyTable[i].bSoftWEP = false; - MACvDisableKeyEntry(dwIoBase, i); - } - } + int i; + + for (i = 0; i < MAX_KEY_TABLE; i++) { + if ((pTable->KeyTable[i].bInUse == true) && + (pTable->KeyTable[i].PairwiseKey.bKeyValid == false) && + (pTable->KeyTable[i].GroupKey[0].bKeyValid == false) && + (pTable->KeyTable[i].GroupKey[1].bKeyValid == false) && + (pTable->KeyTable[i].GroupKey[2].bKeyValid == false) && + (pTable->KeyTable[i].GroupKey[3].bKeyValid == false) +) { + + pTable->KeyTable[i].bInUse = false; + pTable->KeyTable[i].wKeyCtl = 0; + pTable->KeyTable[i].bSoftWEP = false; + MACvDisableKeyEntry(dwIoBase, i); + } + } } @@ -96,24 +96,24 @@ s_vCheckKeyTableValid (PSKeyManagement pTable, unsigned long dwIoBase) * Return Value: none * */ -void KeyvInitTable (PSKeyManagement pTable, unsigned long dwIoBase) +void KeyvInitTable(PSKeyManagement pTable, unsigned long dwIoBase) { - int i; - int jj; - - for (i=0;iKeyTable[i].bInUse = false; - pTable->KeyTable[i].PairwiseKey.bKeyValid = false; - pTable->KeyTable[i].PairwiseKey.pvKeyTable = (void *)&pTable->KeyTable[i]; - for (jj=0; jj < MAX_GROUP_KEY; jj++) { - pTable->KeyTable[i].GroupKey[jj].bKeyValid = false; - pTable->KeyTable[i].GroupKey[jj].pvKeyTable = (void *)&pTable->KeyTable[i]; - } - pTable->KeyTable[i].wKeyCtl = 0; - pTable->KeyTable[i].dwGTKeyIndex = 0; - pTable->KeyTable[i].bSoftWEP = false; - MACvDisableKeyEntry(dwIoBase, i); - } + int i; + int jj; + + for (i = 0; i < MAX_KEY_TABLE; i++) { + pTable->KeyTable[i].bInUse = false; + pTable->KeyTable[i].PairwiseKey.bKeyValid = false; + pTable->KeyTable[i].PairwiseKey.pvKeyTable = (void *)&pTable->KeyTable[i]; + for (jj = 0; jj < MAX_GROUP_KEY; jj++) { + pTable->KeyTable[i].GroupKey[jj].bKeyValid = false; + pTable->KeyTable[i].GroupKey[jj].pvKeyTable = (void *)&pTable->KeyTable[i]; + } + pTable->KeyTable[i].wKeyCtl = 0; + pTable->KeyTable[i].dwGTKeyIndex = 0; + pTable->KeyTable[i].bSoftWEP = false; + MACvDisableKeyEntry(dwIoBase, i); + } } @@ -131,44 +131,44 @@ void KeyvInitTable (PSKeyManagement pTable, unsigned long dwIoBase) * Return Value: true if found otherwise false * */ -bool KeybGetKey ( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyIndex, - PSKeyItem *pKey - ) +bool KeybGetKey( + PSKeyManagement pTable, + unsigned char *pbyBSSID, + unsigned long dwKeyIndex, + PSKeyItem *pKey +) { - int i; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetKey() \n"); - - *pKey = NULL; - for (i=0;iKeyTable[i].bInUse == true) && - !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { - if (dwKeyIndex == 0xFFFFFFFF) { - if (pTable->KeyTable[i].PairwiseKey.bKeyValid == true) { - *pKey = &(pTable->KeyTable[i].PairwiseKey); - return (true); - } - else { - return (false); - } - } else if (dwKeyIndex < MAX_GROUP_KEY) { - if (pTable->KeyTable[i].GroupKey[dwKeyIndex].bKeyValid == true) { - *pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex]); - return (true); - } - else { - return (false); - } - } - else { - return (false); - } - } - } - return (false); + int i; + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybGetKey() \n"); + + *pKey = NULL; + for (i = 0; i < MAX_KEY_TABLE; i++) { + if ((pTable->KeyTable[i].bInUse == true) && + !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { + if (dwKeyIndex == 0xFFFFFFFF) { + if (pTable->KeyTable[i].PairwiseKey.bKeyValid == true) { + *pKey = &(pTable->KeyTable[i].PairwiseKey); + return (true); + } + else { + return (false); + } + } else if (dwKeyIndex < MAX_GROUP_KEY) { + if (pTable->KeyTable[i].GroupKey[dwKeyIndex].bKeyValid == true) { + *pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex]); + return (true); + } + else { + return (false); + } + } + else { + return (false); + } + } + } + return (false); } @@ -189,162 +189,162 @@ bool KeybGetKey ( * Return Value: true if success otherwise false * */ -bool KeybSetKey ( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyIndex, - unsigned long uKeyLength, - PQWORD pKeyRSC, - unsigned char *pbyKey, - unsigned char byKeyDecMode, - unsigned long dwIoBase, - unsigned char byLocalID - ) +bool KeybSetKey( + PSKeyManagement pTable, + unsigned char *pbyBSSID, + unsigned long dwKeyIndex, + unsigned long uKeyLength, + PQWORD pKeyRSC, + unsigned char *pbyKey, + unsigned char byKeyDecMode, + unsigned long dwIoBase, + unsigned char byLocalID +) { - int i,j; - unsigned int ii; - PSKeyItem pKey; - unsigned int uKeyIdx; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetKey: %lX\n", dwKeyIndex); - - j = (MAX_KEY_TABLE-1); - for (i=0;i<(MAX_KEY_TABLE-1);i++) { - if ((pTable->KeyTable[i].bInUse == false) && - (j == (MAX_KEY_TABLE-1))) { - // found empty table - j = i; - } - if ((pTable->KeyTable[i].bInUse == true) && - !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { - // found table already exist - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { - // Pairwise key - pKey = &(pTable->KeyTable[i].PairwiseKey); - pTable->KeyTable[i].wKeyCtl &= 0xFFF0; // clear pairwise key control filed - pTable->KeyTable[i].wKeyCtl |= byKeyDecMode; - uKeyIdx = 4; // use HW key entry 4 for pairwise key - } else { - // Group key - if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) - return (false); - pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]); - if ((dwKeyIndex & TRANSMIT_KEY) != 0) { - // Group transmit key - pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[i].dwGTKeyIndex, i); - } - pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed - pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4); - pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address - uKeyIdx = (dwKeyIndex & 0x000000FF); - } - pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly - - pKey->bKeyValid = true; - pKey->uKeyLength = uKeyLength; - pKey->dwKeyIndex = dwKeyIndex; - pKey->byCipherSuite = byKeyDecMode; - memcpy(pKey->abyKey, pbyKey, uKeyLength); - if (byKeyDecMode == KEY_CTL_WEP) { - if (uKeyLength == WLAN_WEP40_KEYLEN) - pKey->abyKey[15] &= 0x7F; - if (uKeyLength == WLAN_WEP104_KEYLEN) - pKey->abyKey[15] |= 0x80; - } - MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (unsigned long *)pKey->abyKey, byLocalID); - - if ((dwKeyIndex & USE_KEYRSC) == 0) { - // RSC set by NIC - memset(&(pKey->KeyRSC), 0, sizeof(QWORD)); - } - else { - memcpy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD)); - } - pKey->dwTSC47_16 = 0; - pKey->wTSC15_0 = 0; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid); - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", pKey->uKeyLength); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: "); - for (ii = 0; ii < pKey->uKeyLength; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ", pKey->wTSC15_0); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex); - - return (true); - } - } - if (j < (MAX_KEY_TABLE-1)) { - memcpy(pTable->KeyTable[j].abyBSSID,pbyBSSID,ETH_ALEN); - pTable->KeyTable[j].bInUse = true; - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { - // Pairwise key - pKey = &(pTable->KeyTable[j].PairwiseKey); - pTable->KeyTable[j].wKeyCtl &= 0xFFF0; // clear pairwise key control filed - pTable->KeyTable[j].wKeyCtl |= byKeyDecMode; - uKeyIdx = 4; // use HW key entry 4 for pairwise key - } else { - // Group key - if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) - return (false); - pKey = &(pTable->KeyTable[j].GroupKey[dwKeyIndex & 0x000000FF]); - if ((dwKeyIndex & TRANSMIT_KEY) != 0) { - // Group transmit key - pTable->KeyTable[j].dwGTKeyIndex = dwKeyIndex; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(N)[%lX]: %d\n", pTable->KeyTable[j].dwGTKeyIndex, j); - } - pTable->KeyTable[j].wKeyCtl &= 0xFF0F; // clear group key control filed - pTable->KeyTable[j].wKeyCtl |= (byKeyDecMode << 4); - pTable->KeyTable[j].wKeyCtl |= 0x0040; // use group key for group address - uKeyIdx = (dwKeyIndex & 0x000000FF); - } - pTable->KeyTable[j].wKeyCtl |= 0x8000; // enable on-fly - - pKey->bKeyValid = true; - pKey->uKeyLength = uKeyLength; - pKey->dwKeyIndex = dwKeyIndex; - pKey->byCipherSuite = byKeyDecMode; - memcpy(pKey->abyKey, pbyKey, uKeyLength); - if (byKeyDecMode == KEY_CTL_WEP) { - if (uKeyLength == WLAN_WEP40_KEYLEN) - pKey->abyKey[15] &= 0x7F; - if (uKeyLength == WLAN_WEP104_KEYLEN) - pKey->abyKey[15] |= 0x80; - } - MACvSetKeyEntry(dwIoBase, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (unsigned long *)pKey->abyKey, byLocalID); - - if ((dwKeyIndex & USE_KEYRSC) == 0) { - // RSC set by NIC - memset(&(pKey->KeyRSC), 0, sizeof(QWORD)); - } - else { - memcpy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD)); - } - pKey->dwTSC47_16 = 0; - pKey->wTSC15_0 = 0; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(N): \n"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: "); - for (ii = 0; ii < pKey->uKeyLength; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ", pKey->wTSC15_0); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex); - - return (true); - } - return (false); + int i, j; + unsigned int ii; + PSKeyItem pKey; + unsigned int uKeyIdx; + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enter KeybSetKey: %lX\n", dwKeyIndex); + + j = (MAX_KEY_TABLE-1); + for (i = 0; i < (MAX_KEY_TABLE - 1); i++) { + if ((pTable->KeyTable[i].bInUse == false) && + (j == (MAX_KEY_TABLE-1))) { + // found empty table + j = i; + } + if ((pTable->KeyTable[i].bInUse == true) && + !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { + // found table already exist + if ((dwKeyIndex & PAIRWISE_KEY) != 0) { + // Pairwise key + pKey = &(pTable->KeyTable[i].PairwiseKey); + pTable->KeyTable[i].wKeyCtl &= 0xFFF0; // clear pairwise key control filed + pTable->KeyTable[i].wKeyCtl |= byKeyDecMode; + uKeyIdx = 4; // use HW key entry 4 for pairwise key + } else { + // Group key + if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) + return (false); + pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]); + if ((dwKeyIndex & TRANSMIT_KEY) != 0) { + // Group transmit key + pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[i].dwGTKeyIndex, i); + } + pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed + pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4); + pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address + uKeyIdx = (dwKeyIndex & 0x000000FF); + } + pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly + + pKey->bKeyValid = true; + pKey->uKeyLength = uKeyLength; + pKey->dwKeyIndex = dwKeyIndex; + pKey->byCipherSuite = byKeyDecMode; + memcpy(pKey->abyKey, pbyKey, uKeyLength); + if (byKeyDecMode == KEY_CTL_WEP) { + if (uKeyLength == WLAN_WEP40_KEYLEN) + pKey->abyKey[15] &= 0x7F; + if (uKeyLength == WLAN_WEP104_KEYLEN) + pKey->abyKey[15] |= 0x80; + } + MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (unsigned long *)pKey->abyKey, byLocalID); + + if ((dwKeyIndex & USE_KEYRSC) == 0) { + // RSC set by NIC + memset(&(pKey->KeyRSC), 0, sizeof(QWORD)); + } + else { + memcpy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD)); + } + pKey->dwTSC47_16 = 0; + pKey->wTSC15_0 = 0; + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybSetKey(R): \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->bKeyValid: %d\n ", pKey->bKeyValid); + //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->uKeyLength: %d\n ", pKey->uKeyLength); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->abyKey: "); + for (ii = 0; ii < pKey->uKeyLength; ii++) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]); + } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->wTSC15_0: %x\n ", pKey->wTSC15_0); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex); + + return (true); + } + } + if (j < (MAX_KEY_TABLE-1)) { + memcpy(pTable->KeyTable[j].abyBSSID, pbyBSSID, ETH_ALEN); + pTable->KeyTable[j].bInUse = true; + if ((dwKeyIndex & PAIRWISE_KEY) != 0) { + // Pairwise key + pKey = &(pTable->KeyTable[j].PairwiseKey); + pTable->KeyTable[j].wKeyCtl &= 0xFFF0; // clear pairwise key control filed + pTable->KeyTable[j].wKeyCtl |= byKeyDecMode; + uKeyIdx = 4; // use HW key entry 4 for pairwise key + } else { + // Group key + if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) + return (false); + pKey = &(pTable->KeyTable[j].GroupKey[dwKeyIndex & 0x000000FF]); + if ((dwKeyIndex & TRANSMIT_KEY) != 0) { + // Group transmit key + pTable->KeyTable[j].dwGTKeyIndex = dwKeyIndex; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Group transmit key(N)[%lX]: %d\n", pTable->KeyTable[j].dwGTKeyIndex, j); + } + pTable->KeyTable[j].wKeyCtl &= 0xFF0F; // clear group key control filed + pTable->KeyTable[j].wKeyCtl |= (byKeyDecMode << 4); + pTable->KeyTable[j].wKeyCtl |= 0x0040; // use group key for group address + uKeyIdx = (dwKeyIndex & 0x000000FF); + } + pTable->KeyTable[j].wKeyCtl |= 0x8000; // enable on-fly + + pKey->bKeyValid = true; + pKey->uKeyLength = uKeyLength; + pKey->dwKeyIndex = dwKeyIndex; + pKey->byCipherSuite = byKeyDecMode; + memcpy(pKey->abyKey, pbyKey, uKeyLength); + if (byKeyDecMode == KEY_CTL_WEP) { + if (uKeyLength == WLAN_WEP40_KEYLEN) + pKey->abyKey[15] &= 0x7F; + if (uKeyLength == WLAN_WEP104_KEYLEN) + pKey->abyKey[15] |= 0x80; + } + MACvSetKeyEntry(dwIoBase, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (unsigned long *)pKey->abyKey, byLocalID); + + if ((dwKeyIndex & USE_KEYRSC) == 0) { + // RSC set by NIC + memset(&(pKey->KeyRSC), 0, sizeof(QWORD)); + } + else { + memcpy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD)); + } + pKey->dwTSC47_16 = 0; + pKey->wTSC15_0 = 0; + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybSetKey(N): \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->bKeyValid: %d\n ", pKey->bKeyValid); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->abyKey: "); + for (ii = 0; ii < pKey->uKeyLength; ii++) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]); + } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->wTSC15_0: %x\n ", pKey->wTSC15_0); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex); + + return (true); + } + return (false); } @@ -362,63 +362,63 @@ bool KeybSetKey ( * Return Value: true if success otherwise false * */ -bool KeybRemoveKey ( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyIndex, - unsigned long dwIoBase - ) +bool KeybRemoveKey( + PSKeyManagement pTable, + unsigned char *pbyBSSID, + unsigned long dwKeyIndex, + unsigned long dwIoBase +) { - int i; - - if (is_broadcast_ether_addr(pbyBSSID)) { - // delete all keys - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { - for (i=0;iKeyTable[i].PairwiseKey.bKeyValid = false; - } - s_vCheckKeyTableValid(pTable, dwIoBase); - return true; - } - else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { - for (i=0;iKeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; - if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) { - // remove Group transmit key - pTable->KeyTable[i].dwGTKeyIndex = 0; - } - } - s_vCheckKeyTableValid(pTable, dwIoBase); - return true; - } - else { - return false; - } - } - - for (i=0;iKeyTable[i].bInUse == true) && - !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { - pTable->KeyTable[i].PairwiseKey.bKeyValid = false; - s_vCheckKeyTableValid(pTable, dwIoBase); - return (true); - } - else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { - pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; - if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) { - // remove Group transmit key - pTable->KeyTable[i].dwGTKeyIndex = 0; - } - s_vCheckKeyTableValid(pTable, dwIoBase); - return (true); - } - else { - return (false); - } - } - } - return (false); + int i; + + if (is_broadcast_ether_addr(pbyBSSID)) { + // delete all keys + if ((dwKeyIndex & PAIRWISE_KEY) != 0) { + for (i = 0; i < MAX_KEY_TABLE; i++) { + pTable->KeyTable[i].PairwiseKey.bKeyValid = false; + } + s_vCheckKeyTableValid(pTable, dwIoBase); + return true; + } + else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { + for (i = 0; i < MAX_KEY_TABLE; i++) { + pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; + if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) { + // remove Group transmit key + pTable->KeyTable[i].dwGTKeyIndex = 0; + } + } + s_vCheckKeyTableValid(pTable, dwIoBase); + return true; + } + else { + return false; + } + } + + for (i = 0; i < MAX_KEY_TABLE; i++) { + if ((pTable->KeyTable[i].bInUse == true) && + !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { + if ((dwKeyIndex & PAIRWISE_KEY) != 0) { + pTable->KeyTable[i].PairwiseKey.bKeyValid = false; + s_vCheckKeyTableValid(pTable, dwIoBase); + return (true); + } + else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { + pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; + if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) { + // remove Group transmit key + pTable->KeyTable[i].dwGTKeyIndex = 0; + } + s_vCheckKeyTableValid(pTable, dwIoBase); + return (true); + } + else { + return (false); + } + } + } + return (false); } @@ -435,27 +435,27 @@ bool KeybRemoveKey ( * Return Value: true if success otherwise false * */ -bool KeybRemoveAllKey ( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwIoBase - ) +bool KeybRemoveAllKey( + PSKeyManagement pTable, + unsigned char *pbyBSSID, + unsigned long dwIoBase +) { - int i,u; - - for (i=0;iKeyTable[i].bInUse == true) && - !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { - pTable->KeyTable[i].PairwiseKey.bKeyValid = false; - for(u=0;uKeyTable[i].GroupKey[u].bKeyValid = false; - } - pTable->KeyTable[i].dwGTKeyIndex = 0; - s_vCheckKeyTableValid(pTable, dwIoBase); - return (true); - } - } - return (false); + int i, u; + + for (i = 0; i < MAX_KEY_TABLE; i++) { + if ((pTable->KeyTable[i].bInUse == true) && + !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { + pTable->KeyTable[i].PairwiseKey.bKeyValid = false; + for (u = 0; u < MAX_GROUP_KEY; u++) { + pTable->KeyTable[i].GroupKey[u].bKeyValid = false; + } + pTable->KeyTable[i].dwGTKeyIndex = 0; + s_vCheckKeyTableValid(pTable, dwIoBase); + return (true); + } + } + return (false); } /* @@ -470,38 +470,38 @@ bool KeybRemoveAllKey ( * Return Value: true if success otherwise false * */ -void KeyvRemoveWEPKey ( - PSKeyManagement pTable, - unsigned long dwKeyIndex, - unsigned long dwIoBase - ) +void KeyvRemoveWEPKey( + PSKeyManagement pTable, + unsigned long dwKeyIndex, + unsigned long dwIoBase +) { - if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { - if (pTable->KeyTable[MAX_KEY_TABLE-1].bInUse == true) { - if (pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].byCipherSuite == KEY_CTL_WEP) { - pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; - if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex & 0x7FFFFFFF)) { - // remove Group transmit key - pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = 0; - } - } - } - s_vCheckKeyTableValid(pTable, dwIoBase); - } - return; + if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { + if (pTable->KeyTable[MAX_KEY_TABLE-1].bInUse == true) { + if (pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].byCipherSuite == KEY_CTL_WEP) { + pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; + if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex & 0x7FFFFFFF)) { + // remove Group transmit key + pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = 0; + } + } + } + s_vCheckKeyTableValid(pTable, dwIoBase); + } + return; } -void KeyvRemoveAllWEPKey ( - PSKeyManagement pTable, - unsigned long dwIoBase - ) +void KeyvRemoveAllWEPKey( + PSKeyManagement pTable, + unsigned long dwIoBase +) { - int i; + int i; - for(i=0;iKeyTable[i].bInUse == true) && - !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { - - if (dwKeyType == PAIRWISE_KEY) { - - if (pTable->KeyTable[i].PairwiseKey.bKeyValid == true) { - *pKey = &(pTable->KeyTable[i].PairwiseKey); - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PAIRWISE_KEY: KeyTable.abyBSSID: "); - for (ii = 0; ii < 6; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x ", pTable->KeyTable[i].abyBSSID[ii]); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); - - - return (true); - } - else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PairwiseKey.bKeyValid == false\n"); - return (false); - } - } // End of Type == PAIRWISE - else { - if (pTable->KeyTable[i].dwGTKeyIndex == 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ERROR: dwGTKeyIndex == 0 !!!\n"); - return false; - } - if (pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)].bKeyValid == true) { - *pKey = &(pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)]); - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GROUP_KEY: KeyTable.abyBSSID\n"); - for (ii = 0; ii < 6; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x ", pTable->KeyTable[i].abyBSSID[ii]); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"dwGTKeyIndex: %lX\n", pTable->KeyTable[i].dwGTKeyIndex); - - return (true); - } - else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GroupKey.bKeyValid == false\n"); - return (false); - } - } // End of Type = GROUP - } // BSSID match - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ERROR: NO Match BSSID !!! "); - for (ii = 0; ii < 6; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *(pbyBSSID+ii)); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); - return (false); + int i, ii; + + *pKey = NULL; + for (i = 0; i < MAX_KEY_TABLE; i++) { + if ((pTable->KeyTable[i].bInUse == true) && + !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { + + if (dwKeyType == PAIRWISE_KEY) { + + if (pTable->KeyTable[i].PairwiseKey.bKeyValid == true) { + *pKey = &(pTable->KeyTable[i].PairwiseKey); + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybGetTransmitKey:"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "PAIRWISE_KEY: KeyTable.abyBSSID: "); + for (ii = 0; ii < 6; ii++) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%x ", pTable->KeyTable[i].abyBSSID[ii]); + } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); + + + return (true); + } + else { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "PairwiseKey.bKeyValid == false\n"); + return (false); + } + } // End of Type == PAIRWISE + else { + if (pTable->KeyTable[i].dwGTKeyIndex == 0) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ERROR: dwGTKeyIndex == 0 !!!\n"); + return false; + } + if (pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)].bKeyValid == true) { + *pKey = &(pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)]); + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybGetTransmitKey:"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "GROUP_KEY: KeyTable.abyBSSID\n"); + for (ii = 0; ii < 6; ii++) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%x ", pTable->KeyTable[i].abyBSSID[ii]); + } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dwGTKeyIndex: %lX\n", pTable->KeyTable[i].dwGTKeyIndex); + + return (true); + } + else { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "GroupKey.bKeyValid == false\n"); + return (false); + } + } // End of Type = GROUP + } // BSSID match + } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ERROR: NO Match BSSID !!! "); + for (ii = 0; ii < 6; ii++) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", *(pbyBSSID+ii)); + } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); + return (false); } @@ -597,22 +597,22 @@ bool KeybGetTransmitKey ( * Return Value: true if found otherwise false * */ -bool KeybCheckPairewiseKey ( - PSKeyManagement pTable, - PSKeyItem *pKey - ) +bool KeybCheckPairewiseKey( + PSKeyManagement pTable, + PSKeyItem *pKey +) { - int i; - - *pKey = NULL; - for (i=0;iKeyTable[i].bInUse == true) && - (pTable->KeyTable[i].PairwiseKey.bKeyValid == true)) { - *pKey = &(pTable->KeyTable[i].PairwiseKey); - return (true); - } - } - return (false); + int i; + + *pKey = NULL; + for (i = 0; i < MAX_KEY_TABLE; i++) { + if ((pTable->KeyTable[i].bInUse == true) && + (pTable->KeyTable[i].PairwiseKey.bKeyValid == true)) { + *pKey = &(pTable->KeyTable[i].PairwiseKey); + return (true); + } + } + return (false); } /* @@ -631,97 +631,97 @@ bool KeybCheckPairewiseKey ( * Return Value: true if success otherwise false * */ -bool KeybSetDefaultKey ( - PSKeyManagement pTable, - unsigned long dwKeyIndex, - unsigned long uKeyLength, - PQWORD pKeyRSC, - unsigned char *pbyKey, - unsigned char byKeyDecMode, - unsigned long dwIoBase, - unsigned char byLocalID - ) +bool KeybSetDefaultKey( + PSKeyManagement pTable, + unsigned long dwKeyIndex, + unsigned long uKeyLength, + PQWORD pKeyRSC, + unsigned char *pbyKey, + unsigned char byKeyDecMode, + unsigned long dwIoBase, + unsigned char byLocalID +) { - unsigned int ii; - PSKeyItem pKey; - unsigned int uKeyIdx; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetDefaultKey: %1x, %d \n", (int)dwKeyIndex, (int)uKeyLength); - - - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key - return (false); - } else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) { - return (false); - } - - if (uKeyLength > MAX_KEY_LEN) - return false; - - pTable->KeyTable[MAX_KEY_TABLE-1].bInUse = true; - for(ii=0;iiKeyTable[MAX_KEY_TABLE-1].abyBSSID[ii] = 0xFF; - - // Group key - pKey = &(pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF]); - if ((dwKeyIndex & TRANSMIT_KEY) != 0) { - // Group transmit key - pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = dwKeyIndex; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex, MAX_KEY_TABLE-1); - - } - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl &= 0x7F00; // clear all key control filed - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode << 4); - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode); - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x0044; // use group key for all address - uKeyIdx = (dwKeyIndex & 0x000000FF); - - if ((uKeyLength == WLAN_WEP232_KEYLEN) && - (byKeyDecMode == KEY_CTL_WEP)) { - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x4000; // disable on-fly disable address match - pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP = true; - } else { - if (pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP == false) - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0xC000; // enable on-fly disable address match - } - - pKey->bKeyValid = true; - pKey->uKeyLength = uKeyLength; - pKey->dwKeyIndex = dwKeyIndex; - pKey->byCipherSuite = byKeyDecMode; - memcpy(pKey->abyKey, pbyKey, uKeyLength); - if (byKeyDecMode == KEY_CTL_WEP) { - if (uKeyLength == WLAN_WEP40_KEYLEN) - pKey->abyKey[15] &= 0x7F; - if (uKeyLength == WLAN_WEP104_KEYLEN) - pKey->abyKey[15] |= 0x80; - } - MACvSetKeyEntry(dwIoBase, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (unsigned long *)pKey->abyKey, byLocalID); - - if ((dwKeyIndex & USE_KEYRSC) == 0) { - // RSC set by NIC - memset(&(pKey->KeyRSC), 0, sizeof(QWORD)); - } else { - memcpy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD)); - } - pKey->dwTSC47_16 = 0; - pKey->wTSC15_0 = 0; - - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n", pKey->bKeyValid); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n", (int)pKey->uKeyLength); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: \n"); - for (ii = 0; ii < pKey->uKeyLength; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x", pKey->abyKey[ii]); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n", pKey->dwTSC47_16); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n", pKey->wTSC15_0); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %lx\n", pKey->dwKeyIndex); - - return (true); + unsigned int ii; + PSKeyItem pKey; + unsigned int uKeyIdx; + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enter KeybSetDefaultKey: %1x, %d \n", (int)dwKeyIndex, (int)uKeyLength); + + + if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key + return (false); + } else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) { + return (false); + } + + if (uKeyLength > MAX_KEY_LEN) + return false; + + pTable->KeyTable[MAX_KEY_TABLE - 1].bInUse = true; + for (ii = 0; ii < ETH_ALEN; ii++) + pTable->KeyTable[MAX_KEY_TABLE - 1].abyBSSID[ii] = 0xFF; + + // Group key + pKey = &(pTable->KeyTable[MAX_KEY_TABLE - 1].GroupKey[dwKeyIndex & 0x000000FF]); + if ((dwKeyIndex & TRANSMIT_KEY) != 0) { + // Group transmit key + pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = dwKeyIndex; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex, MAX_KEY_TABLE-1); + + } + pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl &= 0x7F00; // clear all key control filed + pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode << 4); + pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode); + pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x0044; // use group key for all address + uKeyIdx = (dwKeyIndex & 0x000000FF); + + if ((uKeyLength == WLAN_WEP232_KEYLEN) && + (byKeyDecMode == KEY_CTL_WEP)) { + pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x4000; // disable on-fly disable address match + pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP = true; + } else { + if (pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP == false) + pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0xC000; // enable on-fly disable address match + } + + pKey->bKeyValid = true; + pKey->uKeyLength = uKeyLength; + pKey->dwKeyIndex = dwKeyIndex; + pKey->byCipherSuite = byKeyDecMode; + memcpy(pKey->abyKey, pbyKey, uKeyLength); + if (byKeyDecMode == KEY_CTL_WEP) { + if (uKeyLength == WLAN_WEP40_KEYLEN) + pKey->abyKey[15] &= 0x7F; + if (uKeyLength == WLAN_WEP104_KEYLEN) + pKey->abyKey[15] |= 0x80; + } + MACvSetKeyEntry(dwIoBase, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (unsigned long *)pKey->abyKey, byLocalID); + + if ((dwKeyIndex & USE_KEYRSC) == 0) { + // RSC set by NIC + memset(&(pKey->KeyRSC), 0, sizeof(QWORD)); + } else { + memcpy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD)); + } + pKey->dwTSC47_16 = 0; + pKey->wTSC15_0 = 0; + + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybSetKey(R): \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->bKeyValid: %d\n", pKey->bKeyValid); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->uKeyLength: %d\n", (int)pKey->uKeyLength); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->abyKey: \n"); + for (ii = 0; ii < pKey->uKeyLength; ii++) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%x", pKey->abyKey[ii]); + } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->dwTSC47_16: %lx\n", pKey->dwTSC47_16); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->wTSC15_0: %x\n", pKey->wTSC15_0); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->dwKeyIndex: %lx\n", pKey->dwKeyIndex); + + return (true); } @@ -741,86 +741,86 @@ bool KeybSetDefaultKey ( * Return Value: true if success otherwise false * */ -bool KeybSetAllGroupKey ( - PSKeyManagement pTable, - unsigned long dwKeyIndex, - unsigned long uKeyLength, - PQWORD pKeyRSC, - unsigned char *pbyKey, - unsigned char byKeyDecMode, - unsigned long dwIoBase, - unsigned char byLocalID - ) +bool KeybSetAllGroupKey( + PSKeyManagement pTable, + unsigned long dwKeyIndex, + unsigned long uKeyLength, + PQWORD pKeyRSC, + unsigned char *pbyKey, + unsigned char byKeyDecMode, + unsigned long dwIoBase, + unsigned char byLocalID +) { - int i; - unsigned int ii; - PSKeyItem pKey; - unsigned int uKeyIdx; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetAllGroupKey: %lX\n", dwKeyIndex); - - - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key - return (false); - } else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) { - return (false); - } - - for (i=0; i < MAX_KEY_TABLE-1; i++) { - if (pTable->KeyTable[i].bInUse == true) { - // found table already exist - // Group key - pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]); - if ((dwKeyIndex & TRANSMIT_KEY) != 0) { - // Group transmit key - pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[i].dwGTKeyIndex, i); - - } - pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed - pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4); - pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address - uKeyIdx = (dwKeyIndex & 0x000000FF); - - pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly - - pKey->bKeyValid = true; - pKey->uKeyLength = uKeyLength; - pKey->dwKeyIndex = dwKeyIndex; - pKey->byCipherSuite = byKeyDecMode; - memcpy(pKey->abyKey, pbyKey, uKeyLength); - if (byKeyDecMode == KEY_CTL_WEP) { - if (uKeyLength == WLAN_WEP40_KEYLEN) - pKey->abyKey[15] &= 0x7F; - if (uKeyLength == WLAN_WEP104_KEYLEN) - pKey->abyKey[15] |= 0x80; - } - MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (unsigned long *)pKey->abyKey, byLocalID); - - if ((dwKeyIndex & USE_KEYRSC) == 0) { - // RSC set by NIC - memset(&(pKey->KeyRSC), 0, sizeof(QWORD)); - } - else { - memcpy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD)); - } - pKey->dwTSC47_16 = 0; - pKey->wTSC15_0 = 0; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: "); - for (ii = 0; ii < pKey->uKeyLength; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", pKey->abyKey[ii]); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); - - //DBG_PRN_GRP12(("pKey->dwTSC47_16: %lX\n ", pKey->dwTSC47_16)); - //DBG_PRN_GRP12(("pKey->wTSC15_0: %X\n ", pKey->wTSC15_0)); - //DBG_PRN_GRP12(("pKey->dwKeyIndex: %lX\n ", pKey->dwKeyIndex)); - - } // (pTable->KeyTable[i].bInUse == true) - } - return (true); + int i; + unsigned int ii; + PSKeyItem pKey; + unsigned int uKeyIdx; + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enter KeybSetAllGroupKey: %lX\n", dwKeyIndex); + + + if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key + return (false); + } else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) { + return (false); + } + + for (i = 0; i < MAX_KEY_TABLE - 1; i++) { + if (pTable->KeyTable[i].bInUse == true) { + // found table already exist + // Group key + pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]); + if ((dwKeyIndex & TRANSMIT_KEY) != 0) { + // Group transmit key + pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex; + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[i].dwGTKeyIndex, i); + + } + pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed + pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4); + pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address + uKeyIdx = (dwKeyIndex & 0x000000FF); + + pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly + + pKey->bKeyValid = true; + pKey->uKeyLength = uKeyLength; + pKey->dwKeyIndex = dwKeyIndex; + pKey->byCipherSuite = byKeyDecMode; + memcpy(pKey->abyKey, pbyKey, uKeyLength); + if (byKeyDecMode == KEY_CTL_WEP) { + if (uKeyLength == WLAN_WEP40_KEYLEN) + pKey->abyKey[15] &= 0x7F; + if (uKeyLength == WLAN_WEP104_KEYLEN) + pKey->abyKey[15] |= 0x80; + } + MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (unsigned long *)pKey->abyKey, byLocalID); + + if ((dwKeyIndex & USE_KEYRSC) == 0) { + // RSC set by NIC + memset(&(pKey->KeyRSC), 0, sizeof(QWORD)); + } + else { + memcpy(&(pKey->KeyRSC), pKeyRSC, sizeof(QWORD)); + } + pKey->dwTSC47_16 = 0; + pKey->wTSC15_0 = 0; + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybSetKey(R): \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->bKeyValid: %d\n ", pKey->bKeyValid); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->abyKey: "); + for (ii = 0; ii < pKey->uKeyLength; ii++) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]); + } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); + + //DBG_PRN_GRP12(("pKey->dwTSC47_16: %lX\n ", pKey->dwTSC47_16)); + //DBG_PRN_GRP12(("pKey->wTSC15_0: %X\n ", pKey->wTSC15_0)); + //DBG_PRN_GRP12(("pKey->dwKeyIndex: %lX\n ", pKey->dwKeyIndex)); + + } // (pTable->KeyTable[i].bInUse == true) + } + return (true); } diff --git a/drivers/staging/vt6655/key.h b/drivers/staging/vt6655/key.h index 6b2dad331a5..f09cdb1885f 100644 --- a/drivers/staging/vt6655/key.h +++ b/drivers/staging/vt6655/key.h @@ -57,39 +57,39 @@ typedef struct tagSKeyItem { - bool bKeyValid; - unsigned long uKeyLength; - unsigned char abyKey[MAX_KEY_LEN]; - QWORD KeyRSC; - unsigned long dwTSC47_16; - unsigned short wTSC15_0; - unsigned char byCipherSuite; - unsigned char byReserved0; - unsigned long dwKeyIndex; - void *pvKeyTable; + bool bKeyValid; + unsigned long uKeyLength; + unsigned char abyKey[MAX_KEY_LEN]; + QWORD KeyRSC; + unsigned long dwTSC47_16; + unsigned short wTSC15_0; + unsigned char byCipherSuite; + unsigned char byReserved0; + unsigned long dwKeyIndex; + void *pvKeyTable; } SKeyItem, *PSKeyItem; //64 typedef struct tagSKeyTable { - unsigned char abyBSSID[ETH_ALEN]; //6 - unsigned char byReserved0[2]; //8 - SKeyItem PairwiseKey; - SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328 - unsigned long dwGTKeyIndex; // GroupTransmitKey Index - bool bInUse; - //2006-1116-01, by NomadZhao - //unsigned short wKeyCtl; - //bool bSoftWEP; - bool bSoftWEP; - unsigned short wKeyCtl; // for address of wKeyCtl at align 4 - - unsigned char byReserved1[6]; + unsigned char abyBSSID[ETH_ALEN]; //6 + unsigned char byReserved0[2]; //8 + SKeyItem PairwiseKey; + SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328 + unsigned long dwGTKeyIndex; // GroupTransmitKey Index + bool bInUse; + //2006-1116-01, by NomadZhao + //unsigned short wKeyCtl; + //bool bSoftWEP; + bool bSoftWEP; + unsigned short wKeyCtl; // for address of wKeyCtl at align 4 + + unsigned char byReserved1[6]; } SKeyTable, *PSKeyTable; //348 typedef struct tagSKeyManagement { - SKeyTable KeyTable[MAX_KEY_TABLE]; -} SKeyManagement, * PSKeyManagement; + SKeyTable KeyTable[MAX_KEY_TABLE]; +} SKeyManagement, *PSKeyManagement; /*--------------------- Export Types ------------------------------*/ @@ -104,81 +104,81 @@ typedef struct tagSKeyManagement void KeyvInitTable(PSKeyManagement pTable, unsigned long dwIoBase); bool KeybGetKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyIndex, - PSKeyItem *pKey - ); + PSKeyManagement pTable, + unsigned char *pbyBSSID, + unsigned long dwKeyIndex, + PSKeyItem *pKey +); bool KeybSetKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyIndex, - unsigned long uKeyLength, - PQWORD pKeyRSC, - unsigned char *pbyKey, - unsigned char byKeyDecMode, - unsigned long dwIoBase, - unsigned char byLocalID - ); + PSKeyManagement pTable, + unsigned char *pbyBSSID, + unsigned long dwKeyIndex, + unsigned long uKeyLength, + PQWORD pKeyRSC, + unsigned char *pbyKey, + unsigned char byKeyDecMode, + unsigned long dwIoBase, + unsigned char byLocalID +); bool KeybSetDefaultKey( - PSKeyManagement pTable, - unsigned long dwKeyIndex, - unsigned long uKeyLength, - PQWORD pKeyRSC, - unsigned char *pbyKey, - unsigned char byKeyDecMode, - unsigned long dwIoBase, - unsigned char byLocalID - ); + PSKeyManagement pTable, + unsigned long dwKeyIndex, + unsigned long uKeyLength, + PQWORD pKeyRSC, + unsigned char *pbyKey, + unsigned char byKeyDecMode, + unsigned long dwIoBase, + unsigned char byLocalID +); bool KeybRemoveKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyIndex, - unsigned long dwIoBase - ); + PSKeyManagement pTable, + unsigned char *pbyBSSID, + unsigned long dwKeyIndex, + unsigned long dwIoBase +); bool KeybGetTransmitKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwKeyType, - PSKeyItem *pKey - ); + PSKeyManagement pTable, + unsigned char *pbyBSSID, + unsigned long dwKeyType, + PSKeyItem *pKey +); bool KeybCheckPairewiseKey( - PSKeyManagement pTable, - PSKeyItem *pKey - ); + PSKeyManagement pTable, + PSKeyItem *pKey +); bool KeybRemoveAllKey( - PSKeyManagement pTable, - unsigned char *pbyBSSID, - unsigned long dwIoBase - ); + PSKeyManagement pTable, + unsigned char *pbyBSSID, + unsigned long dwIoBase +); void KeyvRemoveWEPKey( - PSKeyManagement pTable, - unsigned long dwKeyIndex, - unsigned long dwIoBase - ); + PSKeyManagement pTable, + unsigned long dwKeyIndex, + unsigned long dwIoBase +); void KeyvRemoveAllWEPKey( - PSKeyManagement pTable, - unsigned long dwIoBase - ); - -bool KeybSetAllGroupKey ( - PSKeyManagement pTable, - unsigned long dwKeyIndex, - unsigned long uKeyLength, - PQWORD pKeyRSC, - unsigned char *pbyKey, - unsigned char byKeyDecMode, - unsigned long dwIoBase, - unsigned char byLocalID - ); + PSKeyManagement pTable, + unsigned long dwIoBase +); + +bool KeybSetAllGroupKey( + PSKeyManagement pTable, + unsigned long dwKeyIndex, + unsigned long uKeyLength, + PQWORD pKeyRSC, + unsigned char *pbyKey, + unsigned char byKeyDecMode, + unsigned long dwIoBase, + unsigned char byLocalID +); #endif // __KEY_H__ -- 2.41.0