aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2015-02-18 07:53:56 -0500
committerMarcel Holtmann <marcel@holtmann.org>2015-02-19 02:44:28 -0500
commit354fe804edb29625eee6dd7b1f3c72b43392704d (patch)
tree9fe25fcf417b8004ebe0a9bca904711ed6416a03 /include/net
parentfba7ecf09bc458b15f9d578e4213c8c349f9592d (diff)
Bluetooth: Convert L2CAP security callback to use hci_cb
There's no reason to have the custom hci_proto_auth/encrypt_cfm helpers when the hci_cb list works equally well. This patch adds L2CAP to the hci_cb list and makes l2cap_security_cfm a private function of l2cap_core.c. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/bluetooth/hci_core.h40
1 files changed, 6 insertions, 34 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 137a18226975..4a2db5e62699 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -506,7 +506,6 @@ int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr);
506void l2cap_connect_cfm(struct hci_conn *hcon, u8 status); 506void l2cap_connect_cfm(struct hci_conn *hcon, u8 status);
507int l2cap_disconn_ind(struct hci_conn *hcon); 507int l2cap_disconn_ind(struct hci_conn *hcon);
508void l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason); 508void l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason);
509int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt);
510int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags); 509int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags);
511 510
512int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags); 511int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags);
@@ -1107,35 +1106,6 @@ static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason)
1107 conn->disconn_cfm_cb(conn, reason); 1106 conn->disconn_cfm_cb(conn, reason);
1108} 1107}
1109 1108
1110static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status)
1111{
1112 __u8 encrypt;
1113
1114 if (conn->type != ACL_LINK && conn->type != LE_LINK)
1115 return;
1116
1117 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags))
1118 return;
1119
1120 encrypt = test_bit(HCI_CONN_ENCRYPT, &conn->flags) ? 0x01 : 0x00;
1121 l2cap_security_cfm(conn, status, encrypt);
1122
1123 if (conn->security_cfm_cb)
1124 conn->security_cfm_cb(conn, status);
1125}
1126
1127static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status,
1128 __u8 encrypt)
1129{
1130 if (conn->type != ACL_LINK && conn->type != LE_LINK)
1131 return;
1132
1133 l2cap_security_cfm(conn, status, encrypt);
1134
1135 if (conn->security_cfm_cb)
1136 conn->security_cfm_cb(conn, status);
1137}
1138
1139/* ----- HCI callbacks ----- */ 1109/* ----- HCI callbacks ----- */
1140struct hci_cb { 1110struct hci_cb {
1141 struct list_head list; 1111 struct list_head list;
@@ -1153,8 +1123,6 @@ static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status)
1153 struct hci_cb *cb; 1123 struct hci_cb *cb;
1154 __u8 encrypt; 1124 __u8 encrypt;
1155 1125
1156 hci_proto_auth_cfm(conn, status);
1157
1158 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) 1126 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags))
1159 return; 1127 return;
1160 1128
@@ -1166,6 +1134,9 @@ static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status)
1166 cb->security_cfm(conn, status, encrypt); 1134 cb->security_cfm(conn, status, encrypt);
1167 } 1135 }
1168 mutex_unlock(&hci_cb_list_lock); 1136 mutex_unlock(&hci_cb_list_lock);
1137
1138 if (conn->security_cfm_cb)
1139 conn->security_cfm_cb(conn, status);
1169} 1140}
1170 1141
1171static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, 1142static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status,
@@ -1179,14 +1150,15 @@ static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status,
1179 if (conn->pending_sec_level > conn->sec_level) 1150 if (conn->pending_sec_level > conn->sec_level)
1180 conn->sec_level = conn->pending_sec_level; 1151 conn->sec_level = conn->pending_sec_level;
1181 1152
1182 hci_proto_encrypt_cfm(conn, status, encrypt);
1183
1184 mutex_lock(&hci_cb_list_lock); 1153 mutex_lock(&hci_cb_list_lock);
1185 list_for_each_entry(cb, &hci_cb_list, list) { 1154 list_for_each_entry(cb, &hci_cb_list, list) {
1186 if (cb->security_cfm) 1155 if (cb->security_cfm)
1187 cb->security_cfm(conn, status, encrypt); 1156 cb->security_cfm(conn, status, encrypt);
1188 } 1157 }
1189 mutex_unlock(&hci_cb_list_lock); 1158 mutex_unlock(&hci_cb_list_lock);
1159
1160 if (conn->security_cfm_cb)
1161 conn->security_cfm_cb(conn, status);
1190} 1162}
1191 1163
1192static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status) 1164static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status)