Skip to content

Commit

Permalink
staging: vt6656: replace IS_ETH_ADDRESS_EQUAL with compare_ether_addr
Browse files Browse the repository at this point in the history
Code cleanup, removed custom macro to compare Ethernet addresses.
Some checkpatch warnings on indentation were not resolved.

The return value of compare_ether_addr was reversed, something to consider.

Signed-off-by: Andres More <more.andres@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Andres More authored and Greg Kroah-Hartman committed Jun 24, 2010
1 parent cbf0509 commit 4722a26
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 67 deletions.
10 changes: 6 additions & 4 deletions drivers/staging/vt6656/bssdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ PKnownBSS BSSpSearchBSSList(void *hDeviceContext,

if ((pCurrBSS->bActive) &&
(pCurrBSS->bSelected == FALSE)) {
if (IS_ETH_ADDRESS_EQUAL(pCurrBSS->abyBSSID, pbyBSSID)) {
if (!compare_ether_addr(pCurrBSS->abyBSSID, pbyBSSID)) {
if (pSSID != NULL) {
// compare ssid
if ( !memcmp(pSSID->abySSID,
Expand Down Expand Up @@ -296,7 +296,8 @@ void BSSvClearBSSList(void *hDeviceContext, BOOL bKeepCurrBSSID)
for (ii = 0; ii < MAX_BSS_NUM; ii++) {
if (bKeepCurrBSSID) {
if (pMgmt->sBSSList[ii].bActive &&
IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pMgmt->abyCurrBSSID)) {
!compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
pMgmt->abyCurrBSSID)) {
//mike mark: there are two same BSSID in list if that AP is in hidden ssid mode,one 's SSID is null,
// but other's is obvious, so if it acssociate with your STA exactly,you must keep two
// of them!!!!!!!!!
Expand Down Expand Up @@ -341,7 +342,7 @@ PKnownBSS BSSpAddrIsInBSSList(void *hDeviceContext,
for (ii = 0; ii < MAX_BSS_NUM; ii++) {
pBSSList = &(pMgmt->sBSSList[ii]);
if (pBSSList->bActive) {
if (IS_ETH_ADDRESS_EQUAL(pBSSList->abyBSSID, abyBSSID)) {
if (!compare_ether_addr(pBSSList->abyBSSID, abyBSSID)) {
if (pSSID->len == ((PWLAN_IE_SSID)pBSSList->abySSID)->len){
if (memcmp(pSSID->abySSID,
((PWLAN_IE_SSID)pBSSList->abySSID)->abySSID,
Expand Down Expand Up @@ -744,7 +745,8 @@ BOOL BSSbIsSTAInNodeDB(void *hDeviceContext,
// Index = 0 reserved for AP Node
for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
if (pMgmt->sNodeDBTable[ii].bActive) {
if (IS_ETH_ADDRESS_EQUAL(abyDstAddr, pMgmt->sNodeDBTable[ii].abyMACAddr)) {
if (!compare_ether_addr(abyDstAddr,
pMgmt->sNodeDBTable[ii].abyMACAddr)) {
*puNodeIndex = ii;
return TRUE;
}
Expand Down
15 changes: 8 additions & 7 deletions drivers/staging/vt6656/dpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,9 @@ s_vProcessRxMACHeader (
};

pbyRxBuffer = (PBYTE) (pbyRxBufferAddr + cbHeaderSize);
if (IS_ETH_ADDRESS_EQUAL(pbyRxBuffer, &pDevice->abySNAP_Bridgetunnel[0])) {
if (!compare_ether_addr(pbyRxBuffer, &pDevice->abySNAP_Bridgetunnel[0])) {
cbHeaderSize += 6;
}
else if (IS_ETH_ADDRESS_EQUAL(pbyRxBuffer, &pDevice->abySNAP_RFC1042[0])) {
} else if (!compare_ether_addr(pbyRxBuffer, &pDevice->abySNAP_RFC1042[0])) {
cbHeaderSize += 6;
pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize);
if ((*pwType!= TYPE_PKT_IPX) && (*pwType != cpu_to_le16(0xF380))) {
Expand Down Expand Up @@ -453,7 +452,7 @@ RXbBulkInProcessData (
if ((pMgmt->eCurrMode == WMAC_MODE_STANDBY) ||
(pMgmt->eCurrMode == WMAC_MODE_ESS_STA)) {
if (pMgmt->sNodeDBTable[0].bActive) {
if(IS_ETH_ADDRESS_EQUAL (pMgmt->abyCurrBSSID, pMACHeader->abyAddr2) ) {
if (!compare_ether_addr(pMgmt->abyCurrBSSID, pMACHeader->abyAddr2)) {
if (pMgmt->sNodeDBTable[0].uInActiveCount != 0)
pMgmt->sNodeDBTable[0].uInActiveCount = 0;
}
Expand All @@ -466,16 +465,18 @@ RXbBulkInProcessData (
return FALSE;
}

if ( !IS_ETH_ADDRESS_EQUAL (pDevice->abyCurrentNetAddr, pMACHeader->abyAddr1) ) {
return FALSE;
if (compare_ether_addr(pDevice->abyCurrentNetAddr,
pMACHeader->abyAddr1)) {
return FALSE;
}
}


// Use for TKIP MIC
s_vGetDASA(pbyFrame, &cbHeaderSize, &pDevice->sRxEthHeader);

if (IS_ETH_ADDRESS_EQUAL((PBYTE)&(pDevice->sRxEthHeader.abySrcAddr[0]), pDevice->abyCurrentNetAddr))
if (!compare_ether_addr((PBYTE)&(pDevice->sRxEthHeader.abySrcAddr[0]),
pDevice->abyCurrentNetAddr))
return FALSE;

if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) {
Expand Down
39 changes: 4 additions & 35 deletions drivers/staging/vt6656/iwctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,39 +349,6 @@ int iwctl_giwscan(struct net_device *dev,
}
iwe.u.qual.updated=7;

//2008-0409-01, <Mark> by Einsn Liu
/*
//2008-0220-03, <Modify> by Einsn Liu
if(pDevice->bLinkPass== TRUE && IS_ETH_ADDRESS_EQUAL(pBSS->abyBSSID, pMgmt->abyCurrBSSID)){
#ifdef Calcu_LinkQual
#if 0
if(pDevice->byBBType == BB_TYPE_11B) {
if(pDevice->byCurrSQ > 120)
pDevice->scStatistic.LinkQuality = 100;
else
pDevice->scStatistic.LinkQuality = pDevice->byCurrSQ*100/120;
}
else if(pDevice->byBBType == BB_TYPE_11G) {
if(pDevice->byCurrSQ < 20)
pDevice->scStatistic.LinkQuality = 100;
else if(pDevice->byCurrSQ >96)
pDevice->scStatistic.LinkQuality = 0;
else
pDevice->scStatistic.LinkQuality = (96-pDevice->byCurrSQ)*100/76;
}
if(pDevice->bLinkPass !=TRUE)
pDevice->scStatistic.LinkQuality = 0;
#endif
if(pDevice->scStatistic.LinkQuality > 100)
pDevice->scStatistic.LinkQuality = 100;
iwe.u.qual.qual =(BYTE) pDevice->scStatistic.LinkQuality;
#else
iwe.u.qual.qual = pDevice->byCurrSQ;
#endif
}else {
iwe.u.qual.qual = 0;
}
*/
current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
//ADD encryption
memset(&iwe, 0, sizeof(iwe));
Expand Down Expand Up @@ -772,7 +739,8 @@ int iwctl_siwap(struct net_device *dev,
unsigned int ii, uSameBssidNum = 0;
for (ii = 0; ii < MAX_BSS_NUM; ii++) {
if (pMgmt->sBSSList[ii].bActive &&
IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID,pMgmt->abyDesireBSSID)) {
!compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
pMgmt->abyDesireBSSID)) {
uSameBssidNum++;
}
}
Expand Down Expand Up @@ -957,7 +925,8 @@ int iwctl_siwessid(struct net_device *dev,
// by means of judging if there are two same BSSID exist in list ?
for (ii = 0; ii < MAX_BSS_NUM; ii++) {
if (pMgmt->sBSSList[ii].bActive &&
IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) {
!compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
pCurr->abyBSSID)) {
uSameBssidNum++;
}
}
Expand Down
10 changes: 5 additions & 5 deletions drivers/staging/vt6656/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ BOOL KeybGetKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyIndex,
*pKey = NULL;
for (i=0;i<MAX_KEY_TABLE;i++) {
if ((pTable->KeyTable[i].bInUse == TRUE) &&
IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
!compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
if (dwKeyIndex == 0xFFFFFFFF) {
if (pTable->KeyTable[i].PairwiseKey.bKeyValid == TRUE) {
*pKey = &(pTable->KeyTable[i].PairwiseKey);
Expand Down Expand Up @@ -245,7 +245,7 @@ BOOL KeybSetKey(
j = i;
}
if ((pTable->KeyTable[i].bInUse == TRUE) &&
IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
!compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
// found table already exist
if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
// Pairwise key
Expand Down Expand Up @@ -427,7 +427,7 @@ BOOL KeybRemoveKey(
} else {
for (i=0;i<MAX_KEY_TABLE;i++) {
if ( (pTable->KeyTable[i].bInUse == TRUE) &&
IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
!compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {

if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE;
Expand Down Expand Up @@ -483,7 +483,7 @@ BOOL KeybRemoveAllKey(

for (i=0;i<MAX_KEY_TABLE;i++) {
if ((pTable->KeyTable[i].bInUse == TRUE) &&
IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
!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;
Expand Down Expand Up @@ -561,7 +561,7 @@ BOOL KeybGetTransmitKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyType,
*pKey = NULL;
for (i=0;i<MAX_KEY_TABLE;i++) {
if ((pTable->KeyTable[i].bInUse == TRUE) &&
IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) {
!compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {

if (dwKeyType == PAIRWISE_KEY) {

Expand Down
6 changes: 0 additions & 6 deletions drivers/staging/vt6656/tether.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,6 @@ S802_11Header, *PS802_11Header;
(*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0) \
)

#define IS_ETH_ADDRESS_EQUAL(pbyAddr1, pbyAddr2) ( \
(*(PDWORD)(pbyAddr1) == *(PDWORD)(pbyAddr2)) && \
(*(PWORD)((PBYTE)(pbyAddr1) + 4) == \
*(PWORD)((PBYTE)(pbyAddr2) + 4)) \
)

/*--------------------- Export Classes ----------------------------*/

/*--------------------- Export Variables --------------------------*/
Expand Down
5 changes: 3 additions & 2 deletions drivers/staging/vt6656/wctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ BOOL WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader)
for (ii = 0; ii < DUPLICATE_RX_CACHE_LENGTH; ii++) {
pCacheEntry = &(pCache->asCacheEntry[uIndex]);
if ((pCacheEntry->wFmSequence == pMACHeader->wSeqCtl) &&
(IS_ETH_ADDRESS_EQUAL (&(pCacheEntry->abyAddr2[0]), &(pMACHeader->abyAddr2[0]))) &&
(!compare_ether_addr(&(pCacheEntry->abyAddr2[0]),
&(pMACHeader->abyAddr2[0]))) &&
(LOBYTE(pCacheEntry->wFrameCtl) == LOBYTE(pMACHeader->wFrameCtl))
) {
/* Duplicate match */
Expand Down Expand Up @@ -118,7 +119,7 @@ unsigned int WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader)

for (ii = 0; ii < pDevice->cbDFCB; ii++) {
if ((pDevice->sRxDFCB[ii].bInUse == TRUE) &&
(IS_ETH_ADDRESS_EQUAL(&(pDevice->sRxDFCB[ii].abyAddr2[0]),
(!compare_ether_addr(&(pDevice->sRxDFCB[ii].abyAddr2[0]),
&(pMACHeader->abyAddr2[0])))) {
return ii;
}
Expand Down
9 changes: 2 additions & 7 deletions drivers/staging/vt6656/wmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1705,7 +1705,8 @@ s_vMgrRxDeauthentication(
pDevice->fWPA_Authened = FALSE;
DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP deauthed me, reason=%d.\n", cpu_to_le16((*(sFrame.pwReason))));
// TODO: update BSS list for specific BSSID if pre-authentication case
if (IS_ETH_ADDRESS_EQUAL(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID)) {
if (!compare_ether_addr(sFrame.pHdr->sA3.abyAddr3,
pMgmt->abyCurrBSSID)) {
if (pMgmt->eCurrState >= WMAC_STATE_AUTHPENDING) {
pMgmt->sNodeDBTable[0].bActive = FALSE;
pMgmt->eCurrMode = WMAC_MODE_STANDBY;
Expand Down Expand Up @@ -3099,12 +3100,6 @@ s_vMgrSynchBSS (
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
/* unsigned int ii, uSameBssidNum=0; */

// for (ii = 0; ii < MAX_BSS_NUM; ii++) {
// if (pMgmt->sBSSList[ii].bActive &&
// IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) {
// uSameBssidNum++;
// }
// }
// if( uSameBssidNum>=2) { //we only check AP in hidden sssid mode
if ((pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) || //networkmanager 0.7.0 does not give the pairwise-key selsection,
(pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) { // so we need re-selsect it according to real pairwise-key info.
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/vt6656/wpactl.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ int wpa_set_wpadev(PSDevice pDevice, int val)

} else {
// Key Table Full
if (IS_ETH_ADDRESS_EQUAL(&param->addr[0], pDevice->abyBSSID)) {
if (!compare_ether_addr(&param->addr[0], pDevice->abyBSSID)) {
//DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -Key Table Full.2\n"));
return -EINVAL;

Expand Down

0 comments on commit 4722a26

Please sign in to comment.