diff options
author | Vinicius Costa Gomes <vinicius.gomes@openbossa.org> | 2011-06-14 12:37:41 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-06-14 13:54:05 -0400 |
commit | 5d3de7df18077a0f508ae2c3e3f1866da65fdffd (patch) | |
tree | 7a52c5136964e89c80f1c26595603021ba29e2b9 /net/bluetooth/smp.c | |
parent | 94ac02726cb87dd569bac4536f33e4b696b692eb (diff) |
Bluetooth: Add support for SMP timeout
This patch adds support for disconnecting the link when SMP procedure
takes more than 30 seconds.
SMP begins when either the Pairing Request command is sent or the
Pairing Response is received, and it ends when the link is encrypted
(or terminated). Vol 3, Part H Section 3.4.
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/smp.c')
-rw-r--r-- | net/bluetooth/smp.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index dfd6891b9c86..39886786eb7f 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include <linux/crypto.h> | 27 | #include <linux/crypto.h> |
28 | #include <crypto/b128ops.h> | 28 | #include <crypto/b128ops.h> |
29 | 29 | ||
30 | #define SMP_TIMEOUT 30000 /* 30 seconds */ | ||
31 | |||
30 | static inline void swap128(u8 src[16], u8 dst[16]) | 32 | static inline void swap128(u8 src[16], u8 dst[16]) |
31 | { | 33 | { |
32 | int i; | 34 | int i; |
@@ -228,6 +230,9 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
228 | 230 | ||
229 | smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(*rp), rp); | 231 | smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(*rp), rp); |
230 | 232 | ||
233 | mod_timer(&conn->security_timer, jiffies + | ||
234 | msecs_to_jiffies(SMP_TIMEOUT)); | ||
235 | |||
231 | return 0; | 236 | return 0; |
232 | } | 237 | } |
233 | 238 | ||
@@ -303,6 +308,9 @@ static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb) | |||
303 | smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp); | 308 | smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp); |
304 | } | 309 | } |
305 | 310 | ||
311 | mod_timer(&conn->security_timer, jiffies + | ||
312 | msecs_to_jiffies(SMP_TIMEOUT)); | ||
313 | |||
306 | return 0; | 314 | return 0; |
307 | } | 315 | } |
308 | 316 | ||
@@ -382,6 +390,9 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
382 | 390 | ||
383 | smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); | 391 | smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); |
384 | 392 | ||
393 | mod_timer(&conn->security_timer, jiffies + | ||
394 | msecs_to_jiffies(SMP_TIMEOUT)); | ||
395 | |||
385 | set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->pend); | 396 | set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->pend); |
386 | 397 | ||
387 | return 0; | 398 | return 0; |
@@ -415,6 +426,9 @@ int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level) | |||
415 | conn->preq[0] = SMP_CMD_PAIRING_REQ; | 426 | conn->preq[0] = SMP_CMD_PAIRING_REQ; |
416 | memcpy(&conn->preq[1], &cp, sizeof(cp)); | 427 | memcpy(&conn->preq[1], &cp, sizeof(cp)); |
417 | 428 | ||
429 | mod_timer(&conn->security_timer, jiffies + | ||
430 | msecs_to_jiffies(SMP_TIMEOUT)); | ||
431 | |||
418 | smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); | 432 | smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); |
419 | } else { | 433 | } else { |
420 | struct smp_cmd_security_req cp; | 434 | struct smp_cmd_security_req cp; |