3 * Routines for RTP dissection
4 * RTP = Real time Transport Protocol
6 * Copyright 2000, Philips Electronics N.V.
7 * Written by Andreas Sikkema <h323@ramdyne.nl>
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 * This dissector tries to dissect the RTP protocol according to Annex A
32 * of ITU-T Recommendation H.225.0 (02/98) or RFC 1889
34 * RTP traffic is handled by an even UDP portnumber. This can be any
35 * port number, but there is a registered port available, port 5004
36 * See Annex B of ITU-T Recommendation H.225.0, section B.7
38 * This doesn't dissect older versions of RTP, such as:
40 * the vat protocol ("version 0") - see
42 * ftp://ftp.ee.lbl.gov/conferencing/vat/alpha-test/vatsrc-4.0b2.tar.gz
44 * and look in "session-vat.cc" if you want to write a dissector
45 * (have fun - there aren't any nice header files showing the packet
48 * version 1, as documented in
50 * ftp://gaia.cs.umass.edu/pub/hgschulz/rtp/draft-ietf-avt-rtp-04.txt
52 * It also dissects PacketCable CCC-encapsulated RTP data, as described in
53 * chapter 5 of the PacketCable Electronic Surveillance Specification:
55 * http://www.packetcable.com/downloads/specs/PKT-SP-ESP1.5-I01-050128.pdf
63 #include <epan/packet.h>
65 #include "packet-rtp.h"
66 #include <epan/rtp_pt.h>
67 #include <epan/conversation.h>
68 #include <epan/reassemble.h>
71 #include <epan/prefs.h>
72 #include <epan/emem.h>
73 #include <epan/strutil.h>
75 /* uncomment this to enable debugging of fragment reassembly */
76 /* #define DEBUG_FRAGMENTS 1 */
78 typedef struct _rfc2198_hdr {
82 struct _rfc2198_hdr *next;
85 /* we have one of these for each pdu which spans more than one segment
87 typedef struct _rtp_multisegment_pdu {
88 /* the seqno of the segment where the pdu starts */
91 /* the seqno of the segment where the pdu ends */
93 } rtp_multisegment_pdu;
95 typedef struct _rtp_private_conv_info {
96 /* This tree is indexed by sequence number and keeps track of all
97 * all pdus spanning multiple segments for this flow.
99 emem_tree_t *multisegment_pdus;
100 } rtp_private_conv_info;
102 static GHashTable *fragment_table = NULL;
104 static int hf_rtp_fragments = -1;
105 static int hf_rtp_fragment = -1;
106 static int hf_rtp_fragment_overlap = -1;
107 static int hf_rtp_fragment_overlap_conflict = -1;
108 static int hf_rtp_fragment_multiple_tails = -1;
109 static int hf_rtp_fragment_too_long_fragment = -1;
110 static int hf_rtp_fragment_error = -1;
111 static int hf_rtp_fragment_count = -1;
112 static int hf_rtp_reassembled_in = -1;
113 static int hf_rtp_reassembled_length = -1;
115 static gint ett_rtp_fragment = -1;
116 static gint ett_rtp_fragments = -1;
118 static const fragment_items rtp_fragment_items = {
123 &hf_rtp_fragment_overlap,
124 &hf_rtp_fragment_overlap_conflict,
125 &hf_rtp_fragment_multiple_tails,
126 &hf_rtp_fragment_too_long_fragment,
127 &hf_rtp_fragment_error,
128 &hf_rtp_fragment_count,
129 &hf_rtp_reassembled_in,
130 &hf_rtp_reassembled_length,
134 static dissector_handle_t rtp_handle;
135 static dissector_handle_t classicstun_handle;
136 static dissector_handle_t classicstun_heur_handle;
137 static dissector_handle_t t38_handle;
138 static dissector_handle_t zrtp_handle;
140 static dissector_handle_t sprt_handle;
141 static dissector_handle_t v150fw_handle;
143 static int rtp_tap = -1;
145 static dissector_table_t rtp_pt_dissector_table;
146 static dissector_table_t rtp_dyn_pt_dissector_table;
148 static dissector_table_t rtp_hdr_ext_dissector_table;
149 static dissector_table_t rtp_hdr_ext_rfc5285_dissector_table;
151 /* RTP header fields */
152 static int proto_rtp = -1;
153 static int hf_rtp_version = -1;
154 static int hf_rtp_padding = -1;
155 static int hf_rtp_extension = -1;
156 static int hf_rtp_csrc_count = -1;
157 static int hf_rtp_marker = -1;
158 static int hf_rtp_payload_type = -1;
159 static int hf_rtp_seq_nr = -1;
160 static int hf_rtp_ext_seq_nr = -1;
161 static int hf_rtp_timestamp = -1;
162 static int hf_rtp_ssrc = -1;
163 static int hf_rtp_csrc_items = -1;
164 static int hf_rtp_csrc_item = -1;
165 static int hf_rtp_data = -1;
166 static int hf_rtp_padding_data = -1;
167 static int hf_rtp_padding_count= -1;
168 static int hf_rtp_rfc2198_follow= -1;
169 static int hf_rtp_rfc2198_tm_off= -1;
170 static int hf_rtp_rfc2198_bl_len= -1;
172 /* RTP header extension fields */
173 static int hf_rtp_prof_define = -1;
174 static int hf_rtp_length = -1;
175 static int hf_rtp_hdr_exts = -1;
176 static int hf_rtp_hdr_ext = -1;
178 /* RTP setup fields */
179 static int hf_rtp_setup = -1;
180 static int hf_rtp_setup_frame = -1;
181 static int hf_rtp_setup_method = -1;
183 /* RTP fields defining a sub tree */
184 static gint ett_rtp = -1;
185 static gint ett_csrc_list = -1;
186 static gint ett_hdr_ext = -1;
187 static gint ett_hdr_ext_rfc5285 = -1;
188 static gint ett_rtp_setup = -1;
189 static gint ett_rtp_rfc2198 = -1;
190 static gint ett_rtp_rfc2198_hdr = -1;
193 static int hf_srtp_encrypted_payload = -1;
194 static int hf_srtp_mki = -1;
195 static int hf_srtp_auth_tag = -1;
197 /* PacketCable CCC header fields */
198 static int proto_pkt_ccc = -1;
199 static int hf_pkt_ccc_id = -1;
200 static int hf_pkt_ccc_ts = -1;
202 /* PacketCable CCC field defining a sub tree */
203 static gint ett_pkt_ccc = -1;
205 /* PacketCable CCC port preference */
206 static guint global_pkt_ccc_udp_port = 0;
208 /* RFC 5285 Header extensions */
209 static int hf_rtp_ext_rfc5285_id = -1;
210 static int hf_rtp_ext_rfc5285_length = -1;
211 static int hf_rtp_ext_rfc5285_appbits = -1;
212 static int hf_rtp_ext_rfc5285_data = -1;
214 #define RTP0_INVALID 0
215 #define RTP0_CLASSICSTUN 1
219 static enum_val_t rtp_version0_types[] = {
220 { "invalid", "Invalid or ZRTP packets", RTP0_INVALID },
221 { "classicstun", "CLASSIC-STUN packets", RTP0_CLASSICSTUN },
222 { "t38", "T.38 packets", RTP0_T38 },
223 { "sprt", "SPRT packets", RTP0_SPRT },
226 static gint global_rtp_version0_type = 0;
228 static dissector_handle_t data_handle;
230 /* Forward declaration we need below */
231 void proto_reg_handoff_rtp(void);
232 void proto_reg_handoff_pkt_ccc(void);
234 static void dissect_rtp( tvbuff_t *tvb, packet_info *pinfo,
236 static void show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
237 static void get_conv_info(packet_info *pinfo, struct _rtp_info *rtp_info);
239 /* Preferences bool to control whether or not setup info should be shown */
240 static gboolean global_rtp_show_setup_info = TRUE;
242 /* Try heuristic RTP decode */
243 static gboolean global_rtp_heur = FALSE;
245 /* desegment RTP streams */
246 static gboolean desegment_rtp = TRUE;
248 /* RFC2198 Redundant Audio Data */
249 static guint rtp_rfc2198_pt = 99;
252 * Fields in the first octet of the RTP header.
255 /* Version is the first 2 bits of the first octet*/
256 #define RTP_VERSION(octet) ((octet) >> 6)
258 /* Padding is the third bit; No need to shift, because true is any value
260 #define RTP_PADDING(octet) ((octet) & 0x20)
262 /* Extension bit is the fourth bit */
263 #define RTP_EXTENSION(octet) ((octet) & 0x10)
265 /* CSRC count is the last four bits */
266 #define RTP_CSRC_COUNT(octet) ((octet) & 0xF)
268 static const value_string rtp_version_vals[] =
270 { 2, "RFC 1889 Version" }, /* First for speed */
271 { 0, "Old VAT Version" },
272 { 1, "First Draft Version" },
277 * Fields in the second octet of the RTP header.
280 /* Marker is the first bit of the second octet */
281 #define RTP_MARKER(octet) ((octet) & 0x80)
283 /* Payload type is the last 7 bits */
284 #define RTP_PAYLOAD_TYPE(octet) ((octet) & 0x7F)
285 /* http://www.iana.org/assignments/rtp-parameters */
287 static const value_string rtp_payload_type_vals[] =
289 /* 0 */ { PT_PCMU, "ITU-T G.711 PCMU" },
290 /* 1 */ { PT_1016, "USA Federal Standard FS-1016" },
291 /* 2 */ { PT_G721, "ITU-T G.721" },
292 /* 3 */ { PT_GSM, "GSM 06.10" },
293 /* 4 */ { PT_G723, "ITU-T G.723" },
294 /* 5 */ { PT_DVI4_8000, "DVI4 8000 samples/s" },
295 /* 6 */ { PT_DVI4_16000, "DVI4 16000 samples/s" },
296 /* 7 */ { PT_LPC, "Experimental linear predictive encoding from Xerox PARC" },
297 /* 8 */ { PT_PCMA, "ITU-T G.711 PCMA" },
298 /* 9 */ { PT_G722, "ITU-T G.722" },
299 /* 10 */ { PT_L16_STEREO, "16-bit uncompressed audio, stereo" },
300 /* 11 */ { PT_L16_MONO, "16-bit uncompressed audio, monaural" },
301 /* 12 */ { PT_QCELP, "Qualcomm Code Excited Linear Predictive coding" },
302 /* 13 */ { PT_CN, "Comfort noise" },
303 /* 14 */ { PT_MPA, "MPEG-I/II Audio"},
304 /* 15 */ { PT_G728, "ITU-T G.728" },
305 /* 16 */ { PT_DVI4_11025, "DVI4 11025 samples/s" },
306 /* 17 */ { PT_DVI4_22050, "DVI4 22050 samples/s" },
307 /* 18 */ { PT_G729, "ITU-T G.729" },
308 /* 19 */ { PT_CN_OLD, "Comfort noise (old)" },
309 /* 20 */ { 20, "Unassigned" },
310 /* 21 */ { 21, "Unassigned" },
311 /* 22 */ { 22, "Unassigned" },
312 /* 23 */ { 23, "Unassigned" },
313 /* 24 */ { 24, "Unassigned" },
314 /* 25 */ { PT_CELB, "Sun CellB video encoding" },
315 /* 26 */ { PT_JPEG, "JPEG-compressed video" },
316 /* 27 */ { 27, "Unassigned" },
317 /* 28 */ { PT_NV, "'nv' program" },
318 /* 29 */ { 29, "Unassigned" },
319 /* 30 */ { 30, "Unassigned" },
320 /* 31 */ { PT_H261, "ITU-T H.261" },
321 /* 32 */ { PT_MPV, "MPEG-I/II Video"},
322 /* 33 */ { PT_MP2T, "MPEG-II transport streams"},
323 /* 34 */ { PT_H263, "ITU-T H.263" },
324 /* 35-71 Unassigned */
325 /* 35 */ { 35, "Unassigned" },
326 /* 36 */ { 36, "Unassigned" },
327 /* 37 */ { 37, "Unassigned" },
328 /* 38 */ { 38, "Unassigned" },
329 /* 39 */ { 39, "Unassigned" },
330 /* 40 */ { 40, "Unassigned" },
331 /* 41 */ { 41, "Unassigned" },
332 /* 42 */ { 42, "Unassigned" },
333 /* 43 */ { 43, "Unassigned" },
334 /* 44 */ { 44, "Unassigned" },
335 /* 45 */ { 45, "Unassigned" },
336 /* 46 */ { 46, "Unassigned" },
337 /* 47 */ { 47, "Unassigned" },
338 /* 48 */ { 48, "Unassigned" },
339 /* 49 */ { 49, "Unassigned" },
340 /* 50 */ { 50, "Unassigned" },
341 /* 51 */ { 51, "Unassigned" },
342 /* 52 */ { 52, "Unassigned" },
343 /* 53 */ { 53, "Unassigned" },
344 /* 54 */ { 54, "Unassigned" },
345 /* 55 */ { 55, "Unassigned" },
346 /* 56 */ { 56, "Unassigned" },
347 /* 57 */ { 57, "Unassigned" },
348 /* 58 */ { 58, "Unassigned" },
349 /* 59 */ { 59, "Unassigned" },
350 /* 60 */ { 60, "Unassigned" },
351 /* 61 */ { 61, "Unassigned" },
352 /* 62 */ { 62, "Unassigned" },
353 /* 63 */ { 63, "Unassigned" },
354 /* 64 */ { 64, "Unassigned" },
355 /* 65 */ { 65, "Unassigned" },
356 /* 66 */ { 66, "Unassigned" },
357 /* 67 */ { 67, "Unassigned" },
358 /* 68 */ { 68, "Unassigned" },
359 /* 69 */ { 69, "Unassigned" },
360 /* 70 */ { 70, "Unassigned" },
361 /* 71 */ { 71, "Unassigned" },
362 /* 72-76 Reserved for RTCP conflict avoidance [RFC3551] */
363 /* 72 */ { 72, "Reserved for RTCP conflict avoidance" },
364 /* 73 */ { 73, "Reserved for RTCP conflict avoidance" },
365 /* 74 */ { 74, "Reserved for RTCP conflict avoidance" },
366 /* 75 */ { 75, "Reserved for RTCP conflict avoidance" },
367 /* 76 */ { 76, "Reserved for RTCP conflict avoidance" },
368 /* 77-95 Unassigned ? */
369 /* 77 */ { 77, "Unassigned" },
370 /* 78 */ { 78, "Unassigned" },
371 /* 79 */ { 79, "Unassigned" },
372 /* 80 */ { 80, "Unassigned" },
373 /* 81 */ { 81, "Unassigned" },
374 /* 82 */ { 82, "Unassigned" },
375 /* 83 */ { 83, "Unassigned" },
376 /* 84 */ { 84, "Unassigned" },
377 /* 85 */ { 85, "Unassigned" },
378 /* 86 */ { 86, "Unassigned" },
379 /* 87 */ { 87, "Unassigned" },
380 /* 88 */ { 88, "Unassigned" },
381 /* 89 */ { 89, "Unassigned" },
382 /* 90 */ { 90, "Unassigned" },
383 /* 91 */ { 91, "Unassigned" },
384 /* 92 */ { 92, "Unassigned" },
385 /* 93 */ { 93, "Unassigned" },
386 /* 94 */ { 94, "Unassigned" },
387 /* 95 */ { 95, "Unassigned" },
388 /* Added to support addtional RTP payload types
389 * See epan/rtp_pt.h */
390 { PT_UNDF_96, "DynamicRTP-Type-96" },
391 { PT_UNDF_97, "DynamicRTP-Type-97" },
392 { PT_UNDF_98, "DynamicRTP-Type-98" },
393 { PT_UNDF_99, "DynamicRTP-Type-99" },
394 { PT_UNDF_100, "DynamicRTP-Type-100" },
395 { PT_UNDF_101, "DynamicRTP-Type-101" },
396 { PT_UNDF_102, "DynamicRTP-Type-102" },
397 { PT_UNDF_103, "DynamicRTP-Type-103" },
398 { PT_UNDF_104, "DynamicRTP-Type-104" },
399 { PT_UNDF_105, "DynamicRTP-Type-105" },
400 { PT_UNDF_106, "DynamicRTP-Type-106" },
401 { PT_UNDF_107, "DynamicRTP-Type-107" },
402 { PT_UNDF_108, "DynamicRTP-Type-108" },
403 { PT_UNDF_109, "DynamicRTP-Type-109" },
404 { PT_UNDF_110, "DynamicRTP-Type-110" },
405 { PT_UNDF_111, "DynamicRTP-Type-111" },
406 { PT_UNDF_112, "DynamicRTP-Type-112" },
407 { PT_UNDF_113, "DynamicRTP-Type-113" },
408 { PT_UNDF_114, "DynamicRTP-Type-114" },
409 { PT_UNDF_115, "DynamicRTP-Type-115" },
410 { PT_UNDF_116, "DynamicRTP-Type-116" },
411 { PT_UNDF_117, "DynamicRTP-Type-117" },
412 { PT_UNDF_118, "DynamicRTP-Type-118" },
413 { PT_UNDF_119, "DynamicRTP-Type-119" },
414 { PT_UNDF_120, "DynamicRTP-Type-120" },
415 { PT_UNDF_121, "DynamicRTP-Type-121" },
416 { PT_UNDF_122, "DynamicRTP-Type-122" },
417 { PT_UNDF_123, "DynamicRTP-Type-123" },
418 { PT_UNDF_124, "DynamicRTP-Type-124" },
419 { PT_UNDF_125, "DynamicRTP-Type-125" },
420 { PT_UNDF_126, "DynamicRTP-Type-126" },
421 { PT_UNDF_127, "DynamicRTP-Type-127" },
426 value_string_ext rtp_payload_type_vals_ext = VALUE_STRING_EXT_INIT(rtp_payload_type_vals);
428 static const value_string rtp_payload_type_short_vals[] =
430 { PT_PCMU, "g711U" },
431 { PT_1016, "fs-1016" },
435 { PT_DVI4_8000, "DVI4 8k" },
436 { PT_DVI4_16000, "DVI4 16k" },
437 { PT_LPC, "Exp. from Xerox PARC" },
438 { PT_PCMA, "g711A" },
440 { PT_L16_STEREO, "16-bit audio, stereo" },
441 { PT_L16_MONO, "16-bit audio, monaural" },
442 { PT_QCELP, "Qualcomm" },
444 { PT_MPA, "MPEG-I/II Audio"},
446 { PT_DVI4_11025, "DVI4 11k" },
447 { PT_DVI4_22050, "DVI4 22k" },
449 { PT_CN_OLD, "CN(old)" },
450 { 20, "Unassigned" },
451 { 21, "Unassigned" },
452 { 22, "Unassigned" },
453 { 23, "Unassigned" },
454 { 24, "Unassigned" },
455 { PT_CELB, "CellB" },
457 { 27, "Unassigned" },
459 { 29, "Unassigned" },
460 { 30, "Unassigned" },
462 { PT_MPV, "MPEG-I/II Video"},
463 { PT_MP2T, "MPEG-II streams"},
465 /* 35-71 Unassigned */
466 { 35, "Unassigned" },
467 { 36, "Unassigned" },
468 { 37, "Unassigned" },
469 { 38, "Unassigned" },
470 { 39, "Unassigned" },
471 { 40, "Unassigned" },
472 { 41, "Unassigned" },
473 { 42, "Unassigned" },
474 { 43, "Unassigned" },
475 { 44, "Unassigned" },
476 { 45, "Unassigned" },
477 { 46, "Unassigned" },
478 { 47, "Unassigned" },
479 { 48, "Unassigned" },
480 { 49, "Unassigned" },
481 { 50, "Unassigned" },
482 { 51, "Unassigned" },
483 { 52, "Unassigned" },
484 { 53, "Unassigned" },
485 { 54, "Unassigned" },
486 { 55, "Unassigned" },
487 { 56, "Unassigned" },
488 { 57, "Unassigned" },
489 { 58, "Unassigned" },
490 { 59, "Unassigned" },
491 { 60, "Unassigned" },
492 { 61, "Unassigned" },
493 { 62, "Unassigned" },
494 { 63, "Unassigned" },
495 { 64, "Unassigned" },
496 { 65, "Unassigned" },
497 { 66, "Unassigned" },
498 { 67, "Unassigned" },
499 { 68, "Unassigned" },
500 { 69, "Unassigned" },
501 { 70, "Unassigned" },
502 { 71, "Unassigned" },
503 /* 72-76 Reserved for RTCP conflict avoidance - [RFC3551] */
504 { 72, "Reserved for RTCP conflict avoidance" },
505 { 73, "Reserved for RTCP conflict avoidance" },
506 { 74, "Reserved for RTCP conflict avoidance" },
507 { 75, "Reserved for RTCP conflict avoidance" },
508 { 76, "Reserved for RTCP conflict avoidance" },
509 /* 77-95 Unassigned ? */
510 { 77, "Unassigned" },
511 { 78, "Unassigned" },
512 { 79, "Unassigned" },
513 { 80, "Unassigned" },
514 { 81, "Unassigned" },
515 { 82, "Unassigned" },
516 { 83, "Unassigned" },
517 { 84, "Unassigned" },
518 { 85, "Unassigned" },
519 { 86, "Unassigned" },
520 { 87, "Unassigned" },
521 { 88, "Unassigned" },
522 { 89, "Unassigned" },
523 { 90, "Unassigned" },
524 { 91, "Unassigned" },
525 { 92, "Unassigned" },
526 { 93, "Unassigned" },
527 { 94, "Unassigned" },
528 { 95, "Unassigned" },
529 /* Short RTP types */
530 { PT_UNDF_96, "RTPType-96" },
531 { PT_UNDF_97, "RTPType-97" },
532 { PT_UNDF_98, "RTPType-98" },
533 { PT_UNDF_99, "RTPType-99" },
534 { PT_UNDF_100, "RTPType-100" },
535 { PT_UNDF_101, "RTPType-101" },
536 { PT_UNDF_102, "RTPType-102" },
537 { PT_UNDF_103, "RTPType-103" },
538 { PT_UNDF_104, "RTPType-104" },
539 { PT_UNDF_105, "RTPType-105" },
540 { PT_UNDF_106, "RTPType-106" },
541 { PT_UNDF_107, "RTPType-107" },
542 { PT_UNDF_108, "RTPType-108" },
543 { PT_UNDF_109, "RTPType-109" },
544 { PT_UNDF_110, "RTPType-110" },
545 { PT_UNDF_111, "RTPType-111" },
546 { PT_UNDF_112, "RTPType-112" },
547 { PT_UNDF_113, "RTPType-113" },
548 { PT_UNDF_114, "RTPType-114" },
549 { PT_UNDF_115, "RTPType-115" },
550 { PT_UNDF_116, "RTPType-116" },
551 { PT_UNDF_117, "RTPType-117" },
552 { PT_UNDF_118, "RTPType-118" },
553 { PT_UNDF_119, "RTPType-119" },
554 { PT_UNDF_120, "RTPType-120" },
555 { PT_UNDF_121, "RTPType-121" },
556 { PT_UNDF_122, "RTPType-122" },
557 { PT_UNDF_123, "RTPType-123" },
558 { PT_UNDF_124, "RTPType-124" },
559 { PT_UNDF_125, "RTPType-125" },
560 { PT_UNDF_126, "RTPType-126" },
561 { PT_UNDF_127, "RTPType-127" },
565 value_string_ext rtp_payload_type_short_vals_ext = VALUE_STRING_EXT_INIT(rtp_payload_type_short_vals);
568 static const value_string srtp_encryption_alg_vals[] =
570 { SRTP_ENC_ALG_NULL, "Null Encryption" },
571 { SRTP_ENC_ALG_AES_CM, "AES-128 Counter Mode" },
572 { SRTP_ENC_ALG_AES_F8, "AES-128 F8 Mode" },
576 static const value_string srtp_auth_alg_vals[] =
578 { SRTP_AUTH_ALG_NONE, "No Authentication" },
579 { SRTP_AUTH_ALG_HMAC_SHA1, "HMAC-SHA1" },
584 /* initialisation routine */
586 rtp_fragment_init(void)
588 fragment_table_init(&fragment_table);
592 rtp_free_hash_dyn_payload(GHashTable *rtp_dyn_payload)
594 if (rtp_dyn_payload == NULL) return;
595 g_hash_table_destroy(rtp_dyn_payload);
596 rtp_dyn_payload = NULL;
599 /* Set up an SRTP conversation */
601 srtp_add_address(packet_info *pinfo, address *addr, int port, int other_port,
602 const gchar *setup_method, guint32 setup_frame_number,
603 gboolean is_video _U_, GHashTable *rtp_dyn_payload,
604 struct srtp_info *srtp_info)
607 conversation_t* p_conv;
608 struct _rtp_conversation_info *p_conv_data = NULL;
611 * If this isn't the first time this packet has been processed,
612 * we've already done this work, so we don't need to do it
615 if (pinfo->fd->flags.visited)
621 printf("#%u: %srtp_add_address(%s, %u, %u, %s, %u\n",
622 pinfo->fd->num, (srtp_info)?"s":"", ep_address_to_str(addr), port,
623 other_port, setup_method, setup_frame_number);
626 SET_ADDRESS(&null_addr, AT_NONE, 0, NULL);
629 * Check if the ip address and port combination is not
630 * already registered as a conversation.
632 p_conv = find_conversation(setup_frame_number, addr, &null_addr, PT_UDP, port, other_port,
633 NO_ADDR_B | (!other_port ? NO_PORT_B : 0));
636 * If not, create a new conversation.
638 if (!p_conv || p_conv->setup_frame != setup_frame_number) {
639 p_conv = conversation_new(setup_frame_number, addr, &null_addr, PT_UDP,
640 (guint32)port, (guint32)other_port,
641 NO_ADDR2 | (!other_port ? NO_PORT2 : 0));
645 conversation_set_dissector(p_conv, rtp_handle);
648 * Check if the conversation has data associated with it.
650 p_conv_data = conversation_get_proto_data(p_conv, proto_rtp);
653 * If not, add a new data item.
656 /* Create conversation data */
657 p_conv_data = se_alloc(sizeof(struct _rtp_conversation_info));
658 p_conv_data->rtp_dyn_payload = NULL;
660 /* start this at 0x10000 so that we cope gracefully with the
661 * first few packets being out of order (hence 0,65535,1,2,...)
663 p_conv_data->extended_seqno = 0x10000;
664 p_conv_data->rtp_conv_info = se_alloc(sizeof(rtp_private_conv_info));
665 p_conv_data->rtp_conv_info->multisegment_pdus = se_tree_create(EMEM_TREE_TYPE_RED_BLACK,"rtp_ms_pdus");
666 conversation_add_proto_data(p_conv, proto_rtp, p_conv_data);
670 * Update the conversation data.
672 /* Free the hash if already exists */
673 rtp_free_hash_dyn_payload(p_conv_data->rtp_dyn_payload);
675 g_strlcpy(p_conv_data->method, setup_method, MAX_RTP_SETUP_METHOD_SIZE+1);
676 p_conv_data->frame_number = setup_frame_number;
677 p_conv_data->is_video = is_video;
678 p_conv_data->rtp_dyn_payload = rtp_dyn_payload;
679 p_conv_data->srtp_info = srtp_info;
682 /* Set up an RTP conversation */
684 rtp_add_address(packet_info *pinfo, address *addr, int port, int other_port,
685 const gchar *setup_method, guint32 setup_frame_number,
686 gboolean is_video , GHashTable *rtp_dyn_payload)
688 srtp_add_address(pinfo, addr, port, other_port, setup_method, setup_frame_number, is_video, rtp_dyn_payload, NULL);
692 dissect_rtp_heur_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean check_destport)
695 unsigned int version;
696 unsigned int offset = 0;
698 /* This is a heuristic dissector, which means we get all the UDP
699 * traffic not sent to a known dissector and not claimed by
700 * a heuristic dissector called before us!
703 if (! global_rtp_heur)
706 /* Get the fields in the first octet */
707 octet1 = tvb_get_guint8( tvb, offset );
708 version = RTP_VERSION( octet1 );
711 if (!(tvb_memeql(tvb, 4, "ZRTP", 4)))
713 call_dissector_only(zrtp_handle, tvb, pinfo, tree);
716 switch (global_rtp_version0_type) {
717 case RTP0_CLASSICSTUN:
718 return call_dissector_only(classicstun_heur_handle, tvb, pinfo, tree);
721 /* XXX: Should really be calling a heuristic dissector for T38 ??? */
722 call_dissector_only(t38_handle, tvb, pinfo, tree);
726 call_dissector_only(sprt_handle, tvb, pinfo, tree);
732 return FALSE; /* Unknown or unsupported version */
735 } else if (version != 2) {
736 /* Unknown or unsupported version */
740 /* Was it sent to an even-numbered port? */
741 if (check_destport && ((pinfo->destport % 2) != 0)) {
745 dissect_rtp( tvb, pinfo, tree );
750 dissect_rtp_heur_udp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
752 return dissect_rtp_heur_common(tvb, pinfo, tree, TRUE);
756 dissect_rtp_heur_stun( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
758 return dissect_rtp_heur_common(tvb, pinfo, tree, FALSE);
762 * Process the payload of the RTP packet, hand it to the subdissector
765 process_rtp_payload(tvbuff_t *newtvb, packet_info *pinfo, proto_tree *tree,
766 proto_tree *rtp_tree,
767 unsigned int payload_type)
769 struct _rtp_conversation_info *p_conv_data = NULL;
770 gboolean found_match = FALSE;
772 struct srtp_info *srtp_info;
775 payload_len = tvb_length_remaining(newtvb, offset);
777 /* first check if this is added as an SRTP stream - if so, don't try to dissector the payload data for now */
778 p_conv_data = p_get_proto_data(pinfo->fd, proto_rtp);
779 if (p_conv_data && p_conv_data->srtp_info) {
780 srtp_info = p_conv_data->srtp_info;
781 payload_len -= srtp_info->mki_len + srtp_info->auth_tag_len;
783 #error Currently the srtp_info structure contains no cipher data, see packet-sdp.c adding dummy_srtp_info structure
784 if (p_conv_data->srtp_info->encryption_algorithm==SRTP_ENC_ALG_NULL) {
786 proto_tree_add_text(rtp_tree, newtvb, offset, payload_len, "SRTP Payload with NULL encryption");
792 proto_tree_add_item(rtp_tree, hf_srtp_encrypted_payload, newtvb, offset, payload_len, ENC_NA);
793 found_match = TRUE; /* use this flag to prevent dissection below */
795 offset += payload_len;
797 if (srtp_info->mki_len) {
798 proto_tree_add_item(rtp_tree, hf_srtp_mki, newtvb, offset, srtp_info->mki_len, ENC_NA);
799 offset += srtp_info->mki_len;
802 if (srtp_info->auth_tag_len) {
803 proto_tree_add_item(rtp_tree, hf_srtp_auth_tag, newtvb, offset, srtp_info->auth_tag_len, ENC_NA);
804 offset += srtp_info->auth_tag_len;
808 /* if the payload type is dynamic, we check if the conv is set and we look for the pt definition */
809 else if ( (payload_type >= PT_UNDF_96 && payload_type <= PT_UNDF_127) ) {
810 if (p_conv_data && p_conv_data->rtp_dyn_payload) {
811 gchar *payload_type_str = NULL;
812 encoding_name_and_rate_t *encoding_name_and_rate_pt = NULL;
813 encoding_name_and_rate_pt = g_hash_table_lookup(p_conv_data->rtp_dyn_payload, &payload_type);
814 if (encoding_name_and_rate_pt) {
815 payload_type_str = encoding_name_and_rate_pt->encoding_name;
817 if (payload_type_str){
818 found_match = dissector_try_string(rtp_dyn_pt_dissector_table,
819 payload_type_str, newtvb, pinfo, tree);
820 /* If payload type string set from conversation and
821 * no matching dissector found it's probably because no subdissector
822 * exists. Don't call the dissectors based on payload number
823 * as that'd probably be the wrong dissector in this case.
824 * Just add it as data.
826 if(found_match==FALSE)
827 proto_tree_add_item( rtp_tree, hf_rtp_data, newtvb, 0, -1, ENC_NA );
834 /* if we don't found, it is static OR could be set static from the preferences */
835 if (!found_match && !dissector_try_uint(rtp_pt_dissector_table, payload_type, newtvb, pinfo, tree))
836 proto_tree_add_item( rtp_tree, hf_rtp_data, newtvb, 0, -1, ENC_NA );
840 /* Rtp payload reassembly
842 * This handles the reassembly of PDUs for higher-level protocols.
844 * We're a bit limited on how we can cope with out-of-order packets, because
845 * we don't have any idea of where the datagram boundaries are. So if we see
846 * packets A, C, B (all of which comprise a single datagram), we cannot know
847 * that C should be added to the same datagram as A, until we come to B (which
848 * may or may not actually be present...).
850 * What we end up doing in this case is passing A+B to the subdissector as one
851 * datagram, and make out that a new one starts on C.
854 dissect_rtp_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
855 proto_tree *rtp_tree, int offset, unsigned int data_len,
856 unsigned int data_reported_len,
857 unsigned int payload_type)
860 struct _rtp_conversation_info *p_conv_data= NULL;
861 gboolean must_desegment = FALSE;
862 rtp_private_conv_info *finfo = NULL;
863 rtp_multisegment_pdu *msp = NULL;
866 /* Retrieve RTPs idea of a converation */
867 p_conv_data = p_get_proto_data(pinfo->fd, proto_rtp);
869 if(p_conv_data != NULL)
870 finfo = p_conv_data->rtp_conv_info;
872 if(finfo == NULL || !desegment_rtp) {
873 /* Hand the whole lot off to the subdissector */
874 newtvb=tvb_new_subset(tvb,offset,data_len,data_reported_len);
875 process_rtp_payload(newtvb, pinfo, tree, rtp_tree, payload_type);
879 seqno = p_conv_data->extended_seqno;
881 pinfo->can_desegment = 2;
882 pinfo->desegment_offset = 0;
883 pinfo->desegment_len = 0;
885 #ifdef DEBUG_FRAGMENTS
886 g_debug("%d: RTP Part of convo %d(%p); seqno %d",
888 p_conv_data->frame_number, p_conv_data,
893 /* look for a pdu which we might be extending */
894 msp = (rtp_multisegment_pdu *)se_tree_lookup32_le(finfo->multisegment_pdus,seqno-1);
896 if(msp && msp->startseq < seqno && msp->endseq >= seqno) {
897 guint32 fid = msp->startseq;
898 fragment_data *fd_head;
900 #ifdef DEBUG_FRAGMENTS
901 g_debug("\tContinues fragment %d", fid);
904 /* we always assume the datagram is complete; if this is the
905 * first pass, that's our best guess, and if it's not, what we
906 * say gets ignored anyway.
908 fd_head = fragment_add_seq(tvb, offset, pinfo, fid, fragment_table,
909 seqno-msp->startseq, data_len, FALSE);
911 newtvb = process_reassembled_data(tvb,offset, pinfo, "Reassembled RTP", fd_head,
912 &rtp_fragment_items, NULL, tree);
914 #ifdef DEBUG_FRAGMENTS
915 g_debug("\tFragment Coalesced; fd_head=%p, newtvb=%p (len %d)",fd_head, newtvb,
916 newtvb?tvb_reported_length(newtvb):0);
920 /* Hand off to the subdissector */
921 process_rtp_payload(newtvb, pinfo, tree, rtp_tree, payload_type);
924 * Check to see if there were any complete fragments within the chunk
926 if( pinfo->desegment_len && pinfo->desegment_offset == 0 )
928 #ifdef DEBUG_FRAGMENTS
929 g_debug("\tNo complete pdus in payload" );
931 /* Mark the fragments and not complete yet */
932 fragment_set_partial_reassembly(pinfo, fid, fragment_table);
934 /* we must need another segment */
935 msp->endseq = MIN(msp->endseq,seqno) + 1;
939 if(pinfo->desegment_len)
941 /* the higher-level dissector has asked for some more data - ie,
942 the end of this segment does not coincide with the end of a
944 must_desegment = TRUE;
954 * The segment is not the continuation of a fragmented segment
955 * so process it as normal
957 #ifdef DEBUG_FRAGMENTS
958 g_debug("\tRTP non-fragment payload");
960 newtvb = tvb_new_subset( tvb, offset, data_len, data_reported_len );
962 /* Hand off to the subdissector */
963 process_rtp_payload(newtvb, pinfo, tree, rtp_tree, payload_type);
965 if(pinfo->desegment_len) {
966 /* the higher-level dissector has asked for some more data - ie,
967 the end of this segment does not coincide with the end of a
969 must_desegment = TRUE;
974 * There were bytes left over that the higher protocol couldn't dissect so save them
978 guint32 deseg_offset = pinfo->desegment_offset;
979 guint32 frag_len = tvb_reported_length_remaining(newtvb, deseg_offset);
980 fragment_data *fd_head = NULL;
982 #ifdef DEBUG_FRAGMENTS
983 g_debug("\tRTP Must Desegment: tvb_len=%d ds_len=%d %d frag_len=%d ds_off=%d",
984 tvb_reported_length(newtvb),
985 pinfo->desegment_len,
986 pinfo->fd->flags.visited,
990 /* allocate a new msp for this pdu */
991 msp = se_alloc(sizeof(rtp_multisegment_pdu));
992 msp->startseq = seqno;
993 msp->endseq = seqno+1;
994 se_tree_insert32(finfo->multisegment_pdus,seqno,msp);
997 * Add the fragment to the fragment table
999 fd_head = fragment_add_seq(newtvb,deseg_offset, pinfo, seqno, fragment_table, 0, frag_len,
1004 if( fd_head->reassembled_in != 0 && !(fd_head->flags & FD_PARTIAL_REASSEMBLY) )
1006 proto_item *rtp_tree_item;
1007 rtp_tree_item = proto_tree_add_uint( tree, hf_rtp_reassembled_in,
1008 newtvb, deseg_offset, tvb_reported_length_remaining(newtvb,deseg_offset),
1009 fd_head->reassembled_in);
1010 PROTO_ITEM_SET_GENERATED(rtp_tree_item);
1011 #ifdef DEBUG_FRAGMENTS
1012 g_debug("\tReassembled in %d", fd_head->reassembled_in);
1017 #ifdef DEBUG_FRAGMENTS
1018 g_debug("\tUnfinished fragment");
1020 /* this fragment is never reassembled */
1021 proto_tree_add_text( tree, tvb, deseg_offset, -1,"RTP fragment, unfinished");
1027 * This fragment was the first fragment in a new entry in the
1028 * frag_table; we don't yet know where it is reassembled
1030 #ifdef DEBUG_FRAGMENTS
1031 g_debug("\tnew pdu");
1035 if( pinfo->desegment_offset == 0 )
1037 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP");
1038 col_set_str(pinfo->cinfo, COL_INFO, "[RTP segment of a reassembled PDU]");
1042 pinfo->can_desegment = 0;
1043 pinfo->desegment_offset = 0;
1044 pinfo->desegment_len = 0;
1050 dissect_rtp_rfc2198(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1055 gboolean hdr_follow = TRUE;
1056 proto_item *ti = NULL;
1057 proto_tree *rfc2198_tree = NULL;
1058 proto_tree *rfc2198_hdr_tree = NULL;
1059 rfc2198_hdr *hdr_last, *hdr_new;
1060 rfc2198_hdr *hdr_chain = NULL;
1061 struct _rtp_conversation_info *p_conv_data= NULL;
1062 gchar *payload_type_str;
1064 /* Retrieve RTPs idea of a converation */
1065 p_conv_data = p_get_proto_data(pinfo->fd, proto_rtp);
1067 /* Add try to RFC 2198 data */
1068 ti = proto_tree_add_text(tree, tvb, offset, -1, "RFC 2198: Redundant Audio Data");
1069 rfc2198_tree = proto_item_add_subtree(ti, ett_rtp_rfc2198);
1073 while (hdr_follow) {
1075 payload_type_str = NULL;
1077 /* Allocate and fill in header */
1078 hdr_new = ep_alloc(sizeof(rfc2198_hdr));
1079 hdr_new->next = NULL;
1080 octet1 = tvb_get_guint8(tvb, offset);
1081 hdr_new->pt = RTP_PAYLOAD_TYPE(octet1);
1082 hdr_follow = (octet1 & 0x80);
1084 /* if it is dynamic payload, let use the conv data to see if it is defined */
1085 if ((hdr_new->pt > 95) && (hdr_new->pt < 128)) {
1086 if (p_conv_data && p_conv_data->rtp_dyn_payload){
1087 encoding_name_and_rate_t *encoding_name_and_rate_pt = NULL;
1088 encoding_name_and_rate_pt = g_hash_table_lookup(p_conv_data->rtp_dyn_payload, &hdr_new->pt);
1089 if (encoding_name_and_rate_pt) {
1090 payload_type_str = encoding_name_and_rate_pt->encoding_name;
1094 /* Add a subtree for this header and add items */
1095 ti = proto_tree_add_text(rfc2198_tree, tvb, offset, (hdr_follow)?4:1, "Header %u", cnt);
1096 rfc2198_hdr_tree = proto_item_add_subtree(ti, ett_rtp_rfc2198_hdr);
1097 proto_tree_add_item(rfc2198_hdr_tree, hf_rtp_rfc2198_follow, tvb, offset, 1, ENC_BIG_ENDIAN );
1098 proto_tree_add_uint_format(rfc2198_hdr_tree, hf_rtp_payload_type, tvb,
1099 offset, 1, octet1, "Payload type: %s (%u)",
1100 payload_type_str ? payload_type_str : val_to_str_ext_const(hdr_new->pt, &rtp_payload_type_vals_ext, "Unknown"),
1102 proto_item_append_text(ti, ": PT=%s",
1103 payload_type_str ? payload_type_str :
1104 val_to_str_ext(hdr_new->pt, &rtp_payload_type_vals_ext, "Unknown (%u)"));
1107 /* Timestamp offset and block length don't apply to last header */
1109 proto_tree_add_item(rfc2198_hdr_tree, hf_rtp_rfc2198_tm_off, tvb, offset, 2, ENC_BIG_ENDIAN );
1110 proto_tree_add_item(rfc2198_hdr_tree, hf_rtp_rfc2198_bl_len, tvb, offset + 1, 2, ENC_BIG_ENDIAN );
1111 hdr_new->len = tvb_get_ntohs(tvb, offset + 1) & 0x03FF;
1112 proto_item_append_text(ti, ", len=%u", hdr_new->len);
1120 hdr_last->next = hdr_new;
1122 hdr_chain = hdr_new;
1127 /* Dissect each data block according to the header info */
1128 hdr_last = hdr_chain;
1130 hdr_last->offset = offset;
1131 if (!hdr_last->next) {
1132 hdr_last->len = tvb_reported_length_remaining(tvb, offset);
1134 dissect_rtp_data(tvb, pinfo, tree, rfc2198_tree, hdr_last->offset, hdr_last->len, hdr_last->len, hdr_last->pt);
1135 offset += hdr_last->len;
1136 hdr_last = hdr_last->next;
1141 dissect_rtp_hext_rfc5215_onebyte( tvbuff_t *tvb, packet_info *pinfo,
1142 proto_tree *rtp_hext_tree )
1144 proto_item *ti = NULL;
1145 proto_tree *rtp_hext_rfc5285_tree = NULL;
1146 guint ext_offset = 0, start_ext_offset;
1148 while (ext_offset < tvb_length (tvb)) {
1152 tvbuff_t *subtvb = NULL;
1154 /* Skip bytes with the value 0, they are padding */
1155 start_ext_offset = ext_offset;
1156 while (tvb_get_guint8 (tvb, ext_offset) == 0) {
1157 if (ext_offset >= tvb_length (tvb))
1163 if (ext_offset > start_ext_offset)
1164 proto_tree_add_item(rtp_hext_tree, hf_rtp_padding_data, tvb, ext_offset, ext_offset-start_ext_offset, ENC_NA );
1166 ext_hdr_hdr = tvb_get_guint8 (tvb, ext_offset);
1167 ext_id = ext_hdr_hdr >> 4;
1169 /* 15 is for future extensibility, ignore length, etc and stop processing packet if it shows up */
1173 ext_length = (ext_hdr_hdr & 0x0F) + 1;
1174 if (rtp_hext_tree) {
1175 ti = proto_tree_add_text(rtp_hext_tree, tvb, ext_offset, ext_length + 1, "RFC 5285 Header Extension (One-Byte Header)");
1176 rtp_hext_rfc5285_tree = proto_item_add_subtree( ti, ett_hdr_ext_rfc5285);
1178 proto_tree_add_uint( rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_id, tvb, ext_offset, 1, ext_id);
1179 proto_tree_add_uint( rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_length, tvb, ext_offset, 1, ext_length);
1183 subtvb = tvb_new_subset(tvb, ext_offset, ext_length, ext_length);
1184 if (!dissector_try_uint (rtp_hdr_ext_rfc5285_dissector_table, ext_id, subtvb, pinfo, rtp_hext_rfc5285_tree)) {
1186 proto_tree_add_item(rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_data, subtvb, 0, ext_length, ENC_NA );
1189 ext_offset += ext_length;
1195 dissect_rtp_hext_rfc5215_twobytes(tvbuff_t *parent_tvb, guint id_offset,
1196 guint8 id, tvbuff_t *tvb, packet_info *pinfo, proto_tree *rtp_hext_tree)
1198 proto_item *ti = NULL;
1199 proto_tree *rtp_hext_rfc5285_tree = NULL;
1200 guint ext_offset = 0, start_ext_offset;
1202 while (ext_offset + 2 < tvb_length (tvb)) {
1205 tvbuff_t *subtvb = NULL;
1207 /* Skip bytes with the value 0, they are padding */
1208 start_ext_offset = ext_offset;
1209 while (tvb_get_guint8 (tvb, ext_offset) == 0) {
1210 if (ext_offset + 2 >= tvb_length (tvb))
1215 if (ext_offset > start_ext_offset)
1216 proto_tree_add_item(rtp_hext_tree, hf_rtp_padding_data, tvb, ext_offset, ext_offset-start_ext_offset, ENC_NA );
1218 ext_id = tvb_get_guint8 (tvb, ext_offset);
1219 ext_length = tvb_get_guint8 (tvb, ext_offset + 1);
1221 if (rtp_hext_tree) {
1222 ti = proto_tree_add_text(rtp_hext_tree, tvb, ext_offset, ext_length + 2, "RFC 5285 Header Extension (Two-Byte Header)");
1223 rtp_hext_rfc5285_tree = proto_item_add_subtree( ti, ett_hdr_ext_rfc5285);
1225 proto_tree_add_uint( rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_appbits, parent_tvb, id_offset + 1, 1, id & 0x000F);
1226 proto_tree_add_uint( rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_id, tvb, ext_offset, 1, ext_id);
1227 proto_tree_add_uint( rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_length, tvb, ext_offset + 1, 1, ext_length);
1232 subtvb = tvb_new_subset(tvb, ext_offset, ext_length, ext_length);
1233 if (ext_length && !dissector_try_uint (rtp_hdr_ext_rfc5285_dissector_table, ext_id, subtvb, pinfo, rtp_hext_rfc5285_tree)) {
1234 proto_tree_add_item(rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_data, subtvb, 0, ext_length, ENC_NA );
1237 ext_offset += ext_length;
1242 dissect_rtp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
1244 proto_item *ti = NULL;
1245 proto_tree *rtp_tree = NULL;
1246 proto_tree *rtp_csrc_tree = NULL;
1247 proto_tree *rtp_hext_tree = NULL;
1248 guint8 octet1, octet2;
1249 unsigned int version;
1250 gboolean padding_set;
1251 gboolean extension_set;
1252 unsigned int csrc_count;
1253 gboolean marker_set;
1254 unsigned int payload_type;
1255 gchar *payload_type_str = NULL;
1256 gboolean is_srtp = FALSE;
1258 unsigned int hdr_extension= 0;
1259 unsigned int hdr_extension_id = 0;
1260 unsigned int padding_count;
1261 gint length, reported_length;
1263 unsigned int offset = 0;
1268 struct _rtp_conversation_info *p_conv_data = NULL;
1269 /*struct srtp_info *srtp_info = NULL;*/
1270 /*unsigned int srtp_offset;*/
1271 unsigned int hdrext_offset = 0;
1272 tvbuff_t *newtvb = NULL;
1274 /* Can tap up to 4 RTP packets within same packet */
1275 static struct _rtp_info rtp_info_arr[4];
1276 static int rtp_info_current=0;
1277 struct _rtp_info *rtp_info;
1280 if (rtp_info_current==4) {
1283 rtp_info = &rtp_info_arr[rtp_info_current];
1285 /* Get the fields in the first octet */
1286 octet1 = tvb_get_guint8( tvb, offset );
1287 version = RTP_VERSION( octet1 );
1290 switch (global_rtp_version0_type) {
1291 case RTP0_CLASSICSTUN:
1292 call_dissector(classicstun_handle, tvb, pinfo, tree);
1296 call_dissector(t38_handle, tvb, pinfo, tree);
1300 call_dissector(sprt_handle, tvb, pinfo, tree);
1304 if (!(tvb_memeql(tvb, 4, "ZRTP", 4)))
1306 call_dissector(zrtp_handle,tvb,pinfo,tree);
1310 ; /* Unknown or unsupported version (let it fall through) */
1314 /* fill in the rtp_info structure */
1315 rtp_info->info_version = version;
1318 * Unknown or unsupported version.
1320 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP");
1322 col_add_fstr( pinfo->cinfo, COL_INFO,
1323 "Unknown RTP version %u", version);
1326 ti = proto_tree_add_item( tree, proto_rtp, tvb, offset, -1, ENC_NA );
1327 rtp_tree = proto_item_add_subtree( ti, ett_rtp );
1329 proto_tree_add_uint( rtp_tree, hf_rtp_version, tvb,
1335 padding_set = RTP_PADDING( octet1 );
1336 extension_set = RTP_EXTENSION( octet1 );
1337 csrc_count = RTP_CSRC_COUNT( octet1 );
1339 /* Get the fields in the second octet */
1340 octet2 = tvb_get_guint8( tvb, offset + 1 );
1341 marker_set = RTP_MARKER( octet2 );
1342 payload_type = RTP_PAYLOAD_TYPE( octet2 );
1344 /* Get the subsequent fields */
1345 seq_num = tvb_get_ntohs( tvb, offset + 2 );
1346 timestamp = tvb_get_ntohl( tvb, offset + 4 );
1347 sync_src = tvb_get_ntohl( tvb, offset + 8 );
1349 /* fill in the rtp_info structure */
1350 rtp_info->info_padding_set = padding_set;
1351 rtp_info->info_padding_count = 0;
1352 rtp_info->info_marker_set = marker_set;
1353 rtp_info->info_is_video = FALSE;
1354 rtp_info->info_payload_type = payload_type;
1355 rtp_info->info_seq_num = seq_num;
1356 rtp_info->info_timestamp = timestamp;
1357 rtp_info->info_sync_src = sync_src;
1358 rtp_info->info_is_srtp = FALSE;
1359 rtp_info->info_setup_frame_num = 0;
1360 rtp_info->info_payload_type_str = NULL;
1361 rtp_info->info_payload_rate = 0;
1364 * Do we have all the data?
1366 length = tvb_length_remaining(tvb, offset);
1367 reported_length = tvb_reported_length_remaining(tvb, offset);
1368 if (reported_length >= 0 && length >= reported_length) {
1372 rtp_info->info_all_data_present = TRUE;
1373 rtp_info->info_data_len = reported_length;
1376 * Save the pointer to raw rtp data (header + payload incl.
1378 * That should be safe because the "epan_dissect_t"
1379 * constructed for the packet has not yet been freed when
1380 * the taps are called.
1381 * (Destroying the "epan_dissect_t" will end up freeing
1382 * all the tvbuffs and hence invalidating pointers to
1384 * See "add_packet_to_packet_list()" for details.
1386 rtp_info->info_data = tvb_get_ptr(tvb, 0, -1);
1389 * No - packet was cut short at capture time.
1391 rtp_info->info_all_data_present = FALSE;
1392 rtp_info->info_data_len = 0;
1393 rtp_info->info_data = NULL;
1396 /* Look for conv and add to the frame if found */
1397 get_conv_info(pinfo, rtp_info);
1398 p_conv_data = p_get_proto_data(pinfo->fd, proto_rtp);
1401 rtp_info->info_is_video = p_conv_data->is_video;
1403 if (p_conv_data && p_conv_data->srtp_info) is_srtp = TRUE;
1404 rtp_info->info_is_srtp = is_srtp;
1406 col_set_str( pinfo->cinfo, COL_PROTOCOL, (is_srtp) ? "SRTP" : "RTP" );
1408 /* check if this is added as an SRTP stream - if so, don't try to dissect the payload data for now */
1409 p_conv_data = p_get_proto_data(pinfo->fd, proto_rtp);
1411 #if 0 /* XXX: srtp_offset never actually used ?? */
1412 if (p_conv_data && p_conv_data->srtp_info) {
1413 srtp_info = p_conv_data->srtp_info;
1414 if (rtp_info->info_all_data_present) {
1415 srtp_offset = rtp_info->info_data_len - srtp_info->mki_len - srtp_info->auth_tag_len;
1420 /* if it is dynamic payload, let use the conv data to see if it is defined */
1421 if ( (payload_type>95) && (payload_type<128) ) {
1422 if (p_conv_data && p_conv_data->rtp_dyn_payload){
1423 encoding_name_and_rate_t *encoding_name_and_rate_pt = NULL;
1424 encoding_name_and_rate_pt = g_hash_table_lookup(p_conv_data->rtp_dyn_payload, &payload_type);
1425 if (encoding_name_and_rate_pt) {
1426 rtp_info->info_payload_type_str = payload_type_str = encoding_name_and_rate_pt->encoding_name;
1427 rtp_info->info_payload_rate = encoding_name_and_rate_pt->sample_rate;
1432 col_add_fstr( pinfo->cinfo, COL_INFO,
1433 "PT=%s, SSRC=0x%X, Seq=%u, Time=%u%s",
1434 payload_type_str ? payload_type_str : val_to_str_ext( payload_type, &rtp_payload_type_vals_ext,"Unknown (%u)" ),
1438 marker_set ? ", Mark " : " ");
1443 /* Create RTP protocol tree */
1444 ti = proto_tree_add_item(tree, proto_rtp, tvb, offset, -1, ENC_NA );
1445 rtp_tree = proto_item_add_subtree(ti, ett_rtp );
1447 /* Conversation setup info */
1448 if (global_rtp_show_setup_info)
1450 show_setup_info(tvb, pinfo, rtp_tree);
1453 proto_tree_add_uint( rtp_tree, hf_rtp_version, tvb,
1454 offset, 1, octet1 );
1455 proto_tree_add_boolean( rtp_tree, hf_rtp_padding, tvb,
1456 offset, 1, octet1 );
1457 proto_tree_add_boolean( rtp_tree, hf_rtp_extension, tvb,
1458 offset, 1, octet1 );
1459 proto_tree_add_uint( rtp_tree, hf_rtp_csrc_count, tvb,
1460 offset, 1, octet1 );
1463 proto_tree_add_boolean( rtp_tree, hf_rtp_marker, tvb, offset,
1466 proto_tree_add_uint_format( rtp_tree, hf_rtp_payload_type, tvb,
1467 offset, 1, octet2, "Payload type: %s (%u)",
1468 payload_type_str ? payload_type_str : val_to_str_ext_const( payload_type, &rtp_payload_type_vals_ext,"Unknown"),
1473 /* Sequence number 16 bits (2 octets) */
1474 proto_tree_add_uint( rtp_tree, hf_rtp_seq_nr, tvb, offset, 2, seq_num );
1475 if(p_conv_data != NULL) {
1476 item = proto_tree_add_uint( rtp_tree, hf_rtp_ext_seq_nr, tvb, offset, 2, p_conv_data->extended_seqno );
1477 PROTO_ITEM_SET_GENERATED(item);
1481 /* Timestamp 32 bits (4 octets) */
1482 proto_tree_add_uint( rtp_tree, hf_rtp_timestamp, tvb, offset, 4, timestamp );
1485 /* Synchronization source identifier 32 bits (4 octets) */
1486 proto_tree_add_uint( rtp_tree, hf_rtp_ssrc, tvb, offset, 4, sync_src );
1492 if ( csrc_count > 0 ) {
1494 ti = proto_tree_add_item(rtp_tree, hf_rtp_csrc_items, tvb, offset,
1495 csrc_count * 4, ENC_NA);
1496 proto_item_append_text(ti, " (%u items)", csrc_count);
1497 rtp_csrc_tree = proto_item_add_subtree( ti, ett_csrc_list );
1499 for (i = 0; i < csrc_count; i++ ) {
1500 csrc_item = tvb_get_ntohl( tvb, offset );
1501 if ( tree ) proto_tree_add_uint_format( rtp_csrc_tree,
1502 hf_rtp_csrc_item, tvb, offset, 4,
1504 "CSRC item %d: 0x%X",
1510 /* Optional RTP header extension */
1511 if ( extension_set ) {
1512 /* Defined by profile field is 16 bits (2 octets) */
1513 hdr_extension_id = tvb_get_ntohs( tvb, offset );
1514 if ( tree ) proto_tree_add_uint( rtp_tree, hf_rtp_prof_define, tvb, offset, 2, hdr_extension_id );
1517 hdr_extension = tvb_get_ntohs( tvb, offset );
1518 if ( tree ) proto_tree_add_uint( rtp_tree, hf_rtp_length, tvb, offset, 2, hdr_extension);
1520 if ( hdr_extension > 0 ) {
1522 ti = proto_tree_add_item(rtp_tree, hf_rtp_hdr_exts, tvb, offset, hdr_extension * 4, ENC_NA);
1523 rtp_hext_tree = proto_item_add_subtree( ti, ett_hdr_ext );
1526 /* pass interpretation of header extension to a registered subdissector */
1527 newtvb = tvb_new_subset(tvb, offset, hdr_extension * 4, hdr_extension * 4);
1528 if ( !(dissector_try_uint(rtp_hdr_ext_dissector_table, hdr_extension_id, newtvb, pinfo, rtp_hext_tree)) ) {
1530 /* 0xBEDE is defined by RFC 5215 as a header
1531 * extension with a one byte header
1533 if (hdr_extension_id == 0xBEDE) {
1534 dissect_rtp_hext_rfc5215_onebyte (newtvb, pinfo, rtp_hext_tree);
1536 else if ((hdr_extension_id & 0xFFF0) == 0x1000) {
1537 dissect_rtp_hext_rfc5215_twobytes(tvb,
1538 offset - 4, hdr_extension_id, newtvb,
1539 pinfo, rtp_hext_tree);
1542 hdrext_offset = offset;
1543 for ( i = 0; i < hdr_extension; i++ ) {
1544 if ( tree ) proto_tree_add_uint( rtp_hext_tree, hf_rtp_hdr_ext, tvb, hdrext_offset, 4, tvb_get_ntohl( tvb, hdrext_offset ) );
1549 offset += hdr_extension * 4;
1553 if ( padding_set ) {
1555 * This RTP frame has padding - find it.
1557 * The padding count is found in the LAST octet of
1558 * the packet; it contains the number of octets
1559 * that can be ignored at the end of the packet.
1561 if (tvb_length(tvb) < tvb_reported_length(tvb)) {
1563 * We don't *have* the last octet of the
1564 * packet, so we can't get the padding
1567 * Put an indication of that into the
1568 * tree, and just put in a raw data
1571 if ( tree ) proto_tree_add_text(rtp_tree, tvb, 0, 0,
1572 "Frame has padding, but not all the frame data was captured");
1573 call_dissector(data_handle,
1574 tvb_new_subset_remaining(tvb, offset),
1579 padding_count = tvb_get_guint8( tvb,
1580 tvb_reported_length( tvb ) - 1 );
1582 tvb_reported_length_remaining( tvb, offset ) - padding_count;
1584 rtp_info->info_payload_offset = offset;
1585 rtp_info->info_payload_len = tvb_length_remaining(tvb, offset);
1586 rtp_info->info_padding_count = padding_count;
1590 * There's data left over when you take out
1591 * the padding; dissect it.
1593 dissect_rtp_data( tvb, pinfo, tree, rtp_tree,
1599 } else if (data_len < 0) {
1601 * The padding count is bigger than the
1602 * amount of RTP payload in the packet!
1603 * Clip the padding count.
1605 * XXX - put an item in the tree to indicate
1606 * that the padding count is bogus?
1609 tvb_reported_length_remaining(tvb, offset);
1611 if (padding_count > 1) {
1613 * There's more than one byte of padding;
1614 * show all but the last byte as padding
1617 if ( tree ) proto_tree_add_item( rtp_tree, hf_rtp_padding_data,
1618 tvb, offset, padding_count - 1, ENC_NA );
1619 offset += padding_count - 1;
1622 * Show the last byte in the PDU as the padding
1625 if ( tree ) proto_tree_add_item( rtp_tree, hf_rtp_padding_count,
1626 tvb, offset, 1, ENC_BIG_ENDIAN );
1632 dissect_rtp_data( tvb, pinfo, tree, rtp_tree, offset,
1633 tvb_length_remaining( tvb, offset ),
1634 tvb_reported_length_remaining( tvb, offset ),
1636 rtp_info->info_payload_offset = offset;
1637 rtp_info->info_payload_len = tvb_length_remaining(tvb, offset);
1639 if (!pinfo->flags.in_error_pkt)
1640 tap_queue_packet(rtp_tap, pinfo, rtp_info);
1644 /* calculate the extended sequence number - top 16 bits of the previous sequence number,
1645 * plus our own; then correct for wrapping */
1647 calculate_extended_seqno(guint32 previous_seqno, guint16 raw_seqno)
1649 guint32 seqno = (previous_seqno & 0xffff0000) | raw_seqno;
1650 if(seqno + 0x8000 < previous_seqno) {
1652 } else if(previous_seqno + 0x8000 < seqno) {
1653 /* we got an out-of-order packet which happened to go backwards over the
1660 /* Look for conversation info */
1662 get_conv_info(packet_info *pinfo, struct _rtp_info *rtp_info)
1664 /* Conversation and current data */
1665 conversation_t *p_conv = NULL;
1666 struct _rtp_conversation_info *p_conv_data = NULL;
1668 /* Use existing packet info if available */
1669 p_conv_data = p_get_proto_data(pinfo->fd, proto_rtp);
1673 /* First time, get info from conversation */
1674 p_conv = find_conversation(pinfo->fd->num, &pinfo->net_dst, &pinfo->net_src,
1676 pinfo->destport, pinfo->srcport, NO_ADDR_B);
1679 /* Create space for packet info */
1680 struct _rtp_conversation_info *p_conv_packet_data;
1681 p_conv_data = conversation_get_proto_data(p_conv, proto_rtp);
1686 /* Save this conversation info into packet info */
1687 p_conv_packet_data = se_alloc(sizeof(struct _rtp_conversation_info));
1688 g_strlcpy(p_conv_packet_data->method, p_conv_data->method, MAX_RTP_SETUP_METHOD_SIZE+1);
1689 p_conv_packet_data->frame_number = p_conv_data->frame_number;
1690 p_conv_packet_data->is_video = p_conv_data->is_video;
1691 p_conv_packet_data->rtp_dyn_payload = p_conv_data->rtp_dyn_payload;
1692 p_conv_packet_data->rtp_conv_info = p_conv_data->rtp_conv_info;
1693 p_conv_packet_data->srtp_info = p_conv_data->srtp_info;
1694 p_add_proto_data(pinfo->fd, proto_rtp, p_conv_packet_data);
1696 /* calculate extended sequence number */
1697 seqno = calculate_extended_seqno(p_conv_data->extended_seqno,
1698 rtp_info->info_seq_num);
1700 p_conv_packet_data->extended_seqno = seqno;
1701 p_conv_data->extended_seqno = seqno;
1705 if (p_conv_data) rtp_info->info_setup_frame_num = p_conv_data->frame_number;
1709 /* Display setup info */
1711 show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1713 /* Conversation and current data */
1714 struct _rtp_conversation_info *p_conv_data = NULL;
1715 proto_tree *rtp_setup_tree;
1718 /* Use existing packet info if available */
1719 p_conv_data = p_get_proto_data(pinfo->fd, proto_rtp);
1721 if (!p_conv_data) return;
1723 /* Create setup info subtree with summary info. */
1724 ti = proto_tree_add_string_format(tree, hf_rtp_setup, tvb, 0, 0,
1725 "", "Stream setup by %s (frame %u)",
1726 p_conv_data->method,
1727 p_conv_data->frame_number);
1728 PROTO_ITEM_SET_GENERATED(ti);
1729 rtp_setup_tree = proto_item_add_subtree(ti, ett_rtp_setup);
1732 /* Add details into subtree */
1733 proto_item* item = proto_tree_add_uint(rtp_setup_tree, hf_rtp_setup_frame,
1734 tvb, 0, 0, p_conv_data->frame_number);
1735 PROTO_ITEM_SET_GENERATED(item);
1736 item = proto_tree_add_string(rtp_setup_tree, hf_rtp_setup_method,
1737 tvb, 0, 0, p_conv_data->method);
1738 PROTO_ITEM_SET_GENERATED(item);
1742 /* Dissect PacketCable CCC header */
1745 dissect_pkt_ccc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1747 proto_item *ti = NULL;
1748 proto_tree *pkt_ccc_tree = NULL;
1751 ti = proto_tree_add_item(tree, proto_pkt_ccc, tvb, 0, 12, ENC_NA);
1752 pkt_ccc_tree = proto_item_add_subtree(ti, ett_pkt_ccc);
1754 proto_tree_add_item(pkt_ccc_tree, hf_pkt_ccc_id, tvb, 0, 4, ENC_BIG_ENDIAN);
1755 proto_tree_add_item(pkt_ccc_tree, hf_pkt_ccc_ts, tvb, 4, 8,
1756 ENC_TIME_NTP|ENC_BIG_ENDIAN);
1759 dissect_rtp(tvb, pinfo, tree);
1763 /* Register PacketCable CCC */
1766 proto_register_pkt_ccc(void)
1768 static hf_register_info hf[] =
1773 "PacketCable CCC Identifier",
1785 "PacketCable CCC Timestamp",
1797 static gint *ett[] =
1802 module_t *pkt_ccc_module;
1804 proto_pkt_ccc = proto_register_protocol("PacketCable Call Content Connection",
1805 "PKT CCC", "pkt_ccc");
1806 proto_register_field_array(proto_pkt_ccc, hf, array_length(hf));
1807 proto_register_subtree_array(ett, array_length(ett));
1809 register_dissector("pkt_ccc", dissect_pkt_ccc, proto_pkt_ccc);
1811 pkt_ccc_module = prefs_register_protocol(proto_pkt_ccc, proto_reg_handoff_pkt_ccc);
1813 prefs_register_uint_preference(pkt_ccc_module, "udp_port",
1815 "Decode packets on this UDP port as PacketCable CCC",
1816 10, &global_pkt_ccc_udp_port);
1820 proto_reg_handoff_pkt_ccc(void)
1823 * Register this dissector as one that can be selected by a
1826 static gboolean initialized = FALSE;
1827 static dissector_handle_t pkt_ccc_handle;
1828 static guint saved_pkt_ccc_udp_port;
1831 pkt_ccc_handle = find_dissector("pkt_ccc");
1832 dissector_add_handle("udp.port", pkt_ccc_handle); /* for 'decode-as' */
1835 if (saved_pkt_ccc_udp_port != 0) {
1836 dissector_delete_uint("udp.port", saved_pkt_ccc_udp_port, pkt_ccc_handle);
1840 if (global_pkt_ccc_udp_port != 0) {
1841 dissector_add_uint("udp.port", global_pkt_ccc_udp_port, pkt_ccc_handle);
1843 saved_pkt_ccc_udp_port = global_pkt_ccc_udp_port;
1849 proto_register_rtp(void)
1851 static hf_register_info hf[] =
1860 VALS(rtp_version_vals),
1892 "Contributing source identifiers count",
1914 &hf_rtp_payload_type,
1940 "Extended sequence number",
1964 "Synchronization Source identifier",
1974 &hf_rtp_prof_define,
1976 "Defined by profile",
2000 "Contributing Source identifiers",
2024 "Header extensions",
2058 &hf_rtp_padding_data,
2070 &hf_rtp_padding_count,
2073 "rtp.padding.count",
2090 "Stream setup, method and frame number", HFILL
2094 &hf_rtp_setup_frame,
2102 "Frame that set up this stream", HFILL
2106 &hf_rtp_setup_method,
2114 "Method used to set up this stream", HFILL
2118 &hf_rtp_rfc2198_follow,
2124 TFS(&tfs_set_notset),
2126 "Next header follows", HFILL
2130 &hf_rtp_rfc2198_tm_off,
2133 "rtp.timestamp-offset",
2142 &hf_rtp_rfc2198_bl_len,
2154 &hf_rtp_ext_rfc5285_id,
2157 "rtp.ext.rfc5285.id",
2162 "RFC 5285 Header Extension Identifier",
2167 &hf_rtp_ext_rfc5285_length,
2170 "rtp.ext.rfc5285.len",
2175 "RFC 5285 Header Extension length",
2180 &hf_rtp_ext_rfc5285_appbits,
2183 "rtp.ext.rfc5285.appbits",
2188 "RFC 5285 2-bytes header application bits",
2193 &hf_rtp_ext_rfc5285_data,
2196 "rtp.ext.rfc5285.data",
2201 "RFC 5285 Extension Data",
2206 /* reassembly stuff */
2208 {"RTP Fragments", "rtp.fragments", FT_NONE, BASE_NONE, NULL, 0x0,
2213 {"RTP Fragment data", "rtp.fragment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
2217 {&hf_rtp_fragment_overlap,
2218 {"Fragment overlap", "rtp.fragment.overlap", FT_BOOLEAN, BASE_NONE,
2219 NULL, 0x0, "Fragment overlaps with other fragments", HFILL }
2222 {&hf_rtp_fragment_overlap_conflict,
2223 {"Conflicting data in fragment overlap", "rtp.fragment.overlap.conflict",
2224 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
2225 "Overlapping fragments contained conflicting data", HFILL }
2228 {&hf_rtp_fragment_multiple_tails,
2229 {"Multiple tail fragments found", "rtp.fragment.multipletails",
2230 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
2231 "Several tails were found when defragmenting the packet", HFILL }
2234 {&hf_rtp_fragment_too_long_fragment,
2235 {"Fragment too long", "rtp.fragment.toolongfragment",
2236 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
2237 "Fragment contained data past end of packet", HFILL }
2240 {&hf_rtp_fragment_error,
2241 {"Defragmentation error", "rtp.fragment.error",
2242 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
2243 "Defragmentation error due to illegal fragments", HFILL }
2246 {&hf_rtp_fragment_count,
2247 {"Fragment count", "rtp.fragment.count",
2248 FT_UINT32, BASE_DEC, NULL, 0x0,
2252 {&hf_rtp_reassembled_in,
2253 {"RTP fragment, reassembled in frame", "rtp.reassembled_in",
2254 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
2255 "This RTP packet is reassembled in this frame", HFILL }
2257 {&hf_rtp_reassembled_length,
2258 {"Reassembled RTP length", "rtp.reassembled.length",
2259 FT_UINT32, BASE_DEC, NULL, 0x0,
2260 "The total length of the reassembled payload", HFILL }
2262 {&hf_srtp_encrypted_payload,
2263 {"SRTP Encrypted Payload", "srtp.enc_payload",
2264 FT_BYTES, BASE_NONE, NULL, 0x0,
2268 {"SRTP MKI", "srtp.mki",
2269 FT_BYTES, BASE_NONE, NULL, 0x0,
2270 "SRTP Master Key Index", HFILL }
2273 {"SRTP Auth Tag", "srtp.auth_tag",
2274 FT_BYTES, BASE_NONE, NULL, 0x0,
2275 "SRTP Authentication Tag", HFILL }
2280 static gint *ett[] =
2285 &ett_hdr_ext_rfc5285,
2288 &ett_rtp_rfc2198_hdr,
2293 module_t *rtp_module;
2296 proto_rtp = proto_register_protocol("Real-Time Transport Protocol",
2298 proto_register_field_array(proto_rtp, hf, array_length(hf));
2299 proto_register_subtree_array(ett, array_length(ett));
2301 register_dissector("rtp", dissect_rtp, proto_rtp);
2302 register_dissector("rtp.rfc2198", dissect_rtp_rfc2198, proto_rtp);
2304 rtp_tap = register_tap("rtp");
2306 rtp_pt_dissector_table = register_dissector_table("rtp.pt",
2307 "RTP payload type", FT_UINT8, BASE_DEC);
2308 rtp_dyn_pt_dissector_table = register_dissector_table("rtp_dyn_payload_type",
2309 "Dynamic RTP payload type", FT_STRING, BASE_NONE);
2312 rtp_hdr_ext_dissector_table = register_dissector_table("rtp_hdr_ext",
2313 "RTP header extension", FT_UINT32, BASE_HEX);
2314 rtp_hdr_ext_rfc5285_dissector_table = register_dissector_table("rtp.ext.rfc5285.id",
2315 "RTP Generic header extension (RFC 5285)", FT_UINT8, BASE_DEC);
2316 rtp_module = prefs_register_protocol(proto_rtp, proto_reg_handoff_rtp);
2318 prefs_register_bool_preference(rtp_module, "show_setup_info",
2319 "Show stream setup information",
2320 "Where available, show which protocol and frame caused "
2321 "this RTP stream to be created",
2322 &global_rtp_show_setup_info);
2324 prefs_register_bool_preference(rtp_module, "heuristic_rtp",
2325 "Try to decode RTP outside of conversations",
2326 "If call control SIP/H323/RTSP/.. messages are missing in the trace, "
2327 "RTP isn't decoded without this",
2330 prefs_register_bool_preference(rtp_module, "desegment_rtp_streams",
2331 "Allow subdissector to reassemble RTP streams",
2332 "Whether subdissector can request RTP streams to be reassembled",
2335 prefs_register_enum_preference(rtp_module, "version0_type",
2336 "Treat RTP version 0 packets as",
2337 "If an RTP version 0 packet is encountered, it can be treated as "
2338 "an invalid or ZRTP packet, a CLASSIC-STUN packet, or a T.38 packet",
2339 &global_rtp_version0_type,
2340 rtp_version0_types, FALSE);
2341 prefs_register_uint_preference(rtp_module,
2342 "rfc2198_payload_type", "Payload Type for RFC2198",
2343 "Payload Type for RFC2198 Redundant Audio Data",
2347 register_init_routine(rtp_fragment_init);
2351 proto_reg_handoff_rtp(void)
2353 static gboolean rtp_prefs_initialized = FALSE;
2354 static dissector_handle_t rtp_rfc2198_handle;
2355 static guint rtp_saved_rfc2198_pt;
2357 if (!rtp_prefs_initialized) {
2358 rtp_handle = find_dissector("rtp");
2359 rtp_rfc2198_handle = find_dissector("rtp.rfc2198");
2361 dissector_add_handle("udp.port", rtp_handle); /* for 'decode-as' */
2362 dissector_add_string("rtp_dyn_payload_type", "red", rtp_rfc2198_handle);
2363 heur_dissector_add( "udp", dissect_rtp_heur_udp, proto_rtp);
2364 heur_dissector_add("stun", dissect_rtp_heur_stun, proto_rtp);
2366 data_handle = find_dissector("data");
2367 classicstun_handle = find_dissector("classicstun");
2368 classicstun_heur_handle = find_dissector("classicstun-heur");
2369 t38_handle = find_dissector("t38");
2370 zrtp_handle = find_dissector("zrtp");
2372 sprt_handle = find_dissector("sprt");
2373 v150fw_handle = find_dissector("v150fw");
2375 dissector_add_string("rtp_dyn_payload_type", "v150fw", v150fw_handle);
2377 rtp_prefs_initialized = TRUE;
2379 dissector_delete_uint("rtp.pt", rtp_saved_rfc2198_pt, rtp_rfc2198_handle);
2381 dissector_add_uint("rtp.pt", rtp_rfc2198_pt, rtp_rfc2198_handle);
2382 rtp_saved_rfc2198_pt = rtp_rfc2198_pt;
2388 * indent-tabs-mode: t