Skip to content

Commit

Permalink
Bluetooth: Controller: Define a macro to validate aux offset value
Browse files Browse the repository at this point in the history
Define a macro to validate aux offset value as it is checked
both in LLL and ULL execution contexts.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
  • Loading branch information
cvinayak authored and mmahadevan108 committed Sep 13, 2024
1 parent 9fa1860 commit 176d8ff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions subsys/bluetooth/controller/ll_sw/lll_scan_aux.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

#define AUX_OFFSET_IS_VALID(_offset_us, _win_size_us, _pdu_us) \
(((_offset_us) + (_win_size_us)) >= ((_pdu_us) + (EVENT_MAFS_US)))

int lll_scan_aux_init(void);
int lll_scan_aux_reset(void);
void lll_scan_aux_prepare(void *param);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ uint8_t lll_scan_aux_setup(struct pdu_adv *pdu, uint8_t pdu_phy,

/* Skip reception if invalid aux offset */
pdu_us = PDU_AC_US(pdu->len, pdu_phy, pdu_phy_flags_rx);
if (unlikely((aux_offset_us + window_size_us) < (pdu_us + EVENT_MAFS_US))) {
if (unlikely(!AUX_OFFSET_IS_VALID(aux_offset_us, window_size_us, pdu_us))) {
return 0U;
}

Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/controller/ll_sw/ull_scan_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_pdu *rx)

/* Skip reception if invalid aux offset */
pdu_us = PDU_AC_US(pdu->len, phy, ftr->phy_flags);
if (unlikely((aux_offset_us + window_size_us) < (pdu_us + EVENT_MAFS_US))) {
if (unlikely(!AUX_OFFSET_IS_VALID(aux_offset_us, window_size_us, pdu_us))) {
goto ull_scan_aux_rx_flush;
}

Expand Down

0 comments on commit 176d8ff

Please sign in to comment.