aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/bluetooth/hci_core.h2
-rw-r--r--include/net/bluetooth/mgmt.h12
-rw-r--r--net/bluetooth/hci_event.c16
-rw-r--r--net/bluetooth/mgmt.c20
4 files changed, 45 insertions, 5 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 009fa63a9048..746f8dc8aad1 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -714,6 +714,8 @@ int mgmt_powered(u16 index, u8 powered);
714int mgmt_discoverable(u16 index, u8 discoverable); 714int mgmt_discoverable(u16 index, u8 discoverable);
715int mgmt_connectable(u16 index, u8 connectable); 715int mgmt_connectable(u16 index, u8 connectable);
716int mgmt_new_key(u16 index, struct link_key *key, u8 old_key_type); 716int mgmt_new_key(u16 index, struct link_key *key, u8 old_key_type);
717int mgmt_connected(u16 index, bdaddr_t *bdaddr);
718int mgmt_disconnected(u16 index, bdaddr_t *bdaddr);
717 719
718/* HCI info for socket */ 720/* HCI info for socket */
719#define hci_pi(sk) ((struct hci_pinfo *) sk) 721#define hci_pi(sk) ((struct hci_pinfo *) sk)
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 56b500a2f68c..6719e9a36613 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -162,3 +162,15 @@ struct mgmt_ev_new_key {
162 struct mgmt_key_info key; 162 struct mgmt_key_info key;
163 __u8 old_key_type; 163 __u8 old_key_type;
164} __packed; 164} __packed;
165
166#define MGMT_EV_CONNECTED 0x000B
167struct mgmt_ev_connected {
168 __le16 index;
169 bdaddr_t bdaddr;
170} __packed;
171
172#define MGMT_EV_DISCONNECTED 0x000C
173struct mgmt_ev_disconnected {
174 __le16 index;
175 bdaddr_t bdaddr;
176} __packed;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 80ffd3a901fc..46ddb029912b 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1137,6 +1137,7 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
1137 conn->state = BT_CONFIG; 1137 conn->state = BT_CONFIG;
1138 hci_conn_hold(conn); 1138 hci_conn_hold(conn);
1139 conn->disc_timeout = HCI_DISCONN_TIMEOUT; 1139 conn->disc_timeout = HCI_DISCONN_TIMEOUT;
1140 mgmt_connected(hdev->id, &ev->bdaddr);
1140 } else 1141 } else
1141 conn->state = BT_CONNECTED; 1142 conn->state = BT_CONNECTED;
1142 1143
@@ -1269,13 +1270,18 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
1269 hci_dev_lock(hdev); 1270 hci_dev_lock(hdev);
1270 1271
1271 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 1272 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
1272 if (conn) { 1273 if (!conn)
1273 conn->state = BT_CLOSED; 1274 goto unlock;
1274 1275
1275 hci_proto_disconn_cfm(conn, ev->reason); 1276 conn->state = BT_CLOSED;
1276 hci_conn_del(conn); 1277
1277 } 1278 if (conn->type == ACL_LINK)
1279 mgmt_disconnected(hdev->id, &conn->dst);
1278 1280
1281 hci_proto_disconn_cfm(conn, ev->reason);
1282 hci_conn_del(conn);
1283
1284unlock:
1279 hci_dev_unlock(hdev); 1285 hci_dev_unlock(hdev);
1280} 1286}
1281 1287
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index bdb0e85f182e..7cf1968157d8 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1090,3 +1090,23 @@ int mgmt_new_key(u16 index, struct link_key *key, u8 old_key_type)
1090 1090
1091 return mgmt_event(MGMT_EV_NEW_KEY, &ev, sizeof(ev), NULL); 1091 return mgmt_event(MGMT_EV_NEW_KEY, &ev, sizeof(ev), NULL);
1092} 1092}
1093
1094int mgmt_connected(u16 index, bdaddr_t *bdaddr)
1095{
1096 struct mgmt_ev_connected ev;
1097
1098 put_unaligned_le16(index, &ev.index);
1099 bacpy(&ev.bdaddr, bdaddr);
1100
1101 return mgmt_event(MGMT_EV_CONNECTED, &ev, sizeof(ev), NULL);
1102}
1103
1104int mgmt_disconnected(u16 index, bdaddr_t *bdaddr)
1105{
1106 struct mgmt_ev_disconnected ev;
1107
1108 put_unaligned_le16(index, &ev.index);
1109 bacpy(&ev.bdaddr, bdaddr);
1110
1111 return mgmt_event(MGMT_EV_DISCONNECTED, &ev, sizeof(ev), NULL);
1112}