1 /* packet-text-media.c
\r
2 * Routines for text-based media dissection.
\r
4 * NOTE - The media type is either found in pinfo->match_string
\r
5 * or in pinfo->provate_data.
\r
7 * (C) Olivier Biot, 2004 <Olivier.Biot (ad) siemens.com>
\r
9 * $Id: packet-text-media.c,v 1.2 2004/01/10 02:54:50 obiot Exp $
\r
11 * Ethereal - Network traffic analyzer
\r
12 * By Gerald Combs <gerald@ethereal.com>
\r
13 * Copyright 1998 Gerald Combs
\r
15 * This program is free software; you can redistribute it and/or
\r
16 * modify it under the terms of the GNU General Public License
\r
17 * as published by the Free Software Foundation; either version 2
\r
18 * of the License, or (at your option) any later version.
\r
20 * This program is distributed in the hope that it will be useful,
\r
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
23 * GNU General Public License for more details.
\r
25 * You should have received a copy of the GNU General Public License
\r
26 * along with this program; if not, write to the Free Software
\r
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
\r
30 /* Edit this file with 4-space tabs */
\r
32 #ifdef HAVE_CONFIG_H
\r
40 #include <epan/packet.h>
\r
41 #include <epan/strutil.h>
\r
45 * Media dissector for line-based text media like text/plain, message/http.
\r
47 * TODO - character set and chunked transfer-coding
\r
50 /* Filterable header fields */
\r
51 static gint proto_text_lines = -1;
\r
54 static gint ett_text_lines = -1;
\r
56 /* Dissector handles */
\r
57 static dissector_handle_t text_lines_handle;
\r
60 dissect_text_lines(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
\r
62 proto_tree *subtree;
\r
64 gint offset = 0, next_offset;
\r
66 const char *data_name;
\r
68 data_name = pinfo->match_string;
\r
69 if (! (data_name && data_name[0])) {
\r
71 * No information from "match_string"
\r
73 data_name = (char *)(pinfo->private_data);
\r
74 if (! (data_name && data_name[0])) {
\r
76 * No information from "private_data"
\r
82 if (data_name && check_col(pinfo->cinfo, COL_INFO))
\r
83 col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", data_name);
\r
86 ti = proto_tree_add_item(tree, proto_text_lines,
\r
89 proto_item_append_text(ti, ": %s", data_name);
\r
90 subtree = proto_item_add_subtree(ti, ett_text_lines);
\r
91 /* Read the media line by line */
\r
92 while (tvb_reported_length_remaining(tvb, offset) != 0) {
\r
93 len = tvb_find_line_end(tvb, offset,
\r
94 tvb_ensure_length_remaining(tvb, offset),
\r
95 &next_offset, FALSE);
\r
98 proto_tree_add_text(subtree, tvb, offset, next_offset - offset,
\r
99 "%s", tvb_format_text(tvb, offset, len));
\r
100 offset = next_offset;
\r
106 proto_register_text_lines(void)
\r
108 static gint *ett[] = {
\r
112 proto_register_subtree_array(ett, array_length(ett));
\r
114 proto_text_lines = proto_register_protocol(
\r
115 "Line-based text data", /* Long name */
\r
116 "Line-based text data", /* Short name */
\r
117 "data-text-lines"); /* Filter name */
\r
118 register_dissector("data-text-lines", dissect_text_lines, proto_text_lines);
\r
122 proto_reg_handoff_text_lines(void)
\r
124 text_lines_handle = create_dissector_handle(
\r
125 dissect_text_lines, proto_text_lines);
\r
127 dissector_add_string("media_type", "text/plain", text_lines_handle);
\r
128 /* W3C line-based textual media */
\r
129 dissector_add_string("media_type", "text/html", text_lines_handle);
\r
130 dissector_add_string("media_type", "text/css", text_lines_handle);
\r
131 dissector_add_string("media_type", "application/xml", text_lines_handle);
\r
132 dissector_add_string("media_type", "application/x-javascript", text_lines_handle);
\r
133 dissector_add_string("media_type", "application/x-www-form-urlencoded", text_lines_handle);
\r
134 dissector_add_string("media_type", "application/x-ns-proxy-autoconfig", text_lines_handle);
\r
135 /* WAP line-based textual media */
\r
136 dissector_add_string("media_type", "text/vnd.wap.wml", text_lines_handle);
\r
137 dissector_add_string("media_type", "text/vnd.wap.si", text_lines_handle);
\r
138 dissector_add_string("media_type", "text/vnd.wap.sl", text_lines_handle);
\r
139 dissector_add_string("media_type", "text/vnd.wap.co", text_lines_handle);
\r
140 dissector_add_string("media_type", "text/vnd.wap.emn", text_lines_handle);
\r
142 dissector_add_string("media_type", "text/vnd.sun.j2me.app-descriptor", text_lines_handle);
\r