]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
common: Combine definitions for Multi-Link and per STA profile control
authorAndrei Otcheretianski <andrei.otcheretianski@intel.com>
Wed, 30 Nov 2022 13:09:25 +0000 (15:09 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 3 Dec 2022 09:11:34 +0000 (11:11 +0200)
The control fields are 16 bit wide. Combine the per byte definitions to
make it more convenient.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
src/common/ieee802_11_defs.h
src/drivers/driver_nl80211_event.c

index 7ed5f56060211e5f49749bc08c44fe9aac6abcbd..dbb0691af4714769e7ee24c6a628edb558c115b0 100644 (file)
@@ -2547,28 +2547,26 @@ struct ieee80211_eht_capabilities {
 /* IEEE P802.11be/D2.2, 9.4.2.312.2 - Basic Multi-Link element */
 
 /* Figure 9-1002g: Presence Bitmap subfield of the Basic Multi-Link element */
-#define BASIC_MULTI_LINK_CTRL0_PRES_LINK_ID            0x10
-#define BASIC_MULTI_LINK_CTRL0_PRES_BSS_PARAM_CH_COUNT 0x20
-#define BASIC_MULTI_LINK_CTRL0_PRES_MSD_INFO           0x40
-#define BASIC_MULTI_LINK_CTRL0_PRES_EML_CAPA           0x80
-
-#define BASIC_MULTI_LINK_CTRL1_PRES_MLD_CAPA           0x01
-#define BASIC_MULTI_LINK_CTRL1_PRES_AP_MLD_ID          0x02
+#define BASIC_MULTI_LINK_CTRL_PRES_LINK_ID             0x0010
+#define BASIC_MULTI_LINK_CTRL_PRES_BSS_PARAM_CH_COUNT  0x0020
+#define BASIC_MULTI_LINK_CTRL_PRES_MSD_INFO            0x0040
+#define BASIC_MULTI_LINK_CTRL_PRES_EML_CAPA            0x0080
+#define BASIC_MULTI_LINK_CTRL_PRES_MLD_CAPA            0x0100
+#define BASIC_MULTI_LINK_CTRL_PRES_AP_MLD_ID           0x0200
 
 /*
  * STA Control field definitions of Per-STA Profile subelement in Basic
  * Multi-Link element as described in Figure 9-1002n: STA Control field format.
  */
-#define BASIC_MLE_STA_CTRL0_LINK_ID_SHIFT              0
-#define BASIC_MLE_STA_CTRL0_LINK_ID_MASK               0x0F
-#define BASIC_MLE_STA_CTRL0_COMPLETE_PROFILE           0x10
-#define BASIC_MLE_STA_CTRL0_PRES_STA_MAC               0x20
-#define BASIC_MLE_STA_CTRL0_PRES_BEACON_INT            0x40
-#define BASIC_MLE_STA_CTRL0_PRES_TSF_OFFSET            0x80
-#define BASIC_MLE_STA_CTRL1_PRES_DTIM_INFO             0x01
-#define BASIC_MLE_STA_CTRL1_PRES_NSTR_LINK_PAIR                0x02
-#define BASIC_MLE_STA_CTRL1_NSTR_BITMAP                        0x04
-#define BASIC_MLE_STA_CTRL1_PRES_BSS_PARAM_COUNT       0x08
+#define BASIC_MLE_STA_CTRL_LINK_ID_MASK                        0x000F
+#define BASIC_MLE_STA_CTRL_COMPLETE_PROFILE            0x0010
+#define BASIC_MLE_STA_CTRL_PRES_STA_MAC                        0x0020
+#define BASIC_MLE_STA_CTRL_PRES_BEACON_INT             0x0040
+#define BASIC_MLE_STA_CTRL_PRES_TSF_OFFSET             0x0080
+#define BASIC_MLE_STA_CTRL_PRES_DTIM_INFO              0x0100
+#define BASIC_MLE_STA_CTRL_PRES_NSTR_LINK_PAIR         0x0200
+#define BASIC_MLE_STA_CTRL_NSTR_BITMAP                 0x0400
+#define BASIC_MLE_STA_CTRL_PRES_BSS_PARAM_COUNT                0x0800
 
 #define BASIC_MLE_STA_PROF_STA_MAC_IDX                 3
 
index d2860d7026e55f23acb31a99dce9f8c17ee6447e..bb80fbe39259f9a2a027c6af896618b422a1e1a0 100644 (file)
@@ -536,18 +536,18 @@ static void nl80211_get_basic_mle_links_info(const u8 *mle, size_t mle_len,
                if (pos[0] == MULTI_LINK_SUB_ELEM_ID_PER_STA_PROFILE) {
                        u8 link_id;
                        const u8 *sta_profile;
+                       u16 sta_ctrl;
 
                        if (pos[1] < BASIC_MLE_STA_PROF_STA_MAC_IDX + ETH_ALEN)
                                goto next_subelem;
 
                        sta_profile = &pos[2];
-                       link_id = sta_profile[0] &
-                               BASIC_MLE_STA_CTRL0_LINK_ID_MASK;
+                       sta_ctrl = WPA_GET_LE16(sta_profile);
+                       link_id = sta_ctrl & BASIC_MLE_STA_CTRL_LINK_ID_MASK;
                        if (link_id >= MAX_NUM_MLD_LINKS)
                                goto next_subelem;
 
-                       if (!(sta_profile[0] &
-                             BASIC_MLE_STA_CTRL0_PRES_STA_MAC))
+                       if (!(sta_ctrl & BASIC_MLE_STA_CTRL_PRES_STA_MAC))
                                goto next_subelem;
 
                        info->non_assoc_links |= BIT(link_id);
@@ -640,7 +640,13 @@ static int nl80211_update_rejected_links_info(struct driver_sta_mlo_info *mlo,
 
 static int nl80211_get_assoc_link_id(const u8 *data, u8 len)
 {
-       if (!(data[0] & BASIC_MULTI_LINK_CTRL0_PRES_LINK_ID))
+       u16 control;
+
+       if (len < 2)
+               return -1;
+
+       control = WPA_GET_LE16(data);
+       if (!(control & BASIC_MULTI_LINK_CTRL_PRES_LINK_ID))
                return -1;
 
 #define BASIC_ML_IE_COMMON_INFO_LINK_ID_IDX \