Commit 450238ea authored by Moritz Muehlenhoff's avatar Moritz Muehlenhoff Committed by Greg Kroah-Hartman

Staging: wlan-ng: prism2mgmt.c: Coding style cleanups

Signed-off-by: default avatarMoritz Muehlenhoff <jmm@debian.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 21dc0f89
......@@ -57,9 +57,6 @@
* --------------------------------------------------------------------
*/
/*================================================================*/
/* System Includes */
#include <linux/if_arp.h>
#include <linux/module.h>
#include <linux/kernel.h>
......@@ -137,8 +134,9 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
hw->ident_sta_fw.minor,
hw->ident_sta_fw.variant) <
HFA384x_FIRMWARE_VERSION(1,3,2)) {
printk(KERN_ERR "HostScan not supported with current firmware (<1.3.2).\n");
HFA384x_FIRMWARE_VERSION(1, 3, 2)) {
printk(KERN_ERR
"HostScan not supported with current firmware (<1.3.2).\n");
result = 1;
msg->resultcode.data = P80211ENUM_resultcode_not_supported;
goto exit;
......@@ -148,8 +146,9 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
/* save current roaming mode */
result = hfa384x_drvr_getconfig16(hw,
HFA384x_RID_CNFROAMINGMODE, &roamingmode);
if ( result ) {
HFA384x_RID_CNFROAMINGMODE,
&roamingmode);
if (result) {
printk(KERN_ERR "getconfig(ROAMMODE) failed. result=%d\n",
result);
msg->resultcode.data =
......@@ -161,7 +160,7 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFROAMINGMODE,
HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM);
if ( result ) {
if (result) {
printk(KERN_ERR "setconfig(ROAMINGMODE) failed. result=%d\n",
result);
msg->resultcode.data =
......@@ -173,14 +172,16 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
hw->ident_sta_fw.minor,
hw->ident_sta_fw.variant) >
HFA384x_FIRMWARE_VERSION(1,5,0)) {
if (msg->scantype.data != P80211ENUM_scantype_active) {
HFA384x_FIRMWARE_VERSION(1, 5, 0)) {
if (msg->scantype.data != P80211ENUM_scantype_active)
word = host2hfa384x_16(msg->maxchanneltime.data);
} else {
else
word = 0;
}
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPASSIVESCANCTRL, word);
if ( result ) {
result =
hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPASSIVESCANCTRL,
word);
if (result) {
printk(KERN_WARNING "Passive scan not supported with "
"current firmware. (<1.5.1)\n");
}
......@@ -194,9 +195,10 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
word = 0;
for (i = 0; i < msg->channellist.data.len; i++) {
u8 channel = msg->channellist.data.data[i];
if (channel > 14) continue;
if (channel > 14)
continue;
/* channel 1 is BIT 0 ... channel 14 is BIT 13 */
word |= (1 << (channel-1));
word |= (1 << (channel - 1));
}
scanreq.channelList = host2hfa384x_16(word);
......@@ -206,7 +208,7 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
/* Enable the MAC port if it's not already enabled */
result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_PORTSTATUS, &word);
if ( result ) {
if (result) {
printk(KERN_ERR "getconfig(PORTSTATUS) failed. "
"result=%d\n", result);
msg->resultcode.data =
......@@ -219,8 +221,10 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFROAMINGMODE,
HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM);
if ( result ) {
printk(KERN_ERR "setconfig(ROAMINGMODE) failed. result=%d\n", result);
if (result) {
printk(KERN_ERR
"setconfig(ROAMINGMODE) failed. result=%d\n",
result);
msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure;
goto exit;
......@@ -230,17 +234,19 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
*/
wordbuf[0] = host2hfa384x_16(WLAN_SSID_MAXLEN);
get_random_bytes(&wordbuf[1], WLAN_SSID_MAXLEN);
result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFOWNSSID,
wordbuf, HFA384x_RID_CNFOWNSSID_LEN);
if ( result ) {
result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFOWNSSID,
wordbuf,
HFA384x_RID_CNFOWNSSID_LEN);
if (result) {
printk(KERN_ERR "Failed to set OwnSSID.\n");
msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure;
goto exit;
}
result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFDESIREDSSID,
wordbuf, HFA384x_RID_CNFDESIREDSSID_LEN);
if ( result ) {
result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID,
wordbuf,
HFA384x_RID_CNFDESIREDSSID_LEN);
if (result) {
printk(KERN_ERR "Failed to set DesiredSSID.\n");
msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure;
......@@ -250,7 +256,7 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFPORTTYPE,
HFA384x_PORTTYPE_IBSS);
if ( result ) {
if (result) {
printk(KERN_ERR "Failed to set CNFPORTTYPE.\n");
msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure;
......@@ -260,14 +266,14 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CREATEIBSS,
HFA384x_CREATEIBSS_JOINCREATEIBSS);
if ( result ) {
if (result) {
printk(KERN_ERR "Failed to set CREATEIBSS.\n");
msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure;
goto exit;
}
result = hfa384x_drvr_enable(hw, 0);
if ( result ) {
if (result) {
printk(KERN_ERR "drvr_enable(0) failed. "
"result=%d\n", result);
msg->resultcode.data =
......@@ -279,15 +285,15 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
/* Figure out our timeout first Kus, then HZ */
timeout = msg->channellist.data.len * msg->maxchanneltime.data;
timeout = (timeout * HZ)/1000;
timeout = (timeout * HZ) / 1000;
/* Issue the scan request */
hw->scanflag = 0;
result = hfa384x_drvr_setconfig( hw,
result = hfa384x_drvr_setconfig(hw,
HFA384x_RID_HOSTSCAN, &scanreq,
sizeof(hfa384x_HostScanRequest_data_t));
if ( result ) {
if (result) {
printk(KERN_ERR "setconfig(SCANREQUEST) failed. result=%d\n",
result);
msg->resultcode.data =
......@@ -309,7 +315,7 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
/* Disable port if we temporarily enabled it. */
if (istmpenable) {
result = hfa384x_drvr_disable(hw, 0);
if ( result ) {
if (result) {
printk(KERN_ERR "drvr_disable(0) failed. "
"result=%d\n", result);
msg->resultcode.data =
......@@ -321,7 +327,7 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
/* restore original roaming mode */
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE,
roamingmode);
if ( result ) {
if (result) {
printk(KERN_ERR "setconfig(ROAMMODE) failed. result=%d\n",
result);
msg->resultcode.data =
......@@ -332,13 +338,12 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
result = 0;
msg->resultcode.data = P80211ENUM_resultcode_success;
exit:
exit:
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
return result;
}
/*----------------------------------------------------------------
* prism2mgmt_scan_results
*
......@@ -372,15 +377,17 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
req->resultcode.status = P80211ENUM_msgitem_status_data_ok;
if (! hw->scanresults) {
printk(KERN_ERR "dot11req_scan_results can only be used after a successful dot11req_scan.\n");
if (!hw->scanresults) {
printk(KERN_ERR
"dot11req_scan_results can only be used after a successful dot11req_scan.\n");
result = 2;
req->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
goto exit;
}
count = (hw->scanresults->framelen - 3) / 32;
if (count > 32) count = 32;
if (count > 32)
count = 32;
if (req->bssindex.data >= count) {
pr_debug("requested index (%d) out of range (%d)\n",
......@@ -408,7 +415,7 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
memcpy(req->ssid.data.data, item->ssid.data, req->ssid.data.len);
/* supported rates */
for (count = 0; count < 10 ; count++)
for (count = 0; count < 10; count++)
if (item->supprates[count] == 0)
break;
......@@ -478,22 +485,12 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
/* bsstype */
req->bsstype.status = P80211ENUM_msgitem_status_data_ok;
req->bsstype.data = (WLAN_GET_MGMT_CAP_INFO_ESS(count)) ?
P80211ENUM_bsstype_infrastructure :
P80211ENUM_bsstype_independent;
// item->proberesp_rate
/*
req->fhdwelltime
req->fhhopset
req->fhhoppattern
req->fhhopindex
req->cfpdurremaining
*/
P80211ENUM_bsstype_infrastructure : P80211ENUM_bsstype_independent;
result = 0;
req->resultcode.data = P80211ENUM_resultcode_success;
exit:
exit:
return result;
}
......@@ -524,7 +521,7 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
p80211pstrd_t *pstr;
u8 bytebuf[80];
hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t*)bytebuf;
hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t *) bytebuf;
u16 word;
wlandev->macmode = WLAN_MACMODE_NONE;
......@@ -537,7 +534,7 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
hw->ident_sta_fw.minor,
hw->ident_sta_fw.variant) <
HFA384x_FIRMWARE_VERSION(0,8,3)) {
HFA384x_FIRMWARE_VERSION(0, 8, 3)) {
/* Ad-Hoc not quite supported on Prism2 */
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
msg->resultcode.data = P80211ENUM_resultcode_not_supported;
......@@ -549,17 +546,18 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
/*** STATION ***/
/* Set the REQUIRED config items */
/* SSID */
pstr = (p80211pstrd_t*)&(msg->ssid.data);
pstr = (p80211pstrd_t *)&(msg->ssid.data);
prism2mgmt_pstr2bytestr(p2bytestr, pstr);
result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFOWNSSID,
result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFOWNSSID,
bytebuf, HFA384x_RID_CNFOWNSSID_LEN);
if ( result ) {
if (result) {
printk(KERN_ERR "Failed to set CnfOwnSSID\n");
goto failed;
}
result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFDESIREDSSID,
bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN);
if ( result ) {
result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID,
bytebuf,
HFA384x_RID_CNFDESIREDSSID_LEN);
if (result) {
printk(KERN_ERR "Failed to set CnfDesiredSSID\n");
goto failed;
}
......@@ -571,7 +569,7 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
/* beacon period */
word = msg->beaconperiod.data;
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAPBCNint, word);
if ( result ) {
if (result) {
printk(KERN_ERR "Failed to set beacon period=%d.\n", word);
goto failed;
}
......@@ -579,76 +577,76 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
/* dschannel */
word = msg->dschannel.data;
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNCHANNEL, word);
if ( result ) {
if (result) {
printk(KERN_ERR "Failed to set channel=%d.\n", word);
goto failed;
}
/* Basic rates */
word = p80211rate_to_p2bit(msg->basicrate1.data);
if ( msg->basicrate2.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->basicrate2.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->basicrate2.data);
}
if ( msg->basicrate3.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->basicrate3.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->basicrate3.data);
}
if ( msg->basicrate4.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->basicrate4.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->basicrate4.data);
}
if ( msg->basicrate5.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->basicrate5.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->basicrate5.data);
}
if ( msg->basicrate6.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->basicrate6.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->basicrate6.data);
}
if ( msg->basicrate7.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->basicrate7.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->basicrate7.data);
}
if ( msg->basicrate8.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->basicrate8.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->basicrate8.data);
}
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, word);
if ( result ) {
if (result) {
printk(KERN_ERR "Failed to set basicrates=%d.\n", word);
goto failed;
}
/* Operational rates (supprates and txratecontrol) */
word = p80211rate_to_p2bit(msg->operationalrate1.data);
if ( msg->operationalrate2.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->operationalrate2.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->operationalrate2.data);
}
if ( msg->operationalrate3.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->operationalrate3.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->operationalrate3.data);
}
if ( msg->operationalrate4.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->operationalrate4.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->operationalrate4.data);
}
if ( msg->operationalrate5.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->operationalrate5.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->operationalrate5.data);
}
if ( msg->operationalrate6.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->operationalrate6.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->operationalrate6.data);
}
if ( msg->operationalrate7.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->operationalrate7.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->operationalrate7.data);
}
if ( msg->operationalrate8.status == P80211ENUM_msgitem_status_data_ok ) {
if (msg->operationalrate8.status == P80211ENUM_msgitem_status_data_ok)
word |= p80211rate_to_p2bit(msg->operationalrate8.data);
}
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, word);
if ( result ) {
if (result) {
printk(KERN_ERR "Failed to set supprates=%d.\n", word);
goto failed;
}
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, word);
if ( result ) {
if (result) {
printk(KERN_ERR "Failed to set txrates=%d.\n", word);
goto failed;
}
/* Set the macmode so the frame setup code knows what to do */
if ( msg->bsstype.data == P80211ENUM_bsstype_independent ) {
if (msg->bsstype.data == P80211ENUM_bsstype_independent) {
wlandev->macmode = WLAN_MACMODE_IBSS_STA;
/* lets extend the data length a bit */
hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, 2304);
......@@ -656,7 +654,7 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
/* Enable the Port */
result = hfa384x_drvr_enable(hw, 0);
if ( result ) {
if (result) {
printk(KERN_ERR "Enable macport failed, result=%d.\n", result);
goto failed;
}
......@@ -703,8 +701,7 @@ int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp)
*/
if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
printk(KERN_ERR
"PDA may only be read "
"in the fwload state.\n");
"PDA may only be read " "in the fwload state.\n");
msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure;
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
......@@ -712,15 +709,13 @@ int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp)
/* Call drvr_readpda(), it handles the auxport enable
* and validating the returned PDA.
*/
result = hfa384x_drvr_readpda(
hw,
result = hfa384x_drvr_readpda(hw,
msg->pda.data,
HFA384x_PDA_LEN_MAX);
if (result) {
printk(KERN_ERR
"hfa384x_drvr_readpda() failed, "
"result=%d\n",
result);
"result=%d\n", result);
msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure;
......@@ -782,9 +777,10 @@ int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp)
*/
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
if ( msg->enable.data == P80211ENUM_truth_true ) {
if ( hfa384x_drvr_ramdl_enable(hw, msg->exeaddr.data) ) {
msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;
if (msg->enable.data == P80211ENUM_truth_true) {
if (hfa384x_drvr_ramdl_enable(hw, msg->exeaddr.data)) {
msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure;
} else {
msg->resultcode.data = P80211ENUM_resultcode_success;
}
......@@ -796,7 +792,6 @@ int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp)
return 0;
}
/*----------------------------------------------------------------
* prism2mgmt_ramdl_write
*
......@@ -837,24 +832,23 @@ int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp)
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
/* first validate the length */
if ( msg->len.data > sizeof(msg->data.data) ) {
msg->resultcode.status = P80211ENUM_resultcode_invalid_parameters;
if (msg->len.data > sizeof(msg->data.data)) {
msg->resultcode.status =
P80211ENUM_resultcode_invalid_parameters;
return 0;
}
/* call the hfa384x function to do the write */
addr = msg->addr.data;
len = msg->len.data;
buf = msg->data.data;
if ( hfa384x_drvr_ramdl_write(hw, addr, buf, len) ) {
if (hfa384x_drvr_ramdl_write(hw, addr, buf, len))
msg->resultcode.data = P80211ENUM_resultcode_refused;
}
msg->resultcode.data = P80211ENUM_resultcode_success;
return 0;
}
/*----------------------------------------------------------------
* prism2mgmt_flashdl_state
*
......@@ -902,9 +896,10 @@ int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp)
*/
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
if ( msg->enable.data == P80211ENUM_truth_true ) {
if ( hfa384x_drvr_flashdl_enable(hw) ) {
msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;
if (msg->enable.data == P80211ENUM_truth_true) {
if (hfa384x_drvr_flashdl_enable(hw)) {
msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure;
} else {
msg->resultcode.data = P80211ENUM_resultcode_success;
}
......@@ -932,7 +927,6 @@ int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp)
return 0;
}
/*----------------------------------------------------------------
* prism2mgmt_flashdl_write
*
......@@ -976,7 +970,7 @@ int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp)
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
/* first validate the length */
if ( msg->len.data > sizeof(msg->data.data) ) {
if (msg->len.data > sizeof(msg->data.data)) {
msg->resultcode.status =
P80211ENUM_resultcode_invalid_parameters;
return 0;
......@@ -985,10 +979,9 @@ int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp)
addr = msg->addr.data;
len = msg->len.data;
buf = msg->data.data;
if ( hfa384x_drvr_flashdl_write(hw, addr, buf, len) ) {
if (hfa384x_drvr_flashdl_write(hw, addr, buf, len))
msg->resultcode.data = P80211ENUM_resultcode_refused;
}
msg->resultcode.data = P80211ENUM_resultcode_success;
return 0;
......@@ -1022,7 +1015,7 @@ int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp)
p80211msg_lnxreq_autojoin_t *msg = msgp;
p80211pstrd_t *pstr;
u8 bytebuf[256];
hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t*)bytebuf;
hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t *) bytebuf;
wlandev->macmode = WLAN_MACMODE_NONE;
......@@ -1037,20 +1030,20 @@ int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp)
hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, 0x000f);
/* Set the auth type */
if ( msg->authtype.data == P80211ENUM_authalg_sharedkey ) {
if (msg->authtype.data == P80211ENUM_authalg_sharedkey)
reg = HFA384x_CNFAUTHENTICATION_SHAREDKEY;
} else {
else
reg = HFA384x_CNFAUTHENTICATION_OPENSYSTEM;
}
hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAUTHENTICATION, reg);
/* Set the ssid */
memset(bytebuf, 0, 256);
pstr = (p80211pstrd_t*)&(msg->ssid.data);
pstr = (p80211pstrd_t *)&(msg->ssid.data);
prism2mgmt_pstr2bytestr(p2bytestr, pstr);
result = hfa384x_drvr_setconfig(
hw, HFA384x_RID_CNFDESIREDSSID,
bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN);
result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID,
bytebuf,
HFA384x_RID_CNFDESIREDSSID_LEN);
port_type = HFA384x_PORTTYPE_BSS;
/* Set the PortType */
hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, port_type);
......@@ -1065,7 +1058,6 @@ int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp)
return result;
}
/*----------------------------------------------------------------
* prism2mgmt_wlansniff
*
......@@ -1094,27 +1086,27 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
u16 word;
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
switch (msg->enable.data)
{
switch (msg->enable.data) {
case P80211ENUM_truth_false:
/* Confirm that we're in monitor mode */
if ( wlandev->netdev->type == ARPHRD_ETHER ) {
msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
if (wlandev->netdev->type == ARPHRD_ETHER) {
msg->resultcode.data =
P80211ENUM_resultcode_invalid_parameters;
result = 0;
goto exit;
}
/* Disable monitor mode */
result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE);
if ( result ) {
pr_debug(
if (result) {
printk(KERN_DEBUG
"failed to disable monitor mode, result=%d\n",
result);
goto failed;
}
/* Disable port 0 */
result = hfa384x_drvr_disable(hw, 0);
if ( result ) {
pr_debug(
if (result) {
printk(KERN_DEBUG
"failed to disable port 0 after sniffing, result=%d\n",
result);
goto failed;
......@@ -1126,21 +1118,21 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFWEPFLAGS,
hw->presniff_wepflags);
if ( result ) {
pr_debug(
if (result) {
printk(KERN_DEBUG
"failed to restore wepflags=0x%04x, result=%d\n",
hw->presniff_wepflags,
result);
hw->presniff_wepflags, result);
goto failed;
}
/* Set the port to its prior type and enable (if necessary) */
if (hw->presniff_port_type != 0 ) {
if (hw->presniff_port_type != 0) {
word = hw->presniff_port_type;
result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFPORTTYPE, word);
if ( result ) {
pr_debug(
HFA384x_RID_CNFPORTTYPE,
word);
if (result) {
printk(KERN_DEBUG
"failed to restore porttype, result=%d\n",
result);
goto failed;
......@@ -1148,8 +1140,10 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Enable the port */
result = hfa384x_drvr_enable(hw, 0);
if ( result ) {
pr_debug("failed to enable port to presniff setting, result=%d\n", result);
if (result) {
printk(KERN_DEBUG
"failed to enable port to presniff setting, result=%d\n",
result);
goto failed;
}
} else {
......@@ -1164,28 +1158,34 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
break;
case P80211ENUM_truth_true:
/* Disable the port (if enabled), only check Port 0 */
if ( hw->port_enabled[0]) {
if (hw->port_enabled[0]) {
if (wlandev->netdev->type == ARPHRD_ETHER) {
/* Save macport 0 state */
result = hfa384x_drvr_getconfig16(hw,
HFA384x_RID_CNFPORTTYPE,
&(hw->presniff_port_type));
if ( result ) {
pr_debug("failed to read porttype, result=%d\n", result);
&(hw->
presniff_port_type));
if (result) {
printk(KERN_DEBUG
"failed to read porttype, result=%d\n",
result);
goto failed;
}
/* Save the wepflags state */
result = hfa384x_drvr_getconfig16(hw,
HFA384x_RID_CNFWEPFLAGS,
&(hw->presniff_wepflags));
if ( result ) {
pr_debug("failed to read wepflags, result=%d\n", result);
&(hw->
presniff_wepflags));
if (result) {
printk(KERN_DEBUG
"failed to read wepflags, result=%d\n",
result);
goto failed;
}
hfa384x_drvr_stop(hw);
result = hfa384x_drvr_start(hw);
if ( result ) {
pr_debug(
if (result) {
printk(KERN_DEBUG
"failed to restart the card for sniffing, result=%d\n",
result);
goto failed;
......@@ -1193,8 +1193,8 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
} else {
/* Disable the port */
result = hfa384x_drvr_disable(hw, 0);
if ( result ) {
pr_debug(
if (result) {
printk(KERN_DEBUG
"failed to enable port for sniffing, result=%d\n",
result);
goto failed;
......@@ -1207,14 +1207,14 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Set the channel we wish to sniff */
word = msg->channel.data;
result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFOWNCHANNEL, word);
hw->sniff_channel=word;
HFA384x_RID_CNFOWNCHANNEL,
word);
hw->sniff_channel = word;
if ( result ) {
pr_debug(
if (result) {
printk(KERN_DEBUG
"failed to set channel %d, result=%d\n",
word,
result);
word, result);
goto failed;
}
......@@ -1223,39 +1223,46 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Set the port type to pIbss */
word = HFA384x_PORTTYPE_PSUEDOIBSS;
result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFPORTTYPE, word);
if ( result ) {
pr_debug(
HFA384x_RID_CNFPORTTYPE,
word);
if (result) {
printk(KERN_DEBUG
"failed to set porttype %d, result=%d\n",
word,
result);
word, result);
goto failed;
}
if ((msg->keepwepflags.status == P80211ENUM_msgitem_status_data_ok) && (msg->keepwepflags.data != P80211ENUM_truth_true)) {
if ((msg->keepwepflags.status ==
P80211ENUM_msgitem_status_data_ok)
&& (msg->keepwepflags.data !=
P80211ENUM_truth_true)) {
/* Set the wepflags for no decryption */
word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT |
HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFWEPFLAGS, word);
result =
hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFWEPFLAGS,
word);
}
if ( result ) {
pr_debug(
if (result) {
printk(KERN_DEBUG
"failed to set wepflags=0x%04x, result=%d\n",
word,
result);
word, result);
goto failed;
}
}
/* Do we want to strip the FCS in monitor mode? */
if ((msg->stripfcs.status == P80211ENUM_msgitem_status_data_ok) && (msg->stripfcs.data == P80211ENUM_truth_true)) {
if ((msg->stripfcs.status == P80211ENUM_msgitem_status_data_ok)
&& (msg->stripfcs.data == P80211ENUM_truth_true)) {
hw->sniff_fcs = 0;
} else {
hw->sniff_fcs = 1;
}
/* Do we want to truncate the packets? */
if (msg->packet_trunc.status == P80211ENUM_msgitem_status_data_ok) {
if (msg->packet_trunc.status ==
P80211ENUM_msgitem_status_data_ok) {
hw->sniff_truncate = msg->packet_trunc.data;
} else {
hw->sniff_truncate = 0;
......@@ -1263,31 +1270,35 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Enable the port */
result = hfa384x_drvr_enable(hw, 0);
if ( result ) {
pr_debug(
if (result) {
printk(KERN_DEBUG
"failed to enable port for sniffing, result=%d\n",
result);
goto failed;
}
/* Enable monitor mode */
result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE);
if ( result ) {
pr_debug(
if (result) {
printk(KERN_DEBUG
"failed to enable monitor mode, result=%d\n",
result);
goto failed;
}
if (wlandev->netdev->type == ARPHRD_ETHER) {
if (wlandev->netdev->type == ARPHRD_ETHER)
printk(KERN_INFO "monitor mode enabled\n");
}
/* Set the driver state */
/* Do we want the prism2 header? */
if ((msg->prismheader.status == P80211ENUM_msgitem_status_data_ok) && (msg->prismheader.data == P80211ENUM_truth_true)) {
if ((msg->prismheader.status ==
P80211ENUM_msgitem_status_data_ok)
&& (msg->prismheader.data == P80211ENUM_truth_true)) {
hw->sniffhdr = 0;
wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
} else if ((msg->wlanheader.status == P80211ENUM_msgitem_status_data_ok) && (msg->wlanheader.data == P80211ENUM_truth_true)) {
} else
if ((msg->wlanheader.status ==
P80211ENUM_msgitem_status_data_ok)
&& (msg->wlanheader.data == P80211ENUM_truth_true)) {
hw->sniffhdr = 1;
wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment