Skip to contentSkip to conversation

shared/rap: Fix Mode 0 step serialization

PATCH Applied Prathibha Madugonde 3 participants 3 messages Jun 18 – Jun 19 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shared/rap: Fix Mode 0 step serialization

From: Prathibha Madugonde <[email protected]>

Replace raw struct byte dump with field-by-field serialization that conditionally includes init_measured_freq_offset only for the Initiator role, matching the RAS wire format (5 bytes for Initiator, 3 bytes for Reflector)

---
 src/shared/rap.c | 41 +++++++++++++++++++++++++++++++++--------
 1 file changed, 33 insertions(+), 8 deletions(-)
src/shared/rap.c +33 -8
index 390fd3080..ecf7df5a7 100644
@@ -1307,15 +1307,40 @@ static void process_cs_mode_zero(struct bt_rap *rap,
 				const struct cs_step_data *step,
 				uint8_t idx, uint8_t mode_byte)
 {
-	const uint8_t *payload;
-	uint8_t plen;
+	const struct cs_mode_zero_data *m0 =
+		&step->step_mode_data.mode_zero_data;
+	struct cstracker *resptracker = rap->resptracker;
+	enum cs_role cs_role = resptracker->role;
+	struct iovec temp_iov = { 0 };
+
+	temp_iov.iov_base = malloc(8);
+	if (!temp_iov.iov_base) {
+		DBG(rap, "Mode0 ERROR: malloc failed!");
+		return;
+	}
+	temp_iov.iov_len = 0;
+
+	if (!util_iov_push_u8(&temp_iov, m0->packet_quality) ||
+	    !util_iov_push_u8(&temp_iov, m0->packet_rssi_dbm) ||
+	    !util_iov_push_u8(&temp_iov, m0->packet_ant))
+		goto done;
+
+	if (cs_role == CS_ROLE_INITIATOR) {
+		if (!util_iov_push_le16(&temp_iov,
+					m0->init_measured_freq_offset))
+			goto done;
+	}
 
-	/* Mode 0: use raw structure bytes */
-	payload = (const uint8_t *)&step->step_mode_data;
-	plen = step->step_data_length;
-	cs_pd_ras_append_subevent_bytes(proc, payload, plen);
-	DBG(rap, "step[%u]: mode=0x%02x Mode0 payload_len=%u sent",
-		idx, mode_byte, (unsigned int)plen);
+	cs_pd_ras_append_subevent_bytes(proc, temp_iov.iov_base,
+					temp_iov.iov_len);
+
+done:
+	free(temp_iov.iov_base);
+
+	DBG(rap, "step[%u]: mode=0x%02x Mode0 serialized payload_len=%zu "
+		"role=%s",
+		idx, mode_byte, temp_iov.iov_len,
+		cs_role == CS_ROLE_INITIATOR ? "INIT" : "REFL");
 }
 
 static void process_cs_mode_one(struct bt_rap *rap,
Signature · 1 line
2.34.1
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1113283

---Test result---

Test Summary:

CheckPatch                    PASS      0.30 seconds
GitLint                       PASS      0.20 seconds
BuildEll                      PASS      20.73 seconds
BluezMake                     PASS      658.34 seconds
MakeCheck                     PASS      0.95 seconds
MakeDistcheck                 PASS      246.72 seconds
CheckValgrind                 PASS      222.75 seconds
CheckSmatch                   PASS      350.52 seconds
bluezmakeextell               PASS      185.67 seconds
IncrementalBuild              PASS      663.38 seconds
ScanBuild                     PASS      1039.96 seconds

https://github.com/bluez/bluez/pull/2239

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Prathibha Madugonde
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 8 lines · On Thu, 18 Jun 2026 13:25:29 +0530 you wrote:

From: Prathibha Madugonde <[email protected]>

Replace raw struct byte dump with field-by-field serialization that conditionally includes init_measured_freq_offset only for the Initiator role, matching the RAS wire format (5 bytes for Initiator, 3 bytes for Reflector)

[...]

Here is the summary with links:
- [BlueZ,v1] shared/rap: Fix Mode 0 step serialization

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=9305ae767ac4

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html