2 * Routines for SDP packet disassembly (RFC 2327)
4 * Jason Lango <jal@netapp.com>
5 * Liberally copied from packet-http.c, by Guy Harris <guy@alum.mit.edu>
7 * $Id: packet-sdp.c,v 1.20 2001/01/25 06:14:14 guy Exp $
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@zing.org>
11 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #ifdef HAVE_SYS_TYPES_H
34 #include <sys/types.h>
44 static int proto_sdp = -1;
46 static int ett_sdp = -1;
49 dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
65 * As RFC 2327 says, "SDP is purely a format for session
66 * description - it does not incorporate a transport protocol,
67 * and is intended to use different transport protocols as
68 * appropriate including the Session Announcement Protocol,
69 * Session Initiation Protocol, Real-Time Streaming Protocol,
70 * electronic mail using the MIME extensions, and the
71 * Hypertext Transport Protocol."
73 * We therefore don't set the protocol or info columns;
74 * instead, we append to them, so that we don't erase
75 * what the protocol inside which the SDP stuff resides
78 if (check_col(pinfo->fd, COL_PROTOCOL))
79 col_append_str(pinfo->fd, COL_PROTOCOL, "/SDP");
81 if (check_col(pinfo->fd, COL_INFO)) {
82 /* XXX: Needs description. */
83 col_append_str(pinfo->fd, COL_INFO, ", with session description");
89 ti = proto_tree_add_item(tree, proto_sdp, tvb, offset,
90 tvb_length_remaining(tvb, offset), FALSE);
91 sdp_tree = proto_item_add_subtree(ti, ett_sdp);
94 * Show the SDP message a line at a time.
97 while (tvb_offset_exists(tvb, offset)) {
99 * Find the end of the line.
101 linelen = tvb_find_line_end_unquoted(tvb, offset, -1,
105 * Line must contain at least e.g. "v=".
110 line = tvb_get_ptr(tvb, offset, next_offset - offset);
112 if (line[1] != '=') {
113 proto_tree_add_text(sdp_tree, tvb, offset,
114 next_offset - offset,
116 tvb_format_text(tvb, offset, next_offset - offset));
117 offset = next_offset;
121 valuelen = linelen - 2;
129 typename = "Session Description, version";
132 typename = "Owner/Creator, Session Id";
135 typename = "Session Name";
139 typename = "Session Information";
140 else if (section == 'm')
141 typename = "Media Title";
143 typename = "Misplaced";
146 typename = "URI of Description";
149 typename = "E-mail Address";
152 typename = "Phone Number";
155 typename = "Connection Information";
158 typename = "Bandwidth Information";
162 typename = "Time Description, active time";
165 typename = "Repeat Time";
169 typename = "Media Description, name and address";
172 typename = "Encryption Key";
176 typename = "Session Attribute";
177 else if (section == 'm')
178 typename = "Media Attribute";
180 typename = "Misplaced";
183 typename = "Time Zone Adjustment";
186 typename = "Unknown";
190 proto_tree_add_text(sdp_tree, tvb, offset,
191 next_offset - offset,
192 "%s (%c): %s", typename, type,
193 format_text(value, valuelen));
194 offset = next_offset;
197 datalen = tvb_length_remaining(tvb, offset);
199 proto_tree_add_text(sdp_tree, tvb, offset, datalen,
200 "Data (%d bytes)", datalen);
205 proto_register_sdp(void)
207 /* static hf_register_info hf[] = {
209 { "Name", "sdp.abbreviation", TYPE, VALS_POINTER }},
211 static gint *ett[] = {
215 proto_sdp = proto_register_protocol("Session Description Protocol",
217 /* proto_register_field_array(proto_sdp, hf, array_length(hf));*/
218 proto_register_subtree_array(ett, array_length(ett));
221 * Register the dissector by name, so other dissectors can
222 * grab it by name rather than just referring to it directly
223 * (you can't refer to it directly from a plugin dissector
224 * on Windows without stuffing it into the Big Transfer Vector).
226 register_dissector("sdp", dissect_sdp, proto_sdp);