diff options
-rw-r--r-- | epan/dissectors/packet-bluetooth.c | 35 | ||||
-rw-r--r-- | epan/dissectors/packet-bluetooth.h | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-bt3ds.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-btatt.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-btavctp.c | 71 | ||||
-rw-r--r-- | epan/dissectors/packet-btavdtp.c | 16 | ||||
-rw-r--r-- | epan/dissectors/packet-btavrcp.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-btbnep.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-bthcrp.c | 12 | ||||
-rw-r--r-- | epan/dissectors/packet-bthfp.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-bthid.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-bthsp.c | 7 | ||||
-rw-r--r-- | epan/dissectors/packet-btl2cap.c | 139 | ||||
-rw-r--r-- | epan/dissectors/packet-btmcap.c | 11 | ||||
-rw-r--r-- | epan/dissectors/packet-btobex.c | 62 | ||||
-rw-r--r-- | epan/dissectors/packet-btrfcomm.c | 90 | ||||
-rw-r--r-- | epan/dissectors/packet-btsap.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-btsdp.c | 10 | ||||
-rw-r--r-- | epan/dissectors/packet-btsdp.h | 1 |
19 files changed, 223 insertions, 270 deletions
diff --git a/epan/dissectors/packet-bluetooth.c b/epan/dissectors/packet-bluetooth.c index f994576722..12bfec2008 100644 --- a/epan/dissectors/packet-bluetooth.c +++ b/epan/dissectors/packet-bluetooth.c @@ -27,6 +27,7 @@ #include <epan/packet.h> #include <epan/to_str.h> #include <epan/conversation_table.h> +#include <epan/decode_as.h> #include <wiretap/wtap.h> #include "packet-bluetooth.h" @@ -47,6 +48,7 @@ static dissector_handle_t data_handle; static dissector_table_t bluetooth_table; static dissector_table_t hci_vendor_table; +dissector_table_t bluetooth_uuid_table; static wmem_tree_t *chandle_sessions = NULL; static wmem_tree_t *chandle_to_bdaddr = NULL; @@ -1022,6 +1024,28 @@ guint32 max_disconnect_in_frame = G_MAXUINT32; void proto_register_bluetooth(void); void proto_reg_handoff_bluetooth(void); +static void bluetooth_uuid_prompt(packet_info *pinfo, gchar* result) +{ + gchar *value_data; + + value_data = (gchar *) p_get_proto_data(pinfo->pool, pinfo, proto_bluetooth, PROTO_DATA_BLUETOOTH_SERVICE_UUID); + if (value_data) + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "BT Service UUID %s as", (gchar *) value_data); + else + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Unknown BT Service UUID"); +} + +static gpointer bluetooth_uuid_value(packet_info *pinfo) +{ + gchar *value_data; + + value_data = (gchar *) p_get_proto_data(pinfo->pool, pinfo, proto_bluetooth, PROTO_DATA_BLUETOOTH_SERVICE_UUID); + + if (value_data) + return (gpointer) value_data; + + return NULL; +} gint dissect_bd_addr(gint hf_bd_addr, packet_info *pinfo, proto_tree *tree, @@ -1499,6 +1523,13 @@ proto_register_bluetooth(void) &ett_bluetooth, }; + /* Decode As handling */ + static build_valid_func bluetooth_uuid_da_build_value[1] = {bluetooth_uuid_value}; + static decode_as_value_t bluetooth_uuid_da_values = {bluetooth_uuid_prompt, 1, bluetooth_uuid_da_build_value}; + static decode_as_t bluetooth_uuid_da = {"bluetooth", "BT Service UUID", "bluetooth.uuid", 1, 0, &bluetooth_uuid_da_values, NULL, NULL, + decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; + + proto_bluetooth = proto_register_protocol("Bluetooth", "Bluetooth", "bluetooth"); @@ -1524,7 +1555,11 @@ proto_register_bluetooth(void) bluetooth_tap = register_tap("bluetooth"); bluetooth_device_tap = register_tap("bluetooth.device"); + bluetooth_uuid_table = register_dissector_table("bluetooth.uuid", "BT Service UUID", FT_STRING, BASE_NONE); + register_conversation_table(proto_bluetooth, TRUE, bluetooth_conversation_packet, bluetooth_hostlist_packet); + + register_decode_as(&bluetooth_uuid_da); } void diff --git a/epan/dissectors/packet-bluetooth.h b/epan/dissectors/packet-bluetooth.h index 24259d1086..923eb1df69 100644 --- a/epan/dissectors/packet-bluetooth.h +++ b/epan/dissectors/packet-bluetooth.h @@ -31,6 +31,8 @@ extern "C" { #include "packet-usb.h" #include "packet-ubertooth.h" +#define PROTO_DATA_BLUETOOTH_SERVICE_UUID 0 + #define BLUETOOTH_DATA_SRC 0 #define BLUETOOTH_DATA_DST 1 @@ -232,6 +234,8 @@ extern int bluetooth_device_tap; WS_DLL_PUBLIC const value_string bluetooth_uuid_vals[]; WS_DLL_PUBLIC const bluetooth_uuid_custom_t bluetooth_uuid_custom[]; +extern dissector_table_t bluetooth_uuid_table; + WS_DLL_PUBLIC value_string_ext bluetooth_uuid_vals_ext; WS_DLL_PUBLIC value_string_ext bluetooth_company_id_vals_ext; extern guint32 max_disconnect_in_frame; diff --git a/epan/dissectors/packet-bt3ds.c b/epan/dissectors/packet-bt3ds.c index 5456ba01bc..9a83a088ca 100644 --- a/epan/dissectors/packet-bt3ds.c +++ b/epan/dissectors/packet-bt3ds.c @@ -180,9 +180,9 @@ proto_register_bt3ds(void) void proto_reg_handoff_bt3ds(void) { - dissector_add_uint("btl2cap.service", BTSDP_3D_SYNCHRONIZATION_UUID, b3ds_handle); - dissector_add_uint("btl2cap.service", BTSDP_3D_DISPLAY_UUID, b3ds_handle); - dissector_add_uint("btl2cap.service", BTSDP_3D_GLASSES_UUID, b3ds_handle); + dissector_add_string("bluetooth.uuid", "1137", b3ds_handle); + dissector_add_string("bluetooth.uuid", "1138", b3ds_handle); + dissector_add_string("bluetooth.uuid", "1139", b3ds_handle); dissector_add_uint("btl2cap.psm", BTL2CAP_PSM_3DS, b3ds_handle); dissector_add_for_decode_as("btl2cap.cid", b3ds_handle); diff --git a/epan/dissectors/packet-btatt.c b/epan/dissectors/packet-btatt.c index 0d30cb8113..c764bde337 100644 --- a/epan/dissectors/packet-btatt.c +++ b/epan/dissectors/packet-btatt.c @@ -4903,9 +4903,9 @@ proto_register_btatt(void) "Bluetooth Protocol ATT version from Core 4.0", "Version of protocol supported by this dissector."); - register_decode_as(&btatt_handle_da); - register_decode_as(&btatt_uuid16_da); - register_decode_as(&btatt_uuid128_da); + register_decode_as(&btatt_handle_da); + register_decode_as(&btatt_uuid16_da); + register_decode_as(&btatt_uuid128_da); } void diff --git a/epan/dissectors/packet-btavctp.c b/epan/dissectors/packet-btavctp.c index 390900ea65..3fd5c03441 100644 --- a/epan/dissectors/packet-btavctp.c +++ b/epan/dissectors/packet-btavctp.c @@ -54,8 +54,6 @@ static gint ett_btavctp = -1; static expert_field ei_btavctp_unexpected_frame = EI_INIT; static expert_field ei_btavctp_invalid_profile = EI_INIT; -static dissector_table_t avctp_service_dissector_table; - static dissector_handle_t btavctp_handle; static dissector_handle_t data_handle = NULL; @@ -98,34 +96,9 @@ static const value_string ipid_vals[] = { { 0, NULL } }; -#define BTAVCTP_PID_CONV 0 - void proto_register_btavctp(void); void proto_reg_handoff_btavctp(void); -static void btavctp_pid_prompt(packet_info *pinfo, gchar* result) -{ - gulong *value_data; - - value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btavctp, BTAVCTP_PID_CONV); - if (value_data) - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "AVCTP SERVICE 0x%04x as", (guint) *value_data); - else - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Unknown AVCTP SERVICE"); -} - -static gpointer btavctp_pid_value(packet_info *pinfo) -{ - gulong *value_data; - - value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btavctp, BTAVCTP_PID_CONV); - - if (value_data) - return (gpointer) *value_data; - - return NULL; -} - static gint dissect_btavctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { @@ -194,12 +167,18 @@ dissect_btavctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) proto_tree_add_item(btavctp_tree, hf_btavctp_pid, tvb, offset, 2, ENC_BIG_ENDIAN); pid = tvb_get_ntohs(tvb, offset); - if (p_get_proto_data(pinfo->pool, pinfo, proto_btavctp, BTAVCTP_PID_CONV ) == NULL) { - gulong *value_data; + if (p_get_proto_data(pinfo->pool, pinfo, proto_bluetooth, PROTO_DATA_BLUETOOTH_SERVICE_UUID ) == NULL) { + guint8 *value_data; + bluetooth_uuid_t uuid; + + uuid.size = 2; + uuid.bt_uuid = pid; + uuid.data[0] = pid >> 8; + uuid.data[1] = pid & 0xFF; - value_data = wmem_new(wmem_file_scope(), gulong); - *value_data = pid; - p_add_proto_data(pinfo->pool, pinfo, proto_btavctp, BTAVCTP_PID_CONV, value_data); + value_data = wmem_strdup(wmem_file_scope(), print_numeric_uuid(&uuid)); + + p_add_proto_data(pinfo->pool, pinfo, proto_bluetooth, PROTO_DATA_BLUETOOTH_SERVICE_UUID, value_data); } offset +=2; } @@ -227,7 +206,14 @@ dissect_btavctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) /* reassembling */ next_tvb = tvb_new_subset_length(tvb, offset, length); if (packet_type == PACKET_TYPE_SINGLE) { - if (!dissector_try_uint_new(avctp_service_dissector_table, pid, next_tvb, pinfo, tree, TRUE, avctp_data)) { + bluetooth_uuid_t uuid; + + uuid.size = 2; + uuid.bt_uuid = pid; + uuid.data[0] = pid >> 8; + uuid.data[1] = pid & 0xFF; + + if (!dissector_try_string(bluetooth_uuid_table, print_numeric_uuid(&uuid), next_tvb, pinfo, tree, avctp_data)) { call_dissector(data_handle, next_tvb, pinfo, tree); } @@ -399,6 +385,7 @@ dissect_btavctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) call_dissector(data_handle, next_tvb, pinfo, tree); } else { guint8 *reassembled; + bluetooth_uuid_t uuid; for (i_frame = 1; i_frame <= fragments->count; ++i_frame) { fragment = (fragment_t *)wmem_tree_lookup32_le(fragments->fragment, i_frame); @@ -418,7 +405,12 @@ dissect_btavctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) next_tvb = tvb_new_child_real_data(tvb, reassembled, length, length); add_new_data_source(pinfo, next_tvb, "Reassembled AVCTP"); - if (!dissector_try_uint_new(avctp_service_dissector_table, fragments->pid, next_tvb, pinfo, tree, TRUE, avctp_data)) { + uuid.size = 2; + uuid.bt_uuid = fragments->pid; + uuid.data[0] = fragments->pid >> 8; + uuid.data[1] = fragments->pid & 0xFF; + + if (!dissector_try_string(bluetooth_uuid_table, print_numeric_uuid(&uuid), next_tvb, pinfo, tree, avctp_data)) { call_dissector(data_handle, next_tvb, pinfo, tree); } } @@ -486,15 +478,8 @@ proto_register_btavctp(void) }; /* Decode As handling */ - static build_valid_func btavctp_pid_da_build_value[1] = {btavctp_pid_value}; - static decode_as_value_t btavctp_pid_da_values = {btavctp_pid_prompt, 1, btavctp_pid_da_build_value}; - static decode_as_t btavctp_pid_da = {"btavctp", "AVCTP SERVICE", "btavctp.service", 1, 0, &btavctp_pid_da_values, NULL, NULL, - decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; - reassembling = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); - avctp_service_dissector_table = register_dissector_table("btavctp.service", "BT AVCTP Service", FT_UINT16, BASE_HEX); - proto_btavctp = proto_register_protocol("Bluetooth AVCTP Protocol", "BT AVCTP", "btavctp"); btavctp_handle = new_register_dissector("btavctp", dissect_btavctp, proto_btavctp); @@ -507,8 +492,6 @@ proto_register_btavctp(void) prefs_register_static_text_preference(module, "avctp.version", "Bluetooth Protocol AVCTP version: 1.4", "Version of protocol supported by this dissector."); - - register_decode_as(&btavctp_pid_da); } @@ -517,7 +500,7 @@ proto_reg_handoff_btavctp(void) { data_handle = find_dissector("data"); - dissector_add_uint("btl2cap.service", BTSDP_AVCTP_PROTOCOL_UUID, btavctp_handle); + dissector_add_string("bluetooth.uuid", "17", btavctp_handle); dissector_add_uint("btl2cap.psm", BTL2CAP_PSM_AVCTP_CTRL, btavctp_handle); dissector_add_uint("btl2cap.psm", BTL2CAP_PSM_AVCTP_BRWS, btavctp_handle); diff --git a/epan/dissectors/packet-btavdtp.c b/epan/dissectors/packet-btavdtp.c index a04b5433b7..04a8bd4937 100644 --- a/epan/dissectors/packet-btavdtp.c +++ b/epan/dissectors/packet-btavdtp.c @@ -2710,7 +2710,7 @@ proto_register_btavdtp(void) void proto_reg_handoff_btavdtp(void) { - dissector_add_uint("btl2cap.service", BTSDP_AVDTP_PROTOCOL_UUID, btavdtp_handle); + dissector_add_string("bluetooth.uuid", "19", btavdtp_handle); dissector_add_uint("btl2cap.psm", BTL2CAP_PSM_AVDTP, btavdtp_handle); @@ -3145,9 +3145,10 @@ proto_reg_handoff_bta2dp(void) rtp_handle = find_dissector("rtp"); - dissector_add_uint("btl2cap.service", BTSDP_A2DP_SOURCE_SERVICE_UUID, bta2dp_handle); - dissector_add_uint("btl2cap.service", BTSDP_A2DP_SINK_SERVICE_UUID, bta2dp_handle); - dissector_add_uint("btl2cap.service", BTSDP_A2DP_DISTRIBUTION_SERVICE_UUID, bta2dp_handle); + dissector_add_string("bluetooth.uuid", "110a", bta2dp_handle); + dissector_add_string("bluetooth.uuid", "110b", bta2dp_handle); + dissector_add_string("bluetooth.uuid", "110d", bta2dp_handle); + dissector_add_for_decode_as("btl2cap.cid", bta2dp_handle); } @@ -3381,9 +3382,10 @@ proto_reg_handoff_btvdp(void) rtp_handle = find_dissector("rtp"); - dissector_add_uint("btl2cap.service", BTSDP_VDP_SOURCE_SERVICE_UUID, btvdp_handle); - dissector_add_uint("btl2cap.service", BTSDP_VDP_SINK_SERVICE_UUID, btvdp_handle); - dissector_add_uint("btl2cap.service", BTSDP_VDP_DISTRIBUTION_SERVICE_UUID, btvdp_handle); + dissector_add_string("bluetooth.uuid", "1303", btvdp_handle); + dissector_add_string("bluetooth.uuid", "1304", btvdp_handle); + dissector_add_string("bluetooth.uuid", "1305", btvdp_handle); + dissector_add_for_decode_as("btl2cap.cid", btvdp_handle); } diff --git a/epan/dissectors/packet-btavrcp.c b/epan/dissectors/packet-btavrcp.c index 715a2a5a87..1104bb1235 100644 --- a/epan/dissectors/packet-btavrcp.c +++ b/epan/dissectors/packet-btavrcp.c @@ -3203,9 +3203,9 @@ proto_register_btavrcp(void) void proto_reg_handoff_btavrcp(void) { - dissector_add_uint("btavctp.service", BTSDP_AVRCP_TG_SERVICE_UUID, btavrcp_handle); - dissector_add_uint("btavctp.service", BTSDP_AVRCP_CT_SERVICE_UUID, btavrcp_handle); - dissector_add_uint("btavctp.service", BTSDP_AVRCP_SERVICE_UUID, btavrcp_handle); + dissector_add_string("bluetooth.uuid", "110c", btavrcp_handle); + dissector_add_string("bluetooth.uuid", "110e", btavrcp_handle); + dissector_add_string("bluetooth.uuid", "110f", btavrcp_handle); } diff --git a/epan/dissectors/packet-btbnep.c b/epan/dissectors/packet-btbnep.c index 764d7f3e5e..73a669b981 100644 --- a/epan/dissectors/packet-btbnep.c +++ b/epan/dissectors/packet-btbnep.c @@ -541,9 +541,9 @@ proto_reg_handoff_btbnep(void) data_handle = find_dissector("data"); ethertype_handle = find_dissector("ethertype"); - dissector_add_uint("btl2cap.service", BTSDP_PAN_GN_SERVICE_UUID, btbnep_handle); - dissector_add_uint("btl2cap.service", BTSDP_PAN_NAP_SERVICE_UUID, btbnep_handle); - dissector_add_uint("btl2cap.service", BTSDP_PAN_GN_SERVICE_UUID, btbnep_handle); + dissector_add_string("bluetooth.uuid", "1115", btbnep_handle); + dissector_add_string("bluetooth.uuid", "1116", btbnep_handle); + dissector_add_string("bluetooth.uuid", "1117", btbnep_handle); dissector_add_uint("btl2cap.psm", BTL2CAP_PSM_BNEP, btbnep_handle); dissector_add_for_decode_as("btl2cap.cid", btbnep_handle); diff --git a/epan/dissectors/packet-bthcrp.c b/epan/dissectors/packet-bthcrp.c index 9f7625bafa..52ea0004ab 100644 --- a/epan/dissectors/packet-bthcrp.c +++ b/epan/dissectors/packet-bthcrp.c @@ -677,12 +677,12 @@ proto_reg_handoff_bthcrp(void) { data_handle = find_dissector("data"); - dissector_add_uint("btl2cap.service", BTSDP_HARDCOPY_CONTROL_CHANNEL_PROTOCOL_UUID, bthcrp_handle); - dissector_add_uint("btl2cap.service", BTSDP_HARDCOPY_DATA_CHANNEL_PROTOCOL_UUID, bthcrp_handle); - dissector_add_uint("btl2cap.service", BTSDP_HARDCOPY_NOTIFICATION_PROTOCOL_UUID, bthcrp_handle); - dissector_add_uint("btl2cap.service", BTSDP_HCRP_PRINT_SERVICE_UUID, bthcrp_handle); - dissector_add_uint("btl2cap.service", BTSDP_HCRP_SCAN_SERVICE_UUID, bthcrp_handle); - dissector_add_uint("btl2cap.service", BTSDP_HCRP_SERVICE_UUID, bthcrp_handle); + dissector_add_string("bluetooth.uuid", "12", bthcrp_handle); + dissector_add_string("bluetooth.uuid", "14", bthcrp_handle); + dissector_add_string("bluetooth.uuid", "16", bthcrp_handle); + dissector_add_string("bluetooth.uuid", "1125", bthcrp_handle); + dissector_add_string("bluetooth.uuid", "1126", bthcrp_handle); + dissector_add_string("bluetooth.uuid", "1127", bthcrp_handle); dissector_add_for_decode_as("btl2cap.psm", bthcrp_handle); dissector_add_for_decode_as("btl2cap.cid", bthcrp_handle); diff --git a/epan/dissectors/packet-bthfp.c b/epan/dissectors/packet-bthfp.c index a23b65e81a..59cb8ec31d 100644 --- a/epan/dissectors/packet-bthfp.c +++ b/epan/dissectors/packet-bthfp.c @@ -2976,8 +2976,9 @@ proto_register_bthfp(void) void proto_reg_handoff_bthfp(void) { - dissector_add_uint("btrfcomm.service", BTSDP_HFP_SERVICE_UUID, bthfp_handle); - dissector_add_uint("btrfcomm.service", BTSDP_HFP_GW_SERVICE_UUID, bthfp_handle); + dissector_add_string("bluetooth.uuid", "111e", bthfp_handle); + dissector_add_string("bluetooth.uuid", "111f", bthfp_handle); + dissector_add_for_decode_as("btrfcomm.channel", bthfp_handle); } diff --git a/epan/dissectors/packet-bthid.c b/epan/dissectors/packet-bthid.c index a122b6a923..3062aec4c7 100644 --- a/epan/dissectors/packet-bthid.c +++ b/epan/dissectors/packet-bthid.c @@ -425,8 +425,8 @@ proto_reg_handoff_bthid(void) usb_hid_boot_keyboard_output_report_handle = find_dissector("usbhid.boot_report.keyboard.output"); usb_hid_boot_mouse_input_report_handle = find_dissector("usbhid.boot_report.mouse.input"); - dissector_add_uint("btl2cap.service", BTSDP_HID_SERVICE_UUID, bthid_handle); - dissector_add_uint("btl2cap.service", BTSDP_HIDP_PROTOCOL_UUID, bthid_handle); + dissector_add_string("bluetooth.uuid", "11", bthid_handle); + dissector_add_string("bluetooth.uuid", "1124", bthid_handle); dissector_add_uint("btl2cap.psm", BTL2CAP_PSM_HID_CTRL, bthid_handle); dissector_add_uint("btl2cap.psm", BTL2CAP_PSM_HID_INTR, bthid_handle); diff --git a/epan/dissectors/packet-bthsp.c b/epan/dissectors/packet-bthsp.c index 0b3cfe2e7c..8f263f5314 100644 --- a/epan/dissectors/packet-bthsp.c +++ b/epan/dissectors/packet-bthsp.c @@ -1155,9 +1155,10 @@ proto_register_bthsp(void) void proto_reg_handoff_bthsp(void) { - dissector_add_uint("btrfcomm.service", BTSDP_HSP_SERVICE_UUID, bthsp_handle); - dissector_add_uint("btrfcomm.service", BTSDP_HSP_HS_SERVICE_UUID, bthsp_handle); - dissector_add_uint("btrfcomm.service", BTSDP_HSP_GW_SERVICE_UUID, bthsp_handle); + dissector_add_string("bluetooth.uuid", "1108", bthsp_handle); + dissector_add_string("bluetooth.uuid", "1112", bthsp_handle); + dissector_add_string("bluetooth.uuid", "1131", bthsp_handle); + dissector_add_for_decode_as("btrfcomm.channel", bthsp_handle); } diff --git a/epan/dissectors/packet-btl2cap.c b/epan/dissectors/packet-btl2cap.c index 712bc2418c..051afc117c 100644 --- a/epan/dissectors/packet-btl2cap.c +++ b/epan/dissectors/packet-btl2cap.c @@ -150,7 +150,6 @@ static expert_field ei_btl2cap_unknown_command_code = EI_INIT; /* Initialize dissector table */ static dissector_table_t l2cap_psm_dissector_table; static dissector_table_t l2cap_cid_dissector_table; -static dissector_table_t l2cap_service_dissector_table; /* This table maps cid values to psm values. * The same table is used both for SCID and DCID. @@ -399,9 +398,8 @@ static const range_string le_psm_rvals[] = { { 0, 0, NULL } }; -#define BTL2CAP_CID_CONV 0 -#define BTL2CAP_PSM_CONV 1 -#define BTL2CAP_SERV_CONV 2 +#define PROTO_DATA_BTL2CAP_CID 0 +#define PROTO_DATA_BTL2CAP_PSM 1 void proto_register_btl2cap(void); void proto_reg_handoff_btl2cap(void); @@ -410,7 +408,7 @@ static void btl2cap_cid_prompt(packet_info *pinfo, gchar* result) { gulong *value_data; - value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_CID_CONV); + value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_CID); if (value_data) g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "L2CAP CID 0x%04x as", (guint) *value_data); else @@ -421,7 +419,7 @@ static gpointer btl2cap_cid_value(packet_info *pinfo) { gulong *value_data; - value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_CID_CONV); + value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_CID); if (value_data) return (gpointer) *value_data; @@ -433,7 +431,7 @@ static void btl2cap_psm_prompt(packet_info *pinfo, gchar* result) { gulong *value_data; - value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_PSM_CONV); + value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_PSM); if (value_data) g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "L2CAP PSM 0x%04x as", (guint) *value_data); else @@ -444,30 +442,7 @@ static gpointer btl2cap_psm_value(packet_info *pinfo) { gulong *value_data; - value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_PSM_CONV); - - if (value_data) - return (gpointer) *value_data; - - return NULL; -} - -static void btl2cap_serv_prompt(packet_info *pinfo, gchar* result) -{ - gulong *value_data; - - value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_SERV_CONV); - if (value_data) - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "L2CAP SERVICE 0x%04x as", (guint) *value_data); - else - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Unknown L2CAP SERVICE"); -} - -static gpointer btl2cap_serv_value(packet_info *pinfo) -{ - gulong *value_data; - - value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_SERV_CONV); + value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_PSM); if (value_data) return (gpointer) *value_data; @@ -601,13 +576,13 @@ dissect_connrequest(tvbuff_t *tvb, int offset, packet_info *pinfo, psm = tvb_get_letohs(tvb, offset); - if (p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_PSM_CONV ) == NULL) { + if (p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_PSM ) == NULL) { gulong *value_data; value_data = wmem_new(wmem_file_scope(), gulong); *value_data = psm; - p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_PSM_CONV, value_data); + p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_PSM, value_data); } if (psm < BTL2CAP_DYNAMIC_PSM_START) { @@ -1467,26 +1442,31 @@ dissect_b_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (psm) { proto_item *psm_item; - guint16 uuid; + guint16 bt_uuid; + bluetooth_uuid_t uuid; - if (p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_PSM_CONV ) == NULL) { + if (p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_PSM ) == NULL) { gulong *value_data; value_data = wmem_new(wmem_file_scope(), gulong); *value_data = psm; - p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_PSM_CONV, value_data); + p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_PSM, value_data); } - uuid = get_service_uuid(pinfo, l2cap_data, psm, is_local_psm); + bt_uuid = get_service_uuid(pinfo, l2cap_data, psm, is_local_psm); - if (p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_SERV_CONV ) == NULL) { - gulong *value_data; + uuid.size = 2; + uuid.bt_uuid = bt_uuid; + uuid.data[0] = bt_uuid >> 8; + uuid.data[1] = bt_uuid & 0xFF; - value_data = wmem_new(wmem_file_scope(), gulong); - *value_data = uuid; + if (bt_uuid && p_get_proto_data(pinfo->pool, pinfo, proto_bluetooth, PROTO_DATA_BLUETOOTH_SERVICE_UUID) == NULL) { + guint8 *value_data; + + value_data = wmem_strdup(wmem_file_scope(), print_numeric_uuid(&uuid)); - p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_SERV_CONV, value_data); + p_add_proto_data(pinfo->pool, pinfo, proto_bluetooth, PROTO_DATA_BLUETOOTH_SERVICE_UUID, value_data); } if (psm < BTL2CAP_DYNAMIC_PSM_START) { @@ -1494,9 +1474,9 @@ dissect_b_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } else { psm_item = proto_tree_add_uint(btl2cap_tree, hf_btl2cap_psm_dynamic, tvb, offset, 0, psm); - if (uuid) + if (uuid.bt_uuid) proto_item_append_text(psm_item, ": %s", - val_to_str_ext_const(uuid, &bluetooth_uuid_vals_ext, "Unknown service")); + val_to_str_ext_const(uuid.bt_uuid, &bluetooth_uuid_vals_ext, "Unknown service")); } PROTO_ITEM_SET_GENERATED(psm_item); @@ -1504,7 +1484,7 @@ dissect_b_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (!dissector_try_uint_new(l2cap_cid_dissector_table, (guint32) cid, next_tvb, pinfo, tree, TRUE, l2cap_data)) { if (!dissector_try_uint_new(l2cap_psm_dissector_table, (guint32) psm, next_tvb, pinfo, tree, TRUE, l2cap_data)) { /* not a known fixed PSM, try to find a registered service to a dynamic PSM */ - if (!dissector_try_uint_new(l2cap_service_dissector_table, uuid, next_tvb, pinfo, tree, TRUE, l2cap_data)) { + if (!dissector_try_string(bluetooth_uuid_table, print_numeric_uuid(&uuid), next_tvb, pinfo, tree, l2cap_data)) { /* unknown protocol. declare as data */ proto_tree_add_item(btl2cap_tree, hf_btl2cap_payload, tvb, offset, length, ENC_NA); } @@ -1642,42 +1622,47 @@ dissect_i_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (next_tvb) { if (psm) { proto_item *psm_item; - guint16 uuid; + guint16 bt_uuid; + bluetooth_uuid_t uuid; - if (p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_PSM_CONV ) == NULL) { + if (p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_PSM ) == NULL) { gulong *value_data; value_data = wmem_new(wmem_file_scope(), gulong); *value_data = psm; - p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_PSM_CONV, value_data); + p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_PSM, value_data); } - uuid = get_service_uuid(pinfo, l2cap_data, psm, psm_data->local_service); + bt_uuid = get_service_uuid(pinfo, l2cap_data, psm, psm_data->local_service); - if (p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_SERV_CONV ) == NULL) { - gulong *value_data; + uuid.size = 2; + uuid.bt_uuid = bt_uuid; + uuid.data[0] = bt_uuid >> 8; + uuid.data[1] = bt_uuid & 0xFF; - value_data = wmem_new(wmem_file_scope(), gulong); - *value_data = uuid; + if (bt_uuid && p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BLUETOOTH_SERVICE_UUID) == NULL) { + guint8 *value_data; + + value_data = wmem_strdup(wmem_file_scope(), print_numeric_uuid(&uuid)); - p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_SERV_CONV, value_data); + p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BLUETOOTH_SERVICE_UUID, value_data); } if (psm < BTL2CAP_DYNAMIC_PSM_START) { psm_item = proto_tree_add_uint(btl2cap_tree, hf_btl2cap_psm, tvb, offset, 0, psm); } else { psm_item = proto_tree_add_uint(btl2cap_tree, hf_btl2cap_psm_dynamic, tvb, offset, 0, psm); - if (uuid) + if (uuid.bt_uuid) proto_item_append_text(psm_item, " (%s)", - val_to_str_ext_const(uuid, &bluetooth_uuid_vals_ext, "Unknown service")); + val_to_str_ext_const(uuid.bt_uuid, &bluetooth_uuid_vals_ext, "Unknown service")); } PROTO_ITEM_SET_GENERATED(psm_item); /* call next dissector */ if (!dissector_try_uint_new(l2cap_psm_dissector_table, (guint32) psm, next_tvb, pinfo, tree, TRUE, l2cap_data)) { /* not a known fixed PSM, try to find a registered service to a dynamic PSM */ - if (!dissector_try_uint_new(l2cap_service_dissector_table, uuid, next_tvb, pinfo, tree, TRUE, l2cap_data)) { + if (!dissector_try_string(bluetooth_uuid_table, print_numeric_uuid(&uuid), next_tvb, pinfo, tree, l2cap_data)) { /* unknown protocol. declare as data */ proto_tree_add_item(btl2cap_tree, hf_btl2cap_payload, next_tvb, 0, tvb_reported_length(next_tvb), ENC_NA); } @@ -1774,13 +1759,13 @@ dissect_btl2cap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) cid = tvb_get_letohs(tvb, offset); proto_tree_add_item(btl2cap_tree, hf_btl2cap_cid, tvb, offset, 2, ENC_LITTLE_ENDIAN); - if (p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_CID_CONV ) == NULL) { + if (p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_CID ) == NULL) { gulong *value_data; value_data = wmem_new(wmem_file_scope(), gulong); *value_data = cid; - p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_CID_CONV, value_data); + p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_CID, value_data); } offset += 2; @@ -1990,13 +1975,13 @@ dissect_btl2cap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) l2cap_data->psm = psm; l2cap_data->disconnect_in_frame = &max_disconnect_in_frame; - if (p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_PSM_CONV ) == NULL) { + if (p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_PSM ) == NULL) { gulong *value_data; value_data = wmem_new(wmem_file_scope(), gulong); *value_data = psm; - p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_PSM_CONV, value_data); + p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, PROTO_DATA_BTL2CAP_PSM, value_data); } proto_tree_add_item(btl2cap_tree, hf_btl2cap_psm, tvb, offset, 2, ENC_LITTLE_ENDIAN); @@ -2007,20 +1992,25 @@ dissect_btl2cap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) /* call next dissector */ if (!dissector_try_uint_new(l2cap_psm_dissector_table, (guint32) psm, next_tvb, pinfo, tree, TRUE, l2cap_data)) { /* not a known fixed PSM, try to find a registered service to a dynamic PSM */ - guint16 uuid; + guint16 bt_uuid; + bluetooth_uuid_t uuid; - uuid = get_service_uuid(pinfo, l2cap_data, psm, (pinfo->p2p_dir == P2P_DIR_RECV) ? TRUE : FALSE ); + bt_uuid = get_service_uuid(pinfo, l2cap_data, psm, (pinfo->p2p_dir == P2P_DIR_RECV) ? TRUE : FALSE ); - if (p_get_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_SERV_CONV ) == NULL) { - gulong *value_data; + uuid.size = 2; + uuid.bt_uuid = bt_uuid; + uuid.data[0] = bt_uuid >> 8; + uuid.data[1] = bt_uuid & 0xFF; - value_data = wmem_new(wmem_file_scope(), gulong); - *value_data = uuid; + if (bt_uuid && p_get_proto_data(pinfo->pool, pinfo, proto_bluetooth, PROTO_DATA_BLUETOOTH_SERVICE_UUID ) == NULL) { + guint8 *value_data; - p_add_proto_data(pinfo->pool, pinfo, proto_btl2cap, BTL2CAP_SERV_CONV, value_data); + value_data = wmem_strdup(wmem_file_scope(), print_numeric_uuid(&uuid)); + + p_add_proto_data(pinfo->pool, pinfo, proto_bluetooth, PROTO_DATA_BLUETOOTH_SERVICE_UUID, value_data); } - if (!dissector_try_uint_new(l2cap_service_dissector_table, uuid, next_tvb, pinfo, tree, TRUE, l2cap_data)) { + if (!dissector_try_string(bluetooth_uuid_table, print_numeric_uuid(&uuid), next_tvb, pinfo, tree, l2cap_data)) { /* unknown protocol. declare as data */ proto_tree_add_item(btl2cap_tree, hf_btl2cap_payload, tvb, offset, length, ENC_NA); } @@ -2653,20 +2643,14 @@ proto_register_btl2cap(void) static decode_as_t btl2cap_psm_da = {"btl2cap", "L2CAP PSM", "btl2cap.psm", 1, 0, &btl2cap_psm_da_values, NULL, NULL, decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; - static build_valid_func btl2cap_serv_da_build_value[1] = {btl2cap_serv_value}; - static decode_as_value_t btl2cap_serv_da_values = {btl2cap_serv_prompt, 1, btl2cap_serv_da_build_value}; - static decode_as_t btl2cap_serv_da = {"btl2cap", "L2CAP SERVICE", "btl2cap.service", 1, 0, &btl2cap_serv_da_values, NULL, NULL, - decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; - /* Register the protocol name and description */ proto_btl2cap = proto_register_protocol("Bluetooth L2CAP Protocol", "BT L2CAP", "btl2cap"); new_register_dissector("btl2cap", dissect_btl2cap, proto_btl2cap); /* subdissector code */ - l2cap_psm_dissector_table = register_dissector_table("btl2cap.psm", "BT L2CAP PSM", FT_UINT16, BASE_HEX); - l2cap_service_dissector_table = register_dissector_table("btl2cap.service", "BT L2CAP Service", FT_UINT16, BASE_HEX); - l2cap_cid_dissector_table = register_dissector_table("btl2cap.cid", "BT L2CAP CID", FT_UINT16, BASE_HEX); + l2cap_psm_dissector_table = register_dissector_table("btl2cap.psm", "BT L2CAP PSM", FT_UINT16, BASE_HEX); + l2cap_cid_dissector_table = register_dissector_table("btl2cap.cid", "BT L2CAP CID", FT_UINT16, BASE_HEX); /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_btl2cap, hf, array_length(hf)); @@ -2678,7 +2662,6 @@ proto_register_btl2cap(void) register_decode_as(&btl2cap_cid_da); register_decode_as(&btl2cap_psm_da); - register_decode_as(&btl2cap_serv_da); } diff --git a/epan/dissectors/packet-btmcap.c b/epan/dissectors/packet-btmcap.c index d5fcbb2429..f9e3138ab4 100644 --- a/epan/dissectors/packet-btmcap.c +++ b/epan/dissectors/packet-btmcap.c @@ -434,12 +434,11 @@ proto_register_btmcap(void) void proto_reg_handoff_btmcap(void) { - dissector_add_uint("btl2cap.service", BTSDP_MCAP_CONTROL_CHANNEL_PROTOCOL_UUID, btmcap_handle); - dissector_add_uint("btl2cap.service", BTSDP_MCAP_DATA_CHANNEL_PROTOCOL_UUID, btmcap_handle); - - dissector_add_uint("btl2cap.service", BTSDP_HDP_SERVICE_UUID, btmcap_handle); - dissector_add_uint("btl2cap.service", BTSDP_HDP_SOURCE_SERVICE_UUID, btmcap_handle); - dissector_add_uint("btl2cap.service", BTSDP_HDP_SINK_SERVICE_UUID, btmcap_handle); + dissector_add_string("bluetooth.uuid", "1e", btmcap_handle); + dissector_add_string("bluetooth.uuid", "1f", btmcap_handle); + dissector_add_string("bluetooth.uuid", "1400", btmcap_handle); + dissector_add_string("bluetooth.uuid", "1401", btmcap_handle); + dissector_add_string("bluetooth.uuid", "1402", btmcap_handle); /* dynamic PSM */ dissector_add_for_decode_as("btl2cap.psm", btmcap_handle); diff --git a/epan/dissectors/packet-btobex.c b/epan/dissectors/packet-btobex.c index e6799c8e03..62f4813795 100644 --- a/epan/dissectors/packet-btobex.c +++ b/epan/dissectors/packet-btobex.c @@ -3974,48 +3974,26 @@ proto_register_btobex(void) void proto_reg_handoff_btobex(void) { - /* register in rfcomm and l2cap the profiles/services this dissector should handle */ - dissector_add_uint("btrfcomm.service", BTSDP_OPP_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_FTP_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_BPP_DIRECT_PRINTING_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_BPP_REFERENCE_PRINTING_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_BPP_DIRECT_PRINTING_REF_OBJ_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_BPP_REFLECTED_UI_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_BPP_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_BPP_STATUS_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_BIP_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_BIP_RESPONDER_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_BIP_AUTO_ARCH_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_BIP_REF_OBJ_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_PBAP_PCE_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_PBAP_PSE_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_PBAP_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_MAP_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_MAP_ACCESS_SRV_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_MAP_NOTIFICATION_SRV_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_SYNC_SERVICE_UUID, btobex_handle); - dissector_add_uint("btrfcomm.service", BTSDP_SYNC_COMMAND_SERVICE_UUID, btobex_handle); - - dissector_add_uint("btl2cap.service", BTSDP_OPP_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_FTP_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_BPP_DIRECT_PRINTING_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_BPP_REFERENCE_PRINTING_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_BPP_DIRECT_PRINTING_REF_OBJ_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_BPP_REFLECTED_UI_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_BPP_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_BPP_STATUS_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_BIP_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_BIP_RESPONDER_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_BIP_AUTO_ARCH_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_BIP_REF_OBJ_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_PBAP_PCE_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_PBAP_PSE_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_PBAP_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_MAP_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_MAP_ACCESS_SRV_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_MAP_NOTIFICATION_SRV_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_SYNC_SERVICE_UUID, btobex_handle); - dissector_add_uint("btl2cap.service", BTSDP_SYNC_COMMAND_SERVICE_UUID, btobex_handle); + dissector_add_string("bluetooth.uuid", "1104", btobex_handle); + dissector_add_string("bluetooth.uuid", "1105", btobex_handle); + dissector_add_string("bluetooth.uuid", "1106", btobex_handle); + dissector_add_string("bluetooth.uuid", "1107", btobex_handle); + dissector_add_string("bluetooth.uuid", "1118", btobex_handle); + dissector_add_string("bluetooth.uuid", "1119", btobex_handle); + dissector_add_string("bluetooth.uuid", "111a", btobex_handle); + dissector_add_string("bluetooth.uuid", "111b", btobex_handle); + dissector_add_string("bluetooth.uuid", "111c", btobex_handle); + dissector_add_string("bluetooth.uuid", "111d", btobex_handle); + dissector_add_string("bluetooth.uuid", "1120", btobex_handle); + dissector_add_string("bluetooth.uuid", "1121", btobex_handle); + dissector_add_string("bluetooth.uuid", "1122", btobex_handle); + dissector_add_string("bluetooth.uuid", "1123", btobex_handle); + dissector_add_string("bluetooth.uuid", "112e", btobex_handle); + dissector_add_string("bluetooth.uuid", "112f", btobex_handle); + dissector_add_string("bluetooth.uuid", "1130", btobex_handle); + dissector_add_string("bluetooth.uuid", "1132", btobex_handle); + dissector_add_string("bluetooth.uuid", "1133", btobex_handle); + dissector_add_string("bluetooth.uuid", "1134", btobex_handle); http_handle = find_dissector("http"); xml_handle = find_dissector("xml"); diff --git a/epan/dissectors/packet-btrfcomm.c b/epan/dissectors/packet-btrfcomm.c index eb6c92c226..e5d51a363e 100644 --- a/epan/dissectors/packet-btrfcomm.c +++ b/epan/dissectors/packet-btrfcomm.c @@ -124,7 +124,6 @@ static dissector_handle_t btdun_handle; static dissector_handle_t btspp_handle; static dissector_handle_t btgnss_handle; -static dissector_table_t rfcomm_service_dissector_table; static dissector_table_t rfcomm_channel_dissector_table; static wmem_tree_t *service_directions = NULL; @@ -265,48 +264,24 @@ void proto_reg_handoff_btspp(void); void proto_register_btgnss(void); void proto_reg_handoff_btgnss(void); -#define BTRFCOMM_SERVICE_CONV 0 -#define BTRFCOMM_CHANNEL_CONV 1 +#define PROTO_DATA_BTRFCOMM_CHANNEL 0 -static void btrfcomm_serv_prompt(packet_info *pinfo, gchar* result) +static void btrfcomm_channel_prompt(packet_info *pinfo, gchar* result) { gulong *value_data; - value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_SERVICE_CONV); - if (value_data) - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "RFCOMM SERVICE %d as", (guint) *value_data); - else - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Unknown RFCOMM SERVICE"); -} - -static gpointer btrfcomm_serv_value(packet_info *pinfo) -{ - gulong *value_data; - - value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_SERVICE_CONV); - - if (value_data) - return (gpointer) *value_data; - - return NULL; -} - -static void btrfcomm_chan_prompt(packet_info *pinfo, gchar* result) -{ - gulong *value_data; - - value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_CHANNEL_CONV); + value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, PROTO_DATA_BTRFCOMM_CHANNEL); if (value_data) g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "RFCOMM Channel %d as", (guint) *value_data); else g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Unknown RFCOMM Channel"); } -static gpointer btrfcomm_chan_value(packet_info *pinfo) +static gpointer btrfcomm_channel_value(packet_info *pinfo) { gulong *value_data; - value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_CHANNEL_CONV); + value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, PROTO_DATA_BTRFCOMM_CHANNEL); if (value_data) return (gpointer) *value_data; @@ -492,13 +467,13 @@ dissect_btrfcomm_address(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tr channel = dlci >> 1; proto_item_append_text(dlci_item, " (Direction: %d, Channel: %u)", dlci & 0x01, channel); - if (p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_CHANNEL_CONV) == NULL) { + if (p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, PROTO_DATA_BTRFCOMM_CHANNEL) == NULL) { gulong *value_data; value_data = wmem_new(wmem_file_scope(), gulong); *value_data = channel; - p_add_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_CHANNEL_CONV, value_data); + p_add_proto_data(pinfo->pool, pinfo, proto_btrfcomm, PROTO_DATA_BTRFCOMM_CHANNEL, value_data); } dlci_tree = proto_item_add_subtree(dlci_item, ett_dlci); @@ -771,9 +746,13 @@ dissect_btrfcomm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data col_append_fstr(pinfo->cinfo, COL_INFO, "%s Channel=%u ", val_to_str_const(frame_type, vs_frame_type_short, "Unknown"), dlci >> 1); - if (dlci && (frame_type == FRAME_TYPE_SABM)) - col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ", - val_to_str_ext_const(service_info->uuid.bt_uuid, &bluetooth_uuid_vals_ext, "Unknown")); + if (dlci && (frame_type == FRAME_TYPE_SABM)) { + if (service_info->uuid.size==16) + col_append_fstr(pinfo->cinfo, COL_INFO, "(UUID128: %s) ", print_uuid(&service_info->uuid)); + else + col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ", + val_to_str_ext_const(service_info->uuid.bt_uuid, &bluetooth_uuid_vals_ext, "Unknown")); + } /* UID frame */ if ((frame_type == FRAME_TYPE_UIH) && dlci && pf_flag) { @@ -874,19 +853,18 @@ dissect_btrfcomm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data rfcomm_data->remote_bd_addr_oui = l2cap_data->remote_bd_addr_oui; rfcomm_data->remote_bd_addr_id = l2cap_data->remote_bd_addr_id; - if (p_get_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_SERVICE_CONV ) == NULL) { - gulong *value_data; + if (service_info->uuid.size != 0 && p_get_proto_data(pinfo->pool, pinfo, proto_bluetooth, PROTO_DATA_BLUETOOTH_SERVICE_UUID) == NULL) { + guint8 *value_data; - value_data = wmem_new(wmem_file_scope(), gulong); - *value_data = service_info->uuid.bt_uuid; + value_data = wmem_strdup(wmem_file_scope(), print_numeric_uuid(&service_info->uuid)); - p_add_proto_data(pinfo->pool, pinfo, proto_btrfcomm, BTRFCOMM_SERVICE_CONV, value_data); + p_add_proto_data(pinfo->pool, pinfo, proto_bluetooth, PROTO_DATA_BLUETOOTH_SERVICE_UUID, value_data); } if (!dissector_try_uint_new(rfcomm_channel_dissector_table, (guint32) dlci >> 1, next_tvb, pinfo, tree, TRUE, rfcomm_data)) { - if (!dissector_try_uint_new(rfcomm_service_dissector_table, service_info->uuid.bt_uuid, - next_tvb, pinfo, tree, TRUE, rfcomm_data)) { + if (!dissector_try_string(bluetooth_uuid_table, print_numeric_uuid(&service_info->uuid), + next_tvb, pinfo, tree, rfcomm_data)) { decode_by_dissector = find_proto_by_channel(dlci >> 1); if (rfcomm_channels_enabled && decode_by_dissector) { call_dissector_with_data(decode_by_dissector, next_tvb, pinfo, tree, rfcomm_data); @@ -1143,14 +1121,9 @@ proto_register_btrfcomm(void) }; /* Decode As handling */ - static build_valid_func btrfcomm_serv_da_build_value[1] = {btrfcomm_serv_value}; - static decode_as_value_t btrfcomm_serv_da_values = {btrfcomm_serv_prompt, 1, btrfcomm_serv_da_build_value}; - static decode_as_t btrfcomm_serv_da = {"btrfcomm", "RFCOMM SERVICE", "btrfcomm.service", 1, 0, &btrfcomm_serv_da_values, NULL, NULL, - decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; - - static build_valid_func btrfcomm_chan_da_build_value[1] = {btrfcomm_chan_value}; - static decode_as_value_t btrfcomm_chan_da_values = {btrfcomm_chan_prompt, 1, btrfcomm_chan_da_build_value}; - static decode_as_t btrfcomm_chan_da = {"btrfcomm", "RFCOMM Channel", "btrfcomm.channel", 1, 0, &btrfcomm_chan_da_values, NULL, NULL, + static build_valid_func btrfcomm_channel_da_build_value[1] = {btrfcomm_channel_value}; + static decode_as_value_t btrfcomm_channel_da_values = {btrfcomm_channel_prompt, 1, btrfcomm_channel_da_build_value}; + static decode_as_t btrfcomm_channel_da = {"btrfcomm", "RFCOMM Channel", "btrfcomm.channel", 1, 0, &btrfcomm_channel_da_values, NULL, NULL, decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL}; /* Register the protocol name and description */ @@ -1165,8 +1138,7 @@ proto_register_btrfcomm(void) service_directions = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); - rfcomm_service_dissector_table = register_dissector_table("btrfcomm.service", "BT RFCOMM Service", FT_UINT16, BASE_HEX); - rfcomm_channel_dissector_table = register_dissector_table("btrfcomm.channel", "BT RFCOMM Channel", FT_UINT16, BASE_DEC); + rfcomm_channel_dissector_table = register_dissector_table("btrfcomm.channel", "BT RFCOMM Channel", FT_UINT16, BASE_DEC); module = prefs_register_protocol(proto_btrfcomm, NULL); prefs_register_static_text_preference(module, "rfcomm.version", @@ -1196,8 +1168,7 @@ proto_register_btrfcomm(void) "Decode by channel", uat_rfcomm_channels); - register_decode_as(&btrfcomm_serv_da); - register_decode_as(&btrfcomm_chan_da); + register_decode_as(&btrfcomm_channel_da); } void @@ -1282,7 +1253,8 @@ proto_register_btdun(void) void proto_reg_handoff_btdun(void) { - dissector_add_uint("btrfcomm.service", BTSDP_DUN_SERVICE_UUID, btdun_handle); + dissector_add_string("bluetooth.uuid", "1103", btdun_handle); + dissector_add_for_decode_as("btrfcomm.channel", btdun_handle); ppp_handle = find_dissector("ppp_raw_hdlc"); @@ -1348,7 +1320,8 @@ proto_register_btspp(void) void proto_reg_handoff_btspp(void) { - dissector_add_uint("btrfcomm.service", BTSDP_SPP_SERVICE_UUID, btspp_handle); + dissector_add_string("bluetooth.uuid", "1101", btspp_handle); + dissector_add_for_decode_as("btrfcomm.channel", btspp_handle); } @@ -1400,8 +1373,9 @@ proto_register_btgnss(void) void proto_reg_handoff_btgnss(void) { - dissector_add_uint("btrfcomm.service", BTSDP_GNSS_UUID, btgnss_handle); - dissector_add_uint("btrfcomm.service", BTSDP_GNSS_SERVER_UUID, btgnss_handle); + dissector_add_string("bluetooth.uuid", "1135", btgnss_handle); + dissector_add_string("bluetooth.uuid", "1136", btgnss_handle); + dissector_add_for_decode_as("btrfcomm.channel", btgnss_handle); } diff --git a/epan/dissectors/packet-btsap.c b/epan/dissectors/packet-btsap.c index 94b82ac50a..972764cb66 100644 --- a/epan/dissectors/packet-btsap.c +++ b/epan/dissectors/packet-btsap.c @@ -733,7 +733,7 @@ proto_reg_handoff_btsap(void) gsm_sim_resp_handle = find_dissector("gsm_sim.response"); iso7816_atr_handle = find_dissector("iso7816.atr"); - dissector_add_uint("btrfcomm.service", BTSDP_SAP_SERVICE_UUID, btsap_handle); + dissector_add_string("bluetooth.uuid", "112d", btsap_handle); dissector_add_for_decode_as("btrfcomm.channel", btsap_handle); } diff --git a/epan/dissectors/packet-btsdp.c b/epan/dissectors/packet-btsdp.c index 23eedead74..49597e1488 100644 --- a/epan/dissectors/packet-btsdp.c +++ b/epan/dissectors/packet-btsdp.c @@ -573,9 +573,6 @@ static expert_field ei_data_element_value_large = EI_INIT; static dissector_handle_t btsdp_handle; -static dissector_table_t btrfcomm_service_table; -static dissector_table_t btl2cap_service_table; - static wmem_tree_t *tid_requests = NULL; static wmem_tree_t *continuation_states = NULL; static wmem_tree_t *record_handle_services = NULL; @@ -1124,9 +1121,9 @@ get_specified_uuid(wmem_array_t *uuid_array) for (i_uuid = 0; i_uuid < size; i_uuid += 1) { p_uuid = (bluetooth_uuid_t *) wmem_array_index(uuid_array, i_uuid); - if (dissector_get_uint_handle(btrfcomm_service_table, p_uuid->bt_uuid)) + if (p_uuid->size == 16) /* CustomUUID (UUID128) is always ok */ break; - if (dissector_get_uint_handle(btl2cap_service_table, p_uuid->bt_uuid)) + if (dissector_get_string_handle(bluetooth_uuid_table, print_numeric_uuid(p_uuid))) break; } @@ -6545,9 +6542,6 @@ proto_reg_handoff_btsdp(void) { dissector_add_uint("btl2cap.psm", BTL2CAP_PSM_SDP, btsdp_handle); dissector_add_for_decode_as("btl2cap.cid", btsdp_handle); - - btrfcomm_service_table = find_dissector_table("btrfcomm.service"); - btl2cap_service_table = find_dissector_table("btl2cap.service"); } /* diff --git a/epan/dissectors/packet-btsdp.h b/epan/dissectors/packet-btsdp.h index 6f01428817..6b32c285f4 100644 --- a/epan/dissectors/packet-btsdp.h +++ b/epan/dissectors/packet-btsdp.h @@ -160,7 +160,6 @@ #define BTSDP_HDP_SOURCE_SERVICE_UUID 0x1401 #define BTSDP_HDP_SINK_SERVICE_UUID 0x1402 - #define BTSDP_LOCAL_SERVICE_FLAG_MASK 0x0001 #define BTSDP_SECONDARY_CHANNEL_FLAG_MASK 0x0002 |