Skip to content

Commit 7c6eb24

Browse files
Tronilcarlescufi
authored andcommitted
Bluetooth: Fix endianness handling for ext scan reports evt_type
evt_type is 16 bits and thus requires endianness conversion over HCI Signed-off-by: Troels Nilsson <[email protected]>
1 parent 9edd295 commit 7c6eb24

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

subsys/bluetooth/controller/hci/hci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6385,7 +6385,7 @@ static void le_ext_adv_legacy_report(struct pdu_data *pdu_data,
63856385
sep->num_reports = 1U;
63866386
adv_info = (void *)(((uint8_t *)sep) + sizeof(*sep));
63876387

6388-
adv_info->evt_type = evt_type_lookup[adv->type];
6388+
adv_info->evt_type = sys_cpu_to_le16((uint16_t)evt_type_lookup[adv->type]);
63896389

63906390
#if defined(CONFIG_BT_CTLR_PRIVACY)
63916391
if (rl_idx < ll_rl_size_get()) {
@@ -6576,7 +6576,7 @@ static void ext_adv_info_fill(uint8_t evt_type, uint8_t phy, uint8_t sec_phy,
65766576
sep->num_reports = 1U;
65776577
adv_info = (void *)(((uint8_t *)sep) + sizeof(*sep));
65786578

6579-
adv_info->evt_type = evt_type;
6579+
adv_info->evt_type = sys_cpu_to_le16((uint16_t)evt_type);
65806580

65816581
if (0) {
65826582
#if defined(CONFIG_BT_CTLR_PRIVACY)

subsys/bluetooth/host/scan.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,8 @@ static void create_ext_adv_info(struct bt_hci_evt_le_ext_advertising_info const
572572
scan_info->rssi = evt->rssi;
573573
scan_info->sid = evt->sid;
574574
scan_info->interval = sys_le16_to_cpu(evt->interval);
575-
scan_info->adv_type = get_adv_type(evt->evt_type);
576-
scan_info->adv_props = get_adv_props_extended(evt->evt_type);
575+
scan_info->adv_type = get_adv_type(sys_le16_to_cpu(evt->evt_type));
576+
scan_info->adv_props = get_adv_props_extended(sys_le16_to_cpu(evt->evt_type));
577577
}
578578

579579
void bt_hci_le_adv_ext_report(struct net_buf *buf)
@@ -586,6 +586,7 @@ void bt_hci_le_adv_ext_report(struct net_buf *buf)
586586
struct bt_hci_evt_le_ext_advertising_info *evt;
587587
struct bt_le_scan_recv_info scan_info;
588588
uint16_t data_status;
589+
uint16_t evt_type;
589590
bool is_report_complete;
590591
bool more_to_come;
591592
bool is_new_advertiser;
@@ -596,11 +597,12 @@ void bt_hci_le_adv_ext_report(struct net_buf *buf)
596597
}
597598

598599
evt = net_buf_pull_mem(buf, sizeof(*evt));
599-
data_status = BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS(evt->evt_type);
600+
evt_type = sys_le16_to_cpu(evt->evt_type);
601+
data_status = BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS(evt_type);
600602
is_report_complete = data_status == BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_COMPLETE;
601603
more_to_come = data_status == BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_PARTIAL;
602604

603-
if (evt->evt_type & BT_HCI_LE_ADV_EVT_TYPE_LEGACY) {
605+
if (evt_type & BT_HCI_LE_ADV_EVT_TYPE_LEGACY) {
604606
/* Legacy advertising reports are complete.
605607
* Create event immediately.
606608
*/

0 commit comments

Comments
 (0)