Display MSW and LSW as NTP timestamp as well.
[obnox/wireshark/wip.git] / epan / dissectors / packet-rtcp.c
1 /* packet-rtcp.c
2  *
3  * $Id$
4  *
5  * Routines for RTCP dissection
6  * RTCP = Real-time Transport Control Protocol
7  *
8  * Copyright 2000, Philips Electronics N.V.
9  * Written by Andreas Sikkema <h323@ramdyne.nl>
10  *
11  * Copyright 2004, Anders Broman <anders.broman@ericsson.com>
12  *
13  * Copyright 2005, Nagarjuna Venna <nvenna@brixnet.com>
14  *
15  * Ethereal - Network traffic analyzer
16  * By Gerald Combs <gerald@ethereal.com>
17  * Copyright 1998 Gerald Combs
18  *
19  * This program is free software; you can redistribute it and/or
20  * modify it under the terms of the GNU General Public License
21  * as published by the Free Software Foundation; either version 2
22  * of the License, or (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program; if not, write to the Free Software
31  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
32  */
33
34 /*
35  * This dissector tries to dissect the RTCP protocol according to Annex A
36  * of ITU-T Recommendation H.225.0 (02/98) and RFC 1889
37  * H.225.0 literally copies RFC 1889, but omitting a few sections.
38  *
39  * RTCP traffic is handled by an uneven UDP portnumber. This can be any
40  * port number, but there is a registered port available, port 5005
41  * See Annex B of ITU-T Recommendation H.225.0, section B.7
42  *
43  * RTCP XR is specified in RFC 3611.
44  *
45  * See also http://www.iana.org/assignments/rtp-parameters
46  */
47
48
49 #ifdef HAVE_CONFIG_H
50 # include "config.h"
51 #endif
52
53 #include <glib.h>
54 #include <epan/packet.h>
55
56 #include <stdio.h>
57 #include <string.h>
58
59 #include "packet-rtcp.h"
60 #include "packet-ntp.h"
61 #include <epan/conversation.h>
62
63 #include <epan/prefs.h>
64 #include <epan/emem.h>
65
66
67 /* Version is the first 2 bits of the first octet*/
68 #define RTCP_VERSION(octet)     ((octet) >> 6)
69
70 /* Padding is the third bit; no need to shift, because true is any value
71    other than 0! */
72 #define RTCP_PADDING(octet)     ((octet) & 0x20)
73
74 /* Receiver/ Sender count is the 5 last bits  */
75 #define RTCP_COUNT(octet)       ((octet) & 0x1F)
76
77 static dissector_handle_t rtcp_handle;
78
79 static const value_string rtcp_version_vals[] =
80 {
81         { 0, "Old VAT Version" },
82         { 1, "First Draft Version" },
83         { 2, "RFC 1889 Version" },
84         { 0, NULL },
85 };
86
87 /* RTCP packet types according to Section A.11.1 */
88 /* And http://www.iana.org/assignments/rtp-parameters */
89 #define RTCP_SR   200
90 #define RTCP_RR   201
91 #define RTCP_SDES 202
92 #define RTCP_BYE  203
93 #define RTCP_APP  204
94 #define RTCP_RTPFB  205
95 #define RTCP_PSFB  206
96 #define RTCP_XR   207
97 /* Supplemental H.261 specific RTCP packet types according to Section C.3.5 */
98 #define RTCP_FIR  192
99 #define RTCP_NACK 193
100
101 static const value_string rtcp_packet_type_vals[] =
102 {
103         { RTCP_SR,   "Sender Report" },
104         { RTCP_RR,   "Receiver Report" },
105         { RTCP_SDES, "Source description" },
106         { RTCP_BYE,  "Goodbye" },
107         { RTCP_APP,  "Application specific" },
108         { RTCP_FIR,  "Full Intra-frame Request (H.261)" },
109         { RTCP_NACK, "Negative Acknowledgement (H.261)" },
110         { RTCP_RTPFB, "Generic RTP Feedback" },
111         { RTCP_PSFB, "Payload-specific" },
112         { RTCP_XR,   "Extended report (RFC 3611)"},
113         { 0,         NULL },
114 };
115
116 /* RTCP SDES types (Section A.11.2) */
117 #define RTCP_SDES_END    0
118 #define RTCP_SDES_CNAME  1
119 #define RTCP_SDES_NAME   2
120 #define RTCP_SDES_EMAIL  3
121 #define RTCP_SDES_PHONE  4
122 #define RTCP_SDES_LOC    5
123 #define RTCP_SDES_TOOL   6
124 #define RTCP_SDES_NOTE   7
125 #define RTCP_SDES_PRIV   8
126 #define RTCP_SDES_H323_CADDR   9
127
128 static const value_string rtcp_sdes_type_vals[] =
129 {
130         { RTCP_SDES_END,   "END" },
131         { RTCP_SDES_CNAME, "CNAME (user and domain)" },
132         { RTCP_SDES_NAME,  "NAME (common name)" },
133         { RTCP_SDES_EMAIL, "EMAIL (e-mail address)" },
134         { RTCP_SDES_PHONE, "PHONE (phone number)" },
135         { RTCP_SDES_LOC,   "LOC (geographic location)" },
136         { RTCP_SDES_TOOL,  "TOOL (name/version of source app)" },
137         { RTCP_SDES_NOTE,  "NOTE (note about source)" },
138         { RTCP_SDES_PRIV,  "PRIV (private extensions)" },
139         { RTCP_SDES_H323_CADDR,"H323-CADDR (H.323 callable address)"},
140         { 0,               NULL },
141 };
142
143 /* RTCP XR Blocks (Section 4, RTC 3611) */
144 #define RTCP_XR_LOSS_RLE    1
145 #define RTCP_XR_DUP_RLE     2
146 #define RTCP_XR_PKT_RXTIMES 3
147 #define RTCP_XR_REF_TIME    4
148 #define RTCP_XR_DLRR        5
149 #define RTCP_XR_STATS_SUMRY 6
150 #define RTCP_XR_VOIP_METRCS 7
151
152 static const value_string rtcp_xr_type_vals[] = 
153 {
154         { RTCP_XR_LOSS_RLE,     "Loss Run Length Encoding Report Block" },
155         { RTCP_XR_DUP_RLE,      "Duplicate Run Length Encoding Report Block" },
156         { RTCP_XR_PKT_RXTIMES,  "Packet Receipt Times Report Block" },
157         { RTCP_XR_REF_TIME,     "Receiver Reference Time Report Block" },
158         { RTCP_XR_DLRR,         "DLRR Report Block" },
159         { RTCP_XR_STATS_SUMRY,  "Statistics Summary Report Block" },
160         { RTCP_XR_VOIP_METRCS,  "VoIP Metrics Report Block" },
161         { 0, NULL}
162 };
163
164 /* XR VoIP Metrics Block - PLC Algorithms */
165 static const value_string rtcp_xr_plc_algo_vals[] = 
166 {
167         { 0, "Unspecified" },
168         { 1, "Disabled" },
169         { 2, "Enhanced" },
170         { 3, "Standard" },
171         { 0, NULL }
172 };
173
174 /* XR VoIP Metrics Block - JB Adaptive */
175 static const value_string rtcp_xr_jb_adaptive_vals[] = 
176 {
177         { 0, "Unknown" },
178         { 1, "Reserved" },
179         { 2, "Non-Adaptive" },
180         { 3, "Adaptive" },
181         { 0, NULL }
182 };
183
184 /* XR Stats Summary Block - IP TTL or Hop Limit */
185 static const value_string rtcp_xr_ip_ttl_vals[] = 
186 {
187         { 0, "No TTL Values" },
188         { 1, "IPv4" },
189         { 2, "IPv6" },
190         { 3, "Undefined" },
191         { 0, NULL }
192 };
193
194 /* RTCP Application PoC1 Value strings */
195 static const value_string rtcp_app_poc1_floor_cnt_type_vals[] =
196 {
197         {  0,   "Floor Request"},
198         {  1,   "Floor Grant"},
199         {  2,   "Floor Taken"},
200         {  3,   "Floor Deny"},
201         {  4,   "Floor Release"},
202         {  5,   "Floor Idle"},
203         {  6,   "Floor Revoke"},
204         {  7,   "TBCP Ack"},
205         {  8,   "TBCP Queue Status Request"},
206         {  9,   "TBCP Queue Status Response"},
207         { 11,   "TBCP Disconnect"},
208         { 15,   "TBCP Connect"},
209         { 18,   "Floor Taken (ack expected)"},
210         {  0,   NULL },
211 };
212
213 static const value_string rtcp_app_poc1_reason_code1_vals[] =
214 {
215         {  1,   "Floor already in use"},
216         {  2,   "Internal PoC server error"},
217         {  3,   "Only one participant in the group"},
218         {  4,   "Retry-after timer has not expired"},
219         {  5,   "Listen only"},
220         {  0,   NULL },
221 };
222
223 static const value_string rtcp_app_poc1_reason_code2_vals[] =
224 {
225         {  1,   "Only one user"},
226         {  2,   "Talk burst too long"},
227         {  3,   "No permission"},
228         {  4,   "Talk burst pre-empted"},
229         {  0,   NULL },
230 };
231
232 static const value_string rtcp_app_poc1_conn_sess_type_vals[] =
233 {
234         {  0,   "None"},
235         {  1,   "1-to-1"},
236         {  2,   "Ad-hoc"},
237         {  3,   "Pre-arranged"},
238         {  4,   "Chat"},
239         {  0,   NULL },
240 };
241
242 static const value_string rtcp_app_poc1_qsresp_priority_vals[] =
243 {
244         {  0,   "No priority (un-queued)"},
245         {  1,   "Normal priority"},
246         {  2,   "High priority"},
247         {  3,   "Pre-emptive priority"},
248         {  0,   NULL },
249 };
250
251 /* RTCP header fields                   */
252 static int proto_rtcp                = -1;
253 static int hf_rtcp_version           = -1;
254 static int hf_rtcp_padding           = -1;
255 static int hf_rtcp_rc                = -1;
256 static int hf_rtcp_sc                = -1;
257 static int hf_rtcp_pt                = -1;
258 static int hf_rtcp_length            = -1;
259 static int hf_rtcp_ssrc_sender       = -1;
260 static int hf_rtcp_ntp               = -1;
261 static int hf_rtcp_rtp_timestamp     = -1;
262 static int hf_rtcp_sender_pkt_cnt    = -1;
263 static int hf_rtcp_sender_oct_cnt    = -1;
264 static int hf_rtcp_ssrc_source       = -1;
265 static int hf_rtcp_ssrc_fraction     = -1;
266 static int hf_rtcp_ssrc_cum_nr       = -1;
267 static int hf_rtcp_ssrc_discarded    = -1;
268 /* First the 32 bit number, then the split
269  * up 16 bit values */
270 /* These two are added to a subtree */
271 static int hf_rtcp_ssrc_ext_high_seq = -1;
272 static int hf_rtcp_ssrc_high_seq     = -1;
273 static int hf_rtcp_ssrc_high_cycles  = -1;
274 static int hf_rtcp_ssrc_jitter       = -1;
275 static int hf_rtcp_ssrc_lsr          = -1;
276 static int hf_rtcp_ssrc_dlsr         = -1;
277 static int hf_rtcp_ssrc_csrc         = -1;
278 static int hf_rtcp_ssrc_type         = -1;
279 static int hf_rtcp_ssrc_length       = -1;
280 static int hf_rtcp_ssrc_text         = -1;
281 static int hf_rtcp_ssrc_prefix_len   = -1;
282 static int hf_rtcp_ssrc_prefix_string= -1;
283 static int hf_rtcp_subtype           = -1;
284 static int hf_rtcp_name_ascii        = -1;
285 static int hf_rtcp_app_data          = -1;
286 static int hf_rtcp_fsn               = -1;
287 static int hf_rtcp_blp               = -1;
288 static int hf_rtcp_padding_count     = -1;
289 static int hf_rtcp_padding_data      = -1;
290 static int hf_rtcp_app_poc1_subtype  = -1;
291 static int hf_rtcp_app_poc1_sip_uri  = -1;
292 static int hf_rtcp_app_poc1_disp_name = -1;
293 static int hf_rtcp_app_poc1_last_pkt_seq_no = -1;
294 static int hf_rtcp_app_poc1_reason_code1        = -1;
295 static int hf_rtcp_app_poc1_item_len            = -1;
296 static int hf_rtcp_app_poc1_reason1_phrase      = -1;
297 static int hf_rtcp_app_poc1_reason_code2        = -1;
298 static int hf_rtcp_app_poc1_additionalinfo      = -1;
299 static int hf_rtcp_app_poc1_ack_subtype         = -1;
300 static int hf_rtcp_app_poc1_ack_reason_code     = -1;
301 static int hf_rtcp_app_poc1_qsresp_priority     = -1;
302 static int hf_rtcp_app_poc1_qsresp_position     = -1;
303 static int hf_rtcp_app_poc1_conn_content_1st_byte[5] = { -1, -1, -1, -1, -1 };
304 static int hf_rtcp_app_poc1_conn_session_type   = -1;
305 static int hf_rtcp_app_poc1_conn_add_ind_mao    = -1;
306 static int hf_rtcp_app_poc1_conn_sdes_items[5] = { -1, -1, -1, -1, -1 };
307 static int hf_rtcp_xr_block_type     = -1;
308 static int hf_rtcp_xr_block_specific = -1;
309 static int hf_rtcp_xr_block_length   = -1;
310 static int hf_rtcp_xr_thinning       = -1;
311 static int hf_rtcp_xr_voip_metrics_burst_density = -1;
312 static int hf_rtcp_xr_voip_metrics_gap_density = -1;
313 static int hf_rtcp_xr_voip_metrics_burst_duration = -1;
314 static int hf_rtcp_xr_voip_metrics_gap_duration = -1;
315 static int hf_rtcp_xr_voip_metrics_rtdelay = -1;
316 static int hf_rtcp_xr_voip_metrics_esdelay = -1;
317 static int hf_rtcp_xr_voip_metrics_siglevel = -1;
318 static int hf_rtcp_xr_voip_metrics_noiselevel = -1;
319 static int hf_rtcp_xr_voip_metrics_rerl = -1;
320 static int hf_rtcp_xr_voip_metrics_gmin = -1;
321 static int hf_rtcp_xr_voip_metrics_rfactor = -1;
322 static int hf_rtcp_xr_voip_metrics_extrfactor = -1;
323 static int hf_rtcp_xr_voip_metrics_moslq = -1;
324 static int hf_rtcp_xr_voip_metrics_moscq = -1;
325 static int hf_rtcp_xr_voip_metrics_plc = -1;
326 static int hf_rtcp_xr_voip_metrics_jbadaptive = -1;
327 static int hf_rtcp_xr_voip_metrics_jbrate = -1;
328 static int hf_rtcp_xr_voip_metrics_jbnominal = -1;
329 static int hf_rtcp_xr_voip_metrics_jbmax = -1;
330 static int hf_rtcp_xr_voip_metrics_jbabsmax = -1;
331 static int hf_rtcp_xr_stats_loss_flag = -1;
332 static int hf_rtcp_xr_stats_dup_flag = -1;
333 static int hf_rtcp_xr_stats_jitter_flag = -1;
334 static int hf_rtcp_xr_stats_ttl = -1;
335 static int hf_rtcp_xr_beginseq = -1;
336 static int hf_rtcp_xr_endseq = -1;
337 static int hf_rtcp_xr_stats_lost = -1;
338 static int hf_rtcp_xr_stats_dups = -1;
339 static int hf_rtcp_xr_stats_minjitter = -1;
340 static int hf_rtcp_xr_stats_maxjitter = -1;
341 static int hf_rtcp_xr_stats_meanjitter = -1;
342 static int hf_rtcp_xr_stats_devjitter = -1;
343 static int hf_rtcp_xr_stats_minttl = -1;
344 static int hf_rtcp_xr_stats_maxttl = -1;
345 static int hf_rtcp_xr_stats_meanttl = -1;
346 static int hf_rtcp_xr_stats_devttl = -1;
347 static int hf_rtcp_xr_lrr = -1;
348 static int hf_rtcp_xr_dlrr = -1;
349
350 /* RTCP setup fields */
351 static int hf_rtcp_setup        = -1;
352 static int hf_rtcp_setup_frame  = -1;
353 static int hf_rtcp_setup_method = -1;
354
355 /* RTCP roundtrip delay fields */
356 static int hf_rtcp_roundtrip_delay        = -1;
357 static int hf_rtcp_roundtrip_delay_frame  = -1;
358 static int hf_rtcp_roundtrip_delay_delay  = -1;
359
360
361
362 /* RTCP fields defining a sub tree */
363 static gint ett_rtcp                    = -1;
364 static gint ett_ssrc                    = -1;
365 static gint ett_ssrc_item               = -1;
366 static gint ett_ssrc_ext_high           = -1;
367 static gint ett_sdes                    = -1;
368 static gint ett_sdes_item               = -1;
369 static gint ett_PoC1                    = -1;
370 static gint ett_rtcp_setup              = -1;
371 static gint ett_rtcp_roundtrip_delay    = -1;
372 static gint ett_xr_block                = -1;
373 static gint ett_xr_block_contents       = -1;
374 static gint ett_xr_ssrc                 = -1;
375 static gint  ett_xr_loss_chunk = -1;
376 static gint ett_poc1_conn_contents      = -1;
377
378 /* Main dissection function */
379 static void dissect_rtcp( tvbuff_t *tvb, packet_info *pinfo,
380      proto_tree *tree );
381
382 /* Heuristic dissection */
383 static gboolean global_rtcp_heur = FALSE;
384 static gboolean dissect_rtcp_heur( tvbuff_t *tvb, packet_info *pinfo,
385     proto_tree *tree );
386
387 /* Displaying set info */
388 static gboolean global_rtcp_show_setup_info = TRUE;
389 static void show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
390
391 /* Related to roundtrip calculation (using LSR and DLSR) */
392 static gboolean global_rtcp_show_roundtrip_calculation = FALSE;
393 #define MIN_ROUNDTRIP_TO_REPORT_DEFAULT 10
394 static guint global_rtcp_show_roundtrip_calculation_minimum = MIN_ROUNDTRIP_TO_REPORT_DEFAULT;
395 static void remember_outgoing_sr(packet_info *pinfo, long lsr);
396 static void calculate_roundtrip_delay(tvbuff_t *tvb, packet_info *pinfo,
397                                       proto_tree *tree, guint32 lsr, guint32 dlsr);
398 static void add_roundtrip_delay_info(tvbuff_t *tvb, packet_info *pinfo,
399                                      proto_tree *tree, guint frame, guint delay);
400
401
402 /* Set up an RTCP conversation using the info given */
403 void rtcp_add_address( packet_info *pinfo,
404                        address *addr, int port,
405                        int other_port,
406                        const gchar *setup_method, guint32 setup_frame_number)
407 {
408         address null_addr;
409         conversation_t* p_conv;
410         struct _rtcp_conversation_info *p_conv_data = NULL;
411
412         /*
413          * If this isn't the first time this packet has been processed,
414          * we've already done this work, so we don't need to do it
415          * again.
416          */
417         if (pinfo->fd->flags.visited)
418         {
419                 return;
420         }
421
422         SET_ADDRESS(&null_addr, AT_NONE, 0, NULL);
423
424         /*
425          * Check if the ip address and port combination is not
426          * already registered as a conversation.
427          */
428         p_conv = find_conversation( pinfo->fd->num, addr, &null_addr, PT_UDP, port, other_port,
429                                     NO_ADDR_B | (!other_port ? NO_PORT_B : 0));
430
431         /*
432          * If not, create a new conversation.
433          */
434         if ( ! p_conv ) {
435                 p_conv = conversation_new( pinfo->fd->num, addr, &null_addr, PT_UDP,
436                                            (guint32)port, (guint32)other_port,
437                                            NO_ADDR2 | (!other_port ? NO_PORT2 : 0));
438         }
439
440         /* Set dissector */
441         conversation_set_dissector(p_conv, rtcp_handle);
442
443         /*
444          * Check if the conversation has data associated with it.
445          */
446         p_conv_data = conversation_get_proto_data(p_conv, proto_rtcp);
447
448         /*
449          * If not, add a new data item.
450          */
451         if ( ! p_conv_data ) {
452                 /* Create conversation data */
453                 p_conv_data = se_alloc(sizeof(struct _rtcp_conversation_info));
454                 if (!p_conv_data)
455                 {
456                         return;
457                 }
458                 memset(p_conv_data, 0, sizeof(struct _rtcp_conversation_info));
459                 conversation_add_proto_data(p_conv, proto_rtcp, p_conv_data);
460         }
461
462         /*
463          * Update the conversation data.
464          */
465         p_conv_data->setup_method_set = TRUE;
466         strncpy(p_conv_data->setup_method, setup_method, MAX_RTCP_SETUP_METHOD_SIZE);
467         p_conv_data->setup_method[MAX_RTCP_SETUP_METHOD_SIZE] = '\0';
468         p_conv_data->setup_frame_number = setup_frame_number;
469 }
470
471 static gboolean
472 dissect_rtcp_heur( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
473 {
474         unsigned int offset = 0;
475         unsigned int first_byte;
476         unsigned int packet_type;
477
478         /* This is a heuristic dissector, which means we get all the UDP
479          * traffic not sent to a known dissector and not claimed by
480          * a heuristic dissector called before us!
481          */
482
483         if (!global_rtcp_heur)
484         {
485                 return FALSE;
486         }
487
488         /* Was it sent between 2 odd-numbered ports? */
489         if (!(pinfo->srcport % 2) || !(pinfo->destport % 2))
490         {
491                 return FALSE;
492         }
493
494         /* Look at first byte */
495         first_byte = tvb_get_guint8(tvb, offset);
496
497         /* Are version bits set to 2? */
498         if (((first_byte & 0xC0) >> 6) != 2)
499         {
500                 return FALSE;
501         }
502
503         /* Look at packet type */
504         packet_type = tvb_get_guint8(tvb, offset + 1);
505
506         /* First packet within compound packet is supposed to be a sender
507            or receiver report.  Also see BYE so allow this...  */
508         if (!((packet_type == RTCP_SR)  || (packet_type == RTCP_RR) ||
509            packet_type == RTCP_BYE))
510         {
511                 return FALSE;
512         }
513
514         /* Overall length must be a multiple of 4 bytes */
515         if (tvb_length(tvb) % 4)
516         {
517                 return FALSE;
518         }
519
520         /* OK, dissect as RTCP */
521         dissect_rtcp(tvb, pinfo, tree);
522         return TRUE;
523 }
524
525
526 static int
527 dissect_rtcp_nack( tvbuff_t *tvb, int offset, proto_tree *tree )
528 {
529         /* Packet type = FIR (H261) */
530         proto_tree_add_uint( tree, hf_rtcp_rc, tvb, offset, 1, tvb_get_guint8( tvb, offset ) );
531         offset++;
532         /* Packet type, 8 bits  = APP */
533         proto_tree_add_item( tree, hf_rtcp_pt, tvb, offset, 1, FALSE );
534         offset++;
535
536         /* Packet length in 32 bit words minus one */
537         proto_tree_add_uint( tree, hf_rtcp_length, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
538         offset += 2;
539
540         /* SSRC  */
541         proto_tree_add_uint( tree, hf_rtcp_ssrc_source, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
542         offset += 4;
543
544         /* FSN, 16 bits */
545         proto_tree_add_uint( tree, hf_rtcp_fsn, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
546         offset += 2;
547
548         /* BLP, 16 bits */
549         proto_tree_add_uint( tree, hf_rtcp_blp, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
550         offset += 2;
551
552         return offset;
553 }
554
555 static int
556 dissect_rtcp_fir( tvbuff_t *tvb, int offset, proto_tree *tree )
557 {
558         /* Packet type = FIR (H261) */
559         proto_tree_add_uint( tree, hf_rtcp_rc, tvb, offset, 1, tvb_get_guint8( tvb, offset ) );
560         offset++;
561         /* Packet type, 8 bits  = APP */
562         proto_tree_add_item( tree, hf_rtcp_pt, tvb, offset, 1, FALSE );
563         offset++;
564
565         /* Packet length in 32 bit words minus one */
566         proto_tree_add_uint( tree, hf_rtcp_length, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
567         offset += 2;
568
569         /* SSRC  */
570         proto_tree_add_uint( tree, hf_rtcp_ssrc_source, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
571         offset += 4;
572
573         return offset;
574 }
575
576 static int
577 dissect_rtcp_app( tvbuff_t *tvb,packet_info *pinfo, int offset, proto_tree *tree,
578     unsigned int padding, unsigned int packet_len, guint rtcp_subtype )
579 {
580         unsigned int counter = 0;
581         char ascii_name[5];
582         guint sdes_type         = 0;
583         guint item_len          = 0;
584         guint items_start_offset;
585         proto_tree *PoC1_tree;
586         proto_item *PoC1_item;
587
588         /* XXX If more application types are to be dissected it may be useful to use a table like in packet-sip.c */
589         static const char app_name_str[] = "PoC1";
590
591
592         /* SSRC / CSRC */
593         proto_tree_add_uint( tree, hf_rtcp_ssrc_source, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
594         offset += 4;
595         packet_len -= 4;
596
597         /* Name (ASCII) */
598         for( counter = 0; counter < 4; counter++ )
599             ascii_name[ counter ] = tvb_get_guint8( tvb, offset + counter );
600         /* strncpy( ascii_name, pd + offset, 4 ); */
601         ascii_name[4] = '\0';
602         proto_tree_add_string( tree, hf_rtcp_name_ascii, tvb, offset, 4,
603             ascii_name );
604         if ( strncasecmp(ascii_name,app_name_str,4 ) != 0 ){ /* Not PoC1 */
605                 if (check_col(pinfo->cinfo, COL_INFO))
606                         col_append_fstr(pinfo->cinfo, COL_INFO,"( %s ) subtype=%u",ascii_name, rtcp_subtype);
607                 offset += 4;
608                 packet_len -= 4;
609                 /* Applications specific data */
610                 if ( padding ) {
611                         /* If there's padding present, we have to remove that from the data part
612                         * The last octet of the packet contains the length of the padding
613                         */
614                         packet_len -= tvb_get_guint8( tvb, offset + packet_len - 1 );
615                 }
616                 proto_tree_add_item( tree, hf_rtcp_app_data, tvb, offset, packet_len, FALSE );
617                 offset += packet_len;
618
619                 return offset;
620         }else{/* PoC1 Application */
621                 proto_item *item;
622                 item = proto_tree_add_uint( tree, hf_rtcp_app_poc1_subtype, tvb, offset - 8, 1, rtcp_subtype );
623                 PROTO_ITEM_SET_GENERATED(item);
624                 if (check_col(pinfo->cinfo, COL_INFO))
625                         col_append_fstr(pinfo->cinfo, COL_INFO,"(%s) subtype=%s",ascii_name,
626                                 val_to_str(rtcp_subtype,rtcp_app_poc1_floor_cnt_type_vals,"unknown (%u)") );
627                 offset += 4;
628                 packet_len -= 4;
629                 /* Applications specific data */
630                 if ( padding ) {
631                         /* If there's padding present, we have to remove that from the data part
632                         * The last octet of the packet contains the length of the padding
633                         */
634                         packet_len -= tvb_get_guint8( tvb, offset + packet_len - 1 );
635                 }
636                 /* Create a subtree for the PoC1 Application items; we don't yet know
637                    the length */
638                 items_start_offset = offset;
639
640                 PoC1_item = proto_tree_add_text(tree, tvb, offset, packet_len,
641                     "PoC1 Application specific data");
642                 PoC1_tree = proto_item_add_subtree( PoC1_item, ett_PoC1 );
643
644
645                 proto_tree_add_item( PoC1_tree, hf_rtcp_app_data, tvb, offset, packet_len, FALSE );
646                 switch ( rtcp_subtype ) {
647                         case 2:
648                         case 18:
649                                 sdes_type = tvb_get_guint8( tvb, offset );
650                                 proto_tree_add_item( PoC1_tree, hf_rtcp_ssrc_type, tvb, offset, 1, FALSE );
651                                 offset++;
652                                 packet_len--;
653                                 /* Item length, 8 bits */
654                                 item_len = tvb_get_guint8( tvb, offset );
655                                 proto_tree_add_item( PoC1_tree, hf_rtcp_ssrc_length, tvb, offset, 1, FALSE );
656                                 offset++;
657                                 packet_len--;
658                                 proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_sip_uri, tvb, offset, item_len, FALSE );
659                                 offset = offset + item_len;
660                                 packet_len = packet_len - item_len;
661                                 sdes_type = tvb_get_guint8( tvb, offset );
662                                 proto_tree_add_item( PoC1_tree, hf_rtcp_ssrc_type, tvb, offset, 1, FALSE );
663                                 offset++;
664                                 packet_len--;
665                                 /* Item length, 8 bits */
666                                 item_len = tvb_get_guint8( tvb, offset );
667                                 proto_tree_add_item( PoC1_tree, hf_rtcp_ssrc_length, tvb, offset, 1, FALSE );
668                                 offset++;
669                                 packet_len--;
670                                 if ( item_len != 0 )
671                                         proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_disp_name, tvb, offset, item_len, FALSE );
672                                 offset = offset + item_len;
673                                 packet_len = packet_len - item_len;
674                                 break;
675                         case 3:
676                                 proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_reason_code1, tvb, offset, 1, FALSE );
677                                 offset++;
678                                 packet_len--;
679                                 /* Item length, 8 bits */
680                                 item_len = tvb_get_guint8( tvb, offset );
681                                 proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_item_len, tvb, offset, 1, FALSE );
682                                 offset++;
683                                 packet_len--;
684                                 if ( item_len != 0 )
685                                         proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_reason1_phrase, tvb, offset, item_len, FALSE );
686                                 offset = offset + item_len;
687                                 packet_len = packet_len - item_len;
688                                 break;
689                         case 4:
690                                 proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_last_pkt_seq_no, tvb, offset, 2, FALSE );
691                                 proto_tree_add_text(PoC1_tree, tvb, offset + 2, 2, "Padding 2 bytes");
692                                 offset += 4;
693                                 packet_len-=4;
694                                 break;
695                         case 6:
696                                 proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_reason_code2, tvb, offset, 2, FALSE );
697                                 proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_additionalinfo, tvb, offset + 2, 2, FALSE );
698                                 offset += 4;
699                                 packet_len-=4;
700                                 break;
701
702                         case 7:
703                             proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_ack_subtype, tvb, offset, 1, FALSE );
704                             proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_ack_reason_code, tvb, offset, 2, FALSE );
705                             proto_tree_add_text( PoC1_tree, tvb, offset + 2, 2, "Padding 2 bytes" );
706                             offset += 4;
707                             packet_len -= 4;
708                             break;
709
710                         case 9:
711                             proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_qsresp_priority, tvb, offset, 1, FALSE );
712                             proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_qsresp_position, tvb, offset + 1, 2, FALSE );
713                             proto_tree_add_text( PoC1_tree, tvb, offset + 3, 1, "Padding 1 byte" );
714                             offset += 4;
715                             packet_len -= 4;
716                             break;
717
718                         case 15: {
719                             proto_item *content = proto_tree_add_text(PoC1_tree, tvb, offset, 2, "SDES item content");
720                             gboolean contents[5];
721                             unsigned int i;
722
723                             proto_tree *content_tree = proto_item_add_subtree(content, ett_poc1_conn_contents);
724                             guint temp_byte = tvb_get_guint8( tvb, offset );
725
726                             for ( i = 0; i < sizeof(contents) /
727                                       sizeof(contents[0]) &&
728                                       i < sizeof(hf_rtcp_app_poc1_conn_content_1st_byte) /
729                                       sizeof(hf_rtcp_app_poc1_conn_content_1st_byte[0]);
730                                   ++i ) {
731                                 proto_tree_add_item( content_tree, hf_rtcp_app_poc1_conn_content_1st_byte[i], tvb, offset, 1, FALSE );
732                                 contents[i] = temp_byte & (1 << (7-i));
733                             }
734
735                             proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_conn_session_type, tvb, offset + 2, 1, FALSE );
736
737                             proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_conn_add_ind_mao, tvb, offset + 3, 1, FALSE );
738                             
739                             offset += 4;
740                             packet_len -= 4;
741
742                             for ( i = 0; i < sizeof(contents) /
743                                       sizeof(contents[0]); ++i ) {
744                                 if ( contents[i] ) {
745                                     guint sdes_type, sdes_len;
746                                     sdes_type = tvb_get_guint8( tvb, offset++ );
747                                     sdes_len = tvb_get_guint8( tvb, offset );
748
749                                     proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_conn_sdes_items[i], tvb, offset, 1, FALSE );
750
751                                     offset += sdes_len + 1;
752                                     packet_len -= (sdes_len + 2);
753                                 }
754                             }
755                             break;
756                         }    
757                         default:
758                                 break;
759                 }
760                 offset += packet_len;
761                 return offset;
762         }
763 }
764
765
766 static int
767 dissect_rtcp_bye( tvbuff_t *tvb, int offset, proto_tree *tree,
768     unsigned int count )
769 {
770         unsigned int chunk          = 1;
771         unsigned int reason_length  = 0;
772         char* reason_text = NULL;
773
774         while ( chunk <= count ) {
775                 /* source identifier, 32 bits */
776                 proto_tree_add_item( tree, hf_rtcp_ssrc_source, tvb, offset, 4, FALSE);
777                 offset += 4;
778                 chunk++;
779         }
780
781         if ( tvb_reported_length_remaining( tvb, offset ) > 0 ) {
782                 /* Bye reason consists of an 8 bit length l and a string with length l */
783                 reason_length = tvb_get_guint8( tvb, offset );
784                 proto_tree_add_item( tree, hf_rtcp_ssrc_length, tvb, offset, 1, FALSE );
785                 offset++;
786
787                 reason_text = tvb_get_ephemeral_string(tvb, offset, reason_length);
788                 proto_tree_add_string( tree, hf_rtcp_ssrc_text, tvb, offset, reason_length, reason_text );
789                 offset += reason_length;
790         }
791
792         return offset;
793
794 }
795
796 static void
797 dissect_rtcp_sdes( tvbuff_t *tvb, int offset, proto_tree *tree,
798     unsigned int count )
799 {
800         unsigned int chunk          = 1;
801         proto_item *sdes_item;
802         proto_tree *sdes_tree;
803         proto_tree *sdes_item_tree;
804         proto_item *ti;
805         int start_offset;
806         int items_start_offset;
807         guint32 ssrc;
808         unsigned int item_len       = 0;
809         unsigned int sdes_type      = 0;
810         unsigned int counter        = 0;
811         unsigned int prefix_len     = 0;
812         char *prefix_string = NULL;
813
814         while ( chunk <= count ) {
815                 /* Create a subtree for this chunk; we don't yet know
816                    the length. */
817                 start_offset = offset;
818
819                 ssrc = tvb_get_ntohl( tvb, offset );
820                 sdes_item = proto_tree_add_text(tree, tvb, offset, -1,
821                     "Chunk %u, SSRC/CSRC %u", chunk, ssrc);
822                 sdes_tree = proto_item_add_subtree( sdes_item, ett_sdes );
823
824                 /* SSRC_n source identifier, 32 bits */
825                 proto_tree_add_uint( sdes_tree, hf_rtcp_ssrc_source, tvb, offset, 4, ssrc );
826                 offset += 4;
827
828                 /* Create a subtree for the SDES items; we don't yet know
829                    the length */
830                 items_start_offset = offset;
831                 ti = proto_tree_add_text(sdes_tree, tvb, offset, -1,
832                     "SDES items" );
833                 sdes_item_tree = proto_item_add_subtree( ti, ett_sdes_item );
834
835                 /*
836                  * Not every message is ended with "null" bytes, so check for
837                  * end of frame as well.
838                  */
839                 while ( tvb_reported_length_remaining( tvb, offset ) > 0 ) {
840                         /* ID, 8 bits */
841                         sdes_type = tvb_get_guint8( tvb, offset );
842                         proto_tree_add_item( sdes_item_tree, hf_rtcp_ssrc_type, tvb, offset, 1, FALSE );
843                         offset++;
844
845                         if ( sdes_type == RTCP_SDES_END ) {
846                                 /* End of list */
847                                 break;
848                         }
849
850                         /* Item length, 8 bits */
851                         item_len = tvb_get_guint8( tvb, offset );
852                         proto_tree_add_item( sdes_item_tree, hf_rtcp_ssrc_length, tvb, offset, 1, FALSE );
853                         offset++;
854
855                         if ( sdes_type == RTCP_SDES_PRIV ) {
856                                 /* PRIV adds two items between the SDES length
857                                  * and value - an 8 bit length giving the
858                                  * length of a "prefix string", and the string.
859                                  */
860                                 prefix_len = tvb_get_guint8( tvb, offset );
861                                 proto_tree_add_item( sdes_item_tree, hf_rtcp_ssrc_prefix_len, tvb, offset, 1, FALSE );
862                                 offset++;
863
864                                 prefix_string = ep_alloc( prefix_len + 1 );
865                                 for ( counter = 0; counter < prefix_len; counter++ )
866                                         prefix_string[ counter ] =
867                                             tvb_get_guint8( tvb, offset + counter );
868                                 /* strncpy( prefix_string, pd + offset, prefix_len ); */
869                                 prefix_string[ prefix_len ] = '\0';
870                                 proto_tree_add_string( sdes_item_tree, hf_rtcp_ssrc_prefix_string, tvb, offset, prefix_len, prefix_string );
871                                 offset += prefix_len;
872                         }
873                         prefix_string = ep_alloc( item_len + 1 );
874                         for ( counter = 0; counter < item_len; counter++ )
875                             prefix_string[ counter ] =
876                                 tvb_get_guint8( tvb, offset + counter );
877                         /* strncpy( prefix_string, pd + offset, item_len ); */
878                         prefix_string[ item_len] = 0;
879                         proto_tree_add_string( sdes_item_tree, hf_rtcp_ssrc_text, tvb, offset, item_len, prefix_string );
880                         offset += item_len;
881                 }
882
883                 /* Set the length of the items subtree. */
884                 proto_item_set_len(ti, offset - items_start_offset);
885
886                 /* 32 bits = 4 bytes, so.....
887                  * If offset % 4 != 0, we divide offset by 4, add one and then
888                  * multiply by 4 again to reach the boundary
889                  */
890                 if ( offset % 4 != 0 )
891                         offset = ((offset / 4) + 1 ) * 4;
892
893                 /* Set the length of this chunk. */
894                 proto_item_set_len(sdes_item, offset - start_offset);
895
896                 chunk++;
897         }
898 }
899
900 static void parse_xr_type_specific_field(tvbuff_t *tvb, gint offset, guint block_type, proto_tree *tree)
901 {
902     guint8 flags = tvb_get_guint8(tvb, offset);
903
904     switch (block_type) {
905     case RTCP_XR_LOSS_RLE:
906     case RTCP_XR_DUP_RLE:
907     case RTCP_XR_PKT_RXTIMES:
908         proto_tree_add_uint(tree, hf_rtcp_xr_thinning, tvb, offset, 1, flags);
909         break;
910         
911     case RTCP_XR_STATS_SUMRY:
912         proto_tree_add_boolean(tree, hf_rtcp_xr_stats_loss_flag, tvb, offset, 1, flags);
913         proto_tree_add_boolean(tree, hf_rtcp_xr_stats_dup_flag, tvb, offset, 1, flags);
914         proto_tree_add_boolean(tree, hf_rtcp_xr_stats_jitter_flag, tvb, offset, 1, flags);
915         proto_tree_add_uint(tree, hf_rtcp_xr_stats_ttl, tvb, offset, 1, flags);
916         break;
917
918     default:
919         proto_tree_add_uint(tree, hf_rtcp_xr_block_specific, tvb, offset, 1, flags);
920         break;
921     }
922 }
923
924 static gboolean validate_xr_block_length(tvbuff_t *tvb, int offset, guint block_type, guint block_len, proto_tree *tree)
925 {
926     proto_tree_add_uint(tree, hf_rtcp_xr_block_length, tvb, offset, 2, block_len);
927     switch (block_type) {
928     case RTCP_XR_REF_TIME:
929         if (block_len != 2)
930             proto_tree_add_text(tree, tvb, offset, 2, "Invalid block length, should be 2");
931         return FALSE;
932
933     case RTCP_XR_STATS_SUMRY:
934         if (block_len != 9)
935             proto_tree_add_text(tree, tvb, offset, 2, "Invalid block length, should be 9");
936         return FALSE;
937
938     case RTCP_XR_VOIP_METRCS:
939         if (block_len != 8)
940             proto_tree_add_text(tree, tvb, offset, 2, "Invalid block length, should be 8");
941         return FALSE;
942
943     default:
944         break;
945     }
946     return TRUE;
947 }
948
949 static int
950 dissect_rtcp_xr(tvbuff_t *tvb, packet_info *pinfo _U_, int offset, proto_tree *tree, gint packet_len)
951 {
952     guint block_num = 1;
953     
954     /* Packet length should at least be 4 */
955     if (packet_len < 4) {
956         proto_tree_add_text(tree, tvb, offset, packet_len, "Missing Sender SSRC");
957         return offset + packet_len;
958     }
959         
960     /* SSRC */
961     proto_tree_add_item( tree, hf_rtcp_ssrc_sender, tvb, offset, 4, FALSE );
962     offset += 4;
963     packet_len -= 4;
964     
965     for(;packet_len > 0; block_num++) {
966         guint block_type = tvb_get_guint8(tvb, offset), block_length = 0;
967         gint content_length = 0;
968         gboolean valid = TRUE;
969         
970         /* Create a subtree for this block, dont know the length yet*/
971         proto_item *block = proto_tree_add_text(tree, tvb, offset, -1, "Block %u", block_num);
972         proto_tree *xr_block_tree = proto_item_add_subtree(block, ett_xr_block);
973         proto_item *contents = NULL;
974         proto_item *content_tree = NULL;
975
976         proto_tree_add_item(xr_block_tree, hf_rtcp_xr_block_type, tvb, offset, 1, FALSE);
977         
978         if (packet_len >= 2) {
979             parse_xr_type_specific_field(tvb, offset + 1, block_type, xr_block_tree);
980             if (packet_len >= 4) {
981                 block_length = tvb_get_ntohs(tvb, offset + 2);
982                 valid = validate_xr_block_length(tvb, offset + 2, block_type, block_length, xr_block_tree);
983             }
984         } else {
985             proto_tree_add_text(xr_block_tree, tvb, offset + 1, packet_len, "Missing Required Block Headers");
986             return offset + packet_len;
987         }
988                 
989         content_length = block_length * 4;
990         proto_item_set_len(block, content_length + 4);
991         
992         if (content_length > packet_len) {
993             proto_tree_add_text(xr_block_tree, tvb, offset + 2, 2, "Block length is greater than packet length");
994         }
995                 
996         offset += 4;
997         packet_len -= 4;
998
999         contents = proto_tree_add_text(xr_block_tree, tvb, offset, content_length, "Contents");
1000         content_tree = proto_item_add_subtree(contents, ett_xr_block_contents);
1001             
1002         switch (block_type) {
1003         case RTCP_XR_VOIP_METRCS: {
1004             guint fraction_rate, value;
1005             
1006             /* Identifier */
1007             proto_tree_add_item(content_tree, hf_rtcp_ssrc_source, tvb, offset, 4, FALSE);
1008             offset += 4;
1009             
1010             /* Loss Rate */
1011             fraction_rate = tvb_get_guint8(tvb, offset);
1012             proto_tree_add_uint_format(content_tree, hf_rtcp_ssrc_fraction, tvb, offset, 1, 
1013                                        fraction_rate, "Fraction lost: %u / 256", fraction_rate);
1014             offset++;
1015             
1016             /* Discard Rate */
1017             fraction_rate = tvb_get_guint8(tvb, offset);
1018             proto_tree_add_uint_format(content_tree, hf_rtcp_ssrc_discarded, tvb, offset, 1, 
1019                                        fraction_rate, "Fraction Discarded: %u / 256", fraction_rate);
1020             offset++;
1021             
1022             /* Burst Density */
1023             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_burst_density, tvb, offset, 1, FALSE);
1024             offset++;
1025             
1026             /* Gap Density */
1027             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_gap_density, tvb, offset, 1, FALSE);
1028             offset++;
1029             
1030             /* Burst Duration */
1031             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_burst_duration, tvb, offset, 2, FALSE);
1032             offset += 2;
1033             
1034             /* Gap Duration */
1035             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_gap_duration, tvb, offset, 2, FALSE);
1036             offset += 2;
1037             
1038             /* Round Trip Delay */
1039             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_rtdelay, tvb, offset, 2, FALSE);
1040             offset += 2;
1041             
1042             /* End System Delay */
1043             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_esdelay, tvb, offset, 2, FALSE);
1044             offset += 2;
1045             
1046             /* Signal Level */
1047             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_siglevel, tvb, offset, 1, FALSE);
1048             offset++;
1049             
1050             /* Noise Level */
1051             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_noiselevel, tvb, offset, 1, FALSE);
1052             offset++;
1053             
1054             /* RERL */
1055             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_rerl, tvb, offset, 1, FALSE);
1056             offset++;
1057             
1058             /* GMin */
1059             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_gmin, tvb, offset, 1, FALSE);
1060             offset++;
1061             
1062             /* R factor */
1063             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_rfactor, tvb, offset, 1, FALSE);
1064             offset++;
1065             
1066             /* external R Factor */
1067             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_extrfactor, tvb, offset, 1, FALSE);
1068             offset++;
1069             
1070             /* MOS LQ */
1071             proto_tree_add_float(content_tree, hf_rtcp_xr_voip_metrics_moslq, tvb, offset, 1, 
1072                                  (gfloat)tvb_get_guint8(tvb, offset) / 10);
1073             offset++;
1074             
1075             /* MOS CQ */
1076             proto_tree_add_float(content_tree, hf_rtcp_xr_voip_metrics_moscq, tvb, offset, 1, 
1077                                  (gfloat)tvb_get_guint8(tvb, offset) / 10);
1078             offset++;
1079             
1080             /* PLC, JB Adaptive, JB Rate */
1081             value = tvb_get_guint8(tvb, offset);
1082             proto_tree_add_uint(content_tree, hf_rtcp_xr_voip_metrics_plc, tvb, offset, 1, value);
1083             proto_tree_add_uint(content_tree, hf_rtcp_xr_voip_metrics_jbadaptive, tvb, offset, 1, value);
1084             proto_tree_add_uint(content_tree, hf_rtcp_xr_voip_metrics_jbrate, tvb, offset, 1, value);
1085             offset += 2; /* skip over reseved bit */
1086             
1087             /* JB Nominal */
1088             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_jbnominal, tvb, offset, 2, FALSE);
1089             offset += 2;
1090             
1091             /* JB Max */
1092             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_jbmax, tvb, offset, 2, FALSE);
1093             offset += 2;
1094             
1095             /* JB Abs max */
1096             proto_tree_add_item(content_tree, hf_rtcp_xr_voip_metrics_jbabsmax, tvb, offset, 2, FALSE);
1097             offset += 2;
1098
1099             break;
1100         }
1101             
1102         case RTCP_XR_STATS_SUMRY: {
1103             /* Identifier */
1104             proto_tree_add_item(content_tree, hf_rtcp_ssrc_source, tvb, offset, 4, FALSE);
1105             offset += 4;
1106
1107             /* Begin Seq */
1108             proto_tree_add_item(content_tree, hf_rtcp_xr_beginseq, tvb, offset, 2, FALSE);
1109             offset += 2;
1110
1111             /* End Seq */
1112             proto_tree_add_item(content_tree, hf_rtcp_xr_endseq, tvb, offset, 2, FALSE);
1113             offset += 2;
1114
1115             /* Lost Pkts */
1116             proto_tree_add_item(content_tree, hf_rtcp_xr_stats_lost, tvb, offset, 4, FALSE);
1117             offset += 4;
1118
1119             /* Dup Pkts */
1120             proto_tree_add_item(content_tree, hf_rtcp_xr_stats_dups, tvb, offset, 4, FALSE);
1121             offset += 4;
1122
1123             /* Min Jitter */
1124             proto_tree_add_item(content_tree, hf_rtcp_xr_stats_minjitter, tvb, offset, 4, FALSE);
1125             offset += 4;
1126
1127             /* Max Jitter */
1128             proto_tree_add_item(content_tree, hf_rtcp_xr_stats_maxjitter, tvb, offset, 4, FALSE);
1129             offset += 4;
1130
1131             /* Mean Jitter */
1132             proto_tree_add_item(content_tree, hf_rtcp_xr_stats_meanjitter, tvb, offset, 4, FALSE);
1133             offset += 4;
1134
1135             /* Dev Jitter */
1136             proto_tree_add_item(content_tree, hf_rtcp_xr_stats_devjitter, tvb, offset, 4, FALSE);
1137             offset += 4;
1138
1139             /* Min TTL */
1140             proto_tree_add_item(content_tree, hf_rtcp_xr_stats_minttl, tvb, offset, 1, FALSE);
1141             offset ++;
1142
1143             /* Max TTL */
1144             proto_tree_add_item(content_tree, hf_rtcp_xr_stats_maxttl, tvb, offset, 1, FALSE);
1145             offset ++;
1146
1147             /* Mean TTL */
1148             proto_tree_add_item(content_tree, hf_rtcp_xr_stats_meanttl, tvb, offset, 1, FALSE);
1149             offset ++;
1150
1151             /* Dev TTL */
1152             proto_tree_add_item(content_tree, hf_rtcp_xr_stats_devttl, tvb, offset, 1, FALSE);
1153             offset ++;
1154
1155             break;
1156         }
1157
1158         case RTCP_XR_REF_TIME: {
1159             guint32 ts_msw, ts_lsw;
1160
1161             ts_msw = tvb_get_ntohl(tvb, offset);
1162             proto_tree_add_text(content_tree, tvb, offset, 4, "Timestamp, MSW: %u", ts_msw);
1163             offset += 4;
1164             ts_lsw = tvb_get_ntohl(tvb, offset);
1165             proto_tree_add_text(content_tree, tvb, offset, 4, "Timestamp, LSW: %u", ts_lsw);
1166             offset += 4;
1167             
1168             break;
1169         }
1170
1171         case RTCP_XR_DLRR: {
1172             /* Each report block is 12 bytes */
1173             gint sources = content_length / 12;
1174             gint counter = 0;
1175             for(counter = 0; counter < sources; counter++) {
1176                 /* Create a new subtree for a length of 12 bytes */
1177                 proto_tree *ti = proto_tree_add_text(content_tree, tvb, offset, 12, "Source %u", counter + 1);
1178                 proto_tree *ssrc_tree = proto_item_add_subtree(ti, ett_xr_ssrc);
1179                 
1180                 /* SSRC_n source identifier, 32 bits */
1181                 proto_tree_add_item(ssrc_tree, hf_rtcp_ssrc_source, tvb, offset, 4, FALSE);
1182                 offset += 4;
1183                 
1184                 /* Last RR timestamp */
1185                 proto_tree_add_item(ssrc_tree, hf_rtcp_xr_lrr, tvb, offset, 4, FALSE);
1186                 offset += 4;
1187                 
1188                 /* Delay since last RR timestamp */
1189                 proto_tree_add_item(ssrc_tree, hf_rtcp_xr_dlrr, tvb, offset, 4, FALSE);
1190                 offset += 4;
1191             }
1192             
1193             if (content_length % 12 != 0)
1194                 offset += content_length % 12;
1195             break;
1196         }
1197
1198         case RTCP_XR_PKT_RXTIMES: {
1199             /* 8 bytes of fixed header */
1200             gint count = 0, skip = 8;
1201             guint16 begin = 0;
1202
1203             /* Identifier */
1204             proto_tree_add_item(content_tree, hf_rtcp_ssrc_source, tvb, offset, 4, FALSE);
1205             offset += 4;
1206
1207             /* Begin Seq */
1208             begin = tvb_get_ntohs(tvb, offset);
1209             proto_tree_add_uint(content_tree, hf_rtcp_xr_beginseq, tvb, offset, 2, begin);
1210             offset += 2;
1211
1212             /* End Seq */
1213             proto_tree_add_item(content_tree, hf_rtcp_xr_endseq, tvb, offset, 2, FALSE);
1214             offset += 2;
1215
1216             for(count = 0; skip < content_length; skip += 4, count++) { 
1217                 proto_tree_add_text(content_tree, tvb, offset, 4, "Seq: %u, Timestamp: %u", 
1218                                     (begin + count) % 65536, FALSE);
1219                 offset += 4;
1220             }
1221             break;
1222         }
1223
1224         case RTCP_XR_LOSS_RLE:
1225         case RTCP_XR_DUP_RLE: {
1226             /* 8 bytes of fixed header */
1227             gint count = 0, skip = 8;
1228             guint16 begin = 0;
1229             proto_item *chunks_item;
1230             proto_tree *chunks_tree;
1231             
1232             /* Identifier */
1233             proto_tree_add_item(content_tree, hf_rtcp_ssrc_source, tvb, offset, 4, FALSE);
1234             offset += 4;
1235
1236             /* Begin Seq */
1237             begin = tvb_get_ntohs(tvb, offset);
1238             proto_tree_add_uint(content_tree, hf_rtcp_xr_beginseq, tvb, offset, 2, begin);
1239             offset += 2;
1240
1241             /* End Seq */
1242             proto_tree_add_item(content_tree, hf_rtcp_xr_endseq, tvb, offset, 2, FALSE);
1243             offset += 2;
1244
1245             /* report Chunks */
1246             chunks_item = proto_tree_add_text(content_tree, tvb, offset, content_length,"Report Chunks");
1247             chunks_tree = proto_item_add_subtree(chunks_item, ett_xr_loss_chunk);
1248
1249             for(count = 1; skip < content_length; skip += 2, count++) {
1250                 guint value = tvb_get_ntohs(tvb, offset);
1251                 
1252                 if (value == 0) {
1253                     proto_tree_add_text(chunks_tree, tvb, offset, 2,
1254                                         "Chunk: %u -- Null Terminator ",
1255                                         count);
1256                 } else if (( value & 0x8000 )) {
1257                     const gchar* run_type = (value & 0x4000) ? "1s" : "0s";
1258                     value &= 0x7FFF;
1259                     proto_tree_add_text(chunks_tree, tvb, offset, 2,
1260                                         "Chunk: %u -- Length Run %s, length: %u",
1261                                         count, run_type, value);
1262                 } else {
1263                     char bits[20+1];
1264                     other_decode_bitfield_value(bits, value, 0x00007FFF, 16);
1265                     proto_tree_add_text(chunks_tree, tvb, offset, 2,
1266                                         "Chunk: %u -- Bit Vector, bits: %s",
1267                                         count, bits );
1268                 }
1269                 offset += 2;
1270             }
1271             
1272             break;
1273         }
1274
1275         default:
1276             /* skip over the unknown block */
1277             offset += content_length;
1278             break;
1279         }
1280         packet_len -= content_length;
1281     }
1282     return offset;
1283 }
1284
1285 static int
1286 dissect_rtcp_rr( packet_info *pinfo, tvbuff_t *tvb, int offset, proto_tree *tree,
1287     unsigned int count )
1288 {
1289         unsigned int counter = 1;
1290         proto_tree *ssrc_tree = (proto_tree*) NULL;
1291         proto_tree *ssrc_sub_tree = (proto_tree*) NULL;
1292         proto_tree *high_sec_tree = (proto_tree*) NULL;
1293         proto_item *ti = (proto_item*) NULL;
1294         guint8 rr_flt;
1295         unsigned int cum_nr = 0;
1296
1297         while ( counter <= count ) {
1298                 guint32 lsr, dlsr;
1299
1300                 /* Create a new subtree for a length of 24 bytes */
1301                 ti = proto_tree_add_text(tree, tvb, offset, 24,
1302                     "Source %u", counter );
1303                 ssrc_tree = proto_item_add_subtree( ti, ett_ssrc );
1304
1305                 /* SSRC_n source identifier, 32 bits */
1306                 proto_tree_add_item( ssrc_tree, hf_rtcp_ssrc_source, tvb, offset, 4, FALSE );
1307                 offset += 4;
1308
1309                 ti = proto_tree_add_text(ssrc_tree, tvb, offset, 20, "SSRC contents" );
1310                 ssrc_sub_tree = proto_item_add_subtree( ti, ett_ssrc_item );
1311
1312                 /* Fraction lost, 8bits */
1313                 rr_flt = tvb_get_guint8( tvb, offset );
1314                 proto_tree_add_uint_format( ssrc_sub_tree, hf_rtcp_ssrc_fraction, tvb,
1315                     offset, 1, rr_flt, "Fraction lost: %u / 256", rr_flt );
1316                 offset++;
1317
1318                 /* Cumulative number of packets lost, 24 bits */
1319                 cum_nr = tvb_get_ntohl( tvb, offset ) >> 8;
1320                 proto_tree_add_uint( ssrc_sub_tree, hf_rtcp_ssrc_cum_nr, tvb,
1321                     offset, 3, cum_nr );
1322                 offset += 3;
1323
1324                 /* Extended highest sequence nr received, 32 bits
1325                  * Just for the sake of it, let's add another subtree
1326                  * because this might be a little clearer
1327                  */
1328                 ti = proto_tree_add_uint( ssrc_tree, hf_rtcp_ssrc_ext_high_seq,
1329                     tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
1330                 high_sec_tree = proto_item_add_subtree( ti, ett_ssrc_ext_high );
1331                 /* Sequence number cycles */
1332                 proto_tree_add_item( high_sec_tree, hf_rtcp_ssrc_high_cycles,
1333                     tvb, offset, 2, FALSE );
1334                 offset += 2;
1335                 /* highest sequence number received */
1336                 proto_tree_add_item( high_sec_tree, hf_rtcp_ssrc_high_seq,
1337                     tvb, offset, 2, FALSE );
1338                 offset += 2;
1339
1340                 /* Interarrival jitter */
1341                 proto_tree_add_item( ssrc_tree, hf_rtcp_ssrc_jitter, tvb,
1342                     offset, 4, FALSE );
1343                 offset += 4;
1344
1345                 /* Last SR timestamp */
1346                 lsr = tvb_get_ntohl( tvb, offset );
1347                 proto_tree_add_uint( ssrc_tree, hf_rtcp_ssrc_lsr, tvb,
1348                                      offset, 4, lsr );
1349                 offset += 4;
1350
1351                 /* Delay since last SR timestamp */
1352                 dlsr = tvb_get_ntohl( tvb, offset );
1353                 proto_tree_add_uint( ssrc_tree, hf_rtcp_ssrc_dlsr, tvb,
1354                                      offset, 4, dlsr );
1355                 offset += 4;
1356
1357                 /* Do roundtrip calculation */
1358                 if (global_rtcp_show_roundtrip_calculation)
1359                 {
1360                         /* Based on delay since SR was send in other direction */
1361                         calculate_roundtrip_delay(tvb, pinfo, ssrc_tree, lsr, dlsr);
1362                 }
1363
1364                 counter++;
1365         }
1366
1367         return offset;
1368 }
1369
1370 static int
1371 dissect_rtcp_sr( packet_info *pinfo, tvbuff_t *tvb, int offset, proto_tree *tree,
1372     unsigned int count )
1373 {
1374 #if 0
1375         gchar *buff;
1376         char* ptime = tvb_get_ptr( tvb, offset, 8 );
1377
1378         /* Retreive the NTP timestamp. Using the NTP dissector for this */
1379         buff=ntp_fmt_ts(ptime);
1380         proto_tree_add_string_format( tree, hf_rtcp_ntp, tvb, offset, 8, ( const char* ) buff, "NTP timestamp: %s", buff );
1381         free( ptime ); /*??????????????????????????????????????????????????????????????????*/
1382         offset += 8;
1383 #else
1384         /*
1385          * XXX - RFC 1889 says this is an NTP timestamp, but that appears
1386          * not to be the case.
1387          */
1388         proto_item* item;
1389         guint32 ts_msw, ts_lsw;
1390         gchar *buff;
1391         char* ptime = tvb_get_ptr( tvb, offset, 8 );
1392
1393         ts_msw = tvb_get_ntohl(tvb, offset);
1394         proto_tree_add_text(tree, tvb, offset, 4, "Timestamp, MSW: %u", ts_msw);
1395         offset += 4;
1396         ts_lsw = tvb_get_ntohl(tvb, offset);
1397         proto_tree_add_text(tree, tvb, offset, 4, "Timestamp, LSW: %u", ts_lsw);
1398         offset += 4;
1399
1400         buff=ntp_fmt_ts(ptime);
1401         item = proto_tree_add_string_format( tree, hf_rtcp_ntp, tvb, offset-8, 8, ( const char* ) buff, "MSW and LSW as NTP timestamp: %s", buff );
1402         PROTO_ITEM_SET_GENERATED(item);
1403         free( ptime ); /*??????????????????????????????????????????????????????????????????*/
1404
1405 #endif
1406         /* RTP timestamp, 32 bits */
1407         proto_tree_add_uint( tree, hf_rtcp_rtp_timestamp, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
1408         offset += 4;
1409         /* Sender's packet count, 32 bits */
1410         proto_tree_add_uint( tree, hf_rtcp_sender_pkt_cnt, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
1411         offset += 4;
1412         /* Sender's octet count, 32 bits */
1413         proto_tree_add_uint( tree, hf_rtcp_sender_oct_cnt, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
1414         offset += 4;
1415
1416         /* Record the time of this packet in the sender's conversation */
1417         if (global_rtcp_show_roundtrip_calculation)
1418         {
1419                 /* Use middle 32 bits of 64-bit time value */
1420                 guint32 lsr = ((ts_msw & 0x0000ffff) << 16 | (ts_lsw & 0xffff0000) >> 16);
1421
1422                 /* Record the time that we sent this in appropriate conversation */
1423                 remember_outgoing_sr(pinfo, lsr);
1424         }
1425
1426         /* The rest of the packet is equal to the RR packet */
1427         if ( count != 0 )
1428                 offset = dissect_rtcp_rr( pinfo, tvb, offset, tree, count );
1429
1430         return offset;
1431 }
1432
1433 /* Look for conversation info and display any setup info found */
1434 void show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1435 {
1436         /* Conversation and current data */
1437         conversation_t *p_conv = NULL;
1438         struct _rtcp_conversation_info *p_conv_data = NULL;
1439
1440         /* Use existing packet data if available */
1441         p_conv_data = p_get_proto_data(pinfo->fd, proto_rtcp);
1442
1443         if (!p_conv_data)
1444         {
1445                 /* First time, get info from conversation */
1446                 p_conv = find_conversation(pinfo->fd->num, &pinfo->net_dst, &pinfo->net_src,
1447                                            pinfo->ptype,
1448                                            pinfo->destport, pinfo->srcport, NO_ADDR_B);
1449
1450                 if (p_conv)
1451                 {
1452                         /* Look for data in conversation */
1453                         struct _rtcp_conversation_info *p_conv_packet_data;
1454                         p_conv_data = conversation_get_proto_data(p_conv, proto_rtcp);
1455
1456                         if (p_conv_data)
1457                         {
1458                                 /* Save this conversation info into packet info */
1459                                 p_conv_packet_data = se_alloc(sizeof(struct _rtcp_conversation_info));
1460                                 if (!p_conv_packet_data)
1461                                 {
1462                                         return;
1463                                 }
1464                                 memcpy(p_conv_packet_data, p_conv_data,
1465                                        sizeof(struct _rtcp_conversation_info));
1466
1467                                 p_add_proto_data(pinfo->fd, proto_rtcp, p_conv_packet_data);
1468                         }
1469                 }
1470         }
1471
1472         /* Create setup info subtree with summary info. */
1473         if (p_conv_data && p_conv_data->setup_method_set)
1474         {
1475                 proto_tree *rtcp_setup_tree;
1476                 proto_item *ti =  proto_tree_add_string_format(tree, hf_rtcp_setup, tvb, 0, 0,
1477                                                                "",
1478                                                                "Stream setup by %s (frame %u)",
1479                                                                p_conv_data->setup_method,
1480                                                                p_conv_data->setup_frame_number);
1481                 PROTO_ITEM_SET_GENERATED(ti);
1482                 rtcp_setup_tree = proto_item_add_subtree(ti, ett_rtcp_setup);
1483                 if (rtcp_setup_tree)
1484                 {
1485                         /* Add details into subtree */
1486                         proto_item* item = proto_tree_add_uint(rtcp_setup_tree, hf_rtcp_setup_frame,
1487                                                                tvb, 0, 0, p_conv_data->setup_frame_number);
1488                         PROTO_ITEM_SET_GENERATED(item);
1489                         item = proto_tree_add_string(rtcp_setup_tree, hf_rtcp_setup_method,
1490                                                      tvb, 0, 0, p_conv_data->setup_method);
1491                         PROTO_ITEM_SET_GENERATED(item);
1492                 }
1493         }
1494 }
1495
1496
1497 /* Update conversation data to record time that outgoing rr/sr was sent */
1498 static void remember_outgoing_sr(packet_info *pinfo, long lsr)
1499 {
1500         conversation_t *p_conv = NULL;
1501         struct _rtcp_conversation_info *p_conv_data = NULL;
1502         struct _rtcp_conversation_info *p_packet_data = NULL;
1503
1504         /* This information will be accessed when an incoming packet comes back to
1505            the side that sent this packet, so no use storing in the packet
1506            info.  However, do store the fact that we've already set this info
1507            before  */
1508
1509
1510         /**************************************************************************/
1511         /* First of all, see if we've already stored this information for this sr */
1512
1513         /* Look first in packet info */
1514         p_packet_data = p_get_proto_data(pinfo->fd, proto_rtcp);
1515         if (p_packet_data && p_packet_data->last_received_set &&
1516             p_packet_data->last_received_frame_number >= pinfo->fd->num)
1517         {
1518                 /* We already did this, OK */
1519                 return;
1520         }
1521
1522
1523         /**************************************************************************/
1524         /* Otherwise, we want to find/create the conversation and update it       */
1525
1526         /* First time, get info from conversation.
1527            Even though we think of this as an outgoing packet being sent,
1528            we store the time as being received by the destination. */
1529         p_conv = find_conversation(pinfo->fd->num, &pinfo->net_dst, &pinfo->net_src,
1530                                    pinfo->ptype,
1531                                    pinfo->destport, pinfo->srcport, NO_ADDR_B);
1532
1533         /* If the conversation doesn't exist, create it now. */
1534         if (!p_conv)
1535         {
1536                 p_conv = conversation_new(pinfo->fd->num, &pinfo->net_dst, &pinfo->net_src, PT_UDP,
1537                                           pinfo->destport, pinfo->srcport,
1538                                           NO_ADDR2);
1539                 if (!p_conv)
1540                 {
1541                         /* Give up if can't create it */
1542                         return;
1543                 }
1544         }
1545
1546
1547         /****************************************************/
1548         /* Now find/create conversation data                */
1549         p_conv_data = conversation_get_proto_data(p_conv, proto_rtcp);
1550         if (!p_conv_data)
1551         {
1552                 /* Allocate memory for data */
1553                 p_conv_data = se_alloc(sizeof(struct _rtcp_conversation_info));
1554                 if (!p_conv_data)
1555                 {
1556                         /* Give up if couldn't allocate space for memory */
1557                         return;
1558                 }
1559                 memset(p_conv_data, 0, sizeof(struct _rtcp_conversation_info));
1560
1561                 /* Add it to conversation. */
1562                 conversation_add_proto_data(p_conv, proto_rtcp, p_conv_data);
1563         }
1564
1565         /*******************************************************/
1566         /* Update conversation data                            */
1567         p_conv_data->last_received_set = TRUE;
1568         p_conv_data->last_received_frame_number = pinfo->fd->num;
1569         p_conv_data->last_received_timestamp = pinfo->fd->abs_ts;
1570         p_conv_data->last_received_ts = lsr;
1571
1572
1573         /****************************************************************/
1574         /* Update packet info to record conversation state              */
1575
1576         /* Will use/create packet info */
1577         if (!p_packet_data)
1578         {
1579                 p_packet_data = se_alloc(sizeof(struct _rtcp_conversation_info));
1580                 if (!p_packet_data)
1581                 {
1582                         /* Give up if allocation fails */
1583                         return;
1584                 }
1585                 memset(p_packet_data, 0, sizeof(struct _rtcp_conversation_info));
1586
1587                 p_add_proto_data(pinfo->fd, proto_rtcp, p_packet_data);
1588         }
1589
1590         /* Copy current conversation data into packet info */
1591         p_packet_data->last_received_set = TRUE;
1592         p_packet_data->last_received_frame_number = p_conv_data->last_received_frame_number;
1593         p_packet_data->last_received_timestamp = p_conv_data->last_received_timestamp;
1594 }
1595
1596
1597 /* Use received sr to work out what the roundtrip delay is
1598    (at least between capture point and the other endpoint involved in
1599     the conversation) */
1600 static void calculate_roundtrip_delay(tvbuff_t *tvb, packet_info *pinfo,
1601                                       proto_tree *tree, guint32 lsr, guint32 dlsr)
1602 {
1603         /*****************************************************/
1604         /* This is called dissecting an SR.  We need to:
1605            - look in the packet info for stored calculation.  If found, use.
1606            - look up the conversation of the sending side to see when the
1607              'last SR' was detected (received)
1608            - calculate the network delay using the that packet time,
1609              this packet time, and dlsr
1610         *****************************************************/
1611
1612         conversation_t *p_conv = NULL;
1613         struct _rtcp_conversation_info *p_conv_data = NULL;
1614         struct _rtcp_conversation_info *p_packet_data = NULL;
1615
1616
1617         /*************************************************/
1618         /* Look for previously stored calculation result */
1619         p_packet_data = p_get_proto_data(pinfo->fd, proto_rtcp);
1620         if (p_packet_data && p_packet_data->calculated_delay_set)
1621         {
1622                 /* Show info. */
1623                 add_roundtrip_delay_info(tvb, pinfo, tree,
1624                                          p_packet_data->calculated_delay_used_frame,
1625                                          p_packet_data->calculated_delay);
1626                 return;
1627         }
1628
1629
1630         /********************************************************************/
1631         /* Look for captured timestamp of last SR in conversation of sender */
1632         /* of this packet                                                   */
1633         p_conv = find_conversation(pinfo->fd->num, &pinfo->net_src, &pinfo->net_dst,
1634                                    pinfo->ptype,
1635                                    pinfo->srcport, pinfo->destport, NO_ADDR_B);
1636         if (!p_conv)
1637         {
1638                 return;
1639         }
1640
1641         /* Look for conversation data  */
1642         p_conv_data = conversation_get_proto_data(p_conv, proto_rtcp);
1643         if (!p_conv_data)
1644         {
1645                 return;
1646         }
1647
1648         if (p_conv_data->last_received_set)
1649         {
1650                 /* Store result of calculation in packet info */
1651                 if (!p_packet_data)
1652                 {
1653                         /* Create packet info if it doesn't exist */
1654                         p_packet_data = se_alloc(sizeof(struct _rtcp_conversation_info));
1655                         if (!p_packet_data)
1656                         {
1657                                 /* Give up if allocation fails */
1658                                 return;
1659                         }
1660
1661                         memset(p_packet_data, 0, sizeof(struct _rtcp_conversation_info));
1662
1663                         /* Set as packet info */
1664                         p_add_proto_data(pinfo->fd, proto_rtcp, p_packet_data);
1665                 }
1666
1667                 /* Any previous report must match the lsr given here */
1668                 if (p_conv_data->last_received_ts == lsr)
1669                 {
1670                         /* Look at time of since original packet was sent */
1671                         gint seconds_between_packets =
1672                               pinfo->fd->abs_ts.secs - p_conv_data->last_received_timestamp.secs;
1673                         gint nseconds_between_packets =
1674                               pinfo->fd->abs_ts.nsecs - p_conv_data->last_received_timestamp.nsecs;
1675
1676
1677                         gint total_gap = ((seconds_between_packets*1000000) +
1678                                          nseconds_between_packets) / 1000000;
1679                         gint delay = total_gap - (int)(((double)dlsr/(double)65536) * 1000.0);
1680
1681                         /* No useful calculation can be done if dlsr not set... */
1682                         if (!dlsr)
1683                         {
1684                                 return;
1685                         }
1686
1687                         p_packet_data->calculated_delay_set = TRUE;
1688                         p_packet_data->calculated_delay = delay;
1689                         p_packet_data->calculated_delay_used_frame = p_conv_data->last_received_frame_number;
1690
1691                         /* Show info. */
1692                         add_roundtrip_delay_info(tvb, pinfo, tree, p_conv_data->last_received_frame_number, delay);
1693                 }
1694         }
1695 }
1696
1697 /* Show the calcaulted roundtrip delay info by adding protocol tree items
1698    and appending text to the info column */
1699 static void add_roundtrip_delay_info(tvbuff_t *tvb, packet_info *pinfo,
1700                                      proto_tree *tree, guint frame, guint delay)
1701 {
1702         proto_tree *rtcp_roundtrip_delay_tree;
1703         proto_item *ti;
1704
1705         /* Don't report on calculated delays below the threshold */
1706         if (delay < global_rtcp_show_roundtrip_calculation_minimum)
1707         {
1708                 return;
1709         }
1710
1711         /* Add labelled subtree for roundtrip delay info */
1712         ti =  proto_tree_add_string_format(tree, hf_rtcp_roundtrip_delay, tvb, 0, 0,
1713                                            "",
1714                                            "Calculated Roundtrip delay <-> %s = %ums, using frame %u",
1715                                            address_to_str(&pinfo->net_src), delay,
1716                                            frame);
1717
1718         PROTO_ITEM_SET_GENERATED(ti);
1719         rtcp_roundtrip_delay_tree = proto_item_add_subtree(ti, ett_rtcp_roundtrip_delay);
1720         if (rtcp_roundtrip_delay_tree)
1721         {
1722                 /* Add details into subtree */
1723                 proto_item* item = proto_tree_add_uint(rtcp_roundtrip_delay_tree,
1724                                                        hf_rtcp_roundtrip_delay_frame,
1725                                                        tvb, 0, 0, frame);
1726                 PROTO_ITEM_SET_GENERATED(item);
1727                 item = proto_tree_add_uint(rtcp_roundtrip_delay_tree, hf_rtcp_roundtrip_delay_delay,
1728                                            tvb, 0, 0, delay);
1729                 PROTO_ITEM_SET_GENERATED(item);
1730         }
1731
1732         /* Report delay in INFO column */
1733         if (check_col(pinfo->cinfo, COL_INFO))
1734         {
1735                 col_append_fstr(pinfo->cinfo, COL_INFO,
1736                                 " (roundtrip delay <-> %s = %ums, using frame %u)",
1737                                                 address_to_str(&pinfo->net_src), delay, frame);
1738         }
1739 }
1740
1741
1742
1743 static void
1744 dissect_rtcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
1745 {
1746         proto_item *ti           = NULL;
1747         proto_tree *rtcp_tree    = NULL;
1748         unsigned int temp_byte   = 0;
1749         unsigned int padding_set = 0;
1750         unsigned int elem_count  = 0;
1751         unsigned int packet_type = 0;
1752         unsigned int offset      = 0;
1753         guint16 packet_length    = 0;
1754         guint rtcp_subtype               = 0;
1755
1756         if ( check_col( pinfo->cinfo, COL_PROTOCOL ) )   {
1757                 col_set_str( pinfo->cinfo, COL_PROTOCOL, "RTCP" );
1758         }
1759
1760         if ( check_col( pinfo->cinfo, COL_INFO) ) {
1761                 /* The second octet contains the packet type */
1762                 /* switch ( pd[ offset + 1 ] ) { */
1763                 switch ( tvb_get_guint8( tvb, 1 ) ) {
1764                         case RTCP_SR:
1765                                 col_set_str( pinfo->cinfo, COL_INFO, "Sender Report");
1766                                 break;
1767                         case RTCP_RR:
1768                                 col_set_str( pinfo->cinfo, COL_INFO, "Receiver Report");
1769                                 break;
1770                         case RTCP_SDES:
1771                                 col_set_str( pinfo->cinfo, COL_INFO, "Source Description");
1772                                 break;
1773                         case RTCP_BYE:
1774                                 col_set_str( pinfo->cinfo, COL_INFO, "Goodbye");
1775                                 break;
1776                         case RTCP_APP:
1777                                 col_set_str( pinfo->cinfo, COL_INFO, "Application defined");
1778                                 break;
1779                         case RTCP_XR:
1780                                 col_set_str( pinfo->cinfo, COL_INFO, "Extended report");
1781                                 break;
1782                         case RTCP_FIR:
1783                                 col_set_str( pinfo->cinfo, COL_INFO, "Full Intra-frame Request (H.261)");
1784                                 break;
1785                         case RTCP_NACK:
1786                                 col_set_str( pinfo->cinfo, COL_INFO, "Negative Acknowledgement (H.261)");
1787                                 break;
1788                         default:
1789                                 col_set_str( pinfo->cinfo, COL_INFO, "Unknown packet type");
1790                                 break;
1791                 }
1792         }
1793
1794     /*
1795      * Check if there are at least 4 bytes left in the frame,
1796      * the last 16 bits of those is the length of the current
1797      * RTCP message. The last compound message contains padding,
1798      * that enables us to break from the while loop.
1799      */
1800     while ( tvb_bytes_exist( tvb, offset, 4) ) {
1801         /*
1802          * First retreive the packet_type
1803          */
1804         packet_type = tvb_get_guint8( tvb, offset + 1 );
1805
1806         /*
1807          * Check if it's a valid type
1808          */
1809         if ( ( packet_type < 192 ) || ( packet_type >  207 ) )
1810             break;
1811
1812         /*
1813          * get the packet-length for the complete RTCP packet
1814          */
1815         packet_length = ( tvb_get_ntohs( tvb, offset + 2 ) + 1 ) * 4;
1816
1817                 ti = proto_tree_add_item(tree, proto_rtcp, tvb, offset, packet_length, FALSE );
1818                 rtcp_tree = proto_item_add_subtree( ti, ett_rtcp );
1819
1820                 /* Conversation setup info */
1821                 if (global_rtcp_show_setup_info)
1822                 {
1823                         show_setup_info(tvb, pinfo, rtcp_tree);
1824                 }
1825
1826
1827         temp_byte = tvb_get_guint8( tvb, offset );
1828
1829                 proto_tree_add_uint( rtcp_tree, hf_rtcp_version, tvb,
1830                                                          offset, 1, temp_byte);
1831         padding_set = RTCP_PADDING( temp_byte );
1832
1833                 proto_tree_add_boolean( rtcp_tree, hf_rtcp_padding, tvb,
1834                                                                 offset, 1, temp_byte );
1835         elem_count = RTCP_COUNT( temp_byte );
1836
1837         switch ( packet_type ) {
1838             case RTCP_SR:
1839             case RTCP_RR:
1840                 /* Receiver report count, 5 bits */
1841                 proto_tree_add_uint( rtcp_tree, hf_rtcp_rc, tvb, offset, 1, temp_byte );
1842                 offset++;
1843                 /* Packet type, 8 bits */
1844                 proto_tree_add_item( rtcp_tree, hf_rtcp_pt, tvb, offset, 1, FALSE );
1845                 offset++;
1846                 /* Packet length in 32 bit words MINUS one, 16 bits */
1847                 proto_tree_add_uint( rtcp_tree, hf_rtcp_length, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
1848                 offset += 2;
1849                 /* Sender Synchronization source, 32 bits */
1850                 proto_tree_add_uint( rtcp_tree, hf_rtcp_ssrc_sender, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
1851                 offset += 4;
1852
1853                 if ( packet_type == RTCP_SR ) offset = dissect_rtcp_sr( pinfo, tvb, offset, rtcp_tree, elem_count );
1854                 else offset = dissect_rtcp_rr( pinfo, tvb, offset, rtcp_tree, elem_count );
1855                 break;
1856             case RTCP_SDES:
1857                 /* Source count, 5 bits */
1858                 proto_tree_add_uint( rtcp_tree, hf_rtcp_sc, tvb, offset, 1, temp_byte );
1859                 offset++;
1860                 /* Packet type, 8 bits */
1861                 proto_tree_add_item( rtcp_tree, hf_rtcp_pt, tvb, offset, 1, FALSE );
1862                 offset++;
1863                 /* Packet length in 32 bit words MINUS one, 16 bits */
1864                 proto_tree_add_uint( rtcp_tree, hf_rtcp_length, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
1865                 offset += 2;
1866                 dissect_rtcp_sdes( tvb, offset, rtcp_tree, elem_count );
1867                 offset += packet_length - 4;
1868                 break;
1869             case RTCP_BYE:
1870                 /* Source count, 5 bits */
1871                 proto_tree_add_uint( rtcp_tree, hf_rtcp_sc, tvb, offset, 1, temp_byte );
1872                 offset++;
1873                 /* Packet type, 8 bits */
1874                 proto_tree_add_item( rtcp_tree, hf_rtcp_pt, tvb, offset, 1, FALSE );
1875                 offset++;
1876                 /* Packet length in 32 bit words MINUS one, 16 bits */
1877                 proto_tree_add_uint( rtcp_tree, hf_rtcp_length, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
1878                 offset += 2;
1879                 offset = dissect_rtcp_bye( tvb, offset, rtcp_tree, elem_count );
1880                 break;
1881             case RTCP_APP:
1882                 /* Subtype, 5 bits */
1883                 rtcp_subtype = elem_count;
1884                 proto_tree_add_uint( rtcp_tree, hf_rtcp_subtype, tvb, offset, 1, elem_count );
1885                 offset++;
1886                 /* Packet type, 8 bits */
1887                 proto_tree_add_item( rtcp_tree, hf_rtcp_pt, tvb, offset, 1, FALSE );
1888                 offset++;
1889                 /* Packet length in 32 bit words MINUS one, 16 bits */
1890                 proto_tree_add_uint( rtcp_tree, hf_rtcp_length, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
1891                 offset += 2;
1892                 offset = dissect_rtcp_app( tvb, pinfo, offset,
1893                     rtcp_tree, padding_set,
1894                     packet_length - 4, rtcp_subtype );
1895                 break;
1896             case RTCP_XR:
1897                 /* Reserved, 5 bits, Ignore */
1898                 offset++;
1899                 /* Packet type, 8 bits */
1900                 proto_tree_add_item( rtcp_tree, hf_rtcp_pt, tvb, offset, 1, FALSE );
1901                 offset++;
1902                 /* Packet length in 32 bit words MINUS one, 16 bits */
1903                 proto_tree_add_uint( rtcp_tree, hf_rtcp_length, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
1904                 offset += 2;
1905                 offset = dissect_rtcp_xr( tvb, pinfo, offset, rtcp_tree, packet_length - 4 );
1906                 break;
1907             case RTCP_FIR:
1908                 offset = dissect_rtcp_fir( tvb, offset, rtcp_tree );
1909                 break;
1910             case RTCP_NACK:
1911                 offset = dissect_rtcp_nack( tvb, offset, rtcp_tree );
1912                 break;
1913             default:
1914                 /*
1915                  * To prevent endless loops in case of an unknown message type
1916                  * increase offset. Some time the while will end :-)
1917                  */
1918                 offset++;
1919                 break;
1920         }
1921     }
1922     /* If the padding bit is set, the last octet of the
1923      * packet contains the length of the padding
1924      * We only have to check for this at the end of the LAST RTCP message
1925      */
1926     if ( padding_set ) {
1927         /* If everything went according to plan offset should now point to the
1928          * first octet of the padding
1929          */
1930         proto_tree_add_item( rtcp_tree, hf_rtcp_padding_data, tvb, offset, tvb_length_remaining( tvb, offset) - 1, FALSE );
1931         offset += tvb_length_remaining( tvb, offset) - 1;
1932         proto_tree_add_item( rtcp_tree, hf_rtcp_padding_count, tvb, offset, 1, FALSE );
1933     }
1934 }
1935
1936 void
1937 proto_register_rtcp(void)
1938 {
1939         static hf_register_info hf[] =
1940         {
1941                 {
1942                         &hf_rtcp_version,
1943                         {
1944                                 "Version",
1945                                 "rtcp.version",
1946                                 FT_UINT8,
1947                                 BASE_DEC,
1948                                 VALS(rtcp_version_vals),
1949                                 0xC0,
1950                                 "", HFILL
1951                         }
1952                 },
1953                 {
1954                         &hf_rtcp_padding,
1955                         {
1956                                 "Padding",
1957                                 "rtcp.padding",
1958                                 FT_BOOLEAN,
1959                                 8,
1960                                 NULL,
1961                                 0x20,
1962                                 "", HFILL
1963                         }
1964                 },
1965                 {
1966                         &hf_rtcp_rc,
1967                         {
1968                                 "Reception report count",
1969                                 "rtcp.rc",
1970                                 FT_UINT8,
1971                                 BASE_DEC,
1972                                 NULL,
1973                                 0x1F,
1974                                 "", HFILL
1975                         }
1976                 },
1977                 {
1978                         &hf_rtcp_sc,
1979                         {
1980                                 "Source count",
1981                                 "rtcp.sc",
1982                                 FT_UINT8,
1983                                 BASE_DEC,
1984                                 NULL,
1985                                 0x1F,
1986                                 "", HFILL
1987                         }
1988                 },
1989                 {
1990                         &hf_rtcp_pt,
1991                         {
1992                                 "Packet type",
1993                                 "rtcp.pt",
1994                                 FT_UINT8,
1995                                 BASE_DEC,
1996                                 VALS( rtcp_packet_type_vals ),
1997                                 0x0,
1998                                 "", HFILL
1999                         }
2000                 },
2001                 {
2002                         &hf_rtcp_length,
2003                         {
2004                                 "Length",
2005                                 "rtcp.length",
2006                                 FT_UINT16,
2007                                 BASE_DEC,
2008                                 NULL,
2009                                 0x0,
2010                                 "", HFILL
2011                         }
2012                 },
2013                 {
2014                         &hf_rtcp_ssrc_sender,
2015                         {
2016                                 "Sender SSRC",
2017                                 "rtcp.senderssrc",
2018                                 FT_UINT32,
2019                                 BASE_DEC,
2020                                 NULL,
2021                                 0x0,
2022                                 "", HFILL
2023                         }
2024                 },
2025                 {
2026                         &hf_rtcp_ntp,
2027                         {
2028                                 "NTP timestamp",
2029                                 "rtcp.timestamp.ntp",
2030                                 FT_STRING,
2031                                 BASE_NONE,
2032                                 NULL,
2033                                 0x0,
2034                                 "", HFILL
2035                         }
2036                 },
2037                 {
2038                         &hf_rtcp_rtp_timestamp,
2039                         {
2040                                 "RTP timestamp",
2041                                 "rtcp.timestamp.rtp",
2042                                 FT_UINT32,
2043                                 BASE_DEC,
2044                                 NULL,
2045                                 0x0,
2046                                 "", HFILL
2047                         }
2048                 },
2049                 {
2050                         &hf_rtcp_sender_pkt_cnt,
2051                         {
2052                                 "Sender's packet count",
2053                                 "rtcp.sender.packetcount",
2054                                 FT_UINT32,
2055                                 BASE_DEC,
2056                                 NULL,
2057                                 0x0,
2058                                 "", HFILL
2059                         }
2060                 },
2061                 {
2062                         &hf_rtcp_sender_oct_cnt,
2063                         {
2064                                 "Sender's octet count",
2065                                 "rtcp.sender.octetcount",
2066                                 FT_UINT32,
2067                                 BASE_DEC,
2068                                 NULL,
2069                                 0x0,
2070                                 "", HFILL
2071                         }
2072                 },
2073                 {
2074                         &hf_rtcp_ssrc_source,
2075                         {
2076                                 "Identifier",
2077                                 "rtcp.ssrc.identifier",
2078                                 FT_UINT32,
2079                                 BASE_DEC,
2080                                 NULL,
2081                                 0x0,
2082                                 "", HFILL
2083                         }
2084                 },
2085                 {
2086                         &hf_rtcp_ssrc_fraction,
2087                         {
2088                                 "Fraction lost",
2089                                 "rtcp.ssrc.fraction",
2090                                 FT_UINT8,
2091                                 BASE_DEC,
2092                                 NULL,
2093                                 0x0,
2094                                 "", HFILL
2095                         }
2096                 },
2097                 {
2098                         &hf_rtcp_ssrc_cum_nr,
2099                         {
2100                                 "Cumulative number of packets lost",
2101                                 "rtcp.ssrc.cum_nr",
2102                                 FT_UINT32,
2103                                 BASE_DEC,
2104                                 NULL,
2105                                 0x0,
2106                                 "", HFILL
2107                         }
2108                 },
2109                 {
2110                         &hf_rtcp_ssrc_ext_high_seq,
2111                         {
2112                                 "Extended highest sequence number received",
2113                                 "rtcp.ssrc.ext_high",
2114                                 FT_UINT32,
2115                                 BASE_DEC,
2116                                 NULL,
2117                                 0x0,
2118                                 "", HFILL
2119                         }
2120                 },
2121                 {
2122                         &hf_rtcp_ssrc_high_seq,
2123                         {
2124                                 "Highest sequence number received",
2125                                 "rtcp.ssrc.high_seq",
2126                                 FT_UINT16,
2127                                 BASE_DEC,
2128                                 NULL,
2129                                 0x0,
2130                                 "", HFILL
2131                         }
2132                 },
2133                 {
2134                         &hf_rtcp_ssrc_high_cycles,
2135                         {
2136                                 "Sequence number cycles count",
2137                                 "rtcp.ssrc.high_cycles",
2138                                 FT_UINT16,
2139                                 BASE_DEC,
2140                                 NULL,
2141                                 0x0,
2142                                 "", HFILL
2143                         }
2144                 },
2145                 {
2146                         &hf_rtcp_ssrc_jitter,
2147                         {
2148                                 "Interarrival jitter",
2149                                 "rtcp.ssrc.jitter",
2150                                 FT_UINT32,
2151                                 BASE_DEC,
2152                                 NULL,
2153                                 0x0,
2154                                 "", HFILL
2155                         }
2156                 },
2157                 {
2158                         &hf_rtcp_ssrc_lsr,
2159                         {
2160                                 "Last SR timestamp",
2161                                 "rtcp.ssrc.lsr",
2162                                 FT_UINT32,
2163                                 BASE_DEC,
2164                                 NULL,
2165                                 0x0,
2166                                 "", HFILL
2167                         }
2168                 },
2169                 {
2170                         &hf_rtcp_ssrc_dlsr,
2171                         {
2172                                 "Delay since last SR timestamp",
2173                                 "rtcp.ssrc.dlsr",
2174                                 FT_UINT32,
2175                                 BASE_DEC,
2176                                 NULL,
2177                                 0x0,
2178                                 "", HFILL
2179                         }
2180                 },
2181                 {
2182                         &hf_rtcp_ssrc_csrc,
2183                         {
2184                                 "SSRC / CSRC identifier",
2185                                 "rtcp.sdes.ssrc_csrc",
2186                                 FT_UINT32,
2187                                 BASE_DEC,
2188                                 NULL,
2189                                 0x0,
2190                                 "", HFILL
2191                         }
2192                 },
2193                 {
2194                         &hf_rtcp_ssrc_type,
2195                         {
2196                                 "Type",
2197                                 "rtcp.sdes.type",
2198                                 FT_UINT8,
2199                                 BASE_DEC,
2200                                 VALS( rtcp_sdes_type_vals ),
2201                                 0x0,
2202                                 "", HFILL
2203                         }
2204                 },
2205                 {
2206                         &hf_rtcp_ssrc_length,
2207                         {
2208                                 "Length",
2209                                 "rtcp.sdes.length",
2210                                 FT_UINT32,
2211                                 BASE_DEC,
2212                                 NULL,
2213                                 0x0,
2214                                 "", HFILL
2215                         }
2216                 },
2217                 {
2218                         &hf_rtcp_ssrc_text,
2219                         {
2220                                 "Text",
2221                                 "rtcp.sdes.text",
2222                                 FT_STRING,
2223                                 BASE_NONE,
2224                                 NULL,
2225                                 0x0,
2226                                 "", HFILL
2227                         }
2228                 },
2229                 {
2230                         &hf_rtcp_ssrc_prefix_len,
2231                         {
2232                                 "Prefix length",
2233                                 "rtcp.sdes.prefix.length",
2234                                 FT_UINT8,
2235                                 BASE_DEC,
2236                                 NULL,
2237                                 0x0,
2238                                 "", HFILL
2239                         }
2240                 },
2241                 {
2242                         &hf_rtcp_ssrc_prefix_string,
2243                         {
2244                                 "Prefix string",
2245                                 "rtcp.sdes.prefix.string",
2246                                 FT_STRING,
2247                                 BASE_NONE,
2248                                 NULL,
2249                                 0x0,
2250                                 "", HFILL
2251                         }
2252                 },
2253                 {
2254                         &hf_rtcp_subtype,
2255                         {
2256                                 "Subtype",
2257                                 "rtcp.app.subtype",
2258                                 FT_UINT8,
2259                                 BASE_DEC,
2260                                 NULL,
2261                                 0x0,
2262                                 "", HFILL
2263                         }
2264                 },
2265                 {
2266                         &hf_rtcp_name_ascii,
2267                         {
2268                                 "Name (ASCII)",
2269                                 "rtcp.app.name",
2270                                 FT_STRING,
2271                                 BASE_NONE,
2272                                 NULL,
2273                                 0x0,
2274                                 "", HFILL
2275                         }
2276                 },
2277                 {
2278                         &hf_rtcp_app_data,
2279                         {
2280                                 "Application specific data",
2281                                 "rtcp.app.data",
2282                                 FT_BYTES,
2283                                 BASE_NONE,
2284                                 NULL,
2285                                 0x0,
2286                                 "", HFILL
2287                         }
2288                 },
2289                 {
2290                         &hf_rtcp_app_poc1_subtype,
2291                         {
2292                                 "Subtype",
2293                                 "rtcp.app.PoC1.subtype",
2294                                 FT_UINT8,
2295                                 BASE_DEC,
2296                                 VALS(rtcp_app_poc1_floor_cnt_type_vals),
2297                                 0x0,
2298                                 "", HFILL
2299                         }
2300                 },
2301                 {
2302                         &hf_rtcp_app_poc1_sip_uri,
2303                         {
2304                                 "SIP URI",
2305                                 "rtcp.app.poc1.sip.uri",
2306                                 FT_STRING,
2307                                 BASE_NONE,
2308                                 NULL,
2309                                 0x0,
2310                                 "", HFILL
2311                         }
2312                 },
2313                 {
2314                         &hf_rtcp_app_poc1_disp_name,
2315                         {
2316                                 "Display Name",
2317                                 "rtcp.app.poc1.disp.name",
2318                                 FT_STRING,
2319                                 BASE_NONE,
2320                                 NULL,
2321                                 0x0,
2322                                 "", HFILL
2323                         }
2324                 },
2325                 {
2326                         &hf_rtcp_app_poc1_last_pkt_seq_no,
2327                         {
2328                                 "Seq. no of last RTP packet",
2329                                 "rtcp.app.poc1.last.pkt.seq.no",
2330                                 FT_UINT16,
2331                                 BASE_DEC,
2332                                 NULL,
2333                                 0x0,
2334                                 "", HFILL
2335                         }
2336                 },
2337                 {
2338                         &hf_rtcp_app_poc1_reason_code1,
2339                         {
2340                                 "Reason code",
2341                                 "rtcp.app.poc1.reason.code",
2342                                 FT_UINT8,
2343                                 BASE_DEC,
2344                                 VALS(rtcp_app_poc1_reason_code1_vals),
2345                                 0x0,
2346                                 "", HFILL
2347                         }
2348                 },
2349                 {
2350                         &hf_rtcp_app_poc1_item_len,
2351                         {
2352                                 "Item length",
2353                                 "rtcp.app.poc1.item.len",
2354                                 FT_UINT8,
2355                                 BASE_DEC,
2356                                 NULL,
2357                                 0x0,
2358                                 "", HFILL
2359                         }
2360                 },
2361                 {
2362                         &hf_rtcp_app_poc1_reason1_phrase,
2363                         {
2364                                 "Reason Phrase",
2365                                 "rtcp.app.poc1.reason.phrase",
2366                                 FT_STRING,
2367                                 BASE_NONE,
2368                                 NULL,
2369                                 0x0,
2370                                 "", HFILL
2371                         }
2372                 },
2373                 {
2374                         &hf_rtcp_app_poc1_reason_code2,
2375                         {
2376                                 "Reason code",
2377                                 "rtcp.app.poc1.reason.code",
2378                                 FT_UINT16,
2379                                 BASE_DEC,
2380                                 VALS(rtcp_app_poc1_reason_code2_vals),
2381                                 0x0,
2382                                 "", HFILL
2383                         }
2384                 },
2385                 {
2386                         &hf_rtcp_app_poc1_additionalinfo,
2387                         {
2388                                 "additional information",
2389                                 "rtcp.app.poc1.add.info",
2390                                 FT_UINT16,
2391                                 BASE_DEC,
2392                                 NULL,
2393                                 0x0,
2394                                 "", HFILL
2395                         }
2396                 },
2397                 {
2398                         &hf_rtcp_app_poc1_ack_subtype,
2399                         {
2400                                 "Subtype",
2401                                 "rtcp.app.poc1.ack.subtype",
2402                                 FT_UINT8,
2403                                 BASE_DEC,
2404                                 VALS(rtcp_app_poc1_floor_cnt_type_vals),
2405                                 0xf8,
2406                                 "", HFILL
2407                         }
2408                 },
2409                 {
2410                         &hf_rtcp_app_poc1_ack_reason_code,
2411                         {
2412                                 "Reason code",
2413                                 "rtcp.app.poc1.ack.reason.code",
2414                                 FT_UINT16,
2415                                 BASE_DEC,
2416                                 NULL,
2417                                 0x07ff,
2418                                 "", HFILL
2419                         }
2420                 },
2421                 {
2422                         &hf_rtcp_app_poc1_qsresp_priority,
2423                         {
2424                                 "Priority",
2425                                 "rtcp.app.poc1.qsresp.priority",
2426                                 FT_UINT8,
2427                                 BASE_DEC,
2428                                 VALS(rtcp_app_poc1_qsresp_priority_vals),
2429                                 0x0,
2430                                 "", HFILL
2431                         }
2432                 },
2433                 {
2434                         &hf_rtcp_app_poc1_qsresp_position,
2435                         {
2436                                 "Position",
2437                                 "rtcp.app.poc1.qsresp.position",
2438                                 FT_UINT16,
2439                                 BASE_DEC,
2440                                 NULL,
2441                                 0x0,
2442                                 "", HFILL
2443                         }
2444                 },
2445                 {
2446                         &hf_rtcp_app_poc1_conn_content_1st_byte[0],
2447                         {
2448                                 "Identity of inviting client",
2449                                 "rtcp.app.poc1.conn.content.a.id",
2450                                 FT_BOOLEAN,
2451                                 8,
2452                                 NULL,
2453                                 0x80,
2454                                 "", HFILL
2455                         }
2456                 },
2457                 {
2458                         &hf_rtcp_app_poc1_conn_content_1st_byte[1],
2459                         {
2460                                 "Nick name of inviting client",
2461                                 "rtcp.app.poc1.conn.content.a.dn",
2462                                 FT_BOOLEAN,
2463                                 8,
2464                                 NULL,
2465                                 0x40,
2466                                 "", HFILL
2467                         }
2468                 },
2469                 {
2470                         &hf_rtcp_app_poc1_conn_content_1st_byte[2],
2471                         {
2472                                 "Session identity",
2473                                 "rtcp.app.poc1.conn.content.sess.id",
2474                                 FT_BOOLEAN,
2475                                 8,
2476                                 NULL,
2477                                 0x20,
2478                                 "", HFILL
2479                         }
2480                 },
2481                 {
2482                         &hf_rtcp_app_poc1_conn_content_1st_byte[3],
2483                         {
2484                                 "Group name",
2485                                 "rtcp.app.poc1.conn.content.grp.dn",
2486                                 FT_BOOLEAN,
2487                                 8,
2488                                 NULL,
2489                                 0x10,
2490                                 "", HFILL
2491                         }
2492                 },
2493                 {
2494                         &hf_rtcp_app_poc1_conn_content_1st_byte[4],
2495                         {
2496                                 "Group identity",
2497                                 "rtcp.app.poc1.conn.content.grp.id",
2498                                 FT_BOOLEAN,
2499                                 8,
2500                                 NULL,
2501                                 0x08,
2502                                 "", HFILL
2503                         }
2504                 },
2505                 {
2506                         &hf_rtcp_app_poc1_conn_session_type,
2507                         {
2508                                 "Session type",
2509                                 "rtcp.app.poc1.conn.session.type",
2510                                 FT_UINT8,
2511                                 BASE_DEC,
2512                                 VALS(rtcp_app_poc1_conn_sess_type_vals),
2513                                 0x0,
2514                                 "", HFILL
2515                         }
2516                 },
2517                 {
2518                         &hf_rtcp_app_poc1_conn_add_ind_mao,
2519                         {
2520                                 "Manual answer override",
2521                                 "rtcp.app.poc1.conn.add.ind.mao",
2522                                 FT_BOOLEAN,
2523                                 8,
2524                                 NULL,
2525                                 0x80,
2526                                 "", HFILL
2527                         }
2528                 },
2529                 {
2530                         &hf_rtcp_app_poc1_conn_sdes_items[0],
2531                         {
2532                                 "Identity of inviting client",
2533                                 "rtcp.app.poc1.conn.sdes.a.id",
2534                                 FT_UINT_STRING,
2535                                 BASE_NONE,
2536                                 NULL,
2537                                 0x0,
2538                                 "", HFILL
2539                         }
2540                 },
2541                 {
2542                         &hf_rtcp_app_poc1_conn_sdes_items[1],
2543                         {
2544                                 "Nick name of inviting client",
2545                                 "rtcp.app.poc1.conn.sdes.a.dn",
2546                                 FT_UINT_STRING,
2547                                 BASE_NONE,
2548                                 NULL,
2549                                 0x0,
2550                                 "", HFILL
2551                         }
2552                 },
2553                 {
2554                         &hf_rtcp_app_poc1_conn_sdes_items[2],
2555                         {
2556                                 "Session identity",
2557                                 "rtcp.app.poc1.conn.sdes.sess.id",
2558                                 FT_UINT_STRING,
2559                                 BASE_NONE,
2560                                 NULL,
2561                                 0x0,
2562                                 "", HFILL
2563                         }
2564                 },
2565                 {
2566                         &hf_rtcp_app_poc1_conn_sdes_items[3],
2567                         {
2568                                 "Group Name",
2569                                 "rtcp.app.poc1.conn.sdes.grp.dn",
2570                                 FT_UINT_STRING,
2571                                 BASE_NONE,
2572                                 NULL,
2573                                 0x0,
2574                                 "", HFILL
2575                         }
2576                 },
2577                 {
2578                         &hf_rtcp_app_poc1_conn_sdes_items[4],
2579                         {
2580                                 "Group identity",
2581                                 "rtcp.app.poc1.conn.sdes.grp.id",
2582                                 FT_UINT_STRING,
2583                                 BASE_NONE,
2584                                 NULL,
2585                                 0x0,
2586                                 "", HFILL
2587                         }
2588                 },
2589                 {
2590                         &hf_rtcp_fsn,
2591                         {
2592                                 "First sequence number",
2593                                 "rtcp.nack.fsn",
2594                                 FT_UINT16,
2595                                 BASE_DEC,
2596                                 NULL,
2597                                 0x0,
2598                                 "", HFILL
2599                         }
2600                 },
2601                 {
2602                         &hf_rtcp_blp,
2603                         {
2604                                 "Bitmask of following lost packets",
2605                                 "rtcp.nack.blp",
2606                                 FT_UINT16,
2607                                 BASE_DEC,
2608                                 NULL,
2609                                 0x0,
2610                                 "", HFILL
2611                         }
2612                 },
2613                 {
2614                         &hf_rtcp_padding_count,
2615                         {
2616                                 "Padding count",
2617                                 "rtcp.padding.count",
2618                                 FT_UINT8,
2619                                 BASE_DEC,
2620                                 NULL,
2621                                 0x0,
2622                                 "", HFILL
2623                         }
2624                 },
2625                 {
2626                         &hf_rtcp_padding_data,
2627                         {
2628                                 "Padding data",
2629                                 "rtcp.padding.data",
2630                                 FT_BYTES,
2631                                 BASE_NONE,
2632                                 NULL,
2633                                 0x0,
2634                                 "", HFILL
2635                         }
2636                 },
2637                 {
2638                         &hf_rtcp_setup,
2639                         {
2640                                 "Stream setup",
2641                                 "rtcp.setup",
2642                                 FT_STRING,
2643                                 BASE_NONE,
2644                                 NULL,
2645                                 0x0,
2646                                 "Stream setup, method and frame number", HFILL
2647                         }
2648                 },
2649                 {
2650                         &hf_rtcp_setup_frame,
2651                         {
2652                                 "Setup frame",
2653                                 "rtcp.setup-frame",
2654                                 FT_FRAMENUM,
2655                                 BASE_NONE,
2656                                 NULL,
2657                                 0x0,
2658                                 "Frame that set up this stream", HFILL
2659                         }
2660                 },
2661                 {
2662                         &hf_rtcp_setup_method,
2663                         {
2664                                 "Setup Method",
2665                                 "rtcp.setup-method",
2666                                 FT_STRING,
2667                                 BASE_NONE,
2668                                 NULL,
2669                                 0x0,
2670                                 "Method used to set up this stream", HFILL
2671                         }
2672                 },
2673                 {
2674                         &hf_rtcp_roundtrip_delay,
2675                         {
2676                                 "Roundtrip Delay",
2677                                 "rtcp.roundtrip-delay",
2678                                 FT_STRING,
2679                                 BASE_NONE,
2680                                 NULL,
2681                                 0x0,
2682                                 "Calculated roundtrip delay, frame and ms value", HFILL
2683                         }
2684                 },
2685                 {
2686                         &hf_rtcp_roundtrip_delay_frame,
2687                         {
2688                                 "Previous SR frame used in calculation",
2689                                 "rtcp.roundtrip-previous-sr-frame",
2690                                 FT_FRAMENUM,
2691                                 BASE_NONE,
2692                                 NULL,
2693                                 0x0,
2694                                 "Frame used to calculate roundtrip delay", HFILL
2695                         }
2696                 },
2697                 {
2698                         &hf_rtcp_roundtrip_delay_delay,
2699                         {
2700                                 "Roundtrip Delay(ms)",
2701                                 "rtcp.roundtrip-delay-delay",
2702                                 FT_UINT32,
2703                                 BASE_DEC,
2704                                 NULL,
2705                                 0x0,
2706                                 "Calculated roundtrip delay in ms", HFILL
2707                         }
2708                 },
2709                 {
2710                         &hf_rtcp_xr_block_type,
2711                         {
2712                                 "Type",
2713                                 "rtcp.xr.bt",
2714                                 FT_UINT8,
2715                                 BASE_DEC,
2716                                 VALS(rtcp_xr_type_vals),
2717                                 0x0,
2718                                 "Block Type", HFILL
2719                         }
2720                 },
2721                 {
2722                         &hf_rtcp_xr_block_specific,
2723                         {
2724                                 "Type Specific",
2725                                 "rtcp.xr.bs",
2726                                 FT_UINT8,
2727                                 BASE_DEC,
2728                                 NULL,
2729                                 0x0,
2730                                 "Reserved", HFILL
2731                         }
2732                 },
2733                 {
2734                         &hf_rtcp_xr_block_length,
2735                         {
2736                                 "Length",
2737                                 "rtcp.xr.bl",
2738                                 FT_UINT16,
2739                                 BASE_DEC,
2740                                 NULL,
2741                                 0x0,
2742                                 "Block Length", HFILL
2743                         }
2744                 },
2745                 {
2746                         &hf_rtcp_ssrc_discarded,
2747                         {
2748                                 "Fraction discarded",
2749                                 "rtcp.ssrc.discarded",
2750                                 FT_UINT8,
2751                                 BASE_DEC,
2752                                 NULL,
2753                                 0x0,
2754                                 "Discard Rate", HFILL
2755                         }
2756                 },
2757                 {
2758                         &hf_rtcp_xr_voip_metrics_burst_density,
2759                         {
2760                                 "Burst Density",
2761                                 "rtcp.xr.voipmetrics.burstdensity",
2762                                 FT_UINT8,
2763                                 BASE_DEC,
2764                                 NULL,
2765                                 0x0,
2766                                 "", HFILL
2767                         }
2768                 },
2769                 {
2770                         &hf_rtcp_xr_voip_metrics_gap_density,
2771                         {
2772                                 "Gap Density",
2773                                 "rtcp.xr.voipmetrics.gapdensity",
2774                                 FT_UINT8,
2775                                 BASE_DEC,
2776                                 NULL,
2777                                 0x0,
2778                                 "", HFILL
2779                         }
2780                 },
2781                 {
2782                         &hf_rtcp_xr_voip_metrics_burst_duration,
2783                         {
2784                                 "Burst Duration(ms)",
2785                                 "rtcp.xr.voipmetrics.burstduration",
2786                                 FT_UINT16,
2787                                 BASE_DEC,
2788                                 NULL,
2789                                 0x0,
2790                                 "", HFILL
2791                         }
2792                 },
2793                 {
2794                         &hf_rtcp_xr_voip_metrics_gap_duration,
2795                         {
2796                                 "Gap Duration(ms)",
2797                                 "rtcp.xr.voipmetrics.gapduration",
2798                                 FT_UINT16,
2799                                 BASE_DEC,
2800                                 NULL,
2801                                 0x0,
2802                                 "", HFILL
2803                         }
2804                 },
2805                 {
2806                         &hf_rtcp_xr_voip_metrics_rtdelay,
2807                         {
2808                                 "Round Trip Delay(ms)",
2809                                 "rtcp.xr.voipmetrics.rtdelay",
2810                                 FT_UINT16,
2811                                 BASE_DEC,
2812                                 NULL,
2813                                 0x0,
2814                                 "", HFILL
2815                         }
2816                 },
2817                 {
2818                         &hf_rtcp_xr_voip_metrics_esdelay,
2819                         {
2820                                 "End System Delay(ms)",
2821                                 "rtcp.xr.voipmetrics.esdelay",
2822                                 FT_UINT16,
2823                                 BASE_DEC,
2824                                 NULL,
2825                                 0x0,
2826                                 "", HFILL
2827                         }
2828                 },
2829                 {
2830                         &hf_rtcp_xr_voip_metrics_siglevel,
2831                         {
2832                                 "Signal Level",
2833                                 "rtcp.xr.voipmetrics.signallevel",
2834                                 FT_INT8,
2835                                 BASE_DEC,
2836                                 NULL,
2837                                 0x0,
2838                                 "Signal level of 127 indicates this parameter is unavailable", HFILL
2839                         }
2840                 },
2841                 {
2842                         &hf_rtcp_xr_voip_metrics_noiselevel,
2843                         {
2844                                 "Noise Level",
2845                                 "rtcp.xr.voipmetrics.noiselevel",
2846                                 FT_INT8,
2847                                 BASE_DEC,
2848                                 NULL,
2849                                 0x0,
2850                                 "Noise level of 127 indicates this parameter is unavailable", HFILL
2851                         }
2852                 },
2853                 {
2854                         &hf_rtcp_xr_voip_metrics_rerl,
2855                         {
2856                                 "Residual Echo Return Loss",
2857                                 "rtcp.xr.voipmetrics.rerl",
2858                                 FT_UINT8,
2859                                 BASE_DEC,
2860                                 NULL,
2861                                 0x0,
2862                                 "", HFILL
2863                         }
2864                 },
2865                 {
2866                         &hf_rtcp_xr_voip_metrics_gmin,
2867                         {
2868                                 "Gmin",
2869                                 "rtcp.xr.voipmetrics.gmin",
2870                                 FT_UINT8,
2871                                 BASE_DEC,
2872                                 NULL,
2873                                 0x0,
2874                                 "", HFILL
2875                         }
2876                 },
2877                 {
2878                         &hf_rtcp_xr_voip_metrics_rfactor,
2879                         {
2880                                 "R Factor",
2881                                 "rtcp.xr.voipmetrics.rfactor",
2882                                 FT_UINT8,
2883                                 BASE_DEC,
2884                                 NULL,
2885                                 0x0,
2886                                 "R Factor is in the range of 0 to 100; 127 indicates this parameter is unavailable", HFILL
2887                         }
2888                 },
2889                 {
2890                         &hf_rtcp_xr_voip_metrics_extrfactor,
2891                         {
2892                                 "External R Factor",
2893                                 "rtcp.xr.voipmetrics.extrfactor",
2894                                 FT_UINT8,
2895                                 BASE_DEC,
2896                                 NULL,
2897                                 0x0,
2898                                 "R Factor is in the range of 0 to 100; 127 indicates this parameter is unavailable", HFILL
2899                         }
2900                 },
2901                 {
2902                         &hf_rtcp_xr_voip_metrics_moslq,
2903                         {
2904                                 "MOS - Listening Quality",
2905                                 "rtcp.xr.voipmetrics.moslq",
2906                                 FT_FLOAT,
2907                                 BASE_DEC,
2908                                 NULL,
2909                                 0x0,
2910                                 "MOS is in the range of 1 to 5; 127 indicates this parameter is unavailable", HFILL
2911                         }
2912                 },
2913                 {
2914                         &hf_rtcp_xr_voip_metrics_moscq,
2915                         {
2916                                 "MOS - Conversational Quality",
2917                                 "rtcp.xr.voipmetrics.moscq",
2918                                 FT_FLOAT,
2919                                 BASE_DEC,
2920                                 NULL,
2921                                 0x0,
2922                                 "MOS is in the range of 1 to 5; 127 indicates this parameter is unavailable", HFILL
2923                         }
2924                 },
2925                 {
2926                         &hf_rtcp_xr_voip_metrics_plc,
2927                         {
2928                                 "Packet Loss Conealment Algorithm",
2929                                 "rtcp.xr.voipmetrics.plc",
2930                                 FT_UINT8,
2931                                 BASE_DEC,
2932                                 VALS(rtcp_xr_plc_algo_vals),
2933                                 0xC0,
2934                                 "", HFILL
2935                         }
2936                 },
2937                 {
2938                         &hf_rtcp_xr_voip_metrics_jbadaptive,
2939                         {
2940                                 "Adaptive Jitter Buffer Algorithm",
2941                                 "rtcp.xr.voipmetrics.jba",
2942                                 FT_UINT8,
2943                                 BASE_DEC,
2944                                 VALS(rtcp_xr_jb_adaptive_vals),
2945                                 0x30,
2946                                 "", HFILL
2947                         }
2948                 },
2949                 {
2950                         &hf_rtcp_xr_voip_metrics_jbrate,
2951                         {
2952                                 "Jitter Buffer Rate",
2953                                 "rtcp.xr.voipmetrics.jbrate",
2954                                 FT_UINT8,
2955                                 BASE_DEC,
2956                                 NULL,
2957                                 0x0F,
2958                                 "", HFILL
2959                         }
2960                 },
2961                 {
2962                         &hf_rtcp_xr_voip_metrics_jbnominal,
2963                         {
2964                                 "Nominal Jitter Buffer Size",
2965                                 "rtcp.xr.voipmetrics.jbnominal",
2966                                 FT_UINT16,
2967                                 BASE_DEC,
2968                                 NULL,
2969                                 0x0,
2970                                 "", HFILL
2971                         }
2972                 },
2973                 {
2974                         &hf_rtcp_xr_voip_metrics_jbmax,
2975                         {
2976                                 "Maximum Jitter Buffer Size",
2977                                 "rtcp.xr.voipmetrics.jbmax",
2978                                 FT_UINT16,
2979                                 BASE_DEC,
2980                                 NULL,
2981                                 0x0,
2982                                 "", HFILL
2983                         }
2984                 },
2985                 {
2986                         &hf_rtcp_xr_voip_metrics_jbabsmax,
2987                         {
2988                                 "Absolute Maximum Jitter Buffer Size",
2989                                 "rtcp.xr.voipmetrics.jbabsmax",
2990                                 FT_UINT16,
2991                                 BASE_DEC,
2992                                 NULL,
2993                                 0x0,
2994                                 "", HFILL
2995                         }
2996                 },
2997                 {
2998                         &hf_rtcp_xr_thinning,
2999                         {
3000                                 "Thinning factor",
3001                                 "rtcp.xr.tf",
3002                                 FT_UINT8,
3003                                 BASE_DEC,
3004                                 NULL,
3005                                 0x0F,
3006                                 "", HFILL
3007                         }
3008                 },
3009                 {
3010                         &hf_rtcp_xr_stats_loss_flag,
3011                         {
3012                                 "Loss Report Flag",
3013                                 "rtcp.xr.stats.lrflag",
3014                                 FT_BOOLEAN,
3015                                 8,
3016                                 NULL,
3017                                 0x80,
3018                                 "", HFILL
3019                         }
3020                 },
3021                 {
3022                         &hf_rtcp_xr_stats_dup_flag,
3023                         {
3024                                 "Duplicates Report Flag",
3025                                 "rtcp.xr.stats.dupflag",
3026                                 FT_BOOLEAN,
3027                                 8,
3028                                 NULL,
3029                                 0x40,
3030                                 "", HFILL
3031                         }
3032                 },
3033                 {
3034                         &hf_rtcp_xr_stats_jitter_flag,
3035                         {
3036                                 "Jitter Report Flag",
3037                                 "rtcp.xr.stats.jitterflag",
3038                                 FT_BOOLEAN,
3039                                 8,
3040                                 NULL,
3041                                 0x20,
3042                                 "", HFILL
3043                         }
3044                 },
3045                 {
3046                         &hf_rtcp_xr_stats_ttl,
3047                         {
3048                                 "TTL or Hop Limit Flag",
3049                                 "rtcp.xr.stats.ttl",
3050                                 FT_UINT8,
3051                                 BASE_DEC,
3052                                 VALS(rtcp_xr_ip_ttl_vals),
3053                                 0x18,
3054                                 "", HFILL
3055                         }
3056                 },
3057                 {
3058                         &hf_rtcp_xr_endseq,
3059                         {
3060                                 "End Sequence Number",
3061                                 "rtcp.xr.endseq",
3062                                 FT_UINT16,
3063                                 BASE_DEC,
3064                                 NULL,
3065                                 0x0,
3066                                 "", HFILL
3067                         }
3068                 },
3069                 {
3070                         &hf_rtcp_xr_beginseq,
3071                         {
3072                                 "Begin Sequence Number",
3073                                 "rtcp.xr.beginseq",
3074                                 FT_UINT16,
3075                                 BASE_DEC,
3076                                 NULL,
3077                                 0x0,
3078                                 "", HFILL
3079                         }
3080                 },
3081                 {
3082                         &hf_rtcp_xr_stats_lost,
3083                         {
3084                                 "Lost Packets",
3085                                 "rtcp.xr.stats.lost",
3086                                 FT_UINT32,
3087                                 BASE_DEC,
3088                                 NULL,
3089                                 0x0,
3090                                 "", HFILL
3091                         }
3092                 },
3093                 {
3094                         &hf_rtcp_xr_stats_dups,
3095                         {
3096                                 "Duplicate Packets",
3097                                 "rtcp.xr.stats.dups",
3098                                 FT_UINT32,
3099                                 BASE_DEC,
3100                                 NULL,
3101                                 0x0,
3102                                 "", HFILL
3103                         }
3104                 },
3105                 {
3106                         &hf_rtcp_xr_stats_minjitter,
3107                         {
3108                                 "Minimum Jitter",
3109                                 "rtcp.xr.stats.minjitter",
3110                                 FT_UINT32,
3111                                 BASE_DEC,
3112                                 NULL,
3113                                 0x0,
3114                                 "", HFILL
3115                         }
3116                 },
3117                 {
3118                         &hf_rtcp_xr_stats_maxjitter,
3119                         {
3120                                 "Maximum Jitter",
3121                                 "rtcp.xr.stats.maxjitter",
3122                                 FT_UINT32,
3123                                 BASE_DEC,
3124                                 NULL,
3125                                 0x0,
3126                                 "", HFILL
3127                         }
3128                 },
3129                 {
3130                         &hf_rtcp_xr_stats_meanjitter,
3131                         {
3132                                 "Mean Jitter",
3133                                 "rtcp.xr.stats.meanjitter",
3134                                 FT_UINT32,
3135                                 BASE_DEC,
3136                                 NULL,
3137                                 0x0,
3138                                 "", HFILL
3139                         }
3140                 },
3141                 {
3142                         &hf_rtcp_xr_stats_devjitter,
3143                         {
3144                                 "Standard Deviation of Jitter",
3145                                 "rtcp.xr.stats.devjitter",
3146                                 FT_UINT32,
3147                                 BASE_DEC,
3148                                 NULL,
3149                                 0x0,
3150                                 "", HFILL
3151                         }
3152                 },
3153                 {
3154                         &hf_rtcp_xr_stats_minttl,
3155                         {
3156                                 "Minimum TTL or Hop Limit",
3157                                 "rtcp.xr.stats.minttl",
3158                                 FT_UINT8,
3159                                 BASE_DEC,
3160                                 NULL,
3161                                 0x0,
3162                                 "", HFILL
3163                         }
3164                 },
3165                 {
3166                         &hf_rtcp_xr_stats_maxttl,
3167                         {
3168                                 "Maximum TTL or Hop Limit",
3169                                 "rtcp.xr.stats.maxttl",
3170                                 FT_UINT8,
3171                                 BASE_DEC,
3172                                 NULL,
3173                                 0x0,
3174                                 "", HFILL
3175                         }
3176                 },
3177                 {
3178                         &hf_rtcp_xr_stats_meanttl,
3179                         {
3180                                 "Mean TTL or Hop Limit",
3181                                 "rtcp.xr.stats.meanttl",
3182                                 FT_UINT8,
3183                                 BASE_DEC,
3184                                 NULL,
3185                                 0x0,
3186                                 "", HFILL
3187                         }
3188                 },
3189                 {
3190                         &hf_rtcp_xr_stats_devttl,
3191                         {
3192                                 "Standard Deviation of TTL",
3193                                 "rtcp.xr.stats.devttl",
3194                                 FT_UINT8,
3195                                 BASE_DEC,
3196                                 NULL,
3197                                 0x0,
3198                                 "", HFILL
3199                         }
3200                 },
3201                 {
3202                         &hf_rtcp_xr_lrr,
3203                         {
3204                                 "Last RR timestamp",
3205                                 "rtcp.xr.lrr",
3206                                 FT_UINT32,
3207                                 BASE_DEC,
3208                                 NULL,
3209                                 0x0,
3210                                 "", HFILL
3211                         }
3212                 },
3213                 {
3214                         &hf_rtcp_xr_dlrr,
3215                         {
3216                                 "Delay since last RR timestamp",
3217                                 "rtcp.xr.dlrr",
3218                                 FT_UINT32,
3219                                 BASE_DEC,
3220                                 NULL,
3221                                 0x0,
3222                                 "", HFILL
3223                         }
3224                 },
3225 };
3226
3227         static gint *ett[] =
3228         {
3229                 &ett_rtcp,
3230                 &ett_ssrc,
3231                 &ett_ssrc_item,
3232                 &ett_ssrc_ext_high,
3233                 &ett_sdes,
3234                 &ett_sdes_item,
3235                 &ett_PoC1,
3236                 &ett_rtcp_setup,
3237                 &ett_rtcp_roundtrip_delay,
3238                 &ett_xr_block,
3239                 &ett_xr_block_contents,
3240                 &ett_xr_ssrc,
3241                 &ett_xr_loss_chunk,
3242                 &ett_poc1_conn_contents
3243         };
3244
3245         module_t *rtcp_module;
3246
3247         proto_rtcp = proto_register_protocol("Real-time Transport Control Protocol",
3248             "RTCP", "rtcp");
3249         proto_register_field_array(proto_rtcp, hf, array_length(hf));
3250         proto_register_subtree_array(ett, array_length(ett));
3251
3252         register_dissector("rtcp", dissect_rtcp, proto_rtcp);
3253
3254         rtcp_module = prefs_register_protocol(proto_rtcp, NULL);
3255
3256         prefs_register_bool_preference(rtcp_module, "show_setup_info",
3257                 "Show stream setup information",
3258                 "Where available, show which protocol and frame caused "
3259                 "this RTCP stream to be created",
3260                 &global_rtcp_show_setup_info);
3261
3262         prefs_register_bool_preference(rtcp_module, "heuristic_rtcp",
3263                 "Try to decode RTCP outside of conversations ",
3264                 "If call control SIP/H.323/RTSP/.. messages are missing in the trace, "
3265                 "RTCP isn't decoded without this",
3266                 &global_rtcp_heur);
3267
3268         prefs_register_bool_preference(rtcp_module, "show_roundtrip_calculation",
3269                 "Show relative roundtrip calculations",
3270                 "Try to work out network delay by comparing time between packets "
3271                 "as captured and delays as seen by endpoint",
3272                 &global_rtcp_show_roundtrip_calculation);
3273
3274         prefs_register_uint_preference(rtcp_module, "roundtrip_min_threshhold",
3275                 "Minimum roundtrip calculations to report (ms)",
3276                 "Minimum calculated roundtrip delay time in milliseconds that "
3277                 "should be reported",
3278                 MIN_ROUNDTRIP_TO_REPORT_DEFAULT, &global_rtcp_show_roundtrip_calculation_minimum);
3279
3280
3281 }
3282
3283 void
3284 proto_reg_handoff_rtcp(void)
3285 {
3286         /*
3287          * Register this dissector as one that can be selected by a
3288          * UDP port number.
3289          */
3290         rtcp_handle = find_dissector("rtcp");
3291         dissector_add_handle("udp.port", rtcp_handle);
3292
3293         heur_dissector_add( "udp", dissect_rtcp_heur, proto_rtcp);
3294 }