aboutsummaryrefslogtreecommitdiffstats
path: root/epan/conversation.c
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2014-03-05 10:56:33 -0500
committerAnders Broman <a.broman58@gmail.com>2014-03-21 05:15:57 +0000
commita04f610989400f76beaa7709b0e7fa1bce2109a7 (patch)
tree426bef8a3e3f4357d6d0f347c70fae223004e593 /epan/conversation.c
parent9c5f1990504ba804df76157595248b7e90edf109 (diff)
Add debug printing functions for conversations, sip, sdp, rtp
There have been enough gnarly bus in sip/sdp/rtp that it needs to have good debug printing. Using a debugger isn't good enough because there's interaction across multiple frames and it's too hard to follow what's going on without real printed data history. Change-Id: Ifb5bb1fb580be81f988569ece79d238a9c030c34 Reviewed-on: https://code.wireshark.org/review/688 Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/conversation.c')
-rw-r--r--epan/conversation.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/epan/conversation.c b/epan/conversation.c
index b2d731757e..52d8ee18e0 100644
--- a/epan/conversation.c
+++ b/epan/conversation.c
@@ -30,6 +30,14 @@
#include "emem.h"
#include "conversation.h"
+/* define DEBUG_CONVERSATION for pretty debug printing */
+/* #define DEBUG_CONVERSATION */
+#include "conversation_debug.h"
+
+#ifdef DEBUG_CONVERSATION
+int _debug_conversation_indent = 0;
+#endif
+
/*
* Hash table for conversations with no wildcards.
*/
@@ -551,9 +559,11 @@ conversation_insert_into_hashtable(GHashTable *hashtable, conversation_t *conv)
conv->next = NULL;
conv->last = conv;
g_hash_table_insert(hashtable, conv->key_ptr, conv);
+ DPRINT(("created a new conversation chain"));
}
else {
/* There's an existing chain for this key */
+ DPRINT(("there's an existing conversation chain"));
chain_tail = chain_head->last;
@@ -666,6 +676,10 @@ conversation_new(const guint32 setup_frame, const address *addr1, const address
conversation_t *conversation=NULL;
conversation_key *new_key;
+ DPRINT(("creating conversation for frame #%d: %s:%d -> %s:%d (ptype=%d)",
+ setup_frame, ep_address_to_str(addr1), port1,
+ ep_address_to_str(addr2), port2, ptype));
+
if (options & NO_ADDR2) {
if (options & (NO_PORT2|NO_PORT2_FORCE)) {
hashtable = conversation_hashtable_no_addr2_or_port2;
@@ -705,7 +719,9 @@ conversation_new(const guint32 setup_frame, const address *addr1, const address
new_index++;
+ DINDENT();
conversation_insert_into_hashtable(hashtable, conversation);
+ DENDENT();
return conversation;
}
@@ -720,12 +736,15 @@ conversation_set_port2(conversation_t *conv, const guint32 port)
DISSECTOR_ASSERT_HINT(!(conv->options & CONVERSATION_TEMPLATE),
"Use the conversation_create_from_template function when the CONVERSATION_TEMPLATE bit is set in the options mask");
+ DPRINT(("called for port=%d", port));
+
/*
* If the port 2 value is not wildcarded, don't set it.
*/
if ((!(conv->options & NO_PORT2)) || (conv->options & NO_PORT2_FORCE))
return;
+ DINDENT();
if (conv->options & NO_ADDR2) {
conversation_remove_from_hashtable(conversation_hashtable_no_addr2_or_port2, conv);
} else {
@@ -738,6 +757,7 @@ conversation_set_port2(conversation_t *conv, const guint32 port)
} else {
conversation_insert_into_hashtable(conversation_hashtable_exact, conv);
}
+ DENDENT();
}
/*
@@ -750,12 +770,15 @@ conversation_set_addr2(conversation_t *conv, const address *addr)
DISSECTOR_ASSERT_HINT(!(conv->options & CONVERSATION_TEMPLATE),
"Use the conversation_create_from_template function when the CONVERSATION_TEMPLATE bit is set in the options mask");
+ DPRINT(("called for addr=%s",ep_address_to_str(addr)));
+
/*
* If the address 2 value is not wildcarded, don't set it.
*/
if (!(conv->options & NO_ADDR2))
return;
+ DINDENT();
if (conv->options & NO_PORT2) {
conversation_remove_from_hashtable(conversation_hashtable_no_addr2_or_port2, conv);
} else {
@@ -768,6 +791,7 @@ conversation_set_addr2(conversation_t *conv, const address *addr)
} else {
conversation_insert_into_hashtable(conversation_hashtable_exact, conv);
}
+ DENDENT();
}
/*
@@ -868,12 +892,14 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
* Neither search address B nor search port B are wildcarded,
* start out with an exact match.
*/
+ DPRINT(("trying exact match"));
conversation =
conversation_lookup_hashtable(conversation_hashtable_exact,
frame_num, addr_a, addr_b, ptype,
port_a, port_b);
/* Didn't work, try the other direction */
if (conversation == NULL) {
+ DPRINT(("trying opposite direction"));
conversation =
conversation_lookup_hashtable(conversation_hashtable_exact,
frame_num, addr_b, addr_a, ptype,
@@ -888,6 +914,7 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
frame_num, addr_b, addr_a, ptype,
port_a, port_b);
}
+ DPRINT(("exact match %sfound",conversation?"":"not "));
if (conversation != NULL)
return conversation;
}
@@ -906,6 +933,7 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
* address and port.
* ("addr_b" doesn't take part in this lookup.)
*/
+ DPRINT(("trying wildcarded dest address"));
conversation =
conversation_lookup_hashtable(conversation_hashtable_no_addr2,
frame_num, addr_a, addr_b, ptype, port_a, port_b);
@@ -930,6 +958,7 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
* don't get packets in a given direction coming from more than one
* address, unless the CONVERSATION_TEMPLATE option is set.)
*/
+ DPRINT(("wildcarded dest address match found"));
if (!(conversation->options & NO_ADDR_B) && ptype != PT_UDP)
{
if(!(conversation->options & CONVERSATION_TEMPLATE))
@@ -956,6 +985,7 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
* ("addr_a" doesn't take part in this lookup.)
*/
if (!(options & NO_ADDR_B)) {
+ DPRINT(("trying dest addr:port as source addr:port with wildcarded dest addr"));
conversation =
conversation_lookup_hashtable(conversation_hashtable_no_addr2,
frame_num, addr_b, addr_a, ptype, port_b, port_a);
@@ -968,6 +998,7 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
* wildcarded second address for this
* conversation.
*/
+ DPRINT(("match found"));
if (ptype != PT_UDP) {
if(!(conversation->options & CONVERSATION_TEMPLATE))
{
@@ -998,6 +1029,7 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
* address and port.
* ("port_b" doesn't take part in this lookup.)
*/
+ DPRINT(("trying wildcarded dest port"));
conversation =
conversation_lookup_hashtable(conversation_hashtable_no_port2,
frame_num, addr_a, addr_b, ptype, port_a, port_b);
@@ -1021,6 +1053,7 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
* get packets in a given direction coming from more than one port,
* unless the CONVERSATION_TEMPLATE option is set.)
*/
+ DPRINT(("match found"));
if (!(conversation->options & NO_PORT_B) && ptype != PT_UDP)
{
if(!(conversation->options & CONVERSATION_TEMPLATE))
@@ -1047,6 +1080,7 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
* ("port_a" doesn't take part in this lookup.)
*/
if (!(options & NO_PORT_B)) {
+ DPRINT(("trying dest addr:port as source addr:port and wildcarded dest port"));
conversation =
conversation_lookup_hashtable(conversation_hashtable_no_port2,
frame_num, addr_b, addr_a, ptype, port_b, port_a);
@@ -1059,6 +1093,7 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
* wildcarded second address for this
* conversation.
*/
+ DPRINT(("match found"));
if (ptype != PT_UDP)
{
if(!(conversation->options & CONVERSATION_TEMPLATE))
@@ -1084,6 +1119,7 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
* and port A as the first address and port.
* (Neither "addr_b" nor "port_b" take part in this lookup.)
*/
+ DPRINT(("trying wildcarding dest addr:port"));
conversation =
conversation_lookup_hashtable(conversation_hashtable_no_addr2_or_port2,
frame_num, addr_a, addr_b, ptype, port_a, port_b);
@@ -1101,6 +1137,7 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
* as that's the port that matched the wildcarded
* second port for this conversation.
*/
+ DPRINT(("match found"));
if (ptype != PT_UDP)
{
if(!(conversation->options & CONVERSATION_TEMPLATE))
@@ -1128,6 +1165,7 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
* first packet in the conversation).
* (Neither "addr_a" nor "port_a" take part in this lookup.)
*/
+ DPRINT(("trying dest addr:port as source addr:port and wildcarding dest addr:port"));
if (addr_a->type == AT_FC)
conversation =
conversation_lookup_hashtable(conversation_hashtable_no_addr2_or_port2,
@@ -1146,6 +1184,7 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
* that matched the wildcarded second port for this
* conversation.
*/
+ DPRINT(("match found"));
if (ptype != PT_UDP)
{
if(!(conversation->options & CONVERSATION_TEMPLATE))
@@ -1161,6 +1200,8 @@ find_conversation(const guint32 frame_num, const address *addr_a, const address
return conversation;
}
+ DPRINT(("no matches found"));
+
/*
* We found no conversation.
*/
@@ -1288,20 +1329,33 @@ find_or_create_conversation(packet_info *pinfo)
{
conversation_t *conv=NULL;
+ DPRINT(("called for frame #%d: %s:%d -> %s:%d (ptype=%d)",
+ pinfo->fd->num, ep_address_to_str(&pinfo->src), pinfo->srcport,
+ ep_address_to_str(&pinfo->dst), pinfo->destport, pinfo->ptype));
+ DINDENT();
+
/* Have we seen this conversation before? */
if((conv = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
pinfo->ptype, pinfo->srcport,
pinfo->destport, 0)) != NULL) {
+ DPRINT(("found previous conversation for frame #%d (last_frame=%d)",
+ pinfo->fd->num, conv->last_frame));
if (pinfo->fd->num > conv->last_frame) {
conv->last_frame = pinfo->fd->num;
}
} else {
/* No, this is a new conversation. */
+ DPRINT(("did not find previous conversation for frame #%d",
+ pinfo->fd->num));
+ DINDENT();
conv = conversation_new(pinfo->fd->num, &pinfo->src,
&pinfo->dst, pinfo->ptype,
pinfo->srcport, pinfo->destport, 0);
+ DENDENT();
}
+ DENDENT();
+
return conv;
}