2022-06-07 22:11:36 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2012-05-09 09:30:28 +08:00
|
|
|
/*
|
2020-02-13 00:17:10 +08:00
|
|
|
* NXP Wireless LAN device driver: management IE handling- setting and
|
2012-05-09 09:30:28 +08:00
|
|
|
* deleting IE.
|
|
|
|
*
|
2020-02-13 00:17:10 +08:00
|
|
|
* Copyright 2011-2020 NXP
|
2012-05-09 09:30:28 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
/* This function checks if current IE index is used by any on other interface.
|
|
|
|
* Return: -1: yes, current IE index is used by someone else.
|
|
|
|
* 0: no, current IE index is NOT used by other interface.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
mwifiex_ie_index_used_by_other_intf(struct mwifiex_private *priv, u16 idx)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct mwifiex_adapter *adapter = priv->adapter;
|
|
|
|
struct mwifiex_ie *ie;
|
|
|
|
|
|
|
|
for (i = 0; i < adapter->priv_num; i++) {
|
|
|
|
if (adapter->priv[i] != priv) {
|
|
|
|
ie = &adapter->priv[i]->mgmt_ie[idx];
|
|
|
|
if (ie->mgmt_subtype_mask && ie->ie_length)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get unused IE index. This index will be used for setting new IE */
|
|
|
|
static int
|
|
|
|
mwifiex_ie_get_autoidx(struct mwifiex_private *priv, u16 subtype_mask,
|
|
|
|
struct mwifiex_ie *ie, u16 *index)
|
|
|
|
{
|
|
|
|
u16 mask, len, i;
|
|
|
|
|
|
|
|
for (i = 0; i < priv->adapter->max_mgmt_ie_index; i++) {
|
|
|
|
mask = le16_to_cpu(priv->mgmt_ie[i].mgmt_subtype_mask);
|
2012-06-29 11:30:27 +08:00
|
|
|
len = le16_to_cpu(ie->ie_length);
|
2012-05-09 09:30:28 +08:00
|
|
|
|
|
|
|
if (mask == MWIFIEX_AUTO_IDX_MASK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (mask == subtype_mask) {
|
|
|
|
if (len > IEEE_MAX_IE_SIZE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
*index = i;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!priv->mgmt_ie[i].ie_length) {
|
|
|
|
if (mwifiex_ie_index_used_by_other_intf(priv, i))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
*index = i;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This function prepares IE data buffer for command to be sent to FW */
|
|
|
|
static int
|
|
|
|
mwifiex_update_autoindex_ies(struct mwifiex_private *priv,
|
|
|
|
struct mwifiex_ie_list *ie_list)
|
|
|
|
{
|
|
|
|
u16 travel_len, index, mask;
|
2013-10-23 06:24:46 +08:00
|
|
|
s16 input_len, tlv_len;
|
2012-05-09 09:30:28 +08:00
|
|
|
struct mwifiex_ie *ie;
|
|
|
|
u8 *tmp;
|
|
|
|
|
|
|
|
input_len = le16_to_cpu(ie_list->len);
|
2013-07-23 10:17:57 +08:00
|
|
|
travel_len = sizeof(struct mwifiex_ie_types_header);
|
2012-05-09 09:30:28 +08:00
|
|
|
|
|
|
|
ie_list->len = 0;
|
|
|
|
|
2013-10-23 06:24:46 +08:00
|
|
|
while (input_len >= sizeof(struct mwifiex_ie_types_header)) {
|
2012-05-09 09:30:28 +08:00
|
|
|
ie = (struct mwifiex_ie *)(((u8 *)ie_list) + travel_len);
|
2013-10-23 06:24:46 +08:00
|
|
|
tlv_len = le16_to_cpu(ie->ie_length);
|
|
|
|
travel_len += tlv_len + MWIFIEX_IE_HDR_SIZE;
|
2012-05-09 09:30:28 +08:00
|
|
|
|
2013-10-23 06:24:46 +08:00
|
|
|
if (input_len < tlv_len + MWIFIEX_IE_HDR_SIZE)
|
|
|
|
return -1;
|
2012-05-09 09:30:28 +08:00
|
|
|
index = le16_to_cpu(ie->ie_index);
|
|
|
|
mask = le16_to_cpu(ie->mgmt_subtype_mask);
|
|
|
|
|
|
|
|
if (index == MWIFIEX_AUTO_IDX_MASK) {
|
|
|
|
/* automatic addition */
|
|
|
|
if (mwifiex_ie_get_autoidx(priv, mask, ie, &index))
|
|
|
|
return -1;
|
|
|
|
if (index == MWIFIEX_AUTO_IDX_MASK)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
tmp = (u8 *)&priv->mgmt_ie[index].ie_buffer;
|
|
|
|
memcpy(tmp, &ie->ie_buffer, le16_to_cpu(ie->ie_length));
|
2012-06-29 11:30:27 +08:00
|
|
|
priv->mgmt_ie[index].ie_length = ie->ie_length;
|
2012-05-09 09:30:28 +08:00
|
|
|
priv->mgmt_ie[index].ie_index = cpu_to_le16(index);
|
|
|
|
priv->mgmt_ie[index].mgmt_subtype_mask =
|
|
|
|
cpu_to_le16(mask);
|
|
|
|
|
|
|
|
ie->ie_index = cpu_to_le16(index);
|
|
|
|
} else {
|
|
|
|
if (mask != MWIFIEX_DELETE_MASK)
|
|
|
|
return -1;
|
|
|
|
/*
|
|
|
|
* Check if this index is being used on any
|
|
|
|
* other interface.
|
|
|
|
*/
|
|
|
|
if (mwifiex_ie_index_used_by_other_intf(priv, index))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ie->ie_length = 0;
|
|
|
|
memcpy(&priv->mgmt_ie[index], ie,
|
|
|
|
sizeof(struct mwifiex_ie));
|
|
|
|
}
|
|
|
|
|
2017-03-09 16:36:16 +08:00
|
|
|
le16_unaligned_add_cpu(&ie_list->len,
|
|
|
|
le16_to_cpu(
|
|
|
|
priv->mgmt_ie[index].ie_length) +
|
|
|
|
MWIFIEX_IE_HDR_SIZE);
|
2013-10-23 06:24:46 +08:00
|
|
|
input_len -= tlv_len + MWIFIEX_IE_HDR_SIZE;
|
2012-05-09 09:30:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP)
|
2014-02-28 11:35:12 +08:00
|
|
|
return mwifiex_send_cmd(priv, HostCmd_CMD_UAP_SYS_CONFIG,
|
|
|
|
HostCmd_ACT_GEN_SET,
|
2015-12-04 22:13:03 +08:00
|
|
|
UAP_CUSTOM_IE_I, ie_list, true);
|
2012-05-09 09:30:28 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2012-05-09 09:30:29 +08:00
|
|
|
|
|
|
|
/* Copy individual custom IEs for beacon, probe response and assoc response
|
|
|
|
* and prepare single structure for IE setting.
|
|
|
|
* This function also updates allocated IE indices from driver.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
mwifiex_update_uap_custom_ie(struct mwifiex_private *priv,
|
|
|
|
struct mwifiex_ie *beacon_ie, u16 *beacon_idx,
|
|
|
|
struct mwifiex_ie *pr_ie, u16 *probe_idx,
|
|
|
|
struct mwifiex_ie *ar_ie, u16 *assoc_idx)
|
|
|
|
{
|
|
|
|
struct mwifiex_ie_list *ap_custom_ie;
|
|
|
|
u8 *pos;
|
|
|
|
u16 len;
|
|
|
|
int ret;
|
|
|
|
|
2012-09-24 00:33:00 +08:00
|
|
|
ap_custom_ie = kzalloc(sizeof(*ap_custom_ie), GFP_KERNEL);
|
2012-05-09 09:30:29 +08:00
|
|
|
if (!ap_custom_ie)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
ap_custom_ie->type = cpu_to_le16(TLV_TYPE_MGMT_IE);
|
|
|
|
pos = (u8 *)ap_custom_ie->ie_list;
|
|
|
|
|
|
|
|
if (beacon_ie) {
|
|
|
|
len = sizeof(struct mwifiex_ie) - IEEE_MAX_IE_SIZE +
|
|
|
|
le16_to_cpu(beacon_ie->ie_length);
|
|
|
|
memcpy(pos, beacon_ie, len);
|
|
|
|
pos += len;
|
2017-03-09 16:36:16 +08:00
|
|
|
le16_unaligned_add_cpu(&ap_custom_ie->len, len);
|
2012-05-09 09:30:29 +08:00
|
|
|
}
|
|
|
|
if (pr_ie) {
|
|
|
|
len = sizeof(struct mwifiex_ie) - IEEE_MAX_IE_SIZE +
|
|
|
|
le16_to_cpu(pr_ie->ie_length);
|
|
|
|
memcpy(pos, pr_ie, len);
|
|
|
|
pos += len;
|
2017-03-09 16:36:16 +08:00
|
|
|
le16_unaligned_add_cpu(&ap_custom_ie->len, len);
|
2012-05-09 09:30:29 +08:00
|
|
|
}
|
|
|
|
if (ar_ie) {
|
|
|
|
len = sizeof(struct mwifiex_ie) - IEEE_MAX_IE_SIZE +
|
|
|
|
le16_to_cpu(ar_ie->ie_length);
|
|
|
|
memcpy(pos, ar_ie, len);
|
|
|
|
pos += len;
|
2017-03-09 16:36:16 +08:00
|
|
|
le16_unaligned_add_cpu(&ap_custom_ie->len, len);
|
2012-05-09 09:30:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = mwifiex_update_autoindex_ies(priv, ap_custom_ie);
|
|
|
|
|
|
|
|
pos = (u8 *)(&ap_custom_ie->ie_list[0].ie_index);
|
|
|
|
if (beacon_ie && *beacon_idx == MWIFIEX_AUTO_IDX_MASK) {
|
|
|
|
/* save beacon ie index after auto-indexing */
|
|
|
|
*beacon_idx = le16_to_cpu(ap_custom_ie->ie_list[0].ie_index);
|
|
|
|
len = sizeof(*beacon_ie) - IEEE_MAX_IE_SIZE +
|
|
|
|
le16_to_cpu(beacon_ie->ie_length);
|
|
|
|
pos += len;
|
|
|
|
}
|
|
|
|
if (pr_ie && le16_to_cpu(pr_ie->ie_index) == MWIFIEX_AUTO_IDX_MASK) {
|
|
|
|
/* save probe resp ie index after auto-indexing */
|
|
|
|
*probe_idx = *((u16 *)pos);
|
|
|
|
len = sizeof(*pr_ie) - IEEE_MAX_IE_SIZE +
|
|
|
|
le16_to_cpu(pr_ie->ie_length);
|
|
|
|
pos += len;
|
|
|
|
}
|
|
|
|
if (ar_ie && le16_to_cpu(ar_ie->ie_index) == MWIFIEX_AUTO_IDX_MASK)
|
|
|
|
/* save assoc resp ie index after auto-indexing */
|
|
|
|
*assoc_idx = *((u16 *)pos);
|
|
|
|
|
2012-06-28 03:46:24 +08:00
|
|
|
kfree(ap_custom_ie);
|
2012-05-09 09:30:29 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-09-26 11:23:43 +08:00
|
|
|
/* This function checks if the vendor specified IE is present in passed buffer
|
|
|
|
* and copies it to mwifiex_ie structure.
|
2012-06-29 11:30:30 +08:00
|
|
|
* Function takes pointer to struct mwifiex_ie pointer as argument.
|
2012-09-26 11:23:43 +08:00
|
|
|
* If the vendor specified IE is present then memory is allocated for
|
|
|
|
* mwifiex_ie pointer and filled in with IE. Caller should take care of freeing
|
|
|
|
* this memory.
|
2012-06-29 11:30:30 +08:00
|
|
|
*/
|
2012-09-26 11:23:43 +08:00
|
|
|
static int mwifiex_update_vs_ie(const u8 *ies, int ies_len,
|
|
|
|
struct mwifiex_ie **ie_ptr, u16 mask,
|
|
|
|
unsigned int oui, u8 oui_type)
|
2012-06-29 11:30:30 +08:00
|
|
|
{
|
2012-09-26 11:23:43 +08:00
|
|
|
struct ieee_types_header *vs_ie;
|
|
|
|
struct mwifiex_ie *ie = *ie_ptr;
|
2012-06-29 11:30:30 +08:00
|
|
|
const u8 *vendor_ie;
|
|
|
|
|
2012-09-26 11:23:43 +08:00
|
|
|
vendor_ie = cfg80211_find_vendor_ie(oui, oui_type, ies, ies_len);
|
2012-06-29 11:30:30 +08:00
|
|
|
if (vendor_ie) {
|
2012-09-26 11:23:43 +08:00
|
|
|
if (!*ie_ptr) {
|
|
|
|
*ie_ptr = kzalloc(sizeof(struct mwifiex_ie),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!*ie_ptr)
|
|
|
|
return -ENOMEM;
|
|
|
|
ie = *ie_ptr;
|
|
|
|
}
|
2012-06-29 11:30:30 +08:00
|
|
|
|
2012-09-26 11:23:43 +08:00
|
|
|
vs_ie = (struct ieee_types_header *)vendor_ie;
|
2019-08-28 10:07:51 +08:00
|
|
|
if (le16_to_cpu(ie->ie_length) + vs_ie->len + 2 >
|
|
|
|
IEEE_MAX_IE_SIZE)
|
|
|
|
return -EINVAL;
|
2012-09-26 11:23:43 +08:00
|
|
|
memcpy(ie->ie_buffer + le16_to_cpu(ie->ie_length),
|
|
|
|
vs_ie, vs_ie->len + 2);
|
2017-03-09 16:36:16 +08:00
|
|
|
le16_unaligned_add_cpu(&ie->ie_length, vs_ie->len + 2);
|
2012-06-29 11:30:30 +08:00
|
|
|
ie->mgmt_subtype_mask = cpu_to_le16(mask);
|
|
|
|
ie->ie_index = cpu_to_le16(MWIFIEX_AUTO_IDX_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
*ie_ptr = ie;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-29 11:30:26 +08:00
|
|
|
/* This function parses beacon IEs, probe response IEs, association response IEs
|
|
|
|
* from cfg80211_ap_settings->beacon and sets these IE to FW.
|
2012-05-09 09:30:29 +08:00
|
|
|
*/
|
2012-06-29 11:30:26 +08:00
|
|
|
static int mwifiex_set_mgmt_beacon_data_ies(struct mwifiex_private *priv,
|
|
|
|
struct cfg80211_beacon_data *data)
|
2012-05-09 09:30:29 +08:00
|
|
|
{
|
2012-06-29 11:30:26 +08:00
|
|
|
struct mwifiex_ie *beacon_ie = NULL, *pr_ie = NULL, *ar_ie = NULL;
|
2012-05-09 09:30:29 +08:00
|
|
|
u16 beacon_idx = MWIFIEX_AUTO_IDX_MASK, pr_idx = MWIFIEX_AUTO_IDX_MASK;
|
2012-06-29 11:30:26 +08:00
|
|
|
u16 ar_idx = MWIFIEX_AUTO_IDX_MASK;
|
2012-05-09 09:30:29 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
2012-09-26 11:23:43 +08:00
|
|
|
if (data->beacon_ies && data->beacon_ies_len) {
|
|
|
|
mwifiex_update_vs_ie(data->beacon_ies, data->beacon_ies_len,
|
|
|
|
&beacon_ie, MGMT_MASK_BEACON,
|
|
|
|
WLAN_OUI_MICROSOFT,
|
|
|
|
WLAN_OUI_TYPE_MICROSOFT_WPS);
|
|
|
|
mwifiex_update_vs_ie(data->beacon_ies, data->beacon_ies_len,
|
|
|
|
&beacon_ie, MGMT_MASK_BEACON,
|
|
|
|
WLAN_OUI_WFA, WLAN_OUI_TYPE_WFA_P2P);
|
|
|
|
}
|
2012-05-09 09:30:29 +08:00
|
|
|
|
2012-09-26 11:23:43 +08:00
|
|
|
if (data->proberesp_ies && data->proberesp_ies_len) {
|
|
|
|
mwifiex_update_vs_ie(data->proberesp_ies,
|
|
|
|
data->proberesp_ies_len, &pr_ie,
|
|
|
|
MGMT_MASK_PROBE_RESP, WLAN_OUI_MICROSOFT,
|
|
|
|
WLAN_OUI_TYPE_MICROSOFT_WPS);
|
|
|
|
mwifiex_update_vs_ie(data->proberesp_ies,
|
|
|
|
data->proberesp_ies_len, &pr_ie,
|
|
|
|
MGMT_MASK_PROBE_RESP,
|
|
|
|
WLAN_OUI_WFA, WLAN_OUI_TYPE_WFA_P2P);
|
|
|
|
}
|
2012-05-09 09:30:29 +08:00
|
|
|
|
2012-09-26 11:23:43 +08:00
|
|
|
if (data->assocresp_ies && data->assocresp_ies_len) {
|
|
|
|
mwifiex_update_vs_ie(data->assocresp_ies,
|
|
|
|
data->assocresp_ies_len, &ar_ie,
|
|
|
|
MGMT_MASK_ASSOC_RESP |
|
|
|
|
MGMT_MASK_REASSOC_RESP,
|
|
|
|
WLAN_OUI_MICROSOFT,
|
|
|
|
WLAN_OUI_TYPE_MICROSOFT_WPS);
|
|
|
|
mwifiex_update_vs_ie(data->assocresp_ies,
|
|
|
|
data->assocresp_ies_len, &ar_ie,
|
|
|
|
MGMT_MASK_ASSOC_RESP |
|
|
|
|
MGMT_MASK_REASSOC_RESP, WLAN_OUI_WFA,
|
|
|
|
WLAN_OUI_TYPE_WFA_P2P);
|
|
|
|
}
|
2012-05-09 09:30:29 +08:00
|
|
|
|
|
|
|
if (beacon_ie || pr_ie || ar_ie) {
|
|
|
|
ret = mwifiex_update_uap_custom_ie(priv, beacon_ie,
|
|
|
|
&beacon_idx, pr_ie,
|
|
|
|
&pr_idx, ar_ie, &ar_idx);
|
|
|
|
if (ret)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->beacon_idx = beacon_idx;
|
|
|
|
priv->proberesp_idx = pr_idx;
|
|
|
|
priv->assocresp_idx = ar_idx;
|
|
|
|
|
|
|
|
done:
|
|
|
|
kfree(beacon_ie);
|
|
|
|
kfree(pr_ie);
|
|
|
|
kfree(ar_ie);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2012-05-09 09:30:30 +08:00
|
|
|
|
2015-01-28 18:24:20 +08:00
|
|
|
/* This function parses head and tail IEs, from cfg80211_beacon_data and sets
|
|
|
|
* these IE to FW.
|
2012-06-29 11:30:26 +08:00
|
|
|
*/
|
2015-06-03 19:29:42 +08:00
|
|
|
static int mwifiex_uap_parse_tail_ies(struct mwifiex_private *priv,
|
|
|
|
struct cfg80211_beacon_data *info)
|
2012-06-29 11:30:26 +08:00
|
|
|
{
|
|
|
|
struct mwifiex_ie *gen_ie;
|
2015-06-03 19:29:42 +08:00
|
|
|
struct ieee_types_header *hdr;
|
|
|
|
struct ieee80211_vendor_ie *vendorhdr;
|
2015-01-28 18:24:20 +08:00
|
|
|
u16 gen_idx = MWIFIEX_AUTO_IDX_MASK, ie_len = 0;
|
2015-06-03 19:29:42 +08:00
|
|
|
int left_len, parsed_len = 0;
|
2019-05-31 21:18:41 +08:00
|
|
|
unsigned int token_len;
|
|
|
|
int err = 0;
|
2015-06-03 19:29:42 +08:00
|
|
|
|
|
|
|
if (!info->tail || !info->tail_len)
|
|
|
|
return 0;
|
2012-06-29 11:30:26 +08:00
|
|
|
|
2015-01-28 18:24:20 +08:00
|
|
|
gen_ie = kzalloc(sizeof(*gen_ie), GFP_KERNEL);
|
|
|
|
if (!gen_ie)
|
|
|
|
return -ENOMEM;
|
2012-06-29 11:30:26 +08:00
|
|
|
|
2015-06-03 19:29:42 +08:00
|
|
|
left_len = info->tail_len;
|
|
|
|
|
|
|
|
/* Many IEs are generated in FW by parsing bss configuration.
|
|
|
|
* Let's not add them here; else we may end up duplicating these IEs
|
|
|
|
*/
|
|
|
|
while (left_len > sizeof(struct ieee_types_header)) {
|
|
|
|
hdr = (void *)(info->tail + parsed_len);
|
2019-05-31 21:18:41 +08:00
|
|
|
token_len = hdr->len + sizeof(struct ieee_types_header);
|
|
|
|
if (token_len > left_len) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2015-06-03 19:29:42 +08:00
|
|
|
switch (hdr->element_id) {
|
|
|
|
case WLAN_EID_SSID:
|
|
|
|
case WLAN_EID_SUPP_RATES:
|
|
|
|
case WLAN_EID_COUNTRY:
|
|
|
|
case WLAN_EID_PWR_CONSTRAINT:
|
2018-04-02 20:31:22 +08:00
|
|
|
case WLAN_EID_ERP_INFO:
|
2015-06-03 19:29:42 +08:00
|
|
|
case WLAN_EID_EXT_SUPP_RATES:
|
|
|
|
case WLAN_EID_HT_CAPABILITY:
|
|
|
|
case WLAN_EID_HT_OPERATION:
|
|
|
|
case WLAN_EID_VHT_CAPABILITY:
|
|
|
|
case WLAN_EID_VHT_OPERATION:
|
|
|
|
break;
|
2018-07-24 19:47:27 +08:00
|
|
|
case WLAN_EID_VENDOR_SPECIFIC:
|
|
|
|
/* Skip only Microsoft WMM IE */
|
|
|
|
if (cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
|
|
|
|
WLAN_OUI_TYPE_MICROSOFT_WMM,
|
|
|
|
(const u8 *)hdr,
|
2019-05-31 21:18:41 +08:00
|
|
|
token_len))
|
2018-07-24 19:47:27 +08:00
|
|
|
break;
|
2020-08-21 14:47:20 +08:00
|
|
|
fallthrough;
|
2015-06-03 19:29:42 +08:00
|
|
|
default:
|
2019-05-31 21:18:41 +08:00
|
|
|
if (ie_len + token_len > IEEE_MAX_IE_SIZE) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
memcpy(gen_ie->ie_buffer + ie_len, hdr, token_len);
|
|
|
|
ie_len += token_len;
|
2015-06-03 19:29:42 +08:00
|
|
|
break;
|
2012-06-29 11:30:26 +08:00
|
|
|
}
|
2019-05-31 21:18:41 +08:00
|
|
|
left_len -= token_len;
|
|
|
|
parsed_len += token_len;
|
2015-06-03 19:29:42 +08:00
|
|
|
}
|
2012-06-29 11:30:26 +08:00
|
|
|
|
2015-06-03 19:29:42 +08:00
|
|
|
/* parse only WPA vendor IE from tail, WMM IE is configured by
|
|
|
|
* bss_config command
|
|
|
|
*/
|
|
|
|
vendorhdr = (void *)cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
|
2012-06-29 11:30:26 +08:00
|
|
|
WLAN_OUI_TYPE_MICROSOFT_WPA,
|
2015-06-03 19:29:42 +08:00
|
|
|
info->tail, info->tail_len);
|
|
|
|
if (vendorhdr) {
|
2019-05-31 21:18:41 +08:00
|
|
|
token_len = vendorhdr->len + sizeof(struct ieee_types_header);
|
|
|
|
if (ie_len + token_len > IEEE_MAX_IE_SIZE) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
memcpy(gen_ie->ie_buffer + ie_len, vendorhdr, token_len);
|
|
|
|
ie_len += token_len;
|
2015-06-03 19:29:42 +08:00
|
|
|
}
|
2015-01-28 18:24:24 +08:00
|
|
|
|
2019-05-31 21:18:41 +08:00
|
|
|
if (!ie_len)
|
|
|
|
goto out;
|
2012-06-29 11:30:26 +08:00
|
|
|
|
2015-06-03 19:29:42 +08:00
|
|
|
gen_ie->ie_index = cpu_to_le16(gen_idx);
|
|
|
|
gen_ie->mgmt_subtype_mask = cpu_to_le16(MGMT_MASK_BEACON |
|
|
|
|
MGMT_MASK_PROBE_RESP |
|
|
|
|
MGMT_MASK_ASSOC_RESP);
|
|
|
|
gen_ie->ie_length = cpu_to_le16(ie_len);
|
|
|
|
|
|
|
|
if (mwifiex_update_uap_custom_ie(priv, gen_ie, &gen_idx, NULL, NULL,
|
|
|
|
NULL, NULL)) {
|
2019-05-31 21:18:41 +08:00
|
|
|
err = -EINVAL;
|
|
|
|
goto out;
|
2012-06-29 11:30:26 +08:00
|
|
|
}
|
|
|
|
|
2015-06-03 19:29:42 +08:00
|
|
|
priv->gen_idx = gen_idx;
|
2019-05-31 21:18:41 +08:00
|
|
|
|
|
|
|
out:
|
2015-01-28 18:24:20 +08:00
|
|
|
kfree(gen_ie);
|
2019-05-31 21:18:41 +08:00
|
|
|
return err;
|
2015-01-28 18:24:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This function parses different IEs-head & tail IEs, beacon IEs,
|
|
|
|
* probe response IEs, association response IEs from cfg80211_ap_settings
|
|
|
|
* function and sets these IE to FW.
|
|
|
|
*/
|
|
|
|
int mwifiex_set_mgmt_ies(struct mwifiex_private *priv,
|
|
|
|
struct cfg80211_beacon_data *info)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2015-06-03 19:29:42 +08:00
|
|
|
ret = mwifiex_uap_parse_tail_ies(priv, info);
|
2015-06-24 03:04:03 +08:00
|
|
|
|
|
|
|
if (ret)
|
2015-01-28 18:24:20 +08:00
|
|
|
return ret;
|
|
|
|
|
2012-06-29 11:30:26 +08:00
|
|
|
return mwifiex_set_mgmt_beacon_data_ies(priv, info);
|
|
|
|
}
|
|
|
|
|
2012-05-09 09:30:30 +08:00
|
|
|
/* This function removes management IE set */
|
|
|
|
int mwifiex_del_mgmt_ies(struct mwifiex_private *priv)
|
|
|
|
{
|
|
|
|
struct mwifiex_ie *beacon_ie = NULL, *pr_ie = NULL;
|
2015-01-28 18:24:20 +08:00
|
|
|
struct mwifiex_ie *ar_ie = NULL, *gen_ie = NULL;
|
2012-05-09 09:30:30 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
2015-01-28 18:24:20 +08:00
|
|
|
if (priv->gen_idx != MWIFIEX_AUTO_IDX_MASK) {
|
|
|
|
gen_ie = kmalloc(sizeof(*gen_ie), GFP_KERNEL);
|
|
|
|
if (!gen_ie)
|
2012-05-09 09:30:30 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2015-01-28 18:24:20 +08:00
|
|
|
gen_ie->ie_index = cpu_to_le16(priv->gen_idx);
|
|
|
|
gen_ie->mgmt_subtype_mask = cpu_to_le16(MWIFIEX_DELETE_MASK);
|
|
|
|
gen_ie->ie_length = 0;
|
|
|
|
if (mwifiex_update_uap_custom_ie(priv, gen_ie, &priv->gen_idx,
|
2012-05-09 09:30:30 +08:00
|
|
|
NULL, &priv->proberesp_idx,
|
|
|
|
NULL, &priv->assocresp_idx)) {
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2015-01-28 18:24:20 +08:00
|
|
|
priv->gen_idx = MWIFIEX_AUTO_IDX_MASK;
|
2012-05-09 09:30:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->beacon_idx != MWIFIEX_AUTO_IDX_MASK) {
|
|
|
|
beacon_ie = kmalloc(sizeof(struct mwifiex_ie), GFP_KERNEL);
|
|
|
|
if (!beacon_ie) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
beacon_ie->ie_index = cpu_to_le16(priv->beacon_idx);
|
|
|
|
beacon_ie->mgmt_subtype_mask = cpu_to_le16(MWIFIEX_DELETE_MASK);
|
|
|
|
beacon_ie->ie_length = 0;
|
|
|
|
}
|
|
|
|
if (priv->proberesp_idx != MWIFIEX_AUTO_IDX_MASK) {
|
|
|
|
pr_ie = kmalloc(sizeof(struct mwifiex_ie), GFP_KERNEL);
|
|
|
|
if (!pr_ie) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
pr_ie->ie_index = cpu_to_le16(priv->proberesp_idx);
|
|
|
|
pr_ie->mgmt_subtype_mask = cpu_to_le16(MWIFIEX_DELETE_MASK);
|
|
|
|
pr_ie->ie_length = 0;
|
|
|
|
}
|
|
|
|
if (priv->assocresp_idx != MWIFIEX_AUTO_IDX_MASK) {
|
|
|
|
ar_ie = kmalloc(sizeof(struct mwifiex_ie), GFP_KERNEL);
|
|
|
|
if (!ar_ie) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
ar_ie->ie_index = cpu_to_le16(priv->assocresp_idx);
|
|
|
|
ar_ie->mgmt_subtype_mask = cpu_to_le16(MWIFIEX_DELETE_MASK);
|
|
|
|
ar_ie->ie_length = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (beacon_ie || pr_ie || ar_ie)
|
|
|
|
ret = mwifiex_update_uap_custom_ie(priv,
|
|
|
|
beacon_ie, &priv->beacon_idx,
|
|
|
|
pr_ie, &priv->proberesp_idx,
|
|
|
|
ar_ie, &priv->assocresp_idx);
|
|
|
|
|
|
|
|
done:
|
2015-06-27 03:29:36 +08:00
|
|
|
kfree(gen_ie);
|
2012-05-09 09:30:30 +08:00
|
|
|
kfree(beacon_ie);
|
|
|
|
kfree(pr_ie);
|
|
|
|
kfree(ar_ie);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|