]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
Bluetooth: Send transport open and close monitor events
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 4 Oct 2015 21:34:03 +0000 (23:34 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 5 Oct 2015 07:30:49 +0000 (10:30 +0300)
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>
include/net/bluetooth/hci_mon.h
net/bluetooth/hci_sock.c

index 77d1e5764185acc0aea30c3cc4fc7eb2a3d79509..37e4283d1d6841256247e29627f28ebf0c1bf012 100644 (file)
@@ -39,6 +39,8 @@ struct hci_mon_hdr {
 #define HCI_MON_ACL_RX_PKT     5
 #define HCI_MON_SCO_TX_PKT     6
 #define HCI_MON_SCO_RX_PKT     7
+#define HCI_MON_OPEN_INDEX     8
+#define HCI_MON_CLOSE_INDEX    9
 
 struct hci_mon_new_index {
        __u8            type;
index d9ad68448173da4fe1be88348ed62a4641b41700..64ebe84989d1cea6b72bf252efd0f0637b5b7b7a 100644 (file)
@@ -329,6 +329,22 @@ static struct sk_buff *create_monitor_event(struct hci_dev *hdev, int event)
                opcode = cpu_to_le16(HCI_MON_DEL_INDEX);
                break;
 
+       case HCI_DEV_OPEN:
+               skb = bt_skb_alloc(0, GFP_ATOMIC);
+               if (!skb)
+                       return NULL;
+
+               opcode = cpu_to_le16(HCI_MON_OPEN_INDEX);
+               break;
+
+       case HCI_DEV_CLOSE:
+               skb = bt_skb_alloc(0, GFP_ATOMIC);
+               if (!skb)
+                       return NULL;
+
+               opcode = cpu_to_le16(HCI_MON_CLOSE_INDEX);
+               break;
+
        default:
                return NULL;
        }
@@ -358,6 +374,16 @@ static void send_monitor_replay(struct sock *sk)
 
                if (sock_queue_rcv_skb(sk, skb))
                        kfree_skb(skb);
+
+               if (!test_bit(HCI_RUNNING, &hdev->flags))
+                       continue;
+
+               skb = create_monitor_event(hdev, HCI_DEV_OPEN);
+               if (!skb)
+                       continue;
+
+               if (sock_queue_rcv_skb(sk, skb))
+                       kfree_skb(skb);
        }
 
        read_unlock(&hci_dev_list_lock);