Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-mpeg1.c
blobc7611a4b775b4c1ac05ec0ff091a3e4b8428f846
1 /* packet-mpeg1.c
3 * Routines for RFC 2250 MPEG-1 dissection
5 * Copyright 2001,
6 * Francisco Javier Cabello Torres, <fjcabello@vtools.es>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * SPDX-License-Identifier: GPL-2.0-or-later
16 * This dissector tries to dissect the MPEG-1 video streams.
20 #include "config.h"
22 #include <epan/packet.h>
24 #include <epan/rtp_pt.h>
26 void proto_register_mpeg1(void);
27 void proto_reg_handoff_mpeg1(void);
29 static dissector_handle_t mpeg1_handle;
31 /* MPEG1 header fields */
33 static int proto_mpg;
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;
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;
53 /* MPEG-1 fields defining a sub tree */
54 static int ett_mpg;
56 static const value_string rtp_mpg_picture_types_vals[] =
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 },
69 static int
70 dissect_mpeg1( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ )
72 proto_item *ti;
73 proto_tree *mpg_tree;
74 unsigned int offset = 0;
76 static int * const mpg_fields1[] = {
77 &hf_rtp_mpg_mbz,
78 &hf_rtp_mpg_T,
79 &hf_rtp_mpg_tr,
80 NULL
82 static int * const mpg_fields2[] = {
83 &hf_rtp_mpg_an,
84 &hf_rtp_mpg_n,
85 &hf_rtp_mpg_s,
86 &hf_rtp_mpg_b,
87 &hf_rtp_mpg_e,
88 &hf_rtp_mpg_p,
89 NULL
91 static int * const mpg_fields3[] = {
92 &hf_rtp_mpg_fbv,
93 &hf_rtp_mpg_bfc,
94 &hf_rtp_mpg_ffv,
95 &hf_rtp_mpg_ffc,
96 NULL
99 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPEG-1");
100 col_set_str(pinfo->cinfo, COL_INFO, "MPEG-1 message");
102 /* Get MPEG-1 fields */
104 ti = proto_tree_add_item( tree, proto_mpg, tvb, offset, -1, ENC_NA );
105 mpg_tree = proto_item_add_subtree( ti, ett_mpg );
107 proto_tree_add_bitmask_list(mpg_tree, tvb, offset, 2, mpg_fields1, ENC_BIG_ENDIAN);
108 offset += 2;
110 proto_tree_add_bitmask_list(mpg_tree, tvb, offset, 2, mpg_fields2, ENC_BIG_ENDIAN);
111 offset += 1;
113 proto_tree_add_bitmask_list(mpg_tree, tvb, offset, 1, mpg_fields3, ENC_NA);
114 offset += 1;
116 /* The rest of the packet is the MPEG-1 stream */
117 proto_tree_add_item( mpg_tree, hf_rtp_mpg_data, tvb, offset, -1, ENC_NA );
118 return tvb_captured_length(tvb);
121 void
122 proto_register_mpeg1(void)
124 static hf_register_info hf[] =
127 &hf_rtp_mpg_mbz,
129 "MBZ",
130 "rtp.payload_mpeg_mbz",
131 FT_UINT16,
132 BASE_DEC,
133 NULL,
134 0xF800,
135 NULL, HFILL
139 &hf_rtp_mpg_T,
141 "T",
142 "rtp.payload_mpeg_T",
143 FT_UINT16,
144 BASE_DEC,
145 NULL,
146 0x0400,
147 NULL, HFILL
151 &hf_rtp_mpg_tr,
153 "Temporal Reference",
154 "rtp.payload_mpeg_tr",
155 FT_UINT16,
156 BASE_DEC,
157 NULL,
158 0x03FF,
159 NULL, HFILL
163 &hf_rtp_mpg_an,
165 "AN",
166 "rtp.payload_mpeg_an",
167 FT_UINT16,
168 BASE_DEC,
169 NULL,
170 0x80,
171 NULL, HFILL
176 &hf_rtp_mpg_n,
178 "New Picture Header",
179 "rtp.payload_mpeg_n",
180 FT_UINT16,
181 BASE_DEC,
182 NULL,
183 0x40,
184 NULL, HFILL
189 &hf_rtp_mpg_s,
191 "Sequence Header",
192 "rtp.payload_mpeg_s",
193 FT_BOOLEAN,
195 NULL,
196 0x0020,
197 NULL, HFILL
202 &hf_rtp_mpg_b,
204 "Beginning-of-slice",
205 "rtp.payload_mpeg_b",
206 FT_BOOLEAN,
208 NULL,
209 0x0010,
210 NULL, HFILL
215 &hf_rtp_mpg_e,
217 "End-of-slice",
218 "rtp.payload_mpeg_e",
219 FT_BOOLEAN,
221 NULL,
222 0x0008,
223 NULL, HFILL
228 &hf_rtp_mpg_p,
230 "Picture type",
231 "rtp.payload_mpeg_p",
232 FT_UINT16,
233 BASE_DEC,
234 VALS(rtp_mpg_picture_types_vals),
235 0x07,
236 NULL, HFILL
241 &hf_rtp_mpg_fbv,
243 "FBV",
244 "rtp.payload_mpeg_fbv",
245 FT_UINT16,
246 BASE_DEC,
247 NULL,
248 0x80,
249 NULL, HFILL
254 &hf_rtp_mpg_bfc,
256 "BFC",
257 "rtp.payload_mpeg_bfc",
258 FT_UINT16,
259 BASE_DEC,
260 NULL,
261 0x70,
262 NULL, HFILL
266 &hf_rtp_mpg_ffv,
268 "FFV",
269 "rtp.payload_mpeg_ffv",
270 FT_UINT16,
271 BASE_DEC,
272 NULL,
273 0x08,
274 NULL, HFILL
279 &hf_rtp_mpg_ffc,
281 "FFC",
282 "rtp.payload_mpeg_ffc",
283 FT_UINT16,
284 BASE_DEC,
285 NULL,
286 0x07,
287 NULL, HFILL
291 &hf_rtp_mpg_data,
293 "MPEG-1 stream",
294 "mpeg1.stream",
295 FT_BYTES,
296 BASE_NONE,
297 NULL,
298 0x0,
299 NULL, HFILL
305 static int *ett[] =
307 &ett_mpg,
311 proto_mpg = proto_register_protocol("RFC 2250 MPEG1","MPEG1","mpeg1");
312 mpeg1_handle = register_dissector("mpeg1", dissect_mpeg1, proto_mpg);
313 proto_register_field_array(proto_mpg, hf, array_length(hf));
314 proto_register_subtree_array(ett, array_length(ett));
317 void
318 proto_reg_handoff_mpeg1(void)
320 dissector_add_uint("rtp.pt", PT_MPV, mpeg1_handle);
324 * Editor modelines - https://www.wireshark.org/tools/modelines.html
326 * Local variables:
327 * c-basic-offset: 8
328 * tab-width: 8
329 * indent-tabs-mode: t
330 * End:
332 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
333 * :indentSize=8:tabSize=8:noTabs=false: