#if 0 out the stuff to set the reported length, as it'd throw an
[obnox/wireshark/wip.git] / packet-rtcp.c
index 053b25e4a6ba1ce5e6651b1db0f9c8a13e8f000c..2274dd8bc2168384c93a583172a5cc05eecb6dca 100644 (file)
@@ -1,27 +1,27 @@
 /* packet-rtcp.c
  *
- * $Id: packet-rtcp.c,v 1.24 2001/11/27 07:13:26 guy Exp $
+ * $Id: packet-rtcp.c,v 1.37 2003/05/28 22:40:19 guy Exp $
  *
  * Routines for RTCP dissection
  * RTCP = Real-time Transport Control Protocol
- * 
+ *
  * Copyright 2000, Philips Electronics N.V.
  * Written by Andreas Sikkema <andreas.sikkema@philips.com>
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
- * 
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
@@ -32,7 +32,7 @@
  * of ITU-T Recommendation H.225.0 (02/98) and RFC 1889
  * H.225.0 literally copies RFC 1889, but omitting a few sections.
  *
- * RTCP traffic is handled by an uneven UDP portnumber. This can be any 
+ * RTCP traffic is handled by an uneven UDP portnumber. This can be any
  * port number, but there is a registered port available, port 5005
  * See Annex B of ITU-T Recommendation H.225.0, section B.7
  *
 #endif
 
 #include <glib.h>
-#include "packet.h"
-
-#ifdef HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-#  include <netinet/in.h>
-#endif
+#include <epan/packet.h>
 
 #include <stdio.h>
 #include <string.h>
@@ -61,7 +53,7 @@
 #if 0
 #include "packet-ntp.h"
 #endif
-#include "conversation.h"
+#include <epan/conversation.h>
 
 /* Version is the first 2 bits of the first octet*/
 #define RTCP_VERSION(octet)    ((octet) >> 6)
@@ -73,7 +65,7 @@
 /* Receiver/ Sender count is the 5 last bits  */
 #define RTCP_COUNT(octet)      ((octet) & 0x1F)
 
-static const value_string rtcp_version_vals[] = 
+static const value_string rtcp_version_vals[] =
 {
        { 0, "Old VAT Version" },
        { 1, "First Draft Version" },
@@ -91,7 +83,7 @@ static const value_string rtcp_version_vals[] =
 #define RTCP_FIR  192
 #define RTCP_NACK 193
 
-static const value_string rtcp_packet_type_vals[] = 
+static const value_string rtcp_packet_type_vals[] =
 {
        { RTCP_SR,   "Sender Report" },
        { RTCP_RR,   "Receiver Report" },
@@ -114,7 +106,7 @@ static const value_string rtcp_packet_type_vals[] =
 #define RTCP_SDES_NOTE   7
 #define RTCP_SDES_PRIV   8
 
-static const value_string rtcp_sdes_type_vals[] = 
+static const value_string rtcp_sdes_type_vals[] =
 {
        { RTCP_SDES_END,   "END" },
        { RTCP_SDES_CNAME, "CNAME (user and domain)" },
@@ -144,7 +136,7 @@ static int hf_rtcp_sender_oct_cnt    = -1;
 static int hf_rtcp_ssrc_source       = -1;
 static int hf_rtcp_ssrc_fraction     = -1;
 static int hf_rtcp_ssrc_cum_nr       = -1;
-/* First the 32 bit number, then the split 
+/* First the 32 bit number, then the split
  * up 16 bit values */
 /* These two are added to a subtree */
 static int hf_rtcp_ssrc_ext_high_seq = -1;
@@ -211,7 +203,7 @@ void rtcp_add_address( packet_info *pinfo, const unsigned char* ip_addr,
        }
 
        /*
-        * Check if the ip address and port combination is not 
+        * Check if the ip address and port combination is not
         * already registered
         */
        pconv = find_conversation( &src_addr, &fake_addr, PT_UDP, prt, 0, 0 );
@@ -229,7 +221,7 @@ void rtcp_add_address( packet_info *pinfo, const unsigned char* ip_addr,
 }
 
 #if 0
-static void rtcp_init( void ) 
+static void rtcp_init( void )
 {
        unsigned char* tmp_data;
        int i;
@@ -238,7 +230,7 @@ static void rtcp_init( void )
        fake_addr.type = AT_IPv4;
        fake_addr.len = 4;
 
-       tmp_data = malloc( fake_addr.len );
+       tmp_data = g_malloc( fake_addr.len );
        for ( i = 0; i < fake_addr.len; i++) {
                tmp_data[i] = 0;
        }
@@ -287,7 +279,7 @@ dissect_rtcp_heur( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
 
 
 static int
-dissect_rtcp_nack( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree )
+dissect_rtcp_nack( tvbuff_t *tvb, int offset, proto_tree *tree )
 {
        /* Packet type = FIR (H261) */
        proto_tree_add_uint( tree, hf_rtcp_rc, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 31 );
@@ -303,7 +295,7 @@ dissect_rtcp_nack( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree )
        /* SSRC  */
        proto_tree_add_uint( tree, hf_rtcp_ssrc_source, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
        offset += 4;
-       
+
        /* FSN, 16 bits */
        proto_tree_add_uint( tree, hf_rtcp_fsn, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
        offset += 2;
@@ -316,7 +308,7 @@ dissect_rtcp_nack( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree )
 }
 
 static int
-dissect_rtcp_fir( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree )
+dissect_rtcp_fir( tvbuff_t *tvb, int offset, proto_tree *tree )
 {
        /* Packet type = FIR (H261) */
        proto_tree_add_uint( tree, hf_rtcp_rc, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 31 );
@@ -332,12 +324,12 @@ dissect_rtcp_fir( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree )
        /* SSRC  */
        proto_tree_add_uint( tree, hf_rtcp_ssrc_source, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
        offset += 4;
-       
+
        return offset;
 }
 
 static int
-dissect_rtcp_app( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
+dissect_rtcp_app( tvbuff_t *tvb, int offset, proto_tree *tree,
     unsigned int padding, unsigned int packet_len )
 {
        unsigned int counter = 0;
@@ -360,7 +352,7 @@ dissect_rtcp_app( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
 
        /* Applications specific data */
        if ( padding ) {
-               /* If there's padding present, we have to remove that from the data part 
+               /* If there's padding present, we have to remove that from the data part
                 * The last octet of the packet contains the length of the padding
                 */
                packet_len -= tvb_get_guint8( tvb, offset + packet_len - 1 );
@@ -372,7 +364,7 @@ dissect_rtcp_app( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
 }
 
 static int
-dissect_rtcp_bye( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
+dissect_rtcp_bye( tvbuff_t *tvb, int offset, proto_tree *tree,
     unsigned int count )
 {
        unsigned int chunk          = 1;
@@ -382,29 +374,32 @@ dissect_rtcp_bye( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
 
        while ( chunk <= count ) {
                /* source identifier, 32 bits */
-               proto_tree_add_uint( tree, hf_rtcp_ssrc_source, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
+               proto_tree_add_item( tree, hf_rtcp_ssrc_source, tvb, offset, 4, FALSE);
                offset += 4;
+               chunk++;
        }
 
-       /* Bye reason consists of an 8 bit length l and a string with length l */
-       reason_length = tvb_get_guint8( tvb, offset );
-       proto_tree_add_item( tree, hf_rtcp_ssrc_length, tvb, offset, 1, FALSE );
-       offset++;
+       if ( tvb_reported_length_remaining( tvb, offset ) > 0 ) {
+               /* Bye reason consists of an 8 bit length l and a string with length l */
+               reason_length = tvb_get_guint8( tvb, offset );
+               proto_tree_add_item( tree, hf_rtcp_ssrc_length, tvb, offset, 1, FALSE );
+               offset++;
 
-       reason_text = ( char* ) malloc( reason_length + 1 );
-       for ( counter = 0; counter < reason_length; counter++ ) reason_text[ counter ] = tvb_get_guint8( tvb, offset + counter );
-       /* strncpy( reason_text, pd + offset, reason_length ); */
-       reason_text[ reason_length ] = '\0';
-       proto_tree_add_string( tree, hf_rtcp_ssrc_text, tvb, offset, reason_length, reason_text );
-       free( reason_text );
-       offset += reason_length;
+               reason_text = g_malloc( reason_length + 1 );
+               for ( counter = 0; counter < reason_length; counter++ ) reason_text[ counter ] = tvb_get_guint8( tvb, offset + counter );
+               /* strncpy( reason_text, pd + offset, reason_length ); */
+               reason_text[ reason_length ] = '\0';
+               proto_tree_add_string( tree, hf_rtcp_ssrc_text, tvb, offset, reason_length, reason_text );
+               g_free( reason_text );
+               offset += reason_length;
+       }
 
        return offset;
 
 }
 
-static int
-dissect_rtcp_sdes( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
+static void
+dissect_rtcp_sdes( tvbuff_t *tvb, int offset, proto_tree *tree,
     unsigned int count )
 {
        unsigned int chunk          = 1;
@@ -420,14 +415,14 @@ dissect_rtcp_sdes( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
        unsigned int counter        = 0;
        unsigned int prefix_len     = 0;
        char *prefix_string = NULL;
-       
+
        while ( chunk <= count ) {
                /* Create a subtree for this chunk; we don't yet know
                   the length. */
                start_offset = offset;
 
                ssrc = tvb_get_ntohl( tvb, offset );
-               sdes_item = proto_tree_add_text(tree, tvb, offset, 0,
+               sdes_item = proto_tree_add_text(tree, tvb, offset, -1,
                    "Chunk %u, SSRC/CSRC %u", chunk, ssrc);
                sdes_tree = proto_item_add_subtree( sdes_item, ett_sdes );
 
@@ -436,12 +431,12 @@ dissect_rtcp_sdes( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
                offset += 4;
 
                /* Create a subtree for the SDES items; we don't yet know
-                  the length */        
+                  the length */
                items_start_offset = offset;
-               ti = proto_tree_add_text(sdes_tree, tvb, offset, 0,
+               ti = proto_tree_add_text(sdes_tree, tvb, offset, -1,
                    "SDES items" );
                sdes_item_tree = proto_item_add_subtree( ti, ett_sdes_item );
-               
+
                /*
                 * Not every message is ended with "null" bytes, so check for
                 * end of frame instead.
@@ -467,32 +462,32 @@ dissect_rtcp_sdes( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
                                proto_tree_add_item( sdes_item_tree, hf_rtcp_ssrc_prefix_len, tvb, offset, 1, FALSE );
                                offset++;
 
-                               prefix_string = ( char * ) malloc( prefix_len + 1 );
+                               prefix_string = g_malloc( prefix_len + 1 );
                                for ( counter = 0; counter < prefix_len; counter++ )
                                        prefix_string[ counter ] =
                                            tvb_get_guint8( tvb, offset + counter );
                                /* strncpy( prefix_string, pd + offset, prefix_len ); */
                                prefix_string[ prefix_len ] = '\0';
                                proto_tree_add_string( sdes_item_tree, hf_rtcp_ssrc_prefix_string, tvb, offset, prefix_len, prefix_string );
-                               free( prefix_string );
+                               g_free( prefix_string );
                                offset += prefix_len;
                        }
-                       prefix_string = ( char * ) malloc( item_len + 1 );
+                       prefix_string = g_malloc( item_len + 1 );
                        for ( counter = 0; counter < item_len; counter++ )
                            prefix_string[ counter ] =
                                tvb_get_guint8( tvb, offset + counter );
                        /* strncpy( prefix_string, pd + offset, item_len ); */
                        prefix_string[ item_len] = 0;
                        proto_tree_add_string( sdes_item_tree, hf_rtcp_ssrc_text, tvb, offset, item_len, prefix_string );
-                       free( prefix_string );
+                       g_free( prefix_string );
                        offset += item_len;
                }
 
                /* Set the length of the items subtree. */
                proto_item_set_len(ti, offset - items_start_offset);
 
-               /* 32 bits = 4 bytes, so..... 
-                * If offset % 4 != 0, we divide offset by 4, add one and then 
+               /* 32 bits = 4 bytes, so.....
+                * If offset % 4 != 0, we divide offset by 4, add one and then
                 * multiply by 4 again to reach the boundary
                 */
                if ( offset % 4 != 0 )
@@ -503,13 +498,10 @@ dissect_rtcp_sdes( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
 
                chunk++;
        }
-
-
-       return offset;
 }
 
 static int
-dissect_rtcp_rr( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
+dissect_rtcp_rr( tvbuff_t *tvb, int offset, proto_tree *tree,
     unsigned int count )
 {
        unsigned int counter = 1;
@@ -525,11 +517,11 @@ dissect_rtcp_rr( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
                ti = proto_tree_add_text(tree, tvb, offset, 24,
                    "Source %u", counter );
                ssrc_tree = proto_item_add_subtree( ti, ett_ssrc );
-               
+
                /* SSRC_n source identifier, 32 bits */
                proto_tree_add_uint( ssrc_tree, hf_rtcp_ssrc_source, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
                offset += 4;
-       
+
                ti = proto_tree_add_text(ssrc_tree, tvb, offset, 20, "SSRC contents" );
                ssrc_sub_tree = proto_item_add_subtree( ti, ett_ssrc_item );
 
@@ -582,7 +574,7 @@ dissect_rtcp_rr( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
 }
 
 static int
-dissect_rtcp_sr( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
+dissect_rtcp_sr( tvbuff_t *tvb, int offset, proto_tree *tree,
     unsigned int count )
 {
 #if 0
@@ -618,7 +610,7 @@ dissect_rtcp_sr( tvbuff_t *tvb, int offset, frame_data *fd, proto_tree *tree,
 
        /* The rest of the packet is equal to the RR packet */
        if ( count != 0 )
-               offset = dissect_rtcp_rr( tvb, offset, fd, tree, count );
+               offset = dissect_rtcp_rr( tvb, offset, tree, count );
 
        return offset;
 }
@@ -635,51 +627,51 @@ dissect_rtcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
        unsigned int offset      = 0;
        guint16 packet_length    = 0;
 
-       if ( check_col( pinfo->fd, COL_PROTOCOL ) )   {
-               col_set_str( pinfo->fd, COL_PROTOCOL, "RTCP" );
+       if ( check_col( pinfo->cinfo, COL_PROTOCOL ) )   {
+               col_set_str( pinfo->cinfo, COL_PROTOCOL, "RTCP" );
        }
-       
-       if ( check_col( pinfo->fd, COL_INFO) ) {
+
+       if ( check_col( pinfo->cinfo, COL_INFO) ) {
                /* The second octet contains the packet type */
                /* switch ( pd[ offset + 1 ] ) { */
                switch ( tvb_get_guint8( tvb, 1 ) ) {
                        case RTCP_SR:
-                               col_set_str( pinfo->fd, COL_INFO, "Sender Report");
+                               col_set_str( pinfo->cinfo, COL_INFO, "Sender Report");
                                break;
                        case RTCP_RR:
-                               col_set_str( pinfo->fd, COL_INFO, "Receiver Report");
+                               col_set_str( pinfo->cinfo, COL_INFO, "Receiver Report");
                                break;
                        case RTCP_SDES:
-                               col_set_str( pinfo->fd, COL_INFO, "Source Description");
+                               col_set_str( pinfo->cinfo, COL_INFO, "Source Description");
                                break;
                        case RTCP_BYE:
-                               col_set_str( pinfo->fd, COL_INFO, "Goodbye");
+                               col_set_str( pinfo->cinfo, COL_INFO, "Goodbye");
                                break;
                        case RTCP_APP:
-                               col_set_str( pinfo->fd, COL_INFO, "Application defined");
+                               col_set_str( pinfo->cinfo, COL_INFO, "Application defined");
                                break;
                        case RTCP_FIR:
-                               col_set_str( pinfo->fd, COL_INFO, "Full Intra-frame Request (H.261)");
+                               col_set_str( pinfo->cinfo, COL_INFO, "Full Intra-frame Request (H.261)");
                                break;
                        case RTCP_NACK:
-                               col_set_str( pinfo->fd, COL_INFO, "Negative Acknowledgement (H.261)");
+                               col_set_str( pinfo->cinfo, COL_INFO, "Negative Acknowledgement (H.261)");
                                break;
                        default:
-                               col_set_str( pinfo->fd, COL_INFO, "Unknown packet type");
+                               col_set_str( pinfo->cinfo, COL_INFO, "Unknown packet type");
                                break;
                }
        }
 
        if ( tree ) {
 
-               /* 
-                * Check if there are at least 4 bytes left in the frame, 
-                * the last 16 bits of those is the length of the current 
+               /*
+                * Check if there are at least 4 bytes left in the frame,
+                * the last 16 bits of those is the length of the current
                 * RTCP message. The last compound message contains padding,
                 * that enables us to break from the while loop.
                 */
                while ( tvb_bytes_exist( tvb, offset, 4) ) {
-                       /* 
+                       /*
                         * First retreive the packet_type
                         */
                        packet_type = tvb_get_guint8( tvb, offset + 1 );
@@ -689,13 +681,13 @@ dissect_rtcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
                         */
                        if ( ( packet_type < 192 ) || ( packet_type >  204 ) )
                                break;
-                       
+
                        /*
                         * get the packet-length for the complete RTCP packet
                         */
                        packet_length = ( tvb_get_ntohs( tvb, offset + 2 ) + 1 ) * 4;
 
-                       ti = proto_tree_add_item(tree, proto_rtcp, tvb, offset, packet_length, FALSE ); 
+                       ti = proto_tree_add_item(tree, proto_rtcp, tvb, offset, packet_length, FALSE );
                        rtcp_tree = proto_item_add_subtree( ti, ett_rtcp );
 
                        temp_byte = tvb_get_guint8( tvb, offset );
@@ -723,8 +715,8 @@ dissect_rtcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
                                        proto_tree_add_uint( rtcp_tree, hf_rtcp_ssrc_sender, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
                                        offset += 4;
 
-                                       if ( packet_type == RTCP_SR ) offset = dissect_rtcp_sr( tvb, offset, pinfo->fd, rtcp_tree, elem_count );
-                                       else offset = dissect_rtcp_rr( tvb, offset, pinfo->fd, rtcp_tree, elem_count );
+                                       if ( packet_type == RTCP_SR ) offset = dissect_rtcp_sr( tvb, offset, rtcp_tree, elem_count );
+                                       else offset = dissect_rtcp_rr( tvb, offset, rtcp_tree, elem_count );
                                        break;
                                case RTCP_SDES:
                                        /* Source count, 5 bits */
@@ -736,7 +728,8 @@ dissect_rtcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
                                        /* Packet length in 32 bit words MINUS one, 16 bits */
                                        proto_tree_add_uint( rtcp_tree, hf_rtcp_length, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
                                        offset += 2;
-                                       offset = dissect_rtcp_sdes( tvb, offset, pinfo->fd, rtcp_tree, elem_count );
+                                       dissect_rtcp_sdes( tvb, offset, rtcp_tree, elem_count );
+                                       offset += packet_length - 4;
                                        break;
                                case RTCP_BYE:
                                        /* Source count, 5 bits */
@@ -748,7 +741,7 @@ dissect_rtcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
                                        /* Packet length in 32 bit words MINUS one, 16 bits */
                                        proto_tree_add_uint( rtcp_tree, hf_rtcp_length, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
                                        offset += 2;
-                                       offset = dissect_rtcp_bye( tvb, offset, pinfo->fd, rtcp_tree, elem_count );
+                                       offset = dissect_rtcp_bye( tvb, offset, rtcp_tree, elem_count );
                                        break;
                                case RTCP_APP:
                                        /* Subtype, 5 bits */
@@ -761,14 +754,14 @@ dissect_rtcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
                                        proto_tree_add_uint( rtcp_tree, hf_rtcp_length, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
                                        offset += 2;
                                        offset = dissect_rtcp_app( tvb, offset,
-                                           pinfo->fd, rtcp_tree, padding_set,
+                                           rtcp_tree, padding_set,
                                            packet_length - 4 );
                                        break;
                                case RTCP_FIR:
-                                       offset = dissect_rtcp_fir( tvb, offset, pinfo->fd, rtcp_tree );
+                                       offset = dissect_rtcp_fir( tvb, offset, rtcp_tree );
                                        break;
                                case RTCP_NACK:
-                                       offset = dissect_rtcp_nack( tvb, offset, pinfo->fd, rtcp_tree );
+                                       offset = dissect_rtcp_nack( tvb, offset, rtcp_tree );
                                        break;
                                default:
                                        /*
@@ -779,13 +772,13 @@ dissect_rtcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
                                        break;
                        }
                }
-               /* If the padding bit is set, the last octet of the 
-                * packet contains the length of the padding 
+               /* If the padding bit is set, the last octet of the
+                * packet contains the length of the padding
                 * We only have to check for this at the end of the LAST RTCP message
                 */
                if ( padding_set ) {
-                       /* If everything went according to plan offset should now point to the 
-                        * first octet of the padding 
+                       /* If everything went according to plan offset should now point to the
+                        * first octet of the padding
                         */
                        proto_tree_add_item( rtcp_tree, hf_rtcp_padding_data, tvb, offset, tvb_length_remaining( tvb, offset) - 1, FALSE );
                        offset += tvb_length_remaining( tvb, offset) - 1;
@@ -797,407 +790,407 @@ dissect_rtcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
 void
 proto_register_rtcp(void)
 {
-       static hf_register_info hf[] = 
+       static hf_register_info hf[] =
        {
-               { 
+               {
                        &hf_rtcp_version,
-                       { 
-                               "Version", 
-                               "rtcp.version", 
-                               FT_UINT8, 
-                               BASE_DEC, 
-                               VALS(rtcp_version_vals), 
+                       {
+                               "Version",
+                               "rtcp.version",
+                               FT_UINT8,
+                               BASE_DEC,
+                               VALS(rtcp_version_vals),
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_padding,
-                       { 
-                               "Padding", 
-                               "rtcp.padding", 
-                               FT_BOOLEAN, 
-                               BASE_NONE, 
-                               NULL, 
+                       {
+                               "Padding",
+                               "rtcp.padding",
+                               FT_BOOLEAN,
+                               BASE_NONE,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_rc,
-                       { 
-                               "Reception report count", 
-                               "rtcp.rc", 
-                               FT_UINT8, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Reception report count",
+                               "rtcp.rc",
+                               FT_UINT8,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_sc,
-                       { 
-                               "Source count", 
-                               "rtcp.sc", 
-                               FT_UINT8, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Source count",
+                               "rtcp.sc",
+                               FT_UINT8,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_pt,
-                       { 
-                               "Packet type", 
-                               "rtcp.pt", 
-                               FT_UINT8, 
-                               BASE_DEC, 
-                               VALS( rtcp_packet_type_vals ), 
+                       {
+                               "Packet type",
+                               "rtcp.pt",
+                               FT_UINT8,
+                               BASE_DEC,
+                               VALS( rtcp_packet_type_vals ),
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_length,
-                       { 
-                               "Length", 
-                               "rtcp.length", 
-                               FT_UINT16, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Length",
+                               "rtcp.length",
+                               FT_UINT16,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_sender,
-                       { 
-                               "Sender SSRC", 
-                               "rtcp.senderssrc", 
-                               FT_UINT32, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Sender SSRC",
+                               "rtcp.senderssrc",
+                               FT_UINT32,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ntp,
-                       { 
-                               "NTP timestamp", 
-                               "rtcp.timestamp.ntp", 
-                               FT_STRING, 
-                               BASE_NONE, 
-                               NULL, 
+                       {
+                               "NTP timestamp",
+                               "rtcp.timestamp.ntp",
+                               FT_STRING,
+                               BASE_NONE,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_rtp_timestamp,
-                       { 
-                               "RTP timestamp", 
-                               "rtcp.timestamp.rtp", 
-                               FT_UINT32, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "RTP timestamp",
+                               "rtcp.timestamp.rtp",
+                               FT_UINT32,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_sender_pkt_cnt,
-                       { 
-                               "Sender's packet count", 
-                               "rtcp.sender.packetcount", 
-                               FT_UINT32, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Sender's packet count",
+                               "rtcp.sender.packetcount",
+                               FT_UINT32,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_sender_oct_cnt,
-                       { 
-                               "Sender's octet count", 
-                               "rtcp.sender.octetcount", 
-                               FT_UINT32, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Sender's octet count",
+                               "rtcp.sender.octetcount",
+                               FT_UINT32,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_source,
-                       { 
-                               "Identifier", 
-                               "rtcp.ssrc.identifier", 
-                               FT_UINT32, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Identifier",
+                               "rtcp.ssrc.identifier",
+                               FT_UINT32,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_fraction,
-                       { 
-                               "Fraction lost", 
-                               "rtcp.ssrc.fraction", 
-                               FT_UINT8, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Fraction lost",
+                               "rtcp.ssrc.fraction",
+                               FT_UINT8,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_cum_nr,
-                       { 
-                               "Cumulative number of packets lost", 
-                               "rtcp.ssrc.cum_nr", 
-                               FT_UINT32, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Cumulative number of packets lost",
+                               "rtcp.ssrc.cum_nr",
+                               FT_UINT32,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_ext_high_seq,
-                       { 
-                               "Extended highest sequence number received", 
-                               "rtcp.ssrc.ext_high", 
-                               FT_UINT32, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Extended highest sequence number received",
+                               "rtcp.ssrc.ext_high",
+                               FT_UINT32,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_high_seq,
-                       { 
-                               "Highest sequence number received", 
-                               "rtcp.ssrc.high_seq", 
-                               FT_UINT16, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Highest sequence number received",
+                               "rtcp.ssrc.high_seq",
+                               FT_UINT16,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_high_cycles,
-                       { 
-                               "Sequence number cycles count", 
-                               "rtcp.ssrc.high_cycles", 
-                               FT_UINT16, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Sequence number cycles count",
+                               "rtcp.ssrc.high_cycles",
+                               FT_UINT16,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_jitter,
-                       { 
-                               "Interarrival jitter", 
-                               "rtcp.ssrc.jitter", 
-                               FT_UINT32, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Interarrival jitter",
+                               "rtcp.ssrc.jitter",
+                               FT_UINT32,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_lsr,
-                       { 
-                               "Last SR timestamp", 
-                               "rtcp.ssrc.lsr", 
-                               FT_UINT32, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Last SR timestamp",
+                               "rtcp.ssrc.lsr",
+                               FT_UINT32,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_dlsr,
-                       { 
-                               "Delay since last SR timestamp", 
-                               "rtcp.ssrc.dlsr", 
-                               FT_UINT32, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Delay since last SR timestamp",
+                               "rtcp.ssrc.dlsr",
+                               FT_UINT32,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_csrc,
-                       { 
-                               "SSRC / CSRC identifier", 
-                               "rtcp.sdes.ssrc_csrc", 
-                               FT_UINT32, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "SSRC / CSRC identifier",
+                               "rtcp.sdes.ssrc_csrc",
+                               FT_UINT32,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_type,
-                       { 
-                               "Type", 
-                               "rtcp.sdes.type", 
-                               FT_UINT8, 
-                               BASE_DEC, 
-                               VALS( rtcp_sdes_type_vals ), 
+                       {
+                               "Type",
+                               "rtcp.sdes.type",
+                               FT_UINT8,
+                               BASE_DEC,
+                               VALS( rtcp_sdes_type_vals ),
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_length,
-                       { 
-                               "Length", 
-                               "rtcp.sdes.length", 
-                               FT_UINT32, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Length",
+                               "rtcp.sdes.length",
+                               FT_UINT32,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_text,
-                       { 
-                               "Text", 
-                               "rtcp.sdes.text", 
-                               FT_STRING, 
-                               BASE_NONE, 
-                               NULL, 
+                       {
+                               "Text",
+                               "rtcp.sdes.text",
+                               FT_STRING,
+                               BASE_NONE,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_prefix_len,
-                       { 
-                               "Prefix length", 
-                               "rtcp.sdes.prefix.length", 
-                               FT_UINT8, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Prefix length",
+                               "rtcp.sdes.prefix.length",
+                               FT_UINT8,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_ssrc_prefix_string,
-                       { 
-                               "Prefix string", 
-                               "rtcp.sdes.prefix.string", 
-                               FT_STRING, 
-                               BASE_NONE, 
-                               NULL, 
+                       {
+                               "Prefix string",
+                               "rtcp.sdes.prefix.string",
+                               FT_STRING,
+                               BASE_NONE,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_subtype,
-                       { 
-                               "Subtype", 
-                               "rtcp.app.subtype", 
-                               FT_UINT8, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Subtype",
+                               "rtcp.app.subtype",
+                               FT_UINT8,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_name_ascii,
-                       { 
-                               "Name (ASCII)", 
-                               "rtcp.app.name", 
-                               FT_STRING, 
-                               BASE_NONE, 
-                               NULL, 
+                       {
+                               "Name (ASCII)",
+                               "rtcp.app.name",
+                               FT_STRING,
+                               BASE_NONE,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_app_data,
-                       { 
-                               "Application specific data", 
-                               "rtcp.app.data", 
-                               FT_BYTES, 
-                               BASE_NONE, 
-                               NULL, 
+                       {
+                               "Application specific data",
+                               "rtcp.app.data",
+                               FT_BYTES,
+                               BASE_NONE,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_fsn,
-                       { 
-                               "First sequence number", 
-                               "rtcp.nack.fsn", 
-                               FT_UINT16, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "First sequence number",
+                               "rtcp.nack.fsn",
+                               FT_UINT16,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_blp,
-                       { 
-                               "Bitmask of following lost packets", 
-                               "rtcp.nack.blp", 
-                               FT_UINT16, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Bitmask of following lost packets",
+                               "rtcp.nack.blp",
+                               FT_UINT16,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_padding_count,
-                       { 
-                               "Padding count", 
-                               "rtcp.padding.count", 
-                               FT_UINT8, 
-                               BASE_DEC, 
-                               NULL, 
+                       {
+                               "Padding count",
+                               "rtcp.padding.count",
+                               FT_UINT8,
+                               BASE_DEC,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
-               { 
+               {
                        &hf_rtcp_padding_data,
-                       { 
-                               "Padding data", 
-                               "rtcp.padding.data", 
-                               FT_BYTES, 
-                               BASE_NONE, 
-                               NULL, 
+                       {
+                               "Padding data",
+                               "rtcp.padding.data",
+                               FT_BYTES,
+                               BASE_NONE,
+                               NULL,
                                0x0,
-                               "", HFILL 
+                               "", HFILL
                        }
                },
 };
-       
-       static gint *ett[] = 
+
+       static gint *ett[] =
        {
                &ett_rtcp,
                &ett_ssrc,
@@ -1223,9 +1216,12 @@ proto_register_rtcp(void)
 void
 proto_reg_handoff_rtcp(void)
 {
+       dissector_handle_t rtcp_handle;
+
        /*
-        * Register this dissector as one that can be assigned to a
-        * UDP conversation.
+        * Register this dissector as one that can be selected by a
+        * UDP port number.
         */
-       conv_dissector_add("udp", dissect_rtcp, proto_rtcp);
+       rtcp_handle = find_dissector("rtcp");
+       dissector_add_handle("udp.port", rtcp_handle);
 }