Bluetooth: Refactor bt_conn struct
Isolates existing LE connection specific attributes and prepares for now empty BR/EDR specific connection internals. Change-Id: Ib423306fbf60e8451998e3933aee00cb672a1106 Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
parent
f3f63d0fb0
commit
555d0d2594
5 changed files with 83 additions and 75 deletions
|
@ -97,14 +97,14 @@ void bt_conn_identity_resolved(struct bt_conn *conn)
|
|||
struct bt_conn_cb *cb;
|
||||
|
||||
if (conn->role == BT_HCI_ROLE_MASTER) {
|
||||
rpa = &conn->resp_addr;
|
||||
rpa = &conn->le.resp_addr;
|
||||
} else {
|
||||
rpa = &conn->init_addr;
|
||||
rpa = &conn->le.init_addr;
|
||||
}
|
||||
|
||||
for (cb = callback_list; cb; cb = cb->_next) {
|
||||
if (cb->identity_resolved) {
|
||||
cb->identity_resolved(conn, rpa, &conn->dst);
|
||||
cb->identity_resolved(conn, rpa, &conn->le.dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ static int start_security(struct bt_conn *conn)
|
|||
{
|
||||
struct bt_keys *keys;
|
||||
|
||||
keys = bt_keys_find(BT_KEYS_LTK, &conn->dst);
|
||||
keys = bt_keys_find(BT_KEYS_LTK, &conn->le.dst);
|
||||
if (!keys) {
|
||||
return bt_smp_send_pairing_req(conn);
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ struct bt_conn *bt_conn_add(const bt_addr_le_t *peer)
|
|||
memset(conn, 0, sizeof(*conn));
|
||||
|
||||
atomic_set(&conn->ref, 1);
|
||||
bt_addr_le_copy(&conn->dst, peer);
|
||||
bt_addr_le_copy(&conn->le.dst, peer);
|
||||
#if defined(CONFIG_BLUETOOTH_SMP)
|
||||
conn->sec_level = BT_SECURITY_LOW;
|
||||
conn->required_sec_level = BT_SECURITY_LOW;
|
||||
|
@ -579,7 +579,7 @@ struct bt_conn *bt_conn_lookup_addr_le(const bt_addr_le_t *peer)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!bt_addr_le_cmp(peer, &conns[i].dst)) {
|
||||
if (!bt_addr_le_cmp(peer, &conns[i].le.dst)) {
|
||||
return bt_conn_ref(&conns[i]);
|
||||
}
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ struct bt_conn *bt_conn_lookup_state(const bt_addr_le_t *peer,
|
|||
}
|
||||
|
||||
if (bt_addr_le_cmp(peer, BT_ADDR_LE_ANY) &&
|
||||
bt_addr_le_cmp(peer, &conns[i].dst)) {
|
||||
bt_addr_le_cmp(peer, &conns[i].le.dst)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -628,7 +628,7 @@ void bt_conn_unref(struct bt_conn *conn)
|
|||
|
||||
const bt_addr_le_t *bt_conn_get_dst(const struct bt_conn *conn)
|
||||
{
|
||||
return &conn->dst;
|
||||
return &conn->le.dst;
|
||||
}
|
||||
|
||||
void bt_conn_set_auto_conn(struct bt_conn *conn, bool auto_conn)
|
||||
|
|
|
@ -31,15 +31,22 @@ enum {
|
|||
BT_CONN_AUTO_CONNECT,
|
||||
};
|
||||
|
||||
struct bt_conn {
|
||||
uint16_t handle;
|
||||
uint8_t role;
|
||||
atomic_t flags[1];
|
||||
|
||||
struct bt_conn_le {
|
||||
bt_addr_le_t dst;
|
||||
|
||||
bt_addr_le_t init_addr;
|
||||
bt_addr_le_t resp_addr;
|
||||
uint8_t conn_interval;
|
||||
uint8_t features[8];
|
||||
};
|
||||
|
||||
struct bt_conn_br {
|
||||
};
|
||||
|
||||
struct bt_conn {
|
||||
uint16_t handle;
|
||||
uint8_t role;
|
||||
atomic_t flags[1];
|
||||
|
||||
uint8_t pending_pkts;
|
||||
|
||||
|
@ -60,8 +67,6 @@ struct bt_conn {
|
|||
/* L2CAP channels */
|
||||
void *channels;
|
||||
|
||||
uint8_t le_conn_interval;
|
||||
|
||||
atomic_t ref;
|
||||
|
||||
bt_conn_state_t state;
|
||||
|
@ -69,7 +74,10 @@ struct bt_conn {
|
|||
/* Handle allowing to cancel timeout fiber */
|
||||
void *timeout;
|
||||
|
||||
uint8_t le_features[8];
|
||||
union {
|
||||
struct bt_conn_le le;
|
||||
struct bt_conn_br br;
|
||||
};
|
||||
|
||||
/* Stack for TX fiber and timeout fiber.
|
||||
* Since these fibers don't overlap, one stack can be used by
|
||||
|
|
|
@ -244,7 +244,7 @@ int bt_gatt_attr_read_ccc(struct bt_conn *conn,
|
|||
size_t i;
|
||||
|
||||
for (i = 0; i < ccc->cfg_len; i++) {
|
||||
if (bt_addr_le_cmp(&ccc->cfg[i].peer, &conn->dst)) {
|
||||
if (bt_addr_le_cmp(&ccc->cfg[i].peer, &conn->le.dst)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -297,14 +297,14 @@ int bt_gatt_attr_write_ccc(struct bt_conn *conn,
|
|||
return -EFBIG;
|
||||
}
|
||||
|
||||
if (bt_keys_find_addr(&conn->dst))
|
||||
if (bt_keys_find_addr(&conn->le.dst))
|
||||
bonded = true;
|
||||
else
|
||||
bonded = false;
|
||||
|
||||
for (i = 0; i < ccc->cfg_len; i++) {
|
||||
/* Check for existing configuration */
|
||||
if (!bt_addr_le_cmp(&ccc->cfg[i].peer, &conn->dst)) {
|
||||
if (!bt_addr_le_cmp(&ccc->cfg[i].peer, &conn->le.dst)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ int bt_gatt_attr_write_ccc(struct bt_conn *conn,
|
|||
for (i = 0; i < ccc->cfg_len; i++) {
|
||||
/* Check for unused configuration */
|
||||
if (!ccc->cfg[i].valid) {
|
||||
bt_addr_le_copy(&ccc->cfg[i].peer, &conn->dst);
|
||||
bt_addr_le_copy(&ccc->cfg[i].peer, &conn->le.dst);
|
||||
/* Only set valid if bonded */
|
||||
ccc->cfg[i].valid = bonded;
|
||||
break;
|
||||
|
@ -466,7 +466,7 @@ static uint8_t connected_cb(const struct bt_gatt_attr *attr, void *user_data)
|
|||
|
||||
for (i = 0; i < ccc->cfg_len; i++) {
|
||||
/* Ignore configuration for different peer */
|
||||
if (bt_addr_le_cmp(&conn->dst, &ccc->cfg[i].peer)) {
|
||||
if (bt_addr_le_cmp(&conn->le.dst, &ccc->cfg[i].peer)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -509,7 +509,7 @@ static uint8_t disconnected_cb(const struct bt_gatt_attr *attr, void *user_data)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (bt_addr_le_cmp(&conn->dst, &ccc->cfg[i].peer)) {
|
||||
if (bt_addr_le_cmp(&conn->le.dst, &ccc->cfg[i].peer)) {
|
||||
struct bt_conn *tmp;
|
||||
|
||||
/* Skip if there is another peer connected */
|
||||
|
@ -566,7 +566,7 @@ static void remove_subscribtions(struct bt_conn *conn)
|
|||
/* Lookup existing subscriptions */
|
||||
for (params = subscriptions, prev = NULL; params;
|
||||
prev = params, params = params->_next) {
|
||||
if (bt_addr_le_cmp(¶ms->_peer, &conn->dst)) {
|
||||
if (bt_addr_le_cmp(¶ms->_peer, &conn->le.dst)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1343,7 +1343,7 @@ int bt_gatt_write(struct bt_conn *conn, uint16_t handle, uint16_t offset,
|
|||
static void gatt_subscription_add(struct bt_conn *conn,
|
||||
struct bt_gatt_subscribe_params *params)
|
||||
{
|
||||
bt_addr_le_copy(¶ms->_peer, &conn->dst);
|
||||
bt_addr_le_copy(¶ms->_peer, &conn->le.dst);
|
||||
|
||||
/* Prepend subscription */
|
||||
params->_next = subscriptions;
|
||||
|
@ -1412,7 +1412,7 @@ int bt_gatt_subscribe(struct bt_conn *conn, uint16_t handle,
|
|||
}
|
||||
|
||||
/* Check if another subscription exists */
|
||||
if (!bt_addr_le_cmp(&tmp->_peer, &conn->dst) &&
|
||||
if (!bt_addr_le_cmp(&tmp->_peer, &conn->le.dst) &&
|
||||
tmp->value_handle == params->value_handle &&
|
||||
tmp->value >= params->value) {
|
||||
has_subscription = true;
|
||||
|
@ -1458,7 +1458,7 @@ int bt_gatt_unsubscribe(struct bt_conn *conn, uint16_t handle,
|
|||
}
|
||||
|
||||
/* Check if there still remains any other subscription */
|
||||
if (!bt_addr_le_cmp(&tmp->_peer, &conn->dst) &&
|
||||
if (!bt_addr_le_cmp(&tmp->_peer, &conn->le.dst) &&
|
||||
tmp->value_handle == params->value_handle) {
|
||||
has_subscription = true;
|
||||
}
|
||||
|
@ -1519,7 +1519,7 @@ void bt_gatt_disconnected(struct bt_conn *conn)
|
|||
|
||||
#if defined(CONFIG_BLUETOOTH_GATT_CLIENT)
|
||||
/* If paired don't remove subscriptions */
|
||||
if (bt_keys_find_addr(&conn->dst)) {
|
||||
if (bt_keys_find_addr(&conn->le.dst)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -472,11 +472,11 @@ static int hci_le_read_remote_features(struct bt_conn *conn)
|
|||
|
||||
static int update_conn_params(struct bt_conn *conn)
|
||||
{
|
||||
BT_DBG("conn %p features 0x%x\n", conn, conn->le_features[0]);
|
||||
BT_DBG("conn %p features 0x%x\n", conn, conn->le.features[0]);
|
||||
|
||||
/* Check if there's a need to update conn params */
|
||||
if (conn->le_conn_interval >= LE_CONN_MIN_INTERVAL &&
|
||||
conn->le_conn_interval <= LE_CONN_MAX_INTERVAL) {
|
||||
if (conn->le.conn_interval >= LE_CONN_MIN_INTERVAL &&
|
||||
conn->le.conn_interval <= LE_CONN_MAX_INTERVAL) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,7 @@ static int update_conn_params(struct bt_conn *conn)
|
|||
return bt_l2cap_update_conn_param(conn);
|
||||
}
|
||||
|
||||
if ((conn->le_features[0] & BT_HCI_LE_CONN_PARAM_REQ_PROC) &&
|
||||
if ((conn->le.features[0] & BT_HCI_LE_CONN_PARAM_REQ_PROC) &&
|
||||
(bt_dev.le.features[0] & BT_HCI_LE_CONN_PARAM_REQ_PROC)) {
|
||||
return bt_conn_le_conn_update(conn, LE_CONN_MIN_INTERVAL,
|
||||
LE_CONN_MAX_INTERVAL,
|
||||
|
@ -540,8 +540,8 @@ static void le_conn_complete(struct net_buf *buf)
|
|||
}
|
||||
|
||||
conn->handle = handle;
|
||||
bt_addr_le_copy(&conn->dst, id_addr);
|
||||
conn->le_conn_interval = sys_le16_to_cpu(evt->interval);
|
||||
bt_addr_le_copy(&conn->le.dst, id_addr);
|
||||
conn->le.conn_interval = sys_le16_to_cpu(evt->interval);
|
||||
conn->role = evt->role;
|
||||
|
||||
src.type = BT_ADDR_LE_PUBLIC;
|
||||
|
@ -551,11 +551,11 @@ static void le_conn_complete(struct net_buf *buf)
|
|||
* or responder address
|
||||
*/
|
||||
if (conn->role == BT_HCI_ROLE_MASTER) {
|
||||
bt_addr_le_copy(&conn->init_addr, &src);
|
||||
bt_addr_le_copy(&conn->resp_addr, &evt->peer_addr);
|
||||
bt_addr_le_copy(&conn->le.init_addr, &src);
|
||||
bt_addr_le_copy(&conn->le.resp_addr, &evt->peer_addr);
|
||||
} else {
|
||||
bt_addr_le_copy(&conn->init_addr, &evt->peer_addr);
|
||||
bt_addr_le_copy(&conn->resp_addr, &src);
|
||||
bt_addr_le_copy(&conn->le.init_addr, &evt->peer_addr);
|
||||
bt_addr_le_copy(&conn->le.resp_addr, &src);
|
||||
}
|
||||
|
||||
bt_conn_set_state(conn, BT_CONN_CONNECTED);
|
||||
|
@ -588,8 +588,8 @@ static void le_remote_feat_complete(struct net_buf *buf)
|
|||
}
|
||||
|
||||
if (!evt->status) {
|
||||
memcpy(conn->le_features, evt->features,
|
||||
sizeof(conn->le_features));
|
||||
memcpy(conn->le.features, evt->features,
|
||||
sizeof(conn->le.features));
|
||||
}
|
||||
|
||||
update_conn_params(conn);
|
||||
|
@ -685,7 +685,7 @@ static void le_conn_update_complete(struct net_buf *buf)
|
|||
}
|
||||
|
||||
if (!evt->status) {
|
||||
conn->le_conn_interval = interval;
|
||||
conn->le.conn_interval = interval;
|
||||
}
|
||||
|
||||
/* TODO Notify about connection */
|
||||
|
@ -768,7 +768,7 @@ static void update_sec_level(struct bt_conn *conn)
|
|||
return;
|
||||
}
|
||||
|
||||
keys = bt_keys_find_addr(&conn->dst);
|
||||
keys = bt_keys_find_addr(&conn->le.dst);
|
||||
if (keys && keys->type == BT_KEYS_AUTHENTICATED) {
|
||||
conn->sec_level = BT_SECURITY_HIGH;
|
||||
} else {
|
||||
|
@ -856,7 +856,7 @@ static void le_ltk_request(struct net_buf *buf)
|
|||
}
|
||||
|
||||
if (!conn->keys) {
|
||||
conn->keys = bt_keys_find(BT_KEYS_SLAVE_LTK, &conn->dst);
|
||||
conn->keys = bt_keys_find(BT_KEYS_SLAVE_LTK, &conn->le.dst);
|
||||
}
|
||||
|
||||
if (conn->keys && (conn->keys->keys & BT_KEYS_SLAVE_LTK) &&
|
||||
|
|
|
@ -545,7 +545,7 @@ static uint8_t smp_request_tk(struct bt_smp *smp, uint8_t remote_io)
|
|||
* distributed in new pairing. This is to avoid replacing authenticated
|
||||
* keys with unauthenticated ones.
|
||||
*/
|
||||
keys = bt_keys_find_addr(&conn->dst);
|
||||
keys = bt_keys_find_addr(&conn->le.dst);
|
||||
if (keys && keys->type == BT_KEYS_AUTHENTICATED &&
|
||||
smp->method == JUST_WORKS) {
|
||||
BT_ERR("JustWorks failed, authenticated keys present\n");
|
||||
|
@ -726,8 +726,8 @@ static uint8_t smp_send_pairing_confirm(struct bt_smp *smp)
|
|||
|
||||
req = net_buf_add(rsp_buf, sizeof(*req));
|
||||
|
||||
err = smp_c1(smp->tk, smp->prnd, smp->preq, smp->prsp, &conn->init_addr,
|
||||
&conn->resp_addr, req->val);
|
||||
err = smp_c1(smp->tk, smp->prnd, smp->preq, smp->prsp,
|
||||
&conn->le.init_addr, &conn->le.resp_addr, req->val);
|
||||
if (err) {
|
||||
net_buf_unref(rsp_buf);
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
|
@ -932,8 +932,8 @@ static uint8_t smp_pairing_random(struct bt_smp *smp, struct net_buf *buf)
|
|||
|
||||
memcpy(smp->rrnd, req->val, sizeof(smp->rrnd));
|
||||
|
||||
err = smp_c1(smp->tk, smp->rrnd, smp->preq, smp->prsp, &conn->init_addr,
|
||||
&conn->resp_addr, cfm);
|
||||
err = smp_c1(smp->tk, smp->rrnd, smp->preq, smp->prsp,
|
||||
&conn->le.init_addr, &conn->le.resp_addr, cfm);
|
||||
if (err) {
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
@ -954,7 +954,7 @@ static uint8_t smp_pairing_random(struct bt_smp *smp, struct net_buf *buf)
|
|||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
keys = bt_keys_get_addr(&conn->dst);
|
||||
keys = bt_keys_get_addr(&conn->le.dst);
|
||||
if (!keys) {
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
@ -980,7 +980,7 @@ static uint8_t smp_pairing_random(struct bt_smp *smp, struct net_buf *buf)
|
|||
#endif /* CONFIG_BLUETOOTH_CENTRAL */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_PERIPHERAL)
|
||||
keys = bt_keys_get_type(BT_KEYS_SLAVE_LTK, &conn->dst);
|
||||
keys = bt_keys_get_type(BT_KEYS_SLAVE_LTK, &conn->le.dst);
|
||||
if (!keys) {
|
||||
BT_ERR("Unable to create new keys\n");
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
|
@ -1047,10 +1047,10 @@ static void bt_smp_distribute_keys(struct bt_smp *smp)
|
|||
struct bt_keys *keys;
|
||||
struct net_buf *buf;
|
||||
|
||||
keys = bt_keys_get_addr(&conn->dst);
|
||||
keys = bt_keys_get_addr(&conn->le.dst);
|
||||
if (!keys) {
|
||||
BT_ERR("Unable to look up keys for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
bt_addr_le_str(&conn->le.dst));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1146,10 +1146,10 @@ static uint8_t smp_encrypt_info(struct bt_smp *smp, struct net_buf *buf)
|
|||
|
||||
BT_DBG("\n");
|
||||
|
||||
keys = bt_keys_get_type(BT_KEYS_LTK, &conn->dst);
|
||||
keys = bt_keys_get_type(BT_KEYS_LTK, &conn->le.dst);
|
||||
if (!keys) {
|
||||
BT_ERR("Unable to get keys for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
bt_addr_le_str(&conn->le.dst));
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
|
@ -1168,10 +1168,10 @@ static uint8_t smp_master_ident(struct bt_smp *smp, struct net_buf *buf)
|
|||
|
||||
BT_DBG("\n");
|
||||
|
||||
keys = bt_keys_get_type(BT_KEYS_LTK, &conn->dst);
|
||||
keys = bt_keys_get_type(BT_KEYS_LTK, &conn->le.dst);
|
||||
if (!keys) {
|
||||
BT_ERR("Unable to get keys for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
bt_addr_le_str(&conn->le.dst));
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
|
@ -1208,10 +1208,10 @@ static uint8_t smp_ident_info(struct bt_smp *smp, struct net_buf *buf)
|
|||
|
||||
BT_DBG("\n");
|
||||
|
||||
keys = bt_keys_get_type(BT_KEYS_IRK, &conn->dst);
|
||||
keys = bt_keys_get_type(BT_KEYS_IRK, &conn->le.dst);
|
||||
if (!keys) {
|
||||
BT_ERR("Unable to get keys for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
bt_addr_le_str(&conn->le.dst));
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
|
@ -1233,14 +1233,14 @@ static uint8_t smp_ident_addr_info(struct bt_smp *smp, struct net_buf *buf)
|
|||
|
||||
if (!bt_addr_le_is_identity(&req->addr)) {
|
||||
BT_ERR("Invalid identity %s for %s\n",
|
||||
bt_addr_le_str(&req->addr), bt_addr_le_str(&conn->dst));
|
||||
bt_addr_le_str(&req->addr), bt_addr_le_str(&conn->le.dst));
|
||||
return BT_SMP_ERR_INVALID_PARAMS;
|
||||
}
|
||||
|
||||
keys = bt_keys_get_type(BT_KEYS_IRK, &conn->dst);
|
||||
keys = bt_keys_get_type(BT_KEYS_IRK, &conn->le.dst);
|
||||
if (!keys) {
|
||||
BT_ERR("Unable to get keys for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
bt_addr_le_str(&conn->le.dst));
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
|
@ -1249,9 +1249,9 @@ static uint8_t smp_ident_addr_info(struct bt_smp *smp, struct net_buf *buf)
|
|||
* re-pairing we wouldn't store IRK distributed in new pairing.
|
||||
*/
|
||||
if (conn->role == BT_HCI_ROLE_MASTER) {
|
||||
dst = &conn->resp_addr;
|
||||
dst = &conn->le.resp_addr;
|
||||
} else {
|
||||
dst = &conn->init_addr;
|
||||
dst = &conn->le.init_addr;
|
||||
}
|
||||
|
||||
if (bt_addr_le_is_rpa(dst)) {
|
||||
|
@ -1263,9 +1263,9 @@ static uint8_t smp_ident_addr_info(struct bt_smp *smp, struct net_buf *buf)
|
|||
* identity address. This may happen if IRK was present before
|
||||
* ie. due to re-pairing.
|
||||
*/
|
||||
if (!bt_addr_le_is_identity(&conn->dst)) {
|
||||
if (!bt_addr_le_is_identity(&conn->le.dst)) {
|
||||
bt_addr_le_copy(&keys->addr, &req->addr);
|
||||
bt_addr_le_copy(&conn->dst, &req->addr);
|
||||
bt_addr_le_copy(&conn->le.dst, &req->addr);
|
||||
|
||||
bt_conn_identity_resolved(conn);
|
||||
}
|
||||
|
@ -1300,10 +1300,10 @@ static uint8_t smp_signing_info(struct bt_smp *smp, struct net_buf *buf)
|
|||
|
||||
BT_DBG("\n");
|
||||
|
||||
keys = bt_keys_get_type(BT_KEYS_REMOTE_CSRK, &conn->dst);
|
||||
keys = bt_keys_get_type(BT_KEYS_REMOTE_CSRK, &conn->le.dst);
|
||||
if (!keys) {
|
||||
BT_ERR("Unable to get keys for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
bt_addr_le_str(&conn->le.dst));
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
|
@ -1341,7 +1341,7 @@ static uint8_t smp_security_request(struct bt_smp *smp, struct net_buf *buf)
|
|||
|
||||
BT_DBG("\n");
|
||||
|
||||
keys = bt_keys_find(BT_KEYS_LTK, &conn->dst);
|
||||
keys = bt_keys_find(BT_KEYS_LTK, &conn->le.dst);
|
||||
if (!keys) {
|
||||
goto pair;
|
||||
}
|
||||
|
@ -1514,7 +1514,7 @@ static void bt_smp_encrypt_change(struct bt_l2cap_chan *chan)
|
|||
* only keys distributed in this pairing will be used. This includes
|
||||
* STK as it will be replaced by LTK.
|
||||
*/
|
||||
keys = bt_keys_find_addr(&conn->dst);
|
||||
keys = bt_keys_find_addr(&conn->le.dst);
|
||||
if (keys) {
|
||||
bt_keys_clear(keys, BT_KEYS_ALL);
|
||||
}
|
||||
|
@ -1761,10 +1761,10 @@ int bt_smp_sign_verify(struct bt_conn *conn, struct net_buf *buf)
|
|||
/* Store signature incl. count */
|
||||
memcpy(sig, net_buf_tail(buf) - sizeof(sig), sizeof(sig));
|
||||
|
||||
keys = bt_keys_get_type(BT_KEYS_REMOTE_CSRK, &conn->dst);
|
||||
keys = bt_keys_get_type(BT_KEYS_REMOTE_CSRK, &conn->le.dst);
|
||||
if (!keys) {
|
||||
BT_ERR("Unable to get keys for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
bt_addr_le_str(&conn->le.dst));
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
|
@ -1779,13 +1779,13 @@ int bt_smp_sign_verify(struct bt_conn *conn, struct net_buf *buf)
|
|||
buf->len - sizeof(sig));
|
||||
if (err) {
|
||||
BT_ERR("Unable to create signature for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
bt_addr_le_str(&conn->le.dst));
|
||||
return -EIO;
|
||||
};
|
||||
|
||||
if (memcmp(sig, net_buf_tail(buf) - sizeof(sig), sizeof(sig))) {
|
||||
BT_ERR("Unable to verify signature for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
bt_addr_le_str(&conn->le.dst));
|
||||
return -EBADMSG;
|
||||
};
|
||||
|
||||
|
@ -1800,10 +1800,10 @@ int bt_smp_sign(struct bt_conn *conn, struct net_buf *buf)
|
|||
uint32_t cnt;
|
||||
int err;
|
||||
|
||||
keys = bt_keys_get_type(BT_KEYS_LOCAL_CSRK, &conn->dst);
|
||||
keys = bt_keys_get_type(BT_KEYS_LOCAL_CSRK, &conn->le.dst);
|
||||
if (!keys) {
|
||||
BT_ERR("Unable to get keys for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
bt_addr_le_str(&conn->le.dst));
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
|
@ -1820,7 +1820,7 @@ int bt_smp_sign(struct bt_conn *conn, struct net_buf *buf)
|
|||
err = smp_sign_buf(keys->local_csrk.val, buf->data, buf->len - 12);
|
||||
if (err) {
|
||||
BT_ERR("Unable to create signature for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
bt_addr_le_str(&conn->le.dst));
|
||||
return -EIO;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue