Don't exit when unable to decode specific frames
Changes: * Modify examples/ax25dump.c and decode.c to not die upon failure to decode a specific frame or field; instead, indicate the error, print a hex dump of the frame, and move on to the next frame
This commit is contained in:
parent
4bfe7da77b
commit
754baabf11
2 changed files with 27 additions and 29 deletions
|
@ -98,8 +98,7 @@ int main(int argc, char **argv) {
|
|||
patty_ax25_frame frame;
|
||||
|
||||
if ((decoded = patty_ax25_frame_decode_address(&frame, buf, readlen)) < 0) {
|
||||
fprintf(stderr, "%s: %s: %s\n",
|
||||
argv[0], "patty_ax25_frame_decode_address()", strerror(errno));
|
||||
printf("Invalid frame address\n");
|
||||
|
||||
goto error_ax25_frame_decode_address;
|
||||
} else {
|
||||
|
@ -107,8 +106,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if ((decoded = patty_ax25_frame_decode_control(&frame, PATTY_AX25_FRAME_NORMAL, buf, decoded, readlen)) < 0) {
|
||||
fprintf(stderr, "%s: %s: %s\n",
|
||||
argv[0], "patty_ax25_frame_decode_control()", strerror(errno));
|
||||
printf("Invalid frame control\n");
|
||||
|
||||
goto error_ax25_frame_decode_control;
|
||||
} else {
|
||||
|
@ -129,17 +127,19 @@ int main(int argc, char **argv) {
|
|||
buf,
|
||||
offset,
|
||||
readlen) < 0) {
|
||||
fprintf(stderr, "%s: %s: %s\n",
|
||||
argv[0], "patty_ax25_frame_decode_xid()", strerror(errno));
|
||||
printf("Invalid XID parameters\n");
|
||||
|
||||
goto error_ax25_frame_decode_xid;
|
||||
}
|
||||
|
||||
if (patty_print_params(stdout, ¶ms) < 0) {
|
||||
goto error_io;
|
||||
} else {
|
||||
if (patty_print_params(stdout, ¶ms) < 0) {
|
||||
goto error_io;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error_ax25_frame_decode_xid:
|
||||
error_ax25_frame_decode_control:
|
||||
error_ax25_frame_decode_address:
|
||||
if (patty_print_hexdump(stdout, buf, readlen) < 0) {
|
||||
goto error_io;
|
||||
}
|
||||
|
@ -158,9 +158,6 @@ int main(int argc, char **argv) {
|
|||
return 0;
|
||||
|
||||
error_io:
|
||||
error_ax25_frame_decode_xid:
|
||||
error_ax25_frame_decode_control:
|
||||
error_ax25_frame_decode_address:
|
||||
patty_kiss_tnc_destroy(raw);
|
||||
|
||||
error_kiss_tnc_new:
|
||||
|
|
|
@ -65,8 +65,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if ((decoded = patty_ax25_frame_decode_address(&frame, buf, len)) < 0) {
|
||||
fprintf(stderr, "%s: %s: %s\n",
|
||||
argv[0], "patty_ax25_frame_decode_address()", strerror(errno));
|
||||
printf("Invalid frame address\n");
|
||||
|
||||
goto error_ax25_frame_decode_address;
|
||||
} else {
|
||||
|
@ -74,8 +73,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if ((decoded = patty_ax25_frame_decode_control(&frame, PATTY_AX25_FRAME_NORMAL, buf, offset, len)) < 0) {
|
||||
fprintf(stderr, "%s: %s: %s\n",
|
||||
argv[0], "patty_ax25_frame_decode_control()", strerror(errno));
|
||||
printf("Invalid frame control\n");
|
||||
|
||||
goto error_ax25_frame_decode_control;
|
||||
} else {
|
||||
|
@ -86,7 +84,7 @@ int main(int argc, char **argv) {
|
|||
fprintf(stderr, "%s: %s: %s\n",
|
||||
argv[0], "patty_print_frame_header()", strerror(errno));
|
||||
|
||||
goto error_print;
|
||||
goto error_io;
|
||||
}
|
||||
|
||||
if (frame.type == PATTY_AX25_FRAME_XID) {
|
||||
|
@ -96,19 +94,25 @@ int main(int argc, char **argv) {
|
|||
buf,
|
||||
offset,
|
||||
len) < 0) {
|
||||
fprintf(stderr, "%s: %s: %s\n",
|
||||
argv[0], "patty_ax25_frame_decode_xid()", strerror(errno));
|
||||
printf("Invalid XID parameters\n");
|
||||
|
||||
goto error_ax25_frame_decode_xid;
|
||||
}
|
||||
|
||||
if (patty_print_params(stdout, ¶ms) < 0) {
|
||||
goto error_print;
|
||||
} else {
|
||||
if (patty_print_params(stdout, ¶ms) < 0) {
|
||||
goto error_io;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error_ax25_frame_decode_xid:
|
||||
error_ax25_frame_decode_control:
|
||||
error_ax25_frame_decode_address:
|
||||
if (patty_print_hexdump(stdout, buf, len) < 0) {
|
||||
goto error_print;
|
||||
goto error_io;
|
||||
}
|
||||
|
||||
if (fflush(stdout) < 0) {
|
||||
goto error_io;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,10 +122,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
return 0;
|
||||
|
||||
error_print:
|
||||
error_ax25_frame_decode_xid:
|
||||
error_ax25_frame_decode_control:
|
||||
error_ax25_frame_decode_address:
|
||||
error_io:
|
||||
error_kiss_tnc_recv:
|
||||
free(buf);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue