Coverage Report

Created: 2026-09-28 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-dvb-sit.c
Line
Count
Source
1
/* packet-dvb-sit.c
2
 * Routines for DVB (ETSI EN 300 468) Selection Information Table (SIT) dissection
3
 * Copyright 2021, Roman Volkov <volkoff_roman@ukr.net>
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_sit(void);
20
void proto_reg_handoff_dvb_sit(void);
21
22
static dissector_handle_t dvb_sit_handle;
23
24
static int proto_dvb_sit;
25
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;
38
39
static int ett_dvb_sit;
40
static int ett_dvb_sit_service;
41
42
16
#define DVB_SIT_RESERVED_MASK                   0xC0
43
16
#define DVB_SIT_VERSION_NUMBER_MASK             0x3E
44
16
#define DVB_SIT_CURRENT_NEXT_INDICATOR_MASK     0x01
45
46
16
#define DVB_SIT_RESERVED_FUTURE_USE2_MASK       0xF000
47
22
#define DVB_SIT_TRANSMISSION_INFO_MASK          0x0FFF
48
49
16
#define DVB_SIT_RESERVED_FUTURE_USE3_MASK       0x8000
50
16
#define DVB_SIT_RUNNING_STATUS_MASK             0x7000
51
19
#define DVB_SIT_SERVICE_DESCRIPTORS_LENGTH_MASK 0x0FFF
52
53
static const value_string dvb_sit_running_status_vals[] = {
54
    { 0, "Undefined" },
55
    { 1, "Not Running" },
56
    { 2, "Starts in a few seconds" },
57
    { 3, "Pausing" },
58
    { 4, "Running" },
59
    { 5, "Service off-air" },
60
61
    { 0, NULL }
62
};
63
64
static int
65
dissect_dvb_sit(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
66
6
{
67
68
6
    unsigned    offset = 0, length = 0;
69
6
    unsigned    descriptor_len;
70
6
    uint16_t    svc_id;
71
72
6
    proto_item *ti;
73
6
    proto_tree *dvb_sit_tree;
74
6
    proto_tree *dvb_sit_service_tree;
75
76
    /* The TVB should start right after the section_length in the Section packet */
77
78
6
    col_set_str(pinfo->cinfo, COL_INFO, "Selection Information Table (SIT)");
79
80
6
    ti = proto_tree_add_item(tree, proto_dvb_sit, tvb, offset, -1, ENC_NA);
81
6
    dvb_sit_tree = proto_item_add_subtree(ti, ett_dvb_sit);
82
83
6
    offset += packet_mpeg_sect_header(tvb, offset, dvb_sit_tree, &length, NULL);
84
6
    length -= 4;
85
86
6
    proto_tree_add_item(dvb_sit_tree, hf_dvb_sit_reserved_future_use1,   tvb, offset, 2, ENC_BIG_ENDIAN);
87
6
    offset += 2;
88
89
6
    proto_tree_add_item(dvb_sit_tree, hf_dvb_sit_reserved,               tvb, offset, 1, ENC_BIG_ENDIAN);
90
6
    proto_tree_add_item(dvb_sit_tree, hf_dvb_sit_version_number,         tvb, offset, 1, ENC_BIG_ENDIAN);
