For proto_tree_add_item(..., proto_xxx, ...)use ENC_NA as the encoding arg.
[obnox/wireshark/wip.git] / epan / dissectors / packet-bthci_sco.c
1 /* packet-bthci_sco.c
2  * Routines for the Bluetooth SCO dissection
3  * Copyright 2002, Christoph Scholz <scholz@cs.uni-bonn.de>
4  *
5  * Refactored for wireshark checkin
6  *   Ronnie Sahlberg 2006
7  *
8  * $Id$
9  *
10  * Wireshark - Network traffic analyzer
11  * By Gerald Combs <gerald@wireshark.org>
12  * Copyright 1998 Gerald Combs
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27  */
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33 #include <glib.h>
34 #include <epan/packet.h>
35 #include <etypes.h>
36 #include <packet-hci_h4.h>
37
38 /* Initialize the protocol and registered fields */
39 static int proto_btsco = -1;
40 static int hf_btsco_chandle = -1;
41 static int hf_btsco_length = -1;
42 static int hf_btsco_data = -1;
43
44 /* Initialize the subtree pointers */
45 static gint ett_btsco = -1;
46
47
48 /* Code to actually dissect the packets */
49 static void
50 dissect_btsco(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
51 {
52   proto_item *ti;
53   proto_tree *btsco_tree;
54   int offset=0;
55
56   ti = proto_tree_add_item(tree, proto_btsco, tvb, offset, -1, ENC_NA);
57   btsco_tree = proto_item_add_subtree(ti, ett_btsco);
58
59
60   proto_tree_add_item(btsco_tree, hf_btsco_chandle, tvb, offset, 2, ENC_LITTLE_ENDIAN);
61   offset+=2;
62
63   proto_tree_add_item(btsco_tree, hf_btsco_length, tvb, offset, 1, ENC_LITTLE_ENDIAN);
64   offset++;
65
66   proto_tree_add_item(btsco_tree, hf_btsco_data, tvb, offset, -1, ENC_NA);
67 }
68
69
70 void
71 proto_register_btsco(void)
72 {
73         static hf_register_info hf[] = {
74                 { &hf_btsco_chandle,
75                         { "Connection Handle",           "bthci_sco.chandle",
76                         FT_UINT16, BASE_HEX, NULL, 0x0FFF,
77                         NULL, HFILL }
78                 },
79                 { &hf_btsco_length,
80                         { "Data Total Length",           "bthci_sco.length",
81                         FT_UINT8, BASE_DEC, NULL, 0x0,
82                         NULL, HFILL }
83                 },
84                 { &hf_btsco_data,
85                         { "Data",           "bthci_sco.data",
86                         FT_NONE, BASE_NONE, NULL, 0x0,
87                         NULL, HFILL }
88                 },
89         };
90
91         /* Setup protocol subtree array */
92         static gint *ett[] = {
93           &ett_btsco,
94         };
95
96         /* Register the protocol name and description */
97         proto_btsco = proto_register_protocol("Bluetooth HCI SCO Packet", "HCI_SCO", "bthci_sco");
98         register_dissector("bthci_sco", dissect_btsco, proto_btsco);
99
100         /* Required function calls to register the header fields and subtrees used */
101         proto_register_field_array(proto_btsco, hf, array_length(hf));
102         proto_register_subtree_array(ett, array_length(ett));
103 }
104
105
106 void
107 proto_reg_handoff_btsco(void)
108 {
109         dissector_handle_t bthci_sco_handle;
110
111         bthci_sco_handle = find_dissector("bthci_sco");
112         dissector_add_uint("hci_h4.type", HCI_H4_TYPE_SCO, bthci_sco_handle);
113         dissector_add_uint("hci_h1.type", BTHCI_CHANNEL_SCO, bthci_sco_handle);
114 }
115
116