Bluetooth: Consolidate encryption handling in hci_encrypt_cfm
This makes hci_encrypt_cfm calls hci_connect_cfm in case the connection state is BT_CONFIG so callers don't have to check the state. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
a228f7a410
commit
3ca44c16b0
2 changed files with 21 additions and 27 deletions
|
@ -1381,10 +1381,26 @@ static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status)
|
||||||
conn->security_cfm_cb(conn, status);
|
conn->security_cfm_cb(conn, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status,
|
static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status)
|
||||||
__u8 encrypt)
|
|
||||||
{
|
{
|
||||||
struct hci_cb *cb;
|
struct hci_cb *cb;
|
||||||
|
__u8 encrypt;
|
||||||
|
|
||||||
|
if (conn->state == BT_CONFIG) {
|
||||||
|
if (status)
|
||||||
|
conn->state = BT_CONNECTED;
|
||||||
|
|
||||||
|
hci_connect_cfm(conn, status);
|
||||||
|
hci_conn_drop(conn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!test_bit(HCI_CONN_ENCRYPT, &conn->flags))
|
||||||
|
encrypt = 0x00;
|
||||||
|
else if (test_bit(HCI_CONN_AES_CCM, &conn->flags))
|
||||||
|
encrypt = 0x02;
|
||||||
|
else
|
||||||
|
encrypt = 0x01;
|
||||||
|
|
||||||
if (conn->sec_level == BT_SECURITY_SDP)
|
if (conn->sec_level == BT_SECURITY_SDP)
|
||||||
conn->sec_level = BT_SECURITY_LOW;
|
conn->sec_level = BT_SECURITY_LOW;
|
||||||
|
|
|
@ -2931,7 +2931,7 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
|
||||||
&cp);
|
&cp);
|
||||||
} else {
|
} else {
|
||||||
clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
|
clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
|
||||||
hci_encrypt_cfm(conn, ev->status, 0x00);
|
hci_encrypt_cfm(conn, ev->status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3016,22 +3016,7 @@ static void read_enc_key_size_complete(struct hci_dev *hdev, u8 status,
|
||||||
conn->enc_key_size = rp->key_size;
|
conn->enc_key_size = rp->key_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->state == BT_CONFIG) {
|
hci_encrypt_cfm(conn, 0);
|
||||||
conn->state = BT_CONNECTED;
|
|
||||||
hci_connect_cfm(conn, 0);
|
|
||||||
hci_conn_drop(conn);
|
|
||||||
} else {
|
|
||||||
u8 encrypt;
|
|
||||||
|
|
||||||
if (!test_bit(HCI_CONN_ENCRYPT, &conn->flags))
|
|
||||||
encrypt = 0x00;
|
|
||||||
else if (test_bit(HCI_CONN_AES_CCM, &conn->flags))
|
|
||||||
encrypt = 0x02;
|
|
||||||
else
|
|
||||||
encrypt = 0x01;
|
|
||||||
|
|
||||||
hci_encrypt_cfm(conn, 0, encrypt);
|
|
||||||
}
|
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock(hdev);
|
||||||
|
@ -3149,14 +3134,7 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
|
||||||
}
|
}
|
||||||
|
|
||||||
notify:
|
notify:
|
||||||
if (conn->state == BT_CONFIG) {
|
hci_encrypt_cfm(conn, ev->status);
|
||||||
if (!ev->status)
|
|
||||||
conn->state = BT_CONNECTED;
|
|
||||||
|
|
||||||
hci_connect_cfm(conn, ev->status);
|
|
||||||
hci_conn_drop(conn);
|
|
||||||
} else
|
|
||||||
hci_encrypt_cfm(conn, ev->status, ev->encrypt);
|
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock(hdev);
|
||||||
|
|
Loading…
Add table
Reference in a new issue