From 73256b3fb7d9572fbc8918124fffe02f5ddf639f Mon Sep 17 00:00:00 2001 From: John Thacker Date: Sat, 12 Jun 2021 11:25:37 -0400 Subject: [PATCH] Remove lingering circuit API from stream.h The circuit API was removed and replaced with the conversation "_by_id" API that uses a single uint32 value by commit 800b26edbe34e135cc9be1d4395db2c13ae1213f Remove the lingering references to circuits from the stream API, since it's just used with conversations now. --- debian/libwireshark0.symbols | 4 +- epan/dissectors/packet-dvb-s2-bb.c | 4 +- epan/dissectors/packet-h223.c | 4 +- epan/stream.c | 79 ++++++------------------------ epan/stream.h | 11 ++--- 5 files changed, 24 insertions(+), 78 deletions(-) diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols index b1e136cc7e..f94782b29f 100644 --- a/debian/libwireshark0.symbols +++ b/debian/libwireshark0.symbols @@ -653,7 +653,7 @@ libwireshark.so.0 libwireshark0 #MINVER# find_or_create_conversation_by_id@Base 2.6.3 find_protocol_by_id@Base 1.9.1 find_sid_name@Base 1.9.1 - find_stream_circ@Base 1.9.1 + find_stream@Base 3.5.0 find_tap_id@Base 1.9.1 follow_get_stat_tap_string@Base 2.1.0 follow_info_free@Base 2.3.0 @@ -1569,7 +1569,7 @@ libwireshark.so.0 libwireshark0 #MINVER# str_to_val_idx@Base 1.9.1 stream_add_frag@Base 1.9.1 stream_find_frag@Base 1.9.1 - stream_new_circ@Base 1.9.1 + stream_new@Base 3.5.0 stream_process_reassembled@Base 1.9.1 string_or_null@Base 1.9.1 string_replace@Base 1.9.1 diff --git a/epan/dissectors/packet-dvb-s2-bb.c b/epan/dissectors/packet-dvb-s2-bb.c index c61263dbe4..367aa70632 100644 --- a/epan/dissectors/packet-dvb-s2-bb.c +++ b/epan/dissectors/packet-dvb-s2-bb.c @@ -1794,9 +1794,9 @@ static int dissect_dvb_s2_bb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree if (dvb_s2_df_dissection && user_packet_length) { sync_tvb = tvb_new_subset_length(tvb, DVB_S2_BB_OFFS_SYNC, 1); tsp_tvb = tvb_new_composite(); - ts_stream = find_stream_conv(subcircuit, pinfo->p2p_dir); + ts_stream = find_stream(subcircuit, pinfo->p2p_dir); if (ts_stream == NULL) { - ts_stream = stream_new_conv(subcircuit, pinfo->p2p_dir); + ts_stream = stream_new(subcircuit, pinfo->p2p_dir); } if (syncd == 0xFFFF) { /* Largely theoretical for TS (cf. Generic Packetized, GSE-HEM) diff --git a/epan/dissectors/packet-h223.c b/epan/dissectors/packet-h223.c index e971aa3615..2c8f0548d2 100644 --- a/epan/dissectors/packet-h223.c +++ b/epan/dissectors/packet-h223.c @@ -753,9 +753,9 @@ dissect_mux_sdu_fragment(tvbuff_t *volatile next_tvb, packet_info *pinfo, stream_t *substream; stream_pdu_fragment_t *frag; - substream = find_stream_conv(subcircuit,pinfo->p2p_dir); + substream = find_stream(subcircuit,pinfo->p2p_dir); if(substream == NULL ) - substream = stream_new_conv(subcircuit,pinfo->p2p_dir); + substream = stream_new(subcircuit,pinfo->p2p_dir); frag = stream_find_frag(substream,pinfo->num,pkt_offset); if(frag == NULL ) { diff --git a/epan/stream.c b/epan/stream.c index c65e50af9b..153cd66ea6 100644 --- a/epan/stream.c +++ b/epan/stream.c @@ -63,13 +63,8 @@ struct stream { /* key */ typedef struct stream_key { - /* streams can be attached to circuits or conversations, and we note - that here */ - gboolean is_circuit; - union { - const struct circuit *circuit; - const struct conversation *conv; - } circ; + /* streams are attached to conversations */ + const struct conversation *conv; int p2p_dir; } stream_key_t; @@ -79,8 +74,7 @@ static guint stream_hash_func(gconstpointer k) { const stream_key_t *key = (const stream_key_t *)k; - /* is_circuit is redundant to the circuit/conversation pointer */ - return (GPOINTER_TO_UINT(key->circ.circuit)) ^ key->p2p_dir; + return (GPOINTER_TO_UINT(key->conv)) ^ key->p2p_dir; } /* compare func */ @@ -89,14 +83,10 @@ static gboolean stream_compare_func(gconstpointer a, { const stream_key_t *key1 = (const stream_key_t *)a; const stream_key_t *key2 = (const stream_key_t *)b; - if( key1 -> p2p_dir != key2 -> p2p_dir || - key1-> is_circuit != key2 -> is_circuit ) + if( key1 -> p2p_dir != key2 -> p2p_dir) return FALSE; - if( key1 -> is_circuit ) - return (key1 -> circ.circuit == key2 -> circ.circuit ); - else - return (key1 -> circ.conv == key2 -> circ.conv ); + return (key1 -> conv == key2 -> conv ); } /* the hash table */ @@ -119,20 +109,10 @@ static void init_stream_hash( void ) { } /* lookup function, returns null if not found */ -static stream_t *stream_hash_lookup_circ( const struct circuit *circuit, int p2p_dir ) +static stream_t *stream_hash_lookup( const struct conversation *conv, int p2p_dir ) { stream_key_t key; - key.is_circuit=TRUE; - key.circ.circuit=circuit; - key.p2p_dir=p2p_dir; - return (stream_t *)g_hash_table_lookup(stream_hash, &key); -} - -static stream_t *stream_hash_lookup_conv( const struct conversation *conv, int p2p_dir ) -{ - stream_key_t key; - key.is_circuit=FALSE; - key.circ.conv = conv; + key.conv = conv; key.p2p_dir=p2p_dir; return (stream_t *)g_hash_table_lookup(stream_hash, &key); } @@ -155,25 +135,12 @@ static stream_t *new_stream( stream_key_t *key ) /* insert function */ -static stream_t *stream_hash_insert_circ( const struct circuit *circuit, int p2p_dir ) +static stream_t *stream_hash_insert( const struct conversation *conv, int p2p_dir ) { stream_key_t *key; key = wmem_new(wmem_file_scope(), stream_key_t); - key->is_circuit = TRUE; - key->circ.circuit = circuit; - key->p2p_dir = p2p_dir; - - return new_stream(key); -} - -static stream_t *stream_hash_insert_conv( const struct conversation *conv, int p2p_dir ) -{ - stream_key_t *key; - - key = wmem_new(wmem_file_scope(), stream_key_t); - key->is_circuit = FALSE; - key->circ.conv = conv; + key->conv = conv; key->p2p_dir = p2p_dir; return new_stream(key); @@ -303,30 +270,16 @@ static reassembly_table stream_reassembly_table; /* Initialise a new stream. Call this when you first identify a distinct * stream. */ -stream_t *stream_new_circ ( const struct circuit *circuit, int p2p_dir ) -{ - stream_t * stream; - - /* we don't want to replace the previous data if we get called twice on the - same circuit, so do a lookup first */ - stream = stream_hash_lookup_circ(circuit, p2p_dir); - DISSECTOR_ASSERT( stream == NULL ); - - stream = stream_hash_insert_circ(circuit, p2p_dir); - - return stream; -} - -stream_t *stream_new_conv ( const struct conversation *conv, int p2p_dir ) +stream_t *stream_new ( const struct conversation *conv, int p2p_dir ) { stream_t * stream; /* we don't want to replace the previous data if we get called twice on the same conversation, so do a lookup first */ - stream = stream_hash_lookup_conv(conv, p2p_dir); + stream = stream_hash_lookup(conv, p2p_dir); DISSECTOR_ASSERT( stream == NULL ); - stream = stream_hash_insert_conv(conv, p2p_dir); + stream = stream_hash_insert(conv, p2p_dir); return stream; } @@ -335,13 +288,9 @@ stream_t *stream_new_conv ( const struct conversation *conv, int p2p_dir ) * * Returns null if no matching stream was found. */ -stream_t *find_stream_circ ( const struct circuit *circuit, int p2p_dir ) +stream_t *find_stream ( const struct conversation *conv, int p2p_dir ) { - return stream_hash_lookup_circ(circuit,p2p_dir); -} -stream_t *find_stream_conv ( const struct conversation *conv, int p2p_dir ) -{ - return stream_hash_lookup_conv(conv,p2p_dir); + return stream_hash_lookup(conv,p2p_dir); } /* cleanup the stream routines */ diff --git a/epan/stream.h b/epan/stream.h index fd36b046ea..5e741c4bbf 100644 --- a/epan/stream.h +++ b/epan/stream.h @@ -49,21 +49,18 @@ typedef struct stream stream_t; typedef struct stream_pdu_fragment stream_pdu_fragment_t; - -struct circuit; struct conversation; /* initialise a new stream. Call this when you first identify a distinct - * stream. The circit pointer is just used as a key to look up the stream. */ -WS_DLL_PUBLIC stream_t *stream_new_circ ( const struct circuit *circuit, int p2p_dir ); -extern stream_t *stream_new_conv ( const struct conversation *conv, int p2p_dir ); + * stream. The conversation pointer is just used as a key to look up the stream. + */ +WS_DLL_PUBLIC stream_t *stream_new ( const struct conversation *conv, int p2p_dir ); /* retrieve a previously-created stream. * * Returns null if no matching stream was found. */ -WS_DLL_PUBLIC stream_t *find_stream_circ ( const struct circuit *circuit, int p2p_dir ); -extern stream_t *find_stream_conv ( const struct conversation *conv, int p2p_dir ); +WS_DLL_PUBLIC stream_t *find_stream ( const struct conversation *conv, int p2p_dir );