diff options
author | Michael Mann <mmann78@netscape.net> | 2017-10-28 11:15:44 -0400 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-10-28 16:00:46 +0000 |
commit | 7df5fcdc51cb2616dc7ec97187e73ab7ecccc7b3 (patch) | |
tree | 4005bf11a9e1d0a369f6df46b95b5d210e54ca0e | |
parent | 23afd9a18453c23cfbbc6a63f52b2e6e64e0056c (diff) |
Share use of conversation_hash_exact
It was duplicated in GTK, so just make it public (at least for now)
Change-Id: I89d985b2d42f0edb1c535a65a97b132920dedbcd
Reviewed-on: https://code.wireshark.org/review/24146
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r-- | debian/libwireshark0.symbols | 1 | ||||
-rw-r--r-- | epan/conversation.c | 2 | ||||
-rw-r--r-- | epan/conversation.h | 2 | ||||
-rw-r--r-- | ui/gtk/conversation_hastables_dlg.c | 59 |
4 files changed, 4 insertions, 60 deletions
diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols index ae1f0585d9..7dcbe28790 100644 --- a/debian/libwireshark0.symbols +++ b/debian/libwireshark0.symbols @@ -155,6 +155,7 @@ libwireshark.so.0 libwireshark0 #MINVER# conversation_filter_from_packet@Base 2.2.8 conversation_get_dissector@Base 2.0.0 conversation_get_proto_data@Base 1.9.1 + conversation_hash_exact@Base 2.5.0 conversation_new@Base 1.9.1 conversation_set_dissector@Base 1.9.1 conversation_set_dissector_from_frame_number@Base 2.0.0 diff --git a/epan/conversation.c b/epan/conversation.c index 63c5b8de1d..bf81957b5f 100644 --- a/epan/conversation.c +++ b/epan/conversation.c @@ -162,7 +162,7 @@ conversation_create_from_template(conversation_t *conversation, const address *a /* http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx#existing * One-at-a-Time hash */ -static guint +guint conversation_hash_exact(gconstpointer v) { const conversation_key *key = (const conversation_key *)v; diff --git a/epan/conversation.h b/epan/conversation.h index 3ddc3ec813..a2f90133a9 100644 --- a/epan/conversation.h +++ b/epan/conversation.h @@ -204,6 +204,8 @@ wmem_map_t * get_conversation_hashtable_no_port2(void); WS_DLL_PUBLIC wmem_map_t *get_conversation_hashtable_no_addr2_or_port2(void); +WS_DLL_PUBLIC guint +conversation_hash_exact(gconstpointer v); #ifdef __cplusplus } diff --git a/ui/gtk/conversation_hastables_dlg.c b/ui/gtk/conversation_hastables_dlg.c index 04f8f581dc..c4f9e7cc02 100644 --- a/ui/gtk/conversation_hastables_dlg.c +++ b/ui/gtk/conversation_hastables_dlg.c @@ -40,65 +40,6 @@ static GtkWidget *conversation_hastables_dlg_w = NULL; #define CONV_STR_BUF_MAX 1024 -/* - * Compute the hash value for two given address/port pairs if the match - * is to be exact. - */ -/* http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx#existing - * One-at-a-Time hash - */ -static guint -conversation_hash_exact(gconstpointer v) -{ - const conversation_key *key = (const conversation_key *)v; - guint hash_val; - int i; - const guint8 *add_address_to_hash_data; - - hash_val = 0; -#if 0 - hash_val = add_address_to_hash(hash_val, &key->addr1); - hash_val += key->port1; - hash_val = add_address_to_hash(hash_val, &key->addr2); - hash_val += key->port2; - - return hash_val; -#endif - for ( i = 0; i < key->addr1.len; i++ ) { - add_address_to_hash_data = (const guint8 *)((&key->addr1)->data); - hash_val += add_address_to_hash_data[i]; - hash_val += ( hash_val << 10 ); - hash_val ^= ( hash_val >> 6 ); - } - - for ( i = 0; i < 4; i++ ) { - add_address_to_hash_data = (const guint8 *)(&key->port1); - hash_val += add_address_to_hash_data[i]; - hash_val += ( hash_val << 10 ); - hash_val ^= ( hash_val >> 6 ); - } - - for ( i = 0; i < key->addr2.len; i++ ) { - add_address_to_hash_data = (const guint8 *)((&key->addr2)->data); - hash_val += add_address_to_hash_data[i]; - hash_val += ( hash_val << 10 ); - hash_val ^= ( hash_val >> 6 ); - } - - for ( i = 0; i < 4; i++ ) { - add_address_to_hash_data = (const guint8 *)(&key->port2); - hash_val += add_address_to_hash_data[i]; - hash_val += ( hash_val << 10 ); - hash_val ^= ( hash_val >> 6 ); - } - - hash_val += ( hash_val << 3 ); - hash_val ^= ( hash_val >> 11 ); - hash_val += ( hash_val << 15 ); - - return hash_val; -} - static guint conversation_hash_exact_old(gconstpointer v) { |