Coverage Report

Created: 2026-11-12 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-mpeg1.c
Line
Count
Source
1
/* packet-mpeg1.c
2
 *
3
 * Routines for RFC 2250 MPEG-1 dissection
4
 *
5
 * Copyright 2001,
6
 * Francisco Javier Cabello Torres, <fjcabello@vtools.es>
7
 *
8
 * Wireshark - Network traffic analyzer
9
 * By Gerald Combs <gerald@wireshark.org>
10
 * Copyright 1998 Gerald Combs
11
 *
12
 * SPDX-License-Identifier: GPL-2.0-or-later
13
 */
14
15
/*
16
 * This dissector tries to dissect the MPEG-1 video streams.
17
 */
18
19
20
#include "config.h"
21
22
#include <epan/packet.h>
23
#include "packet-rtp_pt.h"
24
25
26
void proto_register_mpeg1(void);
27
void proto_reg_handoff_mpeg1(void);
28
29
static dissector_handle_t mpeg1_handle;
30
31
/* MPEG1 header fields             */
32
33
static int proto_mpg;
34
35
static int hf_rtp_mpg_mbz;
36
static int hf_rtp_mpg_T;
37
static int hf_rtp_mpg_tr;
38
static int hf_rtp_mpg_an;
39
static int hf_rtp_mpg_n;
40
static int hf_rtp_mpg_s;
41
static int hf_rtp_mpg_b;
42
static int hf_rtp_mpg_e;
43
static int hf_rtp_mpg_p;
44
45
46
static int hf_rtp_mpg_fbv;
47
static int hf_rtp_mpg_bfc;
48
static int hf_rtp_mpg_ffv;
49
static int hf_rtp_mpg_ffc;
50
static int hf_rtp_mpg_data;
51
52
53
/* MPEG-1 fields defining a sub tree */
54
static int ett_mpg;
55
56
static const value_string rtp_mpg_picture_types_vals[] =
57
{
58
  { 0, "Forbidden" },
59
  { 1, "I-Picture" },
60
  { 2, "P-Picture" },
61
  { 3, "B-Picture" },
62
  { 4, "D-Picture" },
63
  { 5, "reserved" },
64
  { 6, "reserved" },
65
  { 7, "reserved" },
66
  { 0, NULL },
67
};
68
69
static int
70
dissect_mpeg1( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ )
71
0
{
72
0
  proto_item *ti;
73
0
  proto_tree *mpg_tree;
74
0
  unsigned int offset       = 0;
75
76
0
  static int * const mpg_fields1[] = {
77
0
    &hf_rtp_mpg_mbz,
78
0
    &hf_rtp_mpg_T,
79
0
    &hf_rtp_mpg_tr,
80
0
    NULL
81
0
  };
82
0
  static int * const mpg_fields2[] = {
83
0
    &hf_rtp_mpg_an,
84
0
    &hf_rtp_mpg_n,
85
0
    &hf_rtp_mpg_s,
86
0
    &hf_rtp_mpg_b,
87
0
    &hf_rtp_mpg_e,
88
0
    &hf_rtp_mpg_p,
89
0
    NULL
90
0
  };
91
0
  static int * const mpg_fields3[] = {
92
0
    &hf_rtp_mpg_fbv,
93
0
    &hf_rtp_mpg_bfc,
94
0
    &hf_rtp_mpg_ffv,
95
0
    &hf_rtp_mpg_ffc,
96
0
    NULL
97
0
  };
98
99
0
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPEG-1");
100
0
  col_set_str(pinfo->cinfo, COL_INFO, "MPEG-1 message");
101
102
  /* Get MPEG-1  fields */
103
104
0
  ti = proto_tree_add_item( tree, proto_mpg, tvb, offset, -1, ENC_NA );
105
0
  mpg_tree = proto_item_add_subtree( ti, ett_mpg );
106
107
0
  proto_tree_add_bitmask_list(mpg_tree, tvb, offset, 2, mpg_fields1, ENC_BIG_ENDIAN);
108
0
  offset += 2;
109
110
0
  proto_tree_add_bitmask_list(mpg_tree, tvb, offset, 1, mpg_fields2, ENC_BIG_ENDIAN);
111
0
  offset += 1;
112
113
0
  proto_tree_add_bitmask_list(mpg_tree, tvb, offset, 1, mpg_fields3, ENC_NA);
114
0
  offset += 1;
115
116
  /* The rest of the packet is the MPEG-1 stream */
117
0
  proto_tree_add_item( mpg_tree, hf_rtp_mpg_data, tvb, offset, -1, ENC_NA );
118
0
  return tvb_captured_length(tvb);
119
0
}
120
121
void
122
proto_register_mpeg1(void)
123
16
{
124
16
  static hf_register_info hf[] =
125
16
  {
126
16
    {
127
16
      &hf_rtp_mpg_mbz,
128
16
      {
129
16
        "MBZ",
130
16
        "rtp.payload_mpeg_mbz",
131
16
        FT_UINT16,
132
16
        BASE_DEC,
133
16
        NULL,
134
16
        0xF800,
135
16
        NULL, HFILL
136
16
      }
137
16
    },
138
16
    {
139
16
      &hf_rtp_mpg_T,
140
16
      {
141
16
        "T",
142
16
        "rtp.payload_mpeg_T",
143
16
        FT_UINT16,
144
16
        BASE_DEC,
145
16
        NULL,
146
16
        0x0400,
147
16
        NULL, HFILL
148
16
      }
149
16
    },
150
16
    {
151
16
      &hf_rtp_mpg_tr,
152
16
      {
153
16
        "Temporal Reference",
154
16
        "rtp.payload_mpeg_tr",
155
16
        FT_UINT16,
156
16
        BASE_DEC,
157
16
        NULL,
158
16
        0x03FF,
159
16
        NULL, HFILL
160
16
      }
161
16
    },
162
16
    {
163
16
      &hf_rtp_mpg_an,
164
16
      {
165
16
        "AN",
166
16
        "rtp.payload_mpeg_an",
167
16
        FT_UINT8,
168
16
        BASE_DEC,
169
16
        NULL,
170
16
        0x80,
171
16
        NULL, HFILL
172
16
      }
173
16
    },
174
175
16
    {
176
16
      &hf_rtp_mpg_n,
177
16
      {
178
16
        "New Picture Header",
179
16
        "rtp.payload_mpeg_n",
180
16
        FT_UINT8,
181
16
        BASE_DEC,
182
16
        NULL,
183
16
        0x40,
184
16
        NULL, HFILL
185
16
      }
186
16
    },
187
188
16
    {
189
16
      &hf_rtp_mpg_s,
190
16
      {
191
16
        "Sequence Header",
192
16
        "rtp.payload_mpeg_s",
193
16
        FT_BOOLEAN,
194
16
        8,
195
16
        NULL,
196
16
        0x0020,
197
16
        NULL, HFILL
198
16
      }
199
16
    },
200
201
16
    {
202
16
      &hf_rtp_mpg_b,
203
16
      {
204
16
        "Beginning-of-slice",
205
16
        "rtp.payload_mpeg_b",
206
16
        FT_BOOLEAN,
207
16
        8,
208
16
        NULL,
209
16
        0x0010,
210
16
        NULL, HFILL
211
16
      }
212
16
    },
213
214
16
    {
215
16
      &hf_rtp_mpg_e,
216
16
      {
217
16
        "End-of-slice",
218
16
        "rtp.payload_mpeg_e",
219
16
        FT_BOOLEAN,
220
16
        8,
221
16
        NULL,
222
16
        0x0008,
223
16
        NULL, HFILL
224
16
      }
225
16
    },
226
227
16
    {
228
16
      &hf_rtp_mpg_p,
229
16
      {
230
16
        "Picture type",
231
16
        "rtp.payload_mpeg_p",
232
16
        FT_UINT8,
233
16
        BASE_DEC,
234
16
        VALS(rtp_mpg_picture_types_vals),
235
16
        0x07,
236
16
        NULL, HFILL
237
16
      }
238
16
    },
239
240
16
    {
241
16
      &hf_rtp_mpg_fbv,
242
16
      {
243
16
        "FBV",
244
16
        "rtp.payload_mpeg_fbv",
245
16
        FT_UINT16,
246
16
        BASE_DEC,
247
16
        NULL,
248
16
        0x80,
249
16
        NULL, HFILL
250
16
      }
251
16
    },
252
253
16
    {
254
16
      &hf_rtp_mpg_bfc,
255
16
      {
256
16
        "BFC",
257
16
        "rtp.payload_mpeg_bfc",
258
16
        FT_UINT16,
259
16
        BASE_DEC,
260
16
        NULL,
261
16
        0x70,
262
16
        NULL, HFILL
263
16
      }
264
16
    },
265
16
    {
266
16
      &hf_rtp_mpg_ffv,
267
16
      {
268
16
        "FFV",
269
16
        "rtp.payload_mpeg_ffv",
270
16
        FT_UINT16,
271
16
        BASE_DEC,
272
16
        NULL,
273
16
        0x08,
274
16
        NULL, HFILL
275
16
      }
276
16
    },
277
278
16
    {
279
16
      &hf_rtp_mpg_ffc,
280
16
      {
281
16
        "FFC",
282
16
        "rtp.payload_mpeg_ffc",
283
16
        FT_UINT16,
284
16
        BASE_DEC,
285
16
        NULL,
286
16
        0x07,
287
16
        NULL, HFILL
288
16
      }
289
16
    },
290
16
    {
291
16
      &hf_rtp_mpg_data,
292
16
      {
293
16
        "MPEG-1 stream",
294
16
        "mpeg1.stream",
295
16
        FT_BYTES,
296
16
        BASE_NONE,
297
16
        NULL,
298
16
        0x0,
299
16
        NULL, HFILL
300
16
      }
301
16
    },
302
303
16
  };
304
305
16
  static int *ett[] =
306
16
  {
307
16
    &ett_mpg,
308
16
  };
309
310
311
16
  proto_mpg = proto_register_protocol("RFC 2250 MPEG1","MPEG1","mpeg1");
312
16
  mpeg1_handle = register_dissector("mpeg1", dissect_mpeg1, proto_mpg);
313
16
  proto_register_field_array(proto_mpg, hf, array_length(hf));
314
16
  proto_register_subtree_array(ett, array_length(ett));
315
16
}
316
317
void
318
proto_reg_handoff_mpeg1(void)
319
16
{
320
16
  dissector_add_uint("rtp.pt", PT_MPV, mpeg1_handle);
321
16
}
322
323
/*
324
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
325
 *
326
 * Local variables:
327
 * c-basic-offset: 8
328
 * tab-width: 8
329
 * indent-tabs-mode: t
330
 * End:
331
 *
332
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
333
 * :indentSize=8:tabSize=8:noTabs=false:
334
 */