/* The maximum number of channels the firmware can scan per command */ #define MWIFIEX_MAX_CHANNELS_PER_SPECIFIC_SCAN 14
#define MWIFIEX_DEF_CHANNELS_PER_SCAN_CMD 4
/* Memory needed to store a max sized Channel List TLV for a firmware scan */ #define CHAN_TLV_MAX_SIZE (sizeof(struct mwifiex_ie_types_header) \
+ (MWIFIEX_MAX_CHANNELS_PER_SPECIFIC_SCAN \
*sizeof(struct mwifiex_chan_scan_param_set)))
/* Memory needed to store supported rate */ #define RATE_TLV_MAX_SIZE (sizeof(struct mwifiex_ie_types_rates_param_set) \
+ HOSTCMD_SUPPORTED_RATES)
/* Memory needed to store a max number/size WildCard SSID TLV for a firmware
scan */ #define WILDCARD_SSID_TLV_MAX_SIZE \
(MWIFIEX_MAX_SSID_LIST_LENGTH * \
(sizeof(struct mwifiex_ie_types_wildcard_ssid_params) \
+ IEEE80211_MAX_SSID_LEN))
/* Maximum memory needed for a mwifiex_scan_cmd_config with all TLVs at max */ #define MAX_SCAN_CFG_ALLOC (sizeof(struct mwifiex_scan_cmd_config) \
+ sizeof(struct mwifiex_ie_types_num_probes) \
+ sizeof(struct mwifiex_ie_types_htcap) \
+ CHAN_TLV_MAX_SIZE \
+ RATE_TLV_MAX_SIZE \
+ WILDCARD_SSID_TLV_MAX_SIZE)
union mwifiex_scan_cmd_config_tlv { /* Scan configuration (variable length) */ struct mwifiex_scan_cmd_config config; /* Max allocated block */
u8 config_alloc_buf[MAX_SCAN_CFG_ALLOC];
};
/* * This function parses a given IE for a given OUI. * * This is used to parse a WPA/RSN IE to find if it has * a given oui in PTK.
*/ static u8
mwifiex_search_oui_in_ie(struct ie_body *iebody, u8 *oui)
{
u8 count;
count = iebody->ptk_cnt[0];
/* There could be multiple OUIs for PTK hence 1) Take the length. 2) Check all the OUIs for AES.
3) If one of them is AES then pass success. */ while (count) { if (!memcmp(iebody->ptk_body, oui, sizeof(iebody->ptk_body))) return MWIFIEX_OUI_PRESENT;
pr_debug("info: %s: OUI is not found in PTK\n", __func__); return MWIFIEX_OUI_NOT_PRESENT;
}
/* * This function checks if a given OUI is present in a RSN IE. * * The function first checks if a RSN IE is present or not in the * BSS descriptor. It tries to locate the OUI only if such an IE is * present.
*/ static u8
mwifiex_is_rsn_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher)
{
u8 *oui; struct ie_body *iebody;
u8 ret = MWIFIEX_OUI_NOT_PRESENT;
if (has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN)) {
iebody = (struct ie_body *)
(((u8 *) bss_desc->bcn_rsn_ie->data) +
RSN_GTK_OUI_OFFSET);
oui = &mwifiex_rsn_oui[cipher][0];
ret = mwifiex_search_oui_in_ie(iebody, oui); if (ret) return ret;
} return ret;
}
/* * This function checks if a given OUI is present in a WPA IE. * * The function first checks if a WPA IE is present or not in the * BSS descriptor. It tries to locate the OUI only if such an IE is * present.
*/ static u8
mwifiex_is_wpa_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher)
{
u8 *oui; struct ie_body *iebody;
u8 ret = MWIFIEX_OUI_NOT_PRESENT;
if (has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC)) {
iebody = (struct ie_body *)((u8 *)bss_desc->bcn_wpa_ie->data +
WPA_GTK_OUI_OFFSET);
oui = &mwifiex_wpa_oui[cipher][0];
ret = mwifiex_search_oui_in_ie(iebody, oui); if (ret) return ret;
} return ret;
}
/* * This function checks if wapi is enabled in driver and scanned network is * compatible with it.
*/ staticbool
mwifiex_is_bss_wapi(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc)
{ if (priv->sec_info.wapi_enabled &&
has_ieee_hdr(bss_desc->bcn_wapi_ie, WLAN_EID_BSS_AC_ACCESS_DELAY)) returntrue; returnfalse;
}
/* * This function checks if driver is configured with no security mode and * scanned network is compatible with it.
*/ staticbool
mwifiex_is_bss_no_sec(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc)
{ if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
!priv->sec_info.wpa2_enabled &&
!has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC) &&
!has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN) &&
!priv->sec_info.encryption_mode && !bss_desc->privacy) { returntrue;
} returnfalse;
}
/* * This function checks if static WEP is enabled in driver and scanned network * is compatible with it.
*/ staticbool
mwifiex_is_bss_static_wep(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc)
{ if (priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
!priv->sec_info.wpa2_enabled && bss_desc->privacy) { returntrue;
} returnfalse;
}
/* * This function checks if wpa is enabled in driver and scanned network is * compatible with it.
*/ staticbool
mwifiex_is_bss_wpa(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc)
{ if (!priv->sec_info.wep_enabled && priv->sec_info.wpa_enabled &&
!priv->sec_info.wpa2_enabled &&
has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC) /* * Privacy bit may NOT be set in some APs like * LinkSys WRT54G && bss_desc->privacy
*/
) {
dbg_security_flags(INFO, "WPA", priv, bss_desc); returntrue;
} returnfalse;
}
/* * This function checks if wpa2 is enabled in driver and scanned network is * compatible with it.
*/ staticbool
mwifiex_is_bss_wpa2(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc)
{ if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
priv->sec_info.wpa2_enabled &&
has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN)) { /* * Privacy bit may NOT be set in some APs like * LinkSys WRT54G && bss_desc->privacy
*/
dbg_security_flags(INFO, "WAP2", priv, bss_desc); returntrue;
} returnfalse;
}
/* * This function checks if adhoc AES is enabled in driver and scanned network is * compatible with it.
*/ staticbool
mwifiex_is_bss_adhoc_aes(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc)
{ if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
!priv->sec_info.wpa2_enabled &&
!has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC) &&
!has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN) &&
!priv->sec_info.encryption_mode && bss_desc->privacy) { returntrue;
} returnfalse;
}
/* * This function checks if dynamic WEP is enabled in driver and scanned network * is compatible with it.
*/ staticbool
mwifiex_is_bss_dynamic_wep(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc)
{ if (!priv->sec_info.wep_enabled && !priv->sec_info.wpa_enabled &&
!priv->sec_info.wpa2_enabled &&
!has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC) &&
!has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN) &&
priv->sec_info.encryption_mode && bss_desc->privacy) {
dbg_security_flags(INFO, "dynamic", priv, bss_desc); returntrue;
} returnfalse;
}
/* * This function checks if a scanned network is compatible with the driver * settings. * * WEP WPA WPA2 ad-hoc encrypt Network * enabled enabled enabled AES mode Privacy WPA WPA2 Compatible * 0 0 0 0 NONE 0 0 0 yes No security * 0 1 0 0 x 1x 1 x yes WPA (disable * HT if no AES) * 0 0 1 0 x 1x x 1 yes WPA2 (disable * HT if no AES) * 0 0 0 1 NONE 1 0 0 yes Ad-hoc AES * 1 0 0 0 NONE 1 0 0 yes Static WEP * (disable HT) * 0 0 0 0 !=NONE 1 0 0 yes Dynamic WEP * * Compatibility is not matched while roaming, except for mode.
*/ static s32
mwifiex_is_network_compatible(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc, u32 mode)
{ struct mwifiex_adapter *adapter = priv->adapter;
bss_desc->disable_11n = false;
/* Don't check for compatibility if roaming */ if (priv->media_connected &&
(priv->bss_mode == NL80211_IFTYPE_STATION) &&
(bss_desc->bss_mode == NL80211_IFTYPE_STATION)) return 0;
if (priv->wps.session_enable) {
mwifiex_dbg(adapter, IOCTL, "info: return success directly in WPS period\n"); return 0;
}
if (bss_desc->chan_sw_ie_present) {
mwifiex_dbg(adapter, INFO, "Don't connect to AP with WLAN_EID_CHANNEL_SWITCH\n"); return -1;
}
if (mwifiex_is_bss_wapi(priv, bss_desc)) {
mwifiex_dbg(adapter, INFO, "info: return success for WAPI AP\n"); return 0;
}
/* * This function creates a channel list for the driver to scan, based * on region/band information. * * This routine is used for any scan that is not provided with a * specific channel list to scan.
*/ staticint
mwifiex_scan_create_channel_list(struct mwifiex_private *priv, conststruct mwifiex_user_scan_cfg
*user_scan_in, struct mwifiex_chan_scan_param_set
*scan_chan_list,
u8 filtered_scan)
{ enum nl80211_band band; struct ieee80211_supported_band *sband; struct ieee80211_channel *ch; struct mwifiex_adapter *adapter = priv->adapter; int chan_idx = 0, i;
for (band = 0; (band < NUM_NL80211_BANDS) ; band++) {
if (!priv->wdev.wiphy->bands[band]) continue;
sband = priv->wdev.wiphy->bands[band];
for (i = 0; (i < sband->n_channels) ; i++) {
ch = &sband->channels[i]; if (ch->flags & IEEE80211_CHAN_DISABLED) continue;
scan_chan_list[chan_idx].radio_type = band;
/* * This function constructs and sends multiple scan config commands to * the firmware. * * Previous routines in the code flow have created a scan command configuration * with any requested TLVs. This function splits the channel TLV into maximum * channels supported per scan lists and sends the portion of the channel TLV, * along with the other TLVs, to the firmware.
*/ staticint
mwifiex_scan_channel_list(struct mwifiex_private *priv,
u32 max_chan_per_scan, u8 filtered_scan, struct mwifiex_scan_cmd_config *scan_cfg_out, struct mwifiex_ie_types_chan_list_param_set
*chan_tlv_out, struct mwifiex_chan_scan_param_set *scan_chan_list)
{ struct mwifiex_adapter *adapter = priv->adapter; int ret = 0; struct mwifiex_chan_scan_param_set *tmp_chan_list;
u32 tlv_idx, rates_size, cmd_no;
u32 total_scan_time;
u32 done_early;
u8 radio_type;
/* Set the temp channel struct pointer to the start of the desired
list */
tmp_chan_list = scan_chan_list;
/* Loop through the desired channel list, sending a new firmware scan commands for each max_chan_per_scan channels (or for 1,6,11
individually if configured accordingly) */ while (tmp_chan_list->chan_number) {
/* * Construct the Channel TLV for the scan command. Continue to * insert channel TLVs until: * - the tlv_idx hits the maximum configured per scan command * - the next channel to insert is 0 (end of desired channel * list) * - done_early is set (controlling individual scanning of * 1,6,11)
*/ while (tlv_idx < max_chan_per_scan &&
tmp_chan_list->chan_number && !done_early) {
if (tmp_chan_list->chan_number == priv->csa_chan) {
tmp_chan_list++; continue;
}
/* Copy the current channel TLV to the command being
prepared */
memcpy(&chan_tlv_out->chan_scan_param[tlv_idx],
tmp_chan_list, sizeof(*chan_tlv_out->chan_scan_param));
/* Increment the TLV header length by the size
appended */
le16_unaligned_add_cpu(&chan_tlv_out->header.len, sizeof(*chan_tlv_out->chan_scan_param));
/* * The tlv buffer length is set to the number of bytes * of the between the channel tlv pointer and the start * of the tlv buffer. This compensates for any TLVs * that were appended before the channel list.
*/
scan_cfg_out->tlv_buf_len = (u32) ((u8 *) chan_tlv_out -
scan_cfg_out->tlv_buf);
/* Add the size of the channel tlv header and the data
length */
scan_cfg_out->tlv_buf_len +=
(sizeof(chan_tlv_out->header)
+ le16_to_cpu(chan_tlv_out->header.len));
/* Increment the index to the channel tlv we are
constructing */
tlv_idx++;
/* Count the total scan time per command */
total_scan_time +=
le16_to_cpu(tmp_chan_list->max_scan_time);
done_early = false;
/* Stop the loop if the *current* channel is in the 1,6,11 set and we are not filtering on a BSSID
or SSID. */ if (!filtered_scan &&
(tmp_chan_list->chan_number == 1 ||
tmp_chan_list->chan_number == 6 ||
tmp_chan_list->chan_number == 11))
done_early = true;
/* Increment the tmp pointer to the next channel to
be scanned */
tmp_chan_list++;
/* Stop the loop if the *next* channel is in the 1,6,11 set. This will cause it to be the only channel
scanned on the next interation */ if (!filtered_scan &&
(tmp_chan_list->chan_number == 1 ||
tmp_chan_list->chan_number == 6 ||
tmp_chan_list->chan_number == 11))
done_early = true;
}
/* The total scan time should be less than scan command timeout
value */ if (total_scan_time > MWIFIEX_MAX_TOTAL_SCAN_TIME) {
mwifiex_dbg(priv->adapter, ERROR, "total scan time %dms\t" "is over limit (%dms), scan skipped\n",
total_scan_time,
MWIFIEX_MAX_TOTAL_SCAN_TIME);
ret = -1; break;
}
/* Send the scan command to the firmware with the specified
cfg */ if (priv->adapter->ext_scan)
cmd_no = HostCmd_CMD_802_11_SCAN_EXT; else
cmd_no = HostCmd_CMD_802_11_SCAN;
ret = mwifiex_send_cmd(priv, cmd_no, HostCmd_ACT_GEN_SET,
0, scan_cfg_out, false);
/* rate IE is updated per scan command but same starting * pointer is used each time so that rate IE from earlier * scan_cfg_out->buf is overwritten with new one.
*/
scan_cfg_out->tlv_buf_len -= sizeof(struct mwifiex_ie_types_header) + rates_size;
if (ret) {
mwifiex_cancel_pending_scan_cmd(adapter); break;
}
}
if (ret) return -1;
return 0;
}
/* * This function constructs a scan command configuration structure to use * in scan commands. * * Application layer or other functions can invoke network scanning * with a scan configuration supplied in a user scan configuration structure. * This structure is used as the basis of one or many scan command configuration * commands that are sent to the command processing module and eventually to the * firmware. * * This function creates a scan command configuration structure based on the * following user supplied parameters (if present): * - SSID filter * - BSSID filter * - Number of Probes to be sent * - Channel list * * If the SSID or BSSID filter is not present, the filter is disabled/cleared. * If the number of probes is not set, adapter default setting is used.
*/ staticvoid
mwifiex_config_scan(struct mwifiex_private *priv, conststruct mwifiex_user_scan_cfg *user_scan_in, struct mwifiex_scan_cmd_config *scan_cfg_out, struct mwifiex_ie_types_chan_list_param_set **chan_list_out, struct mwifiex_chan_scan_param_set *scan_chan_list,
u8 *max_chan_per_scan, u8 *filtered_scan,
u8 *scan_current_only)
{ struct mwifiex_adapter *adapter = priv->adapter; struct mwifiex_ie_types_num_probes *num_probes_tlv; struct mwifiex_ie_types_scan_chan_gap *chan_gap_tlv; struct mwifiex_ie_types_random_mac *random_mac_tlv; struct mwifiex_ie_types_wildcard_ssid_params *wildcard_ssid_tlv; struct mwifiex_ie_types_bssid_list *bssid_tlv;
u8 *tlv_pos;
u32 num_probes;
u32 ssid_len;
u32 chan_idx;
u32 scan_type;
u16 scan_dur;
u8 channel;
u8 radio_type; int i;
u8 ssid_filter; struct mwifiex_ie_types_htcap *ht_cap; struct mwifiex_ie_types_bss_mode *bss_mode;
/* The tlv_buf_len is calculated for each scan command. The TLVs added in this routine will be preserved since the routine that sends the command will append channelTLVs at *chan_list_out. The difference between the *chan_list_out and the tlv_buf start will be used to
calculate the size of anything we add in this routine. */
scan_cfg_out->tlv_buf_len = 0;
/* Running tlv pointer. Assigned to chan_list_out at end of function so later routines know where channels can be added to the command
buf */
tlv_pos = scan_cfg_out->tlv_buf;
/* Initialize the scan as un-filtered; the flag is later set to TRUE
below if a SSID or BSSID filter is sent in the command */
*filtered_scan = false;
/* Initialize the scan as not being only on the current channel. If the channel list is customized, only contains one channel, and is
the active channel, this is set true and data flow is not halted. */
*scan_current_only = false;
if (user_scan_in) {
u8 tmpaddr[ETH_ALEN];
/* Default the ssid_filter flag to TRUE, set false under certain wildcard conditions and qualified by the existence
of an SSID list before marking the scan as filtered */
ssid_filter = true;
/* Set the BSS type scan filter, use Adapter setting if
unset */
scan_cfg_out->bss_mode =
(u8)(user_scan_in->bss_mode ?: adapter->scan_mode);
/* Set the number of probes to send, use Adapter setting
if unset */
num_probes = user_scan_in->num_probes ?: adapter->scan_probes;
/* * Set the BSSID filter to the incoming configuration, * if non-zero. If not set, it will remain disabled * (all zeros).
*/
memcpy(scan_cfg_out->specific_bssid,
user_scan_in->specific_bssid, sizeof(scan_cfg_out->specific_bssid));
mwifiex_dbg(adapter, INFO, "info: scan: ssid[%d]: %s, %d\n",
i, wildcard_ssid_tlv->ssid,
wildcard_ssid_tlv->max_ssid_length);
/* Empty wildcard ssid with a maxlen will match many or potentially all SSIDs (maxlen == 32), therefore do not treat the scan as
filtered. */ if (!ssid_len && wildcard_ssid_tlv->max_ssid_length)
ssid_filter = false;
}
/* * The default number of channels sent in the command is low to * ensure the response buffer from the firmware does not * truncate scan results. That is not an issue with an SSID * or BSSID filter applied to the scan results in the firmware.
*/
memcpy(tmpaddr, scan_cfg_out->specific_bssid, ETH_ALEN); if ((i && ssid_filter) ||
!is_zero_ether_addr(tmpaddr))
*filtered_scan = true;
if (user_scan_in->scan_chan_gap) {
mwifiex_dbg(adapter, INFO, "info: scan: channel gap = %d\n",
user_scan_in->scan_chan_gap);
*max_chan_per_scan =
MWIFIEX_MAX_CHANNELS_PER_SPECIFIC_SCAN;
/* * If a specific BSSID or SSID is used, the number of channels in the * scan command will be increased to the absolute maximum.
*/ if (*filtered_scan) {
*max_chan_per_scan = MWIFIEX_MAX_CHANNELS_PER_SPECIFIC_SCAN;
} else { if (!priv->media_connected)
*max_chan_per_scan = MWIFIEX_DEF_CHANNELS_PER_SCAN_CMD; else
*max_chan_per_scan =
MWIFIEX_DEF_CHANNELS_PER_SCAN_CMD / 2;
}
/* Append vendor specific IE TLV */
mwifiex_cmd_append_vsie_tlv(priv, MWIFIEX_VSIE_MASK_SCAN, &tlv_pos);
/* * Set the output for the channel TLV to the address in the tlv buffer * past any TLVs that were added in this function (SSID, num_probes). * Channel TLVs will be added past this for each scan command, * preserving the TLVs that were previously added.
*/
*chan_list_out =
(struct mwifiex_ie_types_chan_list_param_set *) tlv_pos;
if (user_scan_in && user_scan_in->chan_list[0].chan_number) {
mwifiex_dbg(adapter, INFO, "info: Scan: Using supplied channel list\n");
/* Check if we are only scanning the current channel */ if ((chan_idx == 1) &&
(user_scan_in->chan_list[0].chan_number ==
priv->curr_bss_params.bss_descriptor.channel)) {
*scan_current_only = true;
mwifiex_dbg(adapter, INFO, "info: Scan: Scanning current channel only\n");
}
} else {
mwifiex_dbg(adapter, INFO, "info: Scan: Creating full region channel list\n");
mwifiex_scan_create_channel_list(priv, user_scan_in,
scan_chan_list,
*filtered_scan);
}
}
/* * This function inspects the scan response buffer for pointers to * expected TLVs. * * TLVs can be included at the end of the scan response BSS information. * * Data in the buffer is parsed pointers to TLVs that can potentially * be passed back in the response.
*/ staticvoid
mwifiex_ret_802_11_scan_get_tlv_ptrs(struct mwifiex_adapter *adapter, struct mwifiex_ie_types_data *tlv,
u32 tlv_buf_size, u32 req_tlv_type, struct mwifiex_ie_types_data **tlv_data)
{ struct mwifiex_ie_types_data *current_tlv;
u32 tlv_buf_left;
u32 tlv_type;
u32 tlv_len;
case WLAN_EID_CF_PARAMS: if (total_ie_len < sizeof(*cf_param_set)) return -EINVAL;
cf_param_set =
(struct ieee_types_cf_param_set *) current_ptr;
memcpy(&bss_entry->ss_param_set.cf_param_set,
cf_param_set, sizeof(struct ieee_types_cf_param_set)); break;
case WLAN_EID_IBSS_PARAMS: if (total_ie_len < sizeof(*ibss_param_set)) return -EINVAL;
ibss_param_set =
(struct ieee_types_ibss_param_set *)
current_ptr;
memcpy(&bss_entry->ss_param_set.ibss_param_set,
ibss_param_set, sizeof(struct ieee_types_ibss_param_set)); break;
case WLAN_EID_ERP_INFO: if (!element_len) return -EINVAL;
bss_entry->erp_flags = *(current_ptr + 2); break;
case WLAN_EID_PWR_CONSTRAINT: if (!element_len) return -EINVAL;
bss_entry->local_constraint = *(current_ptr + 2);
bss_entry->sensed_11h = true; break;
case WLAN_EID_CHANNEL_SWITCH:
bss_entry->chan_sw_ie_present = true;
fallthrough; case WLAN_EID_PWR_CAPABILITY: case WLAN_EID_TPC_REPORT: case WLAN_EID_QUIET:
bss_entry->sensed_11h = true; break;
case WLAN_EID_EXT_SUPP_RATES: /* * Only process extended supported rate * if data rate is already found. * Data rate IE should come before * extended supported rate IE
*/ if (found_data_rate_ie) { if ((element_len + rate_size) >
MWIFIEX_SUPPORTED_RATES)
bytes_to_copy =
(MWIFIEX_SUPPORTED_RATES -
rate_size); else
bytes_to_copy = element_len;
/* * This function converts radio type scan parameter to a band configuration * to be used in join command.
*/ static u8
mwifiex_radio_type_to_band(u8 radio_type)
{ switch (radio_type) { case HostCmd_SCAN_RADIO_TYPE_A: return BAND_A; case HostCmd_SCAN_RADIO_TYPE_BG: default: return BAND_G;
}
}
/* * This is an internal function used to start a scan based on an input * configuration. * * This uses the input user scan configuration information when provided in * order to send the appropriate scan commands to firmware to populate or * update the internal driver scan table.
*/ int mwifiex_scan_networks(struct mwifiex_private *priv, conststruct mwifiex_user_scan_cfg *user_scan_in)
{ int ret; struct mwifiex_adapter *adapter = priv->adapter; struct cmd_ctrl_node *cmd_node; union mwifiex_scan_cmd_config_tlv *scan_cfg_out; struct mwifiex_ie_types_chan_list_param_set *chan_list_out; struct mwifiex_chan_scan_param_set *scan_chan_list;
u8 filtered_scan;
u8 scan_current_chan_only;
u8 max_chan_per_scan;
if (adapter->scan_processing) {
mwifiex_dbg(adapter, WARN, "cmd: Scan already in process...\n"); return -EBUSY;
}
if (priv->scan_block) {
mwifiex_dbg(adapter, WARN, "cmd: Scan is blocked during association...\n"); return -EBUSY;
}
if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags) ||
test_bit(MWIFIEX_IS_CMD_TIMEDOUT, &adapter->work_flags)) {
mwifiex_dbg(adapter, ERROR, "Ignore scan. Card removed or firmware in bad state\n"); return -EFAULT;
}
ret = mwifiex_scan_channel_list(priv, max_chan_per_scan, filtered_scan,
&scan_cfg_out->config, chan_list_out,
scan_chan_list);
/* Get scan command from scan_pending_q and put to cmd_pending_q */ if (!ret) {
spin_lock_bh(&adapter->scan_pending_q_lock); if (!list_empty(&adapter->scan_pending_q)) {
cmd_node = list_first_entry(&adapter->scan_pending_q, struct cmd_ctrl_node, list);
list_del(&cmd_node->list);
spin_unlock_bh(&adapter->scan_pending_q_lock);
mwifiex_insert_cmd_to_pending_q(adapter, cmd_node);
queue_work(adapter->workqueue, &adapter->main_work);
/* * This function prepares a scan command to be sent to the firmware. * * This uses the scan command configuration sent to the command processing * module in command preparation stage to configure a scan command structure * to send to firmware. * * The fixed fields specifying the BSS type and BSSID filters as well as a * variable number/length of TLVs are sent in the command to firmware. * * Preparation also includes - * - Setting command ID, and proper size * - Ensuring correct endian-ness
*/ int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd, struct mwifiex_scan_cmd_config *scan_cfg)
{ struct host_cmd_ds_802_11_scan *scan_cmd = &cmd->params.scan;
/* Set fixed field variables in scan command */
scan_cmd->bss_mode = scan_cfg->bss_mode;
memcpy(scan_cmd->bssid, scan_cfg->specific_bssid, sizeof(scan_cmd->bssid));
memcpy(scan_cmd->tlv_buffer, scan_cfg->tlv_buf, scan_cfg->tlv_buf_len);
/* Size is equal to the sizeof(fixed portions) + the TLV len + header */
cmd->size = cpu_to_le16((u16) (sizeof(scan_cmd->bss_mode)
+ sizeof(scan_cmd->bssid)
+ scan_cfg->tlv_buf_len + S_DS_GEN));
return 0;
}
/* * This function checks compatibility of requested network with current * driver settings.
*/ int mwifiex_check_network_compatibility(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc)
{ int ret = -1;
if (!bss_desc) return -1;
if ((mwifiex_get_cfp(priv, (u8) bss_desc->bss_band,
(u16) bss_desc->channel, 0))) { switch (priv->bss_mode) { case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_ADHOC:
ret = mwifiex_is_network_compatible(priv, bss_desc,
priv->bss_mode); if (ret)
mwifiex_dbg(priv->adapter, ERROR, "Incompatible network settings\n"); break; default:
ret = 0;
}
}
return ret;
}
/* This function checks if SSID string contains all zeroes or length is zero */ staticbool mwifiex_is_hidden_ssid(struct cfg80211_ssid *ssid)
{ int idx;
for (idx = 0; idx < ssid->ssid_len; idx++) { if (ssid->ssid[idx]) returnfalse;
}
returntrue;
}
/* This function checks if any hidden SSID found in passive scan channels * and save those channels for specific SSID active scan
*/ staticint mwifiex_save_hidden_ssid_channels(struct mwifiex_private *priv, struct cfg80211_bss *bss)
{ struct mwifiex_bssdescriptor *bss_desc; int ret; int chid;
/* Allocate and fill new bss descriptor */
bss_desc = kzalloc(sizeof(*bss_desc), GFP_KERNEL); if (!bss_desc) return -ENOMEM;
ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc); if (ret) goto done;
if (mwifiex_is_hidden_ssid(&bss_desc->ssid)) {
mwifiex_dbg(priv->adapter, INFO, "found hidden SSID\n"); for (chid = 0 ; chid < MWIFIEX_USER_SCAN_CHAN_MAX; chid++) { if (priv->hidden_chan[chid].chan_number ==
bss->channel->hw_value) break;
done: /* beacon_ie buffer was allocated in function * mwifiex_fill_new_bss_desc(). Free it now.
*/
kfree(bss_desc->beacon_buf);
kfree(bss_desc); return 0;
}
/* Allocate and fill new bss descriptor */
bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor), GFP_KERNEL); if (!bss_desc) return -ENOMEM;
ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc); if (ret) goto done;
ret = mwifiex_check_network_compatibility(priv, bss_desc); if (ret) goto done;
spin_lock_bh(&priv->curr_bcn_buf_lock); /* Make a copy of current BSSID descriptor */
memcpy(&priv->curr_bss_params.bss_descriptor, bss_desc, sizeof(priv->curr_bss_params.bss_descriptor));
/* The contents of beacon_ie will be copied to its own buffer * in mwifiex_save_curr_bcn()
*/
mwifiex_save_curr_bcn(priv);
spin_unlock_bh(&priv->curr_bcn_buf_lock);
done: /* beacon_ie buffer was allocated in function * mwifiex_fill_new_bss_desc(). Free it now.
*/
kfree(bss_desc->beacon_buf);
kfree(bss_desc); return 0;
}
/* Rest of the current buffer are IE's */
ie_buf = current_ptr;
ie_len = curr_bcn_bytes;
mwifiex_dbg(adapter, INFO, "info: InterpretIE: IELength for this AP = %d\n",
curr_bcn_bytes);
while (curr_bcn_bytes >= sizeof(struct ieee_types_header)) {
u8 element_id, element_len;
/* This function checks if any hidden SSID found in passive scan channels * and do specific SSID active scan for those channels
*/ staticint
mwifiex_active_scan_req_for_passive_chan(struct mwifiex_private *priv)
{ int ret; struct mwifiex_adapter *adapter = priv->adapter;
u8 id = 0; struct mwifiex_user_scan_cfg *user_scan_cfg;
if (!priv->hidden_chan[0].chan_number) {
mwifiex_dbg(adapter, INFO, "No BSS with hidden SSID found on DFS channels\n"); return 0;
}
user_scan_cfg = kzalloc(sizeof(*user_scan_cfg), GFP_KERNEL);
if (!user_scan_cfg) return -ENOMEM;
for (id = 0; id < MWIFIEX_USER_SCAN_CHAN_MAX; id++) { if (!priv->hidden_chan[id].chan_number) break;
memcpy(&user_scan_cfg->chan_list[id],
&priv->hidden_chan[id], sizeof(struct mwifiex_user_scan_chan));
}
if (scan_rsp->number_of_sets > MWIFIEX_MAX_AP) {
mwifiex_dbg(adapter, ERROR, "SCAN_RESP: too many AP returned (%d)\n",
scan_rsp->number_of_sets);
ret = -1; goto check_next_scan;
}
mwifiex_dbg(adapter, INFO, "info: SCAN_RESP: returned %d APs before parsing\n",
scan_rsp->number_of_sets);
bss_info = scan_rsp->bss_desc_and_tlv_buffer;
/* * The size of the TLV buffer is equal to the entire command response * size (scan_resp_size) minus the fixed fields (sizeof()'s), the * BSS Descriptions (bss_descript_size as bytesLef) and the command * response header (S_DS_GEN)
*/
tlv_buf_size = scan_resp_size - (bytes_left
+ sizeof(scan_rsp->bss_descript_size)
+ sizeof(scan_rsp->number_of_sets)
+ S_DS_GEN);
/* Search the TLV buffer space in the scan response for any valid
TLVs */
mwifiex_ret_802_11_scan_get_tlv_ptrs(adapter, tlv_data, tlv_buf_size,
TLV_TYPE_TSFTIMESTAMP,
(struct mwifiex_ie_types_data **)
&tsf_tlv);
/* Search the TLV buffer space in the scan response for any valid
TLVs */
mwifiex_ret_802_11_scan_get_tlv_ptrs(adapter, tlv_data, tlv_buf_size,
TLV_TYPE_CHANNELBANDLIST,
(struct mwifiex_ie_types_data **)
&chan_band_tlv);
#ifdef CONFIG_PM if (priv->wdev.wiphy->wowlan_config)
nd_config = priv->wdev.wiphy->wowlan_config->nd_config; #endif
if (nd_config) {
adapter->nd_info =
kzalloc(struct_size(adapter->nd_info, matches,
scan_rsp->number_of_sets),
GFP_ATOMIC);
if (adapter->nd_info)
adapter->nd_info->n_matches = scan_rsp->number_of_sets;
}
for (idx = 0; idx < scan_rsp->number_of_sets && bytes_left; idx++) { /* * If the TSF TLV was appended to the scan results, save this * entry's TSF value in the fw_tsf field. It is the firmware's * TSF value at the time the beacon or probe response was * received.
*/ if (tsf_tlv)
memcpy(&fw_tsf, &tsf_tlv->tsf_data[idx * TSF_DATA_SIZE], sizeof(fw_tsf));
/* * This function prepares an extended scan command to be sent to the firmware * * This uses the scan command configuration sent to the command processing * module in command preparation stage to configure a extended scan command * structure to send to firmware.
*/ int mwifiex_cmd_802_11_scan_ext(struct mwifiex_private *priv,
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5
¤ Dauer der Verarbeitung: 0.30 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.