1998-09-16 02:39:15 +00:00
|
|
|
/* packet-data.c
|
|
|
|
* Routines for raw data (default case)
|
2001-11-13 23:55:44 +00:00
|
|
|
* Gilbert Ramirez <gram@alumni.rice.edu>
|
1998-09-16 02:39:15 +00:00
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
1998-09-16 03:22:19 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
1998-09-16 02:39:15 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
#include <glib.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2002-05-10 23:20:38 +00:00
|
|
|
#include "packet-data.h"
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-07-29 05:47:07 +00:00
|
|
|
/* proto_data cannot be static because it's referenced in the
|
|
|
|
* print routines
|
|
|
|
*/
|
1999-07-07 22:52:57 +00:00
|
|
|
int proto_data = -1;
|
2007-09-28 19:16:05 +00:00
|
|
|
int hf_data_data = -1;
|
|
|
|
int ett_data = -1;
|
1999-07-07 22:52:57 +00:00
|
|
|
|
2002-04-04 05:16:15 +00:00
|
|
|
static void
|
2003-04-22 13:47:38 +00:00
|
|
|
dissect_data(tvbuff_t *tvb, packet_info *pinfo _U_ , proto_tree *tree)
|
2000-05-11 22:04:18 +00:00
|
|
|
{
|
|
|
|
int bytes;
|
|
|
|
|
|
|
|
if (tree) {
|
2001-11-26 05:41:15 +00:00
|
|
|
bytes = tvb_length_remaining(tvb, 0);
|
2000-05-12 06:23:33 +00:00
|
|
|
if (bytes > 0) {
|
2007-09-28 19:16:05 +00:00
|
|
|
proto_item *ti = proto_tree_add_protocol_format(tree, proto_data, tvb,
|
2001-11-26 05:41:15 +00:00
|
|
|
0,
|
2000-05-12 06:23:33 +00:00
|
|
|
bytes, "Data (%d byte%s)", bytes,
|
|
|
|
plurality(bytes, "", "s"));
|
2007-09-28 19:16:05 +00:00
|
|
|
proto_tree *data_tree = proto_item_add_subtree(ti, ett_data);
|
|
|
|
|
|
|
|
proto_tree_add_item(data_tree, hf_data_data, tvb, 0, bytes, FALSE);
|
2000-05-12 06:23:33 +00:00
|
|
|
}
|
2000-05-11 22:04:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
void
|
|
|
|
proto_register_data(void)
|
|
|
|
{
|
2007-09-28 19:16:05 +00:00
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{&hf_data_data,
|
|
|
|
{"Data", "data.data", FT_BYTES, BASE_HEX, NULL, 0x0,
|
|
|
|
NULL, HFILL}}
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_data
|
|
|
|
};
|
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_data = proto_register_protocol (
|
2001-01-03 06:56:03 +00:00
|
|
|
"Data", /* name */
|
|
|
|
"Data", /* short name */
|
|
|
|
"data" /* abbrev */
|
|
|
|
);
|
|
|
|
|
2002-04-04 05:16:15 +00:00
|
|
|
register_dissector("data", dissect_data, proto_data);
|
2001-11-25 21:44:57 +00:00
|
|
|
|
2007-09-28 19:16:05 +00:00
|
|
|
proto_register_field_array(proto_data, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
|
2001-01-03 06:56:03 +00:00
|
|
|
/*
|
|
|
|
* "Data" is used to dissect something whose normal dissector
|
|
|
|
* is disabled, so it cannot itself be disabled.
|
|
|
|
*/
|
2004-01-03 18:40:08 +00:00
|
|
|
proto_set_cant_toggle(proto_data);
|
1999-07-07 22:52:57 +00:00
|
|
|
}
|