Skip to content

Commit cd418ba

Browse files
twpedersenjmberg-intel
authored andcommitted
mac80211: convert S1G beacon to scan results
This commit finds the correct offset for Information Elements in S1G beacon frames so they can be reported in scan results. Signed-off-by: Thomas Pedersen <thomas@adapt-ip.com> Link: https://lore.kernel.org/r/20200922022818.15855-8-thomas@adapt-ip.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 66b0564 commit cd418ba

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

net/mac80211/ieee80211_i.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,9 @@ struct ieee802_11_elems {
15351535
u8 dtim_count;
15361536
u8 dtim_period;
15371537
const struct ieee80211_addba_ext_ie *addba_ext_ie;
1538+
const struct ieee80211_s1g_cap *s1g_capab;
1539+
const struct ieee80211_s1g_oper_ie *s1g_oper;
1540+
const struct ieee80211_s1g_bcn_compat_ie *s1g_bcn_compat;
15381541

15391542
/* length of them, respectively */
15401543
u8 ext_capab_len;

net/mac80211/rx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4578,7 +4578,8 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
45784578
ieee80211_verify_alignment(&rx);
45794579

45804580
if (unlikely(ieee80211_is_probe_resp(hdr->frame_control) ||
4581-
ieee80211_is_beacon(hdr->frame_control)))
4581+
ieee80211_is_beacon(hdr->frame_control) ||
4582+
ieee80211_is_s1g_beacon(hdr->frame_control)))
45824583
ieee80211_scan_rx(local, skb);
45834584

45844585
if (ieee80211_is_data(fc)) {

net/mac80211/scan.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ ieee80211_bss_info_update(struct ieee80211_local *local,
146146
struct ieee80211_mgmt *mgmt, size_t len,
147147
struct ieee80211_channel *channel)
148148
{
149-
bool beacon = ieee80211_is_beacon(mgmt->frame_control);
149+
bool beacon = ieee80211_is_beacon(mgmt->frame_control) ||
150+
ieee80211_is_s1g_beacon(mgmt->frame_control);
150151
struct cfg80211_bss *cbss, *non_tx_cbss;
151152
struct ieee80211_bss *bss, *non_tx_bss;
152153
struct cfg80211_inform_bss bss_meta = {
@@ -195,6 +196,11 @@ ieee80211_bss_info_update(struct ieee80211_local *local,
195196
elements = mgmt->u.probe_resp.variable;
196197
baselen = offsetof(struct ieee80211_mgmt,
197198
u.probe_resp.variable);
199+
} else if (ieee80211_is_s1g_beacon(mgmt->frame_control)) {
200+
struct ieee80211_ext *ext = (void *) mgmt;
201+
202+
baselen = offsetof(struct ieee80211_ext, u.s1g_beacon.variable);
203+
elements = ext->u.s1g_beacon.variable;
198204
} else {
199205
baselen = offsetof(struct ieee80211_mgmt, u.beacon.variable);
200206
elements = mgmt->u.beacon.variable;
@@ -246,9 +252,12 @@ void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb)
246252
struct ieee80211_bss *bss;
247253
struct ieee80211_channel *channel;
248254

249-
if (skb->len < 24 ||
250-
(!ieee80211_is_probe_resp(mgmt->frame_control) &&
251-
!ieee80211_is_beacon(mgmt->frame_control)))
255+
if (ieee80211_is_s1g_beacon(mgmt->frame_control)) {
256+
if (skb->len < 15)
257+
return;
258+
} else if (skb->len < 24 ||
259+
(!ieee80211_is_probe_resp(mgmt->frame_control) &&
260+
!ieee80211_is_beacon(mgmt->frame_control)))
252261
return;
253262

254263
sdata1 = rcu_dereference(local->scan_sdata);

net/mac80211/util.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,10 @@ _ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
10031003
case WLAN_EID_LINK_ID:
10041004
case WLAN_EID_BSS_MAX_IDLE_PERIOD:
10051005
case WLAN_EID_RSNX:
1006+
case WLAN_EID_S1G_BCN_COMPAT:
1007+
case WLAN_EID_S1G_CAPABILITIES:
1008+
case WLAN_EID_S1G_OPERATION:
1009+
case WLAN_EID_S1G_SHORT_BCN_INTERVAL:
10061010
/*
10071011
* not listing WLAN_EID_CHANNEL_SWITCH_WRAPPER -- it seems possible
10081012
* that if the content gets bigger it might be needed more than once
@@ -1288,6 +1292,24 @@ _ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
12881292
&crc : NULL,
12891293
elem, elems);
12901294
break;
1295+
case WLAN_EID_S1G_CAPABILITIES:
1296+
if (elen == sizeof(*elems->s1g_capab))
1297+
elems->s1g_capab = (void *)pos;
1298+
else
1299+
elem_parse_failed = true;
1300+
break;
1301+
case WLAN_EID_S1G_OPERATION:
1302+
if (elen == sizeof(*elems->s1g_oper))
1303+
elems->s1g_oper = (void *)pos;
1304+
else
1305+
elem_parse_failed = true;
1306+
break;
1307+
case WLAN_EID_S1G_BCN_COMPAT:
1308+
if (elen == sizeof(*elems->s1g_bcn_compat))
1309+
elems->s1g_bcn_compat = (void *)pos;
1310+
else
1311+
elem_parse_failed = true;
1312+
break;
12911313
default:
12921314
break;
12931315
}

0 commit comments

Comments
 (0)