Add tables of "conversation" dissectors, which are associated with

particular protocols, and which keep track of all dissectors that could
be associated with conversations using those particular protocols - for
example, the RTP and RTCP dissectors could be assigned to UDP
conversations.

This is for future use with UI features allowing the dissector for a
given conversation to be set from the UI, to allow

	1) conversations between two ports, both of which have
	   dissectors associated with them, that have been given to the
	   wrong dissector to be given to the right dissector;

	2) conversations between two ports, neither of which have
	   dissectors associated with them, to be given to a dissector
	   (RTP and RTCP, for example, typically run on random ports,
	   and if you don't have, in a capture, traffic that would say
	   "OK, traffic between these two hosts and ports will be RTP
	   traffic", you may have to tell Ethereal explicitly what
	   protocol the conversation is).

svn path=/trunk/; revision=2848
This commit is contained in:
Guy Harris 2001-01-09 05:53:21 +00:00
parent 2cedf1666a
commit 925ce16014
6 changed files with 128 additions and 4 deletions

View File

@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
* $Id: packet.c,v 1.11 2000/12/04 06:37:46 guy Exp $
* $Id: packet.c,v 1.12 2001/01/09 05:53:21 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -1463,6 +1463,84 @@ register_heur_dissector_list(const char *name, heur_dissector_list_t *sub_dissec
(gpointer) sub_dissectors);
}
static GHashTable *conv_dissector_lists = NULL;
/*
* XXX - for now, we support having both "old" dissectors, with packet
* data pointer, packet offset, frame_data pointer, and protocol tree
* pointer arguments, and "new" dissectors, with tvbuff pointer,
* packet_info pointer, and protocol tree pointer arguments.
*
* Nuke this and go back to storing a pointer to the dissector when
* the last old-style dissector is gone.
*/
typedef struct {
gboolean is_old_dissector;
union {
old_dissector_t old;
dissector_t new;
} dissector;
} conv_dtbl_entry_t;
/* Finds a conversation dissector table by table name. */
static conv_dissector_list_t *
find_conv_dissector_list(const char *name)
{
g_assert(conv_dissector_lists != NULL);
return g_hash_table_lookup(conv_dissector_lists, name);
}
void
old_conv_dissector_add(const char *name, old_dissector_t dissector)
{
conv_dissector_list_t *sub_dissectors = find_conv_dissector_list(name);
conv_dtbl_entry_t *dtbl_entry;
/* sanity check */
g_assert(sub_dissectors != NULL);
dtbl_entry = g_malloc(sizeof (conv_dtbl_entry_t));
dtbl_entry->is_old_dissector = TRUE;
dtbl_entry->dissector.old = dissector;
/* do the table insertion */
*sub_dissectors = g_slist_append(*sub_dissectors, (gpointer)dtbl_entry);
}
void
conv_dissector_add(const char *name, dissector_t dissector)
{
conv_dissector_list_t *sub_dissectors = find_conv_dissector_list(name);
conv_dtbl_entry_t *dtbl_entry;
/* sanity check */
g_assert(sub_dissectors != NULL);
dtbl_entry = g_malloc(sizeof (conv_dtbl_entry_t));
dtbl_entry->is_old_dissector = FALSE;
dtbl_entry->dissector.new = dissector;
/* do the table insertion */
*sub_dissectors = g_slist_append(*sub_dissectors, (gpointer)dtbl_entry);
}
void
register_conv_dissector_list(const char *name, conv_dissector_list_t *sub_dissectors)
{
/* Create our hash-of-lists if it doesn't already exist */
if (conv_dissector_lists == NULL) {
conv_dissector_lists = g_hash_table_new(g_str_hash, g_str_equal);
g_assert(conv_dissector_lists != NULL);
}
/* Make sure the registration is unique */
g_assert(g_hash_table_lookup(conv_dissector_lists, name) == NULL);
*sub_dissectors = NULL; /* initially empty */
g_hash_table_insert(conv_dissector_lists, (gpointer)name,
(gpointer) sub_dissectors);
}
/*
* Register dissectors by name; used if one dissector always calls a
* particular dissector, or if it bases the decision of which dissector

View File

@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
* $Id: packet.h,v 1.15 2000/12/13 02:24:23 guy Exp $
* $Id: packet.h,v 1.16 2001/01/09 05:53:21 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -253,6 +253,28 @@ void heur_dissector_add(const char *name, heur_dissector_t dissector);
gboolean dissector_try_heuristic(heur_dissector_list_t sub_dissectors,
tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
/* List of "conversation" dissectors (they're not heuristic, but are
assigned to a conversation if some other dissector sees some traffic
saying "traffic between these hosts on these ports will be of type
XXX", e.g. RTSP traffic doing so).
These lists are for use by the UI, which, for a given conversation,
would offer a list of dissectors that could be used with it; this
would include dissectors on the conversation dissector list for
the transport-layer protocol for the conversation, as well as
dissectors for any port-based lists for that protocol (as a conversation
between two ports, both of which have dissectors associated with them,
might have been given to the wrong one of those dissectors). */
typedef GSList *conv_dissector_list_t;
/* A protocol uses this function to register a conversation dissector list */
void register_conv_dissector_list(const char *name, conv_dissector_list_t *list);
/* Add a sub-dissector to a conversation dissector list. Called by the
protocol routine that wants to register a sub-dissector. */
void old_conv_dissector_add(const char *name, old_dissector_t dissector);
void conv_dissector_add(const char *name, dissector_t dissector);
/* Handle for dissectors you call directly.
This handle is opaque outside of "packet.c". */
struct dissector_handle;

