1 /* packet-2dparityfec.c
2 * Mark Lewis <mlewis@altera.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 ** RTP Payload dissector for packets as specified in:
27 ** Pro-MPEG Code of Practice #3 release 2
29 ** This protocol defines a format for FEC data embedded within RTP packets with
30 ** a payload type of 96 (0x60). The format of the FEC packets, which reside within
31 ** the RTP payload, is as follows...
33 ** +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
34 ** | SNBase low bits | Length Recovery |
35 ** +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 ** |E| PT recovery | Mask |
37 ** +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 ** +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 ** |X|D|type |index| Offset | NA |SNBase ext bits|
41 ** +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 ** +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 ** For more information on this protocol see...
48 ** http://www.pro-mpeg.org/publications/pdf/Vid-on-IP-CoP3-r2.pdf
53 ** This protocol always resides in RTP packets with payload type 96. However,
54 ** type 96 is dynamic and may refer to other protocols. As Pro-MPEG FEC must
55 ** function in the absence of a control channel, and because this data is
56 ** likely to be transmitted within closed networks, no automatic mechanism
57 ** exists for specifying the existence of Pro-MPEG FEC on payload type 96.
58 ** This dissector is thus disabled by default. Dissection of this protocol
59 ** may be enabled from the 2dparityfec panel under Preferences->Protocols.
61 ** Mark Lewis - 20th June 2006
64 #define NEW_PROTO_TREE_API
68 #include <epan/packet.h>
69 #include <epan/prefs.h>
71 /* forward reference */
72 void proto_register_2dparityfec(void);
73 void proto_reg_handoff_2dparityfec(void);
75 static dissector_handle_t handle_2dparityfec
= NULL
;
77 static gboolean dissect_fec
= FALSE
;
79 static int fec_rtp_payload_type
= 96;
80 static gint ett_2dparityfec
= -1;
82 static header_field_info
*hfi_2dparityfec
= NULL
;
84 #define _2DPARITYFEC_HFI_INIT HFI_INIT(proto_2dparityfec)
86 static header_field_info hfi_2dparityfec_snbase_low _2DPARITYFEC_HFI_INIT
=
88 "2dparityfec.snbase_low",
96 static header_field_info hfi_2dparityfec_length_recovery _2DPARITYFEC_HFI_INIT
=
106 static header_field_info hfi_2dparityfec_rfc2733_ext _2DPARITYFEC_HFI_INIT
=
107 { "RFC2733 Extension (E)",
116 static header_field_info hfi_2dparityfec_pt_recovery _2DPARITYFEC_HFI_INIT
=
117 { "Payload Type recovery",
126 static header_field_info hfi_2dparityfec_mask _2DPARITYFEC_HFI_INIT
=
129 /*FT_UINT32*/FT_UINT24
,
136 static header_field_info hfi_2dparityfec_ts_recovery _2DPARITYFEC_HFI_INIT
=
137 { "Timestamp recovery",
146 static header_field_info hfi_2dparityfec_ts_pro_mpeg_ext _2DPARITYFEC_HFI_INIT
=
147 { "Pro-MPEG Extension (X)",
156 static header_field_info hfi_2dparityfec_row_flag _2DPARITYFEC_HFI_INIT
=
166 static const value_string fec_type_names
[] = {
173 static header_field_info hfi_2dparityfec_type _2DPARITYFEC_HFI_INIT
=
178 VALS(fec_type_names
),
183 static header_field_info hfi_2dparityfec_index _2DPARITYFEC_HFI_INIT
=
193 static header_field_info hfi_2dparityfec_offset _2DPARITYFEC_HFI_INIT
=
195 "2dparityfec.offset",
203 static header_field_info hfi_2dparityfec_na _2DPARITYFEC_HFI_INIT
=
213 static header_field_info hfi_2dparityfec_snbase_ext _2DPARITYFEC_HFI_INIT
=
215 "2dparityfec.snbase_ext",
223 static header_field_info hfi_2dparityfec_payload _2DPARITYFEC_HFI_INIT
=
225 "2dparityfec.payload",
234 static void dissect_2dparityfec(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
242 SNBase
= (guint32
)tvb_get_guint8(tvb
, 0)<<8;
243 SNBase
|= (guint32
)tvb_get_guint8(tvb
, 1);
244 SNBase
|= (guint32
)tvb_get_guint8(tvb
, 15)<<16;
247 D
= (tvb_get_guint8(tvb
, 12)>>6) & 0x1;
249 /* Extract Offset and NA */
250 OffsetField
= tvb_get_guint8(tvb
, 13);
251 NAField
= tvb_get_guint8(tvb
, 14);
253 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "2dFEC");
255 /* Configure the info column */
258 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Row FEC - SNBase=%u, Offset=%u, NA=%u",
259 SNBase
, OffsetField
, NAField
);
263 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Column FEC - SNBase=%u, Offset=%u, NA=%u",
264 SNBase
, OffsetField
, NAField
);
269 /* we are being asked for details */
270 proto_item
*ti
= NULL
;
271 proto_tree
*tree_2dparityfec
= NULL
;
274 ti
= proto_tree_add_item(tree
, hfi_2dparityfec
, tvb
, 0, -1, ENC_NA
);
275 tree_2dparityfec
= proto_item_add_subtree(ti
, ett_2dparityfec
);
277 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_snbase_low
, tvb
, offset
, 2, ENC_BIG_ENDIAN
); offset
+= 2;
278 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_length_recovery
, tvb
, offset
, 2, ENC_BIG_ENDIAN
); offset
+= 2;
279 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_rfc2733_ext
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
280 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_pt_recovery
, tvb
, offset
, 1, ENC_BIG_ENDIAN
); offset
+= 1;
281 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_mask
, tvb
, offset
, 3, ENC_BIG_ENDIAN
); offset
+= 3;
282 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_ts_recovery
, tvb
, offset
, 4, ENC_BIG_ENDIAN
); offset
+= 4;
283 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_ts_pro_mpeg_ext
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
284 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_row_flag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
285 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
286 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_index
, tvb
, offset
, 1, ENC_BIG_ENDIAN
); offset
+= 1;
287 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_offset
, tvb
, offset
, 1, ENC_BIG_ENDIAN
); offset
+= 1;
288 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_na
, tvb
, offset
, 1, ENC_BIG_ENDIAN
); offset
+= 1;
289 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_snbase_ext
, tvb
, offset
, 1, ENC_BIG_ENDIAN
); offset
+= 1;
290 proto_tree_add_item(tree_2dparityfec
, &hfi_2dparityfec_payload
, tvb
, offset
, -1, ENC_NA
);
294 void proto_register_2dparityfec(void)
296 module_t
*module_2dparityfec
;
298 #ifndef HAVE_HFI_SECTION_INIT
299 /* Payload type definitions */
300 static header_field_info
*hfi
[] = {
301 &hfi_2dparityfec_snbase_low
,
302 &hfi_2dparityfec_length_recovery
,
303 &hfi_2dparityfec_rfc2733_ext
,
304 &hfi_2dparityfec_pt_recovery
,
305 &hfi_2dparityfec_mask
,
306 &hfi_2dparityfec_ts_recovery
,
307 &hfi_2dparityfec_ts_pro_mpeg_ext
,
308 &hfi_2dparityfec_row_flag
,
309 &hfi_2dparityfec_type
,
310 &hfi_2dparityfec_index
,
311 &hfi_2dparityfec_offset
,
313 &hfi_2dparityfec_snbase_ext
,
314 &hfi_2dparityfec_payload
,
318 /* Setup protocol subtree array */
319 static gint
*ett
[] = {
323 int proto_2dparityfec
;
325 proto_2dparityfec
= proto_register_protocol(
326 "Pro-MPEG Code of Practice #3 release 2 FEC Protocol", /* name */
327 "2dparityfec", /* short name */
328 "2dparityfec"); /* abbrev */
329 hfi_2dparityfec
= proto_registrar_get_nth(proto_2dparityfec
);
331 proto_register_fields(proto_2dparityfec
, hfi
, array_length(hfi
));
332 proto_register_subtree_array(ett
, array_length(ett
));
334 module_2dparityfec
= prefs_register_protocol(proto_2dparityfec
,
335 proto_reg_handoff_2dparityfec
);
337 prefs_register_bool_preference(module_2dparityfec
, "enable",
338 "Decode Pro-MPEG FEC on RTP dynamic payload type 96",
339 "Enable this option to recognise all traffic on RTP dynamic payload type 96 (0x60) "
340 "as FEC data corresponding to Pro-MPEG Code of Practice #3 release 2",
343 handle_2dparityfec
= create_dissector_handle(dissect_2dparityfec
,
347 void proto_reg_handoff_2dparityfec(void)
350 dissector_add_uint("rtp.pt", fec_rtp_payload_type
, handle_2dparityfec
);
352 dissector_delete_uint("rtp.pt", fec_rtp_payload_type
, handle_2dparityfec
);
362 * indent-tabs-mode: nil
365 * ex: set shiftwidth=3 tabstop=8 expandtab:
366 * :indentSize=3:tabSize=8:noTabs=true: