Skip to content

Feature: CAN XL Support - #5152

Open
RB-FriedrichWiemer wants to merge 17 commits into
secdev:masterfrom
RB-FriedrichWiemer:feature/canxl-support
Open

RB-FriedrichWiemer wants to merge 17 commits into
secdev:masterfrom
RB-FriedrichWiemer:feature/canxl-support

Conversation

@RB-FriedrichWiemer

Copy link
Copy Markdown

Description

This is my first pull request to scapy.
It adds CAN XL support to the existing CAN layer, making use of the CAN XL implementation available on Linux' SocketCAN.

Introduce the CANXL class in scapy.layers.can, following the Linux
struct canxl_frame wire format and inheriting from the CAN class.
Provides additional ISO 11898-1:2024 property accessors and
show(style='11898-1') for ISO field-name rendering.

AI-Assisted: yes (Claude Opus and Sonnet)
AI-Assisted: yes (Claude Opus and Sonnet)
AI-Assisted: yes (Claude Opus and Sonnet)
Tests pass on Linux. On Windows, tests appear to timeout -- needs further investigation.

AI-Assisted: yes (Claude Opus and Sonnet)
Covers quick start, field naming (Linux vs ISO), byte-order handling, NativeCANSocket usage, can-utils interop, and known limitations.

AI-Assisted: yes (Claude Opus and Sonnet)
AI-Assisted: yes (Claude Opus and Sonnet)
@polybassa

Copy link
Copy Markdown
Contributor

Thanks for this PR. Please resolve the conflicts with the master.

Comment thread scapy/contrib/cansocket_native.py Outdated
Comment thread scapy/contrib/cansocket_native.py Outdated
Comment thread scapy/layers/can.py Outdated
Comment thread scapy/layers/can.py Outdated
Comment thread scapy/layers/can.py Outdated
Comment thread scapy/layers/can.py Outdated
Comment thread scapy/layers/can.py Outdated
Comment thread scapy/layers/can.py Outdated
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 47.82609% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.46%. Comparing base (c935a75) to head (87ae595).

Files with missing lines Patch % Lines
scapy/layers/can.py 42.57% 58 Missing ⚠️
scapy/contrib/cansocket_native.py 60.60% 13 Missing ⚠️
scapy/contrib/cansocket_python_can.py 75.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (c935a75) and HEAD (87ae595). Click for more details.

HEAD has 10 uploads less than BASE
Flag BASE (c935a75) HEAD (87ae595)
12 2
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #5152       +/-   ##
===========================================
- Coverage   80.96%   47.46%   -33.50%     
===========================================
  Files         390      372       -18     
  Lines       96994    96755      -239     
===========================================
- Hits        78530    45926    -32604     
- Misses      18464    50829    +32365     
Files with missing lines Coverage Δ
scapy/contrib/cansocket_python_can.py 79.79% <75.00%> (-4.59%) ⬇️
scapy/contrib/cansocket_native.py 67.88% <60.60%> (-10.69%) ⬇️
scapy/layers/can.py 38.12% <42.57%> (-54.98%) ⬇️

... and 340 files with indirect coverage changes

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

@RB-FriedrichWiemer RB-FriedrichWiemer changed the title [Draft] Feature: CAN XL Support Feature: CAN XL Support Sep 22, 2026
@pfasante

Copy link
Copy Markdown

the byte-swap for wireshark pcaps I still need to check

@polybassa polybassa 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.

Looks good. Let's check what wireshark does, then we can merge

@polybassa

Copy link
Copy Markdown
Contributor

Please fix the failing job.

pfasante and others added 8 commits September 26, 2026 00:29
AI-Assisted: no
Declare the CAN XL header as little endian via BitField's tot_size /
end_tot_size, LEShortField and XLEIntField, instead of swapping the
prio, length and af regions by hand. Removes CANXL.inv_endianness()
and the swap in pre_dissect() and post_build().

AI-Assisted: yes (Claude Opus and Sonnet)
post_dissect duplicated CAN.post_dissect, and the default
guess_payload_class already returns conf.raw_layer when no payload
class is bound.

AI-Assisted: yes (Claude Opus and Sonnet)
Keep Packet.show()'s signature unchanged and expose the ISO 11898-1
rendering as its own method.

AI-Assisted: yes (Claude Opus and Sonnet)
Use Packet.sprintf() for the fields it can resolve instead of
formatting each one against the color theme by hand. Format, FTYPE,
SEC and DLC are properties rather than fields, so they stay resolved
in Python.

AI-Assisted: yes (Claude Opus and Sonnet)
Both recv_raw() and send() open-coded the same four-byte swap that
CAN.inv_endianness() already performs. Also drops _is_canxl(), a
single-use wrapper around CANXL.is_canxl_frame().

AI-Assisted: yes (Claude Opus and Sonnet)
AI-Assisted: yes (Gemini 3.8 Flash)
@pfasante
pfasante force-pushed the feature/canxl-support branch from 99486a3 to ed1f066 Compare September 25, 2026 22:30
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