Skip to content

Commit f117505

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: controller: Fix to restrict addr set in active states
Fixed implementation to disallow setting Bluetooth device address under active advertising or scanning states. Fixes LL.TS.5.0.2 conformance tests: LL/CON/INI/BV-01-C [Connection Initiation] LL/SEC/ADV/BV-01-C [Advertising With Static Address] LL/SEC/SCN/BV-01-C [Random Address Scanning] Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent e8d40df commit f117505

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

subsys/bluetooth/controller/hci/hci.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,11 +696,12 @@ static void le_set_random_address(struct net_buf *buf, struct net_buf **evt)
696696
{
697697
struct bt_hci_cp_le_set_random_address *cmd = (void *)buf->data;
698698
struct bt_hci_evt_cc_status *ccst;
699+
u32_t status;
699700

700-
ll_addr_set(1, &cmd->bdaddr.val[0]);
701+
status = ll_addr_set(1, &cmd->bdaddr.val[0]);
701702

702703
ccst = cmd_complete(evt, sizeof(*ccst));
703-
ccst->status = 0x00;
704+
ccst->status = status;
704705
}
705706

706707
#if defined(CONFIG_BT_CTLR_FILTER)

subsys/bluetooth/controller/include/ll.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int ll_init(struct k_sem *sem_rx);
1212
void ll_reset(void);
1313

1414
u8_t *ll_addr_get(u8_t addr_type, u8_t *p_bdaddr);
15-
void ll_addr_set(u8_t addr_type, u8_t const *const p_bdaddr);
15+
u32_t ll_addr_set(u8_t addr_type, u8_t const *const p_bdaddr);
1616

1717
#if defined(CONFIG_BT_CTLR_ADV_EXT)
1818
u32_t ll_adv_params_set(u8_t handle, u16_t evt_prop, u32_t interval,

subsys/bluetooth/controller/ll_sw/ll_addr.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
#include <string.h>
99

1010
#include <zephyr/types.h>
11-
#include <toolchain.h>
11+
#include <bluetooth/hci.h>
12+
#include <misc/slist.h>
13+
14+
#include "util/util.h"
1215

1316
#include "ll_sw/pdu.h"
17+
#include "ll_sw/ctrl.h"
1418

1519
static u8_t pub_addr[BDADDR_SIZE];
1620
static u8_t rnd_addr[BDADDR_SIZE];
@@ -36,11 +40,17 @@ u8_t *ll_addr_get(u8_t addr_type, u8_t *bdaddr)
3640
return pub_addr;
3741
}
3842

39-
void ll_addr_set(u8_t addr_type, u8_t const *const bdaddr)
43+
u32_t ll_addr_set(u8_t addr_type, u8_t const *const bdaddr)
4044
{
45+
if (radio_adv_is_enabled() || radio_scan_is_enabled()) {
46+
return BT_HCI_ERR_CMD_DISALLOWED;
47+
}
48+
4149
if (addr_type) {
4250
memcpy(rnd_addr, bdaddr, BDADDR_SIZE);
4351
} else {
4452
memcpy(pub_addr, bdaddr, BDADDR_SIZE);
4553
}
54+
55+
return 0;
4656
}

0 commit comments

Comments
 (0)