📄 wlan_cmdresp.c
字号:
Adapter->BSSIDList[i].MacAddress[4],
Adapter->BSSIDList[i].MacAddress[5],
(int) Adapter->BSSIDList[i].Rssi,
Adapter->
BSSIDList[i].SupportedRates[i]);
}
#ifdef PROGRESSIVE_SCAN
}
#endif
#endif
discard_bad_ssid(Adapter);
// if currently connected to an AP or an Ad Hoc network
if (Adapter->CurBssParams.ssid.SsidLength != 0 &&
Adapter->CurBssParams.ssid.Ssid[0] > 0x20) {
// try to find the current SSID in the new scan list
for (i = 0; i < Adapter->ulNumOfBSSIDs; i++) {
if (!SSIDcmp(&Adapter->BSSIDList[i].Ssid,
&Adapter->CurBssParams.ssid) &&
!memcmp(Adapter->CurrentBSSID,
Adapter->BSSIDList[i].
MacAddress,
MRVDRV_ETH_ADDR_LEN)) {
break;
}
}
// if we found matching SSID, update the index
if (i < Adapter->ulNumOfBSSIDs) {
// Set the attempted BSSID Index to current
Adapter->ulCurrentBSSIDIndex = i;
// Set the new BSSID (AP's MAC address) to current BSSID
memcpy(Adapter->CurrentBSSID,
&(Adapter->BSSIDList[Adapter->
ulCurrentBSSIDIndex].MacAddress),
MRVDRV_ETH_ADDR_LEN);
// Make a copy of current BSSID descriptor
memcpy(&Adapter->CurrentBSSIDDescriptor,
&Adapter->BSSIDList[Adapter->
ulCurrentBSSIDIndex],
sizeof(WLAN_802_11_BSSID));
// Set the new configuration to the current config
memcpy(&Adapter->CurrentConfiguration,
&Adapter->BSSIDList[Adapter->
ulCurrentBSSIDIndex].Configuration,
sizeof(WLAN_802_11_CONFIGURATION));
}
// if the current associated SSID is not contained in the
// list, append it
else {
#ifdef PROGRESSIVE_SCAN
if (Adapter->ScanChannelsLeft == 0) {
#endif
AppendCurrentSSID(priv, i);
#ifdef PROGRESSIVE_SCAN
}
#endif
}
}
PRINTK1("HWAC - Scanned %2d APs\n", Adapter->ulNumOfBSSIDs);
LEAVE();
return 0;
}
static int wlan_ret_mac_control(wlan_private * priv, HostCmd_DS_COMMAND * resp)
{
return 0;
}
static int wlan_ret_802_11_associate(wlan_private * priv,
HostCmd_DS_COMMAND * resp)
{
HostCmd_DS_802_11_ASSOCIATE_RSP *rasst = &resp->params.associatersp;
wlan_adapter *Adapter = priv->adapter;
union iwreq_data wrqu;
u16 ResultCode = wlan_le16_to_cpu(rasst->ResultCode);
ENTER();
Adapter->bIsAssociationInProgress = FALSE;
if (ResultCode) {
PRINTK1("HWAC - Association Failed, code = %d\n", rasst->ResultCode);
if (Adapter->MediaConnectStatus == WlanMediaStateConnected) {
MacEventDisconnected(priv);
}
#ifdef WPA
if (ResultCode == HostCmd_Assoc_RESULT_AUTH_REFUSED) {
send_iwevcustom_event(priv, "BAD-AUTH.indication ");
}
#endif
return 0;
}
#ifdef WPA
{
//copy the association result info to the
//ASSOCIATION_INFO buffer
PWLAN_802_11_ASSOCIATION_INFORMATION pInfo;
int buflen;
pInfo = (PWLAN_802_11_ASSOCIATION_INFORMATION)
Adapter->AssocInfoBuffer;
//only currently copy the fixed IE
memcpy(&pInfo->ResponseFixedIEs.Capabilities,
&rasst->CapInfo, sizeof(rasst->CapInfo));
pInfo->ResponseFixedIEs.StatusCode =
ResultCode;
pInfo->ResponseFixedIEs.AssociationId =
wlan_le16_to_cpu(rasst->AssociationID);
pInfo->AvailableResponseFixedIEs |=
WLAN_802_11_AI_RESFI_CAPABILITIES;
pInfo->AvailableResponseFixedIEs |=
WLAN_802_11_AI_RESFI_STATUSCODE;
pInfo->AvailableResponseFixedIEs |=
WLAN_802_11_AI_RESFI_ASSOCIATIONID;
pInfo->OffsetResponseIEs = pInfo->OffsetRequestIEs +
pInfo->RequestIELength;
pInfo->ResponseIELength = wlan_le16_to_cpu(rasst->IELength);
buflen = sizeof(Adapter->AssocInfoBuffer) - pInfo->OffsetResponseIEs;
memmove((u8*)pInfo + pInfo->OffsetResponseIEs,
(u8*)&rasst->RateID,
MIN(buflen, wlan_le16_to_cpu(rasst->IELength)));
PRINTK1("Association Result IE: CapInfo = 0x%x,"
"StatusCode = 0x%x,AssociationID = 0x%x\n",
pInfo->ResponseFixedIEs.Capabilities,
pInfo->ResponseFixedIEs.StatusCode,
pInfo->ResponseFixedIEs.AssociationId);
}
#endif // WPA
HEXDUMP("Association response:",
(void*)rasst, sizeof(HostCmd_DS_802_11_ASSOCIATE_RSP));
// Send a Media Connected event, according to the Spec
Adapter->MediaConnectStatus = WlanMediaStateConnected;
Adapter->LinkSpeed = MRVDRV_LINK_SPEED_11mbps;
// Set the attempted BSSID Index to current
Adapter->ulCurrentBSSIDIndex = Adapter->ulAttemptedBSSIDIndex;
PRINTK1("Associated BSSIDList[%d]=%s\n", Adapter->ulCurrentBSSIDIndex,
Adapter->BSSIDList[Adapter->
ulCurrentBSSIDIndex].Ssid.Ssid);
// Set the new SSID to current SSID
memcpy(&Adapter->CurBssParams.ssid, &Adapter->
BSSIDList[Adapter-> ulCurrentBSSIDIndex].Ssid,
sizeof(WLAN_802_11_SSID));
// Set the new BSSID (AP's MAC address) to current BSSID
memcpy(Adapter->CurrentBSSID, &Adapter->BSSIDList
[Adapter->ulCurrentBSSIDIndex].MacAddress,
MRVDRV_ETH_ADDR_LEN);
// Make a copy of current BSSID descriptor
memcpy(&Adapter->CurrentBSSIDDescriptor,
&Adapter->BSSIDList[Adapter->ulCurrentBSSIDIndex],
sizeof(WLAN_802_11_BSSID));
/* Copy associate'd bssid into Current BSS State struct */
memcpy(&Adapter->CurBssParams.bssid,
&Adapter->BSSIDList[Adapter->ulCurrentBSSIDIndex],
sizeof(WLAN_802_11_BSSID));
#ifdef WMM
if (Adapter->BSSIDList[Adapter->
ulCurrentBSSIDIndex].Wmm_IE[0] == WMM_IE) {
Adapter->CurBssParams.wmm_enabled = TRUE;
wmm_setup_queue_priorities(priv);
}
else
Adapter->CurBssParams.wmm_enabled = FALSE;
if (Adapter->wmm.required && Adapter->CurBssParams.wmm_enabled)
Adapter->wmm.enabled = TRUE;
else
Adapter->wmm.enabled = FALSE;
#endif /* WMM */
#ifdef WMM_UAPSD
Adapter->CurBssParams.wmm_uapsd_enabled = FALSE;
if (Adapter->wmm.enabled == TRUE)
{
if(Adapter->BSSIDList[Adapter->ulCurrentBSSIDIndex].Wmm_IE[8] & 0x80)
Adapter->CurBssParams.wmm_uapsd_enabled = TRUE;
}
#endif
if (Adapter->ulCurrentBSSIDIndex < MRVDRV_MAX_BSSID_LIST) {
// Set the new configuration to the current config
memcpy(&Adapter->CurrentConfiguration,
&Adapter->BSSIDList[Adapter->
ulCurrentBSSIDIndex].
Configuration,
sizeof(WLAN_802_11_CONFIGURATION));
}
#if 0
#ifdef REASSOCIATION
// if the periodic timer is on, cancel it
if (Adapter->TimerIsSet == TRUE) {
CancelTimer(&Adapter->MrvDrvTimer);
Adapter->TimerIsSet = FALSE;
}
#endif /* REASSOCIATION */
#endif
// Association causes the MAC to lose the flag such as
// promiscuous mode on, need to set the flag again
if (Adapter->CurBssParams.ssid.Ssid[0] == '\0' ||
!Adapter->CurBssParams.ssid.SsidLength) {
memcpy(&Adapter->CurBssParams.ssid, &Adapter->PreviousSSID,
sizeof(WLAN_802_11_SSID));
memcpy(&Adapter->CurrentBSSID, &Adapter->PreviousBSSID,
ETH_ALEN);
}
PRINTK1("Value of the mac controller-> %x\n",
Adapter->CurrentPacketFilter);
Adapter->MediaConnectStatus = WlanMediaStateConnected;
#ifdef WPA
if (Adapter->SecInfo.WPAEnabled
#ifdef WPA2
|| Adapter->SecInfo.WPA2Enabled
#endif
)
Adapter->IsGTK_SET = FALSE;
#endif
Adapter->SNR[TYPE_RXPD][TYPE_AVG] =
Adapter->NF[TYPE_RXPD][TYPE_AVG] = 0;
#ifdef WMM
/* Don't enable carrier until we get the WMM_GET_STATUS event */
if (Adapter->wmm.enabled)
sendWMMStatusChangeCmd(priv);
else
#endif /* WMM */
netif_carrier_on(priv->wlan_dev.netdev);
PRINTK1("HWAC - Associated \n");
memcpy(wrqu.ap_addr.sa_data, Adapter->CurrentBSSID, ETH_ALEN);
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
wireless_send_event(priv->wlan_dev.netdev, SIOCGIWAP, &wrqu, NULL);
LEAVE();
return 0;
}
static int wlan_ret_802_11_disassociate(wlan_private * priv,
HostCmd_DS_COMMAND * resp)
{
ENTER();
MacEventDisconnected(priv);
LEAVE();
return 0;
}
static int wlan_ret_802_11_ad_hoc_stop(wlan_private * priv,
HostCmd_DS_COMMAND * resp)
{
ENTER();
MacEventDisconnected(priv);
LEAVE();
return 0;
}
static int wlan_ret_802_11_set_wep(wlan_private * priv,
HostCmd_DS_COMMAND * resp)
{
return 0;
}
static int wlan_ret_802_11_ad_hoc_start(wlan_private * priv,
HostCmd_DS_COMMAND * resp)
{
int ret = 0;
wlan_adapter *Adapter = priv->adapter;
u16 Command = wlan_le16_to_cpu(resp->Command);
HostCmd_DS_802_11_AD_HOC_RESULT *pAdHocResult = &resp->params.result;
u16 Result = wlan_le16_to_cpu(resp->Result);
union iwreq_data wrqu;
ENTER();
PRINTK1("Size = %d\n", wlan_le16_to_cpu(resp->Size));
PRINTK1("Command = %x\n", Command);
PRINTK1("Result = %x\n", Result);
Adapter->bIsAssociationInProgress = FALSE;
// Join result code 0 --> SUCCESS
// if join result code != 0, will return Failure later
if (Result) {
PRINTK1("HWAC Join or Start Command Failed\n");
if (Adapter->MediaConnectStatus == WlanMediaStateConnected) {
MacEventDisconnected(priv);
}
if (Command == HostCmd_RET_802_11_AD_HOC_JOIN) {
Adapter->m_NumAssociationAttemp++;
if (Adapter->m_NumAssociationAttemp >= 2) {
// do not attemp any more
return 0;
}
ret = PrepareAndSendCommand(priv,
HostCmd_CMD_802_11_AD_HOC_JOIN, 0,
HostCmd_OPTION_USE_INT, (WLAN_OID) 0,
HostCmd_PENDING_ON_CMD,
&(Adapter->AttemptedSSIDBeforeScan));
if (ret) {
LEAVE();
return ret;
}
}
// If it's a START command and it fails,
// remove the entry on BSSIDList
else if (Command == HostCmd_RET_802_11_AD_HOC_START) {
memset(&(Adapter->BSSIDList[Adapter->
ulAttemptedBSSIDIndex]), 0,
sizeof(WLAN_802_11_BSSID));
Adapter->ulNumOfBSSIDs--;
}
Adapter->AdHocFailed = TRUE;
return 0;
}
// Now the join cmd should be successful
// If BSSID has changed use SSID to compare instead of BSSID
PRINTK1("Associated with %s\n",
Adapter->BSSIDList[Adapter->
ulAttemptedBSSIDIndex].Ssid.Ssid);
if (memcmp(Adapter->CurBssParams.ssid.Ssid,
Adapter->BSSIDList[Adapter->
ulAttemptedBSSIDIndex].Ssid.Ssid,
Adapter->BSSIDList[Adapter->
ulAttemptedBSSIDIndex].Ssid.SsidLength)) {
// Send a Media Connected event, according to the Spec
Adapter->MediaConnectStatus = WlanMediaStateConnected;
Adapter->LinkSpeed = MRVDRV_LINK_SPEED_11mbps;
// NOTE: According to spec, WLAN_STATUS_MEDIA_CONNECT should
// be indicated only when the first client joins, not
// when the network is started. Therefore, CONNECT
// should not be indicated if the command was AD_HOC_START
// Set the attempted BSSID Index to current
Adapter->ulCurrentBSSIDIndex = Adapter->ulAttemptedBSSIDIndex;
// Set the new SSID to current SSID
memmove(&(Adapter->CurBssParams.ssid),
&(Adapter->BSSIDList[Adapter->
ulCurrentBSSIDIndex].Ssid),
sizeof(WLAN_802_11_SSID));
// If it's a Start command,
// set the BSSID to the returned value
if (Command == HostCmd_RET_802_11_AD_HOC_START) {
memmove(&(Adapter->BSSIDList[Adapter->
ulCurrentBSSIDIndex].
MacAddress),
pAdHocResult->BSSID,
MRVDRV_ETH_ADDR_LEN);
Adapter->AdHocCreated = TRUE;
}
if (Adapter->ulCurrentBSSIDIndex < MRVDRV_MAX_BSSID_LIST) {
// Set the new BSSID (AP's MAC address) to current BSSID
memmove(Adapter->CurrentBSSID,
&(Adapter->BSSIDList[Adapter->
ulCurrentBSSIDIndex].
MacAddress),
MRVDRV_ETH_ADDR_LEN);
// Make a copy of current BSSID descriptor
memmove(&(Adapter->CurrentBSSIDDescriptor),
&(Adapter->BSSIDList[Adapter->
ulCurrentBSSIDIndex]),
sizeof(WLAN_802_11_BSSID));
/* Copy adhoc'd bssid into Current BSS State struct */
memcpy(&Adapter->CurBssParams.bssid, &Adapter->
BSSIDList[Adapter-> ulCurrentBSSIDIndex],
sizeof(WLAN_802_11_BSSID));
// Set the new configuration to the current config
memmove(&Adapter->CurrentConfiguration,
&(Adapter->BSSIDList[Adapter->
ulCurrentBSSIDIndex].
Configuration),
sizeof(WLAN_802_11_CONFIGURATION));
}
}
Adapter->m_NumAssociationAttemp = 0;
netif_carrier_on(priv->wlan_dev.netdev);
memset(&wrqu, 0, sizeof(wrqu));
memcpy(wrqu.ap_addr.sa_data, Adapter->CurrentBSSID, ETH_ALEN);
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
wireless_send_event(priv->wlan_dev.netdev, SIOCGIWAP, &wrqu, NULL);
PRINTK1("HWAC - Joined/Started Ad Hoc\n");
PRINTK1("Ad-Hoc Channel = %d\n", Adapter->AdhocChannel);
PRINTK1("BSSID %x:%x:%x:%x:%x:%x\n",
pAdHocResult->BSSID[0], pAdHocResult->BSSID[1],
pAdHocResult->BSSID[2], pAdHocResult->BSSID[3],
pAdHocResult->BSSID[4], pAdHocResult->BSSID[5]);
LEAVE();
return ret;
}
static int wlan_ret_802_11_reset(wlan_private * priv, HostCmd_DS_COMMAND * resp)
{
ENTER();
PRINTK1("HWAC - Reset command successful\n");
return 0;
}
static int wlan_ret_802_11_query_traffic(wlan_private * priv,
HostCmd_DS_COMMAND * resp)
{
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -