2 * Routines for displaying an undissected media type (default case),
3 * based on the generic "data" dissector.
5 * (C) Olivier Biot, 2004
9 * Refer to the AUTHORS file or the AUTHORS section in the man page
10 * for contacting the author(s) of this file.
12 * Wireshark - Network traffic analyzer
13 * By Gerald Combs <gerald@wireshark.org>
14 * Copyright 1998 Gerald Combs
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
34 #include <epan/packet.h>
36 /* proto_media cannot be static because it's referenced in the
40 static gint ett_media
= -1;
41 static heur_dissector_list_t heur_subdissector_list
;
44 dissect_media(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data
)
48 proto_tree
*media_tree
= 0;
50 if (dissector_try_heuristic(heur_subdissector_list
, tvb
, pinfo
, tree
, data
)) {
51 return tvb_length(tvb
);
54 /* Add media type to the INFO column if it is visible */
55 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " (%s)", (pinfo
->match_string
) ? pinfo
->match_string
: "");
58 if ( (bytes
= tvb_length(tvb
)) > 0 )
60 ti
= proto_tree_add_item(tree
, proto_media
, tvb
, 0, -1, ENC_NA
);
61 media_tree
= proto_item_add_subtree(ti
, ett_media
);
63 if (pinfo
->private_data
) {
64 /* The media type has parameters */
65 proto_tree_add_text(media_tree
, tvb
, 0, bytes
,
66 "Media Type: %s; %s (%d byte%s)",
67 pinfo
->match_string
, (char *)pinfo
->private_data
,
68 bytes
, plurality(bytes
, "", "s"));
70 /* The media type has no parameters */
71 proto_tree_add_text(media_tree
, tvb
, 0, bytes
,
72 "Media Type: %s (%d byte%s)",
73 pinfo
->match_string
? pinfo
->match_string
: "",
74 bytes
, plurality(bytes
, "", "s"));
79 return tvb_length(tvb
);
83 proto_register_media(void)
85 static gint
*ett
[] = {
89 proto_media
= proto_register_protocol (
90 "Media Type", /* name */
91 "Media", /* short name */
94 new_register_dissector("media", dissect_media
, proto_media
);
95 register_heur_dissector_list("media", &heur_subdissector_list
);
96 proto_register_subtree_array(ett
, array_length(ett
));
99 * "Media" is used to dissect something whose normal dissector
100 * is disabled, so it cannot itself be disabled.
102 proto_set_cant_toggle(proto_media
);