From 95de6e0ecbc8ad726a2e060d04008a6710de8186 Mon Sep 17 00:00:00 2001 From: Jakub Zawadzki Date: Tue, 11 Sep 2012 11:53:34 +0000 Subject: Bluetooth: Move HFP dissector from RFCOMM file HFP is moved from RFCOMM where named HF. Then fix name to one used by SIG specification: HFP. Next step is improve dissection of HFP by dissect specific for this profile AT commands. From Michal Labedzki on behalf of Tieto Corporation Part of bug #7639 svn path=/trunk/; revision=44877 --- epan/CMakeLists.txt | 1 + epan/dissectors/Makefile.common | 1 + epan/dissectors/packet-bthfp.c | 100 ++++++++++++++++++++++++++++++++++++++ epan/dissectors/packet-btrfcomm.c | 60 ----------------------- 4 files changed, 102 insertions(+), 60 deletions(-) create mode 100644 epan/dissectors/packet-bthfp.c diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt index 6e0a6118f3..afd1c9e595 100644 --- a/epan/CMakeLists.txt +++ b/epan/CMakeLists.txt @@ -395,6 +395,7 @@ set(DISSECTOR_SRC dissectors/packet-bthci_cmd.c dissectors/packet-bthci_evt.c dissectors/packet-bthci_sco.c + dissectors/packet-bthfp.c dissectors/packet-bthid.c dissectors/packet-btl2cap.c dissectors/packet-btobex.c diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common index 75b7c81a6b..75645ffeb5 100644 --- a/epan/dissectors/Makefile.common +++ b/epan/dissectors/Makefile.common @@ -315,6 +315,7 @@ DISSECTOR_SRC = \ packet-bthci_cmd.c \ packet-bthci_evt.c \ packet-bthci_sco.c \ + packet-bthfp.c \ packet-bthid.c \ packet-btl2cap.c \ packet-btobex.c \ diff --git a/epan/dissectors/packet-bthfp.c b/epan/dissectors/packet-bthfp.c new file mode 100644 index 0000000000..dc7be3dcf5 --- /dev/null +++ b/epan/dissectors/packet-bthfp.c @@ -0,0 +1,100 @@ +/* packet-bthfp.c + * Routines for Bluetooth Handsfree Profile (HFP) + * + * Copyright 2002, Wolfgang Hansmann + * + * Refactored for wireshark checkin + * Ronnie Sahlberg 2006 + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +#include + +#include "packet-btsdp.h" + +static int hf_at_cmd = -1; + +static int proto_bthfp = -1; + +static gint ett_bthfp = -1; + +static void +dissect_bthfp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + proto_item *ti; + proto_tree *st; + + guint length = tvb_length(tvb); + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "HFP"); + + ti = proto_tree_add_item(tree, proto_bthfp, tvb, 0, -1, ENC_NA); + st = proto_item_add_subtree(ti, ett_bthfp); + + col_add_fstr(pinfo->cinfo, COL_INFO, "%s \"%s\"", + (pinfo->p2p_dir == P2P_DIR_SENT) ? "Sent" : "Rcvd", + tvb_format_text(tvb, 0, length)); + + proto_tree_add_item(st, hf_at_cmd, tvb, 0, -1, ENC_ASCII|ENC_NA); +} + +void +proto_register_bthfp(void) +{ + static hf_register_info hf[] = { + { &hf_at_cmd, + { "AT Cmd", "bthfp.atcmd", + FT_STRING, BASE_NONE, NULL, 0, + "AT Command", HFILL} + }, + }; + + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_bthfp, + }; + + proto_bthfp = proto_register_protocol("Bluetooth Handsfree Profile", "BT HFP", "bthfp"); + register_dissector("bthfp", dissect_bthfp, proto_bthfp); + + /* Required function calls to register the header fields and subtrees used */ + proto_register_field_array(proto_bthfp, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); +} + +void +proto_reg_handoff_bthfp(void) +{ + dissector_handle_t bthfp_handle; + + bthfp_handle = find_dissector("bthfp"); + + 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); +} diff --git a/epan/dissectors/packet-btrfcomm.c b/epan/dissectors/packet-btrfcomm.c index 1b73240cc6..63c27fcb55 100644 --- a/epan/dissectors/packet-btrfcomm.c +++ b/epan/dissectors/packet-btrfcomm.c @@ -1,7 +1,6 @@ /* packet-btrfcomm.c * Routines for Bluetooth RFCOMM protocol dissection * and RFCOMM based profile dissection: - * - Handsfree Profile (HFP) * - Dial-Up Networking (DUN) Profile * - Serial Port Profile (SPP) * @@ -78,7 +77,6 @@ static int hf_msc_l = -1; static int hf_fcs = -1; -static int hf_at_cmd = -1; static int hf_dun_at_cmd = -1; static int hf_data = -1; @@ -93,7 +91,6 @@ static int hf_mcc_pn_zeros_padding = -1; /* Initialize the protocol and registered fields */ static int proto_btrfcomm = -1; -static int proto_bthf = -1; static int proto_btdun = -1; static int proto_btspp = -1; @@ -108,7 +105,6 @@ static gint ett_ctrl_pn_v24 = -1; static gint ett_dlci = -1; static gint ett_mcc_dlci = -1; -static gint ett_bthf = -1; static gint ett_btdun = -1; static gint ett_btspp = -1; @@ -969,62 +965,6 @@ proto_reg_handoff_btrfcomm(void) register_tap_listener("btsdp", NULL, NULL, TL_IS_DISSECTOR_HELPER, NULL, btrfcomm_sdp_tap_packet, NULL); } -/* Bluetooth Handsfree (HF) profile dissection */ -static void -dissect_bthf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) -{ - proto_item *ti; - proto_tree *st; - - guint length = tvb_length(tvb); - - col_set_str(pinfo->cinfo, COL_PROTOCOL, "HANDSFREE"); - - ti = proto_tree_add_item(tree, proto_bthf, tvb, 0, -1, ENC_NA); - st = proto_item_add_subtree(ti, ett_bthf); - - col_add_fstr(pinfo->cinfo, COL_INFO, "%s \"%s\"", - (pinfo->p2p_dir == P2P_DIR_SENT) ? "Sent" : "Rcvd", - tvb_format_text(tvb, 0, length)); - - proto_tree_add_item(st, hf_at_cmd, tvb, 0, -1, ENC_ASCII|ENC_NA); -} - -void -proto_register_bthf(void) -{ - static hf_register_info hf[] = { - { &hf_at_cmd, - { "AT Cmd", "bthf.atcmd", - FT_STRING, BASE_NONE, NULL, 0, - "AT Command", HFILL} - }, - }; - - /* Setup protocol subtree array */ - static gint *ett[] = { - &ett_bthf, - }; - - proto_bthf = proto_register_protocol("Bluetooth Handsfree Packet", "BTHF", "bthf"); - - /* Required function calls to register the header fields and subtrees used */ - proto_register_field_array(proto_bthf, hf, array_length(hf)); - proto_register_subtree_array(ett, array_length(ett)); -} - -void -proto_reg_handoff_bthf(void) -{ - dissector_handle_t bthf_handle; - - bthf_handle = create_dissector_handle(dissect_bthf, proto_bthf); - - dissector_add_uint("btrfcomm.service", BTSDP_HFP_SERVICE_UUID, bthf_handle); - dissector_add_uint("btrfcomm.service", BTSDP_HFP_GW_SERVICE_UUID, bthf_handle); - dissector_add_handle("btrfcomm.channel", bthf_handle); -} - /* Bluetooth Dial-Up Networking (DUN) profile dissection */ static void dissect_btdun(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) -- cgit v1.2.1