From 9ec6fb87c98da986c6286d023325168109df76c3 Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Fri, 20 Mar 2020 16:20:17 +0100 Subject: [PATCH] Bluetooth: host: Fix directed advertiser for multiple local identities Fix directed advertiser using the wrong local IRK when doing directed advertising when the identity of the advertiser is not the default identity. This is only an issue for the directed advertiser because it is only for the directed advertiser that we use the controllers local IRK to generate the Advertisers RPA. Signed-off-by: Joakim Andersson --- subsys/bluetooth/host/hci_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index ea1eacbfe0e..aa8b6b71510 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -3051,7 +3051,7 @@ static int addr_res_enable(u8_t enable) buf, NULL); } -static int hci_id_add(const bt_addr_le_t *addr, u8_t val[16]) +static int hci_id_add(u8_t id, const bt_addr_le_t *addr, u8_t peer_irk[16]) { struct bt_hci_cp_le_add_dev_to_rl *cp; struct net_buf *buf; @@ -3065,10 +3065,10 @@ static int hci_id_add(const bt_addr_le_t *addr, u8_t val[16]) cp = net_buf_add(buf, sizeof(*cp)); bt_addr_le_copy(&cp->peer_id_addr, addr); - memcpy(cp->peer_irk, val, 16); + memcpy(cp->peer_irk, peer_irk, 16); #if defined(CONFIG_BT_PRIVACY) - memcpy(cp->local_irk, bt_dev.irk, 16); + memcpy(cp->local_irk, bt_dev.irk[id], 16); #else (void)memset(cp->local_irk, 0, 16); #endif @@ -3136,7 +3136,7 @@ void bt_id_add(struct bt_keys *keys) goto done; } - err = hci_id_add(&keys->addr, keys->irk.val); + err = hci_id_add(keys->id, &keys->addr, keys->irk.val); if (err) { BT_ERR("Failed to add IRK to controller"); goto done; @@ -3178,7 +3178,7 @@ done: static void keys_add_id(struct bt_keys *keys, void *data) { - hci_id_add(&keys->addr, keys->irk.val); + hci_id_add(keys->id, &keys->addr, keys->irk.val); } void bt_id_del(struct bt_keys *keys)