Skip to content

Commit 2f86cff

Browse files
Pass the fd to underlying NativeCANSocket (#4158)
ISOTPSoftSocket should pass the fd (CanFD support) to the NativeCANSocket instance it creates. Otherwise it will always be created as non CanFD.
1 parent ba51704 commit 2f86cff

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

scapy/contrib/isotp/isotp_soft_socket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def __init__(self,
133133

134134
if LINUX and isinstance(can_socket, str):
135135
from scapy.contrib.cansocket_native import NativeCANSocket
136-
can_socket = NativeCANSocket(can_socket)
136+
can_socket = NativeCANSocket(can_socket, fd=fd)
137137
elif isinstance(can_socket, str):
138138
raise Scapy_Exception("Provide a CANSocket object instead")
139139

test/contrib/isotp_soft_socket.uts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ from scapy.layers.can import *
1111
from scapy.contrib.isotp import *
1212
from scapy.contrib.isotp.isotp_soft_socket import TimeoutScheduler
1313
from test.testsocket import TestSocket, cleanup_testsockets
14+
with open(scapy_path("test/contrib/automotive/interface_mockup.py")) as f:
15+
exec(f.read())
1416

1517
= Redirect logging
1618
import logging
@@ -58,6 +60,18 @@ assert sniffed[0]['ISOTP'].rx_ext_address == 0xEA
5860

5961
+ ISOTPSoftSocket tests
6062

63+
= CAN socket FD
64+
~ not_pypy needs_root linux vcan_socket
65+
66+
with ISOTPSoftSocket(iface0, tx_id=0x641, rx_id=0x241, fd=True) as s:
67+
assert s.impl.can_socket.fd == True
68+
69+
= CAN socket non-FD
70+
~ not_pypy needs_root linux vcan_socket
71+
72+
with ISOTPSoftSocket(iface0, tx_id=0x641, rx_id=0x241) as s:
73+
assert s.impl.can_socket.fd == False
74+
6175
= Single-frame receive
6276

6377
with TestSocket(CAN) as cans, TestSocket(CAN) as stim, ISOTPSoftSocket(cans, tx_id=0x641, rx_id=0x241) as s:

0 commit comments

Comments
 (0)