Bluetooth: Add helper to iterate all key objects

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2017-10-03 14:57:03 +03:00 committed by Johan Hedberg
parent b452d6f348
commit 3993814e94
2 changed files with 14 additions and 0 deletions

View file

@ -50,6 +50,18 @@ struct bt_keys *bt_keys_get_addr(const bt_addr_le_t *addr)
return NULL;
}
void bt_keys_foreach(int type, void (*func)(struct bt_keys *keys))
{
int i;
for (i = 0; i < ARRAY_SIZE(key_pool); i++) {
if ((key_pool[i].keys & type)) {
func(&key_pool[i]);
}
}
}
struct bt_keys *bt_keys_find(int type, const bt_addr_le_t *addr)
{
int i;

View file

@ -59,6 +59,8 @@ struct bt_keys {
#endif /* CONFIG_BT_SMP_SC_ONLY */
};
void bt_keys_foreach(int type, void (*func)(struct bt_keys *keys));
struct bt_keys *bt_keys_get_addr(const bt_addr_le_t *addr);
struct bt_keys *bt_keys_get_type(int type, const bt_addr_le_t *addr);
struct bt_keys *bt_keys_find(int type, const bt_addr_le_t *addr);