[PATCH] RRM: Set last beacon report indication in the last element only

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Avraham Stern <avraham.stern@xxxxxxxxx>

The last beacon report indication was set in all the beacon report
elements in the last frame of the beacon report, while it should be
set only in the last beacon report element of the last frame.

Signed-off-by: Avraham Stern <avraham.stern@xxxxxxxxx>
---
 tests/hwsim/test_rrm.py |  2 +-
 wpa_supplicant/rrm.c    | 36 ++++++++++++++++++------------------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/tests/hwsim/test_rrm.py b/tests/hwsim/test_rrm.py
index 23af269d1e..1ac66fe230 100644
--- a/tests/hwsim/test_rrm.py
+++ b/tests/hwsim/test_rrm.py
@@ -875,7 +875,7 @@ def test_rrm_beacon_req_last_frame_indication(dev, apdev):
             raise Exception("Last Beacon Report Indication subelement missing")
 
         last = binascii.hexlify(report.last_indication).decode()
-        if last != '01':
+        if (i == 2 and last != '01') or (i != 2 and last != '00'):
             raise Exception("last beacon report indication is not set on last frame")
 
     # The request does not contain the last beacon report indication subelement
diff --git a/wpa_supplicant/rrm.c b/wpa_supplicant/rrm.c
index ab5e6dbdb6..cb3c6c995d 100644
--- a/wpa_supplicant/rrm.c
+++ b/wpa_supplicant/rrm.c
@@ -397,7 +397,10 @@ static int wpas_rrm_beacon_rep_update_last_frame(u8 *pos, size_t len)
 	struct rrm_measurement_report_element *msr_rep;
 	u8 *end = pos + len;
 	u8 *msr_rep_end;
+	struct rrm_measurement_beacon_report *rep = NULL;
+	u8 *subelem;
 
+	/* Find the last beacon report element */
 	while (end - pos >= (int) sizeof(*msr_rep)) {
 		msr_rep = (struct rrm_measurement_report_element *) pos;
 		msr_rep_end = pos + msr_rep->len + 2;
@@ -410,30 +413,27 @@ static int wpas_rrm_beacon_rep_update_last_frame(u8 *pos, size_t len)
 			return -1;
 		}
 
-		if (msr_rep->type == MEASURE_TYPE_BEACON) {
-			struct rrm_measurement_beacon_report *rep;
-			u8 *subelem;
-
+		if (msr_rep->type == MEASURE_TYPE_BEACON)
 			rep = (struct rrm_measurement_beacon_report *)
 				msr_rep->variable;
-			subelem = rep->variable;
-			while (subelem + 2 < msr_rep_end &&
-			       subelem[0] !=
-			       WLAN_BEACON_REPORT_SUBELEM_LAST_INDICATION)
-				subelem += 2 + subelem[1];
-
-			if (subelem + 2 < msr_rep_end &&
-			    subelem[0] ==
-			    WLAN_BEACON_REPORT_SUBELEM_LAST_INDICATION &&
-			    subelem[1] == 1 &&
-			    subelem +
-			    BEACON_REPORT_LAST_INDICATION_SUBELEM_LEN <= end)
-				subelem[2] = 1;
-		}
 
 		pos += pos[1] + 2;
 	}
 
+	if (!rep)
+		return 0;
+
+	subelem = rep->variable;
+	while (subelem + 2 < msr_rep_end &&
+	       subelem[0] != WLAN_BEACON_REPORT_SUBELEM_LAST_INDICATION)
+		subelem += 2 + subelem[1];
+
+	if (subelem + 2 < msr_rep_end &&
+	    subelem[0] == WLAN_BEACON_REPORT_SUBELEM_LAST_INDICATION &&
+	    subelem[1] == 1 &&
+	    subelem + BEACON_REPORT_LAST_INDICATION_SUBELEM_LEN <= end)
+		subelem[2] = 1;
+
 	return 0;
 }
 
-- 
2.19.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux