summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Escande <thierry.escande@linux.intel.com>2013-03-25 17:45:54 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2013-03-28 18:40:02 +0100
commita2db085bd113f6285431827da60bb60cd410637f (patch)
tree89f9b61984988542f09f0d4a12ee8a09bb87954c
parenteb6a3479cf4eed83d4b11124a65f1ec869927739 (diff)
downloadneard-a2db085bd113f6285431827da60bb60cd410637f.tar.gz
neard-a2db085bd113f6285431827da60bb60cd410637f.tar.bz2
neard-a2db085bd113f6285431827da60bb60cd410637f.zip
nfctool: Print length of buffer before its hexadecimal dump
-rw-r--r--tools/nfctool/llcp-decode.c5
-rw-r--r--tools/nfctool/sniffer.c9
-rw-r--r--tools/nfctool/sniffer.h2
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 */