can-utils
can-utils copied to clipboard
isotpsniffer: option for no quitting on invalid message received
Hello,
I was working with isotpsniffer, and found out that if invalid / incomplete / malformed iso tp message is received, isotpsniffer immediately quits:
┌──(kali㉿kali)-[~/can-utils]
└─$ ./isotpsniffer -s 1D9 -d 481 vcan0
read socket t: Invalid or incomplete multibyte or wide character
┌──(kali㉿kali)-[~/can-utils]
└─$
This wasn't desired behaviour, as I had to use malformed frames for target debugging purposes
This PR address this issue and adds additional command line option (-q) to continue receiving if read command returns -1
./isotpsniffer -s 1D9 -d 481 -q vcan0
read socket s: Invalid or incomplete multibyte or wide character
read socket t: Invalid or incomplete multibyte or wide character
vcan0 481 [6] 00 04 12 02 10 06 - '......'
vcan0 1D9 [6] 00 04 22 02 12 00 - '.."...'
vcan0 481 [16] 00 0E 12 0C 0A 0A 08 08 12 06 0A 04 52 BB 74 EF - '............R.t.'
vcan0 1D9 [14] 00 0C 22 0A 1A 08 12 06 0A 04 52 BB 74 EF - '..".......R.t.'
^C
┌──(kali㉿kali)-[~/can-utils]
As side effect, when socket is closed while isotpsniffer is working, isotpsniffer will NOT exit - that's why this is added as option, not default behaviour:
$ ./isotpsniffer -s 1D9 -d 481 -q vcan0
read socket s: Invalid or incomplete multibyte or wide character
read socket t: Invalid or incomplete multibyte or wide character
vcan0 481 [6] 00 04 12 02 10 06 - '......'
vcan0 1D9 [6] 00 04 22 02 12 00 - '.."...'
read socket t: Network is down
[continues to work. do not quit]
I see possibility to make decision about exit basing on errno value. What do you think about that? Any comments appreciated.
Sorry for the mess in this review. It was the first time where I not only added single comments but used the "start a review" button ...
Thanks for the contribution!
Provided changes you requested - sorry that it took so long
Sorry for the force push. It was non-intentional change, I've modified github actions script on my fork and forgot that it will go also to this PR (facepalm). Force push reverted it to previous state