Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions scapy/contrib/isotp.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,17 +664,11 @@ def run(self):
ins = self.socket

while 1:
pkts = ins.sniff(timeout=1, count=1)
if len(pkts) == 1:
cf = pkts[0]
else:
cf = None
ins.sniff(store=False, timeout=1,
Copy link
Member

Choose a reason for hiding this comment

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

Do you think you could remove the timeout, then the whole while loop, to simply use sniff ?

The stop_filter will take care of exiting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I understood the stop_filter, an exit can only happen, if a message is received.
If this is the case, I can not close the socket, if no further message is received. Sending a "fake message" just to trigger the execution of stop_filter inside close won't work, since I can not inject a message into the CAN socket.
Do you see a possibility to trigger the execution of stop_filter without a receive of a message?

Copy link
Member

Choose a reason for hiding this comment

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

Correct... I had a prototype #1523 of a such implementation, but that wasnt clean enough (now it's outdated).

I'll come back to you if i get any additional options available

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I would be happy, if I could avoid that timeout.

stop_filter=lambda x: self.exiting,
prn=self.callback)
if self.exiting:
return
if cf is None:
continue

self.callback(cf)

def stop(self):
self.exiting = True
Expand Down