Skip to content

Introduce single-layer and compatibility modes for UDS, KWP, OBD, GMLAN#4962

Merged
polybassa merged 1 commit into
secdev:masterfrom
polybassa:add-single-layer-configuration-uds
Apr 24, 2026
Merged

Introduce single-layer and compatibility modes for UDS, KWP, OBD, GMLAN#4962
polybassa merged 1 commit into
secdev:masterfrom
polybassa:add-single-layer-configuration-uds

Conversation

@polybassa
Copy link
Copy Markdown
Contributor

Introduce single-layer and compatibility modes for UDS, KWP, OBD, and GMLAN protocols; add documentation and tests.

This bothered me for a while. When I started implementing the Automotive Application Layer protocols, I've somehow split them in two parts. For example -> UDS() / UDS_RDBI()

However, if we treat this correctly, it should be just one packet UDS_RDBI().

This PR introduces a single layer mode which can be turned on optionally. Also, I've created a compatibility mode that allows to mix both "styles". The compatibility mode will silently remove the service field in a subpacket. Since Scapy should be able to craft malformed packets as well, I made this compatibility mode a configuration option. So if someone wants to craft malformed packets, he can turn this mode off.

Maybe some day in the future, we can turn on the single layer mode by default and flag the dual layer mode as deprecated.

… GMLAN protocols; add documentation and tests.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.35%. Comparing base (9ae49f8) to head (b409ed5).
⚠️ Report is 13 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4962      +/-   ##
==========================================
+ Coverage   80.30%   80.35%   +0.04%     
==========================================
  Files         379      379              
  Lines       93164    93389     +225     
==========================================
+ Hits        74820    75042     +222     
- Misses      18344    18347       +3     
Files with missing lines Coverage Δ
scapy/contrib/automotive/gm/gmlan.py 99.18% <100.00%> (+0.16%) ⬆️
scapy/contrib/automotive/kwp.py 95.69% <100.00%> (+0.95%) ⬆️
scapy/contrib/automotive/obd/iid/iids.py 100.00% <100.00%> (ø)
scapy/contrib/automotive/obd/mid/mids.py 100.00% <100.00%> (ø)
scapy/contrib/automotive/obd/obd.py 97.53% <100.00%> (+1.37%) ⬆️
scapy/contrib/automotive/obd/pid/pids.py 100.00% <100.00%> (ø)
scapy/contrib/automotive/obd/pid/pids_00_1F.py 100.00% <ø> (ø)
scapy/contrib/automotive/obd/services.py 97.18% <100.00%> (+0.63%) ⬆️
scapy/contrib/automotive/obd/tid/tids.py 100.00% <100.00%> (ø)
scapy/contrib/automotive/uds.py 98.45% <100.00%> (+0.28%) ⬆️

... and 6 files with indirect coverage changes

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

@polybassa polybassa requested a review from gpotter2 April 12, 2026 18:04
@polybassa
Copy link
Copy Markdown
Contributor Author

@gpotter2 Please review.

@gpotter2
Copy link
Copy Markdown
Member

The code is good. You really went out of your way way to make it backwards compatible, which is nice, but maybe that wasn't necessary.

Honestly if it were me I would have just made UDS() an empty packet and not bother to allow much more. But the way you did it is nice too.

In any case, LGTM !

@polybassa
Copy link
Copy Markdown
Contributor Author

Thanks for your feedback. I wanted to have a "smooth" transition from the current way of using automotive application layer protocols to the more "scapy" way of using the protocol.

@polybassa polybassa merged commit 1745d39 into secdev:master Apr 24, 2026
24 checks passed
Copilot AI pushed a commit to BenGardiner/scapy that referenced this pull request Apr 27, 2026
… GMLAN protocols; add documentation and tests. (secdev#4962)

Co-authored-by: Nils Weiss <nils.weiss@dissecto.com>
Co-authored-by: BenGardiner <243321+BenGardiner@users.noreply.github.com>
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.

2 participants