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

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

 



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(-)

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);
-- 
2.39.2




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux