3 * Routines for RFC 2833 RTP Events dissection
4 * Copyright 2003, Kevin A. Noll <knoll[AT]poss.com>
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 * This dissector tries to dissect RTP Events.
37 #include <epan/packet.h>
38 #include <epan/prefs.h>
42 #include "packet-rtp-events.h"
44 /* rtp_event_payload_type_value is the value used globally
45 to set the appropriate payload type
46 saved_pt_value is a temporary place to save the value
47 so we can properly reinitialize when the settings
50 static guint rtp_event_payload_type_value = 101;
51 static guint saved_payload_type_value;
54 /* RTP Event Fields */
56 static int proto_rtp_events = -1;
58 static int hf_rtp_events_event = -1; /* one byte */
59 static int hf_rtp_events_end = -1; /* one bit */
60 static int hf_rtp_events_reserved = -1; /* one bit */
61 static int hf_rtp_events_volume = -1; /* six bits */
62 static int hf_rtp_events_duration = -1; /* sixteen bits */
65 /* RTP Events fields defining a subtree */
67 static gint ett_rtp_events = -1;
70 proto_reg_handoff_rtp_events(void);
73 dissect_rtp_events( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
75 proto_item *ti = NULL;
76 proto_tree *rtp_events_tree = NULL;
77 unsigned int offset = 0;
82 if ( check_col( pinfo->cinfo, COL_PROTOCOL ) )
84 col_set_str( pinfo->cinfo, COL_PROTOCOL, "RTP EVENT" );
86 if (check_col(pinfo->cinfo, COL_INFO))
87 col_clear(pinfo->cinfo, COL_INFO);
90 /* Get event fields */
92 rtp_evt = tvb_get_guint8(tvb, offset );
94 if ( check_col( pinfo->cinfo, COL_INFO) )
96 col_add_fstr( pinfo->cinfo, COL_INFO,
97 "Payload type=RTP Event, %s",
98 val_to_str( rtp_evt, rtp_event_type_values, "Unknown (%u)" ));
105 ti = proto_tree_add_item( tree, proto_rtp_events, tvb, offset, -1, FALSE );
106 rtp_events_tree = proto_item_add_subtree( ti, ett_rtp_events );
108 proto_tree_add_uint ( rtp_events_tree, hf_rtp_events_event, tvb, offset, 1, rtp_evt);
110 octet = tvb_get_guint8(tvb, offset +1 );
111 proto_tree_add_boolean (rtp_events_tree, hf_rtp_events_end, tvb, offset+1, 1, octet);
112 proto_tree_add_boolean (rtp_events_tree, hf_rtp_events_reserved, tvb, offset+1, 1, octet);
113 proto_tree_add_uint ( rtp_events_tree, hf_rtp_events_volume, tvb, offset+1, 1, octet);
115 proto_tree_add_item ( rtp_events_tree, hf_rtp_events_duration, tvb, offset+2, 2, FALSE);
117 /* Make end-of-event packets obvious in the info column */
118 if ((octet & 0x80) && check_col(pinfo->cinfo, COL_INFO))
120 col_append_str(pinfo->cinfo, COL_INFO, " (end)");
128 proto_register_rtp_events(void)
131 module_t *rtp_events_module;
133 static hf_register_info hf[] =
136 &hf_rtp_events_event,
142 VALS(rtp_event_type_values),
151 "rtpevent.end_of_event",
160 &hf_rtp_events_reserved,
172 &hf_rtp_events_volume,
185 &hf_rtp_events_duration,
205 proto_rtp_events = proto_register_protocol("RFC 2833 RTP Event", "RTP Event", "rtpevent");
206 proto_register_field_array(proto_rtp_events, hf, array_length(hf));
207 proto_register_subtree_array(ett, array_length(ett));
210 /* Register preferences */
211 rtp_events_module = prefs_register_protocol (proto_rtp_events, proto_reg_handoff_rtp_events);
212 prefs_register_uint_preference (rtp_events_module,
213 "event_payload_type_value", "Payload Type for RFC2833 RTP Events",
214 "This is the value of the Payload Type field"
215 "that specifies RTP Events", 10,
216 &rtp_event_payload_type_value);
222 proto_reg_handoff_rtp_events(void)
224 static dissector_handle_t rtp_events_handle;
225 static int rtp_events_prefs_initialized = FALSE;
227 if (!rtp_events_prefs_initialized) {
228 rtp_events_handle = create_dissector_handle(dissect_rtp_events, proto_rtp_events);
229 rtp_events_prefs_initialized = TRUE;
232 dissector_delete("rtp.pt", saved_payload_type_value, rtp_events_handle);
235 saved_payload_type_value = rtp_event_payload_type_value;
236 /* rtp_event_payload_type_value is set from preferences */
238 dissector_add("rtp.pt", saved_payload_type_value, rtp_events_handle);