aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/smp.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2013-05-14 11:05:12 -0400
committerMarcel Holtmann <marcel@holtmann.org>2013-12-05 10:05:33 -0500
commitad32a2f5ced269f5516950fc8f52b6673462d208 (patch)
treead0af02a62228b1be224483fa18432f6dcebb6ec /net/bluetooth/smp.c
parentf1496dee9cbde2a62821f4441dadb0d3360f60c3 (diff)
Bluetooth: Add smp_sufficient_security helper function
This function is needed both by the smp_conn_security function as well as upcoming code to check for the security requirements when receiving an L2CAP connect request over LE. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/smp.c')
-rw-r--r--net/bluetooth/smp.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index e61e74a1aabb..45007362683b 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -750,6 +750,17 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)
750 return 0; 750 return 0;
751} 751}
752 752
753bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level)
754{
755 if (sec_level == BT_SECURITY_LOW)
756 return true;
757
758 if (hcon->sec_level >= sec_level)
759 return true;
760
761 return false;
762}
763
753int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) 764int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
754{ 765{
755 struct l2cap_conn *conn = hcon->l2cap_data; 766 struct l2cap_conn *conn = hcon->l2cap_data;
@@ -761,10 +772,7 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
761 if (!test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags)) 772 if (!test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags))
762 return 1; 773 return 1;
763 774
764 if (sec_level == BT_SECURITY_LOW) 775 if (smp_sufficient_security(hcon, sec_level))
765 return 1;
766
767 if (hcon->sec_level >= sec_level)
768 return 1; 776 return 1;
769 777
770 if (hcon->link_mode & HCI_LM_MASTER) 778 if (hcon->link_mode & HCI_LM_MASTER)