stm32驱动wifi88W8686WMGMR09edited.docx

上传人:b****7 文档编号:10555633 上传时间:2023-02-21 格式:DOCX 页数:112 大小:50.94KB
下载 相关 举报
stm32驱动wifi88W8686WMGMR09edited.docx_第1页
第1页 / 共112页
stm32驱动wifi88W8686WMGMR09edited.docx_第2页
第2页 / 共112页
stm32驱动wifi88W8686WMGMR09edited.docx_第3页
第3页 / 共112页
stm32驱动wifi88W8686WMGMR09edited.docx_第4页
第4页 / 共112页
stm32驱动wifi88W8686WMGMR09edited.docx_第5页
第5页 / 共112页
点击查看更多>>
下载资源
资源描述

stm32驱动wifi88W8686WMGMR09edited.docx

《stm32驱动wifi88W8686WMGMR09edited.docx》由会员分享,可在线阅读,更多相关《stm32驱动wifi88W8686WMGMR09edited.docx(112页珍藏版)》请在冰豆网上搜索。

stm32驱动wifi88W8686WMGMR09edited.docx

stm32驱动wifi88W8686WMGMR09edited

F:

\WiFi_V2.1\src\wifi\wlan_scan.c

#include"wifi.h"

#include

#include

#include

/********************************************************

LocalConstants

********************************************************/

//!

Approximateamountofdataneededtopassascanresultbacktoiwlist

#defineMAX_SCAN_CELL_SIZE(IW_EV_ADDR_LEN\

+MRVDRV_MAX_SSID_LENGTH\

+IW_EV_UINT_LEN\

+IW_EV_FREQ_LEN\

+IW_EV_QUAL_LEN\

+MRVDRV_MAX_SSID_LENGTH\

+IW_EV_PARAM_LEN\

+40)/*40forWPAIE*/

//!

MemoryneededtostoreamaxsizedChannelListTLVforafirmwarescan

#defineCHAN_TLV_MAX_SIZE(sizeof(MrvlIEtypesHeader_t)\

+(MRVDRV_MAX_CHANNELS_PER_SCAN\

*sizeof(ChanScanParamSet_t)))

//!

Memoryneededtostoreamaxnumber/sizeSSIDTLVforafirmwarescan

#defineSSID_TLV_MAX_SIZE(1*sizeof(MrvlIEtypes_SsIdParamSet_t))

//!

WPSTLVMAXsizeisMAXIEsizeplus2bytesforu16MRVLTLVextension

#defineWPS_TLV_MAX_SIZE(sizeof(IEEEtypes_VendorSpecific_t)+2)

//!

Maximummemoryneededforawlan_scan_cmd_configwithallTLVsatmax

#defineMAX_SCAN_CFG_ALLOC(sizeof(wlan_scan_cmd_config)\

+sizeof(MrvlIEtypes_NumProbes_t)\

+CHAN_TLV_MAX_SIZE\

+SSID_TLV_MAX_SIZE\

+WPS_TLV_MAX_SIZE)

//!

Themaximumnumberofchannelsthefirmwarecanscanpercommand

#defineMRVDRV_MAX_CHANNELS_PER_SCAN14

/**

*@briefNumberofchannelstoscanperfirmwarescancommandissuance.

*

*Numberrestrictedtopreventhittingthelimitontheamountofscandata

*returnedinasinglefirmwarescancommand.

*/

#defineMRVDRV_CHANNELS_PER_SCAN_CMD4

//!

Macrotoenable/disableSSIDcheckingbeforestoringascantable

#ifdefDISCARD_BAD_SSID

#defineCHECK_SSID_IS_VALID(x)ssid_valid(&bssidEntry.Ssid)

Page:

1

F:

\WiFi_V2.1\src\wifi\wlan_scan.c

#else

#defineCHECK_SSID_IS_VALID(x)TRUE

#endif

