diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2013-05-02 13:10:44 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-05-02 16:31:17 +0200 |
commit | 6e0c47e5c0bb995f58d9c13bf8f4405387ada8b3 (patch) | |
tree | 9edeaf71723a98590aacfed628e96c373b34383b /tools | |
parent | ce9f93cab2ba758f0397c33f647832c09005e0d9 (diff) | |
download | neard-6e0c47e5c0bb995f58d9c13bf8f4405387ada8b3.tar.gz neard-6e0c47e5c0bb995f58d9c13bf8f4405387ada8b3.tar.bz2 neard-6e0c47e5c0bb995f58d9c13bf8f4405387ada8b3.zip |
nfctool: sniffer: Simplify print_pdu routine
And prepare for more colors...
Diffstat (limited to 'tools')
-rw-r--r-- | tools/nfctool/llcp-decode.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/tools/nfctool/llcp-decode.c b/tools/nfctool/llcp-decode.c index 159c0b2..34530dd 100644 --- a/tools/nfctool/llcp-decode.c +++ b/tools/nfctool/llcp-decode.c @@ -440,7 +440,7 @@ int llcp_print_pdu(guint8 *data, guint32 data_len, struct timeval *timestamp) { struct timeval msg_timestamp; struct sniffer_packet packet; - gchar *direction_str; + gchar *direction_str, time_str[32]; int err; if (timestamp == NULL) @@ -461,25 +461,24 @@ int llcp_print_pdu(guint8 *data, guint32 data_len, struct timeval *timestamp) else direction_str = "<<"; - printf("%s nfc%d: local:0x%02x remote:0x%02x", - direction_str, packet.adapter_idx, - packet.llcp.local_sap, packet.llcp.remote_sap); - if (opts.show_timestamp != SNIFFER_SHOW_TIMESTAMP_NONE) { - printf(" time: "); + char prefix = ' '; if (opts.show_timestamp == SNIFFER_SHOW_TIMESTAMP_ABS) { + printf("ABSOLUTE\n"); msg_timestamp = *timestamp; } else { timersub(timestamp, &start_timestamp, &msg_timestamp); - printf("+"); + prefix = '+'; } - printf("%lu.%06lu", msg_timestamp.tv_sec, + sprintf(time_str, "%c%lu.%06lus", prefix, msg_timestamp.tv_sec, msg_timestamp.tv_usec); } - printf("\n"); + printf("%s nfc%d: local:0x%02x remote:0x%02x %s\n", + direction_str, packet.adapter_idx, + packet.llcp.local_sap, packet.llcp.remote_sap, time_str); printf(" %s\n", llcp_ptype_str[packet.llcp.ptype]); |