Commit 6e2b996e authored by Vinayak Kariappa Chettimada's avatar Vinayak Kariappa Chettimada Committed by Anas Nashif
Browse files

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: default avatarVinayak Kariappa Chettimada <vich@nordicsemi.no>
parent 2cf4e4ce
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -696,11 +696,12 @@ static void le_set_random_address(struct net_buf *buf, struct net_buf **evt)
{
	struct bt_hci_cp_le_set_random_address *cmd = (void *)buf->data;
	struct bt_hci_evt_cc_status *ccst;
	u32_t status;

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

	ccst = cmd_complete(evt, sizeof(*ccst));
	ccst->status = 0x00;
	ccst->status = status;
}

static void le_read_wl_size(struct net_buf *buf, struct net_buf **evt)
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ void ll_reset(void);
void ll_radio_state_abort(void);
u32_t ll_radio_state_is_idle(void);
u8_t *ll_addr_get(u8_t addr_type, u8_t *p_bdaddr);
void ll_addr_set(u8_t addr_type, u8_t const *const p_bdaddr);
u32_t ll_addr_set(u8_t addr_type, u8_t const *const p_bdaddr);

#if defined(CONFIG_BT_CTLR_ADV_EXT)
u32_t ll_adv_params_set(u8_t handle, u16_t evt_prop, u32_t interval,
+7 −1
Original line number Diff line number Diff line
@@ -288,11 +288,17 @@ u8_t *ll_addr_get(u8_t addr_type, u8_t *bdaddr)
	return _ll_context.pub_addr;
}

void ll_addr_set(u8_t addr_type, u8_t const *const bdaddr)
u32_t ll_addr_set(u8_t addr_type, u8_t const *const bdaddr)
{
	if (radio_adv_is_enabled() || radio_scan_is_enabled()) {
		return BT_HCI_ERR_CMD_DISALLOWED;
	}

	if (addr_type) {
		memcpy(_ll_context.rnd_addr, bdaddr, BDADDR_SIZE);
	} else {
		memcpy(_ll_context.pub_addr, bdaddr, BDADDR_SIZE);
	}

	return 0;
}