1 /* packet-2dparityfec.c
2 * Mark Lewis <mlewis@altera.com>
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
12 ** RTP Payload dissector for packets as specified in:
13 ** Pro-MPEG Code of Practice #3 release 2
15 ** This protocol defines a format for FEC data embedded within RTP packets with
16 ** a payload type of 96 (0x60). The format of the FEC packets, which reside within
17 ** the RTP payload, is as follows...
19 ** +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
20 ** | SNBase low bits | Length Recovery |
21 ** +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
22 ** |E| PT recovery | Mask |
23 ** +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25 ** +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
26 ** |X|D|type |index| Offset | NA |SNBase ext bits|
27 ** +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31 ** +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
33 ** For more information on this protocol see...
34 ** http://www.pro-mpeg.org/publications/pdf/Vid-on-IP-CoP3-r2.pdf
39 ** This protocol always resides in RTP packets with payload type 96. However,
40 ** type 96 is dynamic and may refer to other protocols. As Pro-MPEG FEC must
41 ** function in the absence of a control channel, and because this data is
42 ** likely to be transmitted within closed networks, no automatic mechanism
43 ** exists for specifying the existence of Pro-MPEG FEC on payload type 96.
44 ** This dissector is thus disabled by default. Dissection of this protocol
45 ** may be enabled from the 2dparityfec panel under Preferences->Protocols.
47 ** Mark Lewis - 20th June 2006
51 #include <epan/packet.h>
52 #include <epan/prefs.h>
53 #include <wsutil/array.h>
55 /* forward reference */
56 void proto_register_2dparityfec(void);
57 void proto_reg_handoff_2dparityfec(void);
59 static dissector_handle_t handle_2dparityfec
;
61 static bool dissect_fec
;
63 static int fec_rtp_payload_type
= 96;
65 static int proto_2dparityfec
;
67 static int hf_2dparityfec_index
;
68 static int hf_2dparityfec_length_recovery
;
69 static int hf_2dparityfec_mask
;
70 static int hf_2dparityfec_na
;
71 static int hf_2dparityfec_offset
;
72 static int hf_2dparityfec_payload
;
73 static int hf_2dparityfec_pt_recovery
;
74 static int hf_2dparityfec_rfc2733_ext
;
75 static int hf_2dparityfec_row_flag
;
76 static int hf_2dparityfec_snbase_ext
;
77 static int hf_2dparityfec_snbase_low
;
78 static int hf_2dparityfec_ts_pro_mpeg_ext
;
79 static int hf_2dparityfec_ts_recovery
;
80 static int hf_2dparityfec_type
;
82 static int ett_2dparityfec
;
84 static const value_string fec_type_names
[] = {
91 static int dissect_2dparityfec(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
99 SNBase
= (uint32_t)tvb_get_uint8(tvb
, 0)<<8;
100 SNBase
|= (uint32_t)tvb_get_uint8(tvb
, 1);
101 SNBase
|= (uint32_t)tvb_get_uint8(tvb
, 15)<<16;
104 D
= (tvb_get_uint8(tvb
, 12)>>6) & 0x1;
106 /* Extract Offset and NA */
107 OffsetField
= tvb_get_uint8(tvb
, 13);
108 NAField
= tvb_get_uint8(tvb
, 14);
110 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "2dFEC");
112 /* Configure the info column */
115 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Row FEC - SNBase=%u, Offset=%u, NA=%u",
116 SNBase
, OffsetField
, NAField
);
120 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Column FEC - SNBase=%u, Offset=%u, NA=%u",
121 SNBase
, OffsetField
, NAField
);
126 /* we are being asked for details */
128 proto_tree
*tree_2dparityfec
;
131 ti
= proto_tree_add_item(tree
, proto_2dparityfec
, tvb
, 0, -1, ENC_NA
);
132 tree_2dparityfec
= proto_item_add_subtree(ti
, ett_2dparityfec
);
134 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_snbase_low
, tvb
, offset
, 2, ENC_BIG_ENDIAN
); offset
+= 2;
135 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_length_recovery
, tvb
, offset
, 2, ENC_BIG_ENDIAN
); offset
+= 2;
136 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_rfc2733_ext
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
137 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_pt_recovery
, tvb
, offset
, 1, ENC_BIG_ENDIAN
); offset
+= 1;
138 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_mask
, tvb
, offset
, 3, ENC_BIG_ENDIAN
); offset
+= 3;
139 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_ts_recovery
, tvb
, offset
, 4, ENC_BIG_ENDIAN
); offset
+= 4;
140 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_ts_pro_mpeg_ext
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
141 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_row_flag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
142 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
143 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_index
, tvb
, offset
, 1, ENC_BIG_ENDIAN
); offset
+= 1;
144 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_offset
, tvb
, offset
, 1, ENC_BIG_ENDIAN
); offset
+= 1;
145 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_na
, tvb
, offset
, 1, ENC_BIG_ENDIAN
); offset
+= 1;
146 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_snbase_ext
, tvb
, offset
, 1, ENC_BIG_ENDIAN
); offset
+= 1;
147 proto_tree_add_item(tree_2dparityfec
, hf_2dparityfec_payload
, tvb
, offset
, -1, ENC_NA
);
150 return tvb_captured_length(tvb
);
153 void proto_register_2dparityfec(void)
155 static hf_register_info hf
[] = {
156 { &hf_2dparityfec_snbase_low
,
157 { "SNBase low", "2dparityfec.snbase_low",
158 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
161 { &hf_2dparityfec_length_recovery
,
162 { "Length recovery", "2dparityfec.lr",
163 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
166 { &hf_2dparityfec_rfc2733_ext
,
167 { "RFC2733 Extension (E)", "2dparityfec.e",
168 FT_BOOLEAN
, 8, NULL
, 0x80,
171 { &hf_2dparityfec_pt_recovery
,
172 { "Payload Type recovery", "2dparityfec.ptr",
173 FT_UINT8
, BASE_HEX
, NULL
, 0x7f,
176 { &hf_2dparityfec_mask
,
177 { "Mask", "2dparityfec.mask",
178 /*FT_UINT32*/FT_UINT24
, BASE_HEX
, NULL
, /*0x00ffffff*/0x0,
181 { &hf_2dparityfec_ts_recovery
,
182 { "Timestamp recovery", "2dparityfec.tsr",
183 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
186 { &hf_2dparityfec_ts_pro_mpeg_ext
,
187 { "Pro-MPEG Extension (X)", "2dparityfec.x",
188 FT_BOOLEAN
, 8, NULL
, 0x80,
191 { &hf_2dparityfec_row_flag
,
192 { "Row FEC (D)", "2dparityfec.d",
193 FT_BOOLEAN
, 8, NULL
, 0x40,
196 { &hf_2dparityfec_type
,
197 { "Type", "2dparityfec.type",
198 FT_UINT8
, BASE_DEC
, VALS(fec_type_names
), 0x38,
201 { &hf_2dparityfec_index
,
202 { "Index", "2dparityfec.index",
203 FT_UINT8
, BASE_DEC
, NULL
, 0x07,
206 { &hf_2dparityfec_offset
,
207 { "Offset", "2dparityfec.offset",
208 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
211 { &hf_2dparityfec_na
,
212 { "NA", "2dparityfec.na",
213 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
216 { &hf_2dparityfec_snbase_ext
,
217 { "SNBase ext", "2dparityfec.snbase_ext",
218 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
221 { &hf_2dparityfec_payload
,
222 { "FEC Payload", "2dparityfec.payload",
223 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
228 /* Setup protocol subtree array */
229 static int *ett
[] = {
233 module_t
*module_2dparityfec
;
235 proto_2dparityfec
= proto_register_protocol("Pro-MPEG Code of Practice #3 release 2 FEC Protocol", "2dparityfec", "2dparityfec");
237 proto_register_field_array(proto_2dparityfec
, hf
, array_length(hf
));
238 proto_register_subtree_array(ett
, array_length(ett
));
240 module_2dparityfec
= prefs_register_protocol(proto_2dparityfec
,
241 proto_reg_handoff_2dparityfec
);
243 prefs_register_bool_preference(module_2dparityfec
, "enable",
244 "Decode Pro-MPEG FEC on RTP dynamic payload type 96",
245 "Enable this option to recognise all traffic on RTP dynamic payload type 96 (0x60) "
246 "as FEC data corresponding to Pro-MPEG Code of Practice #3 release 2",
249 handle_2dparityfec
= register_dissector("2dparityfec", dissect_2dparityfec
,
253 void proto_reg_handoff_2dparityfec(void)
256 dissector_add_uint("rtp.pt", fec_rtp_payload_type
, handle_2dparityfec
);
258 dissector_delete_uint("rtp.pt", fec_rtp_payload_type
, handle_2dparityfec
);
268 * indent-tabs-mode: nil
271 * ex: set shiftwidth=3 tabstop=8 expandtab:
272 * :indentSize=3:tabSize=8:noTabs=true: