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.18 2001/01/03 06:55:32 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)
64 CHECK_DISPLAY_AS_DATA(proto_sdp, tvb, pinfo, tree);
66 pinfo->current_proto = "SDP";
69 * As RFC 2327 says, "SDP is purely a format for session
70 * description - it does not incorporate a transport protocol,
71 * and is intended to use different transport protocols as
72 * appropriate including the Session Announcement Protocol,
73 * Session Initiation Protocol, Real-Time Streaming Protocol,
74 * electronic mail using the MIME extensions, and the
75 * Hypertext Transport Protocol."
77 * We therefore don't set the protocol or info columns;
78 * instead, we append to them, so that we don't erase
79 * what the protocol inside which the SDP stuff resides
82 if (check_col(pinfo->fd, COL_PROTOCOL))
83 col_append_str(pinfo->fd, COL_PROTOCOL, "/SDP");
85 if (check_col(pinfo->fd, COL_INFO)) {
86 /* XXX: Needs description. */
87 col_append_str(pinfo->fd, COL_INFO, ", with session description");
93 ti = proto_tree_add_item(tree, proto_sdp, tvb, offset,
94 tvb_length_remaining(tvb, offset), FALSE);
95 sdp_tree = proto_item_add_subtree(ti, ett_sdp);
98 * Show the SDP message a line at a time.
101 while (tvb_offset_exists(tvb, offset)) {
103 * Find the end of the line.
105 linelen = tvb_find_line_end_unquoted(tvb, offset, -1,
109 * Line must contain at least e.g. "v=".
114 line = tvb_get_ptr(tvb, offset, next_offset - offset);
116 if (line[1] != '=') {
117 proto_tree_add_text(sdp_tree, tvb, offset,
118 next_offset - offset,
120 tvb_format_text(tvb, offset, next_offset - offset));
121 offset = next_offset;
125 valuelen = linelen - 2;
133 typename = "Session Description, version";
136 typename = "Owner/Creator, Session Id";
139 typename = "Session Name";
143 typename = "Session Information";
144 else if (section == 'm')
145 typename = "Media Title";
147 typename = "Misplaced";
150 typename = "URI of Description";
153 typename = "E-mail Address";
156 typename = "Phone Number";
159 typename = "Connection Information";
162 typename = "Bandwidth Information";
166 typename = "Time Description, active time";
169 typename = "Repeat Time";
173 typename = "Media Description, name and address";
176 typename = "Encryption Key";
180 typename = "Session Attribute";
181 else if (section == 'm')
182 typename = "Media Attribute";
184 typename = "Misplaced";
187 typename = "Time Zone Adjustment";
190 typename = "Unknown";
194 proto_tree_add_text(sdp_tree, tvb, offset,
195 next_offset - offset,
196 "%s (%c): %s", typename, type,
197 format_text(value, valuelen));
198 offset = next_offset;
201 datalen = tvb_length_remaining(tvb, offset);
203 proto_tree_add_text(sdp_tree, tvb, offset, datalen,
204 "Data (%d bytes)", datalen);
209 proto_register_sdp(void)
211 /* static hf_register_info hf[] = {
213 { "Name", "sdp.abbreviation", TYPE, VALS_POINTER }},
215 static gint *ett[] = {
219 proto_sdp = proto_register_protocol("Session Description Protocol",
221 /* proto_register_field_array(proto_sdp, hf, array_length(hf));*/
222 proto_register_subtree_array(ett, array_length(ett));
225 * Register the dissector by name, so other dissectors can
226 * grab it by name rather than just referring to it directly
227 * (you can't refer to it directly from a plugin dissector
228 * on Windows without stuffing it into the Big Transfer Vector).
230 register_dissector("sdp", dissect_sdp);