Bluetooth: Add support for HCI monitor channel
Subsystems (2)
Marcel Holtmann
maintainerPATCH 1/1 Bluetooth: Add support for HCI monitor channel
The HCI monitor channel can be used to monitor all packets and events from the Bluetooth subsystem. The monitor is not bound to any specific HCI device and allows even capturing multiple devices at the same time.
Signed-off-by Marcel Holtmann <[email protected]>
--- include/net/bluetooth/hci.h | 1 + include/net/bluetooth/hci_core.h | 1 + include/net/bluetooth/hci_mon.h | 51 +++++++++ net/bluetooth/hci_core.c | 13 ++- net/bluetooth/hci_sock.c | 207 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 270 insertions(+), 3 deletions(-) create mode 100644 include/net/bluetooth/hci_mon.h
include/net/bluetooth/hci.h +1 -0
@@ -1320,6 +1320,7 @@ struct sockaddr_hci {#define HCI_CHANNEL_RAW 0#define HCI_CHANNEL_CONTROL 1 +#define HCI_CHANNEL_MONITOR 2struct hci_filter {unsigned long type_mask;
include/net/bluetooth/hci_core.h +1 -0
@@ -950,6 +950,7 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode);/* ----- HCI Sockets ----- */ void hci_send_to_sock (struct hci_dev *hdev,struct sk_buff *skb);void hci_send_to_control (struct sk_buff *skb,struct sock *skip_sk); +void hci_send_to_monitor (struct hci_dev *hdev,struct sk_buff *skb);void hci_sock_dev_event (struct hci_dev *hdev,int event);
include/net/bluetooth/hci_mon.h new file +51 -0
51 lines not on this page · raw message
net/bluetooth/hci_core.c +10 -3
@@ -2113,10 +2113,14 @@ static int hci_send_frame(struct sk_buff *skb)BT_DBG ("%s type %d len %d" , hdev->name,bt_cb (skb)->pkt_type, skb->len); -if (atomic_read (&hdev->promisc)) { -/* Time stamp */ -__net_timestamp (skb); +/* Time stamp */ +__net_timestamp (skb); +/* Send copy to monitor */ +hci_send_to_monitor (hdev, skb); + +if (atomic_read (&hdev->promisc)) { +/* Send copy to the sockets */ hci_send_to_sock (hdev, skb); }
@@ -2802,6 +2806,9 @@ static void hci_rx_work(struct work_struct *work)BT_DBG ("%s" , hdev->name);while ((skb =skb_dequeue (&hdev->rx_q))) { +/* Send copy to monitor */ +hci_send_to_monitor (hdev, skb); +if (atomic_read (&hdev->promisc)) {/* Send copy to the sockets */ hci_send_to_sock (hdev, skb);
net/bluetooth/hci_sock.c +207 -0
252 lines not on this page · raw message
Signature · 1 line
1.7.7.6
Johan Hedberg
AppliedHi Marcel,
Quoted 5 lines · Marcel Holtmann
The HCI monitor channel can be used to monitor all packets and events from the Bluetooth subsystem. The monitor is not bound to any specific HCI device and allows even capturing multiple devices at the same time.
Signed-off-by Marcel Holtmann <[email protected]>
Quoted 8 lines
--- include/net/bluetooth/hci.h | 1 + include/net/bluetooth/hci_core.h | 1 + include/net/bluetooth/hci_mon.h | 51 +++++++++ net/bluetooth/hci_core.c | 13 ++- net/bluetooth/hci_sock.c | 207 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 270 insertions(+), 3 deletions(-) create mode 100644 include/net/bluetooth/hci_mon.h
Applied to my bluetooth-next tree. Thanks.
Johan