Commit edca792c authored by Johan Hedberg's avatar Johan Hedberg Committed by Marcel Holtmann

Bluetooth: Add SMP flag to track which side is the initiator

For remotely initiated just-works pairings we want to show the user a
confirmation dialog for the pairing. However, we can only know which
side was the initiator by tracking which side sends the first Security
Request or Pairing Request PDU. This patch adds a new SMP flag to
indicate whether our side was the initiator for the pairing.
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 4eb65e66
...@@ -716,6 +716,8 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) ...@@ -716,6 +716,8 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
if (ret) if (ret)
return SMP_UNSPECIFIED; return SMP_UNSPECIFIED;
clear_bit(SMP_FLAG_INITIATOR, &smp->smp_flags);
return 0; return 0;
} }
...@@ -871,6 +873,8 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) ...@@ -871,6 +873,8 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)
smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp);
clear_bit(SMP_FLAG_INITIATOR, &smp->smp_flags);
return 0; return 0;
} }
...@@ -939,6 +943,8 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) ...@@ -939,6 +943,8 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
} }
done: done:
set_bit(SMP_FLAG_INITIATOR, &smp->smp_flags);
hcon->pending_sec_level = sec_level; hcon->pending_sec_level = sec_level;
return 0; return 0;
......
...@@ -120,6 +120,7 @@ struct smp_cmd_security_req { ...@@ -120,6 +120,7 @@ struct smp_cmd_security_req {
#define SMP_FLAG_MITM_AUTH 3 #define SMP_FLAG_MITM_AUTH 3
#define SMP_FLAG_LTK_ENCRYPT 4 #define SMP_FLAG_LTK_ENCRYPT 4
#define SMP_FLAG_COMPLETE 5 #define SMP_FLAG_COMPLETE 5
#define SMP_FLAG_INITIATOR 6
#define SMP_REENCRYPT_TIMEOUT msecs_to_jiffies(500) #define SMP_REENCRYPT_TIMEOUT msecs_to_jiffies(500)
......
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