Commit 4227e3a8 authored by Marcel Holtmann's avatar Marcel Holtmann Committed by Marcel Holtmann

[Bluetooth] Add support for L2CAP secure mode

The secure mode requests an authentication and enables the encryption
for that connection. After the successful execution of these procedures
it triggers the generation of a new link key.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 09f68b67
......@@ -170,6 +170,8 @@ enum {
#define HCI_LM_AUTH 0x0002
#define HCI_LM_ENCRYPT 0x0004
#define HCI_LM_TRUSTED 0x0008
#define HCI_LM_RELIABLE 0x0010
#define HCI_LM_SECURE 0x0020
/* ----- HCI Commands ---- */
/* OGF & OCF values */
......
......@@ -56,6 +56,8 @@ struct l2cap_conninfo {
#define L2CAP_LM_AUTH 0x0002
#define L2CAP_LM_ENCRYPT 0x0004
#define L2CAP_LM_TRUSTED 0x0008
#define L2CAP_LM_RELIABLE 0x0010
#define L2CAP_LM_SECURE 0x0020
#define L2CAP_QOS 0x04
struct l2cap_qos {
......
......@@ -57,7 +57,7 @@
#define BT_DBG(D...)
#endif
#define VERSION "2.5"
#define VERSION "2.6"
static struct proto_ops l2cap_sock_ops;
......@@ -1428,7 +1428,8 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
sk->sk_state = BT_CONNECT2;
l2cap_pi(sk)->ident = cmd->ident;
if (l2cap_pi(sk)->link_mode & L2CAP_LM_ENCRYPT) {
if ((l2cap_pi(sk)->link_mode & L2CAP_LM_ENCRYPT) ||
(l2cap_pi(sk)->link_mode & L2CAP_LM_SECURE)) {
if (!hci_conn_encrypt(conn->hcon))
goto done;
} else if (l2cap_pi(sk)->link_mode & L2CAP_LM_AUTH) {
......@@ -1947,7 +1948,8 @@ static int l2cap_auth_cfm(struct hci_conn *hcon, u8 status)
bh_lock_sock(sk);
if (sk->sk_state != BT_CONNECT2 ||
(l2cap_pi(sk)->link_mode & L2CAP_LM_ENCRYPT)) {
(l2cap_pi(sk)->link_mode & L2CAP_LM_ENCRYPT) ||
(l2cap_pi(sk)->link_mode & L2CAP_LM_SECURE)) {
bh_unlock_sock(sk);
continue;
}
......@@ -2015,6 +2017,9 @@ static int l2cap_encrypt_cfm(struct hci_conn *hcon, u8 status)
l2cap_send_cmd(conn, l2cap_pi(sk)->ident,
L2CAP_CONN_RSP, sizeof(rsp), &rsp);
if (l2cap_pi(sk)->link_mode & L2CAP_LM_SECURE)
hci_conn_change_link_key(hcon);
bh_unlock_sock(sk);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment