Bluetooth: Implemented HCI frame reassembly for RX from stream
authorSuraj Sumangala <suraj@atheros.com>
Wed, 14 Jul 2010 07:32:19 +0000 (13:02 +0530)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 21 Jul 2010 17:39:12 +0000 (10:39 -0700)
Implemented frame reassembly implementation for reassembling fragments
received from stream.

Signed-off-by: Suraj Sumangala <suraj@atheros.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_core.c

index 28e5eeefdec8d70f00c65e0f05538890f933de0d..350b3e6964bd99838f10cee889e99813e5e1598f 100644 (file)
@@ -437,6 +437,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
 
 int hci_recv_frame(struct sk_buff *skb);
 int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count);
+int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count);
 
 int hci_register_sysfs(struct hci_dev *hdev);
 void hci_unregister_sysfs(struct hci_dev *hdev);
index 451e266840ad7a9a29a730cfdd63c41682d046c1..995c9f9b84d05635dd1b1be59794dd84cdce0a9e 100644 (file)
@@ -1163,6 +1163,41 @@ int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count)
 }
 EXPORT_SYMBOL(hci_recv_fragment);
 
+#define STREAM_REASSEMBLY 0
+
+int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count)
+{
+       int type;
+       int rem = 0;
+
+       do {
+               struct sk_buff *skb = hdev->reassembly[STREAM_REASSEMBLY];
+
+               if (!skb) {
+                       struct { char type; } *pkt;
+
+                       /* Start of the frame */
+                       pkt = data;
+                       type = pkt->type;
+
+                       data++;
+                       count--;
+               } else
+                       type = bt_cb(skb)->pkt_type;
+
+               rem = hci_reassembly(hdev, type, data,
+                                       count, STREAM_REASSEMBLY, GFP_ATOMIC);
+               if (rem < 0)
+                       return rem;
+
+               data += (count - rem);
+               count = rem;
+       } while (count);
+
+       return rem;
+}
+EXPORT_SYMBOL(hci_recv_stream_fragment);
+
 /* ---- Interface to upper protocols ---- */
 
 /* Register/Unregister protocols.