/********************************************************

LocalVariablesandTypes

********************************************************/

/**

*@briefInterallyusedtosendaconfiguredscancmdbetweendriverroutines

*/

typedefunion

{

wlan_scan_cmd_configconfig;//!

u8configAllocBuf[MAX_SCAN_CFG_ALLOC];//!

}wlan_scan_cmd_config_tlv;

/**

*@briefCheckifascannednetworkcompatiblewiththedriversettings

*

*WEPWPAWPA2ad-hocencryptNetwork

*enabledenabledenabledAESmodePrivacyWPAWPA2Compatible

*0000NONE000yesNosecurity

*0100x1x1xyesWPA

*0010x1xx1yesWPA2

*0001NONE100yesAd-hocAES

*

*1000NONE100yesStaticWEP

*0000!

=NONE100yesDynamicWEP

*

*

*@paramAdapterApointertowlan_adapter

*@paramindexIndexinScanTabletocheckagainstcurrentdriversettings

*@parammodeNetworkmode:

InfrastructureorIBSS

*

*@returnIndexinScanTable,orerrorcodeifnegative

*/

staticint

IsNetworkCompatible(wlan_adapter*Adapter,intindex,intmode)

{

BSSDescriptor_t*pBSSDesc;

ENTER();

pBSSDesc=&Adapter->ScanTable[index];

/*Don'tcheckforcompatibilityifroaming*/

if((Adapter->MediaConnectStatus==WlanMediaStateConnected)

&&(Adapter->InfrastructureMode==Wlan802_11Infrastructure)

&&(pBSSDesc->InfrastructureMode==Wlan802_11Infrastructure)){

LEAVE();

returnindex;

}

if(Adapter->wps.SessionEnable==TRUE){

printf("ReturnsuccessdirectlyinWPSperiod\n");

LEAVE();

returnindex;

}

if(pBSSDesc->InfrastructureMode==mode){

if(Adapter->SecInfo.WEPStatus==Wlan802_11WEPDisabled

&&!

Adapter->SecInfo.WPAEnabled

&&!

Adapter->SecInfo.WPA2Enabled

&&pBSSDesc->wpaIE.VendHdr.ElementId!

=WPA_IE

&&pBSSDesc->rsnIE.IeeeHdr.ElementId!

=RSN_IE

&&!

Adapter->AdhocAESEnabled

&&Adapter->SecInfo.EncryptionMode==CIPHER_NONE

Page:

2

F:

\WiFi_V2.1\src\wifi\wlan_scan.c

&&!

pBSSDesc->Privacy){

/*nosecurity*/

LEAVE();

returnindex;

}elseif(Adapter->SecInfo.WEPStatus==Wlan802_11WEPEnabled

&&!

Adapter->SecInfo.WPAEnabled

&&!

Adapter->SecInfo.WPA2Enabled

&&!

Adapter->AdhocAESEnabled&&pBSSDesc->Privacy){

/*staticWEPenabled*/

LEAVE();

returnindex;

}elseif(Adapter->SecInfo.WEPStatus==Wlan802_11WEPDisabled

&&Adapter->SecInfo.WPAEnabled

&&!

Adapter->SecInfo.WPA2Enabled

&&(pBSSDesc->wpaIE.VendHdr.ElementId==WPA_IE)

&&!

Adapter->AdhocAESEnabled

/*PrivacybitmayNOTbesetinsomeAPslikeLinkSysWRT54G

&&pBSSDesc->Privacy*/

){

/*WPAenabled*/

printf("IsNetworkCompatible()WPA:

index=%dwpa_ie=%#x"

"wpa2_ie=%#xWEP=%sWPA=%sWPA2=%sEncMode=%#x"

"privacy=%#x\n",

index,

pBSSDesc->wpaIE.VendHdr.ElementId,

pBSSDesc->rsnIE.IeeeHdr.ElementId,

(Adapter->SecInfo.WEPStatus==

Wlan802_11WEPEnabled)?

"e":

"d",

(Adapter->SecInfo.WPAEnabled)?

"e":

"d",

(Adapter->SecInfo.WPA2Enabled)?

"e":

"d",

Adapter->SecInfo.EncryptionMode,pBSSDesc->Privacy);

LEAVE();

returnindex;

}elseif(Adapter->SecInfo.WEPStatus==Wlan802_11WEPDisabled

&&!

Adapter->SecInfo.WPAEnabled

&&Adapter->SecInfo.WPA2Enabled

&&(pBSSDesc->rsnIE.IeeeHdr.ElementId==RSN_IE)

&&!

Adapter->AdhocAESEnabled

/*PrivacybitmayNOTbesetinsomeAPslikeLinkSysWRT54G

&&pBSSDesc->Privacy*/

){

/*WPA2enabled*/

printf("IsNetworkCompatible()WPA2:

index=%dwpa_ie=%#x"

"wpa2_ie=%#xWEP=%sWPA=%sWPA2=%sEncMode=%#x"

"privacy=%#x\n",

index,

pBSSDesc->wpaIE.VendHdr.ElementId,

pBSSDesc->rsnIE.IeeeHdr.ElementId,

(Adapter->SecInfo.WEPStatus==

Wlan802_11WEPEnabled)?

"e":

"d",

(Adapter->SecInfo.WPAEnabled)?

"e":

"d",

(Adapter->SecInfo.WPA2Enabled)?

"e":

"d",

Adapter->SecInfo.EncryptionMode,pBSSDesc->Privacy);

LEAVE();

returnindex;

}elseif(Adapter->SecInfo.WEPStatus==Wlan802_11WEPDisabled

&&!

Adapter->SecInfo.WPAEnabled

&&!

Adapter->SecInfo.WPA2Enabled

&&(pBSSDesc->wpaIE.VendHdr.ElementId!

=WPA_IE)

&&(pBSSDesc->rsnIE.IeeeHdr.ElementId!

=RSN_IE)

&&Adapter->AdhocAESEnabled

&&Adapter->SecInfo.EncryptionMode==CIPHER_NONE

&&pBSSDesc->Privacy){

/*Ad-hocAESenabled*/

LEAVE();

returnindex;

}elseif(Adapter->SecInfo.WEPStatus==Wlan802_11WEPDisabled

&&!

Adapter->SecInfo.WPAEnabled

Page:

3

F:

\WiFi_V2.1\src\wifi\wlan_scan.c

&&!

Adapter->SecInfo.WPA2Enabled

&&(pBSSDesc->wpaIE.VendHdr.ElementId!

=WPA_IE)

&&(pBSSDesc->rsnIE.IeeeHdr.ElementId!

=RSN_IE)

&&!

Adapter->AdhocAESEnabled

&&Adapter->SecInfo.EncryptionMode!

=CIPHER_NONE

&&pBSSDesc->Privacy){

/*dynamicWEPenabled*/

printf("IsNetworkCompatible()dynamicWEP:

index=%d"

"wpa_ie=%#xwpa2_ie=%#xEncMode=%#xprivacy=%#x\n",

index,

pBSSDesc->wpaIE.VendHdr.ElementId,

pBSSDesc->rsnIE.IeeeHdr.ElementId,

Adapter->SecInfo.EncryptionMode,pBSSDesc->Privacy);

LEAVE();

returnindex;

}

/*securitydoesn'tmatch*/

printf("IsNetworkCompatible()FAILED:

index=%dwpa_ie=%#x"

"wpa2_ie=%#xWEP=%sWPA=%sWPA2=%sEncMode=%#xprivacy=%#x\n",

index,

pBSSDesc->wpaIE.VendHdr.ElementId,

pBSSDesc->rsnIE.IeeeHdr.ElementId,

(Adapter->SecInfo.WEPStatus==

Wlan802_11WEPEnabled)?

"e":

"d",

(Adapter->SecInfo.WPAEnabled)?

"e":

"d",

(Adapter->SecInfo.WPA2Enabled)?

"e":

"d",

Adapter->SecInfo.EncryptionMode,pBSSDesc->Privacy);

LEAVE();

return-ECONNREFUSED;

}

/*modedoesn'tmatch*/

LEAVE();

return-ENETUNREACH;

}

