diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2015-10-04 17:34:03 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2015-10-05 03:30:49 -0400 |
commit | 22db3cbcf9f91eef848db0986869822b4bf27193 (patch) | |
tree | 9b6c6b0911f7d70214787e5e78ccf95831d96e3e | |
parent | e9ca8bf157f2b45f8f670517c96da313083ee9b2 (diff) |
Bluetooth: Send transport open and close monitor events
When the core starts or shuts down the actual HCI transport, send a new
monitor event that indicates that this is happening. These new events
correspond to HCI_DEV_OPEN and HCI_DEV_CLOSE events.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r-- | include/net/bluetooth/hci_mon.h | 2 | ||||
-rw-r--r-- | net/bluetooth/hci_sock.c | 26 |
2 files changed, 28 insertions, 0 deletions
diff --git a/include/net/bluetooth/hci_mon.h b/include/net/bluetooth/hci_mon.h index 77d1e5764185..37e4283d1d68 100644 --- a/include/net/bluetooth/hci_mon.h +++ b/include/net/bluetooth/hci_mon.h | |||
@@ -39,6 +39,8 @@ struct hci_mon_hdr { | |||
39 | #define HCI_MON_ACL_RX_PKT 5 | 39 | #define HCI_MON_ACL_RX_PKT 5 |
40 | #define HCI_MON_SCO_TX_PKT 6 | 40 | #define HCI_MON_SCO_TX_PKT 6 |
41 | #define HCI_MON_SCO_RX_PKT 7 | 41 | #define HCI_MON_SCO_RX_PKT 7 |
42 | #define HCI_MON_OPEN_INDEX 8 | ||
43 | #define HCI_MON_CLOSE_INDEX 9 | ||
42 | 44 | ||
43 | struct hci_mon_new_index { | 45 | struct hci_mon_new_index { |
44 | __u8 type; | 46 | __u8 type; |
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index d9ad68448173..64ebe84989d1 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
@@ -329,6 +329,22 @@ static struct sk_buff *create_monitor_event(struct hci_dev *hdev, int event) | |||
329 | opcode = cpu_to_le16(HCI_MON_DEL_INDEX); | 329 | opcode = cpu_to_le16(HCI_MON_DEL_INDEX); |
330 | break; | 330 | break; |
331 | 331 | ||
332 | case HCI_DEV_OPEN: | ||
333 | skb = bt_skb_alloc(0, GFP_ATOMIC); | ||
334 | if (!skb) | ||
335 | return NULL; | ||
336 | |||
337 | opcode = cpu_to_le16(HCI_MON_OPEN_INDEX); | ||
338 | break; | ||
339 | |||
340 | case HCI_DEV_CLOSE: | ||
341 | skb = bt_skb_alloc(0, GFP_ATOMIC); | ||
342 | if (!skb) | ||
343 | return NULL; | ||
344 | |||
345 | opcode = cpu_to_le16(HCI_MON_CLOSE_INDEX); | ||
346 | break; | ||
347 | |||
332 | default: | 348 | default: |
333 | return NULL; | 349 | return NULL; |
334 | } | 350 | } |
@@ -358,6 +374,16 @@ static void send_monitor_replay(struct sock *sk) | |||
358 | 374 | ||
359 | if (sock_queue_rcv_skb(sk, skb)) | 375 | if (sock_queue_rcv_skb(sk, skb)) |
360 | kfree_skb(skb); | 376 | kfree_skb(skb); |
377 | |||
378 | if (!test_bit(HCI_RUNNING, &hdev->flags)) | ||
379 | continue; | ||
380 | |||
381 | skb = create_monitor_event(hdev, HCI_DEV_OPEN); | ||
382 | if (!skb) | ||
383 | continue; | ||
384 | |||
385 | if (sock_queue_rcv_skb(sk, skb)) | ||
386 | kfree_skb(skb); | ||
361 | } | 387 | } |
362 | 388 | ||
363 | read_unlock(&hci_dev_list_lock); | 389 | read_unlock(&hci_dev_list_lock); |