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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 existance 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
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 gboolean dissect_fec = FALSE;
77 static int proto_2dparityfec = -1;
78 static int fec_rtp_payload_type = 96;
79 static gint ett_2dparityfec = -1;
81 static int hf_2dparityfec_snbase_low = -1;
82 static int hf_2dparityfec_length_recovery = -1;
83 static int hf_2dparityfec_rfc2733_ext = -1;
84 static int hf_2dparityfec_pt_recovery = -1;
85 static int hf_2dparityfec_mask = -1;
86 static int hf_2dparityfec_ts_recovery = -1;
87 static int hf_2dparityfec_ts_pro_mpeg_ext = -1;
88 static int hf_2dparityfec_row_flag = -1;
89 static int hf_2dparityfec_type = -1;
90 static int hf_2dparityfec_index = -1;
91 static int hf_2dparityfec_offset = -1;
92 static int hf_2dparityfec_na = -1;
93 static int hf_2dparityfec_snbase_ext = -1;
94 static int hf_2dparityfec_payload = -1;
96 static const value_string fec_type_names[] = {
101 static void dissect_2dparityfec(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
109 SNBase = (guint32)tvb_get_guint8(tvb, 0)<<8;
110 SNBase |= (guint32)tvb_get_guint8(tvb, 1);
111 SNBase |= (guint32)tvb_get_guint8(tvb, 15)<<16;
114 D = (tvb_get_guint8(tvb, 12)>>6) & 0x1;
116 /* Extract Offset and NA */
117 OffsetField = tvb_get_guint8(tvb, 13);
118 NAField = tvb_get_guint8(tvb, 14);
120 if(check_col(pinfo->cinfo, COL_PROTOCOL))
122 col_set_str(pinfo->cinfo, COL_PROTOCOL, "2dFEC");
125 /* Configure the info column */
126 if(check_col(pinfo->cinfo, COL_INFO))
128 col_clear(pinfo->cinfo, COL_INFO);
132 col_add_fstr(pinfo->cinfo, COL_INFO, "Row FEC - SNBase=%u, Offset=%u, NA=%u",
133 SNBase, OffsetField, NAField);
137 col_add_fstr(pinfo->cinfo, COL_INFO, "Column FEC - SNBase=%u, Offset=%u, NA=%u",
138 SNBase, OffsetField, NAField);
144 /* we are being asked for details */
145 proto_item *ti = NULL;
146 proto_tree *tree_2dparityfec = NULL;
149 ti = proto_tree_add_item(tree, proto_2dparityfec, tvb, 0, -1, FALSE);
150 tree_2dparityfec = proto_item_add_subtree(ti, ett_2dparityfec);
152 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_snbase_low, tvb, offset, 2, FALSE); offset += 2;
153 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_length_recovery, tvb, offset, 2, FALSE); offset += 2;
154 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_rfc2733_ext, tvb, offset, 1, FALSE);
155 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_pt_recovery, tvb, offset, 1, FALSE); offset += 1;
156 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_mask, tvb, offset, 3, FALSE); offset += 3;
157 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_ts_recovery, tvb, offset, 4, FALSE); offset += 4;
158 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_ts_pro_mpeg_ext, tvb, offset, 1, FALSE);
159 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_row_flag, tvb, offset, 1, FALSE);
160 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_type, tvb, offset, 1, FALSE);
161 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_index, tvb, offset, 1, FALSE); offset += 1;
162 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_offset, tvb, offset, 1, FALSE); offset += 1;
163 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_na, tvb, offset, 1, FALSE); offset += 1;
164 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_snbase_ext, tvb, offset, 1, FALSE); offset += 1;
165 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_payload, tvb, offset, -1, FALSE);
169 /* Payload type definitions */
170 static hf_register_info hf[] = {
171 {&hf_2dparityfec_snbase_low,
173 "2dparityfec.snbase_low",
181 {&hf_2dparityfec_length_recovery,
191 {&hf_2dparityfec_rfc2733_ext,
192 { "RFC2733 Extension (E)",
201 {&hf_2dparityfec_pt_recovery,
202 { "Payload Type recovery",
211 {&hf_2dparityfec_mask,
214 /*FT_UINT32*/FT_UINT24,
221 {&hf_2dparityfec_ts_recovery,
222 { "Timestamp recovery",
231 {&hf_2dparityfec_ts_pro_mpeg_ext,
232 { "Pro-MPEG Extension (X)",
241 {&hf_2dparityfec_row_flag,
251 {&hf_2dparityfec_type,
256 VALS(fec_type_names),
261 {&hf_2dparityfec_index,
271 {&hf_2dparityfec_offset,
273 "2dparityfec.offset",
291 {&hf_2dparityfec_snbase_ext,
293 "2dparityfec.snbase_ext",
301 {&hf_2dparityfec_payload,
303 "2dparityfec.payload",
314 /* Setup protocol subtree array */
315 static gint *ett[] = {
319 void proto_register_2dparityfec(void)
321 module_t *module_2dparityfec;
323 proto_2dparityfec = proto_register_protocol(
324 "Pro-MPEG Code of Practice #3 release 2 FEC Protocol", /* name */
325 "2dparityfec", /* short name */
326 "2dparityfec"); /* abbrev */
328 proto_register_field_array(proto_2dparityfec, hf, array_length(hf));
329 proto_register_subtree_array(ett, array_length(ett));
331 module_2dparityfec = prefs_register_protocol(proto_2dparityfec,
332 proto_reg_handoff_2dparityfec);
334 prefs_register_bool_preference(module_2dparityfec, "enable",
335 "Decode Pro-MPEG FEC on RTP dynamic payload type 96",
336 "Enable this option to recognise all traffic on RTP dynamic payload type 96 (0x60) "
337 "as FEC data corresponding to Pro-MPEG Code of Practice #3 release 2",
342 void proto_reg_handoff_2dparityfec(void)
344 static dissector_handle_t handle_2dparityfec = NULL;
346 if (!handle_2dparityfec) {
347 handle_2dparityfec = create_dissector_handle(dissect_2dparityfec,
352 dissector_add("rtp.pt", fec_rtp_payload_type, handle_2dparityfec);
354 dissector_delete("rtp.pt", fec_rtp_payload_type, handle_2dparityfec);