-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add BPv7 and TCPCL layers #4824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hi there, thanks for your interest in Scapy ! Two quick things before I start a deeper review :
|
Also do not hesitate to run black on your files. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4824 +/- ##
==========================================
- Coverage 80.91% 80.87% -0.04%
==========================================
Files 366 371 +5
Lines 90130 90815 +685
==========================================
+ Hits 72927 73451 +524
- Misses 17203 17364 +161
🚀 New features to boost your workflow:
|
I removed the extra lines from I am reading the UTScapy documentation and will update the PR with unit tests when I figure everything out... |
Btw you can add dependencies for the tests over here Line 35 in 449142a
|
I added unit tests. I believe the runtime dependency import errors should be fixed now for the CI checks, and also the formatting / code quality checks and SPDX checks. |
|
return crcfun(pkt).to_bytes(size, "big"), crc_index | ||
|
||
|
||
class PacketFieldWithRemain(PacketField): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see why you did that, but this isn't how we usually do it.
PacketField
returns the remaining bytes only when they are contained in a Padding
layer. Typically you just have to add the following to the inner packet (which is contained in a PacketField)
def default_payload_class(self):
return conf.padding_layer
This isn't super intuitive, but you'll find many examples in Scapy.
scapy/scapy/layers/msrpce/ept.py
Lines 49 to 50 in 3363981
def default_payload_class(self, _): | |
return conf.padding_layer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi ! Sorry for the delay of reviewing !
It's looking pretty good although I have a few suggestions
), | ||
] | ||
|
||
def dissect(self, s: bytes): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain why you need this? Thanks
def __str__(self): | ||
return f"ipn:{self.node_id}.{self.service_number}" # noqa: E231 | ||
|
||
def __eq__(self, other): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expected this to work without __eq__
:/
return self.cls(decoded_m + remain) | ||
|
||
|
||
class CBORPacketFieldWithRemain(CBORPacketField): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, I think this could be worked around
from typing import List | ||
|
||
|
||
class Session: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this could be implemented using Scapy's "session", which allows users to have their own prn
while still performing actions when receiving a packet in a sniff
, rdpcap
or other packet source.
There's a bit of documentation here
https://scapy.readthedocs.io/en/latest/usage.html#advanced-sniffing-sniffing-sessions
and you can have a look at the source https://github.com/secdev/scapy/blob/master/scapy/sessions.py
Typically you can extend IPSession
if you want it to handle IP fragmentation, or TCPSession
(with a few tricks) to handle TCP reassembly. Feel free to ask if anything's unclear.
This PR adds two new layers to scapy/contrib, implementing the PDUs for the following Delay Tolerant Networking (DTN) protocols: TCP Convergence Layer version 4 (RFC 9174) and Bundle Protocol version 7 (RFC 9171) with support for BPSec (RFC 9172). These protocols are fundamental to the DTN suite and included in nearly all implementations of DTN, which is widely used by NASA, ESA, etc. for experimental purposes and research on internetworking in space communications.
Unit tests are currently not included in this PR but the code has been unit tested in NASA's dtn-test-framework repository, which depends on these two layers and is used internally at NASA for formal software requirements verification. If required by the maintainers, I am willing to modify and import these unit tests into Scapy.
The implementation of these layers depends on two Python libraries:
crcmod
for computing checksums andflynn
for decoding CBOR. I added some lines to thepyproject.toml
to provide these as optional dependencies. The layers are implemented in thescapy.contrib.dtn
directory and are otherwise self-contained. Please let me know if these optional dependencies or methods of organizing the code are not acceptable to the maintainers...