/**

*@briefThisfunctionvalidatesaSSIDasbeingabletobeprinted

*

*@parampSsidSSIDstructuretovalidate

*

*@returnTRUEorFALSE

*/

staticBOOLEAN

ssid_valid(WLAN_802_11_SSID*pSsid)

{

intssidIdx;

for(ssidIdx=0;ssidIdxSsidLength;ssidIdx++){

if(!

isprint(pSsid->Ssid[ssidIdx])){

returnFALSE;

}

}

returnTRUE;

}

/**

*@briefPostprocessthescantableafteranewscancommandhascompleted

*

*Inspecteachentryofthescantableandtrytofindanentrythat

*matchesourcurrentassociated/joinednetworkfromthescan.If

*oneisfound,updatethestoredcopyoftheBSSDescriptorforour

*currentnetwork.

*

*Debugdumpthecurrentscantablecontentsifcompiledaccordingly.

*

Page:

4

F:

\WiFi_V2.1\src\wifi\wlan_scan.c

*@paramprivApointertowlan_privatestructure

*

*@returnvoid

*/

staticvoid

wlan_scan_process_results(wlan_private*priv)

{

wlan_adapter*Adapter=priv->adapter;

inti;

//intfoundCurrent;

//foundCurrent=FALSE;

if(Adapter->MediaConnectStatus==WlanMediaStateConnected){

Adapter->CurBssParams.BSSDescriptor.pBeaconBuf=NULL;

Adapter->CurBssParams.BSSDescriptor.beaconBufSize=0;

Adapter->CurBssParams.BSSDescriptor.beaconBufSizeMax=0;

i=FindSSIDInList(Adapter,

&Adapter->CurBssParams.BSSDescriptor.Ssid,

Adapter->CurBssParams.BSSDescriptor.MacAddress,

Adapter->InfrastructureMode);

if(i>=0){

printf("Foundcurrentssid/bssidinlist@index#%d\n",i);

/*MakeacopyofcurrentBSSIDdescriptor*/

memcpy(&Adapter->CurBssParams.BSSDescriptor,

&Adapter->ScanTable[i],

sizeof(Adapter->CurBssParams.BSSDescriptor));

}

}

for(i=0;iNumInScanTable;i++){

printf("Scan:

(%02d)%02x:

%02x:

%02x:

%02x:

%02x:

%02x,"

"RSSI[%03d],SSID[%s]\n",

i,

Adapter->ScanTable[i].MacAddress[0],

Adapter->ScanTable[i].MacAddress[1],

Adapter->ScanTable[i].MacAddress[2],

Adapter->ScanTable[i].MacAddress[3],

Adapter->ScanTable[i].MacAddress[4],

Adapter->ScanTable[i].MacAddress[5],

(s32)Adapter->ScanTable[i].Rssi,

Adapter->ScanTable[i].Ssid.Ssid);

}

}

/**

*@briefCreateachannellistforthedrivertoscanbasedonregioninfo

*

*Usethedriverregion/bandinformationtoconstructacomprehensivelist

*ofchannelstoscan.Thisroutineisusedforanyscanthatisnot

*providedaspecificchannellisttoscan.

*

*@paramprivApointertowlan_privatestructure

*@paramscanChanListOutputparameter:

Resultingchannellisttoscan

*@paramfilteredScanFlagindicatingwhetherornotaBSSIDorSSIDfilter

*isbeingsentinthecommandtofirmware.Usedto

*increasethenumber

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1