1、stm32驱动wifi88W8686WMGMR09editedF:WiFi_V2.1srcwifiwlan_scan.c#include wifi.h#include #include #include /*Local Constants*/! Approximate amount of data needed to pass a scan result back to iwlist#define MAX_SCAN_CELL_SIZE (IW_EV_ADDR_LEN + MRVDRV_MAX_SSID_LENGTH + IW_EV_UINT_LEN + IW_EV_FREQ_LEN + IW_
2、EV_QUAL_LEN + MRVDRV_MAX_SSID_LENGTH + IW_EV_PARAM_LEN + 40) /* 40 for WPAIE */! Memory needed to store a max sized Channel List TLV for a firmware scan#define CHAN_TLV_MAX_SIZE (sizeof(MrvlIEtypesHeader_t) + (MRVDRV_MAX_CHANNELS_PER_SCAN * sizeof(ChanScanParamSet_t)/! Memory needed to store a max n
3、umber/size SSID TLV for a firmware scan#define SSID_TLV_MAX_SIZE (1 * sizeof(MrvlIEtypes_SsIdParamSet_t)/! WPS TLV MAX size is MAX IE size plus 2 bytes for u16 MRVL TLV extension#define WPS_TLV_MAX_SIZE (sizeof(IEEEtypes_VendorSpecific_t) + 2)/! Maximum memory needed for a wlan_scan_cmd_config with
4、all TLVs at max#define MAX_SCAN_CFG_ALLOC (sizeof(wlan_scan_cmd_config) + sizeof(MrvlIEtypes_NumProbes_t) + CHAN_TLV_MAX_SIZE + SSID_TLV_MAX_SIZE + WPS_TLV_MAX_SIZE)/! The maximum number of channels the firmware can scan per command#define MRVDRV_MAX_CHANNELS_PER_SCAN 14/* brief Number of channels t
5、o scan per firmware scan command issuance.* Number restricted to prevent hitting the limit on the amount of scan data* returned in a single firmware scan command.*/#define MRVDRV_CHANNELS_PER_SCAN_CMD 4/! Macro to enable/disable SSID checking before storing a scan table#ifdef DISCARD_BAD_SSID#define
6、 CHECK_SSID_IS_VALID(x) ssid_valid(&bssidEntry.Ssid)Page: 1F:WiFi_V2.1srcwifiwlan_scan.c#else#define CHECK_SSID_IS_VALID(x) TRUE#endif/*Local Variables and Types*/* brief Interally used to send a configured scan cmd between driver routines*/typedef unionwlan_scan_cmd_config config; /! Scan configura
7、tion (variable length)u8 configAllocBufMAX_SCAN_CFG_ALLOC; /!ScanTableindex;/* Dont check for compatibility if roaming */if (Adapter-MediaConnectStatus = WlanMediaStateConnected)& (Adapter-InfrastructureMode = Wlan802_11Infrastructure)& (pBSSDesc-InfrastructureMode = Wlan802_11Infrastructure) LEAVE(
8、);return index;if (Adapter-wps.SessionEnable = TRUE) printf(Return success directly in WPS periodn);LEAVE();return index;if (pBSSDesc-InfrastructureMode = mode) if (Adapter-SecInfo.WEPStatus = Wlan802_11WEPDisabled& !Adapter-SecInfo.WPAEnabled& !Adapter-SecInfo.WPA2Enabled& pBSSDesc-wpaIE.VendHdr.El
9、ementId != WPA_IE& pBSSDesc-rsnIE.IeeeHdr.ElementId != RSN_IE& !Adapter-AdhocAESEnabled& Adapter-SecInfo.EncryptionMode = CIPHER_NONEPage: 2F:WiFi_V2.1srcwifiwlan_scan.c& !pBSSDesc-Privacy) /* no security */LEAVE();return index; else if (Adapter-SecInfo.WEPStatus = Wlan802_11WEPEnabled& !Adapter-Sec
10、Info.WPAEnabled& !Adapter-SecInfo.WPA2Enabled& !Adapter-AdhocAESEnabled & pBSSDesc-Privacy) /* static WEP enabled */LEAVE();return index; else if (Adapter-SecInfo.WEPStatus = Wlan802_11WEPDisabled& Adapter-SecInfo.WPAEnabled& !Adapter-SecInfo.WPA2Enabled& (pBSSDesc-wpaIE.VendHdr.ElementId = WPA_IE)&
11、 !Adapter-AdhocAESEnabled/* Privacy bit may NOT be set in some APs like LinkSys WRT54G& pBSSDesc-Privacy */) /* WPA enabled */printf(IsNetworkCompatible() WPA: index=%d wpa_ie=%#x wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s EncMode=%#x privacy=%#xn,index,pBSSDesc-wpaIE.VendHdr.ElementId,pBSSDesc-rsnIE.IeeeHdr
12、.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 index; else if (Adapter-SecInfo.WEPStatus = Wlan802_11WEPDisabled& !Adapter-SecInfo.WPAEnab
13、led& Adapter-SecInfo.WPA2Enabled& (pBSSDesc-rsnIE.IeeeHdr.ElementId = RSN_IE)& !Adapter-AdhocAESEnabled/* Privacy bit may NOT be set in some APs like LinkSys WRT54G& pBSSDesc-Privacy */) /* WPA2 enabled */printf( IsNetworkCompatible() WPA2: index=%d wpa_ie=%#x wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s EncMo
14、de=%#x privacy=%#xn,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 index; els
15、e 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& pBSSDesc-Privacy) /*
16、Ad-hoc AES enabled */LEAVE();return index; else if (Adapter-SecInfo.WEPStatus = Wlan802_11WEPDisabled& !Adapter-SecInfo.WPAEnabledPage: 3F:WiFi_V2.1srcwifiwlan_scan.c& !Adapter-SecInfo.WPA2Enabled& (pBSSDesc-wpaIE.VendHdr.ElementId != WPA_IE)& (pBSSDesc-rsnIE.IeeeHdr.ElementId != RSN_IE)& !Adapter-A
17、dhocAESEnabled& Adapter-SecInfo.EncryptionMode != CIPHER_NONE& pBSSDesc-Privacy) /* dynamic WEP enabled */printf( IsNetworkCompatible() dynamic WEP: index=%d wpa_ie=%#x wpa2_ie=%#x EncMode=%#x privacy=%#xn,index,pBSSDesc-wpaIE.VendHdr.ElementId,pBSSDesc-rsnIE.IeeeHdr.ElementId,Adapter-SecInfo.Encryp
18、tionMode, pBSSDesc-Privacy);LEAVE();return index;/* security doesnt match */printf( IsNetworkCompatible() FAILED: index=%d wpa_ie=%#x wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s EncMode=%#x privacy=%#xn,index,pBSSDesc-wpaIE.VendHdr.ElementId,pBSSDesc-rsnIE.IeeeHdr.ElementId,(Adapter-SecInfo.WEPStatus =Wlan802
19、_11WEPEnabled) ? e : d,(Adapter-SecInfo.WPAEnabled) ? e : d,(Adapter-SecInfo.WPA2Enabled) ? e : d,Adapter-SecInfo.EncryptionMode, pBSSDesc-Privacy);LEAVE();return -ECONNREFUSED;/* mode doesnt match */LEAVE();return -ENETUNREACH;/* brief This function validates a SSID as being able to be printed* par
20、am pSsid SSID structure to validate* return TRUE or FALSE*/static BOOLEANssid_valid(WLAN_802_11_SSID * pSsid)int ssidIdx;for (ssidIdx = 0; ssidIdx SsidLength; ssidIdx+) if (!isprint(pSsid-SsidssidIdx) return FALSE;return TRUE;/* brief Post process the scan table after a new scan command has complete
21、d* Inspect each entry of the scan table and try to find an entry that* matches our current associated/joined network from the scan. If* one is found, update the stored copy of the BSSDescriptor for our* current network.* Debug dump the current scan table contents if compiled accordingly.*Page: 4F:Wi
22、Fi_V2.1srcwifiwlan_scan.c* param priv A pointer to wlan_private structure* return void*/static voidwlan_scan_process_results(wlan_private * priv)wlan_adapter *Adapter = priv-adapter;int i;/int foundCurrent;/foundCurrent = FALSE;if (Adapter-MediaConnectStatus = WlanMediaStateConnected) Adapter-CurBss
23、Params.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)
24、 printf(Found current ssid/bssid in list index #%dn, i);/* Make a copy of current BSSID descriptor */memcpy(&Adapter-CurBssParams.BSSDescriptor,&Adapter-ScanTablei,sizeof(Adapter-CurBssParams.BSSDescriptor);for (i = 0; i NumInScanTable; i+) printf( Scan:(%02d) %02x:%02x:%02x:%02x:%02x:%02x, RSSI%03d
25、, SSID%sn,i,Adapter-ScanTablei.MacAddress0,Adapter-ScanTablei.MacAddress1,Adapter-ScanTablei.MacAddress2,Adapter-ScanTablei.MacAddress3,Adapter-ScanTablei.MacAddress4,Adapter-ScanTablei.MacAddress5,(s32) Adapter-ScanTablei.Rssi,Adapter-ScanTablei.Ssid.Ssid);/* brief Create a channel list for the dri
26、ver to scan based on region info* Use the driver region/band information to construct a comprehensive list* of channels to scan. This routine is used for any scan that is not* provided a specific channel list to scan.* param priv A pointer to wlan_private structure* param scanChanList Output parameter: Resulting channel list to scan* param filteredScan Flag indicating whether or not a BSSID or SSID filter* is being sent in the command to firmware. Used to* increase the number
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1