Skip to content

Commit

Permalink
Bluetooth: Implemented HCI frame reassembly for RX from stream
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Suraj Sumangala authored and Marcel Holtmann committed Jul 21, 2010
1 parent f39a3c0 commit 9981151
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
35 changes: 35 additions & 0 deletions net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 9981151

Please sign in to comment.