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
61 #include <epan/packet.h>
63 #include "packet-rtp.h"
65 #include <epan/rtp_pt.h>
66 #include <epan/conversation.h>
67 #include <epan/reassemble.h>
69 #include <epan/epan_dissect.h>
70 #include <epan/prefs.h>
71 #include <epan/wmem/wmem.h>
72 #include <epan/strutil.h>
74 /* uncomment this to enable debugging of fragment reassembly */
75 /* #define DEBUG_FRAGMENTS 1 */
77 typedef struct _rfc2198_hdr {
81 struct _rfc2198_hdr *next;
84 /* we have one of these for each pdu which spans more than one segment
86 typedef struct _rtp_multisegment_pdu {
87 /* the seqno of the segment where the pdu starts */
90 /* the seqno of the segment where the pdu ends */
92 } rtp_multisegment_pdu;
94 typedef struct _rtp_private_conv_info {
95 /* This tree is indexed by sequence number and keeps track of all
96 * all pdus spanning multiple segments for this flow.
98 wmem_tree_t *multisegment_pdus;
99 } rtp_private_conv_info;
101 static reassembly_table rtp_reassembly_table;
103 static int hf_rtp_fragments = -1;
104 static int hf_rtp_fragment = -1;
105 static int hf_rtp_fragment_overlap = -1;
106 static int hf_rtp_fragment_overlap_conflict = -1;
107 static int hf_rtp_fragment_multiple_tails = -1;
108 static int hf_rtp_fragment_too_long_fragment = -1;
109 static int hf_rtp_fragment_error = -1;
110 static int hf_rtp_fragment_count = -1;
111 static int hf_rtp_reassembled_in = -1;
112 static int hf_rtp_reassembled_length = -1;
114 static gint ett_rtp_fragment = -1;
115 static gint ett_rtp_fragments = -1;
117 static const fragment_items rtp_fragment_items = {
122 &hf_rtp_fragment_overlap,
123 &hf_rtp_fragment_overlap_conflict,
124 &hf_rtp_fragment_multiple_tails,
125 &hf_rtp_fragment_too_long_fragment,
126 &hf_rtp_fragment_error,
127 &hf_rtp_fragment_count,
128 &hf_rtp_reassembled_in,
129 &hf_rtp_reassembled_length,
130 /* Reassembled data field */
135 static dissector_handle_t rtp_handle;
136 static dissector_handle_t classicstun_handle;
137 static dissector_handle_t stun_handle;
138 static dissector_handle_t classicstun_heur_handle;
139 static dissector_handle_t stun_heur_handle;
140 static dissector_handle_t t38_handle;
141 static dissector_handle_t zrtp_handle;
143 static dissector_handle_t sprt_handle;
144 static dissector_handle_t v150fw_handle;
146 static dissector_handle_t bta2dp_content_protection_header_scms_t;
147 static dissector_handle_t btvdp_content_protection_header_scms_t;
148 static dissector_handle_t bta2dp_handle;
149 static dissector_handle_t btvdp_handle;
150 static dissector_handle_t sbc_handle;
152 static int rtp_tap = -1;
154 static dissector_table_t rtp_pt_dissector_table;
155 static dissector_table_t rtp_dyn_pt_dissector_table;
157 static dissector_table_t rtp_hdr_ext_dissector_table;
158 static dissector_table_t rtp_hdr_ext_rfc5285_dissector_table;
160 /* RTP header fields */
161 static int proto_rtp = -1;
162 static int hf_rtp_version = -1;
163 static int hf_rtp_padding = -1;
164 static int hf_rtp_extension = -1;
165 static int hf_rtp_csrc_count = -1;
166 static int hf_rtp_marker = -1;
167 static int hf_rtp_payload_type = -1;
168 static int hf_rtp_seq_nr = -1;
169 static int hf_rtp_ext_seq_nr = -1;
170 static int hf_rtp_timestamp = -1;
171 static int hf_rtp_ssrc = -1;
172 static int hf_rtp_csrc_items = -1;
173 static int hf_rtp_csrc_item = -1;
174 static int hf_rtp_data = -1;
175 static int hf_rtp_padding_data = -1;
176 static int hf_rtp_padding_count= -1;
177 static int hf_rtp_rfc2198_follow= -1;
178 static int hf_rtp_rfc2198_tm_off= -1;
179 static int hf_rtp_rfc2198_bl_len= -1;
181 /* RTP header extension fields */
182 static int hf_rtp_prof_define = -1;
183 static int hf_rtp_length = -1;
184 static int hf_rtp_hdr_exts = -1;
185 static int hf_rtp_hdr_ext = -1;
187 /* RTP header ED137A extension fields */
188 static int hf_rtp_hdr_ed137s = -1;
189 static int hf_rtp_hdr_ed137 = -1;
190 static int hf_rtp_hdr_ed137a = -1;
191 static int hf_rtp_hdr_ed137_ptt_type = -1;
192 static int hf_rtp_hdr_ed137_squ = -1;
193 static int hf_rtp_hdr_ed137_ptt_id = -1;
194 static int hf_rtp_hdr_ed137_sct = -1;
195 static int hf_rtp_hdr_ed137_x = -1;
196 static int hf_rtp_hdr_ed137_x_nu = -1;
197 static int hf_rtp_hdr_ed137_ft_type = -1;
198 static int hf_rtp_hdr_ed137_ft_len = -1;
199 static int hf_rtp_hdr_ed137_ft_value = -1;
200 static int hf_rtp_hdr_ed137_ft_bss_qidx = -1;
201 static int hf_rtp_hdr_ed137_ft_bss_rssi_qidx = -1;
202 static int hf_rtp_hdr_ed137_ft_bss_qidx_ml = -1;
203 static int hf_rtp_hdr_ed137_ft_bss_nu = -1;
204 static int hf_rtp_hdr_ed137_vf = -1;
205 static int hf_rtp_hdr_ed137a_ptt_type = -1;
206 static int hf_rtp_hdr_ed137a_squ = -1;
207 static int hf_rtp_hdr_ed137a_ptt_id = -1;
208 static int hf_rtp_hdr_ed137a_pm = -1;
209 static int hf_rtp_hdr_ed137a_ptts = -1;
210 static int hf_rtp_hdr_ed137a_sct = -1;
211 static int hf_rtp_hdr_ed137a_reserved = -1;
212 static int hf_rtp_hdr_ed137a_x = -1;
213 static int hf_rtp_hdr_ed137a_x_nu = -1;
214 static int hf_rtp_hdr_ed137a_ft_type = -1;
215 static int hf_rtp_hdr_ed137a_ft_len = -1;
216 static int hf_rtp_hdr_ed137a_ft_value = -1;
217 static gint ett_hdr_ext_ed137s = -1;
218 static gint ett_hdr_ext_ed137 = -1;
219 static gint ett_hdr_ext_ed137a = -1;
221 /* RTP setup fields */
222 static int hf_rtp_setup = -1;
223 static int hf_rtp_setup_frame = -1;
224 static int hf_rtp_setup_method = -1;
226 /* RTP fields defining a sub tree */
227 static gint ett_rtp = -1;
228 static gint ett_csrc_list = -1;
229 static gint ett_hdr_ext = -1;
230 static gint ett_hdr_ext_rfc5285 = -1;
231 static gint ett_rtp_setup = -1;
232 static gint ett_rtp_rfc2198 = -1;
233 static gint ett_rtp_rfc2198_hdr = -1;
236 static int hf_srtp_encrypted_payload = -1;
237 static int hf_srtp_mki = -1;
238 static int hf_srtp_auth_tag = -1;
240 /* PacketCable CCC header fields */
241 static int proto_pkt_ccc = -1;
242 static int hf_pkt_ccc_id = -1;
243 static int hf_pkt_ccc_ts = -1;
245 /* PacketCable CCC field defining a sub tree */
246 static gint ett_pkt_ccc = -1;
248 /* PacketCable CCC port preference */
249 static guint global_pkt_ccc_udp_port = 0;
251 /* RFC 5285 Header extensions */
252 static int hf_rtp_ext_rfc5285_id = -1;
253 static int hf_rtp_ext_rfc5285_length = -1;
254 static int hf_rtp_ext_rfc5285_appbits = -1;
255 static int hf_rtp_ext_rfc5285_data = -1;
257 #define RTP0_INVALID 0
259 #define RTP0_CLASSICSTUN 2
263 static const enum_val_t rtp_version0_types[] = {
264 { "invalid", "Invalid or ZRTP packets", RTP0_INVALID },
265 { "stun", "STUN packets", RTP0_STUN },
266 { "classicstun", "CLASSIC-STUN packets", RTP0_CLASSICSTUN },
267 { "t38", "T.38 packets", RTP0_T38 },
268 { "sprt", "SPRT packets", RTP0_SPRT },
271 static gint global_rtp_version0_type = 0;
273 static dissector_handle_t data_handle;
275 /* Forward declaration we need below */
276 void proto_register_rtp(void);
277 void proto_reg_handoff_rtp(void);
278 void proto_register_pkt_ccc(void);
279 void proto_reg_handoff_pkt_ccc(void);
281 static gint dissect_rtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data);
282 static void show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
283 static void get_conv_info(packet_info *pinfo, struct _rtp_info *rtp_info);
285 /* Preferences bool to control whether or not setup info should be shown */
286 static gboolean global_rtp_show_setup_info = TRUE;
288 /* Try heuristic RTP decode */
289 static gboolean global_rtp_heur = FALSE;
291 /* desegment RTP streams */
292 static gboolean desegment_rtp = TRUE;
294 /* RFC2198 Redundant Audio Data */
295 static guint rtp_rfc2198_pt = 99;
298 * Fields in the first octet of the RTP header.
301 /* Version is the first 2 bits of the first octet*/
302 #define RTP_VERSION(octet) ((octet) >> 6)
304 /* Padding is the third bit; No need to shift, because true is any value
306 #define RTP_PADDING(octet) ((octet) & 0x20)
308 /* Extension bit is the fourth bit */
309 #define RTP_EXTENSION(octet) ((octet) & 0x10)
311 /* ED137 signature */
312 #define RTP_ED137_SIG 0x0067
314 /* ED137A signature */
315 #define RTP_ED137A_SIG 0x0167
318 #define RTP_ED137_ptt_mask(octet) ((octet) & 0xE0000000)
319 #define RTP_ED137A_ptt_mask(octet) ((octet) & 0xE0000000)
320 #define RTP_ED137_squ_mask(octet) ((octet) & 0x10000000)
321 #define RTP_ED137A_squ_mask(octet) ((octet) & 0x10000000)
323 /* ED137 extended information */
324 #define RTP_ED137_extended_information(octet) ((octet) & 0x00400000)
325 #define RTP_ED137A_extended_information(octet) ((octet) & 0x00010000)
327 /* ED137 feature type */
328 #define RTP_ED137_feature_type(octet) (((octet) & 0x003C0000) >> 18)
329 #define RTP_ED137A_feature_type(octet) (((octet) & 0x0000F000) >> 12)
331 /* ED137 feature length */
332 #define RTP_ED137_feature_length(octet) (((octet) & 0x0003C000) >> 14)
333 #define RTP_ED137A_feature_length(octet) (((octet) & 0x00000F00) >> 8)
335 /* ED137 feature value */
336 #define RTP_ED137_feature_value(octet) (((octet) & 0x00003FFE) >> 1)
337 #define RTP_ED137A_feature_value(octet) (((octet) & 0x000000FF) >> 0)
339 /* ED137 BSS constants */
340 #define RTP_ED137_feature_bss_type 0x1
341 #define RTP_ED137_feature_bss_len 11
342 #define RTP_ED137_feature_bss_qidx(octet) (((octet) & 0x00003FC0) >> 6)
343 #define RTP_ED137_feature_bss_qidx_ml(octet) (((octet) & 0x00000038) >> 2)
345 /* RFC 5215 one byte header signature */
346 #define RTP_RFC5215_ONE_BYTE_SIG 0xBEDE
348 /* RFC 5215 two byte header mask and signature */
349 #define RTP_RFC5215_TWO_BYTE_MASK 0xFFF0
350 #define RTP_RFC5215_TWO_BYTE_SIG 0x1000
352 /* CSRC count is the last four bits */
353 #define RTP_CSRC_COUNT(octet) ((octet) & 0xF)
355 static const value_string rtp_version_vals[] =
357 { 2, "RFC 1889 Version" }, /* First for speed */
358 { 0, "Old VAT Version" },
359 { 1, "First Draft Version" },
363 static const value_string rtp_ext_profile_vals[] =
365 { RTP_ED137_SIG, "ED137" },
366 { RTP_ED137A_SIG, "ED137A" },
370 static const value_string rtp_ext_ed137_ptt_type[] =
373 { 0x01, "Normal PTT ON" },
374 { 0x02, "Coupling PTT ON" },
375 { 0x03, "Priority PTT ON" },
376 { 0x04, "Emergency PTT ON" },
377 { 0x05, "Reserved" },
378 { 0x06, "Reserved" },
379 { 0x07, "Reserved" },
383 static const value_string rtp_ext_ed137_squ[] =
390 static const value_string rtp_ext_ed137_ft_type[] =
392 { 0x0, "No features" },
393 { 0x1, "Best signal selection" },
394 { 0x2, "CLIMAX time delay" },
403 { 0xB, "Vendor reserved" },
404 { 0xC, "Vendor reserved" },
405 { 0xD, "Vendor reserved" },
406 { 0xE, "Vendor reserved" },
407 { 0xF, "Vendor reserved" },
411 static const value_string rtp_ext_ed137_vf[] =
418 static const value_string rtp_ext_ed137_ft_bss_rssi_qidx[] =
420 { 0x00, "lower than -100.00 dBm" },
421 { 0x01, "lower than or equal to -97.86 dBm" },
422 { 0x02, "lower than or equal to -95.71 dBm" },
423 { 0x03, "lower than or equal to -93.57 dBm" },
424 { 0x04, "lower than or equal to -91.43 dBm" },
425 { 0x05, "lower than or equal to -89.29 dBm" },
426 { 0x06, "lower than or equal to -87.14 dBm" },
427 { 0x07, "lower than or equal to -85.00 dBm" },
428 { 0x08, "lower than or equal to -82.86 dBm" },
429 { 0x09, "lower than or equal to -80.71 dBm" },
430 { 0x0a, "lower than or equal to -78.57 dBm" },
431 { 0x0b, "lower than or equal to -76.43 dBm" },
432 { 0x0c, "lower than or equal to -74.29 dBm" },
433 { 0x0d, "lower than or equal to -72.14 dBm" },
434 { 0x0e, "lower than or equal to -70.00 dBm" },
435 { 0x0f, "higher than -70.00 dBm" },
439 static const value_string rtp_ext_ed137_ft_bss_qidx_ml[] =
442 { 0x01, "AGC Level" },
444 { 0x03, "Standardized PSD" },
445 { 0x04, "Vendor specific method" },
446 { 0x05, "Vendor specific method" },
447 { 0x06, "Vendor specific method" },
448 { 0x07, "Vendor specific method" },
452 static const value_string rtp_ext_ed137a_ptt_type[] =
455 { 0x01, "Normal PTT ON" },
456 { 0x02, "Coupling PTT ON" },
457 { 0x03, "Priority PTT ON" },
458 { 0x04, "Emergency PTT ON" },
459 { 0x05, "Reserved" },
460 { 0x06, "Reserved" },
461 { 0x07, "Reserved" },
465 static const value_string rtp_ext_ed137a_squ[] =
472 static const value_string rtp_ext_ed137a_ft_type[] =
474 { 0x0, "No features" },
475 { 0x1, "Signal Quality Information" },
476 { 0x2, "CLIMAX time delay" },
477 { 0x3, "Radio remote control" },
478 { 0x4, "CLIMAX dynamic delay compensation" },
485 { 0xB, "Vendor reserved" },
486 { 0xC, "Vendor reserved" },
487 { 0xD, "Vendor reserved" },
488 { 0xE, "Vendor reserved" },
489 { 0xF, "Vendor reserved" },
494 * Fields in the second octet of the RTP header.
497 /* Marker is the first bit of the second octet */
498 #define RTP_MARKER(octet) ((octet) & 0x80)
500 /* Payload type is the last 7 bits */
501 #define RTP_PAYLOAD_TYPE(octet) ((octet) & 0x7F)
502 /* http://www.iana.org/assignments/rtp-parameters */
504 static const value_string rtp_payload_type_vals[] =
506 /* 0 */ { PT_PCMU, "ITU-T G.711 PCMU" },
507 /* 1 */ { PT_1016, "USA Federal Standard FS-1016" },
508 /* 2 */ { PT_G721, "ITU-T G.721" },
509 /* 3 */ { PT_GSM, "GSM 06.10" },
510 /* 4 */ { PT_G723, "ITU-T G.723" },
511 /* 5 */ { PT_DVI4_8000, "DVI4 8000 samples/s" },
512 /* 6 */ { PT_DVI4_16000, "DVI4 16000 samples/s" },
513 /* 7 */ { PT_LPC, "Experimental linear predictive encoding from Xerox PARC" },
514 /* 8 */ { PT_PCMA, "ITU-T G.711 PCMA" },
515 /* 9 */ { PT_G722, "ITU-T G.722" },
516 /* 10 */ { PT_L16_STEREO, "16-bit uncompressed audio, stereo" },
517 /* 11 */ { PT_L16_MONO, "16-bit uncompressed audio, monaural" },
518 /* 12 */ { PT_QCELP, "Qualcomm Code Excited Linear Predictive coding" },
519 /* 13 */ { PT_CN, "Comfort noise" },
520 /* 14 */ { PT_MPA, "MPEG-I/II Audio"},
521 /* 15 */ { PT_G728, "ITU-T G.728" },
522 /* 16 */ { PT_DVI4_11025, "DVI4 11025 samples/s" },
523 /* 17 */ { PT_DVI4_22050, "DVI4 22050 samples/s" },
524 /* 18 */ { PT_G729, "ITU-T G.729" },
525 /* 19 */ { PT_CN_OLD, "Comfort noise (old)" },
526 /* 20 */ { 20, "Unassigned" },
527 /* 21 */ { 21, "Unassigned" },
528 /* 22 */ { 22, "Unassigned" },
529 /* 23 */ { 23, "Unassigned" },
530 /* 24 */ { 24, "Unassigned" },
531 /* 25 */ { PT_CELB, "Sun CellB video encoding" },
532 /* 26 */ { PT_JPEG, "JPEG-compressed video" },
533 /* 27 */ { 27, "Unassigned" },
534 /* 28 */ { PT_NV, "'nv' program" },
535 /* 29 */ { 29, "Unassigned" },
536 /* 30 */ { 30, "Unassigned" },
537 /* 31 */ { PT_H261, "ITU-T H.261" },
538 /* 32 */ { PT_MPV, "MPEG-I/II Video"},
539 /* 33 */ { PT_MP2T, "MPEG-II transport streams"},
540 /* 34 */ { PT_H263, "ITU-T H.263" },
541 /* 35-71 Unassigned */
542 /* 35 */ { 35, "Unassigned" },
543 /* 36 */ { 36, "Unassigned" },
544 /* 37 */ { 37, "Unassigned" },
545 /* 38 */ { 38, "Unassigned" },
546 /* 39 */ { 39, "Unassigned" },
547 /* 40 */ { 40, "Unassigned" },
548 /* 41 */ { 41, "Unassigned" },
549 /* 42 */ { 42, "Unassigned" },
550 /* 43 */ { 43, "Unassigned" },
551 /* 44 */ { 44, "Unassigned" },
552 /* 45 */ { 45, "Unassigned" },
553 /* 46 */ { 46, "Unassigned" },
554 /* 47 */ { 47, "Unassigned" },
555 /* 48 */ { 48, "Unassigned" },
556 /* 49 */ { 49, "Unassigned" },
557 /* 50 */ { 50, "Unassigned" },
558 /* 51 */ { 51, "Unassigned" },
559 /* 52 */ { 52, "Unassigned" },
560 /* 53 */ { 53, "Unassigned" },
561 /* 54 */ { 54, "Unassigned" },
562 /* 55 */ { 55, "Unassigned" },
563 /* 56 */ { 56, "Unassigned" },
564 /* 57 */ { 57, "Unassigned" },
565 /* 58 */ { 58, "Unassigned" },
566 /* 59 */ { 59, "Unassigned" },
567 /* 60 */ { 60, "Unassigned" },
568 /* 61 */ { 61, "Unassigned" },
569 /* 62 */ { 62, "Unassigned" },
570 /* 63 */ { 63, "Unassigned" },
571 /* 64 */ { 64, "Unassigned" },
572 /* 65 */ { 65, "Unassigned" },
573 /* 66 */ { 66, "Unassigned" },
574 /* 67 */ { 67, "Unassigned" },
575 /* 68 */ { 68, "Unassigned" },
576 /* 69 */ { 69, "Unassigned" },
577 /* 70 */ { 70, "Unassigned" },
578 /* 71 */ { 71, "Unassigned" },
579 /* 72-76 Reserved for RTCP conflict avoidance [RFC3551] */
580 /* 72 */ { 72, "Reserved for RTCP conflict avoidance" },
581 /* 73 */ { 73, "Reserved for RTCP conflict avoidance" },
582 /* 74 */ { 74, "Reserved for RTCP conflict avoidance" },
583 /* 75 */ { 75, "Reserved for RTCP conflict avoidance" },
584 /* 76 */ { 76, "Reserved for RTCP conflict avoidance" },
585 /* 77-95 Unassigned ? */
586 /* 77 */ { 77, "Unassigned" },
587 /* 78 */ { 78, "Unassigned" },
588 /* 79 */ { 79, "Unassigned" },
589 /* 80 */ { 80, "Unassigned" },
590 /* 81 */ { 81, "Unassigned" },
591 /* 82 */ { 82, "Unassigned" },
592 /* 83 */ { 83, "Unassigned" },
593 /* 84 */ { 84, "Unassigned" },
594 /* 85 */ { 85, "Unassigned" },
595 /* 86 */ { 86, "Unassigned" },
596 /* 87 */ { 87, "Unassigned" },
597 /* 88 */ { 88, "Unassigned" },
598 /* 89 */ { 89, "Unassigned" },
599 /* 90 */ { 90, "Unassigned" },
600 /* 91 */ { 91, "Unassigned" },
601 /* 92 */ { 92, "Unassigned" },
602 /* 93 */ { 93, "Unassigned" },
603 /* 94 */ { 94, "Unassigned" },
604 /* 95 */ { 95, "Unassigned" },
605 /* Added to support addtional RTP payload types
606 * See epan/rtp_pt.h */
607 { PT_UNDF_96, "DynamicRTP-Type-96" },
608 { PT_UNDF_97, "DynamicRTP-Type-97" },
609 { PT_UNDF_98, "DynamicRTP-Type-98" },
610 { PT_UNDF_99, "DynamicRTP-Type-99" },
611 { PT_UNDF_100, "DynamicRTP-Type-100" },
612 { PT_UNDF_101, "DynamicRTP-Type-101" },
613 { PT_UNDF_102, "DynamicRTP-Type-102" },
614 { PT_UNDF_103, "DynamicRTP-Type-103" },
615 { PT_UNDF_104, "DynamicRTP-Type-104" },
616 { PT_UNDF_105, "DynamicRTP-Type-105" },
617 { PT_UNDF_106, "DynamicRTP-Type-106" },
618 { PT_UNDF_107, "DynamicRTP-Type-107" },
619 { PT_UNDF_108, "DynamicRTP-Type-108" },
620 { PT_UNDF_109, "DynamicRTP-Type-109" },
621 { PT_UNDF_110, "DynamicRTP-Type-110" },
622 { PT_UNDF_111, "DynamicRTP-Type-111" },
623 { PT_UNDF_112, "DynamicRTP-Type-112" },
624 { PT_UNDF_113, "DynamicRTP-Type-113" },
625 { PT_UNDF_114, "DynamicRTP-Type-114" },
626 { PT_UNDF_115, "DynamicRTP-Type-115" },
627 { PT_UNDF_116, "DynamicRTP-Type-116" },
628 { PT_UNDF_117, "DynamicRTP-Type-117" },
629 { PT_UNDF_118, "DynamicRTP-Type-118" },
630 { PT_UNDF_119, "DynamicRTP-Type-119" },
631 { PT_UNDF_120, "DynamicRTP-Type-120" },
632 { PT_UNDF_121, "DynamicRTP-Type-121" },
633 { PT_UNDF_122, "DynamicRTP-Type-122" },
634 { PT_UNDF_123, "DynamicRTP-Type-123" },
635 { PT_UNDF_124, "DynamicRTP-Type-124" },
636 { PT_UNDF_125, "DynamicRTP-Type-125" },
637 { PT_UNDF_126, "DynamicRTP-Type-126" },
638 { PT_UNDF_127, "DynamicRTP-Type-127" },
643 value_string_ext rtp_payload_type_vals_ext = VALUE_STRING_EXT_INIT(rtp_payload_type_vals);
645 static const value_string rtp_payload_type_short_vals[] =
647 { PT_PCMU, "g711U" },
648 { PT_1016, "fs-1016" },
652 { PT_DVI4_8000, "DVI4 8k" },
653 { PT_DVI4_16000, "DVI4 16k" },
654 { PT_LPC, "Exp. from Xerox PARC" },
655 { PT_PCMA, "g711A" },
657 { PT_L16_STEREO, "16-bit audio, stereo" },
658 { PT_L16_MONO, "16-bit audio, monaural" },
659 { PT_QCELP, "Qualcomm" },
661 { PT_MPA, "MPEG-I/II Audio"},
663 { PT_DVI4_11025, "DVI4 11k" },
664 { PT_DVI4_22050, "DVI4 22k" },
666 { PT_CN_OLD, "CN(old)" },
667 { 20, "Unassigned" },
668 { 21, "Unassigned" },
669 { 22, "Unassigned" },
670 { 23, "Unassigned" },
671 { 24, "Unassigned" },
672 { PT_CELB, "CellB" },
674 { 27, "Unassigned" },
676 { 29, "Unassigned" },
677 { 30, "Unassigned" },
679 { PT_MPV, "MPEG-I/II Video"},
680 { PT_MP2T, "MPEG-II streams"},
682 /* 35-71 Unassigned */
683 { 35, "Unassigned" },
684 { 36, "Unassigned" },
685 { 37, "Unassigned" },
686 { 38, "Unassigned" },
687 { 39, "Unassigned" },
688 { 40, "Unassigned" },
689 { 41, "Unassigned" },
690 { 42, "Unassigned" },
691 { 43, "Unassigned" },
692 { 44, "Unassigned" },
693 { 45, "Unassigned" },
694 { 46, "Unassigned" },
695 { 47, "Unassigned" },
696 { 48, "Unassigned" },
697 { 49, "Unassigned" },
698 { 50, "Unassigned" },
699 { 51, "Unassigned" },
700 { 52, "Unassigned" },
701 { 53, "Unassigned" },
702 { 54, "Unassigned" },
703 { 55, "Unassigned" },
704 { 56, "Unassigned" },
705 { 57, "Unassigned" },
706 { 58, "Unassigned" },
707 { 59, "Unassigned" },
708 { 60, "Unassigned" },
709 { 61, "Unassigned" },
710 { 62, "Unassigned" },
711 { 63, "Unassigned" },
712 { 64, "Unassigned" },
713 { 65, "Unassigned" },
714 { 66, "Unassigned" },
715 { 67, "Unassigned" },
716 { 68, "Unassigned" },
717 { 69, "Unassigned" },
718 { 70, "Unassigned" },
719 { 71, "Unassigned" },
720 /* 72-76 Reserved for RTCP conflict avoidance - [RFC3551] */
721 { 72, "Reserved for RTCP conflict avoidance" },
722 { 73, "Reserved for RTCP conflict avoidance" },
723 { 74, "Reserved for RTCP conflict avoidance" },
724 { 75, "Reserved for RTCP conflict avoidance" },
725 { 76, "Reserved for RTCP conflict avoidance" },
726 /* 77-95 Unassigned ? */
727 { 77, "Unassigned" },
728 { 78, "Unassigned" },
729 { 79, "Unassigned" },
730 { 80, "Unassigned" },
731 { 81, "Unassigned" },
732 { 82, "Unassigned" },
733 { 83, "Unassigned" },
734 { 84, "Unassigned" },
735 { 85, "Unassigned" },
736 { 86, "Unassigned" },
737 { 87, "Unassigned" },
738 { 88, "Unassigned" },
739 { 89, "Unassigned" },
740 { 90, "Unassigned" },
741 { 91, "Unassigned" },
742 { 92, "Unassigned" },
743 { 93, "Unassigned" },
744 { 94, "Unassigned" },
745 { 95, "Unassigned" },
746 /* Short RTP types */
747 { PT_UNDF_96, "RTPType-96" },
748 { PT_UNDF_97, "RTPType-97" },
749 { PT_UNDF_98, "RTPType-98" },
750 { PT_UNDF_99, "RTPType-99" },
751 { PT_UNDF_100, "RTPType-100" },
752 { PT_UNDF_101, "RTPType-101" },
753 { PT_UNDF_102, "RTPType-102" },
754 { PT_UNDF_103, "RTPType-103" },
755 { PT_UNDF_104, "RTPType-104" },
756 { PT_UNDF_105, "RTPType-105" },
757 { PT_UNDF_106, "RTPType-106" },
758 { PT_UNDF_107, "RTPType-107" },
759 { PT_UNDF_108, "RTPType-108" },
760 { PT_UNDF_109, "RTPType-109" },
761 { PT_UNDF_110, "RTPType-110" },
762 { PT_UNDF_111, "RTPType-111" },
763 { PT_UNDF_112, "RTPType-112" },
764 { PT_UNDF_113, "RTPType-113" },
765 { PT_UNDF_114, "RTPType-114" },
766 { PT_UNDF_115, "RTPType-115" },
767 { PT_UNDF_116, "RTPType-116" },
768 { PT_UNDF_117, "RTPType-117" },
769 { PT_UNDF_118, "RTPType-118" },
770 { PT_UNDF_119, "RTPType-119" },
771 { PT_UNDF_120, "RTPType-120" },
772 { PT_UNDF_121, "RTPType-121" },
773 { PT_UNDF_122, "RTPType-122" },
774 { PT_UNDF_123, "RTPType-123" },
775 { PT_UNDF_124, "RTPType-124" },
776 { PT_UNDF_125, "RTPType-125" },
777 { PT_UNDF_126, "RTPType-126" },
778 { PT_UNDF_127, "RTPType-127" },
782 value_string_ext rtp_payload_type_short_vals_ext = VALUE_STRING_EXT_INIT(rtp_payload_type_short_vals);
785 static const value_string srtp_encryption_alg_vals[] =
787 { SRTP_ENC_ALG_NULL, "Null Encryption" },
788 { SRTP_ENC_ALG_AES_CM, "AES-128 Counter Mode" },
789 { SRTP_ENC_ALG_AES_F8, "AES-128 F8 Mode" },
793 static const value_string srtp_auth_alg_vals[] =
795 { SRTP_AUTH_ALG_NONE, "No Authentication" },
796 { SRTP_AUTH_ALG_HMAC_SHA1, "HMAC-SHA1" },
801 /* initialisation routine */
803 rtp_fragment_init(void)
805 reassembly_table_init(&rtp_reassembly_table,
806 &addresses_reassembly_table_functions);
810 rtp_free_hash_dyn_payload(GHashTable *rtp_dyn_payload)
812 if (rtp_dyn_payload == NULL) return;
813 g_hash_table_destroy(rtp_dyn_payload);
814 rtp_dyn_payload = NULL;
819 bluetooth_add_address(packet_info *pinfo, address *addr,
820 const gchar *setup_method, guint32 setup_frame_number,
821 gboolean is_video, void *data)
824 conversation_t* p_conv;
825 struct _rtp_conversation_info *p_conv_data = NULL;
827 * If this isn't the first time this packet has been processed,
828 * we've already done this work, so we don't need to do it
831 if (pinfo->fd->flags.visited)
836 SET_ADDRESS(&null_addr, AT_NONE, 0, NULL);
839 * Check if the ip address and port combination is not
840 * already registered as a conversation.
842 p_conv = find_conversation(setup_frame_number, addr, &null_addr, PT_BLUETOOTH, 0, 0,
843 NO_ADDR_B | NO_PORT_B);
846 * If not, create a new conversation.
848 if (!p_conv || p_conv->setup_frame != setup_frame_number) {
849 p_conv = conversation_new(setup_frame_number, addr, &null_addr, PT_BLUETOOTH, 0, 0,
850 NO_ADDR2 | NO_PORT2);
854 conversation_set_dissector(p_conv, rtp_handle);
857 * Check if the conversation has data associated with it.
859 p_conv_data = (struct _rtp_conversation_info *)conversation_get_proto_data(p_conv, proto_rtp);
862 * If not, add a new data item.
865 /* Create conversation data */
866 p_conv_data = wmem_new(wmem_file_scope(), struct _rtp_conversation_info);
867 p_conv_data->rtp_dyn_payload = NULL;
869 /* start this at 0x10000 so that we cope gracefully with the
870 * first few packets being out of order (hence 0,65535,1,2,...)
872 p_conv_data->extended_seqno = 0x10000;
873 p_conv_data->rtp_conv_info = wmem_new(wmem_file_scope(), rtp_private_conv_info);
874 p_conv_data->rtp_conv_info->multisegment_pdus = wmem_tree_new(wmem_file_scope());
875 conversation_add_proto_data(p_conv, proto_rtp, p_conv_data);
878 p_conv_data->bta2dp_info = NULL;
879 p_conv_data->btvdp_info = (btvdp_codec_info_t *) wmem_memdup(wmem_file_scope(), data, sizeof(btvdp_codec_info_t));
881 p_conv_data->bta2dp_info = (bta2dp_codec_info_t *) wmem_memdup(wmem_file_scope(), data, sizeof(bta2dp_codec_info_t));
882 p_conv_data->btvdp_info = NULL;
887 * Update the conversation data.
889 /* Free the hash if already exists */
890 rtp_free_hash_dyn_payload(p_conv_data->rtp_dyn_payload);
892 g_strlcpy(p_conv_data->method, setup_method, MAX_RTP_SETUP_METHOD_SIZE+1);
893 p_conv_data->frame_number = setup_frame_number;
894 p_conv_data->is_video = is_video;
895 p_conv_data->rtp_dyn_payload = NULL;
896 p_conv_data->srtp_info = NULL;
899 /* Set up an SRTP conversation */
901 srtp_add_address(packet_info *pinfo, address *addr, int port, int other_port,
902 const gchar *setup_method, guint32 setup_frame_number,
903 gboolean is_video _U_, GHashTable *rtp_dyn_payload,
904 struct srtp_info *srtp_info)
907 conversation_t* p_conv;
908 struct _rtp_conversation_info *p_conv_data = NULL;
911 * If this isn't the first time this packet has been processed,
912 * we've already done this work, so we don't need to do it
915 if (pinfo->fd->flags.visited)
921 printf("#%u: %srtp_add_address(%s, %u, %u, %s, %u\n",
922 pinfo->fd->num, (srtp_info)?"s":"", ep_address_to_str(addr), port,
923 other_port, setup_method, setup_frame_number);
926 SET_ADDRESS(&null_addr, AT_NONE, 0, NULL);
929 * Check if the ip address and port combination is not
930 * already registered as a conversation.
932 p_conv = find_conversation(setup_frame_number, addr, &null_addr, PT_UDP, port, other_port,
933 NO_ADDR_B | (!other_port ? NO_PORT_B : 0));
936 * If not, create a new conversation.
938 if (!p_conv || p_conv->setup_frame != setup_frame_number) {
939 p_conv = conversation_new(setup_frame_number, addr, &null_addr, PT_UDP,
940 (guint32)port, (guint32)other_port,
941 NO_ADDR2 | (!other_port ? NO_PORT2 : 0));
945 conversation_set_dissector(p_conv, rtp_handle);
948 * Check if the conversation has data associated with it.
950 p_conv_data = (struct _rtp_conversation_info *)conversation_get_proto_data(p_conv, proto_rtp);
953 * If not, add a new data item.
956 /* Create conversation data */
957 p_conv_data = wmem_new(wmem_file_scope(), struct _rtp_conversation_info);
958 p_conv_data->rtp_dyn_payload = NULL;
960 /* start this at 0x10000 so that we cope gracefully with the
961 * first few packets being out of order (hence 0,65535,1,2,...)
963 p_conv_data->extended_seqno = 0x10000;
964 p_conv_data->rtp_conv_info = wmem_new(wmem_file_scope(), rtp_private_conv_info);
965 p_conv_data->rtp_conv_info->multisegment_pdus = wmem_tree_new(wmem_file_scope());
966 conversation_add_proto_data(p_conv, proto_rtp, p_conv_data);
970 * Update the conversation data.
972 /* Free the hash if already exists */
973 rtp_free_hash_dyn_payload(p_conv_data->rtp_dyn_payload);
975 g_strlcpy(p_conv_data->method, setup_method, MAX_RTP_SETUP_METHOD_SIZE+1);
976 p_conv_data->frame_number = setup_frame_number;
977 p_conv_data->is_video = is_video;
978 p_conv_data->rtp_dyn_payload = rtp_dyn_payload;
979 p_conv_data->srtp_info = srtp_info;
980 p_conv_data->bta2dp_info = NULL;
981 p_conv_data->btvdp_info = NULL;
984 /* Set up an RTP conversation */
986 rtp_add_address(packet_info *pinfo, address *addr, int port, int other_port,
987 const gchar *setup_method, guint32 setup_frame_number,
988 gboolean is_video , GHashTable *rtp_dyn_payload)
990 srtp_add_address(pinfo, addr, port, other_port, setup_method, setup_frame_number, is_video, rtp_dyn_payload, NULL);
994 dissect_rtp_heur_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data, gboolean check_destport)
997 unsigned int version;
998 unsigned int offset = 0;
1000 /* This is a heuristic dissector, which means we get all the UDP
1001 * traffic not sent to a known dissector and not claimed by
1002 * a heuristic dissector called before us!
1005 if (! global_rtp_heur)
1008 /* Get the fields in the first octet */
1009 octet1 = tvb_get_guint8( tvb, offset );
1010 version = RTP_VERSION( octet1 );
1013 if (!(tvb_memeql(tvb, 4, "ZRTP", 4)))
1015 call_dissector_only(zrtp_handle, tvb, pinfo, tree, NULL);
1018 switch (global_rtp_version0_type) {
1020 return call_dissector_only(stun_heur_handle, tvb, pinfo, tree, NULL);
1021 case RTP0_CLASSICSTUN:
1022 return call_dissector_only(classicstun_heur_handle, tvb, pinfo, tree, NULL);
1025 /* XXX: Should really be calling a heuristic dissector for T38 ??? */
1026 call_dissector_only(t38_handle, tvb, pinfo, tree, NULL);
1030 call_dissector_only(sprt_handle, tvb, pinfo, tree, NULL);
1036 return FALSE; /* Unknown or unsupported version */
1039 } else if (version != 2) {
1040 /* Unknown or unsupported version */
1044 /* Was it sent to an even-numbered port? */
1045 if (check_destport && ((pinfo->destport % 2) != 0)) {
1049 dissect_rtp( tvb, pinfo, tree, data );
1054 dissect_rtp_heur_udp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data )
1056 return dissect_rtp_heur_common(tvb, pinfo, tree, data, TRUE);
1060 dissect_rtp_heur_stun( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data )
1062 return dissect_rtp_heur_common(tvb, pinfo, tree, data, FALSE);
1066 * Process the payload of the RTP packet, hand it to the subdissector
1069 process_rtp_payload(tvbuff_t *newtvb, packet_info *pinfo, proto_tree *tree,
1070 proto_tree *rtp_tree, unsigned int payload_type)
1072 struct _rtp_conversation_info *p_conv_data = NULL;
1073 gboolean found_match = FALSE;
1075 struct srtp_info *srtp_info;
1078 payload_len = tvb_length_remaining(newtvb, offset);
1080 /* first check if this is added as an SRTP stream - if so, don't try to dissector the payload data for now */
1081 p_conv_data = (struct _rtp_conversation_info *)p_get_proto_data(pinfo->fd, proto_rtp, 0);
1082 if (p_conv_data && p_conv_data->srtp_info) {
1083 srtp_info = p_conv_data->srtp_info;
1084 payload_len -= srtp_info->mki_len + srtp_info->auth_tag_len;
1086 #error Currently the srtp_info structure contains no cipher data, see packet-sdp.c adding dummy_srtp_info structure
1087 if (p_conv_data->srtp_info->encryption_algorithm==SRTP_ENC_ALG_NULL) {
1089 proto_tree_add_text(rtp_tree, newtvb, offset, payload_len, "SRTP Payload with NULL encryption");
1095 proto_tree_add_item(rtp_tree, hf_srtp_encrypted_payload, newtvb, offset, payload_len, ENC_NA);
1096 found_match = TRUE; /* use this flag to prevent dissection below */
1098 offset += payload_len;
1100 if (srtp_info->mki_len) {
1101 proto_tree_add_item(rtp_tree, hf_srtp_mki, newtvb, offset, srtp_info->mki_len, ENC_NA);
1102 offset += srtp_info->mki_len;
1105 if (srtp_info->auth_tag_len) {
1106 proto_tree_add_item(rtp_tree, hf_srtp_auth_tag, newtvb, offset, srtp_info->auth_tag_len, ENC_NA);
1107 /*offset += srtp_info->auth_tag_len;*/
1109 } else if (p_conv_data && !p_conv_data->bta2dp_info && !p_conv_data->btvdp_info &&
1110 payload_type >= PT_UNDF_96 && payload_type <= PT_UNDF_127) {
1111 /* if the payload type is dynamic, we check if the conv is set and we look for the pt definition */
1112 if (p_conv_data && p_conv_data->rtp_dyn_payload) {
1113 gchar *payload_type_str = NULL;
1114 encoding_name_and_rate_t *encoding_name_and_rate_pt = NULL;
1115 encoding_name_and_rate_pt = (encoding_name_and_rate_t *)g_hash_table_lookup(p_conv_data->rtp_dyn_payload, &payload_type);
1116 if (encoding_name_and_rate_pt) {
1117 payload_type_str = encoding_name_and_rate_pt->encoding_name;
1119 if (payload_type_str){
1120 found_match = dissector_try_string(rtp_dyn_pt_dissector_table,
1121 payload_type_str, newtvb, pinfo, tree, NULL);
1122 /* If payload type string set from conversation and
1123 * no matching dissector found it's probably because no subdissector
1124 * exists. Don't call the dissectors based on payload number
1125 * as that'd probably be the wrong dissector in this case.
1126 * Just add it as data.
1128 if(found_match==FALSE)
1129 proto_tree_add_item( rtp_tree, hf_rtp_data, newtvb, 0, -1, ENC_NA );
1134 } else if (p_conv_data && p_conv_data->bta2dp_info) {
1140 if (p_conv_data->bta2dp_info->content_protection_type == BTAVDTP_CONTENT_PROTECTION_TYPE_SCMS_T) {
1141 nexttvb = tvb_new_subset(newtvb, 0, 1, 1);
1142 call_dissector(bta2dp_content_protection_header_scms_t, nexttvb, pinfo, tree);
1146 nexttvb = tvb_new_subset_remaining(newtvb, suboffset);
1147 if (p_conv_data->bta2dp_info->codec_dissector)
1148 call_dissector(p_conv_data->bta2dp_info->codec_dissector, nexttvb, pinfo, tree);
1150 call_dissector(data_handle, nexttvb, pinfo, tree);
1151 } else if (p_conv_data && p_conv_data->btvdp_info) {
1157 if (p_conv_data->btvdp_info->content_protection_type == BTAVDTP_CONTENT_PROTECTION_TYPE_SCMS_T) {
1158 nexttvb = tvb_new_subset(newtvb, 0, 1, 1);
1159 call_dissector(bta2dp_content_protection_header_scms_t, nexttvb, pinfo, tree);
1163 nexttvb = tvb_new_subset_remaining(newtvb, suboffset);
1164 if (p_conv_data->btvdp_info->codec_dissector)
1165 call_dissector(p_conv_data->btvdp_info->codec_dissector, nexttvb, pinfo, tree);
1167 call_dissector(data_handle, nexttvb, pinfo, tree);
1170 /* if we don't found, it is static OR could be set static from the preferences */
1171 if (!found_match && !dissector_try_uint(rtp_pt_dissector_table, payload_type, newtvb, pinfo, tree))
1172 proto_tree_add_item( rtp_tree, hf_rtp_data, newtvb, 0, -1, ENC_NA );
1176 /* Rtp payload reassembly
1178 * This handles the reassembly of PDUs for higher-level protocols.
1180 * We're a bit limited on how we can cope with out-of-order packets, because
1181 * we don't have any idea of where the datagram boundaries are. So if we see
1182 * packets A, C, B (all of which comprise a single datagram), we cannot know
1183 * that C should be added to the same datagram as A, until we come to B (which
1184 * may or may not actually be present...).
1186 * What we end up doing in this case is passing A+B to the subdissector as one
1187 * datagram, and make out that a new one starts on C.
1190 dissect_rtp_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1191 proto_tree *rtp_tree, int offset, unsigned int data_len,
1192 unsigned int data_reported_len,
1193 unsigned int payload_type)
1196 struct _rtp_conversation_info *p_conv_data= NULL;
1197 gboolean must_desegment = FALSE;
1198 rtp_private_conv_info *finfo = NULL;
1199 rtp_multisegment_pdu *msp = NULL;
1202 /* Retrieve RTPs idea of a converation */
1203 p_conv_data = (struct _rtp_conversation_info *)p_get_proto_data(pinfo->fd, proto_rtp, 0);
1205 if(p_conv_data != NULL)
1206 finfo = p_conv_data->rtp_conv_info;
1208 if(finfo == NULL || !desegment_rtp) {
1209 /* Hand the whole lot off to the subdissector */
1210 newtvb=tvb_new_subset(tvb,offset,data_len,data_reported_len);
1211 process_rtp_payload(newtvb, pinfo, tree, rtp_tree, payload_type);
1215 seqno = p_conv_data->extended_seqno;
1217 pinfo->can_desegment = 2;
1218 pinfo->desegment_offset = 0;
1219 pinfo->desegment_len = 0;
1221 #ifdef DEBUG_FRAGMENTS
1222 g_debug("%d: RTP Part of convo %d(%p); seqno %d",
1224 p_conv_data->frame_number, p_conv_data,
1229 /* look for a pdu which we might be extending */
1230 msp = (rtp_multisegment_pdu *)wmem_tree_lookup32_le(finfo->multisegment_pdus,seqno-1);
1232 if(msp && msp->startseq < seqno && msp->endseq >= seqno) {
1233 guint32 fid = msp->startseq;
1234 fragment_head *fd_head;
1236 #ifdef DEBUG_FRAGMENTS
1237 g_debug("\tContinues fragment %d", fid);
1240 /* we always assume the datagram is complete; if this is the
1241 * first pass, that's our best guess, and if it's not, what we
1242 * say gets ignored anyway.
1244 fd_head = fragment_add_seq(&rtp_reassembly_table,
1245 tvb, offset, pinfo, fid, NULL,
1246 seqno-msp->startseq, data_len,
1249 newtvb = process_reassembled_data(tvb,offset, pinfo, "Reassembled RTP", fd_head,
1250 &rtp_fragment_items, NULL, tree);
1252 #ifdef DEBUG_FRAGMENTS
1253 g_debug("\tFragment Coalesced; fd_head=%p, newtvb=%p (len %d)",fd_head, newtvb,
1254 newtvb?tvb_reported_length(newtvb):0);
1257 if(newtvb != NULL) {
1258 /* Hand off to the subdissector */
1259 process_rtp_payload(newtvb, pinfo, tree, rtp_tree, payload_type);
1262 * Check to see if there were any complete fragments within the chunk
1264 if( pinfo->desegment_len && pinfo->desegment_offset == 0 )
1266 #ifdef DEBUG_FRAGMENTS
1267 g_debug("\tNo complete pdus in payload" );
1269 /* Mark the fragments and not complete yet */
1270 fragment_set_partial_reassembly(&rtp_reassembly_table,
1273 /* we must need another segment */
1274 msp->endseq = MIN(msp->endseq,seqno) + 1;
1278 if(pinfo->desegment_len)
1280 /* the higher-level dissector has asked for some more data - ie,
1281 the end of this segment does not coincide with the end of a
1282 higher-level PDU. */
1283 must_desegment = TRUE;
1293 * The segment is not the continuation of a fragmented segment
1294 * so process it as normal
1296 #ifdef DEBUG_FRAGMENTS
1297 g_debug("\tRTP non-fragment payload");
1299 newtvb = tvb_new_subset( tvb, offset, data_len, data_reported_len );
1301 /* Hand off to the subdissector */
1302 process_rtp_payload(newtvb, pinfo, tree, rtp_tree, payload_type);
1304 if(pinfo->desegment_len) {
1305 /* the higher-level dissector has asked for some more data - ie,
1306 the end of this segment does not coincide with the end of a
1307 higher-level PDU. */
1308 must_desegment = TRUE;
1313 * There were bytes left over that the higher protocol couldn't dissect so save them
1317 guint32 deseg_offset = pinfo->desegment_offset;
1318 guint32 frag_len = tvb_reported_length_remaining(newtvb, deseg_offset);
1319 fragment_head *fd_head = NULL;
1321 #ifdef DEBUG_FRAGMENTS
1322 g_debug("\tRTP Must Desegment: tvb_len=%d ds_len=%d %d frag_len=%d ds_off=%d",
1323 tvb_reported_length(newtvb),
1324 pinfo->desegment_len,
1325 pinfo->fd->flags.visited,
1329 /* allocate a new msp for this pdu */
1330 msp = wmem_new(wmem_file_scope(), rtp_multisegment_pdu);
1331 msp->startseq = seqno;
1332 msp->endseq = seqno+1;
1333 wmem_tree_insert32(finfo->multisegment_pdus,seqno,msp);
1336 * Add the fragment to the fragment table
1338 fd_head = fragment_add_seq(&rtp_reassembly_table,
1339 newtvb, deseg_offset, pinfo, seqno, NULL, 0, frag_len,
1344 if( fd_head->reassembled_in != 0 && !(fd_head->flags & FD_PARTIAL_REASSEMBLY) )
1346 proto_item *rtp_tree_item;
1347 rtp_tree_item = proto_tree_add_uint( tree, hf_rtp_reassembled_in,
1348 newtvb, deseg_offset, tvb_reported_length_remaining(newtvb,deseg_offset),
1349 fd_head->reassembled_in);
1350 PROTO_ITEM_SET_GENERATED(rtp_tree_item);
1351 #ifdef DEBUG_FRAGMENTS
1352 g_debug("\tReassembled in %d", fd_head->reassembled_in);
1357 #ifdef DEBUG_FRAGMENTS
1358 g_debug("\tUnfinished fragment");
1360 /* this fragment is never reassembled */
1361 proto_tree_add_text( tree, tvb, deseg_offset, -1,"RTP fragment, unfinished");
1367 * This fragment was the first fragment in a new entry in the
1368 * frag_table; we don't yet know where it is reassembled
1370 #ifdef DEBUG_FRAGMENTS
1371 g_debug("\tnew pdu");
1375 if( pinfo->desegment_offset == 0 )
1377 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP");
1378 col_set_str(pinfo->cinfo, COL_INFO, "[RTP segment of a reassembled PDU]");
1382 pinfo->can_desegment = 0;
1383 pinfo->desegment_offset = 0;
1384 pinfo->desegment_len = 0;
1390 dissect_rtp_rfc2198(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1395 gboolean hdr_follow = TRUE;
1396 proto_item *ti = NULL;
1397 proto_tree *rfc2198_tree = NULL;
1398 proto_tree *rfc2198_hdr_tree = NULL;
1399 rfc2198_hdr *hdr_last, *hdr_new;
1400 rfc2198_hdr *hdr_chain = NULL;
1401 struct _rtp_conversation_info *p_conv_data= NULL;
1402 gchar *payload_type_str;
1404 /* Retrieve RTPs idea of a converation */
1405 p_conv_data = (struct _rtp_conversation_info *)p_get_proto_data(pinfo->fd, proto_rtp, 0);
1407 /* Add try to RFC 2198 data */
1408 ti = proto_tree_add_text(tree, tvb, offset, -1, "RFC 2198: Redundant Audio Data");
1409 rfc2198_tree = proto_item_add_subtree(ti, ett_rtp_rfc2198);
1413 while (hdr_follow) {
1415 payload_type_str = NULL;
1417 /* Allocate and fill in header */
1418 hdr_new = wmem_new(wmem_packet_scope(), rfc2198_hdr);
1419 hdr_new->next = NULL;
1420 octet1 = tvb_get_guint8(tvb, offset);
1421 hdr_new->pt = RTP_PAYLOAD_TYPE(octet1);
1422 hdr_follow = (octet1 & 0x80);
1424 /* if it is dynamic payload, let use the conv data to see if it is defined */
1425 if ((hdr_new->pt > 95) && (hdr_new->pt < 128)) {
1426 if (p_conv_data && p_conv_data->rtp_dyn_payload){
1427 encoding_name_and_rate_t *encoding_name_and_rate_pt = NULL;
1428 encoding_name_and_rate_pt = (encoding_name_and_rate_t *)g_hash_table_lookup(p_conv_data->rtp_dyn_payload, &hdr_new->pt);
1429 if (encoding_name_and_rate_pt) {
1430 payload_type_str = encoding_name_and_rate_pt->encoding_name;
1434 /* Add a subtree for this header and add items */
1435 ti = proto_tree_add_text(rfc2198_tree, tvb, offset, (hdr_follow)?4:1, "Header %u", cnt);
1436 rfc2198_hdr_tree = proto_item_add_subtree(ti, ett_rtp_rfc2198_hdr);
1437 proto_tree_add_item(rfc2198_hdr_tree, hf_rtp_rfc2198_follow, tvb, offset, 1, ENC_BIG_ENDIAN );
1438 proto_tree_add_uint_format_value(rfc2198_hdr_tree, hf_rtp_payload_type, tvb,
1439 offset, 1, octet1, "%s (%u)",
1440 payload_type_str ? payload_type_str : val_to_str_ext_const(hdr_new->pt, &rtp_payload_type_vals_ext, "Unknown"),
1442 proto_item_append_text(ti, ": PT=%s",
1443 payload_type_str ? payload_type_str :
1444 val_to_str_ext(hdr_new->pt, &rtp_payload_type_vals_ext, "Unknown (%u)"));
1447 /* Timestamp offset and block length don't apply to last header */
1449 proto_tree_add_item(rfc2198_hdr_tree, hf_rtp_rfc2198_tm_off, tvb, offset, 2, ENC_BIG_ENDIAN );
1450 proto_tree_add_item(rfc2198_hdr_tree, hf_rtp_rfc2198_bl_len, tvb, offset + 1, 2, ENC_BIG_ENDIAN );
1451 hdr_new->len = tvb_get_ntohs(tvb, offset + 1) & 0x03FF;
1452 proto_item_append_text(ti, ", len=%u", hdr_new->len);
1460 hdr_last->next = hdr_new;
1462 hdr_chain = hdr_new;
1467 /* Dissect each data block according to the header info */
1468 hdr_last = hdr_chain;
1470 hdr_last->offset = offset;
1471 if (!hdr_last->next) {
1472 hdr_last->len = tvb_reported_length_remaining(tvb, offset);
1474 dissect_rtp_data(tvb, pinfo, tree, rfc2198_tree, hdr_last->offset, hdr_last->len, hdr_last->len, hdr_last->pt);
1475 offset += hdr_last->len;
1476 hdr_last = hdr_last->next;
1481 dissect_rtp_hext_rfc5215_onebyte( tvbuff_t *tvb, packet_info *pinfo,
1482 proto_tree *rtp_hext_tree )
1484 proto_item *ti = NULL;
1485 proto_tree *rtp_hext_rfc5285_tree = NULL;
1486 guint ext_offset = 0, start_ext_offset;
1488 while (ext_offset < tvb_length (tvb)) {
1492 tvbuff_t *subtvb = NULL;
1494 /* Skip bytes with the value 0, they are padding */
1495 start_ext_offset = ext_offset;
1496 while (tvb_get_guint8 (tvb, ext_offset) == 0) {
1498 if (ext_offset >= tvb_length (tvb))
1503 if (ext_offset > start_ext_offset)
1504 proto_tree_add_item(rtp_hext_tree, hf_rtp_padding_data, tvb, ext_offset, ext_offset-start_ext_offset, ENC_NA );
1506 ext_hdr_hdr = tvb_get_guint8 (tvb, ext_offset);
1507 ext_id = ext_hdr_hdr >> 4;
1509 /* 15 is for future extensibility, ignore length, etc and stop processing packet if it shows up */
1513 ext_length = (ext_hdr_hdr & 0x0F) + 1;
1514 if (rtp_hext_tree) {
1515 ti = proto_tree_add_text(rtp_hext_tree, tvb, ext_offset, ext_length + 1, "RFC 5285 Header Extension (One-Byte Header)");
1516 rtp_hext_rfc5285_tree = proto_item_add_subtree( ti, ett_hdr_ext_rfc5285);
1518 proto_tree_add_uint( rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_id, tvb, ext_offset, 1, ext_id);
1519 proto_tree_add_uint( rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_length, tvb, ext_offset, 1, ext_length);
1523 subtvb = tvb_new_subset(tvb, ext_offset, ext_length, ext_length);
1524 if (!dissector_try_uint (rtp_hdr_ext_rfc5285_dissector_table, ext_id, subtvb, pinfo, rtp_hext_rfc5285_tree)) {
1526 proto_tree_add_item(rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_data, subtvb, 0, ext_length, ENC_NA );
1529 ext_offset += ext_length;
1535 dissect_rtp_hext_rfc5215_twobytes(tvbuff_t *parent_tvb, guint id_offset,
1536 guint8 id, tvbuff_t *tvb, packet_info *pinfo, proto_tree *rtp_hext_tree)
1538 proto_item *ti = NULL;
1539 proto_tree *rtp_hext_rfc5285_tree = NULL;
1540 guint ext_offset = 0, start_ext_offset;
1542 while (ext_offset + 2 < tvb_length (tvb)) {
1545 tvbuff_t *subtvb = NULL;
1547 /* Skip bytes with the value 0, they are padding */
1548 start_ext_offset = ext_offset;
1549 while (tvb_get_guint8 (tvb, ext_offset) == 0) {
1550 if (ext_offset + 2 >= tvb_length (tvb))
1555 if (ext_offset > start_ext_offset)
1556 proto_tree_add_item(rtp_hext_tree, hf_rtp_padding_data, tvb, ext_offset, ext_offset-start_ext_offset, ENC_NA );
1558 ext_id = tvb_get_guint8 (tvb, ext_offset);
1559 ext_length = tvb_get_guint8 (tvb, ext_offset + 1);
1561 if (rtp_hext_tree) {
1562 ti = proto_tree_add_text(rtp_hext_tree, tvb, ext_offset, ext_length + 2, "RFC 5285 Header Extension (Two-Byte Header)");
1563 rtp_hext_rfc5285_tree = proto_item_add_subtree( ti, ett_hdr_ext_rfc5285);
1565 proto_tree_add_uint( rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_appbits, parent_tvb, id_offset + 1, 1, id & 0x000F);
1566 proto_tree_add_uint( rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_id, tvb, ext_offset, 1, ext_id);
1567 proto_tree_add_uint( rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_length, tvb, ext_offset + 1, 1, ext_length);
1572 subtvb = tvb_new_subset(tvb, ext_offset, ext_length, ext_length);
1573 if (ext_length && !dissector_try_uint (rtp_hdr_ext_rfc5285_dissector_table, ext_id, subtvb, pinfo, rtp_hext_rfc5285_tree)) {
1574 proto_tree_add_item(rtp_hext_rfc5285_tree, hf_rtp_ext_rfc5285_data, subtvb, 0, ext_length, ENC_NA );
1577 ext_offset += ext_length;
1582 dissect_rtp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1584 proto_item *ti = NULL;
1585 proto_tree *volatile rtp_tree = NULL;
1586 proto_tree *rtp_csrc_tree = NULL;
1587 proto_tree *rtp_hext_tree = NULL;
1588 guint8 octet1, octet2;
1589 unsigned int version;
1590 gboolean padding_set;
1591 gboolean extension_set;
1592 unsigned int csrc_count;
1593 gboolean marker_set;
1594 unsigned int payload_type;
1595 gchar *payload_type_str = NULL;
1596 gboolean is_srtp = FALSE;
1598 unsigned int hdr_extension_len= 0;
1599 unsigned int hdr_extension_id = 0;
1600 volatile unsigned int padding_count;
1601 gint length, reported_length;
1603 volatile unsigned int offset = 0;
1608 struct _rtp_conversation_info *p_conv_data = NULL;
1609 /*struct srtp_info *srtp_info = NULL;*/
1610 /*unsigned int srtp_offset;*/
1611 unsigned int hdrext_offset = 0;
1612 tvbuff_t *newtvb = NULL;
1613 const char *pt = NULL;
1614 /* Can tap up to 4 RTP packets within same packet */
1615 static struct _rtp_info rtp_info_arr[4];
1616 static int rtp_info_current=0;
1617 struct _rtp_info *rtp_info;
1620 if (rtp_info_current==4) {
1623 rtp_info = &rtp_info_arr[rtp_info_current];
1625 /* Get the fields in the first octet */
1626 octet1 = tvb_get_guint8( tvb, offset );
1627 version = RTP_VERSION( octet1 );
1630 switch (global_rtp_version0_type) {
1632 call_dissector(stun_handle, tvb, pinfo, tree);
1633 return tvb_length(tvb);
1634 case RTP0_CLASSICSTUN:
1635 call_dissector(classicstun_handle, tvb, pinfo, tree);
1636 return tvb_length(tvb);
1639 call_dissector(t38_handle, tvb, pinfo, tree);
1640 return tvb_length(tvb);
1643 call_dissector(sprt_handle, tvb, pinfo, tree);
1644 return tvb_length(tvb);
1647 if (!(tvb_memeql(tvb, 4, "ZRTP", 4)))
1649 call_dissector(zrtp_handle,tvb,pinfo,tree);
1650 return tvb_length(tvb);
1653 ; /* Unknown or unsupported version (let it fall through) */
1657 /* fill in the rtp_info structure */
1658 rtp_info->info_version = version;
1661 * Unknown or unsupported version.
1663 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTP");
1665 col_add_fstr( pinfo->cinfo, COL_INFO,
1666 "Unknown RTP version %u", version);
1669 ti = proto_tree_add_item( tree, proto_rtp, tvb, offset, -1, ENC_NA );
1670 rtp_tree = proto_item_add_subtree( ti, ett_rtp );
1672 proto_tree_add_uint( rtp_tree, hf_rtp_version, tvb,
1678 padding_set = RTP_PADDING( octet1 );
1679 extension_set = RTP_EXTENSION( octet1 );
1680 csrc_count = RTP_CSRC_COUNT( octet1 );
1682 /* Get the fields in the second octet */
1683 octet2 = tvb_get_guint8( tvb, offset + 1 );
1684 marker_set = RTP_MARKER( octet2 );
1685 payload_type = RTP_PAYLOAD_TYPE( octet2 );
1687 /* Get the subsequent fields */
1688 seq_num = tvb_get_ntohs( tvb, offset + 2 );
1689 timestamp = tvb_get_ntohl( tvb, offset + 4 );
1690 sync_src = tvb_get_ntohl( tvb, offset + 8 );
1692 /* fill in the rtp_info structure */
1693 rtp_info->info_padding_set = padding_set;
1694 rtp_info->info_padding_count = 0;
1695 rtp_info->info_marker_set = marker_set;
1696 rtp_info->info_is_video = FALSE;
1697 rtp_info->info_payload_type = payload_type;
1698 rtp_info->info_seq_num = seq_num;
1699 rtp_info->info_timestamp = timestamp;
1700 rtp_info->info_sync_src = sync_src;
1701 rtp_info->info_is_srtp = FALSE;
1702 rtp_info->info_setup_frame_num = 0;
1703 rtp_info->info_payload_type_str = NULL;
1704 rtp_info->info_payload_rate = 0;
1707 * Do we have all the data?
1709 length = tvb_length_remaining(tvb, offset);
1710 reported_length = tvb_reported_length_remaining(tvb, offset);
1711 if (reported_length >= 0 && length >= reported_length) {
1715 rtp_info->info_all_data_present = TRUE;
1716 rtp_info->info_data_len = reported_length;
1719 * Save the pointer to raw rtp data (header + payload incl.
1721 * That should be safe because the "epan_dissect_t"
1722 * constructed for the packet has not yet been freed when
1723 * the taps are called.
1724 * (Destroying the "epan_dissect_t" will end up freeing
1725 * all the tvbuffs and hence invalidating pointers to
1727 * See "add_packet_to_packet_list()" for details.
1729 rtp_info->info_data = tvb_get_ptr(tvb, 0, -1);
1732 * No - packet was cut short at capture time.
1734 rtp_info->info_all_data_present = FALSE;
1735 rtp_info->info_data_len = 0;
1736 rtp_info->info_data = NULL;
1739 /* Look for conv and add to the frame if found */
1740 get_conv_info(pinfo, rtp_info);
1741 p_conv_data = (struct _rtp_conversation_info *)p_get_proto_data(pinfo->fd, proto_rtp, 0);
1744 rtp_info->info_is_video = p_conv_data->is_video;
1746 if (p_conv_data && p_conv_data->srtp_info) is_srtp = TRUE;
1747 rtp_info->info_is_srtp = is_srtp;
1749 col_set_str( pinfo->cinfo, COL_PROTOCOL, (is_srtp) ? "SRTP" : "RTP" );
1751 /* check if this is added as an SRTP stream - if so, don't try to dissect the payload data for now */
1752 p_conv_data = (struct _rtp_conversation_info *)p_get_proto_data(pinfo->fd, proto_rtp, 0);
1754 #if 0 /* XXX: srtp_offset never actually used ?? */
1755 if (p_conv_data && p_conv_data->srtp_info) {
1756 srtp_info = p_conv_data->srtp_info;
1757 if (rtp_info->info_all_data_present) {
1758 srtp_offset = rtp_info->info_data_len - srtp_info->mki_len - srtp_info->auth_tag_len;
1763 if (p_conv_data && p_conv_data->bta2dp_info && p_conv_data->bta2dp_info->codec_dissector) {
1764 rtp_info->info_payload_type_str = (const char *) dissector_handle_get_short_name(p_conv_data->bta2dp_info->codec_dissector);
1765 } else if (p_conv_data && p_conv_data->btvdp_info && p_conv_data->btvdp_info->codec_dissector) {
1766 rtp_info->info_payload_type_str = (const char *) dissector_handle_get_short_name(p_conv_data->btvdp_info->codec_dissector);
1769 /* if it is dynamic payload, let use the conv data to see if it is defined */
1770 if ( (payload_type>95) && (payload_type<128) ) {
1771 if (p_conv_data && p_conv_data->rtp_dyn_payload){
1772 encoding_name_and_rate_t *encoding_name_and_rate_pt = NULL;
1773 encoding_name_and_rate_pt = (encoding_name_and_rate_t *)g_hash_table_lookup(p_conv_data->rtp_dyn_payload, &payload_type);
1774 if (encoding_name_and_rate_pt) {
1775 rtp_info->info_payload_type_str = payload_type_str = encoding_name_and_rate_pt->encoding_name;
1776 rtp_info->info_payload_rate = encoding_name_and_rate_pt->sample_rate;
1781 if (p_conv_data && p_conv_data->bta2dp_info) {
1782 pt = (p_conv_data->bta2dp_info->codec_dissector) ? dissector_handle_get_short_name(p_conv_data->bta2dp_info->codec_dissector) : "Unknown";
1783 } else if (p_conv_data && p_conv_data->btvdp_info) {
1784 pt = (p_conv_data->btvdp_info->codec_dissector) ? dissector_handle_get_short_name(p_conv_data->btvdp_info->codec_dissector) : "Unknown";
1786 pt = (payload_type_str ? payload_type_str : val_to_str_ext(payload_type, &rtp_payload_type_vals_ext,"Unknown (%u)"));
1789 col_add_fstr( pinfo->cinfo, COL_INFO,
1790 "PT=%s, SSRC=0x%X, Seq=%u, Time=%u%s",
1795 marker_set ? ", Mark" : "");
1799 /* Create RTP protocol tree */
1800 ti = proto_tree_add_item(tree, proto_rtp, tvb, offset, -1, ENC_NA );
1801 rtp_tree = proto_item_add_subtree(ti, ett_rtp );
1803 /* Conversation setup info */
1804 if (global_rtp_show_setup_info)
1806 show_setup_info(tvb, pinfo, rtp_tree);
1809 proto_tree_add_uint( rtp_tree, hf_rtp_version, tvb,
1810 offset, 1, octet1 );
1811 proto_tree_add_boolean( rtp_tree, hf_rtp_padding, tvb,
1812 offset, 1, octet1 );
1813 proto_tree_add_boolean( rtp_tree, hf_rtp_extension, tvb,
1814 offset, 1, octet1 );
1815 proto_tree_add_uint( rtp_tree, hf_rtp_csrc_count, tvb,
1816 offset, 1, octet1 );
1819 proto_tree_add_boolean( rtp_tree, hf_rtp_marker, tvb, offset,
1822 proto_tree_add_uint_format( rtp_tree, hf_rtp_payload_type, tvb,
1823 offset, 1, octet2, "Payload type: %s (%u)", pt, payload_type);
1827 /* Sequence number 16 bits (2 octets) */
1828 proto_tree_add_uint( rtp_tree, hf_rtp_seq_nr, tvb, offset, 2, seq_num );
1829 if(p_conv_data != NULL) {
1830 item = proto_tree_add_uint( rtp_tree, hf_rtp_ext_seq_nr, tvb, offset, 2, p_conv_data->extended_seqno );
1831 PROTO_ITEM_SET_GENERATED(item);
1835 /* Timestamp 32 bits (4 octets) */
1836 proto_tree_add_uint( rtp_tree, hf_rtp_timestamp, tvb, offset, 4, timestamp );
1839 /* Synchronization source identifier 32 bits (4 octets) */
1840 proto_tree_add_uint( rtp_tree, hf_rtp_ssrc, tvb, offset, 4, sync_src );
1846 if ( csrc_count > 0 ) {
1847 ti = proto_tree_add_item(rtp_tree, hf_rtp_csrc_items, tvb, offset,
1848 csrc_count * 4, ENC_NA);
1849 proto_item_append_text(ti, " (%u items)", csrc_count);
1850 rtp_csrc_tree = proto_item_add_subtree( ti, ett_csrc_list );
1852 for (i = 0; i < csrc_count; i++ ) {
1853 csrc_item = tvb_get_ntohl( tvb, offset );
1854 proto_tree_add_uint_format( rtp_csrc_tree,
1855 hf_rtp_csrc_item, tvb, offset, 4,
1857 "CSRC item %d: 0x%X",
1863 /* Optional RTP header extension */
1864 if ( extension_set ) {
1865 /* Defined by profile field is 16 bits (2 octets) */
1866 hdr_extension_id = tvb_get_ntohs( tvb, offset );
1867 if ( tree ) proto_tree_add_uint( rtp_tree, hf_rtp_prof_define, tvb, offset, 2, hdr_extension_id );
1870 hdr_extension_len = tvb_get_ntohs( tvb, offset );
1871 if ( tree ) proto_tree_add_uint( rtp_tree, hf_rtp_length, tvb, offset, 2, hdr_extension_len);
1873 if ( hdr_extension_len > 0 ) {
1875 ti = proto_tree_add_item(rtp_tree, hf_rtp_hdr_exts, tvb, offset, hdr_extension_len * 4, ENC_NA);
1876 rtp_hext_tree = proto_item_add_subtree( ti, ett_hdr_ext );
1879 /* pass interpretation of header extension to a registered subdissector */
1880 newtvb = tvb_new_subset(tvb, offset, hdr_extension_len * 4, hdr_extension_len * 4);
1882 if (hdr_extension_id == RTP_RFC5215_ONE_BYTE_SIG) {
1883 dissect_rtp_hext_rfc5215_onebyte (newtvb, pinfo, rtp_hext_tree);
1885 else if ((hdr_extension_id & RTP_RFC5215_TWO_BYTE_MASK) == RTP_RFC5215_TWO_BYTE_SIG) {
1886 dissect_rtp_hext_rfc5215_twobytes(tvb,
1887 offset - 4, hdr_extension_id, newtvb,
1888 pinfo, rtp_hext_tree);
1891 if ( !(dissector_try_uint(rtp_hdr_ext_dissector_table, hdr_extension_id, newtvb, pinfo, rtp_hext_tree)) ) {
1892 hdrext_offset = offset;
1893 for ( i = 0; i < hdr_extension_len; i++ ) {
1894 if ( tree ) proto_tree_add_uint( rtp_hext_tree, hf_rtp_hdr_ext, tvb, hdrext_offset, 4, tvb_get_ntohl( tvb, hdrext_offset ) );
1900 offset += hdr_extension_len * 4;
1903 if ( padding_set ) {
1905 * This RTP frame has padding - find it.
1907 * The padding count is found in the LAST octet of
1908 * the packet; it contains the number of octets
1909 * that can be ignored at the end of the packet.
1911 if (tvb_length(tvb) < tvb_reported_length(tvb)) {
1913 * We don't *have* the last octet of the
1914 * packet, so we can't get the padding
1917 * Put an indication of that into the
1918 * tree, and just put in a raw data
1921 if ( tree ) proto_tree_add_text(rtp_tree, tvb, 0, 0,
1922 "Frame has padding, but not all the frame data was captured");
1923 call_dissector(data_handle,
1924 tvb_new_subset_remaining(tvb, offset),
1926 return tvb_length(tvb);;
1929 padding_count = tvb_get_guint8( tvb,
1930 tvb_reported_length( tvb ) - 1 );
1932 tvb_reported_length_remaining( tvb, offset ) - padding_count;
1934 rtp_info->info_payload_offset = offset;
1935 rtp_info->info_payload_len = tvb_length_remaining(tvb, offset);
1936 rtp_info->info_padding_count = padding_count;
1938 if (p_conv_data && p_conv_data->bta2dp_info) {
1939 if (p_conv_data->bta2dp_info->codec_dissector == sbc_handle) {
1940 rtp_info->info_payload_offset += 1;
1941 rtp_info->info_payload_len -= 1;
1944 if (p_conv_data->bta2dp_info->content_protection_type == BTAVDTP_CONTENT_PROTECTION_TYPE_SCMS_T) {
1945 rtp_info->info_payload_offset += 1;
1946 rtp_info->info_payload_len -= 1;
1950 if (p_conv_data && p_conv_data->btvdp_info &&
1951 p_conv_data->bta2dp_info->content_protection_type == BTAVDTP_CONTENT_PROTECTION_TYPE_SCMS_T) {
1952 rtp_info->info_payload_offset += 1;
1953 rtp_info->info_payload_len -= 1;
1958 * There's data left over when you take out
1959 * the padding; dissect it.
1961 /* Ensure that tap is called after packet dissection, even in case of exception */
1963 dissect_rtp_data( tvb, pinfo, tree, rtp_tree,
1969 if (!pinfo->flags.in_error_pkt)
1970 tap_queue_packet(rtp_tap, pinfo, rtp_info);
1975 } else if (data_len < 0) {
1977 * The padding count is bigger than the
1978 * amount of RTP payload in the packet!
1979 * Clip the padding count.
1981 * XXX - put an item in the tree to indicate
1982 * that the padding count is bogus?
1985 tvb_reported_length_remaining(tvb, offset);
1987 if (padding_count > 1) {
1989 * There's more than one byte of padding;
1990 * show all but the last byte as padding
1993 if ( tree ) proto_tree_add_item( rtp_tree, hf_rtp_padding_data,
1994 tvb, offset, padding_count - 1, ENC_NA );
1995 offset += padding_count - 1;
1998 * Show the last byte in the PDU as the padding
2001 if ( tree ) proto_tree_add_item( rtp_tree, hf_rtp_padding_count,
2002 tvb, offset, 1, ENC_BIG_ENDIAN );
2008 rtp_info->info_payload_offset = offset;
2009 rtp_info->info_payload_len = tvb_length_remaining(tvb, offset);
2011 if (p_conv_data && p_conv_data->bta2dp_info) {
2012 if (p_conv_data->bta2dp_info->codec_dissector == sbc_handle) {
2013 rtp_info->info_payload_offset += 1;
2014 rtp_info->info_payload_len -= 1;
2017 if (p_conv_data->bta2dp_info->content_protection_type == BTAVDTP_CONTENT_PROTECTION_TYPE_SCMS_T) {
2018 rtp_info->info_payload_offset += 1;
2019 rtp_info->info_payload_len -= 1;
2023 if (p_conv_data && p_conv_data->btvdp_info &&
2024 p_conv_data->bta2dp_info->content_protection_type == BTAVDTP_CONTENT_PROTECTION_TYPE_SCMS_T) {
2025 rtp_info->info_payload_offset += 1;
2026 rtp_info->info_payload_len -= 1;
2029 if (tvb_reported_length_remaining(tvb, offset) > 0) {
2030 /* Ensure that tap is called after packet dissection, even in case of exception */
2032 dissect_rtp_data( tvb, pinfo, tree, rtp_tree, offset,
2033 tvb_length_remaining( tvb, offset ),
2034 tvb_reported_length_remaining( tvb, offset ),
2037 if (!pinfo->flags.in_error_pkt)
2038 tap_queue_packet(rtp_tap, pinfo, rtp_info);
2044 if (!pinfo->flags.in_error_pkt)
2045 tap_queue_packet(rtp_tap, pinfo, rtp_info);
2051 dissect_rtp_hdr_ext_ed137(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
2053 unsigned int offset = 0;
2054 unsigned int hdr_extension_len = 0;
2055 proto_item *ti = NULL;
2056 proto_item *ti2 = NULL;
2057 proto_tree *rtp_hext_tree = NULL;
2058 proto_tree *rtp_hext_tree2 = NULL;
2061 unsigned int ft_type = 0;
2062 unsigned int bss_qidx = 0;
2063 unsigned int bss_qidx_ml = 0;
2065 hdr_extension_len = tvb_reported_length(tvb)/4;
2067 if ( hdr_extension_len > 0 ) {
2068 unsigned int hdrext_offset = 0;
2071 ti = proto_tree_add_item(tree, hf_rtp_hdr_ed137s, tvb, offset, hdr_extension_len * 4, ENC_NA);
2072 rtp_hext_tree = proto_item_add_subtree( ti, ett_hdr_ext_ed137s );
2074 for(i=0; i<hdr_extension_len; i++) {
2076 ti2 = proto_tree_add_item(rtp_hext_tree, hf_rtp_hdr_ed137, tvb, hdrext_offset, 4, ENC_NA);
2077 rtp_hext_tree2 = proto_item_add_subtree( ti2, ett_hdr_ext_ed137 );
2078 ext_value=tvb_get_ntohl( tvb, hdrext_offset );
2080 if (RTP_ED137_ptt_mask(ext_value)) {
2081 col_append_str(pinfo->cinfo, COL_INFO, ", PTT");
2083 if (RTP_ED137_squ_mask(ext_value)) {
2084 col_append_str(pinfo->cinfo, COL_INFO, ", SQU");
2087 /* Following bits are used from ED137 RTPRx/RTPTx Information field */
2088 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_ptt_type, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2089 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_squ, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2090 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_ptt_id, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2091 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_sct, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2092 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_x, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2094 if (RTP_ED137_extended_information(ext_value)) {
2095 /* Extended information is used */
2096 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_ft_type, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2097 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_ft_len, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2099 ft_type=RTP_ED137_feature_type(ext_value);
2101 case RTP_ED137_feature_bss_type:
2102 bss_qidx=RTP_ED137_feature_bss_qidx(ext_value);
2103 bss_qidx_ml=RTP_ED137_feature_bss_qidx_ml(ext_value);
2104 if (0==bss_qidx_ml) {
2105 /* Special handling for RSSI method */
2108 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_ft_bss_rssi_qidx, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2111 /* Handle as other method */
2112 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_ft_bss_qidx, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2116 /* Other BSS method handling */
2117 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_ft_bss_qidx, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2119 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_ft_bss_qidx_ml, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2120 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_ft_bss_nu, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2123 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_ft_value, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2128 /* Extended information is not used */
2129 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_x_nu, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2132 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137_vf, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2140 dissect_rtp_hdr_ext_ed137a(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
2142 unsigned int offset = 0;
2143 unsigned int hdr_extension_len = 0;
2144 proto_item *ti = NULL;
2145 proto_item *ti2 = NULL;
2146 proto_tree *rtp_hext_tree = NULL;
2147 proto_tree *rtp_hext_tree2 = NULL;
2150 unsigned int ft_type = 0;
2152 hdr_extension_len = tvb_reported_length(tvb)/4;
2154 if ( hdr_extension_len > 0 ) {
2155 unsigned int hdrext_offset = 0;
2158 ti = proto_tree_add_item(tree, hf_rtp_hdr_ed137s, tvb, offset, hdr_extension_len * 4, ENC_NA);
2159 rtp_hext_tree = proto_item_add_subtree( ti, ett_hdr_ext_ed137s );
2161 for(i=0; i<hdr_extension_len; i++) {
2163 ti2 = proto_tree_add_item(rtp_hext_tree, hf_rtp_hdr_ed137a, tvb, hdrext_offset, 4, ENC_NA);
2164 rtp_hext_tree2 = proto_item_add_subtree( ti2, ett_hdr_ext_ed137a );
2165 ext_value=tvb_get_ntohl( tvb, hdrext_offset );
2167 if (RTP_ED137A_ptt_mask(ext_value)) {
2168 col_append_str(pinfo->cinfo, COL_INFO, ", PTT");
2170 if (RTP_ED137A_squ_mask(ext_value)) {
2171 col_append_str(pinfo->cinfo, COL_INFO, ", SQU");
2174 /* Following bits are used from ED137A/B RTPRx Information field */
2175 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137a_ptt_type, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2176 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137a_squ, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2177 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137a_ptt_id, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2178 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137a_pm, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2179 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137a_ptts, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2180 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137a_sct, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2181 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137a_reserved, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2182 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137a_x, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2184 if (RTP_ED137A_extended_information(ext_value)) {
2185 /* Extended information is used */
2186 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137a_ft_type, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2187 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137a_ft_len, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2189 ft_type=RTP_ED137A_feature_type(ext_value);
2192 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137a_ft_value, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2197 /* Extended information is not used */
2198 proto_tree_add_item( rtp_hext_tree2, hf_rtp_hdr_ed137a_x_nu, tvb, hdrext_offset, 4, ENC_BIG_ENDIAN);
2206 /* calculate the extended sequence number - top 16 bits of the previous sequence number,
2207 * plus our own; then correct for wrapping */
2209 calculate_extended_seqno(guint32 previous_seqno, guint16 raw_seqno)
2211 guint32 seqno = (previous_seqno & 0xffff0000) | raw_seqno;
2212 if(seqno + 0x8000 < previous_seqno) {
2214 } else if(previous_seqno + 0x8000 < seqno) {
2215 /* we got an out-of-order packet which happened to go backwards over the
2222 /* Look for conversation info */
2224 get_conv_info(packet_info *pinfo, struct _rtp_info *rtp_info)
2226 /* Conversation and current data */
2227 conversation_t *p_conv = NULL;
2228 struct _rtp_conversation_info *p_conv_data = NULL;
2230 /* Use existing packet info if available */
2231 p_conv_data = (struct _rtp_conversation_info *)p_get_proto_data(pinfo->fd, proto_rtp, 0);
2235 /* First time, get info from conversation */
2236 p_conv = find_conversation(pinfo->fd->num, &pinfo->net_dst, &pinfo->net_src,
2238 pinfo->destport, pinfo->srcport, NO_ADDR_B);
2241 /* Create space for packet info */
2242 struct _rtp_conversation_info *p_conv_packet_data;
2243 p_conv_data = (struct _rtp_conversation_info *)conversation_get_proto_data(p_conv, proto_rtp);
2248 /* Save this conversation info into packet info */
2249 p_conv_packet_data = wmem_new(wmem_file_scope(), struct _rtp_conversation_info);
2250 g_strlcpy(p_conv_packet_data->method, p_conv_data->method, MAX_RTP_SETUP_METHOD_SIZE+1);
2251 p_conv_packet_data->frame_number = p_conv_data->frame_number;
2252 p_conv_packet_data->is_video = p_conv_data->is_video;
2253 p_conv_packet_data->rtp_dyn_payload = p_conv_data->rtp_dyn_payload;
2254 p_conv_packet_data->rtp_conv_info = p_conv_data->rtp_conv_info;
2255 p_conv_packet_data->srtp_info = p_conv_data->srtp_info;
2256 p_conv_packet_data->bta2dp_info = p_conv_data->bta2dp_info;
2257 p_conv_packet_data->btvdp_info = p_conv_data->btvdp_info;
2258 p_add_proto_data(pinfo->fd, proto_rtp, 0, p_conv_packet_data);
2260 /* calculate extended sequence number */
2261 seqno = calculate_extended_seqno(p_conv_data->extended_seqno,
2262 rtp_info->info_seq_num);
2264 p_conv_packet_data->extended_seqno = seqno;
2265 p_conv_data->extended_seqno = seqno;
2269 if (p_conv_data) rtp_info->info_setup_frame_num = p_conv_data->frame_number;
2273 /* Display setup info */
2275 show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2277 /* Conversation and current data */
2278 struct _rtp_conversation_info *p_conv_data = NULL;
2279 proto_tree *rtp_setup_tree;
2282 /* Use existing packet info if available */
2283 p_conv_data = (struct _rtp_conversation_info *)p_get_proto_data(pinfo->fd, proto_rtp, 0);
2285 if (!p_conv_data) return;
2287 /* Create setup info subtree with summary info. */
2288 ti = proto_tree_add_string_format(tree, hf_rtp_setup, tvb, 0, 0,
2289 "", "Stream setup by %s (frame %u)",
2290 p_conv_data->method,
2291 p_conv_data->frame_number);
2292 PROTO_ITEM_SET_GENERATED(ti);
2293 rtp_setup_tree = proto_item_add_subtree(ti, ett_rtp_setup);
2296 /* Add details into subtree */
2297 proto_item* item = proto_tree_add_uint(rtp_setup_tree, hf_rtp_setup_frame,
2298 tvb, 0, 0, p_conv_data->frame_number);
2299 PROTO_ITEM_SET_GENERATED(item);
2300 item = proto_tree_add_string(rtp_setup_tree, hf_rtp_setup_method,
2301 tvb, 0, 0, p_conv_data->method);
2302 PROTO_ITEM_SET_GENERATED(item);
2306 /* Dissect PacketCable CCC header */
2309 dissect_pkt_ccc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
2311 proto_item *ti = NULL;
2312 proto_tree *pkt_ccc_tree = NULL;
2315 ti = proto_tree_add_item(tree, proto_pkt_ccc, tvb, 0, 12, ENC_NA);
2316 pkt_ccc_tree = proto_item_add_subtree(ti, ett_pkt_ccc);
2318 proto_tree_add_item(pkt_ccc_tree, hf_pkt_ccc_id, tvb, 0, 4, ENC_BIG_ENDIAN);
2319 proto_tree_add_item(pkt_ccc_tree, hf_pkt_ccc_ts, tvb, 4, 8,
2320 ENC_TIME_NTP|ENC_BIG_ENDIAN);
2323 return dissect_rtp(tvb, pinfo, tree, data);
2327 /* Register PacketCable CCC */
2330 proto_register_pkt_ccc(void)
2332 static hf_register_info hf[] =
2337 "PacketCable CCC Identifier",
2349 "PacketCable CCC Timestamp",
2361 static gint *ett[] =
2366 module_t *pkt_ccc_module;
2368 proto_pkt_ccc = proto_register_protocol("PacketCable Call Content Connection",
2369 "PKT CCC", "pkt_ccc");
2370 proto_register_field_array(proto_pkt_ccc, hf, array_length(hf));
2371 proto_register_subtree_array(ett, array_length(ett));
2373 new_register_dissector("pkt_ccc", dissect_pkt_ccc, proto_pkt_ccc);
2375 pkt_ccc_module = prefs_register_protocol(proto_pkt_ccc, proto_reg_handoff_pkt_ccc);
2377 prefs_register_uint_preference(pkt_ccc_module, "udp_port",
2379 "Decode packets on this UDP port as PacketCable CCC",
2380 10, &global_pkt_ccc_udp_port);
2384 proto_reg_handoff_pkt_ccc(void)
2387 * Register this dissector as one that can be selected by a
2390 static gboolean initialized = FALSE;
2391 static dissector_handle_t pkt_ccc_handle;
2392 static guint saved_pkt_ccc_udp_port;
2395 pkt_ccc_handle = find_dissector("pkt_ccc");
2396 dissector_add_handle("udp.port", pkt_ccc_handle); /* for 'decode-as' */
2399 if (saved_pkt_ccc_udp_port != 0) {
2400 dissector_delete_uint("udp.port", saved_pkt_ccc_udp_port, pkt_ccc_handle);
2404 if (global_pkt_ccc_udp_port != 0) {
2405 dissector_add_uint("udp.port", global_pkt_ccc_udp_port, pkt_ccc_handle);
2407 saved_pkt_ccc_udp_port = global_pkt_ccc_udp_port;
2413 proto_register_rtp(void)
2415 static hf_register_info hf[] =
2424 VALS(rtp_version_vals),
2456 "Contributing source identifiers count",
2478 &hf_rtp_payload_type,
2504 "Extended sequence number",
2528 "Synchronization Source identifier",
2538 &hf_rtp_prof_define,
2540 "Defined by profile",
2544 VALS(rtp_ext_profile_vals),
2564 "Contributing Source identifiers",
2588 "Header extensions",
2597 /* ED137 and ED137A common structures */
2610 /* ED137 only structures */
2624 &hf_rtp_hdr_ed137_ptt_type,
2627 "rtp.ext.ed137.ptt_type",
2630 VALS(rtp_ext_ed137_ptt_type),
2636 &hf_rtp_hdr_ed137_squ,
2639 "rtp.ext.ed137.squ",
2642 VALS(rtp_ext_ed137_squ),
2648 &hf_rtp_hdr_ed137_ptt_id,
2651 "rtp.ext.ed137.ptt_id",
2660 &hf_rtp_hdr_ed137_sct,
2662 "Simultaneous Call Transmissions",
2663 "rtp.ext.ed137.sct",
2672 &hf_rtp_hdr_ed137_x,
2684 &hf_rtp_hdr_ed137_x_nu,
2687 "rtp.ext.ed137.x-nu",
2696 &hf_rtp_hdr_ed137_ft_type,
2699 "rtp.ext.ed137.ft.type",
2702 VALS(rtp_ext_ed137_ft_type),
2708 &hf_rtp_hdr_ed137_ft_len,
2711 "rtp.ext.ed137.ft.len",
2720 &hf_rtp_hdr_ed137_ft_value,
2723 "rtp.ext.ed137.ft.value",
2732 &hf_rtp_hdr_ed137_vf,
2738 VALS(rtp_ext_ed137_vf),
2744 &hf_rtp_hdr_ed137_ft_bss_qidx,
2746 "BSS Quality Index",
2747 "rtp.ext.ed137.ft.bss.qidx",
2756 &hf_rtp_hdr_ed137_ft_bss_rssi_qidx,
2758 "BSS Quality Index",
2759 "rtp.ext.ed137.ft.bss.qidx",
2762 VALS(rtp_ext_ed137_ft_bss_rssi_qidx),
2768 &hf_rtp_hdr_ed137_ft_bss_qidx_ml,
2770 "BSS Quality Index Method",
2771 "rtp.ext.ed137.ft.bss.qidx-ml",
2774 VALS(rtp_ext_ed137_ft_bss_qidx_ml),
2780 &hf_rtp_hdr_ed137_ft_bss_nu,
2783 "rtp.ext.ed137.ft.bss-nu",
2791 /* ED137A only structures */
2805 &hf_rtp_hdr_ed137a_ptt_type,
2808 "rtp.ext.ed137A.ptt_type",
2811 VALS(rtp_ext_ed137a_ptt_type),
2817 &hf_rtp_hdr_ed137a_squ,
2820 "rtp.ext.ed137A.squ",
2823 VALS(rtp_ext_ed137a_squ),
2829 &hf_rtp_hdr_ed137a_ptt_id,
2832 "rtp.ext.ed137A.ptt_id",
2841 &hf_rtp_hdr_ed137a_pm,
2844 "rtp.ext.ed137A.pm",
2853 &hf_rtp_hdr_ed137a_ptts,
2856 "rtp.ext.ed137A.ptts",
2865 &hf_rtp_hdr_ed137a_sct,
2867 "Simultaneous Call Transmissions",
2868 "rtp.ext.ed137a.sct",
2877 &hf_rtp_hdr_ed137a_reserved,
2880 "rtp.ext.ed137A.reserved",
2889 &hf_rtp_hdr_ed137a_x,
2901 &hf_rtp_hdr_ed137a_x_nu,
2904 "rtp.ext.ed137A.x-nu",
2913 &hf_rtp_hdr_ed137a_ft_type,
2916 "rtp.ext.ed137A.ft.type",
2919 VALS(rtp_ext_ed137a_ft_type),
2925 &hf_rtp_hdr_ed137a_ft_len,
2928 "rtp.ext.ed137A.ft.len",
2937 &hf_rtp_hdr_ed137a_ft_value,
2940 "rtp.ext.ed137A.ft.value",
2948 /* Other RTP structures */
2974 &hf_rtp_padding_data,
2986 &hf_rtp_padding_count,
2989 "rtp.padding.count",
3006 "Stream setup, method and frame number", HFILL
3010 &hf_rtp_setup_frame,
3018 "Frame that set up this stream", HFILL
3022 &hf_rtp_setup_method,
3030 "Method used to set up this stream", HFILL
3034 &hf_rtp_rfc2198_follow,
3040 TFS(&tfs_set_notset),
3042 "Next header follows", HFILL
3046 &hf_rtp_rfc2198_tm_off,
3049 "rtp.timestamp-offset",
3058 &hf_rtp_rfc2198_bl_len,
3070 &hf_rtp_ext_rfc5285_id,
3073 "rtp.ext.rfc5285.id",
3078 "RFC 5285 Header Extension Identifier",
3083 &hf_rtp_ext_rfc5285_length,
3086 "rtp.ext.rfc5285.len",
3091 "RFC 5285 Header Extension length",
3096 &hf_rtp_ext_rfc5285_appbits,
3099 "rtp.ext.rfc5285.appbits",
3104 "RFC 5285 2-bytes header application bits",
3109 &hf_rtp_ext_rfc5285_data,
3112 "rtp.ext.rfc5285.data",
3117 "RFC 5285 Extension Data",
3122 /* reassembly stuff */
3124 {"RTP Fragments", "rtp.fragments", FT_NONE, BASE_NONE, NULL, 0x0,
3129 {"RTP Fragment data", "rtp.fragment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3133 {&hf_rtp_fragment_overlap,
3134 {"Fragment overlap", "rtp.fragment.overlap", FT_BOOLEAN, BASE_NONE,
3135 NULL, 0x0, "Fragment overlaps with other fragments", HFILL }
3138 {&hf_rtp_fragment_overlap_conflict,
3139 {"Conflicting data in fragment overlap", "rtp.fragment.overlap.conflict",
3140 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3141 "Overlapping fragments contained conflicting data", HFILL }
3144 {&hf_rtp_fragment_multiple_tails,
3145 {"Multiple tail fragments found", "rtp.fragment.multipletails",
3146 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3147 "Several tails were found when defragmenting the packet", HFILL }
3150 {&hf_rtp_fragment_too_long_fragment,
3151 {"Fragment too long", "rtp.fragment.toolongfragment",
3152 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3153 "Fragment contained data past end of packet", HFILL }
3156 {&hf_rtp_fragment_error,
3157 {"Defragmentation error", "rtp.fragment.error",
3158 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3159 "Defragmentation error due to illegal fragments", HFILL }
3162 {&hf_rtp_fragment_count,
3163 {"Fragment count", "rtp.fragment.count",
3164 FT_UINT32, BASE_DEC, NULL, 0x0,
3168 {&hf_rtp_reassembled_in,
3169 {"RTP fragment, reassembled in frame", "rtp.reassembled_in",
3170 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3171 "This RTP packet is reassembled in this frame", HFILL }
3173 {&hf_rtp_reassembled_length,
3174 {"Reassembled RTP length", "rtp.reassembled.length",
3175 FT_UINT32, BASE_DEC, NULL, 0x0,
3176 "The total length of the reassembled payload", HFILL }
3178 {&hf_srtp_encrypted_payload,
3179 {"SRTP Encrypted Payload", "srtp.enc_payload",
3180 FT_BYTES, BASE_NONE, NULL, 0x0,
3184 {"SRTP MKI", "srtp.mki",
3185 FT_BYTES, BASE_NONE, NULL, 0x0,
3186 "SRTP Master Key Index", HFILL }
3189 {"SRTP Auth Tag", "srtp.auth_tag",
3190 FT_BYTES, BASE_NONE, NULL, 0x0,
3191 "SRTP Authentication Tag", HFILL }
3196 static gint *ett[] =
3201 &ett_hdr_ext_rfc5285,
3202 &ett_hdr_ext_ed137s,
3204 &ett_hdr_ext_ed137a,
3207 &ett_rtp_rfc2198_hdr,
3212 module_t *rtp_module;
3215 proto_rtp = proto_register_protocol("Real-Time Transport Protocol",
3217 proto_register_field_array(proto_rtp, hf, array_length(hf));
3218 proto_register_subtree_array(ett, array_length(ett));
3220 new_register_dissector("rtp", dissect_rtp, proto_rtp);
3221 register_dissector("rtp.rfc2198", dissect_rtp_rfc2198, proto_rtp);
3223 rtp_tap = register_tap("rtp");
3225 rtp_pt_dissector_table = register_dissector_table("rtp.pt",
3226 "RTP payload type", FT_UINT8, BASE_DEC);
3227 rtp_dyn_pt_dissector_table = register_dissector_table("rtp_dyn_payload_type",
3228 "Dynamic RTP payload type", FT_STRING, BASE_NONE);
3231 rtp_hdr_ext_dissector_table = register_dissector_table("rtp.hdr_ext",
3232 "RTP header extension", FT_UINT32, BASE_HEX);
3233 rtp_hdr_ext_rfc5285_dissector_table = register_dissector_table("rtp.ext.rfc5285.id",
3234 "RTP Generic header extension (RFC 5285)", FT_UINT8, BASE_DEC);
3236 register_dissector("rtp.ext.ed137", dissect_rtp_hdr_ext_ed137, proto_rtp);
3237 register_dissector("rtp.ext.ed137a", dissect_rtp_hdr_ext_ed137a, proto_rtp);
3239 rtp_module = prefs_register_protocol(proto_rtp, proto_reg_handoff_rtp);
3241 prefs_register_bool_preference(rtp_module, "show_setup_info",
3242 "Show stream setup information",
3243 "Where available, show which protocol and frame caused "
3244 "this RTP stream to be created",
3245 &global_rtp_show_setup_info);
3247 prefs_register_bool_preference(rtp_module, "heuristic_rtp",
3248 "Try to decode RTP outside of conversations",
3249 "If call control SIP/H323/RTSP/.. messages are missing in the trace, "
3250 "RTP isn't decoded without this",
3253 prefs_register_bool_preference(rtp_module, "desegment_rtp_streams",
3254 "Allow subdissector to reassemble RTP streams",
3255 "Whether subdissector can request RTP streams to be reassembled",
3258 prefs_register_enum_preference(rtp_module, "version0_type",
3259 "Treat RTP version 0 packets as",
3260 "If an RTP version 0 packet is encountered, it can be treated as "
3261 "an invalid or ZRTP packet, a CLASSIC-STUN packet, or a T.38 packet",
3262 &global_rtp_version0_type,
3263 rtp_version0_types, FALSE);
3264 prefs_register_uint_preference(rtp_module,
3265 "rfc2198_payload_type", "Payload Type for RFC2198",
3266 "Payload Type for RFC2198 Redundant Audio Data",
3270 register_init_routine(rtp_fragment_init);
3274 proto_reg_handoff_rtp(void)
3276 static gboolean rtp_prefs_initialized = FALSE;
3277 static dissector_handle_t rtp_rfc2198_handle;
3278 static dissector_handle_t rtp_hdr_ext_ed137_handle;
3279 static dissector_handle_t rtp_hdr_ext_ed137a_handle;
3280 static guint rtp_saved_rfc2198_pt;
3282 if (!rtp_prefs_initialized) {
3283 rtp_handle = find_dissector("rtp");
3284 rtp_rfc2198_handle = find_dissector("rtp.rfc2198");
3286 dissector_add_handle("udp.port", rtp_handle); /* for 'decode-as' */
3287 dissector_add_string("rtp_dyn_payload_type", "red", rtp_rfc2198_handle);
3288 heur_dissector_add( "udp", dissect_rtp_heur_udp, proto_rtp);
3289 heur_dissector_add("stun", dissect_rtp_heur_stun, proto_rtp);
3291 rtp_hdr_ext_ed137_handle = find_dissector("rtp.ext.ed137");
3292 rtp_hdr_ext_ed137a_handle = find_dissector("rtp.ext.ed137a");
3293 dissector_add_uint("rtp.hdr_ext", RTP_ED137_SIG, rtp_hdr_ext_ed137_handle);
3294 dissector_add_uint("rtp.hdr_ext", RTP_ED137A_SIG, rtp_hdr_ext_ed137a_handle);
3296 data_handle = find_dissector("data");
3297 stun_handle = find_dissector("stun-udp");
3298 classicstun_handle = find_dissector("classicstun");
3299 classicstun_heur_handle = find_dissector("classicstun-heur");
3300 stun_heur_handle = find_dissector("stun-heur");
3301 t38_handle = find_dissector("t38");
3302 zrtp_handle = find_dissector("zrtp");
3304 sprt_handle = find_dissector("sprt");
3305 v150fw_handle = find_dissector("v150fw");
3307 bta2dp_content_protection_header_scms_t = find_dissector("bta2dp_content_protection_header_scms_t");
3308 btvdp_content_protection_header_scms_t = find_dissector("btvdp_content_protection_header_scms_t");
3309 bta2dp_handle = find_dissector("bta2dp");
3310 btvdp_handle = find_dissector("btvdp");
3311 sbc_handle = find_dissector("sbc");
3313 dissector_add_string("rtp_dyn_payload_type", "v150fw", v150fw_handle);
3315 dissector_add_handle("btl2cap.cid", rtp_handle);
3317 rtp_prefs_initialized = TRUE;
3319 dissector_delete_uint("rtp.pt", rtp_saved_rfc2198_pt, rtp_rfc2198_handle);
3321 dissector_add_uint("rtp.pt", rtp_rfc2198_pt, rtp_rfc2198_handle);
3322 rtp_saved_rfc2198_pt = rtp_rfc2198_pt;
3326 * Editor modelines - http://www.wireshark.org/tools/modelines.html
3331 * indent-tabs-mode: t
3334 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
3335 * :indentSize=8:tabSize=8:noTabs=false: