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 @@ ...@@ -57,9 +57,6 @@
* -------------------------------------------------------------------- * --------------------------------------------------------------------
*/ */
/*================================================================*/
/* System Includes */
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -124,105 +121,112 @@ ...@@ -124,105 +121,112 @@
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
{ {
int result = 0; int result = 0;
hfa384x_t *hw = wlandev->priv; hfa384x_t *hw = wlandev->priv;
p80211msg_dot11req_scan_t *msg = msgp; p80211msg_dot11req_scan_t *msg = msgp;
u16 roamingmode, word; u16 roamingmode, word;
int i, timeout; int i, timeout;
int istmpenable = 0; int istmpenable = 0;
hfa384x_HostScanRequest_data_t scanreq; hfa384x_HostScanRequest_data_t scanreq;
/* gatekeeper check */ /* gatekeeper check */
if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major, if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
hw->ident_sta_fw.minor, hw->ident_sta_fw.minor,
hw->ident_sta_fw.variant) < hw->ident_sta_fw.variant) <
HFA384x_FIRMWARE_VERSION(1,3,2)) { HFA384x_FIRMWARE_VERSION(1, 3, 2)) {
printk(KERN_ERR "HostScan not supported with current firmware (<1.3.2).\n"); printk(KERN_ERR
result = 1; "HostScan not supported with current firmware (<1.3.2).\n");
msg->resultcode.data = P80211ENUM_resultcode_not_supported; result = 1;
msg->resultcode.data = P80211ENUM_resultcode_not_supported;
goto exit;
}
memset(&scanreq, 0, sizeof(scanreq));
/* save current roaming mode */
result = hfa384x_drvr_getconfig16(hw,
HFA384x_RID_CNFROAMINGMODE,
&roamingmode);
if (result) {
printk(KERN_ERR "getconfig(ROAMMODE) failed. result=%d\n",
result);
msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure;
goto exit; goto exit;
} }
memset(&scanreq, 0, sizeof(scanreq)); /* drop into mode 3 for the scan */
result = hfa384x_drvr_setconfig16(hw,
/* save current roaming mode */ HFA384x_RID_CNFROAMINGMODE,
result = hfa384x_drvr_getconfig16(hw, HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM);
HFA384x_RID_CNFROAMINGMODE, &roamingmode); if (result) {
if ( result ) { printk(KERN_ERR "setconfig(ROAMINGMODE) failed. result=%d\n",
printk(KERN_ERR "getconfig(ROAMMODE) failed. result=%d\n", result);
result); msg->resultcode.data =
msg->resultcode.data = P80211ENUM_resultcode_implementation_failure;
P80211ENUM_resultcode_implementation_failure; goto exit;
goto exit; }
}
/* active or passive? */
/* drop into mode 3 for the scan */ if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
result = hfa384x_drvr_setconfig16(hw, hw->ident_sta_fw.minor,
HFA384x_RID_CNFROAMINGMODE, hw->ident_sta_fw.variant) >
HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM); HFA384x_FIRMWARE_VERSION(1, 5, 0)) {
if ( result ) { if (msg->scantype.data != P80211ENUM_scantype_active)
printk(KERN_ERR "setconfig(ROAMINGMODE) failed. result=%d\n", word = host2hfa384x_16(msg->maxchanneltime.data);
result); else
msg->resultcode.data = word = 0;
P80211ENUM_resultcode_implementation_failure;
goto exit; result =
} hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPASSIVESCANCTRL,
word);
/* active or passive? */ if (result) {
if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major, printk(KERN_WARNING "Passive scan not supported with "
hw->ident_sta_fw.minor, "current firmware. (<1.5.1)\n");
hw->ident_sta_fw.variant) > }
HFA384x_FIRMWARE_VERSION(1,5,0)) { }
if (msg->scantype.data != P80211ENUM_scantype_active) {
word = host2hfa384x_16(msg->maxchanneltime.data);
} else {
word = 0;
}
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");
}
}
/* set up the txrate to be 2MBPS. Should be fastest basicrate... */ /* set up the txrate to be 2MBPS. Should be fastest basicrate... */
word = HFA384x_RATEBIT_2; word = HFA384x_RATEBIT_2;
scanreq.txRate = host2hfa384x_16(word); scanreq.txRate = host2hfa384x_16(word);
/* set up the channel list */ /* set up the channel list */
word = 0; word = 0;
for (i = 0; i < msg->channellist.data.len; i++) { for (i = 0; i < msg->channellist.data.len; i++) {
u8 channel = msg->channellist.data.data[i]; u8 channel = msg->channellist.data.data[i];
if (channel > 14) continue; if (channel > 14)
/* channel 1 is BIT 0 ... channel 14 is BIT 13 */ continue;
word |= (1 << (channel-1)); /* channel 1 is BIT 0 ... channel 14 is BIT 13 */
} word |= (1 << (channel - 1));
scanreq.channelList = host2hfa384x_16(word); }
scanreq.channelList = host2hfa384x_16(word);
/* set up the ssid, if present. */ /* set up the ssid, if present. */
scanreq.ssid.len = host2hfa384x_16(msg->ssid.data.len); scanreq.ssid.len = host2hfa384x_16(msg->ssid.data.len);
memcpy(scanreq.ssid.data, msg->ssid.data.data, msg->ssid.data.len); memcpy(scanreq.ssid.data, msg->ssid.data.data, msg->ssid.data.len);
/* Enable the MAC port if it's not already enabled */ /* Enable the MAC port if it's not already enabled */
result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_PORTSTATUS, &word); result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_PORTSTATUS, &word);
if ( result ) { if (result) {
printk(KERN_ERR "getconfig(PORTSTATUS) failed. " printk(KERN_ERR "getconfig(PORTSTATUS) failed. "
"result=%d\n", result); "result=%d\n", result);
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
goto exit; goto exit;
} }
if (word == HFA384x_PORTSTATUS_DISABLED) { if (word == HFA384x_PORTSTATUS_DISABLED) {
u16 wordbuf[17]; u16 wordbuf[17];
result = hfa384x_drvr_setconfig16(hw, result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFROAMINGMODE, HFA384x_RID_CNFROAMINGMODE,
HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM); HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM);
if ( result ) { if (result) {
printk(KERN_ERR "setconfig(ROAMINGMODE) failed. result=%d\n", result); printk(KERN_ERR
"setconfig(ROAMINGMODE) failed. result=%d\n",
result);
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
goto exit; goto exit;
} }
/* Construct a bogus SSID and assign it to OwnSSID and /* Construct a bogus SSID and assign it to OwnSSID and
...@@ -230,73 +234,75 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) ...@@ -230,73 +234,75 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
*/ */
wordbuf[0] = host2hfa384x_16(WLAN_SSID_MAXLEN); wordbuf[0] = host2hfa384x_16(WLAN_SSID_MAXLEN);
get_random_bytes(&wordbuf[1], WLAN_SSID_MAXLEN); get_random_bytes(&wordbuf[1], WLAN_SSID_MAXLEN);
result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFOWNSSID, result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFOWNSSID,
wordbuf, HFA384x_RID_CNFOWNSSID_LEN); wordbuf,
if ( result ) { HFA384x_RID_CNFOWNSSID_LEN);
if (result) {
printk(KERN_ERR "Failed to set OwnSSID.\n"); printk(KERN_ERR "Failed to set OwnSSID.\n");
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
goto exit; goto exit;
} }
result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFDESIREDSSID, result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID,
wordbuf, HFA384x_RID_CNFDESIREDSSID_LEN); wordbuf,
if ( result ) { HFA384x_RID_CNFDESIREDSSID_LEN);
if (result) {
printk(KERN_ERR "Failed to set DesiredSSID.\n"); printk(KERN_ERR "Failed to set DesiredSSID.\n");
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
goto exit; goto exit;
} }
/* bsstype */ /* bsstype */
result = hfa384x_drvr_setconfig16(hw, result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFPORTTYPE, HFA384x_RID_CNFPORTTYPE,
HFA384x_PORTTYPE_IBSS); HFA384x_PORTTYPE_IBSS);
if ( result ) { if (result) {
printk(KERN_ERR "Failed to set CNFPORTTYPE.\n"); printk(KERN_ERR "Failed to set CNFPORTTYPE.\n");
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
goto exit; goto exit;
} }
/* ibss options */ /* ibss options */
result = hfa384x_drvr_setconfig16(hw, result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CREATEIBSS, HFA384x_RID_CREATEIBSS,
HFA384x_CREATEIBSS_JOINCREATEIBSS); HFA384x_CREATEIBSS_JOINCREATEIBSS);
if ( result ) { if (result) {
printk(KERN_ERR "Failed to set CREATEIBSS.\n"); printk(KERN_ERR "Failed to set CREATEIBSS.\n");
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
goto exit; goto exit;
} }
result = hfa384x_drvr_enable(hw, 0); result = hfa384x_drvr_enable(hw, 0);
if ( result ) { if (result) {
printk(KERN_ERR "drvr_enable(0) failed. " printk(KERN_ERR "drvr_enable(0) failed. "
"result=%d\n", result); "result=%d\n", result);
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
goto exit; goto exit;
} }
istmpenable = 1; istmpenable = 1;
} }
/* Figure out our timeout first Kus, then HZ */ /* Figure out our timeout first Kus, then HZ */
timeout = msg->channellist.data.len * msg->maxchanneltime.data; timeout = msg->channellist.data.len * msg->maxchanneltime.data;
timeout = (timeout * HZ)/1000; timeout = (timeout * HZ) / 1000;
/* Issue the scan request */ /* Issue the scan request */
hw->scanflag = 0; hw->scanflag = 0;
result = hfa384x_drvr_setconfig( hw, result = hfa384x_drvr_setconfig(hw,
HFA384x_RID_HOSTSCAN, &scanreq, HFA384x_RID_HOSTSCAN, &scanreq,
sizeof(hfa384x_HostScanRequest_data_t)); sizeof(hfa384x_HostScanRequest_data_t));
if ( result ) { if (result) {
printk(KERN_ERR "setconfig(SCANREQUEST) failed. result=%d\n", printk(KERN_ERR "setconfig(SCANREQUEST) failed. result=%d\n",
result); result);
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
goto exit; goto exit;
} }
/* sleep until info frame arrives */ /* sleep until info frame arrives */
wait_event_interruptible_timeout(hw->cmdq, hw->scanflag, timeout); wait_event_interruptible_timeout(hw->cmdq, hw->scanflag, timeout);
msg->numbss.status = P80211ENUM_msgitem_status_data_ok; msg->numbss.status = P80211ENUM_msgitem_status_data_ok;
if (hw->scanflag == -1) if (hw->scanflag == -1)
...@@ -304,16 +310,16 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) ...@@ -304,16 +310,16 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
msg->numbss.data = hw->scanflag; msg->numbss.data = hw->scanflag;
hw->scanflag = 0; hw->scanflag = 0;
/* Disable port if we temporarily enabled it. */ /* Disable port if we temporarily enabled it. */
if (istmpenable) { if (istmpenable) {
result = hfa384x_drvr_disable(hw, 0); result = hfa384x_drvr_disable(hw, 0);
if ( result ) { if (result) {
printk(KERN_ERR "drvr_disable(0) failed. " printk(KERN_ERR "drvr_disable(0) failed. "
"result=%d\n", result); "result=%d\n", result);
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
goto exit; goto exit;
} }
} }
...@@ -321,24 +327,23 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) ...@@ -321,24 +327,23 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
/* restore original roaming mode */ /* restore original roaming mode */
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE, result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE,
roamingmode); roamingmode);
if ( result ) { if (result) {
printk(KERN_ERR "setconfig(ROAMMODE) failed. result=%d\n", printk(KERN_ERR "setconfig(ROAMMODE) failed. result=%d\n",
result); result);
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
goto exit; goto exit;
} }
result = 0; result = 0;
msg->resultcode.data = P80211ENUM_resultcode_success; msg->resultcode.data = P80211ENUM_resultcode_success;
exit: exit:
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
return result; return result;
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* prism2mgmt_scan_results * prism2mgmt_scan_results
* *
...@@ -361,30 +366,32 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) ...@@ -361,30 +366,32 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp)
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
{ {
int result = 0; int result = 0;
p80211msg_dot11req_scan_results_t *req; p80211msg_dot11req_scan_results_t *req;
hfa384x_t *hw = wlandev->priv; hfa384x_t *hw = wlandev->priv;
hfa384x_HScanResultSub_t *item = NULL; hfa384x_HScanResultSub_t *item = NULL;
int count; int count;
req = (p80211msg_dot11req_scan_results_t *) msgp; req = (p80211msg_dot11req_scan_results_t *) msgp;
req->resultcode.status = P80211ENUM_msgitem_status_data_ok; req->resultcode.status = P80211ENUM_msgitem_status_data_ok;
if (! hw->scanresults) { if (!hw->scanresults) {
printk(KERN_ERR "dot11req_scan_results can only be used after a successful dot11req_scan.\n"); printk(KERN_ERR
"dot11req_scan_results can only be used after a successful dot11req_scan.\n");
result = 2; result = 2;
req->resultcode.data = P80211ENUM_resultcode_invalid_parameters; req->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
goto exit; goto exit;
} }
count = (hw->scanresults->framelen - 3) / 32; count = (hw->scanresults->framelen - 3) / 32;
if (count > 32) count = 32; if (count > 32)
count = 32;
if (req->bssindex.data >= count) { if (req->bssindex.data >= count) {
pr_debug("requested index (%d) out of range (%d)\n", pr_debug("requested index (%d) out of range (%d)\n",
req->bssindex.data, count); req->bssindex.data, count);
result = 2; result = 2;
req->resultcode.data = P80211ENUM_resultcode_invalid_parameters; req->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
goto exit; goto exit;
...@@ -408,9 +415,9 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) ...@@ -408,9 +415,9 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
memcpy(req->ssid.data.data, item->ssid.data, req->ssid.data.len); memcpy(req->ssid.data.data, item->ssid.data, req->ssid.data.len);
/* supported rates */ /* supported rates */
for (count = 0; count < 10 ; count++) for (count = 0; count < 10; count++)
if (item->supprates[count] == 0) if (item->supprates[count] == 0)
break; break;
#define REQBASICRATE(N) \ #define REQBASICRATE(N) \
if ((count >= N) && DOT11_RATE5_ISBASIC_GET(item->supprates[(N)-1])) { \ if ((count >= N) && DOT11_RATE5_ISBASIC_GET(item->supprates[(N)-1])) { \
...@@ -476,24 +483,14 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) ...@@ -476,24 +483,14 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
req->cfpollreq.data = WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(count); req->cfpollreq.data = WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(count);
/* bsstype */ /* bsstype */
req->bsstype.status = P80211ENUM_msgitem_status_data_ok; req->bsstype.status = P80211ENUM_msgitem_status_data_ok;
req->bsstype.data = (WLAN_GET_MGMT_CAP_INFO_ESS(count)) ? req->bsstype.data = (WLAN_GET_MGMT_CAP_INFO_ESS(count)) ?
P80211ENUM_bsstype_infrastructure : P80211ENUM_bsstype_infrastructure : P80211ENUM_bsstype_independent;
P80211ENUM_bsstype_independent;
// item->proberesp_rate
/*
req->fhdwelltime
req->fhhopset
req->fhhoppattern
req->fhhopindex
req->cfpdurremaining
*/
result = 0; result = 0;
req->resultcode.data = P80211ENUM_resultcode_success; req->resultcode.data = P80211ENUM_resultcode_success;
exit: exit:
return result; return result;
} }
...@@ -518,14 +515,14 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) ...@@ -518,14 +515,14 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
{ {
int result = 0; int result = 0;
hfa384x_t *hw = wlandev->priv; hfa384x_t *hw = wlandev->priv;
p80211msg_dot11req_start_t *msg = msgp; p80211msg_dot11req_start_t *msg = msgp;
p80211pstrd_t *pstr; p80211pstrd_t *pstr;
u8 bytebuf[80]; u8 bytebuf[80];
hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t*)bytebuf; hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t *) bytebuf;
u16 word; u16 word;
wlandev->macmode = WLAN_MACMODE_NONE; wlandev->macmode = WLAN_MACMODE_NONE;
...@@ -537,7 +534,7 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) ...@@ -537,7 +534,7 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major, if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major,
hw->ident_sta_fw.minor, hw->ident_sta_fw.minor,
hw->ident_sta_fw.variant) < hw->ident_sta_fw.variant) <
HFA384x_FIRMWARE_VERSION(0,8,3)) { HFA384x_FIRMWARE_VERSION(0, 8, 3)) {
/* Ad-Hoc not quite supported on Prism2 */ /* Ad-Hoc not quite supported on Prism2 */
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
msg->resultcode.data = P80211ENUM_resultcode_not_supported; msg->resultcode.data = P80211ENUM_resultcode_not_supported;
...@@ -549,17 +546,18 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) ...@@ -549,17 +546,18 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
/*** STATION ***/ /*** STATION ***/
/* Set the REQUIRED config items */ /* Set the REQUIRED config items */
/* SSID */ /* SSID */
pstr = (p80211pstrd_t*)&(msg->ssid.data); pstr = (p80211pstrd_t *)&(msg->ssid.data);
prism2mgmt_pstr2bytestr(p2bytestr, pstr); 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); bytebuf, HFA384x_RID_CNFOWNSSID_LEN);
if ( result ) { if (result) {
printk(KERN_ERR "Failed to set CnfOwnSSID\n"); printk(KERN_ERR "Failed to set CnfOwnSSID\n");
goto failed; goto failed;
} }
result = hfa384x_drvr_setconfig( hw, HFA384x_RID_CNFDESIREDSSID, result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID,
bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN); bytebuf,
if ( result ) { HFA384x_RID_CNFDESIREDSSID_LEN);
if (result) {
printk(KERN_ERR "Failed to set CnfDesiredSSID\n"); printk(KERN_ERR "Failed to set CnfDesiredSSID\n");
goto failed; goto failed;
} }
...@@ -571,7 +569,7 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) ...@@ -571,7 +569,7 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
/* beacon period */ /* beacon period */
word = msg->beaconperiod.data; word = msg->beaconperiod.data;
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAPBCNint, word); result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAPBCNint, word);
if ( result ) { if (result) {
printk(KERN_ERR "Failed to set beacon period=%d.\n", word); printk(KERN_ERR "Failed to set beacon period=%d.\n", word);
goto failed; goto failed;
} }
...@@ -579,76 +577,76 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) ...@@ -579,76 +577,76 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
/* dschannel */ /* dschannel */
word = msg->dschannel.data; word = msg->dschannel.data;
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNCHANNEL, word); result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNCHANNEL, word);
if ( result ) { if (result) {
printk(KERN_ERR "Failed to set channel=%d.\n", word); printk(KERN_ERR "Failed to set channel=%d.\n", word);
goto failed; goto failed;
} }
/* Basic rates */ /* Basic rates */
word = p80211rate_to_p2bit(msg->basicrate1.data); 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); 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); 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); 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); 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); 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); 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); word |= p80211rate_to_p2bit(msg->basicrate8.data);
}
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, word); result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, word);
if ( result ) { if (result) {
printk(KERN_ERR "Failed to set basicrates=%d.\n", word); printk(KERN_ERR "Failed to set basicrates=%d.\n", word);
goto failed; goto failed;
} }
/* Operational rates (supprates and txratecontrol) */ /* Operational rates (supprates and txratecontrol) */
word = p80211rate_to_p2bit(msg->operationalrate1.data); 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); 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); 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); 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); 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); 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); 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); word |= p80211rate_to_p2bit(msg->operationalrate8.data);
}
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, word); result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, word);
if ( result ) { if (result) {
printk(KERN_ERR "Failed to set supprates=%d.\n", word); printk(KERN_ERR "Failed to set supprates=%d.\n", word);
goto failed; goto failed;
} }
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, word); result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, word);
if ( result ) { if (result) {
printk(KERN_ERR "Failed to set txrates=%d.\n", word); printk(KERN_ERR "Failed to set txrates=%d.\n", word);
goto failed; goto failed;
} }
/* Set the macmode so the frame setup code knows what to do */ /* 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; wlandev->macmode = WLAN_MACMODE_IBSS_STA;
/* lets extend the data length a bit */ /* lets extend the data length a bit */
hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, 2304); hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFMAXDATALEN, 2304);
...@@ -656,7 +654,7 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) ...@@ -656,7 +654,7 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
/* Enable the Port */ /* Enable the Port */
result = hfa384x_drvr_enable(hw, 0); result = hfa384x_drvr_enable(hw, 0);
if ( result ) { if (result) {
printk(KERN_ERR "Enable macport failed, result=%d.\n", result); printk(KERN_ERR "Enable macport failed, result=%d.\n", result);
goto failed; goto failed;
} }
...@@ -694,38 +692,35 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) ...@@ -694,38 +692,35 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp)
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp) int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp)
{ {
hfa384x_t *hw = wlandev->priv; hfa384x_t *hw = wlandev->priv;
p80211msg_p2req_readpda_t *msg = msgp; p80211msg_p2req_readpda_t *msg = msgp;
int result; int result;
/* We only support collecting the PDA when in the FWLOAD /* We only support collecting the PDA when in the FWLOAD
* state. * state.
*/ */
if (wlandev->msdstate != WLAN_MSD_FWLOAD) { if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
printk(KERN_ERR printk(KERN_ERR
"PDA may only be read " "PDA may only be read " "in the fwload state.\n");
"in the fwload state.\n");
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
} else { } else {
/* Call drvr_readpda(), it handles the auxport enable /* Call drvr_readpda(), it handles the auxport enable
* and validating the returned PDA. * and validating the returned PDA.
*/ */
result = hfa384x_drvr_readpda( result = hfa384x_drvr_readpda(hw,
hw, msg->pda.data,
msg->pda.data, HFA384x_PDA_LEN_MAX);
HFA384x_PDA_LEN_MAX);
if (result) { if (result) {
printk(KERN_ERR printk(KERN_ERR
"hfa384x_drvr_readpda() failed, " "hfa384x_drvr_readpda() failed, "
"result=%d\n", "result=%d\n", result);
result);
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
msg->resultcode.status = msg->resultcode.status =
P80211ENUM_msgitem_status_data_ok; P80211ENUM_msgitem_status_data_ok;
return 0; return 0;
} }
msg->pda.status = P80211ENUM_msgitem_status_data_ok; msg->pda.status = P80211ENUM_msgitem_status_data_ok;
...@@ -763,28 +758,29 @@ int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp) ...@@ -763,28 +758,29 @@ int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp)
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp) int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp)
{ {
hfa384x_t *hw = wlandev->priv; hfa384x_t *hw = wlandev->priv;
p80211msg_p2req_ramdl_state_t *msg = msgp; p80211msg_p2req_ramdl_state_t *msg = msgp;
if (wlandev->msdstate != WLAN_MSD_FWLOAD) { if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
printk(KERN_ERR printk(KERN_ERR
"ramdl_state(): may only be called " "ramdl_state(): may only be called "
"in the fwload state.\n"); "in the fwload state.\n");
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
return 0; return 0;
} }
/* /*
** Note: Interrupts are locked out if this is an AP and are NOT ** Note: Interrupts are locked out if this is an AP and are NOT
** locked out if this is a station. ** locked out if this is a station.
*/ */
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
if ( msg->enable.data == P80211ENUM_truth_true ) { if (msg->enable.data == P80211ENUM_truth_true) {
if ( hfa384x_drvr_ramdl_enable(hw, msg->exeaddr.data) ) { if (hfa384x_drvr_ramdl_enable(hw, msg->exeaddr.data)) {
msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure;
} else { } else {
msg->resultcode.data = P80211ENUM_resultcode_success; msg->resultcode.data = P80211ENUM_resultcode_success;
} }
...@@ -796,7 +792,6 @@ int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp) ...@@ -796,7 +792,6 @@ int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp)
return 0; return 0;
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* prism2mgmt_ramdl_write * prism2mgmt_ramdl_write
* *
...@@ -819,42 +814,41 @@ int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp) ...@@ -819,42 +814,41 @@ int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp)
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp) int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp)
{ {
hfa384x_t *hw = wlandev->priv; hfa384x_t *hw = wlandev->priv;
p80211msg_p2req_ramdl_write_t *msg = msgp; p80211msg_p2req_ramdl_write_t *msg = msgp;
u32 addr; u32 addr;
u32 len; u32 len;
u8 *buf; u8 *buf;
if (wlandev->msdstate != WLAN_MSD_FWLOAD) { if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
printk(KERN_ERR printk(KERN_ERR
"ramdl_write(): may only be called " "ramdl_write(): may only be called "
"in the fwload state.\n"); "in the fwload state.\n");
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
return 0; return 0;
} }
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
/* first validate the length */ /* 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; msg->resultcode.status =
P80211ENUM_resultcode_invalid_parameters;
return 0; return 0;
} }
/* call the hfa384x function to do the write */ /* call the hfa384x function to do the write */
addr = msg->addr.data; addr = msg->addr.data;
len = msg->len.data; len = msg->len.data;
buf = msg->data.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_refused;
}
msg->resultcode.data = P80211ENUM_resultcode_success; msg->resultcode.data = P80211ENUM_resultcode_success;
return 0; return 0;
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* prism2mgmt_flashdl_state * prism2mgmt_flashdl_state
* *
...@@ -882,29 +876,30 @@ int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp) ...@@ -882,29 +876,30 @@ int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp)
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp) int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp)
{ {
int result = 0; int result = 0;
hfa384x_t *hw = wlandev->priv; hfa384x_t *hw = wlandev->priv;
p80211msg_p2req_flashdl_state_t *msg = msgp; p80211msg_p2req_flashdl_state_t *msg = msgp;
if (wlandev->msdstate != WLAN_MSD_FWLOAD) { if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
printk(KERN_ERR printk(KERN_ERR
"flashdl_state(): may only be called " "flashdl_state(): may only be called "
"in the fwload state.\n"); "in the fwload state.\n");
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
return 0; return 0;
} }
/* /*
** Note: Interrupts are locked out if this is an AP and are NOT ** Note: Interrupts are locked out if this is an AP and are NOT
** locked out if this is a station. ** locked out if this is a station.
*/ */
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
if ( msg->enable.data == P80211ENUM_truth_true ) { if (msg->enable.data == P80211ENUM_truth_true) {
if ( hfa384x_drvr_flashdl_enable(hw) ) { if (hfa384x_drvr_flashdl_enable(hw)) {
msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure;
} else { } else {
msg->resultcode.data = P80211ENUM_resultcode_success; msg->resultcode.data = P80211ENUM_resultcode_success;
} }
...@@ -922,9 +917,9 @@ int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp) ...@@ -922,9 +917,9 @@ int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp)
result = prism2sta_ifstate(wlandev, P80211ENUM_ifstate_fwload); result = prism2sta_ifstate(wlandev, P80211ENUM_ifstate_fwload);
if (result != P80211ENUM_resultcode_success) { if (result != P80211ENUM_resultcode_success) {
printk(KERN_ERR "prism2sta_ifstate(fwload) failed," printk(KERN_ERR "prism2sta_ifstate(fwload) failed,"
"P80211ENUM_resultcode=%d\n", result); "P80211ENUM_resultcode=%d\n", result);
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
result = -1; result = -1;
} }
} }
...@@ -932,7 +927,6 @@ int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp) ...@@ -932,7 +927,6 @@ int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp)
return 0; return 0;
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* prism2mgmt_flashdl_write * prism2mgmt_flashdl_write
* *
...@@ -953,42 +947,41 @@ int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp) ...@@ -953,42 +947,41 @@ int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp)
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp) int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp)
{ {
hfa384x_t *hw = wlandev->priv; hfa384x_t *hw = wlandev->priv;
p80211msg_p2req_flashdl_write_t *msg = msgp; p80211msg_p2req_flashdl_write_t *msg = msgp;
u32 addr; u32 addr;
u32 len; u32 len;
u8 *buf; u8 *buf;
if (wlandev->msdstate != WLAN_MSD_FWLOAD) { if (wlandev->msdstate != WLAN_MSD_FWLOAD) {
printk(KERN_ERR printk(KERN_ERR
"flashdl_write(): may only be called " "flashdl_write(): may only be called "
"in the fwload state.\n"); "in the fwload state.\n");
msg->resultcode.data = msg->resultcode.data =
P80211ENUM_resultcode_implementation_failure; P80211ENUM_resultcode_implementation_failure;
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
return 0; return 0;
} }
/* /*
** Note: Interrupts are locked out if this is an AP and are NOT ** Note: Interrupts are locked out if this is an AP and are NOT
** locked out if this is a station. ** locked out if this is a station.
*/ */
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
/* first validate the length */ /* first validate the length */
if ( msg->len.data > sizeof(msg->data.data) ) { if (msg->len.data > sizeof(msg->data.data)) {
msg->resultcode.status = msg->resultcode.status =
P80211ENUM_resultcode_invalid_parameters; P80211ENUM_resultcode_invalid_parameters;
return 0; return 0;
} }
/* call the hfa384x function to do the write */ /* call the hfa384x function to do the write */
addr = msg->addr.data; addr = msg->addr.data;
len = msg->len.data; len = msg->len.data;
buf = msg->data.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_refused;
}
msg->resultcode.data = P80211ENUM_resultcode_success; msg->resultcode.data = P80211ENUM_resultcode_success;
return 0; return 0;
...@@ -1015,14 +1008,14 @@ int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp) ...@@ -1015,14 +1008,14 @@ int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp)
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp) int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp)
{ {
hfa384x_t *hw = wlandev->priv; hfa384x_t *hw = wlandev->priv;
int result = 0; int result = 0;
u16 reg; u16 reg;
u16 port_type; u16 port_type;
p80211msg_lnxreq_autojoin_t *msg = msgp; p80211msg_lnxreq_autojoin_t *msg = msgp;
p80211pstrd_t *pstr; p80211pstrd_t *pstr;
u8 bytebuf[256]; u8 bytebuf[256];
hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t*)bytebuf; hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t *) bytebuf;
wlandev->macmode = WLAN_MACMODE_NONE; wlandev->macmode = WLAN_MACMODE_NONE;
...@@ -1037,20 +1030,20 @@ int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp) ...@@ -1037,20 +1030,20 @@ int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp)
hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, 0x000f); hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, 0x000f);
/* Set the auth type */ /* Set the auth type */
if ( msg->authtype.data == P80211ENUM_authalg_sharedkey ) { if (msg->authtype.data == P80211ENUM_authalg_sharedkey)
reg = HFA384x_CNFAUTHENTICATION_SHAREDKEY; reg = HFA384x_CNFAUTHENTICATION_SHAREDKEY;
} else { else
reg = HFA384x_CNFAUTHENTICATION_OPENSYSTEM; reg = HFA384x_CNFAUTHENTICATION_OPENSYSTEM;
}
hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAUTHENTICATION, reg); hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAUTHENTICATION, reg);
/* Set the ssid */ /* Set the ssid */
memset(bytebuf, 0, 256); memset(bytebuf, 0, 256);
pstr = (p80211pstrd_t*)&(msg->ssid.data); pstr = (p80211pstrd_t *)&(msg->ssid.data);
prism2mgmt_pstr2bytestr(p2bytestr, pstr); prism2mgmt_pstr2bytestr(p2bytestr, pstr);
result = hfa384x_drvr_setconfig( result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID,
hw, HFA384x_RID_CNFDESIREDSSID, bytebuf,
bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN); HFA384x_RID_CNFDESIREDSSID_LEN);
port_type = HFA384x_PORTTYPE_BSS; port_type = HFA384x_PORTTYPE_BSS;
/* Set the PortType */ /* Set the PortType */
hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, port_type); hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, port_type);
...@@ -1065,7 +1058,6 @@ int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp) ...@@ -1065,7 +1058,6 @@ int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp)
return result; return result;
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* prism2mgmt_wlansniff * prism2mgmt_wlansniff
* *
...@@ -1087,36 +1079,36 @@ int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp) ...@@ -1087,36 +1079,36 @@ int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp)
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
{ {
int result = 0; int result = 0;
p80211msg_lnxreq_wlansniff_t *msg = msgp; p80211msg_lnxreq_wlansniff_t *msg = msgp;
hfa384x_t *hw = wlandev->priv; hfa384x_t *hw = wlandev->priv;
u16 word; u16 word;
msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok;
switch (msg->enable.data) switch (msg->enable.data) {
{
case P80211ENUM_truth_false: case P80211ENUM_truth_false:
/* Confirm that we're in monitor mode */ /* Confirm that we're in monitor mode */
if ( wlandev->netdev->type == ARPHRD_ETHER ) { if (wlandev->netdev->type == ARPHRD_ETHER) {
msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters; msg->resultcode.data =
P80211ENUM_resultcode_invalid_parameters;
result = 0; result = 0;
goto exit; goto exit;
} }
/* Disable monitor mode */ /* Disable monitor mode */
result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE); result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE);
if ( result ) { if (result) {
pr_debug( printk(KERN_DEBUG
"failed to disable monitor mode, result=%d\n", "failed to disable monitor mode, result=%d\n",
result); result);
goto failed; goto failed;
} }
/* Disable port 0 */ /* Disable port 0 */
result = hfa384x_drvr_disable(hw, 0); result = hfa384x_drvr_disable(hw, 0);
if ( result ) { if (result) {
pr_debug( printk(KERN_DEBUG
"failed to disable port 0 after sniffing, result=%d\n", "failed to disable port 0 after sniffing, result=%d\n",
result); result);
goto failed; goto failed;
} }
/* Clear the driver state */ /* Clear the driver state */
...@@ -1124,32 +1116,34 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) ...@@ -1124,32 +1116,34 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Restore the wepflags */ /* Restore the wepflags */
result = hfa384x_drvr_setconfig16(hw, result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFWEPFLAGS, HFA384x_RID_CNFWEPFLAGS,
hw->presniff_wepflags); hw->presniff_wepflags);
if ( result ) { if (result) {
pr_debug( printk(KERN_DEBUG
"failed to restore wepflags=0x%04x, result=%d\n", "failed to restore wepflags=0x%04x, result=%d\n",
hw->presniff_wepflags, hw->presniff_wepflags, result);
result);
goto failed; goto failed;
} }
/* Set the port to its prior type and enable (if necessary) */ /* 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; word = hw->presniff_port_type;
result = hfa384x_drvr_setconfig16(hw, result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFPORTTYPE, word); HFA384x_RID_CNFPORTTYPE,
if ( result ) { word);
pr_debug( if (result) {
"failed to restore porttype, result=%d\n", printk(KERN_DEBUG
result); "failed to restore porttype, result=%d\n",
result);
goto failed; goto failed;
} }
/* Enable the port */ /* Enable the port */
result = hfa384x_drvr_enable(hw, 0); result = hfa384x_drvr_enable(hw, 0);
if ( result ) { if (result) {
pr_debug("failed to enable port to presniff setting, result=%d\n", result); printk(KERN_DEBUG
"failed to enable port to presniff setting, result=%d\n",
result);
goto failed; goto failed;
} }
} else { } else {
...@@ -1164,39 +1158,45 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) ...@@ -1164,39 +1158,45 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
break; break;
case P80211ENUM_truth_true: case P80211ENUM_truth_true:
/* Disable the port (if enabled), only check Port 0 */ /* 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) { if (wlandev->netdev->type == ARPHRD_ETHER) {
/* Save macport 0 state */ /* Save macport 0 state */
result = hfa384x_drvr_getconfig16(hw, result = hfa384x_drvr_getconfig16(hw,
HFA384x_RID_CNFPORTTYPE, HFA384x_RID_CNFPORTTYPE,
&(hw->presniff_port_type)); &(hw->
if ( result ) { presniff_port_type));
pr_debug("failed to read porttype, result=%d\n", result); if (result) {
printk(KERN_DEBUG
"failed to read porttype, result=%d\n",
result);
goto failed; goto failed;
} }
/* Save the wepflags state */ /* Save the wepflags state */
result = hfa384x_drvr_getconfig16(hw, result = hfa384x_drvr_getconfig16(hw,
HFA384x_RID_CNFWEPFLAGS, HFA384x_RID_CNFWEPFLAGS,
&(hw->presniff_wepflags)); &(hw->
if ( result ) { presniff_wepflags));
pr_debug("failed to read wepflags, result=%d\n", result); if (result) {
printk(KERN_DEBUG
"failed to read wepflags, result=%d\n",
result);
goto failed; goto failed;
} }
hfa384x_drvr_stop(hw); hfa384x_drvr_stop(hw);
result = hfa384x_drvr_start(hw); result = hfa384x_drvr_start(hw);
if ( result ) { if (result) {
pr_debug( printk(KERN_DEBUG
"failed to restart the card for sniffing, result=%d\n", "failed to restart the card for sniffing, result=%d\n",
result); result);
goto failed; goto failed;
} }
} else { } else {
/* Disable the port */ /* Disable the port */
result = hfa384x_drvr_disable(hw, 0); result = hfa384x_drvr_disable(hw, 0);
if ( result ) { if (result) {
pr_debug( printk(KERN_DEBUG
"failed to enable port for sniffing, result=%d\n", "failed to enable port for sniffing, result=%d\n",
result); result);
goto failed; goto failed;
} }
} }
...@@ -1207,14 +1207,14 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) ...@@ -1207,14 +1207,14 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Set the channel we wish to sniff */ /* Set the channel we wish to sniff */
word = msg->channel.data; word = msg->channel.data;
result = hfa384x_drvr_setconfig16(hw, result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFOWNCHANNEL, word); HFA384x_RID_CNFOWNCHANNEL,
hw->sniff_channel=word; word);
hw->sniff_channel = word;
if ( result ) { if (result) {
pr_debug( printk(KERN_DEBUG
"failed to set channel %d, result=%d\n", "failed to set channel %d, result=%d\n",
word, word, result);
result);
goto failed; goto failed;
} }
...@@ -1223,39 +1223,46 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) ...@@ -1223,39 +1223,46 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Set the port type to pIbss */ /* Set the port type to pIbss */
word = HFA384x_PORTTYPE_PSUEDOIBSS; word = HFA384x_PORTTYPE_PSUEDOIBSS;
result = hfa384x_drvr_setconfig16(hw, result = hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFPORTTYPE, word); HFA384x_RID_CNFPORTTYPE,
if ( result ) { word);
pr_debug( if (result) {
"failed to set porttype %d, result=%d\n", printk(KERN_DEBUG
word, "failed to set porttype %d, result=%d\n",
result); word, result);
goto failed; 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 */ /* Set the wepflags for no decryption */
word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT | word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT |
HFA384x_WEPFLAGS_DISABLE_RXCRYPT; HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFWEPFLAGS, word); result =
hfa384x_drvr_setconfig16(hw,
HFA384x_RID_CNFWEPFLAGS,
word);
} }
if ( result ) { if (result) {
pr_debug( printk(KERN_DEBUG
"failed to set wepflags=0x%04x, result=%d\n", "failed to set wepflags=0x%04x, result=%d\n",
word, word, result);
result);
goto failed; goto failed;
} }
} }
/* Do we want to strip the FCS in monitor mode? */ /* 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; hw->sniff_fcs = 0;
} else { } else {
hw->sniff_fcs = 1; hw->sniff_fcs = 1;
} }
/* Do we want to truncate the packets? */ /* 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; hw->sniff_truncate = msg->packet_trunc.data;
} else { } else {
hw->sniff_truncate = 0; hw->sniff_truncate = 0;
...@@ -1263,31 +1270,35 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) ...@@ -1263,31 +1270,35 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
/* Enable the port */ /* Enable the port */
result = hfa384x_drvr_enable(hw, 0); result = hfa384x_drvr_enable(hw, 0);
if ( result ) { if (result) {
pr_debug( printk(KERN_DEBUG
"failed to enable port for sniffing, result=%d\n", "failed to enable port for sniffing, result=%d\n",
result); result);
goto failed; goto failed;
} }
/* Enable monitor mode */ /* Enable monitor mode */
result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE); result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE);
if ( result ) { if (result) {
pr_debug( printk(KERN_DEBUG
"failed to enable monitor mode, result=%d\n", "failed to enable monitor mode, result=%d\n",
result); result);
goto failed; goto failed;
} }
if (wlandev->netdev->type == ARPHRD_ETHER) { if (wlandev->netdev->type == ARPHRD_ETHER)
printk(KERN_INFO "monitor mode enabled\n"); printk(KERN_INFO "monitor mode enabled\n");
}
/* Set the driver state */ /* Set the driver state */
/* Do we want the prism2 header? */ /* 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; hw->sniffhdr = 0;
wlandev->netdev->type = ARPHRD_IEEE80211_PRISM; 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; hw->sniffhdr = 1;
wlandev->netdev->type = ARPHRD_IEEE80211_PRISM; wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
} else { } 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