2 * Routines for DVB (ETSI EN 300 468) Bouquet Association Table (BAT) dissection
3 * Copyright 2012, Guy Martin <gmsoft@tuxicoman.be>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <epan/packet.h>
31 #include <epan/dissectors/packet-mpeg-sect.h>
33 #include "packet-mpeg-descriptor.h"
35 void proto_register_dvb_bat(void);
36 void proto_reg_handoff_dvb_bat(void);
38 static int proto_dvb_bat
= -1;
39 static int hf_dvb_bat_bouquet_id
= -1;
40 static int hf_dvb_bat_reserved1
= -1;
41 static int hf_dvb_bat_version_number
= -1;
42 static int hf_dvb_bat_current_next_indicator
= -1;
43 static int hf_dvb_bat_section_number
= -1;
44 static int hf_dvb_bat_last_section_number
= -1;
46 static int hf_dvb_bat_reserved2
= -1;
47 static int hf_dvb_bat_bouquet_descriptors_length
= -1;
49 static int hf_dvb_bat_reserved3
= -1;
50 static int hf_dvb_bat_transport_stream_loop_length
= -1;
52 static int hf_dvb_bat_transport_stream_id
= -1;
53 static int hf_dvb_bat_original_network_id
= -1;
54 static int hf_dvb_bat_reserved4
= -1;
55 static int hf_dvb_bat_transport_descriptors_length
= -1;
57 static gint ett_dvb_bat
= -1;
58 static gint ett_dvb_bat_transport_stream
= -1;
61 #define DVB_BAT_TID 0x4A
63 #define DVB_BAT_RESERVED1_MASK 0xC0
64 #define DVB_BAT_VERSION_NUMBER_MASK 0x3E
65 #define DVB_BAT_CURRENT_NEXT_INDICATOR_MASK 0x01
67 #define DVB_BAT_RESERVED2_MASK 0xF000
68 #define DVB_BAT_BOUQUET_DESCRIPTORS_LENGTH_MASK 0x0FFF
70 #define DVB_BAT_RESERVED3_MASK 0xF000
71 #define DVB_BAT_TRANSPORT_STREAM_LOOP_LENGTH_MASK 0x0FFF
73 #define DVB_BAT_RESERVED4_MASK 0xF000
74 #define DVB_BAT_TRANSPORT_DESCRIPTORS_LENGTH_MASK 0x0FFF
76 static const value_string dvb_bat_cur_next_vals
[] = {
77 { 0, "Not yet applicable" },
78 { 1, "Currently applicable" },
84 static const value_string dvb_bat_running_status_vals
[] = {
87 { 2, "Starts in a few seconds" },
90 { 5, "Service off-air" },
95 static const value_string dvb_bat_free_ca_mode_vals
[] = {
96 { 0, "Not Scrambled" },
97 { 1, "One or more component scrambled" },
104 dissect_dvb_bat(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
107 guint offset
= 0, length
= 0, ts_loop_end
;
108 guint16 ts_id
, descriptor_len
, ts_loop_len
;
111 proto_tree
*dvb_bat_tree
;
113 proto_tree
*transport_stream_tree
;
115 col_set_str(pinfo
->cinfo
, COL_INFO
, "Bouquet Association Table (BAT)");
117 ti
= proto_tree_add_item(tree
, proto_dvb_bat
, tvb
, offset
, -1, ENC_NA
);
118 dvb_bat_tree
= proto_item_add_subtree(ti
, ett_dvb_bat
);
120 offset
+= packet_mpeg_sect_header(tvb
, offset
, dvb_bat_tree
, &length
, NULL
);
123 proto_tree_add_item(dvb_bat_tree
, hf_dvb_bat_bouquet_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
126 proto_tree_add_item(dvb_bat_tree
, hf_dvb_bat_reserved1
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
127 proto_tree_add_item(dvb_bat_tree
, hf_dvb_bat_version_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
128 proto_tree_add_item(dvb_bat_tree
, hf_dvb_bat_current_next_indicator
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
131 proto_tree_add_item(dvb_bat_tree
, hf_dvb_bat_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
134 proto_tree_add_item(dvb_bat_tree
, hf_dvb_bat_last_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
137 descriptor_len
= tvb_get_ntohs(tvb
, offset
) & DVB_BAT_BOUQUET_DESCRIPTORS_LENGTH_MASK
;
138 proto_tree_add_item(dvb_bat_tree
, hf_dvb_bat_reserved2
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
139 proto_tree_add_item(dvb_bat_tree
, hf_dvb_bat_bouquet_descriptors_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
142 offset
+= proto_mpeg_descriptor_loop_dissect(tvb
, offset
, descriptor_len
, dvb_bat_tree
);
144 ts_loop_len
= tvb_get_ntohs(tvb
, offset
) & DVB_BAT_TRANSPORT_STREAM_LOOP_LENGTH_MASK
;
145 proto_tree_add_item(dvb_bat_tree
, hf_dvb_bat_reserved3
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
146 proto_tree_add_item(dvb_bat_tree
, hf_dvb_bat_transport_stream_loop_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
149 ts_loop_end
= offset
+ ts_loop_len
;
150 while (offset
< ts_loop_end
) {
151 ts_id
= tvb_get_ntohs(tvb
, offset
);
152 descriptor_len
= tvb_get_ntohs(tvb
, offset
+ 4) & DVB_BAT_TRANSPORT_DESCRIPTORS_LENGTH_MASK
;
154 tsi
= proto_tree_add_text(dvb_bat_tree
, tvb
, offset
, 6 + descriptor_len
, "Transport Stream 0x%04x", ts_id
);
155 transport_stream_tree
= proto_item_add_subtree(tsi
, ett_dvb_bat_transport_stream
);
157 proto_tree_add_item(transport_stream_tree
, hf_dvb_bat_transport_stream_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
160 proto_tree_add_item(transport_stream_tree
, hf_dvb_bat_original_network_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
163 proto_tree_add_item(transport_stream_tree
, hf_dvb_bat_reserved4
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
164 proto_tree_add_item(transport_stream_tree
, hf_dvb_bat_transport_descriptors_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
167 offset
+= proto_mpeg_descriptor_loop_dissect(tvb
, offset
, descriptor_len
, transport_stream_tree
);
170 offset
+= packet_mpeg_sect_crc(tvb
, pinfo
, dvb_bat_tree
, 0, offset
);
171 proto_item_set_len(ti
, offset
);
176 proto_register_dvb_bat(void)
179 static hf_register_info hf
[] = {
181 { &hf_dvb_bat_bouquet_id
, {
182 "Bouquet ID", "dvb_bat.bouquet_id",
183 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
186 { &hf_dvb_bat_reserved1
, {
187 "Reserved", "dvb_bat.reserved1",
188 FT_UINT8
, BASE_HEX
, NULL
, DVB_BAT_RESERVED1_MASK
, NULL
, HFILL
191 { &hf_dvb_bat_version_number
, {
192 "Version Number", "dvb_bat.version",
193 FT_UINT8
, BASE_HEX
, NULL
, DVB_BAT_VERSION_NUMBER_MASK
, NULL
, HFILL
196 { &hf_dvb_bat_current_next_indicator
, {
197 "Current/Next Indicator", "dvb_bat.cur_next_ind",
198 FT_UINT8
, BASE_DEC
, VALS(dvb_bat_cur_next_vals
), DVB_BAT_CURRENT_NEXT_INDICATOR_MASK
, NULL
, HFILL
201 { &hf_dvb_bat_section_number
, {
202 "Section Number", "dvb_bat.sect_num",
203 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
206 { &hf_dvb_bat_last_section_number
, {
207 "Last Section Number", "dvb_bat.last_sect_num",
208 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
211 { &hf_dvb_bat_reserved2
, {
212 "Reserved", "dvb_bat.reserved2",
213 FT_UINT16
, BASE_HEX
, NULL
, DVB_BAT_RESERVED2_MASK
, NULL
, HFILL
216 { &hf_dvb_bat_bouquet_descriptors_length
, {
217 "Bouquet Descriptors Length", "dvb_bat.bouquet_desc_len",
218 FT_UINT16
, BASE_DEC
, NULL
, DVB_BAT_BOUQUET_DESCRIPTORS_LENGTH_MASK
, NULL
, HFILL
221 { &hf_dvb_bat_reserved3
, {
222 "Reserved", "dvb_bat.reserved3",
223 FT_UINT16
, BASE_HEX
, NULL
, DVB_BAT_RESERVED3_MASK
, NULL
, HFILL
226 { &hf_dvb_bat_transport_stream_loop_length
, {
227 "Transport Stream Loop Length", "dvb_bat.ts_loop_len",
228 FT_UINT16
, BASE_DEC
, NULL
, DVB_BAT_TRANSPORT_STREAM_LOOP_LENGTH_MASK
, NULL
, HFILL
231 { &hf_dvb_bat_transport_stream_id
, {
232 "Transport Stream ID", "dvb_bat.ts.id",
233 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
236 { &hf_dvb_bat_original_network_id
, {
237 "Original Network ID", "dvb_bat.ts.original_nid",
238 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
241 { &hf_dvb_bat_reserved4
, {
242 "Reserved", "dvb_bat.ts.reserved",
243 FT_UINT16
, BASE_HEX
, NULL
, DVB_BAT_RESERVED4_MASK
, NULL
, HFILL
246 { &hf_dvb_bat_transport_descriptors_length
, {
247 "Bouquet Descriptors Length", "dvb_bat.ts.desc_len",
248 FT_UINT16
, BASE_DEC
, NULL
, DVB_BAT_BOUQUET_DESCRIPTORS_LENGTH_MASK
, NULL
, HFILL
253 static gint
*ett
[] = {
255 &ett_dvb_bat_transport_stream
258 proto_dvb_bat
= proto_register_protocol("DVB Bouquet Association Table", "DVB BAT", "dvb_bat");
260 proto_register_field_array(proto_dvb_bat
, hf
, array_length(hf
));
261 proto_register_subtree_array(ett
, array_length(ett
));
266 void proto_reg_handoff_dvb_bat(void)
268 dissector_handle_t dvb_bat_handle
;
270 dvb_bat_handle
= create_dissector_handle(dissect_dvb_bat
, proto_dvb_bat
);
272 dissector_add_uint("mpeg_sect.tid", DVB_BAT_TID
, dvb_bat_handle
);
276 * Editor modelines - http://www.wireshark.org/tools/modelines.html
281 * indent-tabs-mode: nil
284 * vi: set shiftwidth=4 tabstop=8 expandtab:
285 * :indentSize=4:tabSize=8:noTabs=true: