Lines Matching +full:key +full:- +full:int
1 /* keys_br.c - Bluetooth BR/EDR key handling */
4 * Copyright (c) 2015-2016 Intel Corporation
6 * SPDX-License-Identifier: Apache-2.0
38 struct bt_keys_link_key *key; in bt_keys_find_link_key() local
39 int i; in bt_keys_find_link_key()
44 key = &key_pool[i]; in bt_keys_find_link_key()
46 if (bt_addr_eq(&key->addr, addr)) { in bt_keys_find_link_key()
47 return key; in bt_keys_find_link_key()
56 struct bt_keys_link_key *key; in bt_keys_get_link_key() local
58 key = bt_keys_find_link_key(addr); in bt_keys_get_link_key()
59 if (key) { in bt_keys_get_link_key()
60 return key; in bt_keys_get_link_key()
63 key = bt_keys_find_link_key(BT_ADDR_ANY); in bt_keys_get_link_key()
65 if (!key) { in bt_keys_get_link_key()
66 int i; in bt_keys_get_link_key()
68 key = &key_pool[0]; in bt_keys_get_link_key()
72 if (current->aging_counter < key->aging_counter) { in bt_keys_get_link_key()
73 key = current; in bt_keys_get_link_key()
77 if (key) { in bt_keys_get_link_key()
78 bt_keys_link_key_clear(key); in bt_keys_get_link_key()
83 if (key) { in bt_keys_get_link_key()
84 bt_addr_copy(&key->addr, addr); in bt_keys_get_link_key()
86 key->aging_counter = ++aging_counter_val; in bt_keys_get_link_key()
87 last_keys_updated = key; in bt_keys_get_link_key()
89 LOG_DBG("created %p for %s", key, bt_addr_str(addr)); in bt_keys_get_link_key()
90 return key; in bt_keys_get_link_key()
104 bt_addr_copy(&le_addr.a, &link_key->addr); in bt_keys_link_key_clear()
109 LOG_DBG("%s", bt_addr_str(&link_key->addr)); in bt_keys_link_key_clear()
115 int i; in bt_keys_link_key_clear_addr()
116 struct bt_keys_link_key *key; in bt_keys_link_key_clear_addr() local
120 key = &key_pool[i]; in bt_keys_link_key_clear_addr()
121 bt_keys_link_key_clear(key); in bt_keys_link_key_clear_addr()
126 key = bt_keys_find_link_key(addr); in bt_keys_link_key_clear_addr()
127 if (key) { in bt_keys_link_key_clear_addr()
128 bt_keys_link_key_clear(key); in bt_keys_link_key_clear_addr()
135 int err; in bt_keys_link_key_store()
139 bt_addr_copy(&le_addr.a, &link_key->addr); in bt_keys_link_key_store()
141 err = bt_settings_store_link_key(&le_addr, link_key->storage_start, in bt_keys_link_key_store()
144 LOG_ERR("Failed to save link key (err %d)", err); in bt_keys_link_key_store()
155 const struct bt_keys_link_key *key = &key_pool[i]; in bt_foreach_bond_br() local
157 if (!bt_addr_eq(&key->addr, BT_ADDR_ANY)) { in bt_foreach_bond_br()
161 bt_addr_copy(&info.addr.a, &key->addr); in bt_foreach_bond_br()
169 static int link_key_set(const char *name, size_t len_rd, in link_key_set()
172 int err; in link_key_set()
180 return -EINVAL; in link_key_set()
186 return -EINVAL; in link_key_set()
194 return -EINVAL; in link_key_set()
209 memcpy(link_key->storage_start, val, len); in link_key_set()
210 LOG_DBG("Successfully restored link key for %s", bt_addr_le_str(&le_addr)); in link_key_set()
212 if (aging_counter_val < link_key->aging_counter) { in link_key_set()
213 aging_counter_val = link_key->aging_counter; in link_key_set()
236 link_key->aging_counter = ++aging_counter_val; in bt_keys_link_key_update_usage()
239 LOG_DBG("Aging counter for %s is set to %u", bt_addr_str(addr), link_key->aging_counter); in bt_keys_link_key_update_usage()