staging, vt6656/wpactl.c: A basic style cleanup

This patch cleans up the coding style in
drivers/staging/vt6656/wpactl.c to closer match the generally accepted
kernel CodingStyle. It is by no means a "make it perfect" patch, but
it does get the file a fair bit closer to matching the accepted style
(whomever was involved in the evolution of this file seriously need to
configure their editors to maintain a consistent style - it was a
mess).

Besides pure style cleanups I also took the liberty of removing some
pointless parens, some unneeded casts and removing some commented out code
(it was obviously not used and git has it if it's ever needed in the
future).

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jesper Juhl 2012-01-16 21:28:23 +01:00 committed by Greg Kroah-Hartman
parent 08afcf9c9f
commit 4e1efd6e85

View file

@ -46,23 +46,18 @@
#define VIAWGET_WPA_MAX_BUF_SIZE 1024 #define VIAWGET_WPA_MAX_BUF_SIZE 1024
static const int frequency_list[] = { static const int frequency_list[] = {
2412, 2417, 2422, 2427, 2432, 2437, 2442, 2412, 2417, 2422, 2427, 2432, 2437, 2442,
2447, 2452, 2457, 2462, 2467, 2472, 2484 2447, 2452, 2457, 2462, 2467, 2472, 2484
}; };
/*--------------------- Static Classes ----------------------------*/ /*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/ /*--------------------- Static Variables --------------------------*/
//static int msglevel =MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO;
static int msglevel =MSG_LEVEL_INFO;
/*--------------------- Static Functions --------------------------*/ /*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/ /*--------------------- Export Variables --------------------------*/
static void wpadev_setup(struct net_device *dev) static void wpadev_setup(struct net_device *dev)
{ {
@ -72,9 +67,9 @@ static void wpadev_setup(struct net_device *dev)
dev->addr_len = ETH_ALEN; dev->addr_len = ETH_ALEN;
dev->tx_queue_len = 1000; dev->tx_queue_len = 1000;
memset(dev->broadcast,0xFF, ETH_ALEN); memset(dev->broadcast, 0xFF, ETH_ALEN);
dev->flags = IFF_BROADCAST|IFF_MULTICAST; dev->flags = IFF_BROADCAST | IFF_MULTICAST;
} }
/* /*
@ -90,12 +85,11 @@ static void wpadev_setup(struct net_device *dev)
* Return Value: * Return Value:
* *
*/ */
static int wpa_init_wpadev(PSDevice pDevice) static int wpa_init_wpadev(PSDevice pDevice)
{ {
PSDevice wpadev_priv; PSDevice wpadev_priv;
struct net_device *dev = pDevice->dev; struct net_device *dev = pDevice->dev;
int ret=0; int ret = 0;
pDevice->wpadev = alloc_netdev(sizeof(PSDevice), "vntwpa", wpadev_setup); pDevice->wpadev = alloc_netdev(sizeof(PSDevice), "vntwpa", wpadev_setup);
if (pDevice->wpadev == NULL) if (pDevice->wpadev == NULL)
@ -128,7 +122,6 @@ static int wpa_init_wpadev(PSDevice pDevice)
return 0; return 0;
} }
/* /*
* Description: * Description:
* unregister net_device (wpadev) * unregister net_device (wpadev)
@ -141,7 +134,6 @@ static int wpa_init_wpadev(PSDevice pDevice)
* Return Value: * Return Value:
* *
*/ */
static int wpa_release_wpadev(PSDevice pDevice) static int wpa_release_wpadev(PSDevice pDevice)
{ {
if (pDevice->skb) { if (pDevice->skb) {
@ -160,10 +152,6 @@ static int wpa_release_wpadev(PSDevice pDevice)
return 0; return 0;
} }
/* /*
* Description: * Description:
* Set enable/disable dev for wpa supplicant deamon * Set enable/disable dev for wpa supplicant deamon
@ -177,12 +165,10 @@ static int wpa_release_wpadev(PSDevice pDevice)
* Return Value: * Return Value:
* *
*/ */
int wpa_set_wpadev(PSDevice pDevice, int val) int wpa_set_wpadev(PSDevice pDevice, int val)
{ {
if (val) if (val)
return wpa_init_wpadev(pDevice); return wpa_init_wpadev(pDevice);
else
return wpa_release_wpadev(pDevice); return wpa_release_wpadev(pDevice);
} }
@ -199,25 +185,24 @@ int wpa_set_wpadev(PSDevice pDevice, int val)
* Return Value: * Return Value:
* *
*/ */
int wpa_set_keys(PSDevice pDevice, void *ctx, BOOL fcpfkernel) int wpa_set_keys(PSDevice pDevice, void *ctx, BOOL fcpfkernel)
{ {
struct viawget_wpa_param *param=ctx; struct viawget_wpa_param *param = ctx;
PSMgmtObject pMgmt = &(pDevice->sMgmtObj); PSMgmtObject pMgmt = &pDevice->sMgmtObj;
DWORD dwKeyIndex = 0; DWORD dwKeyIndex = 0;
BYTE abyKey[MAX_KEY_LEN]; BYTE abyKey[MAX_KEY_LEN];
BYTE abySeq[MAX_KEY_LEN]; BYTE abySeq[MAX_KEY_LEN];
QWORD KeyRSC; QWORD KeyRSC;
// NDIS_802_11_KEY_RSC KeyRSC;
BYTE byKeyDecMode = KEY_CTL_WEP; BYTE byKeyDecMode = KEY_CTL_WEP;
int ret = 0; int ret = 0;
int uu, ii; int uu;
int ii;
if (param->u.wpa_key.alg_name > WPA_ALG_CCMP) if (param->u.wpa_key.alg_name > WPA_ALG_CCMP)
return -EINVAL; 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) { if (param->u.wpa_key.alg_name == WPA_ALG_NONE) {
pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
pDevice->bEncryptionEnable = FALSE; pDevice->bEncryptionEnable = FALSE;
@ -233,12 +218,12 @@ int wpa_set_wpadev(PSDevice pDevice, int val)
return -EINVAL; return -EINVAL;
spin_unlock_irq(&pDevice->lock); spin_unlock_irq(&pDevice->lock);
if(param->u.wpa_key.key && fcpfkernel) { if (param->u.wpa_key.key && fcpfkernel) {
memcpy(&abyKey[0], param->u.wpa_key.key, param->u.wpa_key.key_len); memcpy(&abyKey[0], param->u.wpa_key.key, param->u.wpa_key.key_len);
} } else {
else {
if (param->u.wpa_key.key && if (param->u.wpa_key.key &&
copy_from_user(&abyKey[0], param->u.wpa_key.key, param->u.wpa_key.key_len)) { copy_from_user(&abyKey[0], param->u.wpa_key.key,
param->u.wpa_key.key_len)) {
spin_lock_irq(&pDevice->lock); spin_lock_irq(&pDevice->lock);
return -EINVAL; return -EINVAL;
} }
@ -250,8 +235,7 @@ int wpa_set_wpadev(PSDevice pDevice, int val)
if (param->u.wpa_key.alg_name == WPA_ALG_WEP) { if (param->u.wpa_key.alg_name == WPA_ALG_WEP) {
if (dwKeyIndex > 3) { if (dwKeyIndex > 3) {
return -EINVAL; return -EINVAL;
} } else {
else {
if (param->u.wpa_key.set_tx) { if (param->u.wpa_key.set_tx) {
pDevice->byKeyIndex = (BYTE)dwKeyIndex; pDevice->byKeyIndex = (BYTE)dwKeyIndex;
pDevice->bTransmitKey = TRUE; pDevice->bTransmitKey = TRUE;
@ -277,12 +261,12 @@ int wpa_set_wpadev(PSDevice pDevice, int val)
return -EINVAL; return -EINVAL;
spin_unlock_irq(&pDevice->lock); spin_unlock_irq(&pDevice->lock);
if(param->u.wpa_key.seq && fcpfkernel) { if (param->u.wpa_key.seq && fcpfkernel) {
memcpy(&abySeq[0], param->u.wpa_key.seq, param->u.wpa_key.seq_len); memcpy(&abySeq[0], param->u.wpa_key.seq, param->u.wpa_key.seq_len);
} } else {
else {
if (param->u.wpa_key.seq && if (param->u.wpa_key.seq &&
copy_from_user(&abySeq[0], param->u.wpa_key.seq, param->u.wpa_key.seq_len)) { copy_from_user(&abySeq[0], param->u.wpa_key.seq,
param->u.wpa_key.seq_len)) {
spin_lock_irq(&pDevice->lock); spin_lock_irq(&pDevice->lock);
return -EINVAL; return -EINVAL;
} }
@ -295,7 +279,6 @@ int wpa_set_wpadev(PSDevice pDevice, int val)
LODWORD(KeyRSC) |= (abySeq[ii] << (ii * 8)); LODWORD(KeyRSC) |= (abySeq[ii] << (ii * 8));
else else
HIDWORD(KeyRSC) |= (abySeq[ii] << ((ii-4) * 8)); HIDWORD(KeyRSC) |= (abySeq[ii] << ((ii-4) * 8));
//KeyRSC |= (abySeq[ii] << (ii * 8));
} }
dwKeyIndex |= 1 << 29; dwKeyIndex |= 1 << 29;
} }
@ -343,7 +326,6 @@ int wpa_set_wpadev(PSDevice pDevice, int val)
if ((byKeyDecMode == KEY_CTL_TKIP) && if ((byKeyDecMode == KEY_CTL_TKIP) &&
(param->u.wpa_key.key_len != MAX_KEY_LEN)) { (param->u.wpa_key.key_len != MAX_KEY_LEN)) {
// TKIP Key must be 256 bits // 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"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "return- TKIP Key must be 256 bits!\n");
return -EINVAL; return -EINVAL;
} }
@ -359,9 +341,7 @@ int wpa_set_wpadev(PSDevice pDevice, int val)
/* if broadcast, set the key as every key entry's group key */ /* if broadcast, set the key as every key entry's group key */
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Groupe Key Assign.\n"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Groupe Key Assign.\n");
if ((KeybSetAllGroupKey(pDevice, if ((KeybSetAllGroupKey(pDevice, &(pDevice->sKey), dwKeyIndex,
&(pDevice->sKey),
dwKeyIndex,
param->u.wpa_key.key_len, param->u.wpa_key.key_len,
(PQWORD) &(KeyRSC), (PQWORD) &(KeyRSC),
(PBYTE)abyKey, (PBYTE)abyKey,
@ -376,12 +356,9 @@ int wpa_set_wpadev(PSDevice pDevice, int val)
byKeyDecMode byKeyDecMode
) == TRUE) ) { ) == TRUE) ) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "GROUP Key Assign.\n"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "GROUP Key Assign.\n");
} else { } else {
//DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -KeybSetDefaultKey Fail.0\n"));
return -EINVAL; return -EINVAL;
} }
} else { } else {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key Assign.\n"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key Assign.\n");
// BSSID not 0xffffffffffff // BSSID not 0xffffffffffff
@ -390,29 +367,21 @@ int wpa_set_wpadev(PSDevice pDevice, int val)
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key can't be WEP\n"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key can't be WEP\n");
return -EINVAL; return -EINVAL;
} }
dwKeyIndex |= (1 << 30); // set pairwise key dwKeyIndex |= (1 << 30); // set pairwise key
if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) { if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) {
//DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - WMAC_CONFIG_IBSS_STA\n")); //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - WMAC_CONFIG_IBSS_STA\n"));
return -EINVAL; return -EINVAL;
} }
if (KeybSetKey(pDevice, if (KeybSetKey(pDevice, &(pDevice->sKey), &param->addr[0],
&(pDevice->sKey), dwKeyIndex, param->u.wpa_key.key_len,
&param->addr[0], (PQWORD) &(KeyRSC), (PBYTE)abyKey, byKeyDecMode
dwKeyIndex,
param->u.wpa_key.key_len,
(PQWORD) &(KeyRSC),
(PBYTE)abyKey,
byKeyDecMode
) == TRUE) { ) == TRUE) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key Set\n"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key Set\n");
} else { } else {
// Key Table Full // Key Table Full
if (!compare_ether_addr(&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")); //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -Key Table Full.2\n"));
return -EINVAL; return -EINVAL;
} else { } else {
// Save Key and configure just before associate/reassociate to BSSID // Save Key and configure just before associate/reassociate to BSSID
// we do not implement now // we do not implement now
@ -426,18 +395,7 @@ int wpa_set_wpadev(PSDevice pDevice, int val)
} }
pDevice->bEncryptionEnable = TRUE; pDevice->bEncryptionEnable = TRUE;
/*
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; return ret;
} }
@ -454,12 +412,9 @@ int wpa_set_wpadev(PSDevice pDevice, int val)
* Return Value: * Return Value:
* *
*/ */
static int wpa_set_wpa(PSDevice pDevice, struct viawget_wpa_param *param)
static int wpa_set_wpa(PSDevice pDevice,
struct viawget_wpa_param *param)
{ {
PSMgmtObject pMgmt = &pDevice->sMgmtObj;
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
int ret = 0; int ret = 0;
pMgmt->eAuthenMode = WMAC_AUTH_OPEN; pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
@ -468,9 +423,6 @@ static int wpa_set_wpa(PSDevice pDevice,
return ret; return ret;
} }
/* /*
* Description: * Description:
* set disassociate * set disassociate
@ -484,25 +436,21 @@ static int wpa_set_wpa(PSDevice pDevice,
* Return Value: * Return Value:
* *
*/ */
static int wpa_set_disassociate(PSDevice pDevice, struct viawget_wpa_param *param)
static int wpa_set_disassociate(PSDevice pDevice,
struct viawget_wpa_param *param)
{ {
PSMgmtObject pMgmt = &(pDevice->sMgmtObj); PSMgmtObject pMgmt = &pDevice->sMgmtObj;
int ret = 0; int ret = 0;
spin_lock_irq(&pDevice->lock); spin_lock_irq(&pDevice->lock);
if (pDevice->bLinkPass) { if (pDevice->bLinkPass) {
if (!memcmp(param->addr, pMgmt->abyCurrBSSID, 6)) if (!memcmp(param->addr, pMgmt->abyCurrBSSID, 6))
bScheduleCommand((void *) pDevice, WLAN_CMD_DISASSOCIATE, NULL); bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
} }
spin_unlock_irq(&pDevice->lock); spin_unlock_irq(&pDevice->lock);
return ret; return ret;
} }
/* /*
* Description: * Description:
* enable scan process * enable scan process
@ -516,37 +464,31 @@ static int wpa_set_disassociate(PSDevice pDevice,
* Return Value: * Return Value:
* *
*/ */
static int wpa_set_scan(PSDevice pDevice, struct viawget_wpa_param *param)
static int wpa_set_scan(PSDevice pDevice,
struct viawget_wpa_param *param)
{ {
int ret = 0; int ret = 0;
/**set ap_scan=1&&scan_ssid=1 under hidden ssid mode**/ /**set ap_scan=1&&scan_ssid=1 under hidden ssid mode**/
PSMgmtObject pMgmt = &(pDevice->sMgmtObj); PSMgmtObject pMgmt = &pDevice->sMgmtObj;
PWLAN_IE_SSID pItemSSID; PWLAN_IE_SSID pItemSSID;
printk("wpa_set_scan-->desired [ssid=%s,ssid_len=%d]\n", printk("wpa_set_scan-->desired [ssid=%s,ssid_len=%d]\n",
param->u.scan_req.ssid,param->u.scan_req.ssid_len); param->u.scan_req.ssid,param->u.scan_req.ssid_len);
// Set the SSID // Set the SSID
memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
pItemSSID->byElementID = WLAN_EID_SSID; pItemSSID->byElementID = WLAN_EID_SSID;
memcpy(pItemSSID->abySSID, param->u.scan_req.ssid, param->u.scan_req.ssid_len); memcpy(pItemSSID->abySSID, param->u.scan_req.ssid, param->u.scan_req.ssid_len);
pItemSSID->len = param->u.scan_req.ssid_len; pItemSSID->len = param->u.scan_req.ssid_len;
spin_lock_irq(&pDevice->lock); spin_lock_irq(&pDevice->lock);
BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass); BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass);
/* bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL); */ bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN,
bScheduleCommand((void *) pDevice,
WLAN_CMD_BSSID_SCAN,
pMgmt->abyDesireSSID); pMgmt->abyDesireSSID);
spin_unlock_irq(&pDevice->lock); spin_unlock_irq(&pDevice->lock);
return ret; return ret;
} }
/* /*
* Description: * Description:
* get bssid * get bssid
@ -560,19 +502,15 @@ pItemSSID->len = param->u.scan_req.ssid_len;
* Return Value: * Return Value:
* *
*/ */
static int wpa_get_bssid(PSDevice pDevice, struct viawget_wpa_param *param)
static int wpa_get_bssid(PSDevice pDevice,
struct viawget_wpa_param *param)
{ {
PSMgmtObject pMgmt = &(pDevice->sMgmtObj); PSMgmtObject pMgmt = &pDevice->sMgmtObj;
int ret = 0; int ret = 0;
memcpy(param->u.wpa_associate.bssid, pMgmt->abyCurrBSSID , 6); memcpy(param->u.wpa_associate.bssid, pMgmt->abyCurrBSSID, 6);
return ret; return ret;
} }
/* /*
* Description: * Description:
* get bssid * get bssid
@ -586,24 +524,20 @@ static int wpa_get_bssid(PSDevice pDevice,
* Return Value: * Return Value:
* *
*/ */
static int wpa_get_ssid(PSDevice pDevice, struct viawget_wpa_param *param)
static int wpa_get_ssid(PSDevice pDevice,
struct viawget_wpa_param *param)
{ {
PSMgmtObject pMgmt = &(pDevice->sMgmtObj); PSMgmtObject pMgmt = &pDevice->sMgmtObj;
PWLAN_IE_SSID pItemSSID; PWLAN_IE_SSID pItemSSID;
int ret = 0; int ret = 0;
pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
memcpy(param->u.wpa_associate.ssid, pItemSSID->abySSID , pItemSSID->len); memcpy(param->u.wpa_associate.ssid, pItemSSID->abySSID, pItemSSID->len);
param->u.wpa_associate.ssid_len = pItemSSID->len; param->u.wpa_associate.ssid_len = pItemSSID->len;
return ret; return ret;
} }
/* /*
* Description: * Description:
* get scan results * get scan results
@ -617,62 +551,44 @@ static int wpa_get_ssid(PSDevice pDevice,
* Return Value: * Return Value:
* *
*/ */
static int wpa_get_scan(PSDevice pDevice, struct viawget_wpa_param *param)
static int wpa_get_scan(PSDevice pDevice,
struct viawget_wpa_param *param)
{ {
struct viawget_scan_result *scan_buf; struct viawget_scan_result *scan_buf;
PSMgmtObject pMgmt = &(pDevice->sMgmtObj); PSMgmtObject pMgmt = &pDevice->sMgmtObj;
PWLAN_IE_SSID pItemSSID; PWLAN_IE_SSID pItemSSID;
PKnownBSS pBSS; PKnownBSS pBSS;
PBYTE pBuf; PBYTE pBuf;
int ret = 0; int ret = 0;
u16 count = 0; u16 count = 0;
u16 ii, jj; u16 ii;
long ldBm;//James //add u16 jj;
long ldBm; //James //add
//******mike:bubble sort by stronger RSSI*****// //******mike:bubble sort by stronger RSSI*****//
PBYTE ptempBSS; PBYTE ptempBSS;
ptempBSS = kmalloc(sizeof(KnownBSS), GFP_ATOMIC);
ptempBSS = kmalloc(sizeof(KnownBSS), (int)GFP_ATOMIC);
if (ptempBSS == NULL) { if (ptempBSS == NULL) {
printk("bubble sort kmalloc memory fail@@@\n"); printk("bubble sort kmalloc memory fail@@@\n");
ret = -ENOMEM; ret = -ENOMEM;
return ret; return ret;
} }
for (ii = 0; ii < MAX_BSS_NUM; ii++) { for (ii = 0; ii < MAX_BSS_NUM; ii++) {
for (jj = 0; jj < MAX_BSS_NUM - ii - 1; jj++) { for (jj = 0; jj < MAX_BSS_NUM - ii - 1; jj++) {
if ((pMgmt->sBSSList[jj].bActive != TRUE)
if ((pMgmt->sBSSList[jj].bActive != TRUE) || || ((pMgmt->sBSSList[jj].uRSSI > pMgmt->sBSSList[jj + 1].uRSSI)
&& (pMgmt->sBSSList[jj + 1].bActive != FALSE))) {
((pMgmt->sBSSList[jj].uRSSI>pMgmt->sBSSList[jj+1].uRSSI) &&(pMgmt->sBSSList[jj+1].bActive!=FALSE))) { memcpy(ptempBSS,&pMgmt->sBSSList[jj], sizeof(KnownBSS));
memcpy(&pMgmt->sBSSList[jj], &pMgmt->sBSSList[jj + 1],
memcpy(ptempBSS,&pMgmt->sBSSList[jj],sizeof(KnownBSS)); sizeof(KnownBSS));
memcpy(&pMgmt->sBSSList[jj + 1], ptempBSS, sizeof(KnownBSS));
memcpy(&pMgmt->sBSSList[jj],&pMgmt->sBSSList[jj+1],sizeof(KnownBSS));
memcpy(&pMgmt->sBSSList[jj+1],ptempBSS,sizeof(KnownBSS));
} }
} }
} }
kfree(ptempBSS); kfree(ptempBSS);
// printk("bubble sort result:\n");
count = 0; count = 0;
pBSS = &(pMgmt->sBSSList[0]); pBSS = &(pMgmt->sBSSList[0]);
for (ii = 0; ii < MAX_BSS_NUM; ii++) { for (ii = 0; ii < MAX_BSS_NUM; ii++) {
@ -682,7 +598,7 @@ static int wpa_get_scan(PSDevice pDevice,
count++; 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) { if (pBuf == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
@ -690,7 +606,7 @@ static int wpa_get_scan(PSDevice pDevice,
} }
scan_buf = (struct viawget_scan_result *)pBuf; scan_buf = (struct viawget_scan_result *)pBuf;
pBSS = &(pMgmt->sBSSList[0]); pBSS = &(pMgmt->sBSSList[0]);
for (ii = 0, jj = 0; ii < MAX_BSS_NUM ; ii++) { for (ii = 0, jj = 0; ii < MAX_BSS_NUM; ii++) {
pBSS = &(pMgmt->sBSSList[ii]); pBSS = &(pMgmt->sBSSList[ii]);
if (pBSS->bActive) { if (pBSS->bActive) {
if (jj >= count) if (jj >= count)
@ -700,16 +616,15 @@ static int wpa_get_scan(PSDevice pDevice,
memcpy(scan_buf->ssid, pItemSSID->abySSID, pItemSSID->len); memcpy(scan_buf->ssid, pItemSSID->abySSID, pItemSSID->len);
scan_buf->ssid_len = pItemSSID->len; scan_buf->ssid_len = pItemSSID->len;
scan_buf->freq = frequency_list[pBSS->uChannel-1]; scan_buf->freq = frequency_list[pBSS->uChannel-1];
scan_buf->caps = pBSS->wCapInfo; //DavidWang for sharemode scan_buf->caps = pBSS->wCapInfo; // DavidWang for sharemode
RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm); RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
if(-ldBm<50){ if (-ldBm < 50)
scan_buf->qual = 100; scan_buf->qual = 100;
}else if(-ldBm > 90) { else if (-ldBm > 90)
scan_buf->qual = 0; scan_buf->qual = 0;
}else { else
scan_buf->qual=(40-(-ldBm-50))*100/40; scan_buf->qual=(40-(-ldBm-50))*100/40;
}
//James //James
//scan_buf->caps = pBSS->wCapInfo; //scan_buf->caps = pBSS->wCapInfo;
@ -734,18 +649,16 @@ static int wpa_get_scan(PSDevice pDevice,
if (jj < count) if (jj < count)
count = jj; 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; ret = -EFAULT;
}
param->u.scan_results.scan_count = count; 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); kfree(pBuf);
return ret; return ret;
} }
/* /*
* Description: * Description:
* set associate with AP * set associate with AP
@ -759,11 +672,9 @@ static int wpa_get_scan(PSDevice pDevice,
* Return Value: * Return Value:
* *
*/ */
static int wpa_set_associate(PSDevice pDevice, struct viawget_wpa_param *param)
static int wpa_set_associate(PSDevice pDevice,
struct viawget_wpa_param *param)
{ {
PSMgmtObject pMgmt = &(pDevice->sMgmtObj); PSMgmtObject pMgmt = &pDevice->sMgmtObj;
PWLAN_IE_SSID pItemSSID; PWLAN_IE_SSID pItemSSID;
BYTE abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; BYTE abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
BYTE abyWPAIE[64]; BYTE abyWPAIE[64];
@ -777,7 +688,7 @@ static int wpa_set_associate(PSDevice pDevice,
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "auth_alg = %d\n", param->u.wpa_associate.auth_alg); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "auth_alg = %d\n", param->u.wpa_associate.auth_alg);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "mode = %d\n", param->u.wpa_associate.mode); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "mode = %d\n", param->u.wpa_associate.mode);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_ie_len = %d\n", param->u.wpa_associate.wpa_ie_len); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_ie_len = %d\n", param->u.wpa_associate.wpa_ie_len);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Roaming dBm = %d\n", param->u.wpa_associate.roam_dbm); //Davidwang DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Roaming dBm = %d\n", param->u.wpa_associate.roam_dbm); // Davidwang
if (param->u.wpa_associate.wpa_ie) { if (param->u.wpa_associate.wpa_ie) {
if (param->u.wpa_associate.wpa_ie_len > sizeof(abyWPAIE)) if (param->u.wpa_associate.wpa_ie_len > sizeof(abyWPAIE))
@ -833,7 +744,6 @@ static int wpa_set_associate(PSDevice pDevice,
case CIPHER_WEP104: case CIPHER_WEP104:
pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
bwepEnabled = TRUE; bwepEnabled = TRUE;
// printk("****************wpa_set_associate:set CIPHER_WEP40_104\n");
break; break;
case CIPHER_NONE: case CIPHER_NONE:
if (param->u.wpa_associate.group_suite == CIPHER_CCMP) if (param->u.wpa_associate.group_suite == CIPHER_CCMP)
@ -846,22 +756,18 @@ static int wpa_set_associate(PSDevice pDevice,
} }
pMgmt->Roam_dbm = param->u.wpa_associate.roam_dbm; pMgmt->Roam_dbm = param->u.wpa_associate.roam_dbm;
// if ((pMgmt->Roam_dbm > 40)&&(pMgmt->Roam_dbm<80)) if (pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) { // @wep-sharekey
// pDevice->bEnableRoaming = TRUE;
if (pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) { //@wep-sharekey
pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
pMgmt->bShareKeyAlgorithm = TRUE; pMgmt->bShareKeyAlgorithm = TRUE;
} } else if (pMgmt->eAuthenMode == WMAC_AUTH_OPEN) {
else if (pMgmt->eAuthenMode == WMAC_AUTH_OPEN) {
if(bwepEnabled==TRUE) { //@open-wep if(bwepEnabled==TRUE) { //@open-wep
pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
} } else {
else { //@only open // @only open
pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
} }
} }
//mike save old encryption status // mike save old encryption status
pDevice->eOldEncryptionStatus = pDevice->eEncryptionStatus; pDevice->eOldEncryptionStatus = pDevice->eEncryptionStatus;
if (pDevice->eEncryptionStatus != Ndis802_11EncryptionDisabled) if (pDevice->eEncryptionStatus != Ndis802_11EncryptionDisabled)
@ -871,21 +777,20 @@ static int wpa_set_associate(PSDevice pDevice,
if ((pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) || if ((pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) ||
((pMgmt->eAuthenMode == WMAC_AUTH_OPEN) && (bwepEnabled==TRUE))) { ((pMgmt->eAuthenMode == WMAC_AUTH_OPEN) && (bwepEnabled==TRUE))) {
//mike re-comment:open-wep && sharekey-wep needn't do initial key!! // mike re-comment:open-wep && sharekey-wep needn't do initial key!!
} else {
}
else
KeyvInitTable(pDevice,&pDevice->sKey); KeyvInitTable(pDevice,&pDevice->sKey);
}
spin_lock_irq(&pDevice->lock); spin_lock_irq(&pDevice->lock);
pDevice->bLinkPass = FALSE; pDevice->bLinkPass = FALSE;
ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW);
memset(pMgmt->abyCurrBSSID, 0, 6); memset(pMgmt->abyCurrBSSID, 0, 6);
pMgmt->eCurrState = WMAC_STATE_IDLE; pMgmt->eCurrState = WMAC_STATE_IDLE;
netif_stop_queue(pDevice->dev); netif_stop_queue(pDevice->dev);
/*******search if ap_scan=2 ,which is associating request in hidden ssid mode ****/ /******* search if ap_scan=2, which is associating request in hidden ssid mode ****/
{ {
PKnownBSS pCurr = NULL; PKnownBSS pCurr = NULL;
pCurr = BSSpSearchBSSList(pDevice, pCurr = BSSpSearchBSSList(pDevice,
pMgmt->abyDesireBSSID, pMgmt->abyDesireBSSID,
@ -895,20 +800,19 @@ static int wpa_set_associate(PSDevice pDevice,
if (pCurr == NULL){ if (pCurr == NULL){
printk("wpa_set_associate---->hidden mode site survey before associate.......\n"); printk("wpa_set_associate---->hidden mode site survey before associate.......\n");
bScheduleCommand((void *) pDevice, bScheduleCommand((void *)pDevice,
WLAN_CMD_BSSID_SCAN, WLAN_CMD_BSSID_SCAN,
pMgmt->abyDesireSSID); pMgmt->abyDesireSSID);
} }
} }
/****************************************************************/ /****************************************************************/
bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL);
spin_unlock_irq(&pDevice->lock); spin_unlock_irq(&pDevice->lock);
return ret; return ret;
} }
/* /*
* Description: * Description:
* wpa_ioctl main function supported for wpa supplicant * wpa_ioctl main function supported for wpa supplicant
@ -922,7 +826,6 @@ static int wpa_set_associate(PSDevice pDevice,
* Return Value: * Return Value:
* *
*/ */
int wpa_ioctl(PSDevice pDevice, struct iw_point *p) int wpa_ioctl(PSDevice pDevice, struct iw_point *p)
{ {
struct viawget_wpa_param *param; struct viawget_wpa_param *param;
@ -933,7 +836,7 @@ int wpa_ioctl(PSDevice pDevice, struct iw_point *p)
p->length > VIAWGET_WPA_MAX_BUF_SIZE || !p->pointer) p->length > VIAWGET_WPA_MAX_BUF_SIZE || !p->pointer)
return -EINVAL; return -EINVAL;
param = kmalloc((int)p->length, (int)GFP_KERNEL); param = kmalloc((int)p->length, GFP_KERNEL);
if (param == NULL) if (param == NULL)
return -ENOMEM; return -ENOMEM;
@ -1000,7 +903,6 @@ int wpa_ioctl(PSDevice pDevice, struct iw_point *p)
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_ioctl: unknown cmd=%d\n", DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_ioctl: unknown cmd=%d\n",
param->cmd); param->cmd);
return -EOPNOTSUPP; return -EOPNOTSUPP;
break;
} }
if ((ret == 0) && wpa_ioctl) { if ((ret == 0) && wpa_ioctl) {
@ -1012,7 +914,5 @@ int wpa_ioctl(PSDevice pDevice, struct iw_point *p)
out: out:
kfree(param); kfree(param);
return ret; return ret;
} }