diff mbox series

[BlueZ,1/4] btio: Bind listener to bcaster addr based on dst opt

Message ID 20231004153150.3051-2-iulia.tanasescu@nxp.com
State New
Headers show
Series Add BASS unit tests for the SPE suite | expand

Commit Message

Iulia Tanasescu Oct. 4, 2023, 3:31 p.m. UTC
This updates the btio module to decide whether to bind a listening socket
to a broadcaster address or not, by looking at the dst address.

---
 btio/btio.c          | 24 ++++++++++++++----------
 profiles/audio/bap.c |  4 ++--
 2 files changed, 16 insertions(+), 12 deletions(-)

Comments

bluez.test.bot@gmail.com Oct. 4, 2023, 5:29 p.m. UTC | #1
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=789981

---Test result---

Test Summary:
CheckPatch                    PASS      7.75 seconds
GitLint                       PASS      2.94 seconds
BuildEll                      PASS      29.11 seconds
BluezMake                     PASS      988.24 seconds
MakeCheck                     PASS      12.12 seconds
MakeDistcheck                 PASS      165.30 seconds
CheckValgrind                 PASS      264.72 seconds
CheckSmatch                   PASS      354.81 seconds
bluezmakeextell               PASS      110.69 seconds
IncrementalBuild              PASS      3537.44 seconds
ScanBuild                     PASS      1170.86 seconds



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/btio/btio.c b/btio/btio.c
index c6d056b89..d45b8240d 100644
--- a/btio/btio.c
+++ b/btio/btio.c
@@ -774,16 +774,21 @@  static int sco_bind(int sock, const bdaddr_t *src, GError **err)
 	return 0;
 }
 
-static int iso_bind(int sock, const bdaddr_t *src, uint8_t src_type,
-					const bdaddr_t *dst, uint8_t dst_type,
-					uint8_t bc_sid, uint8_t num_bis,
-					uint8_t *bis, GError **err)
+static int iso_bind(int sock, bool server, const bdaddr_t *src,
+					uint8_t src_type, const bdaddr_t *dst,
+					uint8_t dst_type, uint8_t bc_sid,
+					uint8_t num_bis, uint8_t *bis,
+					GError **err)
 {
 	struct sockaddr_iso *addr = NULL;
 	size_t addr_len;
 	int ret = 0;
 
-	if (num_bis)
+	/* If this is an ISO listener and the destination address
+	 * is not BDADDR_ANY, the listener should be bound to the
+	 * broadcaster address
+	 */
+	if (server && bacmp(dst, BDADDR_ANY))
 		addr_len = sizeof(*addr) + sizeof(*addr->iso_bc);
 	else
 		addr_len = sizeof(*addr);
@@ -798,7 +803,7 @@  static int iso_bind(int sock, const bdaddr_t *src, uint8_t src_type,
 	bacpy(&addr->iso_bdaddr, src);
 	addr->iso_bdaddr_type = src_type;
 
-	if (num_bis) {
+	if (addr_len > sizeof(*addr)) {
 		bacpy(&addr->iso_bc->bc_bdaddr, dst);
 		addr->iso_bc->bc_bdaddr_type = dst_type;
 		addr->iso_bc->bc_sid = bc_sid;
@@ -1930,10 +1935,9 @@  static GIOChannel *create_io(gboolean server, struct set_opts *opts,
 			return NULL;
 		}
 
-		if (iso_bind(sock, &opts->src, opts->src_type,
-				 &opts->dst, opts->dst_type,
-				 opts->bc_sid, opts->bc_num_bis,
-				 opts->bc_bis, err) < 0)
+		if (iso_bind(sock, server, &opts->src, opts->src_type,
+				 &opts->dst, opts->dst_type, opts->bc_sid,
+				 opts->bc_num_bis, opts->bc_bis, err) < 0)
 			goto failed;
 		if (!iso_set_qos(sock, &opts->qos, err))
 			goto failed;
diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index d70ad872e..cab68f779 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -1566,9 +1566,9 @@  static void bap_listen_io(struct bap_data *data, struct bt_bap_stream *stream,
 				BT_IO_OPT_SOURCE_BDADDR,
 				btd_adapter_get_address(adapter),
 				BT_IO_OPT_DEST_BDADDR,
-				device_get_address(data->device),
+				BDADDR_ANY,
 				BT_IO_OPT_DEST_TYPE,
-				device_get_le_address_type(data->device),
+				BDADDR_LE_PUBLIC,
 				BT_IO_OPT_MODE, BT_IO_MODE_ISO,
 				BT_IO_OPT_QOS, qos,
 				BT_IO_OPT_INVALID);