Bluetooth: controller: Keep track of IRK to RL indices

In order to associate a hit on the hardware IRK filtering with an entry
of the resolving list, add an array of correspondance between the IRKs
and the resolving list entries.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
Carles Cufi 2017-06-26 17:06:46 +02:00 committed by Johan Hedberg
commit 386c524f93

View file

@ -63,6 +63,7 @@ static struct rl_dev {
} rl[CONFIG_BLUETOOTH_CONTROLLER_RL_SIZE]; } rl[CONFIG_BLUETOOTH_CONTROLLER_RL_SIZE];
static u8_t peer_irks[CONFIG_BLUETOOTH_CONTROLLER_RL_SIZE][16]; static u8_t peer_irks[CONFIG_BLUETOOTH_CONTROLLER_RL_SIZE][16];
static u8_t peer_irk_rl_ids[CONFIG_BLUETOOTH_CONTROLLER_RL_SIZE];
static u8_t peer_irk_count; static u8_t peer_irk_count;
/* Hardware filter for the resolving list */ /* Hardware filter for the resolving list */
@ -566,7 +567,9 @@ u32_t ll_rl_add(bt_addr_le_t *id_addr, const u8_t pirk[16],
rl[i].pirk = mem_nz((u8_t *)pirk, 16); rl[i].pirk = mem_nz((u8_t *)pirk, 16);
rl[i].lirk = mem_nz((u8_t *)lirk, 16); rl[i].lirk = mem_nz((u8_t *)lirk, 16);
if (rl[i].pirk) { if (rl[i].pirk) {
/* cross-reference */
rl[i].pirk_idx = peer_irk_count; rl[i].pirk_idx = peer_irk_count;
peer_irk_rl_ids[peer_irk_count] = i;
memcpy(peer_irks[peer_irk_count++], pirk, 16); memcpy(peer_irks[peer_irk_count++], pirk, 16);
} }
if (rl[i].lirk) { if (rl[i].lirk) {
@ -614,10 +617,12 @@ u32_t ll_rl_remove(bt_addr_le_t *id_addr)
if (rl[k].taken && rl[k].pirk && if (rl[k].taken && rl[k].pirk &&
rl[k].pirk_idx == pj) { rl[k].pirk_idx == pj) {
rl[k].pirk_idx = pi; rl[k].pirk_idx = pi;
peer_irk_rl_ids[pi] = k;
break; break;
} }
} }
} }
peer_irk_count--;
} }
/* Check if referenced by a whitelist entry */ /* Check if referenced by a whitelist entry */