diff --git a/emulator/btdev.c b/emulator/btdev.c
index 0a5645c..7f4386e 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
}
}
+#define RL_ADDR_EQUAL(_rl, _type, _addr) \
+ (_rl->type == _type && !bacmp(&_rl->addr, (bdaddr_t *)_addr))
+
+static struct btdev_rl *rl_find(struct btdev *dev, uint8_t type, uint8_t *addr)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(dev->le_rl); i++) {
+ struct btdev_rl *rl = &dev->le_rl[i];
+
+ if (RL_ADDR_EQUAL(rl, type, addr))
+ return rl;
+ }
+
+ return NULL;
+}
+
static int cmd_set_adv_enable(struct btdev *dev, const void *data, uint8_t len)
{
const struct bt_hci_cmd_le_set_ext_adv_enable *cmd = data;
uint8_t status;
+ bool random_addr;
if (dev->le_adv_enable == cmd->enable) {
status = BT_HCI_ERR_COMMAND_DISALLOWED;
dev->le_adv_enable = cmd->enable;
status = BT_HCI_ERR_SUCCESS;
+ if (!cmd->enable)
+ goto done;
+
+ random_addr = bacmp((bdaddr_t *)dev->random_addr, BDADDR_ANY);
+
+ /* If Advertising_Enable is set to 0x01, the advertising parameters'
+ * Own_Address_Type parameter is set to 0x01, and the random address for
+ * the device has not been initialized, the Controller shall return the
+ * error code Invalid HCI Command Parameters (0x12).
+ */
+ if (dev->le_adv_own_addr == 0x01 && !random_addr) {
+ status = BT_HCI_ERR_INVALID_PARAMETERS;
+ goto done;
+ }
+
+ /* If Advertising_Enable is set to 0x01, the advertising parameters'
+ * Own_Address_Type parameter is set to 0x03, the controller's resolving
+ * list did not contain a matching entry, and the random address for the
+ * device has not been initialized, the Controller shall return the
+ * error code Invalid HCI Command Parameters (0x12).
+ */
+ if (dev->le_adv_own_addr == 0x03 && !random_addr) {
+ if (!dev->le_rl_enable ||
+ !rl_find(dev, dev->le_adv_direct_addr_type,
+ dev->le_adv_direct_addr)) {
+ status = BT_HCI_ERR_INVALID_PARAMETERS;
+ goto done;
+ }
+ }
+
done:
cmd_complete(dev, BT_HCI_CMD_LE_SET_ADV_ENABLE, &status,
sizeof(status));
goto done;
}
+ /* If LE_Scan_Enable is set to 0x01, the scanning parameters'
+ * Own_Address_Type parameter is set to 0x01 or 0x03, and the random
+ * address for the device has not been initialized, the Controller shall
+ * return the error code Invalid HCI Command Parameters (0x12).
+ */
+ if ((dev->le_scan_own_addr_type == 0x01 ||
+ dev->le_scan_own_addr_type == 0x03) &&
+ !bacmp((bdaddr_t *)dev->random_addr, BDADDR_ANY)) {
+ status = BT_HCI_ERR_INVALID_PARAMETERS;
+ goto done;
+ }
+
dev->le_scan_enable = cmd->enable;
dev->le_filter_dup = cmd->filter_dup;
status = BT_HCI_ERR_SUCCESS;
return 0;
}
-#define RL_ADDR_EQUAL(_rl, _type, _addr) \
- (_rl->type == _type && !bacmp(&_rl->addr, (bdaddr_t *)_addr))
-
static int cmd_add_rl(struct btdev *dev, const void *data, uint8_t len)
{
const struct bt_hci_cmd_le_add_to_resolv_list *cmd = data;
return false;
}
-static struct btdev_rl *rl_find(struct btdev *dev, uint8_t type, uint8_t *addr)
-{
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(dev->le_rl); i++) {
- struct btdev_rl *rl = &dev->le_rl[i];
-
- if (RL_ADDR_EQUAL(rl, type, addr))
- return rl;
- }
-
- return NULL;
-}
-
static int cmd_set_ext_adv_enable(struct btdev *dev, const void *data,
uint8_t len)
{
const struct bt_hci_cmd_le_set_ext_scan_enable *cmd = data;
uint8_t status;
- if (dev->le_scan_enable == cmd->enable)
+ if (dev->le_scan_enable == cmd->enable) {
status = BT_HCI_ERR_COMMAND_DISALLOWED;
- else {
- dev->le_scan_enable = cmd->enable;
- dev->le_filter_dup = cmd->filter_dup;
- status = BT_HCI_ERR_SUCCESS;
+ goto done;
+ }
+
+ /* If Enable is set to 0x01, the scanning parameters' Own_Address_Type
+ * parameter is set to 0x01 or 0x03, and the random address for the
+ * device has not been initialized, the Controller shall return the
+ * error code Invalid HCI Command Parameters (0x12).
+ */
+ if ((dev->le_scan_own_addr_type == 0x01 ||
+ dev->le_scan_own_addr_type == 0x03) &&
+ !bacmp((bdaddr_t *)dev->random_addr, BDADDR_ANY)) {
+ status = BT_HCI_ERR_INVALID_PARAMETERS;
+ goto done;
}
+ dev->le_scan_enable = cmd->enable;
+ dev->le_filter_dup = cmd->filter_dup;
+ status = BT_HCI_ERR_SUCCESS;
+
+done:
cmd_complete(dev, BT_HCI_CMD_LE_SET_EXT_SCAN_ENABLE, &status,
sizeof(status));
diff --git a/src/main.conf b/src/main.conf
index 1988995..791b0f9 100644
--- a/src/main.conf
+++ b/src/main.conf
# Possible values: "off", "device", "network"
# "network" option not supported currently
# Defaults to "off"
-# Privacy = off
+Privacy = device
# Specify the policy to the JUST-WORKS repairing initiated by peer
# Possible values: "never", "confirm", "always"
# Enables experimental features and interfaces.
# Defaults to false.
-#Experimental = false
+Experimental = true
[BR]
# The following values are used to load default adapter parameters for BR/EDR.