Coverage Report

Created: 2026-08-14 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-dvb-eit.c
Line
Count
Source
1
/* packet-dvb-eit.c
2
 * Routines for DVB (ETSI EN 300 468) Event Information Table (EIT) dissection
3
 * Copyright 2012, Guy Martin <gmsoft@tuxicoman.be>
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1998 Gerald Combs
8
 *
9
 * SPDX-License-Identifier: GPL-2.0-or-later
10
 */
11
12
#include "config.h"
13
14
#include <epan/packet.h>
15
#include <epan/tfs.h>
16
#include "packet-mpeg-sect.h"
17
#include "packet-mpeg-descriptor.h"
18
19
void proto_register_dvb_eit(void);
20
void proto_reg_handoff_dvb_eit(void);
21
22
static dissector_handle_t dvb_eit_handle;
23
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;
31
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;
36
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;
43
44
static int ett_dvb_eit;
45
static int ett_dvb_eit_event;
46
47
48
16
#define DVB_EIT_RESERVED_MASK                     0xC0
49
16
#define DVB_EIT_VERSION_NUMBER_MASK               0x3E
50
16
#define DVB_EIT_CURRENT_NEXT_INDICATOR_MASK       0x01
51
52
16
#define DVB_EIT_RUNNING_STATUS_MASK             0xE000
53
16
#define DVB_EIT_FREE_CA_MODE_MASK               0x1000
54
279
#define DVB_EIT_DESCRIPTORS_LOOP_LENGTH_MASK    0x0FFF
55
56
static const value_string dvb_eit_running_status_vals[] = {
57
    { 0, "Undefined" },
58
    { 1, "Not Running" },
59
    { 2, "Starts in a few seconds" },
60
    { 3, "Pausing" },
61
    { 4, "Running" },
62
    { 5, "Service off-air" },
63
64
    { 0, NULL }
65
};
66
67
static const value_string dvb_eit_free_ca_mode_vals[] = {
68
    { 0, "Not Scrambled" },
69
    { 1, "One or more component scrambled" },
70
71
    { 0, NULL }
72
};
73
74
static int
75
dissect_dvb_eit(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
76
169
{
77
78
169
    unsigned    offset = 0, length = 0;
79
169
    unsigned    descriptor_len;
80
169
    uint16_t    evt_id;
81
82
169
    proto_item *ti;
83
169
    proto_tree *dvb_eit_tree;
84
169
    proto_tree *dvb_eit_event_tree;
85
169
    proto_item *duration_item;
86
87
169
    nstime_t    start_time;
88
89
169
    col_set_str(pinfo->cinfo, COL_INFO, "Event Information Table (EIT)");
90
91
169
    ti = proto_tree_add_item(tree, proto_dvb_eit, tvb, offset, -1, ENC_NA);
92
169
    dvb_eit_tree = proto_item_add_subtree(ti, ett_dvb_eit);
93
94
169
    offset += packet_mpeg_sect_header(tvb, offset, dvb_eit_tree, &length, NULL);
95
169
    length -= 4;
96
97
169
    proto_tree_add_item(dvb_eit_tree, hf_dvb_eit_service_id,                  tvb, offset, 2, ENC_BIG_ENDIAN);
98
169
    offset += 2;
99
100
169
    proto_tree_add_item(dvb_eit_tree, hf_dvb_eit_reserved,                    tvb, offset, 1, ENC_BIG_ENDIAN);
101
169
    proto_tree_add_item(dvb_eit_tree, hf_dvb_eit_version_number,              tvb, offset, 1, ENC_BIG_ENDIAN);
102
169
    proto_tree_add_item(dvb_eit_tree, hf_dvb_eit_current_next_indicator,      tvb, offset, 1, ENC_BIG_ENDIAN);
103
169
    offset += 1;
104
105
169
    proto_tree_add_item(dvb_eit_tree, hf_dvb_eit_section_number,              tvb, offset, 1, ENC_BIG_ENDIAN);
106
169
    offset += 1;
107
108
169
    proto_tree_add_item(dvb_eit_tree, hf_dvb_eit_last_section_number,         tvb, offset, 1, ENC_BIG_ENDIAN);
109
169
    offset += 1;
110
111
169
    proto_tree_add_item(dvb_eit_tree, hf_dvb_eit_transport_stream_id,         tvb, offset, 2, ENC_BIG_ENDIAN);
112
169
    offset += 2;
113
114
169
    proto_tree_add_item(dvb_eit_tree, hf_dvb_eit_original_network_id,         tvb, offset, 2, ENC_BIG_ENDIAN);
115
169
    offset += 2;
116
117
169
    proto_tree_add_item(dvb_eit_tree, hf_dvb_eit_segment_last_section_number, tvb, offset, 1, ENC_BIG_ENDIAN);
118
169
    offset += 1;
119
120
169
    proto_tree_add_item(dvb_eit_tree, hf_dvb_eit_last_table_id, tvb, offset, 1, ENC_BIG_ENDIAN);
121
169
    offset += 1;
122
123
169
    if (offset >= length) {
124
3
        packet_mpeg_sect_crc(tvb, pinfo, dvb_eit_tree, 0, offset);
125
126
3
        return offset;
127
3
    }
128
129
    /* Parse all the events */
130
429
    while (offset < length) {
131
132
263
        evt_id = tvb_get_ntohs(tvb, offset);
133
263
        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);
134
135
263
        proto_tree_add_item(dvb_eit_event_tree, hf_dvb_eit_event_id, tvb, offset, 2, ENC_BIG_ENDIAN);
136
263
        offset += 2;
137
138
263
        if (tvb_memeql(tvb, offset, (const uint8_t*)"\xFF\xFF\xFF\xFF\xFF", 5)) {
139
258
            if (packet_mpeg_sect_mjd_to_utc_time(tvb, offset, &start_time) < 0) {
140
136
                proto_tree_add_time_format(dvb_eit_event_tree, hf_dvb_eit_start_time, tvb, offset, 5,
141
136
                                    &start_time, "Unparseable time");
142
136
            } else {
143
122
                proto_tree_add_time(dvb_eit_event_tree, hf_dvb_eit_start_time, tvb, offset,
144
122
                    5, &start_time);
145
122
            }
146
258
        } else {
147
5
            start_time.secs = 0xFFFFFFFF;
148
5
            start_time.nsecs = 0xFFFFFFFF;
149
5
            proto_tree_add_time_format_value(tree, hf_dvb_eit_start_time, tvb, offset, 5, &start_time, "Undefined (0xFFFFFFFFFF)");
150
5
        }
151
263
        offset += 5;
152
153
263
        duration_item = proto_tree_add_item(dvb_eit_event_tree, hf_dvb_eit_duration, tvb, offset, 3, ENC_BIG_ENDIAN);
154
263
        proto_item_append_text(duration_item, " (%02u:%02u:%02u)",
155
263
            MPEG_SECT_BCD44_TO_DEC(tvb_get_uint8(tvb, offset)),
156
263
            MPEG_SECT_BCD44_TO_DEC(tvb_get_uint8(tvb, offset + 1)),
157
263
            MPEG_SECT_BCD44_TO_DEC(tvb_get_uint8(tvb, offset + 2)));
158
263
        offset += 3;
159
160
263
        proto_tree_add_item(dvb_eit_event_tree, hf_dvb_eit_running_status,          tvb, offset, 2, ENC_BIG_ENDIAN);
161
263
        proto_tree_add_item(dvb_eit_event_tree, hf_dvb_eit_free_ca_mode,            tvb, offset, 2, ENC_BIG_ENDIAN);
162
263
        proto_tree_add_item(dvb_eit_event_tree, hf_dvb_eit_descriptors_loop_length, tvb, offset, 2, ENC_BIG_ENDIAN);
163
263
        descriptor_len = tvb_get_ntohs(tvb, offset) & DVB_EIT_DESCRIPTORS_LOOP_LENGTH_MASK;
164
263
        offset += 2;
165
166
263
        offset += proto_mpeg_descriptor_loop_dissect(tvb, pinfo, offset, descriptor_len, dvb_eit_event_tree);
167
263
    }
168
169
166
    offset += packet_mpeg_sect_crc(tvb, pinfo, dvb_eit_tree, 0, offset);
170
166
    proto_item_set_len(ti, offset);
171
166
    return tvb_captured_length(tvb);
172
169
}
173
174
175
void
176
proto_register_dvb_eit(void)
177
16
{
178
179
16
    static hf_register_info hf[] = {
180
181
16
        { &hf_dvb_eit_service_id, {
182
16
            "Service ID", "dvb_eit.sid",
183
16
            FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
184
16
        } },
185
186
16
        { &hf_dvb_eit_reserved, {
187
16
            "Reserved", "dvb_eit.reserved",
188
16
            FT_UINT8, BASE_HEX, NULL, DVB_EIT_RESERVED_MASK, NULL, HFILL
189
16
        } },
190
191
16
        { &hf_dvb_eit_version_number, {
192
16
            "Version Number", "dvb_eit.version",
193
16
            FT_UINT8, BASE_HEX, NULL, DVB_EIT_VERSION_NUMBER_MASK, NULL, HFILL
194
16
        } },
195
196
16
        { &hf_dvb_eit_current_next_indicator, {
197
16
            "Current/Next Indicator", "dvb_eit.cur_next_ind",
198
16
            FT_BOOLEAN, 8, TFS(&tfs_current_not_yet), DVB_EIT_CURRENT_NEXT_INDICATOR_MASK, NULL, HFILL
199
16
        } },
200
201
16
        { &hf_dvb_eit_section_number, {
202
16
            "Section Number", "dvb_eit.sect_num",
203
16
            FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
204
16
        } },
205
206
16
        { &hf_dvb_eit_last_section_number, {
207
16
            "Last Section Number", "dvb_eit.last_sect_num",
208
16
            FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
209
16
        } },
210
211
16
        { &hf_dvb_eit_transport_stream_id, {
212
16
            "Transport Stream ID", "dvb_eit.tsid",
213
16
            FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
214
16
        } },
215
216
16
        { &hf_dvb_eit_original_network_id, {
217
16
            "Original Network ID", "dvb_eit.original_nid",
218
16
            FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
219
16
        } },
220
221
16
        { &hf_dvb_eit_segment_last_section_number, {
222
16
            "Segment Last Section Number", "dvb_eit.segment_last_sect_num",
223
16
            FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
224
16
        } },
225
226
16
        { &hf_dvb_eit_last_table_id, {
227
16
            "Last Table ID", "dvb_eit.last_tid",
228
16
            FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL
229
16
        } },
230
231
16
        { &hf_dvb_eit_event_id, {
232
16
            "Event ID", "dvb_eit.evt.id",
233
16
            FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
234
16
        } },
235
236
16
        { &hf_dvb_eit_start_time, {
237
16
            "UTC Start Time", "dvb_eit.evt.start_time",
238
16
            FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0, NULL, HFILL
239
16
        } },
240
241
16
        { &hf_dvb_eit_duration, {
242
16
            "Duration", "dvb_eit.evt.duration",
243
16
            FT_UINT24, BASE_HEX, NULL, 0, NULL, HFILL
244
16
        } },
245
246
16
        { &hf_dvb_eit_running_status, {
247
16
            "Running Status", "dvb_eit.evt.running_status",
248
16
            FT_UINT16, BASE_HEX, VALS(dvb_eit_running_status_vals), DVB_EIT_RUNNING_STATUS_MASK, NULL, HFILL
249
16
        } },
250
251
16
        { &hf_dvb_eit_free_ca_mode, {
252
16
            "Free CA Mode", "dvb_eit.evt.free_ca_mode",
253
16
            FT_UINT16, BASE_HEX, VALS(dvb_eit_free_ca_mode_vals), DVB_EIT_FREE_CA_MODE_MASK, NULL, HFILL
254
16
        } },
255
256
16
        { &hf_dvb_eit_descriptors_loop_length, {
257
16
            "Descriptors Loop Length", "dvb_eit.evt.descr_loop_len",
258
16
            FT_UINT16, BASE_DEC, NULL, DVB_EIT_DESCRIPTORS_LOOP_LENGTH_MASK, NULL, HFILL
259
16
        } }
260
16
    };
261
262
16
    static int *ett[] = {
263
16
        &ett_dvb_eit,
264
16
        &ett_dvb_eit_event
265
16
    };
266
267
16
    proto_dvb_eit = proto_register_protocol("DVB Event Information Table", "DVB EIT", "dvb_eit");
268
269
16
    proto_register_field_array(proto_dvb_eit, hf, array_length(hf));
270
16
    proto_register_subtree_array(ett, array_length(ett));
271
272
16
    dvb_eit_handle = register_dissector("dvb_eit", dissect_dvb_eit, proto_dvb_eit);
273
16
}
274
275
276
void proto_reg_handoff_dvb_eit(void)
277
16
{
278
16
    int tid;
279
280
560
    for (tid = DVB_EIT_TID_MIN; tid <= DVB_EIT_TID_MAX; tid++)
281
544
        dissector_add_uint("mpeg_sect.tid", tid, dvb_eit_handle);
282
16
}
283
284
285
/*
286
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
287
 *
288
 * Local variables:
289
 * c-basic-offset: 4
290
 * tab-width: 8
291
 * indent-tabs-mode: nil
292
 * End:
293
 *
294
 * vi: set shiftwidth=4 tabstop=8 expandtab:
295
 * :indentSize=4:tabSize=8:noTabs=true:
296
 */