#include #include #include #include #define printable(c) \ (c >= 0x20 && c < 0x7f) int patty_print_hexdump(FILE *fh, void *data, size_t len) { size_t i; for (i=0; isrc); fprintf(fh, " > "); for (i=0; ihops; i++) { print_addr(fh, &frame->repeaters[i]); fprintf(fh, " > "); } print_addr(fh, &frame->dest); return 0; } int patty_print_frame(FILE *fh, const patty_ax25_frame *frame, void *buf, size_t len) { if (print_frame_addrs(fh, frame) < 0) { goto error_io; } if (PATTY_AX25_CONTROL_INFO(frame->control)) { if (fprintf(fh, " type I poll %d ns %d nr %d info %zu bytes", PATTY_AX25_CONTROL_POLL(frame->control), PATTY_AX25_CONTROL_SEQ_SEND(frame->control), PATTY_AX25_CONTROL_SEQ_RECV(frame->control), frame->infolen) < 0) { goto error_io; } } else if (PATTY_AX25_CONTROL_UNNUMBERED(frame->control)) { if (fprintf(fh, " type U") < 0) { goto error_io; } if (PATTY_AX25_CONTROL_UNNUMBERED_INFO(frame->control)) { if (fprintf(fh, " info %zu bytes", frame->infolen) < 0) { goto error_io; } } } else if (PATTY_AX25_CONTROL_SUPER(frame->control)) { if (fprintf(fh, " type S") < 0) { goto error_io; } } fprintf(fh, "\n"); return patty_print_hexdump(fh, buf, len); error_io: return -1; }