J1939SoftSocket: expand edge-case unit tests, soft↔native interop coverage, and pgn filter#33
J1939SoftSocket: expand edge-case unit tests, soft↔native interop coverage, and pgn filter#33Copilot wants to merge 4 commits into
Conversation
Agent-Logs-Url: https://github.com/polybassa/scapy-1/sessions/f6a2a521-bf16-4a7f-8ec3-dc07974f9205 Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
Agent-Logs-Url: https://github.com/polybassa/scapy-1/sessions/c15c0b92-d1c7-4994-aa40-05efeb53734b Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
|
@copilot Analyze the J1939 SoftSocket implementation from BenGardiner:j1939_scanning https://github.com/secdev/scapy/pull/4961/changes#diff-5d6504c729d8bfec31ff30aec28e76f32ae70eba914b2338540fe2b13a221f34 Check for useful modifications |
…rmatting bugs Agent-Logs-Url: https://github.com/polybassa/scapy-1/sessions/95d8553e-8c55-4ebe-bc14-ae49e72e2006 Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
…back) Agent-Logs-Url: https://github.com/polybassa/scapy-1/sessions/95d8553e-8c55-4ebe-bc14-ae49e72e2006 Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
Analyzed PR secdev#4961. Summary of what BenGardiner's implementation adds over ours, and what we incorporated: Already in our implementation (confirmed equivalent):
Incorporated from BenGardiner's approach:
Not incorporated (out of scope / too complex for this PR):
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
Try different URL formats for BenGardiner's PRurls = [
|
Extends the
J1939SoftSockettest suite with boundary/error edge cases and richer interoperability scenarios againstNativeJ1939Socket. Also incorporates apgnfilter parameter inspired by BenGardiner'srx_pgnfrom PR #4961.New feature:
pgnfilter parameterAdds a
pgnkeyword argument to bothJ1939TPImplementationandJ1939SoftSocket(default0= accept all PGNs). When set to a non-zero value, only messages whose PGN matches are delivered — covering single-frame, BAM, and RTS/CTS sessions. Inspired by BenGardiner'srx_pgnparameter.Edge-case unit tests (TestSocket, no root)
J1939.priority(0/3/6/7) maps 1-to-1 to the CAN ID priority bits on the wiredata_page=1PGN – PGNs > 0xFFFF (e.g.0x1FECA) encoded in BAM payloadpgnfield; TP.CM CAN ID keepsdata_page=0per specCTS(num_packets=0)pauses sender; no DT emitted until a releasingCTS(count>0)arrivesrecv()after close – returnsNone, does not raisepgnfilter – matching PGN delivered; non-matching single-frame and BAM silently dropped;pgn=0accepts all PGNsInteroperability tests (vcan, needs_root)
dstfield verifiedNativeCANSocket(basecls=J1939_CAN)