1999-07-07 22:52:57 +00:00
|
|
|
/* proto.h
|
|
|
|
* Definitions for protocol display
|
|
|
|
*
|
Convert IPX-and-friend dissectors in packet-ipx.c to use
tvbuffs.
In doing so, I realied that my recommendation for using
tvb_new_subset(pi.compat_top_tvb, -1, -1) was incorrect, because
some dissectors (ethernet!) change pi.len and pi.cap_len. So, I have
to take those two variables into account instead of using -1 and -1.
So, I provide a macro called tvb_create_from_top(offset), where
offset is the name of your offset variable. It is a wrapper around
tvb_new_subset().
I converted the lines that followed my suggestion to use
tvb_create_from_top().
In proto.c I added
proto_tree_add_debug_text(proto_tree*, const char*, ...)
It's much like proto_tree_add_text(), except that it takes no offset
or length; it's soley for temporarily putting debug text into the
proto_tree while debugging a dissector. In making sure that its
use is temporary, the funciton also prints the debug string to stdout
to remind the programmer that the debug code needs to be removed
before shipping the code.
svn path=/trunk/; revision=2068
2000-06-15 03:49:00 +00:00
|
|
|
* $Id: proto.h,v 1.35 2000/06/15 03:48:45 gram Exp $
|
1999-07-07 22:52:57 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@zing.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __PROTO_H__
|
|
|
|
#define __PROTO_H__
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
1999-09-12 14:34:36 +00:00
|
|
|
# ifndef _SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
# endif
|
1999-07-07 22:52:57 +00:00
|
|
|
#endif
|
|
|
|
|
1999-07-13 02:53:26 +00:00
|
|
|
#ifdef HAVE_WINSOCK_H
|
1999-09-12 14:34:36 +00:00
|
|
|
# include <winsock.h>
|
1999-07-13 02:53:26 +00:00
|
|
|
#endif
|
|
|
|
|
1999-11-15 06:32:38 +00:00
|
|
|
#ifndef __IPV4_H__
|
|
|
|
#include "ipv4.h"
|
|
|
|
#endif
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
#ifndef __TVBUFF_H__
|
|
|
|
#include "tvbuff.h"
|
|
|
|
#endif
|
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
/* needs glib.h */
|
2000-05-30 09:52:30 +00:00
|
|
|
typedef GNode proto_tree;
|
|
|
|
typedef GNode proto_item;
|
1999-07-07 22:52:57 +00:00
|
|
|
struct value_string;
|
|
|
|
|
|
|
|
#define ITEM_LABEL_LENGTH 240
|
|
|
|
|
|
|
|
/* In order to make a const value_string[] look like a value_string*, I
|
|
|
|
* need this macro */
|
|
|
|
#define VALS(x) (struct value_string*)(x)
|
|
|
|
|
1999-10-12 06:21:15 +00:00
|
|
|
/* ... and similarly, */
|
|
|
|
#define TFS(x) (struct true_false_string*)(x)
|
1999-07-07 22:52:57 +00:00
|
|
|
|
|
|
|
/* field types */
|
|
|
|
enum ftenum {
|
|
|
|
FT_NONE, /* used for protocol labels (thus no field type) */
|
|
|
|
FT_BOOLEAN, /* TRUE and FALSE come from <glib.h> */
|
|
|
|
FT_UINT8,
|
|
|
|
FT_UINT16,
|
1999-10-12 06:21:15 +00:00
|
|
|
FT_UINT24, /* really a UINT32, but displayed as 3 hex-digits if FD_HEX*/
|
1999-07-07 22:52:57 +00:00
|
|
|
FT_UINT32,
|
1999-10-12 06:21:15 +00:00
|
|
|
FT_INT8,
|
|
|
|
FT_INT16,
|
|
|
|
FT_INT24,
|
|
|
|
FT_INT32,
|
1999-09-12 06:11:51 +00:00
|
|
|
FT_DOUBLE,
|
1999-07-07 22:52:57 +00:00
|
|
|
FT_ABSOLUTE_TIME,
|
|
|
|
FT_RELATIVE_TIME,
|
|
|
|
FT_STRING,
|
|
|
|
FT_ETHER,
|
|
|
|
FT_BYTES,
|
|
|
|
FT_IPv4,
|
|
|
|
FT_IPv6,
|
Changed the display filter scanner from GLIB's GScanner to lex. The code
as it standed depends on your lex being flex, but that only matters if you're
a developer. The distribution will include the dfilter-scanner.c file, so
that if the user doesn't modify dfilter-scanner.l, he won't need flex to
re-create the *.c file.
The new lex scanner gives me better syntax checking for ether addresses. I
thought I could get by using GScanner, but it simply wasn't powerful enough.
All operands have English-like abbreviations and C-like syntax:
and, && ; or, || ; eq, == ; ne, != ; , etc.
I removed the ETHER_VENDOR type in favor of letting the user use the [x:y]
notation: ether.src[0:3] == 0:6:29 instead of ether.srcvendor == 00:06:29
I implemented the IPXNET field type; it had been there before, but was
not implemented. I chose to make it use integer values rather than byte
ranges, since an IPX Network is 4 bytes. So a display filter looks like this:
ipx.srcnet == 0xc0a82c00
rather than this:
ipx.srcnet == c0:a8:2c:00
I can supposrt the byte-range type IPXNET in the future, very trivially.
I still have more work to do on the parser though. It needs to check ranges
when extracting byte ranges ([x:y]) from packets. And I need to get rid
of those reduce/reduce errors from yacc!
svn path=/trunk/; revision=414
1999-08-01 04:28:20 +00:00
|
|
|
FT_IPXNET,
|
1999-07-07 22:52:57 +00:00
|
|
|
FT_TEXT_ONLY, /* non-filterable, used when converting ethereal
|
|
|
|
from old-style proto_tree to new-style proto_tree */
|
|
|
|
NUM_FIELD_TYPES /* last item number plus one */
|
|
|
|
};
|
|
|
|
|
1999-10-12 06:21:15 +00:00
|
|
|
enum {
|
|
|
|
BASE_NONE,
|
|
|
|
BASE_DEC,
|
|
|
|
BASE_HEX,
|
|
|
|
BASE_OCT,
|
|
|
|
BASE_BIN
|
|
|
|
};
|
|
|
|
|
2000-04-03 09:24:12 +00:00
|
|
|
|
1999-07-15 15:33:52 +00:00
|
|
|
/* information describing a header field */
|
1999-07-07 22:52:57 +00:00
|
|
|
typedef struct header_field_info {
|
|
|
|
char *name;
|
|
|
|
char *abbrev;
|
|
|
|
enum ftenum type;
|
2000-03-12 04:48:32 +00:00
|
|
|
int display; /* for integers only, so far. Base */
|
1999-10-12 06:21:15 +00:00
|
|
|
void *strings; /* val_string or true_false_string */
|
|
|
|
guint32 bitmask;
|
|
|
|
char *blurb; /* Brief description of field. */
|
|
|
|
|
|
|
|
int id; /* assigned by registration function, not programmer */
|
|
|
|
int parent; /* parent protocol */
|
|
|
|
int bitshift; /* bits to shift */
|
1999-07-07 22:52:57 +00:00
|
|
|
} header_field_info;
|
|
|
|
|
2000-04-03 09:24:12 +00:00
|
|
|
|
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
/* Used when registering many fields at once */
|
|
|
|
typedef struct hf_register_info {
|
|
|
|
int *p_id; /* pointer to int; written to by register() function */
|
1999-07-15 15:33:52 +00:00
|
|
|
header_field_info hfinfo;
|
1999-07-07 22:52:57 +00:00
|
|
|
} hf_register_info;
|
|
|
|
|
|
|
|
|
|
|
|
/* Info stored in each proto_item GNode */
|
|
|
|
typedef struct field_info {
|
|
|
|
struct header_field_info *hfinfo;
|
|
|
|
gint start;
|
|
|
|
gint length;
|
|
|
|
gint tree_type; /* ETT_* */
|
|
|
|
char *representation; /* for GUI tree */
|
|
|
|
int visible;
|
|
|
|
union {
|
|
|
|
guint32 numeric;
|
1999-09-12 06:11:51 +00:00
|
|
|
struct timeval time; /* the whole struct, not a pointer */
|
|
|
|
gdouble floating;
|
1999-07-07 22:52:57 +00:00
|
|
|
gchar *string;
|
1999-09-18 15:44:41 +00:00
|
|
|
guint8 *bytes;
|
1999-07-07 22:52:57 +00:00
|
|
|
guint8 ether[6];
|
1999-11-15 06:32:38 +00:00
|
|
|
ipv4_addr ipv4;
|
1999-10-11 17:05:49 +00:00
|
|
|
guint8 ipv6[16];
|
1999-07-07 22:52:57 +00:00
|
|
|
} value;
|
|
|
|
} field_info;
|
|
|
|
|
|
|
|
|
1999-08-29 04:06:43 +00:00
|
|
|
/* used when calling proto search functions */
|
1999-07-07 22:52:57 +00:00
|
|
|
typedef struct proto_tree_search_info {
|
1999-08-29 04:06:43 +00:00
|
|
|
int target;
|
|
|
|
int parent;
|
|
|
|
const guint8 *packet_data;
|
1999-10-11 14:58:04 +00:00
|
|
|
guint packet_len;
|
1999-08-29 04:06:43 +00:00
|
|
|
GNodeTraverseFunc traverse_func;
|
|
|
|
union {
|
|
|
|
GArray *array;
|
|
|
|
GNode *node;
|
|
|
|
} result;
|
1999-07-07 22:52:57 +00:00
|
|
|
} proto_tree_search_info;
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
|
|
|
|
/* For use while converting dissectors to use tvbuff's */
|
|
|
|
#define NullTVB NULL
|
|
|
|
|
1999-08-26 06:20:50 +00:00
|
|
|
/* Sets up memory used by proto routines. Called at program startup */
|
1999-07-07 22:52:57 +00:00
|
|
|
void proto_init(void);
|
1999-08-26 06:20:50 +00:00
|
|
|
|
|
|
|
/* Frees memory used by proto routines. Called at program shutdown */
|
|
|
|
void proto_cleanup(void);
|
|
|
|
|
2000-01-22 04:59:55 +00:00
|
|
|
/* Set text of proto_item after having already been created. */
|
2000-03-07 05:54:52 +00:00
|
|
|
#if __GNUC__ == 2
|
|
|
|
void proto_item_set_text(proto_item *ti, const char *format, ...)
|
|
|
|
__attribute__((format (printf, 2, 3)));
|
|
|
|
#else
|
|
|
|
void proto_item_set_text(proto_item *ti, const char *format, ...);
|
|
|
|
#endif
|
2000-01-22 04:59:55 +00:00
|
|
|
|
1999-10-12 06:21:15 +00:00
|
|
|
/* Set length of proto_item after having already been created. */
|
1999-07-07 22:52:57 +00:00
|
|
|
void proto_item_set_len(proto_item *ti, gint length);
|
1999-10-12 06:21:15 +00:00
|
|
|
|
|
|
|
/* Creates new proto_tree root */
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree* proto_tree_create_root(void);
|
1999-10-12 06:21:15 +00:00
|
|
|
|
|
|
|
/* Clear memory for entry proto_tree. Clears proto_tree struct also. */
|
1999-07-07 22:52:57 +00:00
|
|
|
void proto_tree_free(proto_tree *tree);
|
1999-10-12 06:21:15 +00:00
|
|
|
|
|
|
|
/* Create a subtree under an existing item; returns tree pointer */
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree* proto_item_add_subtree(proto_item *ti, gint idx);
|
|
|
|
|
|
|
|
int
|
|
|
|
proto_register_field(char *name, char *abbrev, enum ftenum type, int parent,
|
|
|
|
struct value_string* vals);
|
|
|
|
|
|
|
|
int
|
|
|
|
proto_register_protocol(char *name, char *abbrev);
|
|
|
|
|
|
|
|
void
|
1999-07-15 15:33:52 +00:00
|
|
|
proto_register_field_array(int parent, hf_register_info *hf, int num_records);
|
1999-07-07 22:52:57 +00:00
|
|
|
|
1999-11-16 11:44:20 +00:00
|
|
|
void
|
|
|
|
proto_register_subtree_array(gint **indices, int num_indices);
|
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
/* Add an item to a proto_tree, using the text label registered to that item;
|
|
|
|
the item is extracted from the tvbuff handed to it. */
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
|
|
|
|
gint start, gint length, gboolean little_endian);
|
|
|
|
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_item_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb,
|
|
|
|
gint start, gint length, gboolean little_endian);
|
|
|
|
|
|
|
|
/* Add a FT_NONE to a proto_tree */
|
2000-03-12 04:48:32 +00:00
|
|
|
#if __GNUC__ == 2
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-12 04:48:32 +00:00
|
|
|
gint length, const char *format, ...)
|
2000-05-11 08:18:09 +00:00
|
|
|
__attribute__((format (printf, 6, 7)));
|
2000-03-12 04:48:32 +00:00
|
|
|
#else
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-12 04:48:32 +00:00
|
|
|
gint length, const char *format, ...);
|
|
|
|
#endif
|
1999-07-07 22:52:57 +00:00
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
/* Add a FT_BYTES to a proto_tree */
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, const guint8* start_ptr);
|
|
|
|
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_bytes_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, const guint8* start_ptr);
|
2000-03-12 04:48:32 +00:00
|
|
|
|
|
|
|
#if __GNUC__ == 2
|
2000-01-22 04:59:55 +00:00
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-14 06:03:26 +00:00
|
|
|
gint length, const guint8* start_ptr, const char *format, ...)
|
2000-05-11 08:18:09 +00:00
|
|
|
__attribute__((format (printf, 7, 8)));
|
2000-03-12 04:48:32 +00:00
|
|
|
#else
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-14 06:03:26 +00:00
|
|
|
gint length, const guint8* start_ptr, const char *format, ...);
|
2000-03-12 04:48:32 +00:00
|
|
|
#endif
|
2000-01-22 04:59:55 +00:00
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
/* Add a FT_*TIME to a proto_tree */
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_time(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, struct timeval* value_ptr);
|
|
|
|
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_time_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, struct timeval* value_ptr);
|
|
|
|
|
2000-03-12 04:48:32 +00:00
|
|
|
#if __GNUC__ == 2
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-12 04:48:32 +00:00
|
|
|
gint length, struct timeval* value_ptr, const char *format, ...)
|
2000-05-11 08:18:09 +00:00
|
|
|
__attribute__((format (printf, 7, 8)));
|
2000-03-12 04:48:32 +00:00
|
|
|
#else
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-12 04:48:32 +00:00
|
|
|
gint length, struct timeval* value_ptr, const char *format, ...);
|
|
|
|
#endif
|
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
/* Add a FT_IPXNET to a proto_tree */
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_ipxnet(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, guint32 value);
|
|
|
|
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_ipxnet_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, guint32 value);
|
|
|
|
|
2000-03-12 04:48:32 +00:00
|
|
|
#if __GNUC__ == 2
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_ipxnet_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-12 04:48:32 +00:00
|
|
|
gint length, guint32 value, const char *format, ...)
|
2000-05-11 08:18:09 +00:00
|
|
|
__attribute__((format (printf, 7, 8)));
|
2000-03-12 04:48:32 +00:00
|
|
|
#else
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_ipxnet_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-12 04:48:32 +00:00
|
|
|
gint length, guint32 value, const char *format, ...);
|
|
|
|
#endif
|
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
/* Add a FT_IPv4 to a proto_tree */
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_ipv4(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, guint32 value);
|
|
|
|
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_ipv4_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, guint32 value);
|
|
|
|
|
2000-03-12 04:48:32 +00:00
|
|
|
#if __GNUC__ == 2
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_ipv4_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-12 04:48:32 +00:00
|
|
|
gint length, guint32 value, const char *format, ...)
|
2000-05-11 08:18:09 +00:00
|
|
|
__attribute__((format (printf, 7, 8)));
|
2000-03-12 04:48:32 +00:00
|
|
|
#else
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_ipv4_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-12 04:48:32 +00:00
|
|
|
gint length, guint32 value, const char *format, ...);
|
|
|
|
#endif
|
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
/* Add a FT_IPv6 to a proto_tree */
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_ipv6(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, const guint8* value_ptr);
|
|
|
|
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_ipv6_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, const guint8* value_ptr);
|
|
|
|
|
2000-03-12 04:48:32 +00:00
|
|
|
#if __GNUC__ == 2
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_ipv6_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-05-31 05:09:07 +00:00
|
|
|
gint length, const guint8* value_ptr, const char *format, ...)
|
2000-05-11 08:18:09 +00:00
|
|
|
__attribute__((format (printf, 7, 8)));
|
2000-03-12 04:48:32 +00:00
|
|
|
#else
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_ipv6_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-05-31 05:09:07 +00:00
|
|
|
gint length, const guint8* value_ptr, const char *format, ...);
|
2000-03-12 04:48:32 +00:00
|
|
|
#endif
|
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
/* Add a FT_ETHER to a proto_tree */
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_ether(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, const guint8* value);
|
|
|
|
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_ether_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, const guint8* value);
|
|
|
|
|
2000-03-12 04:48:32 +00:00
|
|
|
#if __GNUC__ == 2
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-05-31 05:09:07 +00:00
|
|
|
gint length, const guint8* value, const char *format, ...)
|
2000-05-11 08:18:09 +00:00
|
|
|
__attribute__((format (printf, 7, 8)));
|
2000-03-12 04:48:32 +00:00
|
|
|
#else
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-05-31 18:32:15 +00:00
|
|
|
gint length, const guint8* value, const char *format, ...);
|
2000-03-12 04:48:32 +00:00
|
|
|
#endif
|
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
/* Add a FT_STRING to a proto_tree */
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_string(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, const char* value);
|
|
|
|
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_string_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, const char* value);
|
|
|
|
|
2000-03-12 04:48:32 +00:00
|
|
|
#if __GNUC__ == 2
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_string_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-14 06:03:26 +00:00
|
|
|
gint length, const char* value, const char *format, ...)
|
2000-05-11 08:18:09 +00:00
|
|
|
__attribute__((format (printf, 7, 8)));
|
2000-03-12 04:48:32 +00:00
|
|
|
#else
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_string_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-14 06:03:26 +00:00
|
|
|
gint length, const char* value, const char *format, ...);
|
2000-03-12 04:48:32 +00:00
|
|
|
#endif
|
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
/* Add a FT_BOOLEAN to a proto_tree */
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_boolean(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, guint32 value);
|
|
|
|
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_boolean_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, guint32 value);
|
|
|
|
|
2000-03-12 04:48:32 +00:00
|
|
|
#if __GNUC__ == 2
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_boolean_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-12 04:48:32 +00:00
|
|
|
gint length, guint32 value, const char *format, ...)
|
2000-05-11 08:18:09 +00:00
|
|
|
__attribute__((format (printf, 7, 8)));
|
2000-03-12 04:48:32 +00:00
|
|
|
#else
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_boolean_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-12 04:48:32 +00:00
|
|
|
gint length, guint32 value, const char *format, ...);
|
|
|
|
#endif
|
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
/* Add a FT_DOUBLE to a proto_tree */
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_double(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, double value);
|
|
|
|
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_double_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, double value);
|
|
|
|
|
|
|
|
#if __GNUC__ == 2
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_double_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, double value, const char *format, ...)
|
|
|
|
__attribute__((format (printf, 7, 8)));
|
|
|
|
#else
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_double_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, double value, const char *format, ...);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Add any FT_UINT* to a proto_tree */
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, guint32 value);
|
|
|
|
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_uint_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, guint32 value);
|
|
|
|
|
2000-03-12 04:48:32 +00:00
|
|
|
#if __GNUC__ == 2
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-12 04:48:32 +00:00
|
|
|
gint length, guint32 value, const char *format, ...)
|
2000-05-11 08:18:09 +00:00
|
|
|
__attribute__((format (printf, 7, 8)));
|
2000-03-12 04:48:32 +00:00
|
|
|
#else
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-03-12 04:48:32 +00:00
|
|
|
gint length, guint32 value, const char *format, ...);
|
|
|
|
#endif
|
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
/* Add any FT_INT* to a proto_tree */
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_int(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, gint32 value);
|
|
|
|
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_int_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
|
|
|
gint length, gint32 value);
|
|
|
|
|
2000-04-25 21:43:50 +00:00
|
|
|
#if __GNUC__ == 2
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_int_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-04-25 21:43:50 +00:00
|
|
|
gint length, gint32 value, const char *format, ...)
|
2000-05-11 08:18:09 +00:00
|
|
|
__attribute__((format (printf, 7, 8)));
|
2000-04-25 21:43:50 +00:00
|
|
|
#else
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_int_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
|
2000-04-25 21:43:50 +00:00
|
|
|
gint length, gint32 value, const char *format, ...);
|
|
|
|
#endif
|
|
|
|
|
2000-03-12 04:48:32 +00:00
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
/* Add a text-only node to the proto_tree */
|
2000-03-12 04:48:32 +00:00
|
|
|
#if __GNUC__ == 2
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, const char *,
|
|
|
|
...) __attribute__((format (printf, 5, 6)));
|
2000-03-12 04:48:32 +00:00
|
|
|
#else
|
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, const char *,
|
2000-03-12 04:48:32 +00:00
|
|
|
...);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-05-31 05:09:07 +00:00
|
|
|
/* Add a node with no text */
|
2000-03-12 04:48:32 +00:00
|
|
|
proto_item *
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_notext(proto_tree *tree, tvbuff_t *tvb, gint start, gint length);
|
2000-03-12 04:48:32 +00:00
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
|
Convert IPX-and-friend dissectors in packet-ipx.c to use
tvbuffs.
In doing so, I realied that my recommendation for using
tvb_new_subset(pi.compat_top_tvb, -1, -1) was incorrect, because
some dissectors (ethernet!) change pi.len and pi.cap_len. So, I have
to take those two variables into account instead of using -1 and -1.
So, I provide a macro called tvb_create_from_top(offset), where
offset is the name of your offset variable. It is a wrapper around
tvb_new_subset().
I converted the lines that followed my suggestion to use
tvb_create_from_top().
In proto.c I added
proto_tree_add_debug_text(proto_tree*, const char*, ...)
It's much like proto_tree_add_text(), except that it takes no offset
or length; it's soley for temporarily putting debug text into the
proto_tree while debugging a dissector. In making sure that its
use is temporary, the funciton also prints the debug string to stdout
to remind the programmer that the debug code needs to be removed
before shipping the code.
svn path=/trunk/; revision=2068
2000-06-15 03:49:00 +00:00
|
|
|
/* Useful for quick debugging. Also sends string to STDOUT, so don't
|
|
|
|
* leave call to this function in production code. */
|
|
|
|
#if __GNUC__ == 2
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_debug_text(proto_tree *tree, const char *format, ...)
|
|
|
|
__attribute__((format (printf, 2, 3)));
|
|
|
|
#else
|
|
|
|
proto_item *
|
|
|
|
proto_tree_add_debug_text(proto_tree *tree, const char *format, ...);
|
|
|
|
#endif
|
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
void
|
|
|
|
proto_item_fill_label(field_info *fi, gchar *label_str);
|
|
|
|
|
1999-08-26 07:01:44 +00:00
|
|
|
/* Returns number of items (protocols or header fields) registered. */
|
1999-07-07 22:52:57 +00:00
|
|
|
int proto_registrar_n(void);
|
1999-08-26 07:01:44 +00:00
|
|
|
|
1999-11-11 16:20:25 +00:00
|
|
|
/* Returns char* to name for item # n (0-indexed) */
|
|
|
|
char* proto_registrar_get_name(int n);
|
|
|
|
|
1999-08-26 07:01:44 +00:00
|
|
|
/* Returns char* to abbrev for item # n (0-indexed) */
|
1999-07-07 22:52:57 +00:00
|
|
|
char* proto_registrar_get_abbrev(int n);
|
1999-08-26 07:01:44 +00:00
|
|
|
|
2000-04-03 09:24:12 +00:00
|
|
|
/* get the header field information based upon a field or protocol id */
|
2000-04-04 02:34:40 +00:00
|
|
|
struct header_field_info* proto_registrar_get_nth(int hfindex);
|
2000-04-03 09:24:12 +00:00
|
|
|
|
1999-08-26 07:01:44 +00:00
|
|
|
/* Returns enum ftenum for item # n */
|
1999-07-07 22:52:57 +00:00
|
|
|
int proto_registrar_get_ftype(int n);
|
1999-08-26 07:01:44 +00:00
|
|
|
|
|
|
|
/* Returns parent protocol for item # n.
|
|
|
|
* Returns -1 if item _is_ a protocol */
|
1999-07-07 22:52:57 +00:00
|
|
|
int proto_registrar_get_parent(int n);
|
1999-08-26 07:01:44 +00:00
|
|
|
|
|
|
|
/* Is item #n a protocol? */
|
1999-07-07 22:52:57 +00:00
|
|
|
gboolean proto_registrar_is_protocol(int n);
|
1999-08-26 07:01:44 +00:00
|
|
|
|
1999-10-12 04:21:13 +00:00
|
|
|
/* Get length of registered field according to field type.
|
|
|
|
* 0 means undeterminable at registration time.
|
|
|
|
* -1 means unknown field */
|
|
|
|
gint proto_registrar_get_length(int n);
|
|
|
|
|
1999-08-29 04:06:43 +00:00
|
|
|
/* Checks for existence any protocol or field within a tree.
|
|
|
|
* TRUE = found, FALSE = not found */
|
|
|
|
gboolean proto_check_for_protocol_or_field(proto_tree* tree, int id);
|
|
|
|
|
|
|
|
/* Search for a protocol subtree, which can occur more than once, and for each successful
|
|
|
|
* find, call the calback function, passing sinfo as the second argument */
|
|
|
|
void proto_find_protocol_multi(proto_tree* tree, int target, GNodeTraverseFunc callback,
|
|
|
|
proto_tree_search_info *sinfo);
|
|
|
|
|
|
|
|
/* Just a wrapper to call sinfo->traverse_func() for all nodes in the subtree, with the GNode
|
|
|
|
* and sinfo as the two arguments to sinfo->traverse_func(). Useful when you have to process
|
|
|
|
* all nodes in a subtree. */
|
|
|
|
gboolean proto_get_field_values(proto_tree* subtree, proto_tree_search_info *sinfo);
|
1999-07-07 22:52:57 +00:00
|
|
|
|
1999-07-15 15:33:52 +00:00
|
|
|
/* Dumps a glossary of the protocol and field registrations to STDOUT */
|
|
|
|
void proto_registrar_dump(void);
|
|
|
|
|
1999-08-26 07:01:44 +00:00
|
|
|
/* Is the parsing being done for a visible proto_tree or an invisible one?
|
|
|
|
* By setting this correctly, the proto_tree creation is sped up by not
|
|
|
|
* having to call vsnprintf and copy strings around.
|
|
|
|
*/
|
|
|
|
extern gboolean proto_tree_is_visible;
|
|
|
|
|
1999-11-16 11:44:20 +00:00
|
|
|
/* Points to the first element of an array of Booleans, indexed by
|
|
|
|
a subtree item type; that array element is TRUE if subtrees of
|
|
|
|
an item of that type are to be expanded.
|
|
|
|
|
|
|
|
ETT_NONE is reserved for unregistered subtree types. */
|
|
|
|
#define ETT_NONE 0
|
|
|
|
extern gboolean *tree_is_expanded;
|
|
|
|
|
|
|
|
/* Number of elements in that array. */
|
|
|
|
extern int num_tree_types;
|
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
#endif /* proto.h */
|