}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