TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags
[wireshark-sm.git] / epan / dissectors / packet-dvb-bat.c
bloba95640e6a85e3c353d2962b57d6e83c59f0c8fc5
1 /* packet-dvb-bat.c
2 * Routines for DVB (ETSI EN 300 468) Bouquet Association Table (BAT) dissection
3 * Copyright 2012, Guy Martin <gmsoft@tuxicoman.be>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "config.h"
14 #include <epan/packet.h>
15 #include <epan/tfs.h>
16 #include "packet-mpeg-sect.h"
17 #include "packet-mpeg-descriptor.h"
19 void proto_register_dvb_bat(void);
20 void proto_reg_handoff_dvb_bat(void);
22 static dissector_handle_t dvb_bat_handle;
24 static int proto_dvb_bat;
25 static int hf_dvb_bat_bouquet_id;
26 static int hf_dvb_bat_reserved1;
27 static int hf_dvb_bat_version_number;
28 static int hf_dvb_bat_current_next_indicator;
29 static int hf_dvb_bat_section_number;
30 static int hf_dvb_bat_last_section_number;
32 static int hf_dvb_bat_reserved2;
33 static int hf_dvb_bat_bouquet_descriptors_length;
35 static int hf_dvb_bat_reserved3;
36 static int hf_dvb_bat_transport_stream_loop_length;
38 static int hf_dvb_bat_transport_stream_id;
39 static int hf_dvb_bat_original_network_id;
40 static int hf_dvb_bat_reserved4;
41 static int hf_dvb_bat_transport_descriptors_length;
43 static int ett_dvb_bat;
44 static int ett_dvb_bat_transport_stream;
47 #define DVB_BAT_RESERVED1_MASK 0xC0
48 #define DVB_BAT_VERSION_NUMBER_MASK 0x3E
49 #define DVB_BAT_CURRENT_NEXT_INDICATOR_MASK 0x01
51 #define DVB_BAT_RESERVED2_MASK 0xF000
52 #define DVB_BAT_BOUQUET_DESCRIPTORS_LENGTH_MASK 0x0FFF
54 #define DVB_BAT_RESERVED3_MASK 0xF000
55 #define DVB_BAT_TRANSPORT_STREAM_LOOP_LENGTH_MASK 0x0FFF
57 #define DVB_BAT_RESERVED4_MASK 0xF000
58 #define DVB_BAT_TRANSPORT_DESCRIPTORS_LENGTH_MASK 0x0FFF
60 #if 0
61 static const value_string dvb_bat_running_status_vals[] = {
62 { 0, "Undefined" },
63 { 1, "Not Running" },
64 { 2, "Starts in a few seconds" },
65 { 3, "Pausing" },
66 { 4, "Running" },
67 { 5, "Service off-air" },
69 { 0, NULL }
72 static const value_string dvb_bat_free_ca_mode_vals[] = {
73 { 0, "Not Scrambled" },
74 { 1, "One or more component scrambled" },
76 { 0, NULL }
78 #endif
80 static int
81 dissect_dvb_bat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
84 unsigned offset = 0, length = 0, ts_loop_end;
85 uint16_t ts_id, descriptor_len, ts_loop_len;
87 proto_item *ti;
88 proto_tree *dvb_bat_tree;
89 proto_tree *transport_stream_tree;
91 col_set_str(pinfo->cinfo, COL_INFO, "Bouquet Association Table (BAT)");
93 ti = proto_tree_add_item(tree, proto_dvb_bat, tvb, offset, -1, ENC_NA);
94 dvb_bat_tree = proto_item_add_subtree(ti, ett_dvb_bat);
96 offset += packet_mpeg_sect_header(tvb, offset, dvb_bat_tree, &length, NULL);
97 length -= 4;
99 proto_tree_add_item(dvb_bat_tree, hf_dvb_bat_bouquet_id, tvb, offset, 2, ENC_BIG_ENDIAN);
100 offset += 2;
102 proto_tree_add_item(dvb_bat_tree, hf_dvb_bat_reserved1, tvb, offset, 1, ENC_BIG_ENDIAN);
103 proto_tree_add_item(dvb_bat_tree, hf_dvb_bat_version_number, tvb, offset, 1, ENC_BIG_ENDIAN);
104 proto_tree_add_item(dvb_bat_tree, hf_dvb_bat_current_next_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
105 offset += 1;
107 proto_tree_add_item(dvb_bat_tree, hf_dvb_bat_section_number, tvb, offset, 1, ENC_BIG_ENDIAN);
108 offset += 1;
110 proto_tree_add_item(dvb_bat_tree, hf_dvb_bat_last_section_number, tvb, offset, 1, ENC_BIG_ENDIAN);
111 offset += 1;
113 descriptor_len = tvb_get_ntohs(tvb, offset) & DVB_BAT_BOUQUET_DESCRIPTORS_LENGTH_MASK;
114 proto_tree_add_item(dvb_bat_tree, hf_dvb_bat_reserved2, tvb, offset, 2, ENC_BIG_ENDIAN);
115 proto_tree_add_item(dvb_bat_tree, hf_dvb_bat_bouquet_descriptors_length, tvb, offset, 2, ENC_BIG_ENDIAN);
116 offset += 2;
118 offset += proto_mpeg_descriptor_loop_dissect(tvb, offset, descriptor_len, dvb_bat_tree);
120 ts_loop_len = tvb_get_ntohs(tvb, offset) & DVB_BAT_TRANSPORT_STREAM_LOOP_LENGTH_MASK;
121 proto_tree_add_item(dvb_bat_tree, hf_dvb_bat_reserved3, tvb, offset, 2, ENC_BIG_ENDIAN);
122 proto_tree_add_item(dvb_bat_tree, hf_dvb_bat_transport_stream_loop_length, tvb, offset, 2, ENC_BIG_ENDIAN);
123 offset += 2;
125 ts_loop_end = offset + ts_loop_len;
126 while (offset < ts_loop_end) {
127 ts_id = tvb_get_ntohs(tvb, offset);
128 descriptor_len = tvb_get_ntohs(tvb, offset + 4) & DVB_BAT_TRANSPORT_DESCRIPTORS_LENGTH_MASK;
130 transport_stream_tree = proto_tree_add_subtree_format(dvb_bat_tree, tvb, offset, 6 + descriptor_len,
131 ett_dvb_bat_transport_stream, NULL, "Transport Stream 0x%04x", ts_id);
133 proto_tree_add_item(transport_stream_tree, hf_dvb_bat_transport_stream_id, tvb, offset, 2, ENC_BIG_ENDIAN);
134 offset += 2;
136 proto_tree_add_item(transport_stream_tree, hf_dvb_bat_original_network_id, tvb, offset, 2, ENC_BIG_ENDIAN);
137 offset += 2;
139 proto_tree_add_item(transport_stream_tree, hf_dvb_bat_reserved4, tvb, offset, 2, ENC_BIG_ENDIAN);
140 proto_tree_add_item(transport_stream_tree, hf_dvb_bat_transport_descriptors_length, tvb, offset, 2, ENC_BIG_ENDIAN);
141 offset += 2;
143 offset += proto_mpeg_descriptor_loop_dissect(tvb, offset, descriptor_len, transport_stream_tree);
146 offset += packet_mpeg_sect_crc(tvb, pinfo, dvb_bat_tree, 0, offset);
147 proto_item_set_len(ti, offset);
148 return tvb_captured_length(tvb);
152 void
153 proto_register_dvb_bat(void)
156 static hf_register_info hf[] = {
158 { &hf_dvb_bat_bouquet_id, {
159 "Bouquet ID", "dvb_bat.bouquet_id",
160 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
161 } },
163 { &hf_dvb_bat_reserved1, {
164 "Reserved", "dvb_bat.reserved1",
165 FT_UINT8, BASE_HEX, NULL, DVB_BAT_RESERVED1_MASK, NULL, HFILL
166 } },
168 { &hf_dvb_bat_version_number, {
169 "Version Number", "dvb_bat.version",
170 FT_UINT8, BASE_HEX, NULL, DVB_BAT_VERSION_NUMBER_MASK, NULL, HFILL
171 } },
173 { &hf_dvb_bat_current_next_indicator, {
174 "Current/Next Indicator", "dvb_bat.cur_next_ind",
175 FT_BOOLEAN, 8, TFS(&tfs_current_not_yet), DVB_BAT_CURRENT_NEXT_INDICATOR_MASK, NULL, HFILL
176 } },
178 { &hf_dvb_bat_section_number, {
179 "Section Number", "dvb_bat.sect_num",
180 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
181 } },
183 { &hf_dvb_bat_last_section_number, {
184 "Last Section Number", "dvb_bat.last_sect_num",
185 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
186 } },
188 { &hf_dvb_bat_reserved2, {
189 "Reserved", "dvb_bat.reserved2",
190 FT_UINT16, BASE_HEX, NULL, DVB_BAT_RESERVED2_MASK, NULL, HFILL
191 } },
193 { &hf_dvb_bat_bouquet_descriptors_length, {
194 "Bouquet Descriptors Length", "dvb_bat.bouquet_desc_len",
195 FT_UINT16, BASE_DEC, NULL, DVB_BAT_BOUQUET_DESCRIPTORS_LENGTH_MASK, NULL, HFILL
196 } },
198 { &hf_dvb_bat_reserved3, {
199 "Reserved", "dvb_bat.reserved3",
200 FT_UINT16, BASE_HEX, NULL, DVB_BAT_RESERVED3_MASK, NULL, HFILL
201 } },
203 { &hf_dvb_bat_transport_stream_loop_length, {
204 "Transport Stream Loop Length", "dvb_bat.ts_loop_len",
205 FT_UINT16, BASE_DEC, NULL, DVB_BAT_TRANSPORT_STREAM_LOOP_LENGTH_MASK, NULL, HFILL
206 } },
208 { &hf_dvb_bat_transport_stream_id, {
209 "Transport Stream ID", "dvb_bat.ts.id",
210 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
211 } },
213 { &hf_dvb_bat_original_network_id, {
214 "Original Network ID", "dvb_bat.ts.original_nid",
215 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
216 } },
218 { &hf_dvb_bat_reserved4, {
219 "Reserved", "dvb_bat.ts.reserved",
220 FT_UINT16, BASE_HEX, NULL, DVB_BAT_RESERVED4_MASK, NULL, HFILL
221 } },
223 { &hf_dvb_bat_transport_descriptors_length, {
224 "Bouquet Descriptors Length", "dvb_bat.ts.desc_len",
225 FT_UINT16, BASE_DEC, NULL, DVB_BAT_BOUQUET_DESCRIPTORS_LENGTH_MASK, NULL, HFILL
226 } },
230 static int *ett[] = {
231 &ett_dvb_bat,
232 &ett_dvb_bat_transport_stream
235 proto_dvb_bat = proto_register_protocol("DVB Bouquet Association Table", "DVB BAT", "dvb_bat");
236 dvb_bat_handle = register_dissector("dvb_bat", dissect_dvb_bat, proto_dvb_bat);
238 proto_register_field_array(proto_dvb_bat, hf, array_length(hf));
239 proto_register_subtree_array(ett, array_length(ett));
244 void proto_reg_handoff_dvb_bat(void)
246 dissector_add_uint("mpeg_sect.tid", DVB_BAT_TID, dvb_bat_handle);
250 * Editor modelines - https://www.wireshark.org/tools/modelines.html
252 * Local variables:
253 * c-basic-offset: 4
254 * tab-width: 8
255 * indent-tabs-mode: nil
256 * End:
258 * vi: set shiftwidth=4 tabstop=8 expandtab:
259 * :indentSize=4:tabSize=8:noTabs=true: