diff options
Diffstat (limited to 'epan/dissectors/packet-hci_h4.c')
-rw-r--r-- | epan/dissectors/packet-hci_h4.c | 68 |
1 files changed, 19 insertions, 49 deletions
diff --git a/epan/dissectors/packet-hci_h4.c b/epan/dissectors/packet-hci_h4.c index 5b2243b784..9e1f99bf71 100644 --- a/epan/dissectors/packet-hci_h4.c +++ b/epan/dissectors/packet-hci_h4.c @@ -31,9 +31,8 @@ #include <epan/packet.h> #include <wiretap/wtap.h> #include <epan/wmem/wmem.h> -#include <wiretap/wtap.h> -#include "packet-bluetooth-hci.h" +#include "packet-bluetooth.h" static int proto_hci_h4 = -1; static int hf_hci_h4_type = -1; @@ -46,12 +45,6 @@ static dissector_handle_t hci_h4_handle; static dissector_table_t hci_h4_table; static dissector_handle_t data_handle; -static wmem_tree_t *chandle_sessions = NULL; -static wmem_tree_t *chandle_to_bdaddr_table = NULL; -static wmem_tree_t *bdaddr_to_name_table = NULL; -static wmem_tree_t *localhost_name = NULL; -static wmem_tree_t *localhost_bdaddr = NULL; - static const value_string hci_h4_type_vals[] = { {HCI_H4_TYPE_CMD, "HCI Command"}, {HCI_H4_TYPE_ACL, "ACL Data"}, @@ -66,20 +59,20 @@ static const value_string hci_h4_direction_vals[] = { {0, NULL} }; -static guint32 max_disconnect_in_frame = G_MAXUINT32; - - void proto_register_hci_h4(void); void proto_reg_handoff_hci_h4(void); static gint -dissect_hci_h4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) +dissect_hci_h4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { - guint8 type; - tvbuff_t *next_tvb; - proto_item *ti = NULL; - proto_tree *hci_h4_tree = NULL; - hci_data_t *hci_data; + guint8 type; + tvbuff_t *next_tvb; + proto_item *main_item; + proto_tree *main_tree; + proto_item *sub_item; + bluetooth_data_t *bluetooth_data; + + bluetooth_data = (bluetooth_data_t *) data; col_set_str(pinfo->cinfo, COL_PROTOCOL, "HCI H4"); switch (pinfo->p2p_dir) { @@ -103,36 +96,19 @@ dissect_hci_h4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ type = tvb_get_guint8(tvb, 0); - if (tree) { - ti = proto_tree_add_item(tree, proto_hci_h4, tvb, 0, 1, ENC_NA); - hci_h4_tree = proto_item_add_subtree(ti, ett_hci_h4); - } + main_item = proto_tree_add_item(tree, proto_hci_h4, tvb, 0, 1, ENC_NA); + main_tree = proto_item_add_subtree(main_item, ett_hci_h4); - hci_data = (hci_data_t *) wmem_new(wmem_packet_scope(), hci_data_t); - if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) - hci_data->interface_id = pinfo->phdr->interface_id; - else - hci_data->interface_id = HCI_INTERFACE_DEFAULT; - hci_data->adapter_id = HCI_ADAPTER_DEFAULT; - hci_data->adapter_disconnect_in_frame = &max_disconnect_in_frame; - hci_data->chandle_sessions = chandle_sessions; - hci_data->chandle_to_bdaddr_table = chandle_to_bdaddr_table; - hci_data->bdaddr_to_name_table = bdaddr_to_name_table; - hci_data->localhost_bdaddr = localhost_bdaddr; - hci_data->localhost_name = localhost_name; - - pinfo->ptype = PT_BLUETOOTH; - - ti = proto_tree_add_uint(hci_h4_tree, hf_hci_h4_direction, tvb, 0, 0, pinfo->p2p_dir); - PROTO_ITEM_SET_GENERATED(ti); - - proto_tree_add_item(hci_h4_tree, hf_hci_h4_type, + sub_item = proto_tree_add_uint(main_tree, hf_hci_h4_direction, tvb, 0, 0, pinfo->p2p_dir); + PROTO_ITEM_SET_GENERATED(sub_item); + + proto_tree_add_item(main_tree, hf_hci_h4_type, tvb, 0, 1, ENC_LITTLE_ENDIAN); col_append_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str(type, hci_h4_type_vals, "Unknown HCI packet type 0x%02x")); next_tvb = tvb_new_subset_remaining(tvb, 1); - if (!dissector_try_uint_new(hci_h4_table, type, next_tvb, pinfo, tree, TRUE, hci_data)) { + if (!dissector_try_uint_new(hci_h4_table, type, next_tvb, pinfo, tree, TRUE, bluetooth_data)) { call_dissector(data_handle, next_tvb, pinfo, tree); } @@ -170,12 +146,6 @@ proto_register_hci_h4(void) hci_h4_table = register_dissector_table("hci_h4.type", "HCI H4 pdu type", FT_UINT8, BASE_HEX); - - chandle_sessions = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); - chandle_to_bdaddr_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, chandle: bdaddr */ - bdaddr_to_name_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* bdaddr: name */ - localhost_bdaddr = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: bdaddr */ - localhost_name = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* adapter, frame: name */ } void @@ -183,8 +153,8 @@ proto_reg_handoff_hci_h4(void) { data_handle = find_dissector("data"); - dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_H4, hci_h4_handle); - dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR, hci_h4_handle); + dissector_add_uint("bluetooth.encap", WTAP_ENCAP_BLUETOOTH_H4, hci_h4_handle); + dissector_add_uint("bluetooth.encap", WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR, hci_h4_handle); } /* |