]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
HE: Fix calculation of the PPE Threshold field length
authorShiva Sankar Gajula <quic_sgajula@quicinc.com>
Fri, 4 Feb 2022 17:43:30 +0000 (23:13 +0530)
committerJouni Malinen <j@w1.fi>
Wed, 2 Mar 2022 23:31:39 +0000 (01:31 +0200)
The previously used calculation was not correct for the cases where the
extra padding field was needed. Fix this by properly calculating the
number of full octets in the field.

Fixes: 0497e4148197 ("HE: Fix HE Capabilities element size")
Signed-off-by: Shiva Sankar Gajula <quic_sgajula@quicinc.com>
src/ap/ieee802_11_he.c

index 6cd6c90dcf021808b23e6749edd72520d0b899ac..6e368ff33770c3d41dcd62c97a8835e628a3e34b 100644 (file)
@@ -29,17 +29,19 @@ static u8 ieee80211_he_ppet_size(u8 ppe_thres_hdr, const u8 *phy_cap_info)
 
        ru = (ppe_thres_hdr >> HE_PPE_THRES_RU_INDEX_BITMASK_SHIFT) &
                HE_PPE_THRES_RU_INDEX_BITMASK_MASK;
+       /* Count the number of 1 bits in RU Index Bitmask */
        while (ru) {
                if (ru & 0x1)
                        sz++;
                ru >>= 1;
        }
 
+       /* fixed header of 3 (NSTS) + 4 (RU Index Bitmask) = 7 bits */
+       /* 6 * (NSTS + 1) bits for bit 1 in RU Index Bitmask */
        sz *= 1 + (ppe_thres_hdr & HE_PPE_THRES_NSS_MASK);
        sz = (sz * 6) + 7;
-       if (sz % 8)
-               sz += 8;
-       sz /= 8;
+       /* PPE Pad to count the number of needed full octets */
+       sz = (sz + 7) / 8;
 
        return sz;
 }