Fix l2cap segmentation error in concurrent subscription#28
Open
davidalo wants to merge 11 commits intobettercap:masterfrom
Open
Fix l2cap segmentation error in concurrent subscription#28davidalo wants to merge 11 commits intobettercap:masterfrom
davidalo wants to merge 11 commits intobettercap:masterfrom
Conversation
This checks that the request is valid, replies to the other side in any event (with an accept/reject) and, if accepted, also updates the connection parameters to HCI.
…o copy the data buffer. The bug that otherwise happens is: 1. HCI.mainLoop gets a byte buffer, reads into it, calls handlePacket 2. handlePacket calls handleL2CAP, which unmarshals into an aclData. This aclData references the original b slice 3. handleL2CAP adds the aclData to a channel 4. handlePacket returns the buffer to the pool 5. Repeat from 1, getting the same buffer _while the aclData referencing it is still in the channel_ Triggering this needs a relatively high data rate, but was possible repeatedly for me with a Polar H10.
…rcap/gatt. NB: I still intend to drop this fork once I've got everything that I want working and any resulting pull requests to bettercap are merged.
…callee is checking for six bytes, but nobody was checking for 5 bytes :)
…ent sending in l2cap.conn.write to avoid sending unordered segments for the same l2cap channel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We are having some issues when we subscribe to different characteristics in the same server and get data from them simultaneously, we are getting corrupted packages.
After some research we discovered that the problem was in l2cap layer, segments were being mixed and this was causing reassembly inconsistencies.
When l2cap layer needs to fragment the packets, it seems this layer does not support unordered segments. With this patch we ensure these segments are sent in order for each upper-layer's packet.
As an example, we need to send two packets of 135 bytes, so l2cap layer needs to fragment it in 5 segments of 27 bytes.
On the other side, we would receive something like (P1=Packet1, P2=Packet2):
With this patch we aim to solve this. See orca-io@edd7ec2