aboutsummaryrefslogtreecommitdiffstats
path: root/epan/conversation.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2017-10-28 13:26:51 -0400
committerMichael Mann <mmann78@netscape.net>2017-10-28 19:22:24 +0000
commit7dbc520d57b8567738a15f617a11d9b5b70f40a7 (patch)
tree4b39448bd5f2243275f1d0590e0e1f0b4a3469dc /epan/conversation.c
parentdb3be9f850446c1a1c4894f5d08d67a370abf94a (diff)
Privatize the conversation_key structure
The intention is to make it more transparent when making a switch to an "endpoint" over address/port combination. Change-Id: Ic424c32095ecb103bcb4f7f4079c549de2c8d9c4 Reviewed-on: https://code.wireshark.org/review/24148 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/conversation.c')
-rw-r--r--epan/conversation.c76
1 files changed, 62 insertions, 14 deletions
diff --git a/epan/conversation.c b/epan/conversation.c
index bf81957b5f..21e8bf160a 100644
--- a/epan/conversation.c
+++ b/epan/conversation.c
@@ -36,6 +36,15 @@
int _debug_conversation_indent = 0;
#endif
+struct conversation_key {
+ struct conversation_key *next;
+ address addr1;
+ address addr2;
+ port_type ptype;
+ guint32 port1;
+ guint32 port2;
+};
+
/*
* Hash table for conversations with no wildcards.
*/
@@ -165,7 +174,7 @@ conversation_create_from_template(conversation_t *conversation, const address *a
guint
conversation_hash_exact(gconstpointer v)
{
- const conversation_key *key = (const conversation_key *)v;
+ const conversation_key_t key = (const conversation_key_t)v;
guint hash_val;
address tmp_addr;
@@ -195,8 +204,8 @@ conversation_hash_exact(gconstpointer v)
static gint
conversation_match_exact(gconstpointer v, gconstpointer w)
{
- const conversation_key *v1 = (const conversation_key *)v;
- const conversation_key *v2 = (const conversation_key *)w;
+ const conversation_key_t v1 = (const conversation_key_t)v;
+ const conversation_key_t v2 = (const conversation_key_t)w;
if (v1->ptype != v2->ptype)
return 0; /* different types of port */
@@ -248,7 +257,7 @@ conversation_match_exact(gconstpointer v, gconstpointer w)
static guint
conversation_hash_no_addr2(gconstpointer v)
{
- const conversation_key *key = (const conversation_key *)v;
+ const conversation_key_t key = (const conversation_key_t)v;
guint hash_val;
address tmp_addr;
@@ -279,8 +288,8 @@ conversation_hash_no_addr2(gconstpointer v)
static gint
conversation_match_no_addr2(gconstpointer v, gconstpointer w)
{
- const conversation_key *v1 = (const conversation_key *)v;
- const conversation_key *v2 = (const conversation_key *)w;
+ const conversation_key_t v1 = (const conversation_key_t)v;
+ const conversation_key_t v2 = (const conversation_key_t)w;
if (v1->ptype != v2->ptype)
return 0; /* different types of port */
@@ -313,7 +322,7 @@ conversation_match_no_addr2(gconstpointer v, gconstpointer w)
static guint
conversation_hash_no_port2(gconstpointer v)
{
- const conversation_key *key = (const conversation_key *)v;
+ const conversation_key_t key = (const conversation_key_t)v;
guint hash_val;
address tmp_addr;
@@ -343,8 +352,8 @@ conversation_hash_no_port2(gconstpointer v)
static gint
conversation_match_no_port2(gconstpointer v, gconstpointer w)
{
- const conversation_key *v1 = (const conversation_key *)v;
- const conversation_key *v2 = (const conversation_key *)w;
+ const conversation_key_t v1 = (const conversation_key_t)v;
+ const conversation_key_t v2 = (const conversation_key_t)w;
if (v1->ptype != v2->ptype)
return 0; /* different types of port */
@@ -377,7 +386,7 @@ conversation_match_no_port2(gconstpointer v, gconstpointer w)
static guint
conversation_hash_no_addr2_or_port2(gconstpointer v)
{
- const conversation_key *key = (const conversation_key *)v;
+ const conversation_key_t key = (const conversation_key_t)v;
guint hash_val;
address tmp_addr;
@@ -405,8 +414,8 @@ conversation_hash_no_addr2_or_port2(gconstpointer v)
static gint
conversation_match_no_addr2_or_port2(gconstpointer v, gconstpointer w)
{
- const conversation_key *v1 = (const conversation_key *)v;
- const conversation_key *v2 = (const conversation_key *)w;
+ const conversation_key_t v1 = (const conversation_key_t)v;
+ const conversation_key_t v2 = (const conversation_key_t)w;
if (v1->ptype != v2->ptype)
return 0; /* different types of port */
@@ -606,7 +615,7 @@ conversation_new(const guint32 setup_frame, const address *addr1, const address
*/
wmem_map_t* hashtable;
conversation_t *conversation=NULL;
- conversation_key *new_key;
+ conversation_key_t new_key;
DPRINT(("creating conversation for frame #%d: %s:%d -> %s:%d (ptype=%d)",
setup_frame, address_to_str(wmem_packet_scope(), addr1), port1,
@@ -737,7 +746,7 @@ conversation_lookup_hashtable(wmem_map_t *hashtable, const guint32 frame_num, co
conversation_t* convo=NULL;
conversation_t* match=NULL;
conversation_t* chain_head=NULL;
- conversation_key key;
+ struct conversation_key key;
/*
* We don't make a copy of the address data, we just copy the
@@ -1310,6 +1319,45 @@ get_conversation_hashtable_no_addr2_or_port2(void)
return conversation_hashtable_no_addr2_or_port2;
}
+address*
+conversation_key_addr1(const conversation_key_t key)
+{
+ return &key->addr1;
+}
+
+address*
+conversation_key_addr2(const conversation_key_t key)
+{
+ return &key->addr2;
+}
+
+guint32
+conversation_key_port1(const conversation_key_t key)
+{
+ return key->port1;
+}
+
+guint32
+conversation_key_port2(const conversation_key_t key)
+{
+ return key->port2;
+}
+
+gchar*
+conversation_get_html_hash(const conversation_key_t key)
+{
+ gchar *hash, *addr1, *addr2;
+
+ addr1 = address_to_str(NULL, &key->addr1);
+ addr2 = address_to_str(NULL, &key->addr2);
+ hash = wmem_strdup_printf(NULL, "<tr><td>%s</td><td>%d</td><td>%s</td><td>%d</td></tr>\n",
+ addr1, key->port1, addr2, key->port2);
+ wmem_free(NULL, addr1);
+ wmem_free(NULL, addr2);
+
+ return hash;
+}
+
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*