View File

@ -1218,3 +1218,13 @@ proto_register_rtcp(void)
register_init_routine( &rtcp_init );
#endif
}
void
proto_reg_handoff_rtcp(void)
{
/*
* Register this dissector as one that can be assigned to a
* UDP conversation.
*/
conv_dissector_add("udp", dissect_rtcp);
}

View File

@ -629,3 +629,13 @@ proto_register_rtp(void)
register_init_routine( &rtp_init );
#endif
}
void
proto_reg_handoff_rtp(void)
{
/*
* Register this dissector as one that can be assigned to a
* UDP conversation.
*/
conv_dissector_add("udp", dissect_rtp);
}

View File

@ -1,7 +1,7 @@
/* packet-tcp.c
* Routines for TCP packet disassembly
*
* $Id: packet-tcp.c,v 1.95 2001/01/03 07:53:43 guy Exp $
* $Id: packet-tcp.c,v 1.96 2001/01/09 05:53:20 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -89,6 +89,7 @@ static gint ett_tcp_option_sack = -1;
static dissector_table_t subdissector_table;
static heur_dissector_list_t heur_subdissector_list;
static conv_dissector_list_t conv_subdissector_list;
/* TCP Ports */
@ -753,6 +754,7 @@ proto_register_tcp(void)
/* subdissector code */
subdissector_table = register_dissector_table("tcp.port");
register_heur_dissector_list("tcp", &heur_subdissector_list);
register_conv_dissector_list("tcp", &conv_subdissector_list);
/* Register configuration preferences */
tcp_module = prefs_register_protocol(proto_tcp, NULL);

View File

@ -1,7 +1,7 @@
/* packet-udp.c
* Routines for UDP packet disassembly
*
* $Id: packet-udp.c,v 1.82 2001/01/06 08:44:03 guy Exp $
* $Id: packet-udp.c,v 1.83 2001/01/09 05:53:20 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -73,6 +73,7 @@ typedef struct _e_udphdr {
static dissector_table_t udp_dissector_table;
static heur_dissector_list_t heur_subdissector_list;
static conv_dissector_list_t conv_subdissector_list;
/* Determine if there is a sub-dissector and call it. This has been */
/* separated into a stand alone routine to other protocol dissectors */
@ -273,6 +274,7 @@ proto_register_udp(void)
/* subdissector code */
udp_dissector_table = register_dissector_table("udp.port");
register_heur_dissector_list("udp", &heur_subdissector_list);
register_conv_dissector_list("udp", &conv_subdissector_list);
}
void