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;
|
patty_ax25_frame frame;
|
||||||
|
|
||||||
if ((decoded = patty_ax25_frame_decode_address(&frame, buf, readlen)) < 0) {
|
if ((decoded = patty_ax25_frame_decode_address(&frame, buf, readlen)) < 0) {
|
||||||
fprintf(stderr, "%s: %s: %s\n",
|
printf("Invalid frame address\n");
|
||||||
argv[0], "patty_ax25_frame_decode_address()", strerror(errno));
|
|
||||||
|
|
||||||
goto error_ax25_frame_decode_address;
|
goto error_ax25_frame_decode_address;
|
||||||
} else {
|
} 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) {
|
if ((decoded = patty_ax25_frame_decode_control(&frame, PATTY_AX25_FRAME_NORMAL, buf, decoded, readlen)) < 0) {
|
||||||
fprintf(stderr, "%s: %s: %s\n",
|
printf("Invalid frame control\n");
|
||||||
argv[0], "patty_ax25_frame_decode_control()", strerror(errno));
|
|
||||||
|
|
||||||
goto error_ax25_frame_decode_control;
|
goto error_ax25_frame_decode_control;
|
||||||
} else {
|
} else {
|
||||||
|
@ -129,17 +127,19 @@ int main(int argc, char **argv) {
|
||||||
buf,
|
buf,
|
||||||
offset,
|
offset,
|
||||||
readlen) < 0) {
|
readlen) < 0) {
|
||||||
fprintf(stderr, "%s: %s: %s\n",
|
printf("Invalid XID parameters\n");
|
||||||
argv[0], "patty_ax25_frame_decode_xid()", strerror(errno));
|
|
||||||
|
|
||||||
goto error_ax25_frame_decode_xid;
|
goto error_ax25_frame_decode_xid;
|
||||||
}
|
} else {
|
||||||
|
if (patty_print_params(stdout, ¶ms) < 0) {
|
||||||
if (patty_print_params(stdout, ¶ms) < 0) {
|
goto error_io;
|
||||||
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) {
|
if (patty_print_hexdump(stdout, buf, readlen) < 0) {
|
||||||
goto error_io;
|
goto error_io;
|
||||||
}
|
}
|
||||||
|
@ -158,9 +158,6 @@ int main(int argc, char **argv) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_io:
|
error_io:
|
||||||
error_ax25_frame_decode_xid:
|
|
||||||
error_ax25_frame_decode_control:
|
|
||||||
error_ax25_frame_decode_address:
|
|
||||||
patty_kiss_tnc_destroy(raw);
|
patty_kiss_tnc_destroy(raw);
|
||||||
|
|
||||||
error_kiss_tnc_new:
|
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) {
|
if ((decoded = patty_ax25_frame_decode_address(&frame, buf, len)) < 0) {
|
||||||
fprintf(stderr, "%s: %s: %s\n",
|
printf("Invalid frame address\n");
|
||||||
argv[0], "patty_ax25_frame_decode_address()", strerror(errno));
|
|
||||||
|
|
||||||
goto error_ax25_frame_decode_address;
|
goto error_ax25_frame_decode_address;
|
||||||
} else {
|
} 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) {
|
if ((decoded = patty_ax25_frame_decode_control(&frame, PATTY_AX25_FRAME_NORMAL, buf, offset, len)) < 0) {
|
||||||
fprintf(stderr, "%s: %s: %s\n",
|
printf("Invalid frame control\n");
|
||||||
argv[0], "patty_ax25_frame_decode_control()", strerror(errno));
|
|
||||||
|
|
||||||
goto error_ax25_frame_decode_control;
|
goto error_ax25_frame_decode_control;
|
||||||
} else {
|
} else {
|
||||||
|
@ -86,7 +84,7 @@ int main(int argc, char **argv) {
|
||||||
fprintf(stderr, "%s: %s: %s\n",
|
fprintf(stderr, "%s: %s: %s\n",
|
||||||
argv[0], "patty_print_frame_header()", strerror(errno));
|
argv[0], "patty_print_frame_header()", strerror(errno));
|
||||||
|
|
||||||
goto error_print;
|
goto error_io;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame.type == PATTY_AX25_FRAME_XID) {
|
if (frame.type == PATTY_AX25_FRAME_XID) {
|
||||||
|
@ -96,19 +94,25 @@ int main(int argc, char **argv) {
|
||||||
buf,
|
buf,
|
||||||
offset,
|
offset,
|
||||||
len) < 0) {
|
len) < 0) {
|
||||||
fprintf(stderr, "%s: %s: %s\n",
|
printf("Invalid XID parameters\n");
|
||||||
argv[0], "patty_ax25_frame_decode_xid()", strerror(errno));
|
|
||||||
|
|
||||||
goto error_ax25_frame_decode_xid;
|
goto error_ax25_frame_decode_xid;
|
||||||
}
|
} else {
|
||||||
|
if (patty_print_params(stdout, ¶ms) < 0) {
|
||||||
if (patty_print_params(stdout, ¶ms) < 0) {
|
goto error_io;
|
||||||
goto error_print;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_ax25_frame_decode_xid:
|
||||||
|
error_ax25_frame_decode_control:
|
||||||
|
error_ax25_frame_decode_address:
|
||||||
if (patty_print_hexdump(stdout, buf, len) < 0) {
|
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;
|
return 0;
|
||||||
|
|
||||||
error_print:
|
error_io:
|
||||||
error_ax25_frame_decode_xid:
|
|
||||||
error_ax25_frame_decode_control:
|
|
||||||
error_ax25_frame_decode_address:
|
|
||||||
error_kiss_tnc_recv:
|
error_kiss_tnc_recv:
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue