Skip to content

Conversation

@polybassa
Copy link
Contributor

Usually, payloads are stored inside SOMEIP.data[0]. In the past I made this become a PacketListField, so that customizations for custom data interpretations can be added to the SOMEIP.get_payload_cls_by_srv_id().

However, this needs to be respected in the fragment function. This PR adds support for this custom handling. Also, there is still the possibility to use add_payload, which would create a SOMEIP/Raw packet. Therefore this changes will determine, if the payload is outside or inside the SOMEIP packet.

@codecov
Copy link

codecov bot commented Feb 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.12%. Comparing base (1dcad5d) to head (8f0978d).
Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4655      +/-   ##
==========================================
+ Coverage   81.53%   82.12%   +0.58%     
==========================================
  Files         359      359              
  Lines       86565    86583      +18     
==========================================
+ Hits        70582    71106     +524     
+ Misses      15983    15477     -506     
Files with missing lines Coverage Δ
scapy/contrib/automotive/someip.py 95.17% <100.00%> (+1.11%) ⬆️

... and 27 files with indirect coverage changes

gpotter2
gpotter2 previously approved these changes Feb 17, 2025
@gpotter2
Copy link
Member

Aw, conflicts :/

@polybassa
Copy link
Contributor Author

Aw, conflicts :/

fixed

Copy link
Member

@gpotter2 gpotter2 left a comment

Choose a reason for hiding this comment

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

Reading only this code and not the spec, I kinda feel like "data" could have been a Padding payload. It all in all seems a bit complicated.

If your fix fixes the issue, it's fine to merge it though.

@polybassa
Copy link
Contributor Author

The current implementation "tries" to do two things which are somewhat in conflict with each other.

  1. Multiple SOME/IP packets in one "frame" (Ether/IP/UDP/SOMEIP/SOMEIP/SOMEIP)
  2. Custom payload classes which should support dynamic import of definitions

To support multiple packets in one frame (1), #4632 was merged. This uses bind_layers of SOMEIP

Custom payload classes are supported by an explicit data field for which the callback can be overloaded dynamically:
https://github.com/polybassa/scapy-1/blob/6ae85f977f86e332cf6630049372de3f06ebe364/scapy/contrib/automotive/someip.py#L129

By moving the data field in the padding payload, we would need to call bind_layers(SOMEIP, A) for each specific payload time, which then would need to bind to SOMEIP again, to have multiple SOMEIP packets supported bind_layers(A, SOMEIP)

I would say, the current solution is more "straight forward". Do you see an alternative way of doing this?

polybassa and others added 2 commits February 25, 2025 09:16
Revert suggested change
Copy link
Member

@gpotter2 gpotter2 left a comment

Choose a reason for hiding this comment

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

Fine by me !

@polybassa polybassa merged commit bff1ea0 into secdev:master Feb 27, 2025
24 checks passed
abajk pushed a commit to abajk/scapy that referenced this pull request Feb 27, 2025
* Fix secdev#4651: Improve SOMEIP.fragment()

* fix flake
@gpotter2 gpotter2 added this to the 2.7.0 milestone Nov 2, 2025
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