Skip to contentSkip to conversation

Bluetooth: Add support for HCI monitor channel

PATCH Applied Marcel Holtmann 2 participants 2 messages Feb 20, 2012

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH 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.

---
 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
index 1b634e1..60a4727 100644
@@ -1320,6 +1320,7 @@ struct sockaddr_hci {
 
 #define HCI_CHANNEL_RAW		0
 #define HCI_CHANNEL_CONTROL	1
+#define HCI_CHANNEL_MONITOR	2
 
 struct hci_filter {
 	unsigned long type_mask;
include/net/bluetooth/hci_core.h +1 -0
index 41adae5..094b5db 100644
@@ -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
index 4721728..87ff7ff 100644
@@ -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
#1 lore raw

Hi 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.

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