Reduce the CinemaScope-like proportions of the preferences dialog by
[obnox/wireshark/wip.git] / packet-rtp.c
1 /* packet-rtp.c
2  *
3  * Routines for RTP dissection
4  * RTP = Real time Transport Protocol
5  * 
6  * Copyright 2000, Philips Electronics N.V.
7  * Written by Andreas Sikkema <andreas.sikkema@philips.com>
8  *
9  * $Id: packet-rtp.c,v 1.25 2001/09/08 00:43:51 guy Exp $
10  *
11  * Ethereal - Network traffic analyzer
12  * By Gerald Combs <gerald@ethereal.com>
13  * Copyright 1998 Gerald Combs
14  * 
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  * 
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  * 
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
28  */
29
30 /*
31  * This dissector tries to dissect the RTP protocol according to Annex A
32  * of ITU-T Recommendation H.225.0 (02/98) or RFC 1889
33  *
34  * RTP traffic is handled by an even UDP portnumber. This can be any 
35  * port number, but there is a registered port available, port 5004
36  * See Annex B of ITU-T Recommendation H.225.0, section B.7
37  *
38  * This doesn't dissect older versions of RTP, such as:
39  *
40  *    the vat protocol ("version 0") - see
41  *
42  *      ftp://ftp.ee.lbl.gov/conferencing/vat/alpha-test/vatsrc-4.0b2.tar.gz
43  *
44  *    and look in "session-vat.cc" if you want to write a dissector
45  *    (have fun - there aren't any nice header files showing the packet
46  *    format);
47  *
48  *    version 1, as documented in
49  *
50  *      ftp://gaia.cs.umass.edu/pub/hgschulz/rtp/draft-ietf-avt-rtp-04.txt
51  */
52
53
54 #ifdef HAVE_CONFIG_H
55 # include "config.h"
56 #endif
57
58 #include <glib.h>
59 #include "packet.h"
60
61 #ifdef HAVE_SYS_TYPES_H
62 #  include <sys/types.h>
63 #endif
64
65 #ifdef HAVE_NETINET_IN_H
66 #  include <netinet/in.h>
67 #endif
68
69 #include <stdio.h>
70 #include <string.h>
71
72 #include "packet-rtp.h"
73 #include "conversation.h"
74
75 /* RTP header fields             */
76 static int proto_rtp           = -1;
77 static int hf_rtp_version      = -1;
78 static int hf_rtp_padding      = -1;
79 static int hf_rtp_extension    = -1;
80 static int hf_rtp_csrc_count   = -1;
81 static int hf_rtp_marker       = -1;
82 static int hf_rtp_payload_type = -1;
83 static int hf_rtp_seq_nr       = -1;
84 static int hf_rtp_timestamp    = -1;
85 static int hf_rtp_ssrc         = -1;
86 static int hf_rtp_csrc_item    = -1;
87 static int hf_rtp_data         = -1;
88 static int hf_rtp_padding_data = -1;
89 static int hf_rtp_padding_count= -1;
90
91 /* RTP header extension fields   */
92 static int hf_rtp_prof_define  = -1;
93 static int hf_rtp_length       = -1;
94 static int hf_rtp_hdr_ext      = -1;
95
96 /* RTP fields defining a sub tree */
97 static gint ett_rtp       = -1;
98 static gint ett_csrc_list = -1;
99 static gint ett_hdr_ext   = -1;
100
101 static dissector_handle_t h261_handle;
102 static dissector_handle_t mpeg1_handle;
103
104 /*
105  * Fields in the first octet of the RTP header.
106  */
107
108 /* Version is the first 2 bits of the first octet*/
109 #define RTP_VERSION(octet)      ((octet) >> 6)
110
111 /* Padding is the third bit; No need to shift, because true is any value
112    other than 0! */
113 #define RTP_PADDING(octet)      ((octet) & 0x20)
114
115 /* Extension bit is the fourth bit */
116 #define RTP_EXTENSION(octet)    ((octet) & 0x10)
117
118 /* CSRC count is the last four bits */
119 #define RTP_CSRC_COUNT(octet)   ((octet) & 0xF)
120
121 static const value_string rtp_version_vals[] = 
122 {
123         { 0, "Old VAT Version" },
124         { 1, "First Draft Version" },
125         { 2, "RFC 1889 Version" },
126         { 0, NULL },
127 };
128
129 /*
130  * Fields in the second octet of the RTP header.
131  */
132
133 /* Marker is the first bit of the second octet */
134 #define RTP_MARKER(octet)       ((octet) & 0x80)
135
136 /* Payload type is the last 7 bits */
137 #define RTP_PAYLOAD_TYPE(octet) ((octet) & 0x7F)
138
139 /* 
140  * RTP Payload types 
141  * Table B.2 / H.225.0
142  * Also RFC 1890
143  */
144 #define PT_PCMU         0
145 #define PT_1016         1
146 #define PT_G721         2
147 #define PT_GSM          3
148 #define PT_G723         4
149 #define PT_DVI4_8000    5
150 #define PT_DVI4_16000   6
151 #define PT_LPC          7
152 #define PT_PCMA         8
153 #define PT_G722         9
154 #define PT_L16_STEREO   10
155 #define PT_L16_MONO     11
156 #define PT_MPA          14
157 #define PT_G728         15
158 #define PT_G729         18
159 #define PT_CELB         25
160 #define PT_JPEG         26
161 #define PT_NV           28
162 #define PT_H261         31
163 #define PT_MPV          32
164 #define PT_MP2T         33
165 #define PT_H263         34
166
167 static const value_string rtp_payload_type_vals[] = 
168 {
169         { PT_PCMU,      "ITU-T G.711 PCMU" },
170         { PT_1016,      "USA Federal Standard FS-1016" },
171         { PT_G721,      "ITU-T G.721" },
172         { PT_GSM,       "GSM 06.10" },
173         { PT_G723,      "ITU-T G.723" },
174         { PT_DVI4_8000, "DVI4 8000 samples/s" },
175         { PT_DVI4_16000, "DVI4 16000 samples/s" },
176         { PT_LPC,       "LPC" },
177         { PT_PCMA,      "ITU-T G.711 PCMA" },
178         { PT_G722,      "ITU-T G.722" },
179         { PT_L16_STEREO, "16-bit uncompressed audio, stereo" },
180         { PT_L16_MONO,  "16-bit uncompressed audio, monaural" },
181         { PT_MPA,       "MPEG-I/II Audeo"},
182         { PT_G728,      "ITU-T G.728" },
183         { PT_G729,      "ITU-T G.729" },
184         { PT_CELB,      "Sun CELL-B" },
185         { PT_JPEG,      "JPEG" },
186         { PT_NV,        "'nv' program" },
187         { PT_H261,      "ITU-T H.261" },
188         { PT_MPV,       "MPEG-I/II Video"},
189         { PT_MP2T,      "MPEG-II transport streams"},
190         { PT_H263,      "ITU-T H.263" },
191         { 0,            NULL },
192 };
193
194 static address fake_addr;
195 static int heur_init = FALSE;
196
197 void rtp_add_address( packet_info *pinfo, const unsigned char* ip_addr,
198     int prt )
199 {
200         address src_addr;
201         conversation_t* pconv;
202
203         /*
204          * If this isn't the first time this packet has been processed,
205          * we've already done this work, so we don't need to do it
206          * again.
207          */
208         if (pinfo->fd->flags.visited)
209                 return;
210
211         src_addr.type = AT_IPv4;
212         src_addr.len = 4;
213         src_addr.data = ip_addr;
214
215         /*
216          * The first time the function is called let the tcp dissector
217          * know that we're interested in traffic
218          */
219         if ( ! heur_init ) {
220                 heur_dissector_add( "udp", dissect_rtp_heur, proto_rtp );
221                 heur_init = TRUE;
222         }
223
224         /*
225          * Check if the ip address an dport combination is not 
226          * already registered
227          */
228         pconv = find_conversation( &src_addr, &fake_addr, PT_UDP, prt, 0, 0 );
229
230         /*
231          * If not, add
232          * XXX - use wildcard address and port B?
233          */
234         if ( ! pconv ) {
235                 pconv = conversation_new( &src_addr, &fake_addr, PT_UDP,
236                     (guint32) prt, (guint32) 0, 0 );
237                 conversation_add_proto_data(pconv, proto_rtp, NULL);
238         }
239
240 }
241
242 #if 0
243 static void rtp_init( void ) 
244 {
245         unsigned char* tmp_data;
246         int i;
247
248         /* Create a fake adddress... */
249         fake_addr.type = AT_IPv4;
250         fake_addr.len = 4;
251
252         tmp_data = malloc( fake_addr.len );
253         for ( i = 0; i < fake_addr.len; i++) {
254                 tmp_data[i] = 0;
255         }
256         fake_addr.data = tmp_data;
257 }
258 #endif
259
260 gboolean
261 dissect_rtp_heur( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
262 {
263         conversation_t* pconv;
264
265         if (!proto_is_protocol_enabled(proto_rtp))
266                 return FALSE;   /* RTP has been disabled */
267
268         /* This is a heuristic dissector, which means we get all the TCP
269          * traffic not sent to a known dissector and not claimed by
270          * a heuristic dissector called before us!
271          * So we first check if the frame is really meant for us.
272          */
273         if ( ( pconv = find_conversation( &pinfo->src, &fake_addr, pinfo->ptype,
274             pinfo->srcport, 0, 0 ) ) == NULL ) {
275                 /*
276                  * The source ip:port combination was not what we were
277                  * looking for, check the destination
278                  */
279                 if ( ( pconv = find_conversation( &pinfo->dst, &fake_addr,
280                     pinfo->ptype, pinfo->destport, 0, 0 ) ) == NULL ) {
281                         return FALSE;
282                 }
283         }
284
285         /*
286          * An RTP conversation always has a data item for RTP.
287          * (Its existence is sufficient to indicate that this is an RTP
288          * conversation.)
289          */
290         if (conversation_get_proto_data(pconv, proto_rtp) == NULL)
291                 return FALSE;
292
293         dissect_rtp( tvb, pinfo, tree );
294
295         return TRUE;
296 }
297
298 static void 
299 dissect_rtp_data( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
300     proto_tree *rtp_tree, int offset, unsigned int data_len,
301     unsigned int data_reported_len, unsigned int payload_type )
302 {
303         tvbuff_t *newtvb;
304
305         switch( payload_type ) {
306                 case PT_H261:
307                         newtvb = tvb_new_subset( tvb, offset, data_len,
308                             data_reported_len );
309                         call_dissector(h261_handle, newtvb, pinfo, tree);
310                         break;
311
312                 case PT_MPV:
313                         newtvb = tvb_new_subset( tvb, offset, data_len,
314                             data_reported_len );
315                         call_dissector(mpeg1_handle, newtvb, pinfo, tree);
316                         break;    
317
318                 default:
319                         proto_tree_add_item( rtp_tree, hf_rtp_data, tvb, offset, data_len, FALSE );
320                         break;
321         }
322 }
323
324 void
325 dissect_rtp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
326 {
327         proto_item *ti            = NULL;
328         proto_tree *rtp_tree      = NULL;
329         proto_tree *rtp_csrc_tree = NULL;
330         guint8      octet;
331         unsigned int version;
332         gboolean    padding_set;
333         gboolean    extension_set;
334         unsigned int csrc_count;
335         gboolean    marker_set;
336         unsigned int payload_type;
337         unsigned int i            = 0;
338         unsigned int hdr_extension= 0;
339         unsigned int padding_count;
340         int         data_len;
341         unsigned int offset = 0;
342         guint16     seq_num;
343         guint32     timestamp;
344         guint32     sync_src;
345         guint32     csrc_item;
346
347         CHECK_DISPLAY_AS_DATA(proto_rtp, tvb, pinfo, tree);
348
349         pinfo->current_proto = "RTP";
350
351         /* Get the fields in the first octet */
352         octet = tvb_get_guint8( tvb, offset );
353         version = RTP_VERSION( octet );
354
355         if (version != 2) {
356                 /*
357                  * Unknown or unsupported version.
358                  */
359                 if ( check_col( pinfo->fd, COL_PROTOCOL ) )   {
360                         col_set_str( pinfo->fd, COL_PROTOCOL, "RTP" );
361                 }
362         
363                 if ( check_col( pinfo->fd, COL_INFO) ) {
364                         col_add_fstr( pinfo->fd, COL_INFO,
365                             "Unknown RTP version %u", version);
366                 }
367
368                 if ( tree ) {
369                         ti = proto_tree_add_item( tree, proto_rtp, tvb, offset, tvb_length_remaining( tvb, offset ), FALSE );
370                         rtp_tree = proto_item_add_subtree( ti, ett_rtp );
371                 
372                         proto_tree_add_uint( rtp_tree, hf_rtp_version, tvb,
373                             offset, 1, version );
374                 }
375                 return;
376         }
377
378         padding_set = RTP_PADDING( octet );
379         extension_set = RTP_EXTENSION( octet );
380         csrc_count = RTP_CSRC_COUNT( octet );
381
382         /* Get the fields in the second octet */
383         octet = tvb_get_guint8( tvb, offset + 1 );
384         marker_set = RTP_MARKER( octet );
385         payload_type = RTP_PAYLOAD_TYPE( octet );
386
387         /* Get the subsequent fields */
388         seq_num = tvb_get_ntohs( tvb, offset + 2 );
389         timestamp = tvb_get_ntohl( tvb, offset + 4 );
390         sync_src = tvb_get_ntohl( tvb, offset + 8 );
391
392         if ( check_col( pinfo->fd, COL_PROTOCOL ) )   {
393                 col_set_str( pinfo->fd, COL_PROTOCOL, "RTP" );
394         }
395         
396         if ( check_col( pinfo->fd, COL_INFO) ) {
397                 col_add_fstr( pinfo->fd, COL_INFO,
398                     "Payload type=%s, SSRC=%u, Seq=%u, Time=%u%s",
399                     val_to_str( payload_type, rtp_payload_type_vals,
400                         "Unknown (%u)" ),
401                     sync_src,
402                     seq_num,
403                     timestamp,
404                     marker_set ? ", Mark" : "");
405         }
406
407         if ( tree ) {
408                 ti = proto_tree_add_item( tree, proto_rtp, tvb, offset, tvb_length_remaining( tvb, offset ), FALSE );
409                 rtp_tree = proto_item_add_subtree( ti, ett_rtp );
410                 
411                 proto_tree_add_uint( rtp_tree, hf_rtp_version, tvb,
412                     offset, 1, version );
413                 proto_tree_add_boolean( rtp_tree, hf_rtp_padding, tvb,
414                     offset, 1, padding_set );
415                 proto_tree_add_boolean( rtp_tree, hf_rtp_extension, tvb,
416                     offset, 1, extension_set );
417                 proto_tree_add_uint( rtp_tree, hf_rtp_csrc_count, tvb,
418                     offset, 1, csrc_count );
419                 offset++;
420
421                 proto_tree_add_boolean( rtp_tree, hf_rtp_marker, tvb, offset,
422                     1, marker_set );
423                 proto_tree_add_uint( rtp_tree, hf_rtp_payload_type, tvb,
424                     offset, 1, payload_type );
425                 offset++;
426
427                 /* Sequence number 16 bits (2 octets) */
428                 proto_tree_add_uint( rtp_tree, hf_rtp_seq_nr, tvb, offset, 2, seq_num );
429                 offset += 2;
430
431                 /* Timestamp 32 bits (4 octets) */
432                 proto_tree_add_uint( rtp_tree, hf_rtp_timestamp, tvb, offset, 4, timestamp );
433                 offset += 4;
434
435                 /* Synchronization source identifier 32 bits (4 octets) */
436                 proto_tree_add_uint( rtp_tree, hf_rtp_ssrc, tvb, offset, 4, sync_src );
437                 offset += 4;
438
439                 /* CSRC list*/
440                 if ( csrc_count > 0 ) {
441                         ti = proto_tree_add_text(rtp_tree, tvb, offset, csrc_count * 4, "Contributing Source identifiers");
442                         rtp_csrc_tree = proto_item_add_subtree( ti, ett_csrc_list );
443                         for (i = 0; i < csrc_count; i++ ) {
444                                 csrc_item = tvb_get_ntohl( tvb, offset );
445                                 proto_tree_add_uint_format( rtp_csrc_tree,
446                                     hf_rtp_csrc_item, tvb, offset, 4,
447                                     csrc_item,
448                                     "CSRC item %d: %u",
449                                     i, csrc_item );
450                                 offset += 4;
451                         }
452                 }
453
454                 /* Optional RTP header extension */
455                 if ( extension_set ) {
456                         /* Defined by profile field is 16 bits (2 octets) */
457                         proto_tree_add_uint( rtp_tree, hf_rtp_prof_define, tvb, offset, 2, tvb_get_ntohs( tvb, offset ) );
458                         offset += 2;
459
460                         hdr_extension = tvb_get_ntohs( tvb, offset );
461                         proto_tree_add_uint( rtp_tree, hf_rtp_length, tvb,
462                             offset, 2, hdr_extension);
463                         offset += 2;
464                         if ( hdr_extension > 0 ) {
465                                 ti = proto_tree_add_text(rtp_tree, tvb, offset, csrc_count * 4, "Header extensions");
466                                 /* I'm re-using the old tree variable here
467                                    from the CSRC list!*/
468                                 rtp_csrc_tree = proto_item_add_subtree( ti,
469                                     ett_hdr_ext );
470                                 for (i = 0; i < hdr_extension; i++ ) {
471                                         proto_tree_add_uint( rtp_csrc_tree, hf_rtp_hdr_ext, tvb, offset, 4, tvb_get_ntohl( tvb, offset ) );
472                                         offset += 4;
473                                 }
474                         }
475                 }
476
477                 if ( padding_set ) {
478                         /*
479                          * This RTP frame has padding - find it.
480                          *
481                          * The padding count is found in the LAST octet of
482                          * the packet; it contains the number of octets
483                          * that can be ignored at the end of the packet.
484                          */
485                         if (tvb_length(tvb) < tvb_reported_length(tvb)) {
486                                 /*
487                                  * We don't *have* the last octet of the
488                                  * packet, so we can't get the padding
489                                  * count.
490                                  *
491                                  * Put an indication of that into the
492                                  * tree, and just put in a raw data
493                                  * item.
494                                  */
495                                 proto_tree_add_text(rtp_tree, tvb, 0, 0,
496                                     "Frame has padding, but not all the frame data was captured");
497                                 dissect_data(tvb, offset, pinfo, rtp_tree);
498                                 return;
499                         }
500
501                         padding_count = tvb_get_guint8( tvb,
502                             tvb_reported_length( tvb ) - 1 );
503                         data_len =
504                             tvb_reported_length_remaining( tvb, offset ) - padding_count;
505                         if (data_len > 0) {
506                                 /*
507                                  * There's data left over when you take out
508                                  * the padding; dissect it.
509                                  */
510                                 dissect_rtp_data( tvb, pinfo, tree, rtp_tree,
511                                     offset,
512                                     data_len,
513                                     data_len,
514                                     payload_type );
515                                 offset += data_len;
516                         } else if (data_len < 0) {
517                                 /*
518                                  * The padding count is bigger than the
519                                  * amount of RTP payload in the packet!
520                                  * Clip the padding count.
521                                  *
522                                  * XXX - put an item in the tree to indicate
523                                  * that the padding count is bogus?
524                                  */
525                                 padding_count =
526                                     tvb_reported_length_remaining(tvb, offset);
527                         }
528                         if (padding_count > 1) {
529                                 /*
530                                  * There's more than one byte of padding;
531                                  * show all but the last byte as padding
532                                  * data.
533                                  */
534                                 proto_tree_add_item( rtp_tree, hf_rtp_padding_data,
535                                     tvb, offset, padding_count - 1, FALSE );
536                                 offset += padding_count - 1;
537                         }
538                         /*
539                          * Show the last byte in the PDU as the padding
540                          * count.
541                          */
542                         proto_tree_add_item( rtp_tree, hf_rtp_padding_count,
543                             tvb, offset, 1, FALSE );
544                 }
545                 else {
546                         /*
547                          * No padding.
548                          */
549                         dissect_rtp_data( tvb, pinfo, tree, rtp_tree, offset,
550                             tvb_length_remaining( tvb, offset ),
551                             tvb_reported_length_remaining( tvb, offset ),
552                             payload_type );
553                 }
554         }
555 }
556
557 void
558 proto_register_rtp(void)
559 {
560         static hf_register_info hf[] = 
561         {
562                 { 
563                         &hf_rtp_version,
564                         { 
565                                 "Version", 
566                                 "rtp.version", 
567                                 FT_UINT8, 
568                                 BASE_DEC, 
569                                 VALS(rtp_version_vals), 
570                                 0x0,
571                                 "", HFILL 
572                         }
573                 },
574                 { 
575                         &hf_rtp_padding,
576                         { 
577                                 "Padding", 
578                                 "rtp.padding", 
579                                 FT_BOOLEAN, 
580                                 BASE_NONE, 
581                                 NULL, 
582                                 0x0,
583                                 "", HFILL 
584                         }
585                 },
586                 { 
587                         &hf_rtp_extension,
588                         { 
589                                 "Extension", 
590                                 "rtp.ext", 
591                                 FT_BOOLEAN, 
592                                 BASE_NONE, 
593                                 NULL, 
594                                 0x0,
595                                 "", HFILL 
596                         }
597                 },
598                 { 
599                         &hf_rtp_csrc_count,
600                         { 
601                                 "Contributing source identifiers count", 
602                                 "rtp.cc", 
603                                 FT_UINT8, 
604                                 BASE_DEC, 
605                                 NULL, 
606                                 0x0,
607                                 "", HFILL 
608                         }
609                 },
610                 { 
611                         &hf_rtp_marker,
612                         { 
613                                 "Marker", 
614                                 "rtp.marker", 
615                                 FT_BOOLEAN, 
616                                 BASE_NONE, 
617                                 NULL, 
618                                 0x0,
619                                 "", HFILL 
620                         }
621                 },
622                 { 
623                         &hf_rtp_payload_type,
624                         { 
625                                 "Payload type", 
626                                 "rtp.p_type", 
627                                 FT_UINT8, 
628                                 BASE_DEC, 
629                                 VALS(rtp_payload_type_vals), 
630                                 0x0,
631                                 "", HFILL 
632                         }
633                 },
634                 { 
635                         &hf_rtp_seq_nr,
636                         { 
637                                 "Sequence number", 
638                                 "rtp.seq", 
639                                 FT_UINT16, 
640                                 BASE_DEC, 
641                                 NULL, 
642                                 0x0,
643                                 "", HFILL 
644                         }
645                 },
646                 { 
647                         &hf_rtp_timestamp,
648                         { 
649                                 "Timestamp", 
650                                 "rtp.timestamp", 
651                                 FT_UINT32, 
652                                 BASE_DEC, 
653                                 NULL, 
654                                 0x0,
655                                 "", HFILL 
656                         }
657                 },
658                 { 
659                         &hf_rtp_ssrc,
660                         { 
661                                 "Synchronization Source identifier", 
662                                 "rtp.ssrc", 
663                                 FT_UINT32, 
664                                 BASE_DEC, 
665                                 NULL, 
666                                 0x0,
667                                 "", HFILL 
668                         }
669                 },
670                 { 
671                         &hf_rtp_prof_define,
672                         { 
673                                 "Defined by profile", 
674                                 "rtp.ext.profile", 
675                                 FT_UINT16, 
676                                 BASE_DEC, 
677                                 NULL, 
678                                 0x0,
679                                 "", HFILL 
680                         }
681                 },
682                 { 
683                         &hf_rtp_length,
684                         { 
685                                 "Extension length", 
686                                 "rtp.ext.len", 
687                                 FT_UINT16, 
688                                 BASE_DEC, 
689                                 NULL, 
690                                 0x0,
691                                 "", HFILL 
692                         }
693                 },
694                 { 
695                         &hf_rtp_csrc_item,
696                         { 
697                                 "CSRC item", 
698                                 "rtp.csrc.item", 
699                                 FT_UINT32, 
700                                 BASE_DEC, 
701                                 NULL, 
702                                 0x0,
703                                 "", HFILL 
704                         }
705                 },
706                 { 
707                         &hf_rtp_hdr_ext,
708                         { 
709                                 "Header extension", 
710                                 "rtp.hdr_ext", 
711                                 FT_UINT32, 
712                                 BASE_DEC, 
713                                 NULL, 
714                                 0x0,
715                                 "", HFILL 
716                         }
717                 },
718                 { 
719                         &hf_rtp_data,
720                         { 
721                                 "Payload", 
722                                 "rtp.payload", 
723                                 FT_BYTES, 
724                                 BASE_HEX, 
725                                 NULL, 
726                                 0x0,
727                                 "", HFILL 
728                         }
729                 },
730                 { 
731                         &hf_rtp_padding_data,
732                         { 
733                                 "Padding data", 
734                                 "rtp.padding.data", 
735                                 FT_BYTES, 
736                                 BASE_HEX, 
737                                 NULL, 
738                                 0x0,
739                                 "", HFILL 
740                         }
741                 },
742                 { 
743                         &hf_rtp_padding_count,
744                         { 
745                                 "Padding count", 
746                                 "rtp.padding.count", 
747                                 FT_UINT8, 
748                                 BASE_DEC, 
749                                 NULL, 
750                                 0x0,
751                                 "", HFILL 
752                         }
753                 },
754 };
755         
756         static gint *ett[] = 
757         {
758                 &ett_rtp,
759                 &ett_csrc_list,
760                 &ett_hdr_ext,
761         };
762
763
764         proto_rtp = proto_register_protocol("Real-Time Transport Protocol",
765             "RTP", "rtp");
766         proto_register_field_array(proto_rtp, hf, array_length(hf));
767         proto_register_subtree_array(ett, array_length(ett));
768
769         register_dissector("rtp", dissect_rtp, proto_rtp);
770
771 #if 0
772         register_init_routine( &rtp_init );
773 #endif
774 }
775
776 void
777 proto_reg_handoff_rtp(void)
778 {
779         /*
780          * Get handles for the H.261 and MPEG-1 dissectors.
781          */
782         h261_handle = find_dissector("h261");
783         mpeg1_handle = find_dissector("mpeg1");
784
785         /*
786          * Register this dissector as one that can be assigned to a
787          * UDP conversation.
788          */
789         conv_dissector_add("udp", dissect_rtp, proto_rtp);
790 }