First pass at per frame proto data. Keep each proto block as a GSList list.

Use glib as far as possible. Currently have data structures and routines
defined ... Next will write the routines ...

svn path=/trunk/; revision=1748
This commit is contained in:
Richard Sharpe 2000-03-26 06:57:41 +00:00
parent df1a7250cf
commit 92646c4b3c
2 changed files with 57 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
* $Id: packet.c,v 1.66 2000/03/23 00:38:10 guy Exp $
* $Id: packet.c,v 1.67 2000/03/26 06:57:40 sharpe Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -1154,6 +1154,52 @@ dissect_packet(const u_char *pd, frame_data *fd, proto_tree *tree)
}
}
gint p_compare(gconstpointer a, gconstpointer b)
{
if (((frame_proto_data *)a) -> proto > ((frame_proto_data *)b) -> proto)
return 1;
else if (((frame_proto_data *)a) -> proto == ((frame_proto_data *)b) -> proto)
return 0;
else
return -1;
}
void
p_add_proto_data(frame_data *fd, int proto, void *proto_data)
{
frame_proto_data *p1 = malloc(sizeof(frame_proto_data)); /* FIXME */
g_assert(p1 != NULL);
p1 -> proto = proto;
p1 -> proto_data = proto_data;
/* Allocate a frame_proto_data struct and then add it to the GSLIST */
fd -> pfd = g_slist_insert_sorted(fd -> pfd,
(gpointer *)p1,
p_compare);
}
void *
p_get_proto_data(frame_data *fd, int proto)
{
return(NULL);
}
void
p_rem_proto_data(frame_data *fd, int proto)
{
}
void
proto_register_frame(void)
{

View File

@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
* $Id: packet.h,v 1.174 2000/03/08 06:47:51 guy Exp $
* $Id: packet.h,v 1.175 2000/03/26 06:57:41 sharpe Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -114,6 +114,11 @@ typedef enum {
CHAR_EBCDIC /* EBCDIC */
} char_enc;
typedef struct _frame_proto_data {
int proto;
void *proto_data;
} frame_proto_data;
/* XXX - some of this stuff is used only while a packet is being dissected;
should we keep around a separate data structure for that, to save
memory?
@ -123,6 +128,7 @@ typedef enum {
typedef struct _frame_data {
struct _frame_data *next; /* Next element in list */
struct _frame_data *prev; /* Previous element in list */
GSList *pfd; /* Per frame proto data */
guint32 num; /* Frame number */
guint32 pkt_len; /* Packet length */
guint32 cap_len; /* Amount actually captured */
@ -254,6 +260,9 @@ void col_append_str(frame_data *, gint, gchar *);
void col_set_cls_time(frame_data *, int);
void fill_in_columns(frame_data *);
void p_add_proto_data(frame_data *, int, void *);
void *p_get_proto_data(frame_data *, int);
void blank_packetinfo(void);
/* Allow protocols to register "init" routines, which are called before