BT Common: fix dissection of 32 bits and 128 bits UUID
They are in little endian, not big endian. Bug: 14843 Change-Id: I1680e84bfce9a03eaeeda9e38c84b471fda2bd8e Reviewed-on: https://code.wireshark.org/review/28116 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
parent
650e379154
commit
ee88dc8196
|
@ -2726,7 +2726,7 @@ get_uuid(tvbuff_t *tvb, gint offset, gint size)
|
|||
|
||||
memset(&uuid, 0, sizeof(uuid));
|
||||
|
||||
if (size != 2 && size != 16) {
|
||||
if (size != 2 && size != 4 && size != 16) {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
|
@ -2734,7 +2734,17 @@ get_uuid(tvbuff_t *tvb, gint offset, gint 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.bt_uuid = uuid.data[1] | uuid.data[0] << 8;
|
||||
} else if (size == 4) {
|
||||
uuid.data[0] = tvb_get_guint8(tvb, offset + 3);
|
||||
uuid.data[1] = tvb_get_guint8(tvb, offset + 2);
|
||||
uuid.data[2] = tvb_get_guint8(tvb, offset + 1);
|
||||
uuid.data[3] = tvb_get_guint8(tvb, offset);
|
||||
|
||||
if (uuid.data[0] == 0x00 && uuid.data[1] == 0x00)
|
||||
uuid.bt_uuid = uuid.data[2] | uuid.data[3] << 8;
|
||||
} else {
|
||||
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);
|
||||
|
@ -2751,17 +2761,13 @@ get_uuid(tvbuff_t *tvb, gint offset, gint size)
|
|||
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[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 &&
|
||||
uuid.data[7] == 0x00 && uuid.data[8] == 0x80 && uuid.data[9] == 0x00 &&
|
||||
uuid.data[10] == 0x00 && uuid.data[11] == 0x80 && uuid.data[12] == 0x5F &&
|
||||
uuid.data[13] == 0x9B && uuid.data[14] == 0x34 && uuid.data[15] == 0xFB)
|
||||
uuid.bt_uuid = uuid.data[2] | uuid.data[3] << 8;
|
||||
uuid.data[4] == 0x00 && uuid.data[5] == 0x00 && uuid.data[6] == 0x10 &&
|
||||
uuid.data[7] == 0x00 && uuid.data[8] == 0x80 && uuid.data[9] == 0x00 &&
|
||||
uuid.data[10] == 0x00 && uuid.data[11] == 0x80 && uuid.data[12] == 0x5F &&
|
||||
uuid.data[13] == 0x9B && uuid.data[14] == 0x34 && uuid.data[15] == 0xFB)
|
||||
uuid.bt_uuid = uuid.data[2] | uuid.data[3] << 8;
|
||||
}
|
||||
|
||||
return uuid;
|
||||
|
|
|
@ -662,7 +662,8 @@ static gint hf_btcommon_eir_ad_flags_le_limited_discoverable_mode = -1;
|
|||
static gint hf_btcommon_eir_ad_uuid_16 = -1;
|
||||
static gint hf_btcommon_eir_ad_uuid_32 = -1;
|
||||
static gint hf_btcommon_eir_ad_uuid_128 = -1;
|
||||
static gint hf_btcommon_eir_ad_custom_uuid = -1;
|
||||
static gint hf_btcommon_eir_ad_custom_uuid_32 = -1;
|
||||
static gint hf_btcommon_eir_ad_custom_uuid_128 = -1;
|
||||
static gint hf_btcommon_eir_ad_name = -1;
|
||||
static gint hf_btcommon_eir_ad_tx_power = -1;
|
||||
static gint hf_btcommon_eir_ad_ssp_oob_length = -1;
|
||||
|
@ -7364,6 +7365,7 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bluetoo
|
|||
gboolean has_bd_addr = FALSE;
|
||||
guint8 bd_addr[6];
|
||||
guint8 *name = NULL;
|
||||
bluetooth_uuid_t uuid;
|
||||
|
||||
DISSECTOR_ASSERT(bluetooth_eir_ad_data);
|
||||
|
||||
|
@ -7414,15 +7416,12 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bluetoo
|
|||
case 0x1F: /* List of 32-bit Service Solicitation UUIDs */
|
||||
end_offset = offset + length;
|
||||
while (offset < end_offset) {
|
||||
if (tvb_get_ntohs(tvb, offset) == 0x0000) {
|
||||
sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_uuid_32, tvb, offset, 4, ENC_BIG_ENDIAN);
|
||||
proto_item_append_text(sub_item, " (%s)", val_to_str_ext_const(tvb_get_ntohs(tvb, offset + 2), &bluetooth_uuid_vals_ext, "Unknown"));
|
||||
uuid = get_uuid(tvb, offset, 4);
|
||||
if (uuid.bt_uuid) {
|
||||
sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_uuid_32, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
||||
proto_item_append_text(sub_item, " (%s)", val_to_str_ext_const(uuid.bt_uuid, &bluetooth_uuid_vals_ext, "Unknown"));
|
||||
} else {
|
||||
bluetooth_uuid_t uuid;
|
||||
|
||||
sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_custom_uuid, tvb, offset, 4, ENC_NA);
|
||||
uuid = get_uuid(tvb, offset, 4);
|
||||
|
||||
sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_custom_uuid_32, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
||||
proto_item_append_text(sub_item, " (%s)", print_uuid(&uuid));
|
||||
}
|
||||
|
||||
|
@ -7435,18 +7434,13 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bluetoo
|
|||
case 0x15: /* List of 128-bit Service Solicitation UUIDs */
|
||||
end_offset = offset + length;
|
||||
while (offset < end_offset) {
|
||||
if (tvb_get_ntohs(tvb, offset) == 0x0000 &&
|
||||
tvb_get_ntohl(tvb, offset + 4) == 0x1000 &&
|
||||
tvb_get_ntoh64(tvb, offset + 8) == G_GUINT64_CONSTANT(0x800000805F9B34FB)) {
|
||||
sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_uuid_128, tvb, offset, 16, ENC_NA);
|
||||
proto_item_append_text(sub_item, " (%s)", val_to_str_ext_const(tvb_get_ntohs(tvb, offset + 2), &bluetooth_uuid_vals_ext, "Unknown"));
|
||||
uuid = get_uuid(tvb, offset, 16);
|
||||
if (uuid.bt_uuid) {
|
||||
sub_item = proto_tree_add_bytes_format_value(entry_tree, hf_btcommon_eir_ad_uuid_128, tvb, offset, 16, uuid.data, "%s", print_numeric_uuid(&uuid));
|
||||
proto_item_append_text(sub_item, " (%s)", val_to_str_ext_const(uuid.bt_uuid, &bluetooth_uuid_vals_ext, "Unknown"));
|
||||
}
|
||||
else {
|
||||
bluetooth_uuid_t uuid;
|
||||
|
||||
sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_custom_uuid, tvb, offset, 16, ENC_NA);
|
||||
uuid = get_uuid(tvb, offset, 16);
|
||||
|
||||
sub_item = proto_tree_add_bytes_format_value(entry_tree, hf_btcommon_eir_ad_custom_uuid_128, tvb, offset, 16, uuid.data, "%s", print_numeric_uuid(&uuid));
|
||||
proto_item_append_text(sub_item, " (%s)", print_uuid(&uuid));
|
||||
}
|
||||
|
||||
|
@ -7574,16 +7568,13 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bluetoo
|
|||
}
|
||||
break;
|
||||
case 0x20: /* Service Data - 32 bit UUID */
|
||||
if (tvb_get_ntohs(tvb, offset) == 0x0000) {
|
||||
sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_uuid_32, tvb, offset, 4, ENC_BIG_ENDIAN);
|
||||
proto_item_append_text(sub_item, " (%s)", val_to_str_ext_const(tvb_get_ntohs(tvb, offset + 2), &bluetooth_uuid_vals_ext, "Unknown"));
|
||||
uuid = get_uuid(tvb, offset, 4);
|
||||
if (uuid.bt_uuid) {
|
||||
sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_uuid_32, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
||||
proto_item_append_text(sub_item, " (%s)", val_to_str_ext_const(uuid.bt_uuid, &bluetooth_uuid_vals_ext, "Unknown"));
|
||||
}
|
||||
else {
|
||||
bluetooth_uuid_t uuid;
|
||||
|
||||
sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_custom_uuid, tvb, offset, 4, ENC_NA);
|
||||
uuid = get_uuid(tvb, offset, 4);
|
||||
|
||||
sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_custom_uuid_32, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
||||
proto_item_append_text(sub_item, " (%s)", print_uuid(&uuid));
|
||||
}
|
||||
offset += 4;
|
||||
|
@ -7594,18 +7585,13 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bluetoo
|
|||
}
|
||||
break;
|
||||
case 0x21: /* Service Data - 128 bit UUID */
|
||||
if (tvb_get_ntohs(tvb, offset) == 0x0000 &&
|
||||
tvb_get_ntohl(tvb, offset + 4) == 0x1000 &&
|
||||
tvb_get_ntoh64(tvb, offset + 8) == G_GUINT64_CONSTANT(0x800000805F9B34FB)) {
|
||||
sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_uuid_128, tvb, offset, 16, ENC_NA);
|
||||
proto_item_append_text(sub_item, " (%s)", val_to_str_ext_const(tvb_get_ntohs(tvb, offset + 2), &bluetooth_uuid_vals_ext, "Unknown"));
|
||||
uuid = get_uuid(tvb, offset, 16);
|
||||
if (uuid.bt_uuid) {
|
||||
sub_item = proto_tree_add_bytes_format_value(entry_tree, hf_btcommon_eir_ad_uuid_128, tvb, offset, 16, uuid.data, "%s", print_numeric_uuid(&uuid));
|
||||
proto_item_append_text(sub_item, " (%s)", val_to_str_ext_const(uuid.bt_uuid, &bluetooth_uuid_vals_ext, "Unknown"));
|
||||
}
|
||||
else {
|
||||
bluetooth_uuid_t uuid;
|
||||
|
||||
sub_item = proto_tree_add_item(entry_tree, hf_btcommon_eir_ad_custom_uuid, tvb, offset, 16, ENC_NA);
|
||||
uuid = get_uuid(tvb, offset, 16);
|
||||
|
||||
sub_item = proto_tree_add_bytes_format_value(entry_tree, hf_btcommon_eir_ad_custom_uuid_128, tvb, offset, 16, uuid.data, "%s", print_numeric_uuid(&uuid));
|
||||
proto_item_append_text(sub_item, " (%s)", print_uuid(&uuid));
|
||||
}
|
||||
offset += 16;
|
||||
|
@ -8185,8 +8171,13 @@ proto_register_btcommon(void)
|
|||
FT_BYTES, BASE_NONE, NULL, 0x0,
|
||||
NULL, HFILL }
|
||||
},
|
||||
{ &hf_btcommon_eir_ad_custom_uuid,
|
||||
{ "Custom UUID", "btcommon.eir_ad.entry.custom_uuid",
|
||||
{ &hf_btcommon_eir_ad_custom_uuid_32,
|
||||
{ "Custom UUID", "btcommon.eir_ad.entry.custom_uuid_32",
|
||||
FT_UINT32, BASE_HEX, NULL, 0x0,
|
||||
NULL, HFILL }
|
||||
},
|
||||
{ &hf_btcommon_eir_ad_custom_uuid_128,
|
||||
{ "Custom UUID", "btcommon.eir_ad.entry.custom_uuid_128",
|
||||
FT_BYTES, BASE_NONE, NULL, 0x0,
|
||||
NULL, HFILL }
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue