2 * Routines for DVB (ETSI EN 300 468) Selection Information Table (SIT) dissection
3 * Copyright 2021, Roman Volkov <volkoff_roman@ukr.net>
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_sit(void);
20 void proto_reg_handoff_dvb_sit(void);
22 static dissector_handle_t dvb_sit_handle
;
24 static int proto_dvb_sit
;
26 static int hf_dvb_sit_reserved_future_use1
;
27 static int hf_dvb_sit_reserved
;
28 static int hf_dvb_sit_version_number
;
29 static int hf_dvb_sit_current_next_indicator
;
30 static int hf_dvb_sit_section_number
;
31 static int hf_dvb_sit_last_section_number
;
32 static int hf_dvb_sit_reserved_future_use2
;
33 static int hf_dvb_sit_transmission_info_len
;
34 static int hf_dvb_sit_service_id
;
35 static int hf_dvb_sit_reserved_future_use3
;
36 static int hf_dvb_sit_running_status
;
37 static int hf_dvb_sit_service_descriptors_length
;
39 static int ett_dvb_sit
;
40 static int ett_dvb_sit_service
;
42 #define DVB_SIT_RESERVED_MASK 0xC0
43 #define DVB_SIT_VERSION_NUMBER_MASK 0x3E
44 #define DVB_SIT_CURRENT_NEXT_INDICATOR_MASK 0x01
46 #define DVB_SIT_RESERVED_FUTURE_USE2_MASK 0xF000
47 #define DVB_SIT_TRANSMISSION_INFO_MASK 0x0FFF
49 #define DVB_SIT_RESERVED_FUTURE_USE3_MASK 0x8000
50 #define DVB_SIT_RUNNING_STATUS_MASK 0x7000
51 #define DVB_SIT_SERVICE_DESCRIPTORS_LENGTH_MASK 0x0FFF
53 static const value_string dvb_sit_running_status_vals
[] = {
56 { 2, "Starts in a few seconds" },
59 { 5, "Service off-air" },
65 dissect_dvb_sit(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
68 unsigned offset
= 0, length
= 0;
69 unsigned descriptor_len
;
73 proto_tree
*dvb_sit_tree
;
74 proto_tree
*dvb_sit_service_tree
;
76 /* The TVB should start right after the section_length in the Section packet */
78 col_set_str(pinfo
->cinfo
, COL_INFO
, "Selection Information Table (SIT)");
80 ti
= proto_tree_add_item(tree
, proto_dvb_sit
, tvb
, offset
, -1, ENC_NA
);
81 dvb_sit_tree
= proto_item_add_subtree(ti
, ett_dvb_sit
);
83 offset
+= packet_mpeg_sect_header(tvb
, offset
, dvb_sit_tree
, &length
, NULL
);
86 proto_tree_add_item(dvb_sit_tree
, hf_dvb_sit_reserved_future_use1
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
89 proto_tree_add_item(dvb_sit_tree
, hf_dvb_sit_reserved
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
90 proto_tree_add_item(dvb_sit_tree
, hf_dvb_sit_version_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
91 proto_tree_add_item(dvb_sit_tree
, hf_dvb_sit_current_next_indicator
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
94 proto_tree_add_item(dvb_sit_tree
, hf_dvb_sit_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
97 proto_tree_add_item(dvb_sit_tree
, hf_dvb_sit_last_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
100 descriptor_len
= tvb_get_ntohs(tvb
, offset
) & DVB_SIT_TRANSMISSION_INFO_MASK
;
101 proto_tree_add_item(dvb_sit_tree
, hf_dvb_sit_reserved_future_use2
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
102 proto_tree_add_item(dvb_sit_tree
, hf_dvb_sit_transmission_info_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
105 offset
+= proto_mpeg_descriptor_loop_dissect(tvb
, offset
, descriptor_len
, dvb_sit_tree
);
107 if (offset
>= length
)
110 /* Parse all the services */
111 while (offset
< length
) {
113 svc_id
= tvb_get_ntohs(tvb
, offset
);
114 dvb_sit_service_tree
= proto_tree_add_subtree_format(dvb_sit_tree
, tvb
, offset
, 5,
115 ett_dvb_sit_service
, NULL
, "Service 0x%04hx", svc_id
);
117 proto_tree_add_item(dvb_sit_service_tree
, hf_dvb_sit_service_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
120 proto_tree_add_item(dvb_sit_service_tree
, hf_dvb_sit_reserved_future_use3
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
121 proto_tree_add_item(dvb_sit_service_tree
, hf_dvb_sit_running_status
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
122 proto_tree_add_item(dvb_sit_service_tree
, hf_dvb_sit_service_descriptors_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
123 descriptor_len
= tvb_get_ntohs(tvb
, offset
) & DVB_SIT_SERVICE_DESCRIPTORS_LENGTH_MASK
;
126 offset
+= proto_mpeg_descriptor_loop_dissect(tvb
, offset
, descriptor_len
, dvb_sit_service_tree
);
129 offset
+= packet_mpeg_sect_crc(tvb
, pinfo
, dvb_sit_tree
, 0, offset
);
130 proto_item_set_len(ti
, offset
);
131 return tvb_captured_length(tvb
);
136 proto_register_dvb_sit(void)
139 static hf_register_info hf
[] = {
141 { &hf_dvb_sit_reserved_future_use1
, {
142 "Reserved", "dvb_sit.reserved_future_use1",
143 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
146 { &hf_dvb_sit_reserved
, {
147 "Reserved", "dvb_sit.reserved",
148 FT_UINT8
, BASE_HEX
, NULL
, DVB_SIT_RESERVED_MASK
, NULL
, HFILL
151 { &hf_dvb_sit_version_number
, {
152 "Version Number", "dvb_sit.version",
153 FT_UINT8
, BASE_HEX
, NULL
, DVB_SIT_VERSION_NUMBER_MASK
, NULL
, HFILL
156 { &hf_dvb_sit_current_next_indicator
, {
157 "Current/Next Indicator", "dvb_sit.cur_next_ind",
158 FT_BOOLEAN
, 8, TFS(&tfs_current_not_yet
), DVB_SIT_CURRENT_NEXT_INDICATOR_MASK
, NULL
, HFILL
161 { &hf_dvb_sit_section_number
, {
162 "Section Number", "dvb_sit.sect_num",
163 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
166 { &hf_dvb_sit_last_section_number
, {
167 "Last Section Number", "dvb_sit.last_sect_num",
168 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
171 { &hf_dvb_sit_reserved_future_use2
, {
172 "Reserved", "dvb_sit.reserved_future_use2",
173 FT_UINT16
, BASE_HEX
, NULL
, DVB_SIT_RESERVED_FUTURE_USE2_MASK
, NULL
, HFILL
176 { &hf_dvb_sit_transmission_info_len
, {
177 "Transmission Info Descriptors Length", "dvb_sit.transmission_info_descriptors_length",
178 FT_UINT16
, BASE_DEC
, NULL
, DVB_SIT_TRANSMISSION_INFO_MASK
, NULL
, HFILL
181 { &hf_dvb_sit_service_id
, {
182 "Service ID", "dvb_sit.svc.id",
183 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
186 { &hf_dvb_sit_reserved_future_use3
, {
187 "Reserved", "dvb_sit.svc.reserved_future_use3",
188 FT_UINT16
, BASE_HEX
, NULL
, DVB_SIT_RESERVED_FUTURE_USE3_MASK
, NULL
, HFILL
191 { &hf_dvb_sit_running_status
, {
192 "Running Status", "dvb_sit.svc.running_status",
193 FT_UINT16
, BASE_HEX
, VALS(dvb_sit_running_status_vals
), DVB_SIT_RUNNING_STATUS_MASK
, NULL
, HFILL
196 { &hf_dvb_sit_service_descriptors_length
, {
197 "Service Descriptors Length", "dvb_sit.svc.service_descriptors_length",
198 FT_UINT16
, BASE_DEC
, NULL
, DVB_SIT_SERVICE_DESCRIPTORS_LENGTH_MASK
, NULL
, HFILL
203 static int *ett
[] = {
208 proto_dvb_sit
= proto_register_protocol("DVB Selection Information Table", "DVB SIT", "dvb_sit");
209 dvb_sit_handle
= register_dissector("dvb_sit", dissect_dvb_sit
, proto_dvb_sit
);
211 proto_register_field_array(proto_dvb_sit
, hf
, array_length(hf
));
212 proto_register_subtree_array(ett
, array_length(ett
));
217 void proto_reg_handoff_dvb_sit(void)
219 dissector_add_uint("mpeg_sect.tid", DVB_SIT_TID
, dvb_sit_handle
);
224 * Editor modelines - https://www.wireshark.org/tools/modelines.html
229 * indent-tabs-mode: nil
232 * vi: set shiftwidth=4 tabstop=8 expandtab:
233 * :indentSize=4:tabSize=8:noTabs=true: