diff options
-rw-r--r-- | tools/nfctool/llcp-decode.c | 5 | ||||
-rw-r--r-- | tools/nfctool/sniffer.c | 9 | ||||
-rw-r--r-- | tools/nfctool/sniffer.h | 2 |
3 files changed, 12 insertions, 4 deletions
diff --git a/tools/nfctool/llcp-decode.c b/tools/nfctool/llcp-decode.c index a49cd8e..aa701c7 100644 --- a/tools/nfctool/llcp-decode.c +++ b/tools/nfctool/llcp-decode.c @@ -387,7 +387,7 @@ static int llcp_print_i(guint8 *data, guint32 data_len) if (llcp_print_sequence(data, data_len)) return -EINVAL; - sniffer_print_hexdump(stdout, data + 1, data_len - 1, " "); + sniffer_print_hexdump(stdout, data + 1, data_len - 1, " ", TRUE); return 0; } @@ -500,7 +500,8 @@ int llcp_print_pdu(guint8 *data, guint32 data_len, struct timeval *timestamp) break; default: - sniffer_print_hexdump(stdout, llcp.data, llcp.data_len, " "); + sniffer_print_hexdump(stdout, llcp.data, llcp.data_len, " ", + TRUE); break; } diff --git a/tools/nfctool/sniffer.c b/tools/nfctool/sniffer.c index 2c79f35..2e89ddc 100644 --- a/tools/nfctool/sniffer.c +++ b/tools/nfctool/sniffer.c @@ -158,7 +158,7 @@ static void pcap_file_cleanup(void) * */ void sniffer_print_hexdump(FILE *file, guint8 *data, guint32 len, - gchar *line_prefix) + gchar *line_prefix, gboolean print_len) { guint8 digits; guint32 offset; @@ -173,6 +173,13 @@ void sniffer_print_hexdump(FILE *file, guint8 *data, guint32 len, digits = 0; total = 0; + if (print_len) { + if (line_prefix) + fprintf(file, "%s", line_prefix); + + fprintf(file, "Total length: %u bytes\n", len); + } + while (total < len) { if (digits == 0) { memset(line, ' ', HUMAN_READABLE_OFFSET); diff --git a/tools/nfctool/sniffer.h b/tools/nfctool/sniffer.h index 848a71a..2f3603a 100644 --- a/tools/nfctool/sniffer.h +++ b/tools/nfctool/sniffer.h @@ -31,6 +31,6 @@ int sniffer_init(void); void sniffer_cleanup(void); void sniffer_print_hexdump(FILE *file, guint8 *data, guint32 len, - gchar *line_prefix); + gchar *line_prefix, gboolean print_len); #endif /* __SNIFFER_H */ |