Skip to content

Commit

Permalink
Bluetooth: ISO: Add ISO BIS bitfield check macro
Browse files Browse the repository at this point in the history
Checks validity of ISO BIS bitfield (BIT(0)|...|BIT(30))

Signed-off-by: Lars Knudsen <LAKD@demant.com>
  • Loading branch information
larsgk committed Oct 9, 2024
1 parent 41e4b53 commit ad2b1bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions include/zephyr/bluetooth/iso.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ extern "C" {
/** Maximum pre-transmission offset */
#define BT_ISO_PTO_MAX 0x0FU

/**
* @brief Check if ISO BIS bitfield is valid (BT_ISO_BIS_INDEX_BIT(1)|..|BT_ISO_BIS_INDEX_BIT(31))
*
* @param _bis_bitfield BIS index bitfield (uint32)
*/
#define BT_ISO_VALID_BIS_BITFIELD(_bis_bitfield) \
((_bis_bitfield) != 0U && (_bis_bitfield) <= BIT_MASK(BT_ISO_BIS_INDEX_MAX))

/**
* @brief Life-span states of ISO channel. Used only by internal APIs dealing with setting channel
* to proper state depending on operational context.
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -3316,7 +3316,7 @@ int bt_iso_big_sync(struct bt_le_per_adv_sync *sync, struct bt_iso_big_sync_para
return -EINVAL;
}

CHECKIF(param->bis_bitfield == 0U || param->bis_bitfield > BIT_MASK(BT_ISO_BIS_INDEX_MAX)) {
CHECKIF(param->bis_bitfield == 0U || !BT_ISO_VALID_BIS_BITFIELD(param->bis_bitfield)) {
LOG_DBG("Invalid BIS bitfield 0x%08x", param->bis_bitfield);
return -EINVAL;
}
Expand Down

0 comments on commit ad2b1bf

Please sign in to comment.