summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2013-06-13 16:45:55 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2013-06-13 17:16:26 +0200
commit7263e1d9adf0f298920a971ccd372135af93456a (patch)
treedfb9ad1039224da754afe3dc8320def369b59eac
parent1463d1005d1e4254d84e54ccf169c1e05f24ea79 (diff)
downloadneard-7263e1d9adf0f298920a971ccd372135af93456a.tar.gz
neard-7263e1d9adf0f298920a971ccd372135af93456a.tar.bz2
neard-7263e1d9adf0f298920a971ccd372135af93456a.zip
nfctool: sniffer: Output the MIME type value
This is needed for handover sniffing.
-rw-r--r--tools/nfctool/ndef-decode.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/tools/nfctool/ndef-decode.c b/tools/nfctool/ndef-decode.c
index 8910f56..94694bc 100644
--- a/tools/nfctool/ndef-decode.c
+++ b/tools/nfctool/ndef-decode.c
@@ -38,6 +38,15 @@
#define ndef_printf_error(fmt, ...) print_indent(NDEF_MSG_INDENT, COLOR_ERROR, \
fmt, ## __VA_ARGS__)
+enum record_tnf {
+ RECORD_TNF_EMPTY = 0x00,
+ RECORD_TNF_WELLKNOWN = 0x01,
+ RECORD_TNF_MIME = 0x02,
+ RECORD_TNF_URI = 0x03,
+ RECORD_TNF_EXTERNAL = 0x04,
+ RECORD_TNF_UNKNOWN = 0x05,
+ RECORD_TNF_UNCHANGED = 0x06,
+};
static gchar *tnf_str[] = {
"Empty (0x00)",
@@ -53,7 +62,8 @@ static gchar *tnf_str[] = {
int ndef_print_records(guint8 *data, guint32 data_len)
{
gboolean mb, me, cf, sr, il;
- guint8 tnf;
+ enum record_tnf tnf;
+ char *mime_string;
guint8 type_len;
guint8 *type;
guint32 payload_len;
@@ -162,10 +172,25 @@ int ndef_print_records(guint8 *data, guint32 data_len)
ndef_printf_msg("ID Length: %u", id_len);
if (type) {
- ndef_printf_msg("Type:");
-
- sniffer_print_hexdump(stdout, type, type_len,
- NDEF_HEX_INDENT, FALSE);
+ switch (tnf) {
+ case RECORD_TNF_MIME:
+ mime_string = g_try_malloc(type_len + 1);
+ if (mime_string != NULL) {
+ g_snprintf(mime_string,
+ type_len + 1, "%s", type);
+
+ ndef_printf_msg("Type: %s", mime_string);
+ g_free(mime_string);
+ break;
+ }
+
+ default:
+ ndef_printf_msg("Type:");
+ sniffer_print_hexdump(stdout, type, type_len,
+ NDEF_HEX_INDENT, FALSE);
+
+ break;
+ }
}
if (id) {