Skip to content

Fix BLE Link-Layer byte order - #5072

Open
sacca97 wants to merge 1 commit into
secdev:masterfrom
sacca97:master
Open

Fix BLE Link-Layer byte order#5072
sacca97 wants to merge 1 commit into
secdev:masterfrom
sacca97:master

Conversation

@sacca97

@sacca97 sacca97 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

The Bluetooth standard requires multi-octet Link Layer fields to transmit the least-significant octet first Vol 6, Part B, §1.2

Hence, BTLE_CONNECT_REQ, LL_CONNECTION_PARAM_REQ, LL_CONNECTION_PARAM_RSP, LL_PHY_UPDATE_IND, LL_CIS_REQ, LL_CIS_RSP, and LL_CIS_IND were changed accordingly.

AI-Assisted: no

@polybassa

Copy link
Copy Markdown
Contributor

Thanks for the PR. Please revert all formatting only changes to reduce our review effort.

@sacca97

sacca97 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

My bad. Done!

@polybassa

Copy link
Copy Markdown
Contributor

Please fix

'''
2026-08-03T22:17:43.2866695Z ##[group]Run bash ./.config/ci/check_commits.sh
2026-08-03T22:17:43.2869601Z �[36;1mbash ./.config/ci/check_commits.sh�[0m
2026-08-03T22:17:43.2917056Z shell: /usr/bin/bash -e {0}
2026-08-03T22:17:43.2918458Z env:
2026-08-03T22:17:43.2919300Z PR_FETCH_DEPTH: 5
2026-08-03T22:17:43.2920242Z ##[endgroup]
2026-08-03T22:17:43.3048446Z ERROR: Commit �[0;33m12a3bd2b9a5f057b558c5fd516a9b4a176e7ce6e�[0m is missing the 'AI-Assisted: yes|no [tool(s)]' trailer.
2026-08-03T22:17:43.3070904Z ERROR: Commit �[0;33mcf5ebe20c0caef20ffc6b4da0152a81abf5ac663�[0m is missing the 'AI-Assisted: yes|no [tool(s)]' trailer.
2026-08-03T22:17:43.3093760Z ERROR: Commit �[0;33m806929e1facb3f935b3fc11aa7a216733f466a67�[0m is missing the 'AI-Assisted: yes|no [tool(s)]' trailer.
2026-08-03T22:17:43.3116715Z ERROR: Commit �[0;33m4162425bca5ee74a8ff84672615d0b9f28be65bc�[0m is missing the 'AI-Assisted: yes|no [tool(s)]' trailer.
2026-08-03T22:17:43.3120101Z
2026-08-03T22:17:43.3121492Z �[0;31mPlease add the 'AI-Assisted' trailer to commit messages !�[0m
2026-08-03T22:17:43.3123997Z See the contribution guide at: https://github.com/secdev/scapy/blob/master/CONTRIBUTING.md
2026-08-03T22:17:43.3136660Z ##[error]Process completed with exit code 1.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request aligns Scapy’s Bluetooth LE Link Layer packet serialization with the Bluetooth Core spec requirement that multi-octet Link Layer fields are transmitted least-significant octet first (little-endian), correcting the on-the-wire byte order for several LL PDUs.

Changes:

  • Switched BTLE/LL packet fields in BTLE_CONNECT_REQ, LL_CONNECTION_PARAM_REQ/RSP, LL_PHY_UPDATE_IND, and LL_CIS_* to little-endian field types (XLE*).
  • Added/updated unit tests to assert the exact raw byte layouts for BTLE_CONNECT_REQ, LL_CONNECTION_PARAM_REQ/RSP, and LL_PHY_UPDATE_IND.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test/scapy/layers/bluetooth4LE.uts Adds raw byte-order assertions for several updated LL PDUs to prevent regressions.
scapy/layers/bluetooth4LE.py Corrects field endianness for multiple Link Layer PDUs by using little-endian field classes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

XLEShortField("max_pdu_p_to_c", 0),
XByteField("nse", 0),
X3BytesField("subinterval", 0x0),
XLE3BytesField("subinterval", 0x0),
The Bluetooth standard requires multi-octet Link Layer fields to transmit the least-significant octet first Vol 6, Part B, §1.2
Hence, BTLE_CONNECT_REQ, LL_CONNECTION_PARAM_REQ, LL_CONNECTION_PARAM_RSP, LL_PHY_UPDATE_IND, LL_CIS_REQ, LL_CIS_RSP, and LL_CIS_IND were changed accordingly.

AI-Assisted: no
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.50%. Comparing base (5e13d41) to head (e4810ab).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5072      +/-   ##
==========================================
- Coverage   80.50%   80.50%   -0.01%     
==========================================
  Files         390      390              
  Lines       96785    96785              
==========================================
- Hits        77920    77912       -8     
- Misses      18865    18873       +8     
Files with missing lines Coverage Δ
scapy/layers/bluetooth4LE.py 96.87% <ø> (ø)

... and 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants