2 * Routines for DVB (ETSI EN 300 468) Event Information Table (EIT) 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
14 #include <epan/packet.h>
16 #include "packet-mpeg-sect.h"
17 #include "packet-mpeg-descriptor.h"
19 void proto_register_dvb_eit(void);
20 void proto_reg_handoff_dvb_eit(void);
22 static dissector_handle_t dvb_eit_handle
;
24 static int proto_dvb_eit
;
25 static int hf_dvb_eit_service_id
;
26 static int hf_dvb_eit_reserved
;
27 static int hf_dvb_eit_version_number
;
28 static int hf_dvb_eit_current_next_indicator
;
29 static int hf_dvb_eit_section_number
;
30 static int hf_dvb_eit_last_section_number
;
32 static int hf_dvb_eit_transport_stream_id
;
33 static int hf_dvb_eit_original_network_id
;
34 static int hf_dvb_eit_segment_last_section_number
;
35 static int hf_dvb_eit_last_table_id
;
37 static int hf_dvb_eit_event_id
;
38 static int hf_dvb_eit_start_time
;
39 static int hf_dvb_eit_duration
;
40 static int hf_dvb_eit_running_status
;
41 static int hf_dvb_eit_free_ca_mode
;
42 static int hf_dvb_eit_descriptors_loop_length
;
44 static int ett_dvb_eit
;
45 static int ett_dvb_eit_event
;
48 #define DVB_EIT_RESERVED_MASK 0xC0
49 #define DVB_EIT_VERSION_NUMBER_MASK 0x3E
50 #define DVB_EIT_CURRENT_NEXT_INDICATOR_MASK 0x01
52 #define DVB_EIT_RUNNING_STATUS_MASK 0xE000
53 #define DVB_EIT_FREE_CA_MODE_MASK 0x1000
54 #define DVB_EIT_DESCRIPTORS_LOOP_LENGTH_MASK 0x0FFF
56 static const value_string dvb_eit_running_status_vals
[] = {
59 { 2, "Starts in a few seconds" },
62 { 5, "Service off-air" },
67 static const value_string dvb_eit_free_ca_mode_vals
[] = {
68 { 0, "Not Scrambled" },
69 { 1, "One or more component scrambled" },
75 dissect_dvb_eit(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
78 unsigned offset
= 0, length
= 0;
79 unsigned descriptor_len
;
83 proto_tree
*dvb_eit_tree
;
84 proto_tree
*dvb_eit_event_tree
;
85 proto_item
*duration_item
;
89 col_set_str(pinfo
->cinfo
, COL_INFO
, "Event Information Table (EIT)");
91 ti
= proto_tree_add_item(tree
, proto_dvb_eit
, tvb
, offset
, -1, ENC_NA
);
92 dvb_eit_tree
= proto_item_add_subtree(ti
, ett_dvb_eit
);
94 offset
+= packet_mpeg_sect_header(tvb
, offset
, dvb_eit_tree
, &length
, NULL
);
97 proto_tree_add_item(dvb_eit_tree
, hf_dvb_eit_service_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
100 proto_tree_add_item(dvb_eit_tree
, hf_dvb_eit_reserved
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
101 proto_tree_add_item(dvb_eit_tree
, hf_dvb_eit_version_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
102 proto_tree_add_item(dvb_eit_tree
, hf_dvb_eit_current_next_indicator
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
105 proto_tree_add_item(dvb_eit_tree
, hf_dvb_eit_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
108 proto_tree_add_item(dvb_eit_tree
, hf_dvb_eit_last_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
111 proto_tree_add_item(dvb_eit_tree
, hf_dvb_eit_transport_stream_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
114 proto_tree_add_item(dvb_eit_tree
, hf_dvb_eit_original_network_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
117 proto_tree_add_item(dvb_eit_tree
, hf_dvb_eit_segment_last_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
120 proto_tree_add_item(dvb_eit_tree
, hf_dvb_eit_last_table_id
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
123 if (offset
>= length
) {
124 packet_mpeg_sect_crc(tvb
, pinfo
, dvb_eit_tree
, 0, offset
);
129 /* Parse all the events */
130 while (offset
< length
) {
132 evt_id
= tvb_get_ntohs(tvb
, offset
);
133 dvb_eit_event_tree
= proto_tree_add_subtree_format(dvb_eit_tree
, tvb
, offset
, 12, ett_dvb_eit_event
, NULL
, "Event 0x%04hx", evt_id
);
135 proto_tree_add_item(dvb_eit_event_tree
, hf_dvb_eit_event_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
138 if (tvb_memeql(tvb
, offset
, (const uint8_t*)"\xFF\xFF\xFF\xFF\xFF", 5)) {
139 if (packet_mpeg_sect_mjd_to_utc_time(tvb
, offset
, &start_time
) < 0) {
140 proto_tree_add_time_format(dvb_eit_event_tree
, hf_dvb_eit_start_time
, tvb
, offset
, 5,
141 &start_time
, "Unparseable time");
143 proto_tree_add_time(dvb_eit_event_tree
, hf_dvb_eit_start_time
, tvb
, offset
,
147 start_time
.secs
= 0xFFFFFFFF;
148 start_time
.nsecs
= 0xFFFFFFFF;
149 proto_tree_add_time_format_value(tree
, hf_dvb_eit_start_time
, tvb
, offset
, 5, &start_time
, "Undefined (0xFFFFFFFFFF)");
153 duration_item
= proto_tree_add_item(dvb_eit_event_tree
, hf_dvb_eit_duration
, tvb
, offset
, 3, ENC_BIG_ENDIAN
);
154 proto_item_append_text(duration_item
, " (%02u:%02u:%02u)",
155 MPEG_SECT_BCD44_TO_DEC(tvb_get_uint8(tvb
, offset
)),
156 MPEG_SECT_BCD44_TO_DEC(tvb_get_uint8(tvb
, offset
+ 1)),
157 MPEG_SECT_BCD44_TO_DEC(tvb_get_uint8(tvb
, offset
+ 2)));
160 proto_tree_add_item(dvb_eit_event_tree
, hf_dvb_eit_running_status
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
161 proto_tree_add_item(dvb_eit_event_tree
, hf_dvb_eit_free_ca_mode
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
162 proto_tree_add_item(dvb_eit_event_tree
, hf_dvb_eit_descriptors_loop_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
163 descriptor_len
= tvb_get_ntohs(tvb
, offset
) & DVB_EIT_DESCRIPTORS_LOOP_LENGTH_MASK
;
166 offset
+= proto_mpeg_descriptor_loop_dissect(tvb
, offset
, descriptor_len
, dvb_eit_event_tree
);
169 offset
+= packet_mpeg_sect_crc(tvb
, pinfo
, dvb_eit_tree
, 0, offset
);
170 proto_item_set_len(ti
, offset
);
171 return tvb_captured_length(tvb
);
176 proto_register_dvb_eit(void)
179 static hf_register_info hf
[] = {
181 { &hf_dvb_eit_service_id
, {
182 "Service ID", "dvb_eit.sid",
183 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
186 { &hf_dvb_eit_reserved
, {
187 "Reserved", "dvb_eit.reserved",
188 FT_UINT8
, BASE_HEX
, NULL
, DVB_EIT_RESERVED_MASK
, NULL
, HFILL
191 { &hf_dvb_eit_version_number
, {
192 "Version Number", "dvb_eit.version",
193 FT_UINT8
, BASE_HEX
, NULL
, DVB_EIT_VERSION_NUMBER_MASK
, NULL
, HFILL
196 { &hf_dvb_eit_current_next_indicator
, {
197 "Current/Next Indicator", "dvb_eit.cur_next_ind",
198 FT_BOOLEAN
, 8, TFS(&tfs_current_not_yet
), DVB_EIT_CURRENT_NEXT_INDICATOR_MASK
, NULL
, HFILL
201 { &hf_dvb_eit_section_number
, {
202 "Section Number", "dvb_eit.sect_num",
203 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
206 { &hf_dvb_eit_last_section_number
, {
207 "Last Section Number", "dvb_eit.last_sect_num",
208 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
211 { &hf_dvb_eit_transport_stream_id
, {
212 "Transport Stream ID", "dvb_eit.tsid",
213 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
216 { &hf_dvb_eit_original_network_id
, {
217 "Original Network ID", "dvb_eit.original_nid",
218 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
221 { &hf_dvb_eit_segment_last_section_number
, {
222 "Segment Last Section Number", "dvb_eit.segment_last_sect_num",
223 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
226 { &hf_dvb_eit_last_table_id
, {
227 "Last Table ID", "dvb_eit.last_tid",
228 FT_UINT8
, BASE_HEX
, NULL
, 0, NULL
, HFILL
231 { &hf_dvb_eit_event_id
, {
232 "Event ID", "dvb_eit.evt.id",
233 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
236 { &hf_dvb_eit_start_time
, {
237 "UTC Start Time", "dvb_eit.evt.start_time",
238 FT_ABSOLUTE_TIME
, ABSOLUTE_TIME_UTC
, NULL
, 0, NULL
, HFILL
241 { &hf_dvb_eit_duration
, {
242 "Duration", "dvb_eit.evt.duration",
243 FT_UINT24
, BASE_HEX
, NULL
, 0, NULL
, HFILL
246 { &hf_dvb_eit_running_status
, {
247 "Running Status", "dvb_eit.evt.running_status",
248 FT_UINT16
, BASE_HEX
, VALS(dvb_eit_running_status_vals
), DVB_EIT_RUNNING_STATUS_MASK
, NULL
, HFILL
251 { &hf_dvb_eit_free_ca_mode
, {
252 "Free CA Mode", "dvb_eit.evt.free_ca_mode",
253 FT_UINT16
, BASE_HEX
, VALS(dvb_eit_free_ca_mode_vals
), DVB_EIT_FREE_CA_MODE_MASK
, NULL
, HFILL
256 { &hf_dvb_eit_descriptors_loop_length
, {
257 "Descriptors Loop Length", "dvb_eit.evt.descr_loop_len",
258 FT_UINT16
, BASE_DEC
, NULL
, DVB_EIT_DESCRIPTORS_LOOP_LENGTH_MASK
, NULL
, HFILL
262 static int *ett
[] = {
267 proto_dvb_eit
= proto_register_protocol("DVB Event Information Table", "DVB EIT", "dvb_eit");
269 proto_register_field_array(proto_dvb_eit
, hf
, array_length(hf
));
270 proto_register_subtree_array(ett
, array_length(ett
));
272 dvb_eit_handle
= register_dissector("dvb_eit", dissect_dvb_eit
, proto_dvb_eit
);
276 void proto_reg_handoff_dvb_eit(void)
280 for (tid
= DVB_EIT_TID_MIN
; tid
<= DVB_EIT_TID_MAX
; tid
++)
281 dissector_add_uint("mpeg_sect.tid", tid
, dvb_eit_handle
);
286 * Editor modelines - https://www.wireshark.org/tools/modelines.html
291 * indent-tabs-mode: nil
294 * vi: set shiftwidth=4 tabstop=8 expandtab:
295 * :indentSize=4:tabSize=8:noTabs=true: