/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, 2, 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 | 14 | { |
124 | 14 | static hf_register_info hf[] = |
125 | 14 | { |
126 | 14 | { |
127 | 14 | &hf_rtp_mpg_mbz, |
128 | 14 | { |
129 | 14 | "MBZ", |
130 | 14 | "rtp.payload_mpeg_mbz", |
131 | 14 | FT_UINT16, |
132 | 14 | BASE_DEC, |
133 | 14 | NULL, |
134 | 14 | 0xF800, |
135 | 14 | NULL, HFILL |
136 | 14 | } |
137 | 14 | }, |
138 | 14 | { |
139 | 14 | &hf_rtp_mpg_T, |
140 | 14 | { |
141 | 14 | "T", |
142 | 14 | "rtp.payload_mpeg_T", |
143 | 14 | FT_UINT16, |
144 | 14 | BASE_DEC, |
145 | 14 | NULL, |
146 | 14 | 0x0400, |
147 | 14 | NULL, HFILL |
148 | 14 | } |
149 | 14 | }, |
150 | 14 | { |
151 | 14 | &hf_rtp_mpg_tr, |
152 | 14 | { |
153 | 14 | "Temporal Reference", |
154 | 14 | "rtp.payload_mpeg_tr", |
155 | 14 | FT_UINT16, |
156 | 14 | BASE_DEC, |
157 | 14 | NULL, |
158 | 14 | 0x03FF, |
159 | 14 | NULL, HFILL |
160 | 14 | } |
161 | 14 | }, |
162 | 14 | { |
163 | 14 | &hf_rtp_mpg_an, |
164 | 14 | { |
165 | 14 | "AN", |
166 | 14 | "rtp.payload_mpeg_an", |
167 | 14 | FT_UINT16, |
168 | 14 | BASE_DEC, |
169 | 14 | NULL, |
170 | 14 | 0x80, |
171 | 14 | NULL, HFILL |
172 | 14 | } |
173 | 14 | }, |
174 | | |
175 | 14 | { |
176 | 14 | &hf_rtp_mpg_n, |
177 | 14 | { |
178 | 14 | "New Picture Header", |
179 | 14 | "rtp.payload_mpeg_n", |
180 | 14 | FT_UINT16, |
181 | 14 | BASE_DEC, |
182 | 14 | NULL, |
183 | 14 | 0x40, |
184 | 14 | NULL, HFILL |
185 | 14 | } |
186 | 14 | }, |
187 | | |
188 | 14 | { |
189 | 14 | &hf_rtp_mpg_s, |
190 | 14 | { |
191 | 14 | "Sequence Header", |
192 | 14 | "rtp.payload_mpeg_s", |
193 | 14 | FT_BOOLEAN, |
194 | 14 | 16, |
195 | 14 | NULL, |
196 | 14 | 0x0020, |
197 | 14 | NULL, HFILL |
198 | 14 | } |
199 | 14 | }, |
200 | | |
201 | 14 | { |
202 | 14 | &hf_rtp_mpg_b, |
203 | 14 | { |
204 | 14 | "Beginning-of-slice", |
205 | 14 | "rtp.payload_mpeg_b", |
206 | 14 | FT_BOOLEAN, |
207 | 14 | 16, |
208 | 14 | NULL, |
209 | 14 | 0x0010, |
210 | 14 | NULL, HFILL |
211 | 14 | } |
212 | 14 | }, |
213 | | |
214 | 14 | { |
215 | 14 | &hf_rtp_mpg_e, |
216 | 14 | { |
217 | 14 | "End-of-slice", |
218 | 14 | "rtp.payload_mpeg_e", |
219 | 14 | FT_BOOLEAN, |
220 | 14 | 16, |
221 | 14 | NULL, |
222 | 14 | 0x0008, |
223 | 14 | NULL, HFILL |
224 | 14 | } |
225 | 14 | }, |
226 | | |
227 | 14 | { |
228 | 14 | &hf_rtp_mpg_p, |
229 | 14 | { |
230 | 14 | "Picture type", |
231 | 14 | "rtp.payload_mpeg_p", |
232 | 14 | FT_UINT16, |
233 | 14 | BASE_DEC, |
234 | 14 | VALS(rtp_mpg_picture_types_vals), |
235 | 14 | 0x07, |
236 | 14 | NULL, HFILL |
237 | 14 | } |
238 | 14 | }, |
239 | | |
240 | 14 | { |
241 | 14 | &hf_rtp_mpg_fbv, |
242 | 14 | { |
243 | 14 | "FBV", |
244 | 14 | "rtp.payload_mpeg_fbv", |
245 | 14 | FT_UINT16, |
246 | 14 | BASE_DEC, |
247 | 14 | NULL, |
248 | 14 | 0x80, |
249 | 14 | NULL, HFILL |
250 | 14 | } |
251 | 14 | }, |
252 | | |
253 | 14 | { |
254 | 14 | &hf_rtp_mpg_bfc, |
255 | 14 | { |
256 | 14 | "BFC", |
257 | 14 | "rtp.payload_mpeg_bfc", |
258 | 14 | FT_UINT16, |
259 | 14 | BASE_DEC, |
260 | 14 | NULL, |
261 | 14 | 0x70, |
262 | 14 | NULL, HFILL |
263 | 14 | } |
264 | 14 | }, |
265 | 14 | { |
266 | 14 | &hf_rtp_mpg_ffv, |
267 | 14 | { |
268 | 14 | "FFV", |
269 | 14 | "rtp.payload_mpeg_ffv", |
270 | 14 | FT_UINT16, |
271 | 14 | BASE_DEC, |
272 | 14 | NULL, |
273 | 14 | 0x08, |
274 | 14 | NULL, HFILL |
275 | 14 | } |
276 | 14 | }, |
277 | | |
278 | 14 | { |
279 | 14 | &hf_rtp_mpg_ffc, |
280 | 14 | { |
281 | 14 | "FFC", |
282 | 14 | "rtp.payload_mpeg_ffc", |
283 | 14 | FT_UINT16, |
284 | 14 | BASE_DEC, |
285 | 14 | NULL, |
286 | 14 | 0x07, |
287 | 14 | NULL, HFILL |
288 | 14 | } |
289 | 14 | }, |
290 | 14 | { |
291 | 14 | &hf_rtp_mpg_data, |
292 | 14 | { |
293 | 14 | "MPEG-1 stream", |
294 | 14 | "mpeg1.stream", |
295 | 14 | FT_BYTES, |
296 | 14 | BASE_NONE, |
297 | 14 | NULL, |
298 | 14 | 0x0, |
299 | 14 | NULL, HFILL |
300 | 14 | } |
301 | 14 | }, |
302 | | |
303 | 14 | }; |
304 | | |
305 | 14 | static int *ett[] = |
306 | 14 | { |
307 | 14 | &ett_mpg, |
308 | 14 | }; |
309 | | |
310 | | |
311 | 14 | proto_mpg = proto_register_protocol("RFC 2250 MPEG1","MPEG1","mpeg1"); |
312 | 14 | mpeg1_handle = register_dissector("mpeg1", dissect_mpeg1, proto_mpg); |
313 | 14 | proto_register_field_array(proto_mpg, hf, array_length(hf)); |
314 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
315 | 14 | } |
316 | | |
317 | | void |
318 | | proto_reg_handoff_mpeg1(void) |
319 | 14 | { |
320 | 14 | dissector_add_uint("rtp.pt", PT_MPV, mpeg1_handle); |
321 | 14 | } |
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 | | */ |