diff options
-rw-r--r-- | epan/conversation.c | 96 | ||||
-rw-r--r-- | epan/conversation.h | 11 | ||||
-rw-r--r-- | packet-afs.c | 4 | ||||
-rw-r--r-- | packet-bxxp.c | 5 | ||||
-rw-r--r-- | packet-dcerpc.c | 6 | ||||
-rw-r--r-- | packet-dsi.c | 25 | ||||
-rw-r--r-- | packet-ftp.c | 4 | ||||
-rw-r--r-- | packet-msproxy.c | 51 | ||||
-rw-r--r-- | packet-ncp2222.inc | 12 | ||||
-rw-r--r-- | packet-quake.c | 4 | ||||
-rw-r--r-- | packet-rlogin.c | 22 | ||||
-rw-r--r-- | packet-rpc.c | 6 | ||||
-rw-r--r-- | packet-rtcp.c | 35 | ||||
-rw-r--r-- | packet-rtcp.h | 4 | ||||
-rw-r--r-- | packet-rtp.c | 35 | ||||
-rw-r--r-- | packet-rtp.h | 4 | ||||
-rw-r--r-- | packet-rtsp.c | 11 | ||||
-rw-r--r-- | packet-smb.c | 6 | ||||
-rw-r--r-- | packet-smtp.c | 5 | ||||
-rw-r--r-- | packet-snmp.c | 5 | ||||
-rw-r--r-- | packet-socks.c | 33 | ||||
-rw-r--r-- | packet-ssl.c | 45 | ||||
-rw-r--r-- | packet-tftp.c | 5 | ||||
-rw-r--r-- | packet-wcp.c | 24 | ||||
-rw-r--r-- | packet-wsp.c | 8 |
25 files changed, 297 insertions, 169 deletions
diff --git a/epan/conversation.c b/epan/conversation.c index 56d20fe23d..214f1d3c1e 100644 --- a/epan/conversation.c +++ b/epan/conversation.c @@ -1,7 +1,7 @@ /* conversation.c * Routines for building lists of packets that are part of a "conversation" * - * $Id: conversation.c,v 1.12 2001/09/03 07:31:20 guy Exp $ + * $Id: conversation.c,v 1.13 2001/09/03 10:33:12 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -85,6 +85,17 @@ static guint32 new_index; static int conversation_init_count = 200; /* + * Protocol-specific data attached to a conversation_t structure - protocol + * index and opaque pointer. + */ +typedef struct _conv_proto_data { + int proto; + void *proto_data; +} conv_proto_data; + +static GMemChunk *conv_proto_data_area = NULL; + +/* * Compute the hash value for two given address/port pairs if the match * is to be exact. */ @@ -378,6 +389,17 @@ conversation_init(void) if (conversation_chunk != NULL) g_mem_chunk_destroy(conversation_chunk); + /* + * Free up any space allocated for conversation protocol data + * areas. + * + * We can free the space, as the structures it contains are + * pointed to by conversation data structures that were freed + * above. + */ + if (conv_proto_data_area != NULL) + g_mem_chunk_destroy(conv_proto_data_area); + conversation_hashtable_exact = g_hash_table_new(conversation_hash_exact, conversation_match_exact); @@ -400,6 +422,13 @@ conversation_init(void) G_ALLOC_AND_FREE); /* + * Allocate a new area for conversation protocol data items. + */ + conv_proto_data_area = g_mem_chunk_new("conv_proto_data_area", + sizeof(conv_proto_data), 20 * sizeof(conv_proto_data), /* FIXME*/ + G_ALLOC_ONLY); + + /* * Start the conversation indices over at 0. */ new_index = 0; @@ -415,7 +444,7 @@ conversation_init(void) */ conversation_t * conversation_new(address *addr1, address *addr2, port_type ptype, - guint32 port1, guint32 port2, void *data, guint options) + guint32 port1, guint32 port2, guint options) { conversation_t *conversation; conversation_key *new_key; @@ -431,7 +460,7 @@ conversation_new(address *addr1, address *addr2, port_type ptype, conversation = g_mem_chunk_alloc(conversation_chunk); conversation->index = new_index; - conversation->data = data; + conversation->data_list = NULL; /* clear dissector pointer */ conversation->dissector.new_d = NULL; @@ -810,6 +839,67 @@ find_conversation(address *addr_a, address *addr_b, port_type ptype, return NULL; } +static gint +p_compare(gconstpointer a, gconstpointer b) +{ + if (((conv_proto_data *)a)->proto > ((conv_proto_data *)b)->proto) + return 1; + else if (((conv_proto_data *)a)->proto == ((conv_proto_data *)b)->proto) + return 0; + else + return -1; +} + +void +conversation_add_proto_data(conversation_t *conv, int proto, void *proto_data) +{ + conv_proto_data *p1 = g_mem_chunk_alloc(conv_proto_data_area); + + p1->proto = proto; + p1->proto_data = proto_data; + + /* Add it to the list of items for this conversation. */ + + conv->data_list = g_slist_insert_sorted(conv->data_list, (gpointer *)p1, + p_compare); +} + +void * +conversation_get_proto_data(conversation_t *conv, int proto) +{ + conv_proto_data temp, *p1; + GSList *item; + + temp.proto = proto; + temp.proto_data = NULL; + + item = g_slist_find_custom(conv->data_list, (gpointer *)&temp, + p_compare); + + if (item != NULL) { + p1 = (conv_proto_data *)item->data; + return p1->proto_data; + } + + return NULL; +} + +void +conversation_delete_proto_data(conversation_t *conv, int proto) +{ + conv_proto_data temp; + GSList *item; + + temp.proto = proto; + temp.proto_data = NULL; + + item = g_slist_find_custom(conv->data_list, (gpointer *)&temp, + p_compare); + + if (item != NULL) + conv->data_list = g_slist_remove(conv->data_list, item); +} + /* * Set the dissector for a conversation. */ diff --git a/epan/conversation.h b/epan/conversation.h index 7ea269445b..4e27862762 100644 --- a/epan/conversation.h +++ b/epan/conversation.h @@ -1,7 +1,7 @@ /* conversation.h * Routines for building lists of packets that are part of a "conversation" * - * $Id: conversation.h,v 1.5 2001/06/10 09:50:20 guy Exp $ + * $Id: conversation.h,v 1.6 2001/09/03 10:33:12 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -56,7 +56,7 @@ typedef struct conversation_key { typedef struct conversation { struct conversation *next; /* pointer to next conversation on hash chain */ guint32 index; /* unique ID for conversation */ - void *data; /* data our client can associate with a conversation */ + GSList *data_list; /* list of data associated with conversation */ gboolean is_old_dissector; /* XXX - nuke when everybody tvbuffified */ union { old_dissector_t old_d; @@ -69,11 +69,16 @@ typedef struct conversation { extern void conversation_init(void); conversation_t *conversation_new(address *addr1, address *addr2, - port_type ptype, guint32 port1, guint32 port2, void *data, guint options); + port_type ptype, guint32 port1, guint32 port2, guint options); conversation_t *find_conversation(address *addr_a, address *addr_b, port_type ptype, guint32 port_a, guint32 port_b, guint options); +void conversation_add_proto_data(conversation_t *conv, int proto, + void *proto_data); +void *conversation_get_proto_data(conversation_t *conv, int proto); +void conversation_delete_proto_data(conversation_t *conv, int proto); + void old_conversation_set_dissector(conversation_t *conversation, old_dissector_t dissector); void conversation_set_dissector(conversation_t *conversation, diff --git a/packet-afs.c b/packet-afs.c index c6534377df..83868488ef 100644 --- a/packet-afs.c +++ b/packet-afs.c @@ -8,7 +8,7 @@ * Portions based on information/specs retrieved from the OpenAFS sources at * www.openafs.org, Copyright IBM. * - * $Id: packet-afs.c,v 1.33 2001/08/04 04:04:33 guy Exp $ + * $Id: packet-afs.c,v 1.34 2001/09/03 10:33:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -224,7 +224,7 @@ dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (conversation == NULL) { /* It's not part of any conversation - create a new one. */ conversation = conversation_new(&pinfo->src, &pinfo->dst, - pinfo->ptype, pinfo->srcport, pinfo->destport, NULL, 0); + pinfo->ptype, pinfo->srcport, pinfo->destport, 0); } request_key.conversation = conversation->index; diff --git a/packet-bxxp.c b/packet-bxxp.c index a490e47b48..a1ad8e302c 100644 --- a/packet-bxxp.c +++ b/packet-bxxp.c @@ -1,7 +1,7 @@ /* packet-bxxp.c * Routines for BXXP packet disassembly * - * $Id: packet-bxxp.c,v 1.20 2001/07/03 04:56:45 guy Exp $ + * $Id: packet-bxxp.c,v 1.21 2001/09/03 10:33:05 guy Exp $ * * Copyright (c) 2000 by Richard Sharpe <rsharpe@ns.aus.com> * @@ -1019,8 +1019,7 @@ dissect_bxxp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) pinfo->srcport, pinfo->destport, 0); if (conversation == NULL) { /* No conversation, create one */ conversation = conversation_new(&pinfo->src, &pinfo->dst, pinfo->ptype, - pinfo->srcport, pinfo->destport, NULL, - 0); + pinfo->srcport, pinfo->destport, 0); } diff --git a/packet-dcerpc.c b/packet-dcerpc.c index 5c394c9d3e..7bc11cb490 100644 --- a/packet-dcerpc.c +++ b/packet-dcerpc.c @@ -2,7 +2,7 @@ * Routines for DCERPC packet disassembly * Copyright 2001, Todd Sabin <tas@webspan.net> * - * $Id: packet-dcerpc.c,v 1.7 2001/07/11 04:49:34 guy Exp $ + * $Id: packet-dcerpc.c,v 1.8 2001/09/03 10:33:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -539,7 +539,7 @@ dissect_dcerpc_cn_bind (tvbuff_t *tvb, packet_info *pinfo, proto_tree *dcerpc_tr pinfo->srcport, pinfo->destport, 0); if (conv == NULL) { conv = conversation_new (&pinfo->src, &pinfo->dst, pinfo->ptype, - pinfo->srcport, pinfo->destport, NULL, 0); + pinfo->srcport, pinfo->destport, 0); } key = g_mem_chunk_alloc (dcerpc_conv_key_chunk); @@ -1024,7 +1024,7 @@ dissect_dcerpc_dg (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) pinfo->srcport, pinfo->destport, 0); if (!conv) { conv = conversation_new (&pinfo->src, &pinfo->dst, pinfo->ptype, - pinfo->srcport, pinfo->destport, NULL, 0); + pinfo->srcport, pinfo->destport, 0); } /* diff --git a/packet-dsi.c b/packet-dsi.c index 0c1d72f44d..2ef73a826e 100644 --- a/packet-dsi.c +++ b/packet-dsi.c @@ -2,15 +2,14 @@ * Routines for dsi packet dissection * Copyright 2001, Randy McEoin <rmceoin@pe.com> * - * $Id: packet-dsi.c,v 1.2 2001/06/18 02:17:46 guy Exp $ + * $Id: packet-dsi.c,v 1.3 2001/09/03 10:33:05 guy Exp $ * * Ethereal - Network traffic analyzer - * By Gerald Combs <gerald@zing.org> + * By Gerald Combs <gerald@ethereal.com> * Copyright 1998 Gerald Combs * * Copied from packet-pop.c * - * * 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 @@ -318,17 +317,19 @@ dissect_dsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) conversation = find_conversation(&pinfo->src, &pinfo->dst, PT_TCP, pinfo->srcport, pinfo->destport, 0); - if (conversation == NULL) { - hash_info = g_mem_chunk_alloc(vals); - hash_info->state = NONE; + if (conversation == NULL) + { conversation = conversation_new(&pinfo->src, &pinfo->dst, - pinfo->ptype, pinfo->srcport, pinfo->destport, - hash_info, 0); - - conversation_set_dissector(conversation, dissect_dsi); - }else + pinfo->ptype, pinfo->srcport, pinfo->destport, 0); + } + conversation_set_dissector(conversation, dissect_dsi); + hash_info = conversation_get_proto_data(conversation, proto_dsi); + if (hash_info == NULL) { - hash_info = conversation->data; + hash_info = g_mem_chunk_alloc(vals); + hash_info->state = NONE; + conversation_add_proto_data(conversation, proto_dsi, + hash_info); } prev_cont=dsi_state_machine( hash_info, tvb, pinfo, offset); diff --git a/packet-ftp.c b/packet-ftp.c index 8109b2ba24..b58ee64230 100644 --- a/packet-ftp.c +++ b/packet-ftp.c @@ -3,7 +3,7 @@ * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com> * Copyright 2001, Juan Toledo <toledo@users.sourceforge.net> (Passive FTP) * - * $Id: packet-ftp.c,v 1.33 2001/09/03 03:12:01 guy Exp $ + * $Id: packet-ftp.c,v 1.34 2001/09/03 10:33:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -180,7 +180,7 @@ handle_pasv_response(const u_char *line, int linelen, packet_info *pinfo) * handle conversations not in the hash table? */ conversation = conversation_new(&server_addr, &pinfo->dst, - PT_TCP, server_port, 0, NULL, NO_PORT2); + PT_TCP, server_port, 0, NO_PORT2); conversation_set_dissector(conversation, dissect_ftpdata); } diff --git a/packet-msproxy.c b/packet-msproxy.c index 1eaeb89558..65b80c0bdc 100644 --- a/packet-msproxy.c +++ b/packet-msproxy.c @@ -2,7 +2,7 @@ * Routines for Microsoft Proxy packet dissection * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com> * - * $Id: packet-msproxy.c,v 1.21 2001/06/18 02:17:49 guy Exp $ + * $Id: packet-msproxy.c,v 1.22 2001/09/03 10:33:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -221,7 +221,8 @@ static void msproxy_sub_dissector( tvbuff_t *tvb, packet_info *pinfo, g_assert( conversation); /* should always find a conversation */ - redirect_info = (redirect_entry_t*)conversation->data; + redirect_info = conversation_get_proto_data(conversation, + proto_msproxy); if (check_col(pinfo->fd, COL_PROTOCOL)) col_set_str(pinfo->fd, COL_PROTOCOL, "MS Proxy"); @@ -280,30 +281,38 @@ static void add_msproxy_conversation( packet_info *pinfo, /* and pinfo->dst will not be correct and this routine will have */ /* to change. */ + conversation_t *conversation; redirect_entry_t *new_conv_info; - conversation_t *conversation = find_conversation( &pinfo->src, + if (pinfo->fd->flags.visited) { + /* + * We've already processed this frame once, so we + * should already have done this. + */ + return; + } + + conversation = find_conversation( &pinfo->src, &pinfo->dst, hash_info->proto, hash_info->server_int_port, hash_info->clnt_port, 0); - if ( conversation) - return; + if ( !conversation) { + conversation = conversation_new( &pinfo->src, &pinfo->dst, + hash_info->proto, hash_info->server_int_port, + hash_info->clnt_port, 0); + } + conversation_set_dissector(conversation, msproxy_sub_dissector); new_conv_info = g_mem_chunk_alloc(redirect_vals); - conversation = conversation_new( &pinfo->src, &pinfo->dst, - hash_info->proto, hash_info->server_int_port, - hash_info->clnt_port, new_conv_info, 0); - - g_assert( new_conv_info); - g_assert( conversation); new_conv_info->remote_addr = hash_info->dst_addr; new_conv_info->clnt_port = hash_info->clnt_port; new_conv_info->remote_port = hash_info->dst_port; new_conv_info->server_int_port = hash_info->server_int_port; new_conv_info->proto = hash_info->proto; - - conversation_set_dissector(conversation, msproxy_sub_dissector); + + conversation_add_proto_data(conversation, proto_msproxy, + new_conv_info); } @@ -1109,15 +1118,15 @@ static void dissect_msproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) conversation = find_conversation( &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0); - if ( conversation) /* conversation found */ - hash_info = conversation->data; - - /* new conversation create local data structure */ - else { + if ( !conversation) { + conversation = conversation_new( &pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->srcport, pinfo->destport, 0); + } + hash_info = conversation_get_proto_data(conversation, proto_msproxy); + if ( !hash_info) { hash_info = g_mem_chunk_alloc(vals); - - conversation_new( &pinfo->src, &pinfo->dst, pinfo->ptype, - pinfo->srcport, pinfo->destport, hash_info, 0); + conversation_add_proto_data(conversation, proto_msproxy, + hash_info); } if (check_col(pinfo->fd, COL_INFO)){ diff --git a/packet-ncp2222.inc b/packet-ncp2222.inc index 281a08454f..55c3bbc254 100644 --- a/packet-ncp2222.inc +++ b/packet-ncp2222.inc @@ -7,10 +7,10 @@ * * Gilbert Ramirez <gram@xiexie.org> * - * $Id: packet-ncp2222.inc,v 1.3 2001/06/28 02:42:48 gram Exp $ + * $Id: packet-ncp2222.inc,v 1.4 2001/09/03 10:33:05 guy Exp $ * * Ethereal - Network traffic analyzer - * By Gerald Combs <gerald@zing.org> + * By Gerald Combs <gerald@ethereal.com> * Copyright 2000 Gerald Combs * * This program is free software; you can redistribute it and/or @@ -180,12 +180,12 @@ dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo, to have all packets over the same connection treated as being part of a single conversation so that we can let the user select that conversation to be displayed.) */ - conversation = find_conversation(&pi.src, &pi.dst, + conversation = find_conversation(&pinfo->src, &pinfo->dst, PT_NCP, nw_connection, nw_connection, 0); if (conversation == NULL) { /* It's not part of any conversation - create a new one. */ - conversation = conversation_new(&pi.src, &pi.dst, - PT_NCP, nw_connection, nw_connection, NULL, 0); + conversation = conversation_new(&pinfo->src, &pinfo->dst, + PT_NCP, nw_connection, nw_connection, 0); } ncp_hash_insert(conversation, sequence, 0x2222, ncp_rec); } @@ -255,7 +255,7 @@ dissect_ncp_reply(tvbuff_t *tvb, packet_info *pinfo, const char *error_string; /* Find the conversation whence the request would have come. */ - conversation = find_conversation(&pi.src, &pi.dst, + conversation = find_conversation(&pinfo->src, &pinfo->dst, PT_NCP, nw_connection, nw_connection, 0); if (conversation != NULL) { /* find the record telling us the request made that caused diff --git a/packet-quake.c b/packet-quake.c index 6982725d1c..920d864423 100644 --- a/packet-quake.c +++ b/packet-quake.c @@ -4,7 +4,7 @@ * Uwe Girlich <uwe@planetquake.com> * http://www.idsoftware.com/q1source/q1source.zip * - * $Id: packet-quake.c,v 1.17 2001/07/03 04:56:45 guy Exp $ + * $Id: packet-quake.c,v 1.18 2001/09/03 10:33:06 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -241,7 +241,7 @@ dissect_quake_CCREP_ACCEPT port = tvb_get_letohl(tvb, 0); c = conversation_new( &pinfo->src, &pinfo->dst, PT_UDP, port, - pinfo->destport, NULL, 0); + pinfo->destport, 0); if (c) { conversation_set_dissector(c, dissect_quake); } diff --git a/packet-rlogin.c b/packet-rlogin.c index 28070ffcc9..6bc2e4cb5e 100644 --- a/packet-rlogin.c +++ b/packet-rlogin.c @@ -2,7 +2,7 @@ * Routines for unix rlogin packet dissection * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com> * - * $Id: packet-rlogin.c,v 1.18 2001/07/03 00:49:57 guy Exp $ + * $Id: packet-rlogin.c,v 1.19 2001/09/03 10:33:06 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -23,8 +23,6 @@ * 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 @@ -337,26 +335,26 @@ static void rlogin_display( rlogin_hash_entry_t *hash_info, tvbuff_t *tvb, static void dissect_rlogin(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - rlogin_hash_entry_t *hash_info = 0; conversation_t *conversation; + rlogin_hash_entry_t *hash_info; gint ti_offset; /* Lookup this connection*/ conversation = find_conversation( &pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0); - if ( conversation) /* conversation found */ - hash_info = conversation->data; - - /* new conversation create local data structure */ - else { + if ( !conversation) { + conversation = conversation_new( &pinfo->src, &pinfo->dst, + pinfo->ptype, pinfo->srcport, pinfo->destport, 0); + } + hash_info = conversation_get_proto_data(conversation, proto_rlogin); + if ( !hash_info) { hash_info = g_mem_chunk_alloc(rlogin_vals); hash_info->state = NONE; hash_info->info_framenum = 0; /* no frame has the number 0 */ hash_info->name[ 0] = 0; - - conversation_new( &pinfo->src, &pinfo->dst, pinfo->ptype, - pinfo->srcport, pinfo->destport, hash_info, 0); + conversation_add_proto_data(conversation, proto_rlogin, + hash_info); } if (check_col(pinfo->fd, COL_PROTOCOL)) /* update protocol */ diff --git a/packet-rpc.c b/packet-rpc.c index b869962e34..044c195409 100644 --- a/packet-rpc.c +++ b/packet-rpc.c @@ -2,7 +2,7 @@ * Routines for rpc dissection * Copyright 1999, Uwe Girlich <Uwe.Girlich@philosys.de> * - * $Id: packet-rpc.c,v 1.67 2001/09/02 23:57:33 guy Exp $ + * $Id: packet-rpc.c,v 1.68 2001/09/03 10:33:06 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1141,7 +1141,7 @@ dissect_rpc_indir_call(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, dissector. */ conversation = conversation_new(&pinfo->src, &null_address, pinfo->ptype, pinfo->srcport, - pinfo->destport, NULL, 0); + pinfo->destport, 0); } /* Prepare the key data. @@ -1591,7 +1591,7 @@ dissect_rpc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) one. */ conversation = conversation_new(&pinfo->src, &null_address, pinfo->ptype, pinfo->srcport, - pinfo->destport, NULL, 0); + pinfo->destport, 0); } /* prepare the key data */ diff --git a/packet-rtcp.c b/packet-rtcp.c index 206118c588..cfec976e8a 100644 --- a/packet-rtcp.c +++ b/packet-rtcp.c @@ -1,6 +1,6 @@ /* packet-rtcp.c * - * $Id: packet-rtcp.c,v 1.20 2001/09/03 08:10:46 guy Exp $ + * $Id: packet-rtcp.c,v 1.21 2001/09/03 10:33:06 guy Exp $ * * Routines for RTCP dissection * RTCP = Real-time Transport Control Protocol @@ -178,15 +178,22 @@ static gint ett_sdes_item = -1; static address fake_addr; static int heur_init = FALSE; -static char rtcp_proto[] = "RTCP"; - static gboolean dissect_rtcp_heur( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ); -void rtcp_add_address( const unsigned char* ip_addr, int prt ) +void rtcp_add_address( packet_info *pinfo, const unsigned char* ip_addr, + int prt ) { address src_addr; - conversation_t* pconv = ( conversation_t* ) NULL; + conversation_t* pconv; + + /* + * If this isn't the first time this packet has been processed, + * we've already done this work, so we don't need to do it + * again. + */ + if (pinfo->fd->flags.visited) + return; src_addr.type = AT_IPv4; src_addr.len = 4; @@ -209,10 +216,12 @@ void rtcp_add_address( const unsigned char* ip_addr, int prt ) /* * If not, add + * XXX - use wildcard address and port B? */ if ( ! pconv ) { - conversation_new( &src_addr, &fake_addr, PT_UDP, (guint32) prt, - (guint32) 0, (void*) rtcp_proto, 0 ); + pconv = conversation_new( &src_addr, &fake_addr, PT_UDP, + (guint32) prt, (guint32) 0, 0 ); + conversation_add_proto_data(pconv, proto_rtcp, NULL); } } @@ -262,15 +271,11 @@ dissect_rtcp_heur( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ) /* - * An RTCP conversation always contains data - */ - if ( pconv->data == NULL ) - return FALSE; - - /* - * An RTCP conversation data always contains "RTCP" + * An RTCP conversation always has a data item for RTCP. + * (Its existence is sufficient to indicate that this is an RTCP + * conversation.) */ - if ( strcmp( pconv->data, rtcp_proto ) != 0 ) + if (conversation_get_proto_data(pconv, proto_rtcp) == NULL) return FALSE; /* diff --git a/packet-rtcp.h b/packet-rtcp.h index 3cb1875b3e..d9b01e09b5 100644 --- a/packet-rtcp.h +++ b/packet-rtcp.h @@ -1,6 +1,6 @@ /* packet-rtcp.h * - * $Id: packet-rtcp.h,v 1.5 2001/06/12 06:31:14 guy Exp $ + * $Id: packet-rtcp.h,v 1.6 2001/09/03 10:33:06 guy Exp $ * * Routines for RTCP dissection * RTCP = Real-time Transport Control Protocol @@ -27,6 +27,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -void rtcp_add_address ( const unsigned char* ip_addr, int prt ); +void rtcp_add_address ( packet_info *pinfo, const unsigned char* ip_addr, int prt ); void dissect_rtcp ( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ); void proto_register_rtcp( void ); diff --git a/packet-rtp.c b/packet-rtp.c index bc0b12135d..34438f2144 100644 --- a/packet-rtp.c +++ b/packet-rtp.c @@ -6,7 +6,7 @@ * Copyright 2000, Philips Electronics N.V. * Written by Andreas Sikkema <andreas.sikkema@philips.com> * - * $Id: packet-rtp.c,v 1.23 2001/07/16 05:16:57 guy Exp $ + * $Id: packet-rtp.c,v 1.24 2001/09/03 10:33:06 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -194,12 +194,19 @@ static const value_string rtp_payload_type_vals[] = static address fake_addr; static int heur_init = FALSE; -static const char rtp_proto[] = "RTP"; - -void rtp_add_address( const unsigned char* ip_addr, int prt ) +void rtp_add_address( packet_info *pinfo, const unsigned char* ip_addr, + int prt ) { address src_addr; - conversation_t* pconv = ( conversation_t* ) NULL; + conversation_t* pconv; + + /* + * If this isn't the first time this packet has been processed, + * we've already done this work, so we don't need to do it + * again. + */ + if (pinfo->fd->flags.visited) + return; src_addr.type = AT_IPv4; src_addr.len = 4; @@ -222,10 +229,12 @@ void rtp_add_address( const unsigned char* ip_addr, int prt ) /* * If not, add + * XXX - use wildcard address and port B? */ if ( ! pconv ) { - conversation_new( &src_addr, &fake_addr, PT_UDP, (guint32) prt, - (guint32) 0, ( void * ) rtp_proto, 0 ); + pconv = conversation_new( &src_addr, &fake_addr, PT_UDP, + (guint32) prt, (guint32) 0, 0 ); + conversation_add_proto_data(pconv, proto_rtp, NULL); } } @@ -274,15 +283,11 @@ dissect_rtp_heur( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ) } /* - * An RTP conversation always contains data - */ - if ( pconv->data == NULL ) - return FALSE; - - /* - * An RTP conversation data always contains "RTP" + * An RTP conversation always has a data item for RTP. + * (Its existence is sufficient to indicate that this is an RTP + * conversation.) */ - if ( strcmp( pconv->data, rtp_proto ) != 0 ) + if (conversation_get_proto_data(pconv, proto_rtp) == NULL) return FALSE; dissect_rtp( tvb, pinfo, tree ); diff --git a/packet-rtp.h b/packet-rtp.h index 49254452c6..fb982031a5 100644 --- a/packet-rtp.h +++ b/packet-rtp.h @@ -3,7 +3,7 @@ * Routines for RTP dissection * RTP = Real time Transport Protocol * - * $Id: packet-rtp.h,v 1.4 2001/06/12 06:31:14 guy Exp $ + * $Id: packet-rtp.h,v 1.5 2001/09/03 10:33:06 guy Exp $ * * Copyright 2000, Philips Electronics N.V. * Written by Andreas Sikkema <andreas.sikkema@philips.com> @@ -27,7 +27,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -void rtp_add_address ( const unsigned char* ip_addr, int prt ); +void rtp_add_address ( packet_info *pinfo, const unsigned char* ip_addr, int prt ); gboolean dissect_rtp_heur ( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ); void dissect_rtp ( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ); void proto_register_rtp( void ); diff --git a/packet-rtsp.c b/packet-rtsp.c index d696b15351..f5eb2f54da 100644 --- a/packet-rtsp.c +++ b/packet-rtsp.c @@ -4,12 +4,11 @@ * Jason Lango <jal@netapp.com> * Liberally copied from packet-http.c, by Guy Harris <guy@alum.mit.edu> * - * $Id: packet-rtsp.c,v 1.40 2001/08/18 04:16:37 guy Exp $ + * $Id: packet-rtsp.c,v 1.41 2001/09/03 10:33:06 guy Exp $ * * Ethereal - Network traffic analyzer - * By Gerald Combs <gerald@zing.org> + * By Gerald Combs <gerald@ethereal.com> * 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 @@ -24,8 +23,6 @@ * 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. - * - * */ #include "config.h" @@ -266,14 +263,14 @@ rtsp_create_conversation(packet_info *pinfo, const u_char *line_begin, SET_ADDRESS(&null_addr, pinfo->src.type, 0, NULL); conv = conversation_new(&pinfo->dst, &null_addr, PT_UDP, c_data_port, - s_data_port, NULL, NO_ADDR2 | (!s_data_port ? NO_PORT2 : 0)); + s_data_port, NO_ADDR2 | (!s_data_port ? NO_PORT2 : 0)); conversation_set_dissector(conv, dissect_rtp); if (!c_mon_port) return; conv = conversation_new(&pinfo->dst, &null_addr, PT_UDP, c_mon_port, - s_mon_port, NULL, NO_ADDR2 | (!s_mon_port ? NO_PORT2 : 0)); + s_mon_port, NO_ADDR2 | (!s_mon_port ? NO_PORT2 : 0)); conversation_set_dissector(conv, dissect_rtcp); } diff --git a/packet-smb.c b/packet-smb.c index db62791dd5..476a5e3632 100644 --- a/packet-smb.c +++ b/packet-smb.c @@ -2,7 +2,7 @@ * Routines for smb packet dissection * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com> * - * $Id: packet-smb.c,v 1.111 2001/08/27 23:17:30 guy Exp $ + * $Id: packet-smb.c,v 1.112 2001/09/03 10:33:06 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -9799,7 +9799,7 @@ dissect_transact2_smb(const u_char *pd, int offset, frame_data *fd, proto_tree * if (conversation == NULL) { /* It's not part of any conversation - create a new one. */ conversation = conversation_new(&pi.src, &pi.dst, pi.ptype, - pi.srcport, pi.destport, NULL, 0); + pi.srcport, pi.destport, 0); } si.conversation = conversation; /* Save this for later */ @@ -10638,7 +10638,7 @@ dissect_transact_smb(const u_char *pd, int offset, frame_data *fd, if (conversation == NULL) { /* Create a new conversation */ conversation = conversation_new(&pi.src, &pi.dst, pi.ptype, - pi.srcport, pi.destport, NULL, 0); + pi.srcport, pi.destport, 0); } diff --git a/packet-smtp.c b/packet-smtp.c index 220b015243..94a092f471 100644 --- a/packet-smtp.c +++ b/packet-smtp.c @@ -1,7 +1,7 @@ /* packet-smtp.c * Routines for SMTP packet disassembly * - * $Id: packet-smtp.c,v 1.19 2001/07/03 04:56:46 guy Exp $ + * $Id: packet-smtp.c,v 1.20 2001/09/03 10:33:07 guy Exp $ * * Copyright (c) 2000 by Richard Sharpe <rsharpe@ns.aus.com> * @@ -220,8 +220,7 @@ dissect_smtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) pinfo->srcport, pinfo->destport, 0); if (conversation == NULL) { /* No conversation, create one */ conversation = conversation_new(&pinfo->src, &pinfo->dst, pinfo->ptype, - pinfo->srcport, pinfo->destport, NULL, - 0); + pinfo->srcport, pinfo->destport, 0); } diff --git a/packet-snmp.c b/packet-snmp.c index 40f6ecd894..9528ecc54a 100644 --- a/packet-snmp.c +++ b/packet-snmp.c @@ -8,7 +8,7 @@ * * See RFCs 1905, 1906, 1909, and 1910 for SNMPv2u. * - * $Id: packet-snmp.c,v 1.70 2001/09/03 08:19:12 guy Exp $ + * $Id: packet-snmp.c,v 1.71 2001/09/03 10:33:07 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -2130,8 +2130,7 @@ dissect_snmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) pinfo->srcport, 0, NO_PORT_B); if (conversation == NULL) { conversation = conversation_new(&pinfo->src, &pinfo->dst, PT_UDP, - pinfo->srcport, 0, NULL, - NO_PORT2); + pinfo->srcport, 0, NO_PORT2); conversation_set_dissector(conversation, dissect_snmp); } } diff --git a/packet-socks.c b/packet-socks.c index e478d7d555..ed79a3f3c5 100644 --- a/packet-socks.c +++ b/packet-socks.c @@ -2,7 +2,7 @@ * Routines for socks versions 4 &5 packet dissection * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com> * - * $Id: packet-socks.c,v 1.22 2001/09/03 08:27:56 guy Exp $ + * $Id: packet-socks.c,v 1.23 2001/09/03 10:33:07 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -375,7 +375,7 @@ static void socks_udp_dissector( const u_char *pd, int offset, frame_data *fd, g_assert( conversation); /* should always find a conversation */ - hash_info = (socks_hash_entry_t*)conversation->data; + hash_info = conversation_get_proto_data(conversation, proto_socks); if (check_col(fd, COL_PROTOCOL)) col_set_str(fd, COL_PROTOCOL, "Socks"); @@ -434,10 +434,11 @@ static void socks_udp_dissector( const u_char *pd, int offset, frame_data *fd, void new_udp_conversation( socks_hash_entry_t *hash_info){ conversation_t *conversation = conversation_new( &pi.src, &pi.dst, PT_UDP, - hash_info->udp_port, hash_info->port, hash_info, 0); - + hash_info->udp_port, hash_info->port, 0); + g_assert( conversation); + conversation_add_proto_data(conversation, proto_socks, hash_info); old_conversation_set_dissector(conversation, socks_udp_dissector); } @@ -826,14 +827,15 @@ static void state_machine_v5( socks_hash_entry_t *hash_info, const u_char *pd, offset += 3; /* skip to address type */ offset = get_address_v5( pd, offset, hash_info); - /* save server udp port and create upd conversation */ + /* save server udp port and create udp conversation */ if (!BYTES_ARE_IN_FRAME(offset, 2)){ hash_info->state = Done; return; } hash_info->udp_port = pntohs( &pd[ offset]); - new_udp_conversation( hash_info); + if (!fd->flags.visited) + new_udp_conversation( hash_info); /*$$ may need else statement to handle unknows and generate error message */ @@ -965,15 +967,12 @@ dissect_socks(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { conversation = find_conversation( &pi.src, &pi.dst, pi.ptype, pi.srcport, pi.destport, 0); - if ( conversation){ /* conversation found */ - hash_info = conversation->data; - if ( !hash_info){ /* exit if bad value */ - old_dissect_data(pd, offset, fd, tree); - return; - } - - /* new conversation create local data structure */ - } else { + if ( !conversation){ + conversation = conversation_new( &pi.src, &pi.dst, pi.ptype, + pi.srcport, pi.destport, 0); + } + hash_info = conversation_get_proto_data(conversation,proto_socks); + if ( !hash_info){ hash_info = g_mem_chunk_alloc(socks_vals); hash_info->start_done_row = G_MAXINT; hash_info->state = None; @@ -984,8 +983,8 @@ dissect_socks(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { ( hash_info->version != 5)) hash_info->state = Done; - conversation = conversation_new( &pi.src, &pi.dst, pi.ptype, - pi.srcport, pi.destport, hash_info, 0); + conversation_add_proto_data(conversation, proto_socks, + hash_info); /* set dissector for now */ old_conversation_set_dissector(conversation, dissect_socks); diff --git a/packet-ssl.c b/packet-ssl.c index 60e602732e..b63ea12e05 100644 --- a/packet-ssl.c +++ b/packet-ssl.c @@ -2,7 +2,7 @@ * Routines for ssl dissection * Copyright (c) 2000-2001, Scott Renfro <scott@renfro.org> * - * $Id: packet-ssl.c,v 1.5 2001/07/16 05:17:30 guy Exp $ + * $Id: packet-ssl.c,v 1.6 2001/09/03 10:33:07 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -514,6 +514,7 @@ dissect_ssl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { conversation_t *conversation; + void *conv_data; guint conv_version = SSL_VER_UNKNOWN; proto_item *ti = NULL; proto_tree *ssl_tree = NULL; @@ -538,12 +539,12 @@ dissect_ssl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { /* create a new conversation */ conversation = conversation_new(&pinfo->src, &pinfo->dst, pinfo->ptype, - pinfo->srcport, pinfo->destport, - (void*)SSL_VER_UNKNOWN, 0); + pinfo->srcport, pinfo->destport, 0); } - if (conversation) + conv_data = conversation_get_proto_data(conversation, proto_ssl); + if (conv_data != NULL) { - conv_version = (guint)conversation->data; + conv_version = (guint)conv_data; } /* Initialize the protocol column; we'll set it later when we @@ -657,8 +658,15 @@ dissect_ssl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) break; } + /* If we haven't already set the version information for + * this conversation, do so. */ + if (conv_data == NULL) + { + conv_data = (void *)conv_version; + conversation_add_proto_data(conversation, proto_ssl, conv_data); + } + /* set up for next record in frame, if any */ - conversation->data = (void*)conv_version; first_record_in_frame = FALSE; } @@ -1957,19 +1965,32 @@ static void ssl_set_conv_version(packet_info *pinfo, guint version) { conversation_t *conversation; + void *conv_data; + + if (pinfo->fd->flags.visited) + { + /* We've already processed this frame; no need to do any more + * work on it. + */ + return; + } + conversation = find_conversation(&pinfo->src, &pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0); - if (conversation) + if (conversation == NULL) { - conversation->data = (void*)version; + /* create a new conversation */ + conversation = conversation_new(&pinfo->src, &pinfo->dst, pinfo->ptype, + pinfo->srcport, pinfo->destport, 0); } - else + + if (conversation_get_proto_data(conversation, proto_ssl) != NULL) { - /* create a new conversation */ - conversation_new(&pinfo->src, &pinfo->dst, pinfo->ptype, - pinfo->srcport, pinfo->destport, (void*)version, 0); + /* get rid of the current data */ + conversation_delete_proto_data(conversation, proto_ssl); } + conversation_add_proto_data(conversation, proto_ssl, (void *)version); } static int diff --git a/packet-tftp.c b/packet-tftp.c index 0a39e99bb7..ae306ef378 100644 --- a/packet-tftp.c +++ b/packet-tftp.c @@ -5,7 +5,7 @@ * Craig Newell <CraigN@cheque.uq.edu.au> * RFC2347 TFTP Option Extension * - * $Id: packet-tftp.c,v 1.26 2001/06/18 02:17:53 guy Exp $ + * $Id: packet-tftp.c,v 1.27 2001/09/03 10:33:07 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -125,8 +125,7 @@ dissect_tftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) pinfo->srcport, 0, NO_PORT_B); if (conversation == NULL) { conversation = conversation_new(&pinfo->src, &pinfo->dst, PT_UDP, - pinfo->srcport, 0, NULL, - NO_PORT2); + pinfo->srcport, 0, NO_PORT2); conversation_set_dissector(conversation, dissect_tftp); } } diff --git a/packet-wcp.c b/packet-wcp.c index f8490021fe..3f8bcd4d6e 100644 --- a/packet-wcp.c +++ b/packet-wcp.c @@ -2,12 +2,11 @@ * Routines for Wellfleet Compression frame disassembly * Copyright 2001, Jeffrey C. Foster <jfoste@woodward.com> * - * $Id: packet-wcp.c,v 1.10 2001/06/18 02:17:54 guy Exp $ + * $Id: packet-wcp.c,v 1.11 2001/09/03 10:33:07 guy Exp $ * * Ethereal - Network traffic analyzer - * By Gerald Combs <gerald@zing.org> + * By Gerald Combs <gerald@ethereal.com> * Copyright 1998 - * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -470,21 +469,26 @@ wcp_window_t *get_wcp_window_ptr( packet_info *pinfo){ /* find the conversation for this side of the DLCI, create one if needed */ /* and return the wcp_window data structure pointer */ - conversation_t *conv = find_conversation( &pinfo->dl_src, &pinfo->dl_src, PT_NONE, + conversation_t *conv; + wcp_window_t *wcp_win_data; + + conv = find_conversation( &pinfo->dl_src, &pinfo->dl_src, PT_NONE, ((pinfo->pseudo_header->x25.flags & FROM_DCE)? 1:0), ((pinfo->pseudo_header->x25.flags & FROM_DCE)? 1:0), 0); - if ( !conv){ - conv = conversation_new( &pinfo->dl_src, &pinfo->dl_src, PT_NONE, ((pinfo->pseudo_header->x25.flags & FROM_DCE)? 1:0), ((pinfo->pseudo_header->x25.flags & FROM_DCE)? 1:0), - g_mem_chunk_alloc( wcp_window), 0); - - ((wcp_window_t*)conv->data)->buf_cur = ((wcp_window_t*)conv->data)->buffer; + 0); + } + wcp_win_data = conversation_get_proto_data(conv, proto_wcp); + if ( !wcp_win_data){ + wcp_win_data = g_mem_chunk_alloc( wcp_window); + wcp_win_data->buf_cur = wcp_win_data->buffer; + conversation_add_proto_data(conv, proto_wcp, wcp_win_data); } - return (wcp_window_t*)conv->data; + return wcp_win_data; } diff --git a/packet-wsp.c b/packet-wsp.c index 44f0212a1b..a3d987ff25 100644 --- a/packet-wsp.c +++ b/packet-wsp.c @@ -2,7 +2,7 @@ * * Routines to dissect WSP component of WAP traffic. * - * $Id: packet-wsp.c,v 1.32 2001/07/30 21:24:29 guy Exp $ + * $Id: packet-wsp.c,v 1.33 2001/09/03 10:33:07 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -881,8 +881,7 @@ dissect_redirect(tvbuff_t *tvb, int offset, packet_info *pinfo, PT_UDP, port_num, 0, NO_PORT_B); if (conv == NULL) { conv = conversation_new(&redir_address, - &pinfo->dst, PT_UDP, port_num, 0, - NULL, NO_PORT2); + &pinfo->dst, PT_UDP, port_num, 0, NO_PORT2); } conversation_set_dissector(conv, dissector); break; @@ -916,8 +915,7 @@ dissect_redirect(tvbuff_t *tvb, int offset, packet_info *pinfo, PT_UDP, port_num, 0, NO_PORT_B); if (conv == NULL) { conv = conversation_new(&redir_address, - &pinfo->dst, PT_UDP, port_num, 0, - NULL, NO_PORT2); + &pinfo->dst, PT_UDP, port_num, 0, NO_PORT2); } conversation_set_dissector(conv, dissector); break; |