diff mbox series

[BlueZ,1/5] shared/bap: Fix handling for Company ID and Vendor Codec ID

Message ID 20221029170408.175533-2-abhay.maheshbhai.maheta@intel.com
State Superseded
Headers show
Series To add support for Metadata, CID, VID | expand

Commit Message

Abhay Maheta Oct. 29, 2022, 5:04 p.m. UTC
This adds fixes for handing for Company ID and Vendor Codec ID
while adding PAC record to database and responding to Attribute
Read Request for Sink/Source PAC Characteristics.
---
 src/shared/bap.c | 5 +++++
 src/shared/bap.h | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Luiz Augusto von Dentz Oct. 31, 2022, 8:48 p.m. UTC | #1
Hi Abhay,

On Sat, Oct 29, 2022 at 9:53 AM Abhay Maheta
<abhay.maheshbhai.maheta@intel.com> wrote:
>
> This adds fixes for handing for Company ID and Vendor Codec ID
> while adding PAC record to database and responding to Attribute
> Read Request for Sink/Source PAC Characteristics.
> ---
>  src/shared/bap.c | 5 +++++
>  src/shared/bap.h | 2 +-
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/shared/bap.c b/src/shared/bap.c
> index c3c0d596f..0ae0eba33 100644
> --- a/src/shared/bap.c
> +++ b/src/shared/bap.c
> @@ -416,6 +416,8 @@ static void pac_foreach(void *data, void *user_data)
>
>         p = iov_add(iov, sizeof(*p));
>         p->codec.id = pac->codec.id;

Lets check if the codec.id is 0xff before attempting to assign these
values, btw since they are le16 we need to use cpu_to_le16 when
assigning.

> +       p->codec.cid = pac->codec.cid;
> +       p->codec.vid = pac->codec.vid;
>
>         if (pac->data) {
>                 p->cc_len = pac->data->iov_len;
> @@ -2415,6 +2417,9 @@ struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db,
>         if (!bdb)
>                 return NULL;
>
> +       if ((id != 0xff) && ((cid != 0U)  || (vid != 0U)))
> +               return NULL;
> +
>         codec.id = id;
>         codec.cid = cid;
>         codec.vid = vid;
> diff --git a/src/shared/bap.h b/src/shared/bap.h
> index 7b9f88c83..923669f32 100644
> --- a/src/shared/bap.h
> +++ b/src/shared/bap.h
> @@ -39,8 +39,8 @@ struct bt_bap_stream;
>
>  struct bt_bap_codec {
>         uint8_t  id;
> -       uint16_t vid;
>         uint16_t cid;
> +       uint16_t vid;
>  } __packed;
>
>  struct bt_ltv {
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/src/shared/bap.c b/src/shared/bap.c
index c3c0d596f..0ae0eba33 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -416,6 +416,8 @@  static void pac_foreach(void *data, void *user_data)
 
 	p = iov_add(iov, sizeof(*p));
 	p->codec.id = pac->codec.id;
+	p->codec.cid = pac->codec.cid;
+	p->codec.vid = pac->codec.vid;
 
 	if (pac->data) {
 		p->cc_len = pac->data->iov_len;
@@ -2415,6 +2417,9 @@  struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db,
 	if (!bdb)
 		return NULL;
 
+	if ((id != 0xff) && ((cid != 0U)  || (vid != 0U)))
+		return NULL;
+
 	codec.id = id;
 	codec.cid = cid;
 	codec.vid = vid;
diff --git a/src/shared/bap.h b/src/shared/bap.h
index 7b9f88c83..923669f32 100644
--- a/src/shared/bap.h
+++ b/src/shared/bap.h
@@ -39,8 +39,8 @@  struct bt_bap_stream;
 
 struct bt_bap_codec {
 	uint8_t  id;
-	uint16_t vid;
 	uint16_t cid;
+	uint16_t vid;
 } __packed;
 
 struct bt_ltv {