-
Notifications
You must be signed in to change notification settings - Fork 714
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
isotpsniffer: option for no quitting on invalid message received #550
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,7 @@ void print_usage(char *prg) | |
fprintf(stderr, " -f <format> (1 = HEX, 2 = ASCII, 3 = HEX & ASCII - default: %d)\n", FORMAT_DEFAULT); | ||
fprintf(stderr, " -L (set link layer options for CAN FD)\n"); | ||
fprintf(stderr, " -h <len> (head: print only first <len> bytes)\n"); | ||
fprintf(stderr, " -q (don't quit on read error, allows to receive malformed frames)\n"); | ||
fprintf(stderr, "\nCAN IDs and addresses are given and expected in hexadecimal values.\n"); | ||
fprintf(stderr, "\n"); | ||
} | ||
|
@@ -189,6 +190,7 @@ int main(int argc, char **argv) | |
int head = 0; | ||
int timestamp = 0; | ||
int format = FORMAT_DEFAULT; | ||
int noquit = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To follow up with the '-i' option ignore_errors = 0 |
||
canid_t src = NO_CAN_ID; | ||
canid_t dst = NO_CAN_ID; | ||
extern int optind, opterr, optopt; | ||
|
@@ -197,7 +199,7 @@ int main(int argc, char **argv) | |
unsigned char buffer[4096]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add some |
||
int nbytes; | ||
|
||
while ((opt = getopt(argc, argv, "s:d:x:X:h:ct:f:L?")) != -1) { | ||
while ((opt = getopt(argc, argv, "s:d:x:X:h:ct:f:L?q")) != -1) { | ||
switch (opt) { | ||
case 's': | ||
src = strtoul(optarg, NULL, 16); | ||
|
@@ -249,6 +251,10 @@ int main(int argc, char **argv) | |
} | ||
break; | ||
|
||
case 'q': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -i ... |
||
noquit = 1; | ||
break; | ||
|
||
case '?': | ||
print_usage(basename(argv[0])); | ||
goto out; | ||
|
@@ -371,29 +377,35 @@ int main(int argc, char **argv) | |
if (nbytes < 0) { | ||
perror("read socket s"); | ||
r = 1; | ||
goto out; | ||
if(!noquit) | ||
goto out; | ||
} | ||
if (nbytes > 4095) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (nbytes > PDU_BUF_SIZE - 1) |
||
r = 1; | ||
perror("read socket s too much data"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PDU length %d longer than PDU buffer", nbytes) |
||
goto out; | ||
} | ||
printbuf(buffer, nbytes, color?2:0, timestamp, format, | ||
&tv, &last_tv, dst, s, if_name, head); | ||
if(nbytes > 0) | ||
printbuf(buffer, nbytes, color?2:0, timestamp, format, | ||
&tv, &last_tv, dst, s, if_name, head); | ||
} | ||
|
||
if (FD_ISSET(t, &rdfs)) { | ||
nbytes = read(t, buffer, 4096); | ||
if (nbytes < 0) { | ||
perror("read socket t"); | ||
r = 1; | ||
goto out; | ||
if(!noquit) | ||
goto out; | ||
} | ||
if (nbytes > 4095) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (nbytes > PDU_BUF_SIZE - 1) |
||
r = 1; | ||
perror("read socket t too much data"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PDU length %d longer than PDU buffer", nbytes) |
||
goto out; | ||
} | ||
printbuf(buffer, nbytes, color?1:0, timestamp, format, | ||
&tv, &last_tv, src, t, if_name, head); | ||
if(nbytes > 0) | ||
printbuf(buffer, nbytes, color?1:0, timestamp, format, | ||
&tv, &last_tv, src, t, if_name, head); | ||
} | ||
} | ||
|
||
|
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 would suggest to use '-i' analog to cangen:
-i (ignore syscall errors to receive malformed PDUs)