|
111 | 111 |
|
112 | 112 | /* bits unique to S1G beacon */ |
113 | 113 | #define IEEE80211_S1G_BCN_NEXT_TBTT 0x100 |
| 114 | +#define IEEE80211_S1G_BCN_CSSID 0x200 |
| 115 | +#define IEEE80211_S1G_BCN_ANO 0x400 |
114 | 116 |
|
115 | 117 | /* see 802.11ah-2016 9.9 NDP CMAC frames */ |
116 | 118 | #define IEEE80211_S1G_1MHZ_NDP_BITS 25 |
|
153 | 155 |
|
154 | 156 | #define IEEE80211_ANO_NETTYPE_WILD 15 |
155 | 157 |
|
156 | | -/* bits unique to S1G beacon */ |
157 | | -#define IEEE80211_S1G_BCN_NEXT_TBTT 0x100 |
158 | | - |
159 | 158 | /* control extension - for IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTL_EXT */ |
160 | 159 | #define IEEE80211_CTL_EXT_POLL 0x2000 |
161 | 160 | #define IEEE80211_CTL_EXT_SPR 0x3000 |
@@ -627,6 +626,42 @@ static inline bool ieee80211_is_s1g_beacon(__le16 fc) |
627 | 626 | cpu_to_le16(IEEE80211_FTYPE_EXT | IEEE80211_STYPE_S1G_BEACON); |
628 | 627 | } |
629 | 628 |
|
| 629 | +/** |
| 630 | + * ieee80211_s1g_has_next_tbtt - check if IEEE80211_S1G_BCN_NEXT_TBTT |
| 631 | + * @fc: frame control bytes in little-endian byteorder |
| 632 | + * Return: whether or not the frame contains the variable-length |
| 633 | + * next TBTT field |
| 634 | + */ |
| 635 | +static inline bool ieee80211_s1g_has_next_tbtt(__le16 fc) |
| 636 | +{ |
| 637 | + return ieee80211_is_s1g_beacon(fc) && |
| 638 | + (fc & cpu_to_le16(IEEE80211_S1G_BCN_NEXT_TBTT)); |
| 639 | +} |
| 640 | + |
| 641 | +/** |
| 642 | + * ieee80211_s1g_has_ano - check if IEEE80211_S1G_BCN_ANO |
| 643 | + * @fc: frame control bytes in little-endian byteorder |
| 644 | + * Return: whether or not the frame contains the variable-length |
| 645 | + * ANO field |
| 646 | + */ |
| 647 | +static inline bool ieee80211_s1g_has_ano(__le16 fc) |
| 648 | +{ |
| 649 | + return ieee80211_is_s1g_beacon(fc) && |
| 650 | + (fc & cpu_to_le16(IEEE80211_S1G_BCN_ANO)); |
| 651 | +} |
| 652 | + |
| 653 | +/** |
| 654 | + * ieee80211_s1g_has_cssid - check if IEEE80211_S1G_BCN_CSSID |
| 655 | + * @fc: frame control bytes in little-endian byteorder |
| 656 | + * Return: whether or not the frame contains the variable-length |
| 657 | + * compressed SSID field |
| 658 | + */ |
| 659 | +static inline bool ieee80211_s1g_has_cssid(__le16 fc) |
| 660 | +{ |
| 661 | + return ieee80211_is_s1g_beacon(fc) && |
| 662 | + (fc & cpu_to_le16(IEEE80211_S1G_BCN_CSSID)); |
| 663 | +} |
| 664 | + |
630 | 665 | /** |
631 | 666 | * ieee80211_is_s1g_short_beacon - check if frame is an S1G short beacon |
632 | 667 | * @fc: frame control bytes in little-endian byteorder |
@@ -1245,16 +1280,40 @@ struct ieee80211_ext { |
1245 | 1280 | u8 change_seq; |
1246 | 1281 | u8 variable[0]; |
1247 | 1282 | } __packed s1g_beacon; |
1248 | | - struct { |
1249 | | - u8 sa[ETH_ALEN]; |
1250 | | - __le32 timestamp; |
1251 | | - u8 change_seq; |
1252 | | - u8 next_tbtt[3]; |
1253 | | - u8 variable[0]; |
1254 | | - } __packed s1g_short_beacon; |
1255 | 1283 | } u; |
1256 | 1284 | } __packed __aligned(2); |
1257 | 1285 |
|
| 1286 | +/** |
| 1287 | + * ieee80211_s1g_optional_len - determine length of optional S1G beacon fields |
| 1288 | + * @fc: frame control bytes in little-endian byteorder |
| 1289 | + * Return: total length in bytes of the optional fixed-length fields |
| 1290 | + * |
| 1291 | + * S1G beacons may contain up to three optional fixed-length fields that |
| 1292 | + * precede the variable-length elements. Whether these fields are present |
| 1293 | + * is indicated by flags in the frame control field. |
| 1294 | + * |
| 1295 | + * From IEEE 802.11-2024 section 9.3.4.3: |
| 1296 | + * - Next TBTT field may be 0 or 3 bytes |
| 1297 | + * - Short SSID field may be 0 or 4 bytes |
| 1298 | + * - Access Network Options (ANO) field may be 0 or 1 byte |
| 1299 | + */ |
| 1300 | +static inline size_t |
| 1301 | +ieee80211_s1g_optional_len(__le16 fc) |
| 1302 | +{ |
| 1303 | + size_t len = 0; |
| 1304 | + |
| 1305 | + if (ieee80211_s1g_has_next_tbtt(fc)) |
| 1306 | + len += 3; |
| 1307 | + |
| 1308 | + if (ieee80211_s1g_has_cssid(fc)) |
| 1309 | + len += 4; |
| 1310 | + |
| 1311 | + if (ieee80211_s1g_has_ano(fc)) |
| 1312 | + len += 1; |
| 1313 | + |
| 1314 | + return len; |
| 1315 | +} |
| 1316 | + |
1258 | 1317 | #define IEEE80211_TWT_CONTROL_NDP BIT(0) |
1259 | 1318 | #define IEEE80211_TWT_CONTROL_RESP_MODE BIT(1) |
1260 | 1319 | #define IEEE80211_TWT_CONTROL_NEG_TYPE_BROADCAST BIT(3) |
|
0 commit comments