2 * Routines for DVB (ETSI EN 300 468) Servide Description Table (SDT) 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_sdt(void);
20 void proto_reg_handoff_dvb_sdt(void);
22 static dissector_handle_t dvb_sdt_handle
;
24 static int proto_dvb_sdt
;
25 static int hf_dvb_sdt_transport_stream_id
;
26 static int hf_dvb_sdt_reserved1
;
27 static int hf_dvb_sdt_version_number
;
28 static int hf_dvb_sdt_current_next_indicator
;
29 static int hf_dvb_sdt_section_number
;
30 static int hf_dvb_sdt_last_section_number
;
32 static int hf_dvb_sdt_original_network_id
;
33 static int hf_dvb_sdt_reserved2
;
35 static int hf_dvb_sdt_service_id
;
36 static int hf_dvb_sdt_reserved3
;
37 static int hf_dvb_sdt_eit_schedule_flag
;
38 static int hf_dvb_sdt_eit_present_following_flag
;
39 static int hf_dvb_sdt_running_status
;
40 static int hf_dvb_sdt_free_ca_mode
;
41 static int hf_dvb_sdt_descriptors_loop_length
;
43 static int ett_dvb_sdt
;
44 static int ett_dvb_sdt_service
;
46 #define DVB_SDT_RESERVED1_MASK 0xC0
47 #define DVB_SDT_VERSION_NUMBER_MASK 0x3E
48 #define DVB_SDT_CURRENT_NEXT_INDICATOR_MASK 0x01
50 #define DVB_SDT_RESERVED3_MASK 0xFC
51 #define DVB_SDT_EIT_SCHEDULE_FLAG_MASK 0x02
52 #define DVB_SDT_EIT_PRESENT_FOLLOWING_FLAG_MASK 0x01
54 #define DVB_SDT_RUNNING_STATUS_MASK 0xE000
55 #define DVB_SDT_FREE_CA_MODE_MASK 0x1000
56 #define DVB_SDT_DESCRIPTORS_LOOP_LENGTH_MASK 0x0FFF
58 static const value_string dvb_sdt_running_status_vals
[] = {
61 { 2, "Starts in a few seconds" },
64 { 5, "Service off-air" },
69 static const value_string dvb_sdt_free_ca_mode_vals
[] = {
70 { 0, "Not Scrambled" },
71 { 1, "One or more component scrambled" },
77 dissect_dvb_sdt(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
80 unsigned offset
= 0, length
= 0;
81 unsigned descriptor_len
;
85 proto_tree
*dvb_sdt_tree
;
86 proto_tree
*dvb_sdt_service_tree
;
88 /* The TVB should start right after the section_length in the Section packet */
90 col_set_str(pinfo
->cinfo
, COL_INFO
, "Service Description Table (SDT)");
92 ti
= proto_tree_add_item(tree
, proto_dvb_sdt
, tvb
, offset
, -1, ENC_NA
);
93 dvb_sdt_tree
= proto_item_add_subtree(ti
, ett_dvb_sdt
);
95 offset
+= packet_mpeg_sect_header(tvb
, offset
, dvb_sdt_tree
, &length
, NULL
);
98 proto_tree_add_item(dvb_sdt_tree
, hf_dvb_sdt_transport_stream_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
101 proto_tree_add_item(dvb_sdt_tree
, hf_dvb_sdt_reserved1
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
102 proto_tree_add_item(dvb_sdt_tree
, hf_dvb_sdt_version_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
103 proto_tree_add_item(dvb_sdt_tree
, hf_dvb_sdt_current_next_indicator
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
106 proto_tree_add_item(dvb_sdt_tree
, hf_dvb_sdt_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
109 proto_tree_add_item(dvb_sdt_tree
, hf_dvb_sdt_last_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
112 proto_tree_add_item(dvb_sdt_tree
, hf_dvb_sdt_original_network_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
115 proto_tree_add_item(dvb_sdt_tree
, hf_dvb_sdt_reserved2
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
119 if (offset
>= length
)
122 /* Parse all the services */
123 while (offset
< length
) {
125 svc_id
= tvb_get_ntohs(tvb
, offset
);
126 dvb_sdt_service_tree
= proto_tree_add_subtree_format(dvb_sdt_tree
, tvb
, offset
, 5,
127 ett_dvb_sdt_service
, NULL
, "Service 0x%04hx", svc_id
);
129 proto_tree_add_item(dvb_sdt_service_tree
, hf_dvb_sdt_service_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
132 proto_tree_add_item(dvb_sdt_service_tree
, hf_dvb_sdt_reserved3
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
133 proto_tree_add_item(dvb_sdt_service_tree
, hf_dvb_sdt_eit_schedule_flag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
134 proto_tree_add_item(dvb_sdt_service_tree
, hf_dvb_sdt_eit_present_following_flag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
137 proto_tree_add_item(dvb_sdt_service_tree
, hf_dvb_sdt_running_status
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
138 proto_tree_add_item(dvb_sdt_service_tree
, hf_dvb_sdt_free_ca_mode
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
139 proto_tree_add_item(dvb_sdt_service_tree
, hf_dvb_sdt_descriptors_loop_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
140 descriptor_len
= tvb_get_ntohs(tvb
, offset
) & DVB_SDT_DESCRIPTORS_LOOP_LENGTH_MASK
;
143 offset
+= proto_mpeg_descriptor_loop_dissect(tvb
, offset
, descriptor_len
, dvb_sdt_service_tree
);
146 offset
+= packet_mpeg_sect_crc(tvb
, pinfo
, dvb_sdt_tree
, 0, offset
);
147 proto_item_set_len(ti
, offset
);
148 return tvb_captured_length(tvb
);
153 proto_register_dvb_sdt(void)
156 static hf_register_info hf
[] = {
158 { &hf_dvb_sdt_transport_stream_id
, {
159 "Transport Stream ID", "dvb_sdt.tsid",
160 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
163 { &hf_dvb_sdt_reserved1
, {
164 "Reserved", "dvb_sdt.reserved1",
165 FT_UINT8
, BASE_HEX
, NULL
, DVB_SDT_RESERVED1_MASK
, NULL
, HFILL
168 { &hf_dvb_sdt_version_number
, {
169 "Version Number", "dvb_sdt.version",
170 FT_UINT8
, BASE_HEX
, NULL
, DVB_SDT_VERSION_NUMBER_MASK
, NULL
, HFILL
173 { &hf_dvb_sdt_current_next_indicator
, {
174 "Current/Next Indicator", "dvb_sdt.cur_next_ind",
175 FT_BOOLEAN
, 8, TFS(&tfs_current_not_yet
), DVB_SDT_CURRENT_NEXT_INDICATOR_MASK
, NULL
, HFILL
178 { &hf_dvb_sdt_section_number
, {
179 "Section Number", "dvb_sdt.sect_num",
180 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
183 { &hf_dvb_sdt_last_section_number
, {
184 "Last Section Number", "dvb_sdt.last_sect_num",
185 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
188 { &hf_dvb_sdt_original_network_id
, {
189 "Original Network ID", "dvb_sdt.original_nid",
190 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
193 { &hf_dvb_sdt_reserved2
, {
194 "Reserved", "dvb_sdt.reserved2",
195 FT_UINT8
, BASE_HEX
, NULL
, 0, NULL
, HFILL
199 { &hf_dvb_sdt_service_id
, {
200 "Service ID", "dvb_sdt.svc.id",
201 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
204 { &hf_dvb_sdt_reserved3
, {
205 "Reserved", "dvb_sdt.svc.reserved",
206 FT_UINT8
, BASE_HEX
, NULL
, DVB_SDT_RESERVED3_MASK
, NULL
, HFILL
209 { &hf_dvb_sdt_eit_schedule_flag
, {
210 "EIT Schedule Flag", "dvb_sdt.svc.eit_schedule_flag",
211 FT_UINT8
, BASE_DEC
, NULL
, DVB_SDT_EIT_SCHEDULE_FLAG_MASK
, NULL
, HFILL
214 { &hf_dvb_sdt_eit_present_following_flag
, {
215 "EIT Present Following Flag", "dvb_sdt.svc.eit_present_following_flag",
216 FT_UINT8
, BASE_DEC
, NULL
, DVB_SDT_EIT_PRESENT_FOLLOWING_FLAG_MASK
, NULL
, HFILL
219 { &hf_dvb_sdt_running_status
, {
220 "Running Status", "dvb_sdt.svc.running_status",
221 FT_UINT16
, BASE_HEX
, VALS(dvb_sdt_running_status_vals
), DVB_SDT_RUNNING_STATUS_MASK
, NULL
, HFILL
224 { &hf_dvb_sdt_free_ca_mode
, {
225 "Free CA Mode", "dvb_sdt.svc.free_ca_mode",
226 FT_UINT16
, BASE_HEX
, VALS(dvb_sdt_free_ca_mode_vals
), DVB_SDT_FREE_CA_MODE_MASK
, NULL
, HFILL
229 { &hf_dvb_sdt_descriptors_loop_length
, {
230 "Descriptors Loop Length", "dvb_sdt.svc.descr_loop_len",
231 FT_UINT16
, BASE_DEC
, NULL
, DVB_SDT_DESCRIPTORS_LOOP_LENGTH_MASK
, NULL
, HFILL
236 static int *ett
[] = {
241 proto_dvb_sdt
= proto_register_protocol("DVB Service Description Table", "DVB SDT", "dvb_sdt");
243 proto_register_field_array(proto_dvb_sdt
, hf
, array_length(hf
));
244 proto_register_subtree_array(ett
, array_length(ett
));
246 dvb_sdt_handle
= register_dissector("dvb_sdt", dissect_dvb_sdt
, proto_dvb_sdt
);
250 void proto_reg_handoff_dvb_sdt(void)
252 dissector_add_uint("mpeg_sect.tid", DVB_SDT_TID_ACTUAL
, dvb_sdt_handle
);
253 dissector_add_uint("mpeg_sect.tid", DVB_SDT_TID_OTHER
, dvb_sdt_handle
);
258 * Editor modelines - https://www.wireshark.org/tools/modelines.html
263 * indent-tabs-mode: nil
266 * vi: set shiftwidth=4 tabstop=8 expandtab:
267 * :indentSize=4:tabSize=8:noTabs=true: