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_reg_handoff_2dparityfec(void);
74 static gboolean dissect_fec = FALSE;
76 static int proto_2dparityfec = -1;
77 static int fec_rtp_payload_type = 96;
78 static gint ett_2dparityfec = -1;
80 static int hf_2dparityfec_snbase_low = -1;
81 static int hf_2dparityfec_length_recovery = -1;
82 static int hf_2dparityfec_rfc2733_ext = -1;
83 static int hf_2dparityfec_pt_recovery = -1;
84 static int hf_2dparityfec_mask = -1;
85 static int hf_2dparityfec_ts_recovery = -1;
86 static int hf_2dparityfec_ts_pro_mpeg_ext = -1;
87 static int hf_2dparityfec_row_flag = -1;
88 static int hf_2dparityfec_type = -1;
89 static int hf_2dparityfec_index = -1;
90 static int hf_2dparityfec_offset = -1;
91 static int hf_2dparityfec_na = -1;
92 static int hf_2dparityfec_snbase_ext = -1;
93 static int hf_2dparityfec_payload = -1;
95 static const value_string fec_type_names[] = {
102 static void dissect_2dparityfec(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
110 SNBase = (guint32)tvb_get_guint8(tvb, 0)<<8;
111 SNBase |= (guint32)tvb_get_guint8(tvb, 1);
112 SNBase |= (guint32)tvb_get_guint8(tvb, 15)<<16;
115 D = (tvb_get_guint8(tvb, 12)>>6) & 0x1;
117 /* Extract Offset and NA */
118 OffsetField = tvb_get_guint8(tvb, 13);
119 NAField = tvb_get_guint8(tvb, 14);
121 col_set_str(pinfo->cinfo, COL_PROTOCOL, "2dFEC");
123 /* Configure the info column */
124 if(check_col(pinfo->cinfo, COL_INFO))
126 col_clear(pinfo->cinfo, COL_INFO);
130 col_add_fstr(pinfo->cinfo, COL_INFO, "Row FEC - SNBase=%u, Offset=%u, NA=%u",
131 SNBase, OffsetField, NAField);
135 col_add_fstr(pinfo->cinfo, COL_INFO, "Column FEC - SNBase=%u, Offset=%u, NA=%u",
136 SNBase, OffsetField, NAField);
142 /* we are being asked for details */
143 proto_item *ti = NULL;
144 proto_tree *tree_2dparityfec = NULL;
147 ti = proto_tree_add_item(tree, proto_2dparityfec, tvb, 0, -1, FALSE);
148 tree_2dparityfec = proto_item_add_subtree(ti, ett_2dparityfec);
150 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_snbase_low, tvb, offset, 2, FALSE); offset += 2;
151 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_length_recovery, tvb, offset, 2, FALSE); offset += 2;
152 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_rfc2733_ext, tvb, offset, 1, FALSE);
153 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_pt_recovery, tvb, offset, 1, FALSE); offset += 1;
154 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_mask, tvb, offset, 3, FALSE); offset += 3;
155 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_ts_recovery, tvb, offset, 4, FALSE); offset += 4;
156 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_ts_pro_mpeg_ext, tvb, offset, 1, FALSE);
157 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_row_flag, tvb, offset, 1, FALSE);
158 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_type, tvb, offset, 1, FALSE);
159 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_index, tvb, offset, 1, FALSE); offset += 1;
160 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_offset, tvb, offset, 1, FALSE); offset += 1;
161 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_na, tvb, offset, 1, FALSE); offset += 1;
162 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_snbase_ext, tvb, offset, 1, FALSE); offset += 1;
163 proto_tree_add_item(tree_2dparityfec, hf_2dparityfec_payload, tvb, offset, -1, FALSE);
167 void proto_register_2dparityfec(void)
169 module_t *module_2dparityfec;
171 /* Payload type definitions */
172 static hf_register_info hf[] = {
173 {&hf_2dparityfec_snbase_low,
175 "2dparityfec.snbase_low",
183 {&hf_2dparityfec_length_recovery,
193 {&hf_2dparityfec_rfc2733_ext,
194 { "RFC2733 Extension (E)",
203 {&hf_2dparityfec_pt_recovery,
204 { "Payload Type recovery",
213 {&hf_2dparityfec_mask,
216 /*FT_UINT32*/FT_UINT24,
223 {&hf_2dparityfec_ts_recovery,
224 { "Timestamp recovery",
233 {&hf_2dparityfec_ts_pro_mpeg_ext,
234 { "Pro-MPEG Extension (X)",
243 {&hf_2dparityfec_row_flag,
253 {&hf_2dparityfec_type,
258 VALS(fec_type_names),
263 {&hf_2dparityfec_index,
273 {&hf_2dparityfec_offset,
275 "2dparityfec.offset",
293 {&hf_2dparityfec_snbase_ext,
295 "2dparityfec.snbase_ext",
303 {&hf_2dparityfec_payload,
305 "2dparityfec.payload",
316 /* Setup protocol subtree array */
317 static gint *ett[] = {
321 proto_2dparityfec = proto_register_protocol(
322 "Pro-MPEG Code of Practice #3 release 2 FEC Protocol", /* name */
323 "2dparityfec", /* short name */
324 "2dparityfec"); /* abbrev */
326 proto_register_field_array(proto_2dparityfec, hf, array_length(hf));
327 proto_register_subtree_array(ett, array_length(ett));
329 module_2dparityfec = prefs_register_protocol(proto_2dparityfec,
330 proto_reg_handoff_2dparityfec);
332 prefs_register_bool_preference(module_2dparityfec, "enable",
333 "Decode Pro-MPEG FEC on RTP dynamic payload type 96",
334 "Enable this option to recognise all traffic on RTP dynamic payload type 96 (0x60) "
335 "as FEC data corresponding to Pro-MPEG Code of Practice #3 release 2",
340 void proto_reg_handoff_2dparityfec(void)
342 static dissector_handle_t handle_2dparityfec = NULL;
344 if (!handle_2dparityfec) {
345 handle_2dparityfec = create_dissector_handle(dissect_2dparityfec,
350 dissector_add("rtp.pt", fec_rtp_payload_type, handle_2dparityfec);
352 dissector_delete("rtp.pt", fec_rtp_payload_type, handle_2dparityfec);
362 * indent-tabs-mode: nil
365 * ex: set shiftwidth=3 tabstop=3 expandtab
366 * :indentSize=3:tabSize=3:noTabs=true: