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.21 2001/12/10 00:25:34 guy Exp $
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@ethereal.com>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #ifdef HAVE_SYS_TYPES_H
31 #include <sys/types.h>
41 static int proto_sdp = -1;
43 static int ett_sdp = -1;
46 dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
62 * As RFC 2327 says, "SDP is purely a format for session
63 * description - it does not incorporate a transport protocol,
64 * and is intended to use different transport protocols as
65 * appropriate including the Session Announcement Protocol,
66 * Session Initiation Protocol, Real-Time Streaming Protocol,
67 * electronic mail using the MIME extensions, and the
68 * Hypertext Transport Protocol."
70 * We therefore don't set the protocol or info columns;
71 * instead, we append to them, so that we don't erase
72 * what the protocol inside which the SDP stuff resides
75 if (check_col(pinfo->cinfo, COL_PROTOCOL))
76 col_append_str(pinfo->cinfo, COL_PROTOCOL, "/SDP");
78 if (check_col(pinfo->cinfo, COL_INFO)) {
79 /* XXX: Needs description. */
80 col_append_str(pinfo->cinfo, COL_INFO, ", with session description");
86 ti = proto_tree_add_item(tree, proto_sdp, tvb, offset,
87 tvb_length_remaining(tvb, offset), FALSE);
88 sdp_tree = proto_item_add_subtree(ti, ett_sdp);
91 * Show the SDP message a line at a time.
94 while (tvb_offset_exists(tvb, offset)) {
96 * Find the end of the line.
98 linelen = tvb_find_line_end_unquoted(tvb, offset, -1,
102 * Line must contain at least e.g. "v=".
107 line = tvb_get_ptr(tvb, offset, next_offset - offset);
109 if (line[1] != '=') {
110 proto_tree_add_text(sdp_tree, tvb, offset,
111 next_offset - offset,
113 tvb_format_text(tvb, offset, next_offset - offset));
114 offset = next_offset;
118 valuelen = linelen - 2;
126 typename = "Session Description, version";
129 typename = "Owner/Creator, Session Id";
132 typename = "Session Name";
136 typename = "Session Information";
137 else if (section == 'm')
138 typename = "Media Title";
140 typename = "Misplaced";
143 typename = "URI of Description";
146 typename = "E-mail Address";
149 typename = "Phone Number";
152 typename = "Connection Information";
155 typename = "Bandwidth Information";
159 typename = "Time Description, active time";
162 typename = "Repeat Time";
166 typename = "Media Description, name and address";
169 typename = "Encryption Key";
173 typename = "Session Attribute";
174 else if (section == 'm')
175 typename = "Media Attribute";
177 typename = "Misplaced";
180 typename = "Time Zone Adjustment";
183 typename = "Unknown";
187 proto_tree_add_text(sdp_tree, tvb, offset,
188 next_offset - offset,
189 "%s (%c): %s", typename, type,
190 format_text(value, valuelen));
191 offset = next_offset;
194 datalen = tvb_length_remaining(tvb, offset);
196 proto_tree_add_text(sdp_tree, tvb, offset, datalen,
197 "Data (%d bytes)", datalen);
202 proto_register_sdp(void)
204 /* static hf_register_info hf[] = {
206 { "Name", "sdp.abbreviation", TYPE, VALS_POINTER }},
208 static gint *ett[] = {
212 proto_sdp = proto_register_protocol("Session Description Protocol",
214 /* proto_register_field_array(proto_sdp, hf, array_length(hf));*/
215 proto_register_subtree_array(ett, array_length(ett));
218 * Register the dissector by name, so other dissectors can
219 * grab it by name rather than just referring to it directly
220 * (you can't refer to it directly from a plugin dissector
221 * on Windows without stuffing it into the Big Transfer Vector).
223 register_dissector("sdp", dissect_sdp, proto_sdp);