📄 wlan_cmdresp.c
字号:
// next 3 fields are time stamp, beacon interval,
// and capability information
// time stamp is 8 byte long
memcpy(pFixedIE->Timestamp, pCurrentPtr, 8);
memcpy(pBSSIDList->TimeStamp, pCurrentPtr, 8);
pCurrentPtr += 8;
usBytesLeftForCurrentBeacon -= 8;
// beacon interval is 2 byte long
memcpy(&(pFixedIE->BeaconInterval), pCurrentPtr, 2);
pBSSIDList->Configuration.BeaconPeriod =
wlan_le16_to_cpu(pFixedIE->BeaconInterval);
pCurrentPtr += 2;
usBytesLeftForCurrentBeacon -= 2;
// capability information is 2 byte long
memcpy(&(pFixedIE->Capabilities), pCurrentPtr, 2);
PRINTK1("(In WithIE fun1)pFixedIE->Capabilities=0x%X\n",
pFixedIE->Capabilities);
pBSSIDList->Configuration.BeaconPeriod =
wlan_le16_to_cpu(pFixedIE->BeaconInterval);
PRINTK1("(In WithIE fun2)pFixedIE->Capabilities=0x%X\n",
pFixedIE->Capabilities);
pFixedIE->Capabilities = wlan_le16_to_cpu(pFixedIE->Capabilities);
pCap = (IEEEtypes_CapInfo_t *) & (pFixedIE->Capabilities);
if (pCap->Privacy) {
PRINTK1("AP WEP enabled\n");
pBSSIDList->Privacy = Wlan802_11PrivFilter8021xWEP;
} else {
pBSSIDList->Privacy = Wlan802_11PrivFilterAcceptAll;
}
if (pCap->Ibss == 1) {
pBSSIDList->InfrastructureMode = Wlan802_11IBSS;
} else {
pBSSIDList->InfrastructureMode = Wlan802_11Infrastructure;
}
memcpy(&pBSSIDList->Cap, pCap, sizeof(IEEEtypes_CapInfo_t));
#ifdef ENABLE_802_11H_TPC
PRINTK2("Capability=0x%X SpectrumMgmt=%d\n",
pFixedIE->Capabilities, pCap->SpectrumMgmt );
if (pCap->SpectrumMgmt == 1) {
pBSSIDList->Sensed11H = 1;
/*
Set Sensed==TRUE,
if Cap.SpectrumMgmt==1 or
one of the TC_REQUEST, TP_REQUEST, POWERCAP,
POWERCONSTRAINT IE is found in Beacon or Probe-Resp
*/
}
#endif
pCurrentPtr += 2;
usBytesLeftForCurrentBeacon -= 2;
if (usBytesLeftForCurrentBeacon >
MRVDRV_SCAN_LIST_VAR_IE_SPACE) {
// not enough space to copy the IE for the current AP
// just skip it for now
pCurrentPtr += usBytesLeftForCurrentBeacon;
nBytesLeft -= usBeaconSize;
Adapter->ulNumOfBSSIDs--;
PRINTK1("Variable IE size too big to fit into buffer, "
"skip\n");
continue;
}
// reset are variable IE
// copy the entire variable IE to IE buffer
memcpy(pVariableIE, pCurrentPtr, usBytesLeftForCurrentBeacon);
HEXDUMP("IE info", (u8 *) pVariableIE,
usBytesLeftForCurrentBeacon);
bFoundDataRateIE = FALSE;
// process variable IE
while (usBytesLeftForCurrentBeacon > 2) {
nElemID = (IEEEtypes_ElementId_e)(*((unsigned char *)pCurrentPtr));
ucElemLen = *((unsigned char *) pCurrentPtr + 1);
usNumLineToPrint = (ucElemLen + 15) >> 4;
if (usBytesLeftForCurrentBeacon < ucElemLen) {
nBytesLeft -= usBeaconSize;
/* Keep AP info and only ignore the paddings
Adapter->ulNumOfBSSIDs--;
*/
PRINTK1("Error in processing IE, bytes left < IE length\n");
usBytesLeftForCurrentBeacon = 0;
continue;
}
if ( ucElemLen == 0x00 ) {
PRINTK1("Ignore IE with zero Length\n");
pCurrentPtr += 2;
usBytesLeftForCurrentBeacon -= 2;
continue;
}
switch (nElemID) {
case SSID:
pBSSIDList->Ssid.SsidLength = ucElemLen;
memcpy(pBSSIDList->Ssid.Ssid, (pCurrentPtr + 2), ucElemLen);
break;
case SUPPORTED_RATES:
memcpy(pBSSIDList->DataRates, (pCurrentPtr + 2), ucElemLen);
memmove(pBSSIDList->SupportedRates, (pCurrentPtr + 2),
ucElemLen);
ucRateSize = ucElemLen;
bFoundDataRateIE = TRUE;
break;
case EXTRA_IE:
PRINTK1("EXTRA_IE Found!\n" );
pBSSIDList->extra_ie = 1;
break;
case FH_PARAM_SET:
pFH = (IEEEtypes_FhParamSet_t *)pCurrentPtr;
pBSSIDList->NetworkTypeInUse = Wlan802_11FH;
pBSSIDList->Configuration.DSConfig = 0;
pBSSIDList->Configuration.FHConfig.Length =
sizeof(WLAN_802_11_CONFIGURATION_FH);
pBSSIDList->Configuration.FHConfig.HopPattern = pFH->HopSet;
pBSSIDList->Configuration.FHConfig.DwellTime = pFH->DwellTime;
memmove(&pBSSIDList->PhyParamSet.FhParamSet, pFH,
sizeof(IEEEtypes_FhParamSet_t));
pBSSIDList->PhyParamSet.FhParamSet.DwellTime
= wlan_le16_to_cpu(pBSSIDList
->PhyParamSet.FhParamSet.DwellTime);
break;
case DS_PARAM_SET:
pDS = (IEEEtypes_DsParamSet_t *)pCurrentPtr;
pBSSIDList->NetworkTypeInUse = Wlan802_11DS;
pBSSIDList->Configuration.DSConfig
= DSFreqList[pDS->CurrentChan];
pBSSIDList->Channel = pDS->CurrentChan;
memcpy(&pBSSIDList->PhyParamSet.DsParamSet, pDS,
sizeof(IEEEtypes_DsParamSet_t));
break;
case CF_PARAM_SET:
pCF = (IEEEtypes_CfParamSet_t *)pCurrentPtr;
memcpy(&(pBSSIDList->SsParamSet.CfParamSet), pCF,
sizeof(IEEEtypes_CfParamSet_t));
break;
case IBSS_PARAM_SET:
pIbss = (IEEEtypes_IbssParamSet_t *)pCurrentPtr;
pBSSIDList->Configuration.ATIMWindow
= wlan_le32_to_cpu(pIbss->AtimWindow);
memmove(&pBSSIDList->SsParamSet.IbssParamSet, pIbss,
sizeof(IEEEtypes_IbssParamSet_t));
pBSSIDList->SsParamSet.IbssParamSet.AtimWindow
= wlan_le16_to_cpu(pBSSIDList
->SsParamSet.IbssParamSet.AtimWindow);
break;
#ifdef ENABLE_802_11D
case COUNTRY_INFO: /*Handle Country Info IE*/
pcountryinfo = (IEEEtypes_CountryInfoSet_t *)pCurrentPtr;
if ( pcountryinfo->Len < sizeof(pcountryinfo->CountryCode) ||
pcountryinfo->Len > 254 ) {
PRINTK1("11D: Err CountryInfo len =%d min=%d max=254\n",
pcountryinfo->Len,
sizeof(pcountryinfo->CountryCode) );
return -1;
}
memcpy( &(pBSSIDList->CountryInfo), pcountryinfo,
pcountryinfo->Len + 2 );
HEXDUMP("11D: CountryInfo:", (u8 *)pcountryinfo,
(int)(pcountryinfo->Len+2) );
break;
#endif
#ifdef ENABLE_802_11H_TPC
case POWER_CONSTRAINT:
PRINTK("11HTPC: POWER_CONSTAINT IE Found\n");
pBSSIDList->Sensed11H = 1;
{
IEEEtypes_PowerConstraint_t *ppwrCons
= (IEEEtypes_PowerConstraint_t *)pCurrentPtr;
/* Copy IEEEtypes_PowerConstraint_t info to pBSSIDList */
memmove(&pBSSIDList->PowerConstraint, ppwrCons,
sizeof(IEEEtypes_PowerConstraint_t));
}
break;
case POWER_CAPABILITY:
PRINTK("11HTPC: POWER_CAPABILITY IE Found\n");
pBSSIDList->Sensed11H = 1;
{
IEEEtypes_PowerCapability_t *ppwrCap =
(IEEEtypes_PowerCapability_t *)pCurrentPtr;
memmove(&pBSSIDList->PowerCapability, ppwrCap,
sizeof(IEEEtypes_PowerCapability_t));
}
break;
case TPC_REQUEST:
PRINTK("11HTPC: TPC_REQUEST IE Found\n");
pBSSIDList->Sensed11H = 1;
break;
case TPC_REPORT:
PRINTK("11HTPC: TPC_REPORT IE Found\n");
pBSSIDList->Sensed11H = 1;
{
IEEEtypes_TPCReport_t *ptpcreport =
(IEEEtypes_TPCReport_t *)pCurrentPtr;
memmove(&pBSSIDList->TPCReport, ptpcreport,
sizeof(IEEEtypes_TPCReport_t));
}
break;
#endif /* ENABLE_802_11H_TPC */
case EXTENDED_SUPPORTED_RATES:
// only process extended supported rate
// if data rate is already found.
// data rate IE should come before
// extended supported rate IE
if (bFoundDataRateIE) {
unsigned char *pRate;
u8 ucBytesToCopy;
if ((ucElemLen + ucRateSize) > WLAN_SUPPORTED_RATES)
{
ucBytesToCopy = (WLAN_SUPPORTED_RATES - ucRateSize);
}
else
{
ucBytesToCopy = ucElemLen;
}
pRate = (unsigned char *)pBSSIDList->DataRates;
pRate += ucRateSize;
memmove(pRate,(pCurrentPtr +2), ucBytesToCopy);
pRate = (unsigned char *)pBSSIDList->SupportedRates;
pRate += ucRateSize;
memmove(pRate,(pCurrentPtr +2), ucBytesToCopy);
}
break;
case VENDOR_SPECIFIC_221:
#ifdef WPA
#define IE_ID_LEN_FIELDS_BYTES 2
pIe = (IE_WPA *) pCurrentPtr;
if (!memcmp(pIe->oui, oui01, sizeof(oui01)))
{
pwpa_supplicant->Wpa_ie_len
= MIN(ucElemLen + IE_ID_LEN_FIELDS_BYTES,
sizeof(pwpa_supplicant->Wpa_ie));
memcpy(pwpa_supplicant->Wpa_ie,
pCurrentPtr, pwpa_supplicant->Wpa_ie_len);
HEXDUMP("Resp WPA_IE",
pwpa_supplicant->Wpa_ie, ucElemLen);
}
#ifdef WMM
else if (!memcmp(pIe->oui, oui02, sizeof(oui02))) {
pBSSIDList->Wmm_ie_len
= MIN(ucElemLen + IE_ID_LEN_FIELDS_BYTES,
sizeof(pBSSIDList->Wmm_IE));
memcpy(pBSSIDList->Wmm_IE, pCurrentPtr,
pBSSIDList->Wmm_ie_len);
HEXDUMP("Resp WMM_IE", pBSSIDList->Wmm_IE,
pBSSIDList->Wmm_ie_len);
}
#endif /* WMM */
#endif /* WPA */
#ifdef CCX
wlan_ccx_process_bss_elem(&pBSSIDList->ccx_bss_info,
pCurrentPtr);
#endif
break;
#ifdef WPA2
case WPA2_IE:
pIe = (IE_WPA *) pCurrentPtr;
pwpa2_supplicant->Wpa_ie_len
= MIN(ucElemLen + IE_ID_LEN_FIELDS_BYTES,
sizeof(pwpa2_supplicant->Wpa_ie));
memcpy(pwpa2_supplicant->Wpa_ie,
pCurrentPtr, pwpa2_supplicant->Wpa_ie_len);
HEXDUMP("Resp WPA2_IE", pwpa2_supplicant->Wpa_ie, ucElemLen);
break;
#endif //WPA2
case TIM:
break;
case CHALLENGE_TEXT:
break;
#ifdef CCX
default:
wlan_ccx_process_bss_elem(&pBSSIDList->ccx_bss_info,
pCurrentPtr);
break;
#endif
}
pCurrentPtr += ucElemLen + 2;
// need to account for IE ID and IE Len
usBytesLeftForCurrentBeacon =
usBytesLeftForCurrentBeacon - ucElemLen - 2;
} // while (usBytesLeftForCurrentBeacon > 2)
// update the length field
pBSSIDList->Length = sizeof(WLAN_802_11_BSSID) + pBSSIDList->IELength;
// need to be 4 byte aligned
pBSSIDList->Length = ((pBSSIDList->Length + 3) >> 2) << 2;
nBytesLeft -= usBeaconSize;
ulBSSIDIndex++;
} // while (nBytesLeft > 0 && ulBSSIDIndex < MRVDRV_MAX_BSSID_LIST)
PRINTK1("-InterpretBSSDescription: normal exit\n");
return 0;
}
int InterpretBSSDescription(wlan_private * priv, void *RetCommandBuffer,
u32 ulBSSDescriptionListSize, int next_bssid_index)
{
wlan_adapter *Adapter = priv->adapter;
if (FW_IS_WPA_ENABLED(Adapter)) {
PRINTK1("WPA Enabled in Firmware\n");
return InterpretBSSDescriptionWithIE(priv, RetCommandBuffer,
ulBSSDescriptionListSize, next_bssid_index);
}
else
PRINTK1("WPA NOT Enabled in Firmware\n");
return WLAN_STATUS_FAILURE;
}
int wlan_ret_reg_access(wlan_private * priv, u16 type,
HostCmd_DS_COMMAND * resp)
{
wlan_adapter *Adapter = priv->adapter;
ENTER();
switch (type) {
case HostCmd_RET_MAC_REG_ACCESS:
{
HostCmd_DS_MAC_REG_ACCESS *reg;
reg = (PHostCmd_DS_MAC_REG_ACCESS) &
resp->params.macreg;
Adapter->OffsetValue.offset = reg->Offset;
Adapter->OffsetValue.value = reg->Value;
break;
}
case HostCmd_RET_BBP_REG_ACCESS:
{
HostCmd_DS_BBP_REG_ACCESS *reg;
reg = (PHostCmd_DS_BBP_REG_ACCESS) &
resp->params.bbpreg;
Adapter->OffsetValue.offset = reg->Offset;
Adapter->OffsetValue.value = reg->Value;
break;
}
case HostCmd_RET_RF_REG_ACCESS:
{
HostCmd_DS_RF_REG_ACCESS *reg;
reg = (PHostCmd_DS_RF_REG_ACCESS) &
resp->params.rfreg;
Adapter->OffsetValue.offset = reg->Offset;
Adapter->OffsetValue.value = reg->Value;
break;
}
default:
return -1;
}
LEAVE();
return 0;
}
void MacEventDisconnected(wlan_private * priv)
{
wlan_adapter *Adapter = priv->adapter;
union iwreq_data wrqu;
ENTER();
if (Adapter->MediaConnectStatus != WlanMediaStateConnected)
return;
PRINTK1("WlanMediaStateDisconnected\n");
memset(wrqu.ap_addr.sa_data, 0x00, ETH_ALEN);
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
/* Cisco AP sends EAP failure and de-auth in less than 0.5 ms. This
and that causes problems in the Supplicant */
os_sched_timeout(1000);
wireless_send_event(priv->wlan_dev.netdev, SIOCGIWAP, &wrqu, NULL);
/* Flush all the packets upto the OS before stopping */
wlan_send_rxskbQ(priv);
netif_carrier_off(priv->wlan_dev.netdev);
/* reset SNR/NF/RSSI values */
memset(Adapter->SNR, 0x00, sizeof(Adapter->SNR));
memset(Adapter->NF, 0x00, sizeof(Adapter->NF));
memset(Adapter->RSSI, 0x00, sizeof(Adapter->RSSI));
PRINTK1("Current SSID=%s, Ssid Length=%u\n",
Adapter->CurBssParams.ssid.Ssid,
Adapter->CurBssParams.ssid.SsidLength);
PRINTK1("Previous SSID=%s, Ssid Length=%u\n",
Adapter->PreviousSSID.Ssid,
Adapter->PreviousSSID.SsidLength);
/* reset internal flags */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -