^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * spectrum management
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright 2003, Jouni Malinen <jkmaline@cc.hut.fi>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright 2002-2005, Instant802 Networks, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright 2005-2006, Devicescape Software, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Copyright 2007-2008, Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Copyright (C) 2018, 2020 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/ieee80211.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <net/cfg80211.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <net/mac80211.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "ieee80211_i.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "sta_info.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include "wme.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct ieee802_11_elems *elems,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) enum nl80211_band current_band,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) u32 vht_cap_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) u32 sta_flags, u8 *bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct ieee80211_csa_ie *csa_ie)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) enum nl80211_band new_band = current_band;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) int new_freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) u8 new_chan_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct ieee80211_channel *new_chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct cfg80211_chan_def new_vht_chandef = {};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int secondary_channel_offset = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) memset(csa_ie, 0, sizeof(*csa_ie));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) sec_chan_offs = elems->sec_chan_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) wide_bw_chansw_ie = elems->wide_bw_chansw_ie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) if (sta_flags & (IEEE80211_STA_DISABLE_HT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) IEEE80211_STA_DISABLE_40MHZ)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) sec_chan_offs = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) wide_bw_chansw_ie = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) if (sta_flags & IEEE80211_STA_DISABLE_VHT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) wide_bw_chansw_ie = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) if (elems->ext_chansw_ie) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if (!ieee80211_operating_class_to_band(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) elems->ext_chansw_ie->new_operating_class,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) &new_band)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) "cannot understand ECSA IE operating class, %d, ignoring\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) elems->ext_chansw_ie->new_operating_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) new_chan_no = elems->ext_chansw_ie->new_ch_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) csa_ie->count = elems->ext_chansw_ie->count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) csa_ie->mode = elems->ext_chansw_ie->mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) } else if (elems->ch_switch_ie) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) new_chan_no = elems->ch_switch_ie->new_ch_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) csa_ie->count = elems->ch_switch_ie->count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) csa_ie->mode = elems->ch_switch_ie->mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /* nothing here we understand */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) /* Mesh Channel Switch Parameters Element */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) if (elems->mesh_chansw_params_ie) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) csa_ie->ttl = elems->mesh_chansw_params_ie->mesh_ttl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) csa_ie->mode = elems->mesh_chansw_params_ie->mesh_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) csa_ie->pre_value = le16_to_cpu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) elems->mesh_chansw_params_ie->mesh_pre_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) if (elems->mesh_chansw_params_ie->mesh_flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) WLAN_EID_CHAN_SWITCH_PARAM_REASON)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) csa_ie->reason_code = le16_to_cpu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) elems->mesh_chansw_params_ie->mesh_reason);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) new_freq = ieee80211_channel_to_frequency(new_chan_no, new_band);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) new_chan = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) if (!new_chan || new_chan->flags & IEEE80211_CHAN_DISABLED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) "BSS %pM switches to unsupported channel (%d MHz), disconnecting\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) bssid, new_freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if (sec_chan_offs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) secondary_channel_offset = sec_chan_offs->sec_chan_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) } else if (!(sta_flags & IEEE80211_STA_DISABLE_HT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /* If the secondary channel offset IE is not present,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * we can't know what's the post-CSA offset, so the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * best we can do is use 20MHz.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) secondary_channel_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) switch (secondary_channel_offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /* secondary_channel_offset was present but is invalid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) case IEEE80211_HT_PARAM_CHA_SEC_NONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) cfg80211_chandef_create(&csa_ie->chandef, new_chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) NL80211_CHAN_HT20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) cfg80211_chandef_create(&csa_ie->chandef, new_chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) NL80211_CHAN_HT40PLUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) cfg80211_chandef_create(&csa_ie->chandef, new_chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) NL80211_CHAN_HT40MINUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) case -1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) cfg80211_chandef_create(&csa_ie->chandef, new_chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) NL80211_CHAN_NO_HT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /* keep width for 5/10 MHz channels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) switch (sdata->vif.bss_conf.chandef.width) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) case NL80211_CHAN_WIDTH_5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) case NL80211_CHAN_WIDTH_10:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) csa_ie->chandef.width =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) sdata->vif.bss_conf.chandef.width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) if (wide_bw_chansw_ie) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) u8 new_seg1 = wide_bw_chansw_ie->new_center_freq_seg1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) struct ieee80211_vht_operation vht_oper = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) .chan_width =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) wide_bw_chansw_ie->new_channel_width,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) .center_freq_seg0_idx =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) wide_bw_chansw_ie->new_center_freq_seg0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) .center_freq_seg1_idx = new_seg1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /* .basic_mcs_set doesn't matter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct ieee80211_ht_operation ht_oper = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) .operation_mode =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) cpu_to_le16(new_seg1 <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) IEEE80211_HT_OP_MODE_CCFS2_SHIFT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /* default, for the case of IEEE80211_VHT_CHANWIDTH_USE_HT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * to the previously parsed chandef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) new_vht_chandef = csa_ie->chandef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /* ignore if parsing fails */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) if (!ieee80211_chandef_vht_oper(&sdata->local->hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) vht_cap_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) &vht_oper, &ht_oper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) &new_vht_chandef))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) new_vht_chandef.chan = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) if (sta_flags & IEEE80211_STA_DISABLE_80P80MHZ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) new_vht_chandef.width == NL80211_CHAN_WIDTH_80P80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) ieee80211_chandef_downgrade(&new_vht_chandef);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) if (sta_flags & IEEE80211_STA_DISABLE_160MHZ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) new_vht_chandef.width == NL80211_CHAN_WIDTH_160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) ieee80211_chandef_downgrade(&new_vht_chandef);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /* if VHT data is there validate & use it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (new_vht_chandef.chan) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (!cfg80211_chandef_compatible(&new_vht_chandef,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) &csa_ie->chandef)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) sdata_info(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) "BSS %pM: CSA has inconsistent channel data, disconnecting\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) bssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) csa_ie->chandef = new_vht_chandef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) if (elems->max_channel_switch_time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) csa_ie->max_switch_time =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) (elems->max_channel_switch_time[0] << 0) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) (elems->max_channel_switch_time[1] << 8) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) (elems->max_channel_switch_time[2] << 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static void ieee80211_send_refuse_measurement_request(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct ieee80211_msrment_ie *request_ie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) const u8 *da, const u8 *bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) u8 dialog_token)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) struct ieee80211_local *local = sdata->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) struct ieee80211_mgmt *msr_report;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) skb = dev_alloc_skb(sizeof(*msr_report) + local->hw.extra_tx_headroom +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) sizeof(struct ieee80211_msrment_ie));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (!skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) skb_reserve(skb, local->hw.extra_tx_headroom);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) msr_report = skb_put_zero(skb, 24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) memcpy(msr_report->da, da, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) memcpy(msr_report->sa, sdata->vif.addr, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) memcpy(msr_report->bssid, bssid, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) msr_report->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) IEEE80211_STYPE_ACTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) skb_put(skb, 1 + sizeof(msr_report->u.action.u.measurement));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) msr_report->u.action.category = WLAN_CATEGORY_SPECTRUM_MGMT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) msr_report->u.action.u.measurement.action_code =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) WLAN_ACTION_SPCT_MSR_RPRT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) msr_report->u.action.u.measurement.dialog_token = dialog_token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) msr_report->u.action.u.measurement.element_id = WLAN_EID_MEASURE_REPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) msr_report->u.action.u.measurement.length =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) sizeof(struct ieee80211_msrment_ie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) memset(&msr_report->u.action.u.measurement.msr_elem, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) sizeof(struct ieee80211_msrment_ie));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) msr_report->u.action.u.measurement.msr_elem.token = request_ie->token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) msr_report->u.action.u.measurement.msr_elem.mode |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) msr_report->u.action.u.measurement.msr_elem.type = request_ie->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) ieee80211_tx_skb(sdata, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) struct ieee80211_mgmt *mgmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) * Ignoring measurement request is spec violation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) * Mandatory measurements must be reported optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * measurements might be refused or reported incapable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) * For now just refuse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * TODO: Answer basic measurement as unmeasured
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) ieee80211_send_refuse_measurement_request(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) &mgmt->u.action.u.measurement.msr_elem,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) mgmt->sa, mgmt->bssid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) mgmt->u.action.u.measurement.dialog_token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }