diff --git a/epan/dissectors/packet-bthfp.c b/epan/dissectors/packet-bthfp.c index 0cb9f286cc..6294a1d886 100644 --- a/epan/dissectors/packet-bthfp.c +++ b/epan/dissectors/packet-bthfp.c @@ -124,7 +124,6 @@ static gint ett_bthfp_brsf_ag = -1; static dissector_handle_t bthfp_handle; static wmem_tree_t *fragments = NULL; -static wmem_tree_t *sdp_service_infos = NULL; #define ROLE_UNKNOWN 0 #define ROLE_AG 1 @@ -1242,7 +1241,7 @@ dissect_bthfp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) key[9].length = 0; key[9].key = NULL; - service_info = (service_info_t *) wmem_tree_lookup32_array_le(sdp_service_infos, key); + service_info = btsdp_get_service_info(key); if (service_info && service_info->interface_id == rfcomm_data->interface_id && service_info->adapter_id == rfcomm_data->adapter_id && service_info->sdp_psm == SDP_PSM_DEFAULT && @@ -1529,18 +1528,6 @@ dissect_bthfp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) return offset; } -static int -bthfp_sdp_tap_packet(void *arg _U_, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *arg2) -{ - const sdp_package_t *sdp_package = (const sdp_package_t *) arg2; - - if (sdp_service_infos == NULL) { - sdp_service_infos = sdp_package->service_infos; - } - - return 0; -} - void proto_register_bthfp(void) { @@ -2048,8 +2035,6 @@ 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_handle("btrfcomm.channel", bthfp_handle); - - register_tap_listener("btsdp", NULL, NULL, TL_IS_DISSECTOR_HELPER, NULL, bthfp_sdp_tap_packet, NULL); } /* diff --git a/epan/dissectors/packet-bthsp.c b/epan/dissectors/packet-bthsp.c index 0cbbe73f19..089a57845f 100644 --- a/epan/dissectors/packet-bthsp.c +++ b/epan/dissectors/packet-bthsp.c @@ -71,7 +71,6 @@ static gint ett_bthsp_parameters = -1; static dissector_handle_t bthsp_handle; static wmem_tree_t *fragments = NULL; -static wmem_tree_t *sdp_service_infos = NULL; #define ROLE_UNKNOWN 0 #define ROLE_AG 1 @@ -741,7 +740,7 @@ dissect_bthsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) key[9].length = 0; key[9].key = NULL; - service_info = (service_info_t *) wmem_tree_lookup32_array_le(sdp_service_infos, key); + service_info = btsdp_get_service_info(key); if (service_info && service_info->interface_id == rfcomm_data->interface_id && service_info->adapter_id == rfcomm_data->adapter_id && service_info->sdp_psm == SDP_PSM_DEFAULT && @@ -1028,18 +1027,6 @@ dissect_bthsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) return offset; } -static int -bthsp_sdp_tap_packet(void *arg _U_, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *arg2) -{ - const sdp_package_t *sdp_package = (const sdp_package_t *) arg2; - - if (sdp_service_infos == NULL) { - sdp_service_infos = sdp_package->service_infos; - } - - return 0; -} - void proto_register_bthsp(void) { @@ -1177,8 +1164,6 @@ proto_reg_handoff_bthsp(void) 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_handle("btrfcomm.channel", bthsp_handle); - - register_tap_listener("btsdp", NULL, NULL, TL_IS_DISSECTOR_HELPER, NULL, bthsp_sdp_tap_packet, NULL); } /* diff --git a/epan/dissectors/packet-btl2cap.c b/epan/dissectors/packet-btl2cap.c index c5304f78e2..a22fade5d2 100644 --- a/epan/dissectors/packet-btl2cap.c +++ b/epan/dissectors/packet-btl2cap.c @@ -150,7 +150,6 @@ static dissector_table_t l2cap_service_dissector_table; * For received CIDs we 'or' the cid with 0x80000000 in this table */ static wmem_tree_t *cid_to_psm_table = NULL; -static wmem_tree_t *sdp_service_infos = NULL; typedef struct _config_data_t { guint8 mode; @@ -473,10 +472,8 @@ get_service_uuid(packet_info *pinfo, btl2cap_data_t *l2cap_data, guint16 psm, gb key[9].length = 0; key[9].key = NULL; - if (sdp_service_infos) - service_info = (service_info_t *) wmem_tree_lookup32_array_le(sdp_service_infos, key); - else - service_info = NULL; + service_info = btsdp_get_service_info(key); + if (service_info && service_info->interface_id == interface_id && service_info->adapter_id == adapter_id && service_info->sdp_psm == SDP_PSM_DEFAULT && @@ -1935,19 +1932,6 @@ dissect_btl2cap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) } -static int -btl2cap_sdp_tap_packet(void *arg _U_, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *arg2) -{ - const sdp_package_t *sdp_package = (const sdp_package_t *) arg2; - - if (sdp_service_infos == NULL) { - sdp_service_infos = sdp_package->service_infos; - } - - return 0; -} - - /* Register the protocol with Wireshark */ void proto_register_btl2cap(void) @@ -2436,10 +2420,6 @@ proto_register_btl2cap(void) void proto_reg_handoff_btl2cap(void) { - /* tap into the btsdp dissector to look for l2cap PSM infomation that - helps us determine the type of l2cap payload, i.e. which service is - using the PSM channel so we know which sub-dissector to call */ - register_tap_listener("btsdp", NULL, NULL, TL_IS_DISSECTOR_HELPER, NULL, btl2cap_sdp_tap_packet, NULL); } /* diff --git a/epan/dissectors/packet-btrfcomm.c b/epan/dissectors/packet-btrfcomm.c index f5e3a7d2d1..ab82587ef4 100644 --- a/epan/dissectors/packet-btrfcomm.c +++ b/epan/dissectors/packet-btrfcomm.c @@ -121,8 +121,6 @@ static gint ett_btgnss = -1; static expert_field ei_btrfcomm_mcc_length_bad = EI_INIT; -static wmem_tree_t *sdp_service_infos = NULL; - static dissector_table_t rfcomm_service_dissector_table; static dissector_table_t rfcomm_channel_dissector_table; @@ -660,9 +658,8 @@ dissect_btrfcomm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data key[9].length = 0; key[9].key = NULL; - if (sdp_service_infos) { - service_info = (service_info_t *) wmem_tree_lookup32_array_le(sdp_service_infos, key); - } + service_info = btsdp_get_service_info(key); + if (service_info && service_info->interface_id == l2cap_data->interface_id && service_info->adapter_id == l2cap_data->adapter_id && service_info->sdp_psm == SDP_PSM_DEFAULT && @@ -1104,18 +1101,6 @@ proto_register_btrfcomm(void) register_decode_as(&btrfcomm_chan_da); } -static int -btrfcomm_sdp_tap_packet(void *arg _U_, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *arg2) -{ - const sdp_package_t *sdp_package = (const sdp_package_t *) arg2; - - if (sdp_service_infos == NULL) { - sdp_service_infos = sdp_package->service_infos; - } - - return 0; -} - void proto_reg_handoff_btrfcomm(void) { @@ -1126,11 +1111,6 @@ proto_reg_handoff_btrfcomm(void) dissector_add_handle("btl2cap.cid", btrfcomm_handle); data_handle = find_dissector("data"); - - /* tap into the btsdp dissector to look for rfcomm channel infomation that - helps us determine the type of rfcomm payload, i.e. which service is - using the channels so we know which sub-dissector to call */ - register_tap_listener("btsdp", NULL, NULL, TL_IS_DISSECTOR_HELPER, NULL, btrfcomm_sdp_tap_packet, NULL); } /* Bluetooth Dial-Up Networking (DUN) profile dissection */ diff --git a/epan/dissectors/packet-btsdp.c b/epan/dissectors/packet-btsdp.c index a0e205021f..44cb853751 100644 --- a/epan/dissectors/packet-btsdp.c +++ b/epan/dissectors/packet-btsdp.c @@ -347,15 +347,11 @@ static expert_field ei_btsdp_continuation_state_none = EI_INIT; static expert_field ei_btsdp_continuation_state_large = EI_INIT; static expert_field ei_data_element_value_large = EI_INIT; -static gint btsdp_tap = -1; - static wmem_tree_t *tid_requests = NULL; static wmem_tree_t *continuation_states = NULL; static wmem_tree_t *record_handle_services = NULL; static wmem_tree_t *service_infos = NULL; -static sdp_package_t sdp_package; - typedef struct _tid_request_t { guint32 interface_id; guint32 adapter_id; @@ -970,6 +966,13 @@ extern value_string_ext usb_langid_vals_ext; void proto_register_btsdp(void); void proto_reg_handoff_btsdp(void); +service_info_t* btsdp_get_service_info(wmem_tree_key_t* key) +{ + if (service_infos == NULL) + return NULL; + + return (service_info_t *)wmem_tree_lookup32_array_le(service_infos, key); +} static uuid_t get_most_specified_uuid(wmem_array_t *uuid_array) @@ -4263,8 +4266,6 @@ dissect_btsdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) l2cap_data = (btl2cap_data_t *) data; DISSECTOR_ASSERT(l2cap_data); - tap_queue_packet(btsdp_tap, NULL, (void *) &sdp_package); - switch (pinfo->p2p_dir) { case P2P_DIR_SENT: col_set_str(pinfo->cinfo, COL_INFO, "Sent "); @@ -5749,8 +5750,6 @@ proto_register_btsdp(void) record_handle_services = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); service_infos = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); - sdp_package.service_infos = service_infos; - btsdp_tap = register_tap("btsdp"); module = prefs_register_protocol(proto_btsdp, NULL); prefs_register_static_text_preference(module, "bnep.version", diff --git a/epan/dissectors/packet-btsdp.h b/epan/dissectors/packet-btsdp.h index 4b0c39d661..e85b3dfc14 100644 --- a/epan/dissectors/packet-btsdp.h +++ b/epan/dissectors/packet-btsdp.h @@ -206,9 +206,7 @@ typedef struct _service_info_t { extern value_string_ext vs_service_classes_ext; -typedef struct _sdp_package_t { - wmem_tree_t *service_infos; -} sdp_package_t; +extern service_info_t* btsdp_get_service_info(wmem_tree_key_t* key); #endif