91
6
    proto_tree_add_item(dvb_sit_tree, hf_dvb_sit_current_next_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
92
6
    offset += 1;
93
94
6
    proto_tree_add_item(dvb_sit_tree, hf_dvb_sit_section_number,         tvb, offset, 1, ENC_BIG_ENDIAN);
95
6
    offset += 1;
96
97
6
    proto_tree_add_item(dvb_sit_tree, hf_dvb_sit_last_section_number,    tvb, offset, 1, ENC_BIG_ENDIAN);
98
6
    offset += 1;
99
100
6
    descriptor_len = tvb_get_ntohs(tvb, offset) & DVB_SIT_TRANSMISSION_INFO_MASK;
101
6
    proto_tree_add_item(dvb_sit_tree, hf_dvb_sit_reserved_future_use2,   tvb, offset, 2, ENC_BIG_ENDIAN);
102
6
    proto_tree_add_item(dvb_sit_tree, hf_dvb_sit_transmission_info_len,  tvb, offset, 2, ENC_BIG_ENDIAN);
103
6
    offset += 2;
104
105
6
    offset += proto_mpeg_descriptor_loop_dissect(tvb, pinfo, offset, descriptor_len, dvb_sit_tree);
106
107
6
    if (offset >= length)
108
0
        return offset;
109
110
    /* Parse all the services */
111
9
    while (offset < length) {
112
113
3
        svc_id = tvb_get_ntohs(tvb, offset);
114
3
        dvb_sit_service_tree = proto_tree_add_subtree_format(dvb_sit_tree, tvb, offset, 5,
115
3
                    ett_dvb_sit_service, NULL, "Service 0x%04hx", svc_id);
116
117
3
        proto_tree_add_item(dvb_sit_service_tree, hf_dvb_sit_service_id,                 tvb, offset, 2, ENC_BIG_ENDIAN);
118
3
        offset += 2;
119
120
3
        proto_tree_add_item(dvb_sit_service_tree, hf_dvb_sit_reserved_future_use3,       tvb, offset, 2, ENC_BIG_ENDIAN);
121
3
        proto_tree_add_item(dvb_sit_service_tree, hf_dvb_sit_running_status,             tvb, offset, 2, ENC_BIG_ENDIAN);
122
3
        proto_tree_add_item(dvb_sit_service_tree, hf_dvb_sit_service_descriptors_length, tvb, offset, 2, ENC_BIG_ENDIAN);
123
3
        descriptor_len = tvb_get_ntohs(tvb, offset) & DVB_SIT_SERVICE_DESCRIPTORS_LENGTH_MASK;
124
3
        offset += 2;
125
126
3
        offset += proto_mpeg_descriptor_loop_dissect(tvb, pinfo, offset, descriptor_len, dvb_sit_service_tree);
127
3
    }
128
129
6
    offset += packet_mpeg_sect_crc(tvb, pinfo, dvb_sit_tree, 0, offset);
130
6
    proto_item_set_len(ti, offset);
131
6
    return tvb_captured_length(tvb);
132
6
}
133
134
135
void
136
proto_register_dvb_sit(void)
137
16
{
138
139
16
    static hf_register_info hf[] = {
140
141
16
        { &hf_dvb_sit_reserved_future_use1, {
142
16
            "Reserved", "dvb_sit.reserved_future_use1",
143
16
            FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
144
16
        } },
145
146
16
        { &hf_dvb_sit_reserved, {
147
16
            "Reserved", "dvb_sit.reserved",
148
16
            FT_UINT8, BASE_HEX, NULL, DVB_SIT_RESERVED_MASK, NULL, HFILL
149
16
        } },
150
151
16
        { &hf_dvb_sit_version_number, {
152
16
            "Version Number", "dvb_sit.version",
153
16
            FT_UINT8, BASE_HEX, NULL, DVB_SIT_VERSION_NUMBER_MASK, NULL, HFILL
154
16
        } },
155
156
16
        { &hf_dvb_sit_current_next_indicator, {
157
16
            "Current/Next Indicator", "dvb_sit.cur_next_ind",
158
16
            FT_BOOLEAN, 8, TFS(&tfs_current_not_yet), DVB_SIT_CURRENT_NEXT_INDICATOR_MASK, NULL, HFILL
159
16
        } },
160
161
16
        { &hf_dvb_sit_section_number, {
162
16
            "Section Number", "dvb_sit.sect_num",
163
16
            FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
164
16
        } },
165
166
16
        { &hf_dvb_sit_last_section_number, {
167
16
            "Last Section Number", "dvb_sit.last_sect_num",
168
16
            FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
169
16
        } },
170
171
16
        { &hf_dvb_sit_reserved_future_use2, {
172
16
            "Reserved", "dvb_sit.reserved_future_use2",
173
16
            FT_UINT16, BASE_HEX, NULL, DVB_SIT_RESERVED_FUTURE_USE2_MASK, NULL, HFILL
174
16
        } },
175
176
16
        { &hf_dvb_sit_transmission_info_len, {
177
16
            "Transmission Info Descriptors Length", "dvb_sit.transmission_info_descriptors_length",
178
16
            FT_UINT16, BASE_DEC, NULL, DVB_SIT_TRANSMISSION_INFO_MASK, NULL, HFILL
179
16
        } },
180
181
16
        { &hf_dvb_sit_service_id, {
182
16
            "Service ID", "dvb_sit.svc.id",
183
16
            FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL
184
16
        } },
185
186
16
        { &hf_dvb_sit_reserved_future_use3, {
187
16
            "Reserved", "dvb_sit.svc.reserved_future_use3",
188
16
            FT_UINT16, BASE_HEX, NULL, DVB_SIT_RESERVED_FUTURE_USE3_MASK, NULL, HFILL
189
16
        } },
190
191
16
        { &hf_dvb_sit_running_status, {
192
16
            "Running Status", "dvb_sit.svc.running_status",
193
16
            FT_UINT16, BASE_HEX, VALS(dvb_sit_running_status_vals), DVB_SIT_RUNNING_STATUS_MASK, NULL, HFILL
194
16
        } },
195
196
16
        { &hf_dvb_sit_service_descriptors_length, {
197
16
            "Service Descriptors Length", "dvb_sit.svc.service_descriptors_length",
198
16
            FT_UINT16, BASE_DEC, NULL, DVB_SIT_SERVICE_DESCRIPTORS_LENGTH_MASK, NULL, HFILL
199
16
        } }
200
201
16
    };
202
203
16
    static int *ett[] = {
204
16
        &ett_dvb_sit,
205
16
        &ett_dvb_sit_service
206
16
    };
207
208
16
    proto_dvb_sit = proto_register_protocol("DVB Selection Information Table", "DVB SIT", "dvb_sit");
209
16
    dvb_sit_handle = register_dissector("dvb_sit", dissect_dvb_sit, proto_dvb_sit);
210
211
16
    proto_register_field_array(proto_dvb_sit, hf, array_length(hf));
212
16
    proto_register_subtree_array(ett, array_length(ett));
213
214
16
}
215
216
217
void proto_reg_handoff_dvb_sit(void)
218
16
{
219
16
    dissector_add_uint("mpeg_sect.tid", DVB_SIT_TID, dvb_sit_handle);
220
16
}
221
222
223
/*
224
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
225
 *
226
 * Local variables:
227
 * c-basic-offset: 4
228
 * tab-width: 8
229
 * indent-tabs-mode: nil
230
 * End:
231
 *
232
 * vi: set shiftwidth=4 tabstop=8 expandtab:
233
 * :indentSize=4:tabSize=8:noTabs=true:
234
 */