diff options
author | Michal Labedzki <michal.labedzki@tieto.com> | 2015-09-09 17:34:46 +0200 |
---|---|---|
committer | Michal Labedzki <michal.labedzki@tieto.com> | 2015-10-17 10:21:37 +0000 |
commit | 8bb4fed753b05147166be2b8429be643ac88438e (patch) | |
tree | 22138fefc241de991c74a204b90218d67bd4ffc6 /epan/dissectors/packet-bluetooth.c | |
parent | 58081a2d1ce4800ac33d7b9ce2b82259701c3c16 (diff) |
Bluetooth: Fix displaying and handling UUID128
Use a standard way of displaying 128 UUIDs (like GUID).
This also change a way that UUID are handled by dissector tables.
Change-Id: Ie0f880f58480c34b40dd23c426202349e0620b12
Reviewed-on: https://code.wireshark.org/review/11018
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Diffstat (limited to 'epan/dissectors/packet-bluetooth.c')
-rw-r--r-- | epan/dissectors/packet-bluetooth.c | 65 |
1 files changed, 52 insertions, 13 deletions
diff --git a/epan/dissectors/packet-bluetooth.c b/epan/dissectors/packet-bluetooth.c index bff8e8d73b..fd25b5c13d 100644 --- a/epan/dissectors/packet-bluetooth.c +++ b/epan/dissectors/packet-bluetooth.c @@ -1251,10 +1251,30 @@ get_uuid(tvbuff_t *tvb, gint offset, gint size) } uuid.size = size; - tvb_memcpy(tvb, uuid.data, offset, size); + if (size == 2) { + uuid.data[0] = tvb_get_guint8(tvb, offset + 1); + uuid.data[1] = tvb_get_guint8(tvb, offset); + } else if (size == 16) { + uuid.data[0] = tvb_get_guint8(tvb, offset + 15); + uuid.data[1] = tvb_get_guint8(tvb, offset + 14); + uuid.data[2] = tvb_get_guint8(tvb, offset + 13); + uuid.data[3] = tvb_get_guint8(tvb, offset + 12); + uuid.data[4] = tvb_get_guint8(tvb, offset + 11); + uuid.data[5] = tvb_get_guint8(tvb, offset + 10); + uuid.data[6] = tvb_get_guint8(tvb, offset + 9); + uuid.data[7] = tvb_get_guint8(tvb, offset + 8); + uuid.data[8] = tvb_get_guint8(tvb, offset + 7); + uuid.data[9] = tvb_get_guint8(tvb, offset + 6); + uuid.data[10] = tvb_get_guint8(tvb, offset + 5); + uuid.data[11] = tvb_get_guint8(tvb, offset + 4); + uuid.data[12] = tvb_get_guint8(tvb, offset + 3); + uuid.data[13] = tvb_get_guint8(tvb, offset + 2); + uuid.data[14] = tvb_get_guint8(tvb, offset + 1); + uuid.data[15] = tvb_get_guint8(tvb, offset); + } if (size == 2) { - uuid.bt_uuid = uuid.data[0] | uuid.data[1] << 8; + uuid.bt_uuid = uuid.data[1] | uuid.data[0] << 8; } else { if (uuid.data[0] == 0x00 && uuid.data[1] == 0x00 && uuid.data[4] == 0x00 && uuid.data[5] == 0x00 && uuid.data[6] == 0x10 && @@ -1268,6 +1288,35 @@ get_uuid(tvbuff_t *tvb, gint offset, gint size) } gchar * +print_numeric_uuid(bluetooth_uuid_t *uuid) +{ + if (!(uuid && uuid->size > 0)) + return NULL; + + if (uuid->size != 16) { + return bytes_to_str(wmem_packet_scope(), uuid->data, uuid->size); + } else { + gchar *text; + + text = (gchar *) wmem_alloc(wmem_packet_scope(), 38); + bytes_to_hexstr(&text[0], uuid->data, 4); + text[8] = '-'; + bytes_to_hexstr(&text[9], uuid->data + 4, 2); + text[13] = '-'; + bytes_to_hexstr(&text[14], uuid->data + 4 + 2 * 1, 2); + text[18] = '-'; + bytes_to_hexstr(&text[19], uuid->data + 4 + 2 * 2, 2); + text[23] = '-'; + bytes_to_hexstr(&text[24], uuid->data + 4 + 2 * 3, 6); + text[36] = '\0'; + + return text; + } + + return NULL; +} + +gchar * print_uuid(bluetooth_uuid_t *uuid) { if (uuid->bt_uuid) { @@ -1289,20 +1338,10 @@ print_uuid(bluetooth_uuid_t *uuid) i_uuid += 1; } - return bytes_to_str(wmem_packet_scope(), uuid->data, uuid->size); + return print_numeric_uuid(uuid); } } -gchar * -print_numeric_uuid(bluetooth_uuid_t *uuid) -{ - if (uuid && uuid->size > 0) - return bytes_to_str(wmem_packet_scope(), uuid->data, uuid->size); - - return NULL; -} - - static bluetooth_data_t * dissect_bluetooth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { |