aboutsummaryrefslogtreecommitdiffstats
path: root/epan/conversation.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-05-11 10:40:53 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-05-11 10:40:53 +0000
commitfcab322ada6b72863c18bfbf92cb7324c312529a (patch)
tree4a98b2534f93e14a8a47f11a20fb930fed85b87f /epan/conversation.c
parente3e4f52245627029b832875a5bbf438350484678 (diff)
Some applications do very naughty things like reusing a port for a different protocol during different stages of an application cycle.
This is very naughty and will cause problems when we have assigned a dissector to a dynamic port using conversation_set_dissector(). To make ethereal handle this case I have changed the try_conversation_dissector() to allow it to fail and return 0, meaning yes there is indeed a protocol registered for this conversation but that protocol rejected this packet. (which only happens for "new" style dissectors, "old" style dissectors will never reject a packet that way) When this happens the decode_udp_port() helper will still allow other dissectors to be tried, in the hope that the conversation is now used for some other protocol and thus someone else might be able to decode the packet. Update SNMP and TFTP dissectors to check that even if there already is a conversation but that conversation does NOT have snmp/tftp registered as the dissector for it, then create a new conversation anyway and attach the proper dissector. Since ethereal keeps track of which frame number a conversation started in, this actually works really well. svn path=/trunk/; revision=14345
Diffstat (limited to 'epan/conversation.c')
-rw-r--r--epan/conversation.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/epan/conversation.c b/epan/conversation.c
index 17fb491aef..3911b9e682 100644
--- a/epan/conversation.c
+++ b/epan/conversation.c
@@ -1119,8 +1119,7 @@ conversation_delete_proto_data(conversation_t *conv, int proto)
}
void
-conversation_set_dissector(conversation_t *conversation,
- dissector_handle_t handle)
+conversation_set_dissector(conversation_t *conversation, dissector_handle_t handle)
{
conversation->dissector_handle = handle;
}
@@ -1129,6 +1128,11 @@ conversation_set_dissector(conversation_t *conversation,
* Given two address/port pairs for a packet, search for a matching
* conversation and, if found and it has a conversation dissector,
* call that dissector and return TRUE, otherwise return FALSE.
+ *
+ * This helper uses call_dissector_only which will NOT call the default
+ * "data" dissector if the packet was rejected.
+ * Our caller is responsible to call the data dissector explicitely in case
+ * this function returns FALSE.
*/
gboolean
try_conversation_dissector(address *addr_a, address *addr_b, port_type ptype,
@@ -1141,10 +1145,18 @@ try_conversation_dissector(address *addr_a, address *addr_b, port_type ptype,
port_b, 0);
if (conversation != NULL) {
+ int ret;
if (conversation->dissector_handle == NULL)
return FALSE;
- call_dissector(conversation->dissector_handle, tvb, pinfo,
+ ret=call_dissector_only(conversation->dissector_handle, tvb, pinfo,
tree);
+ if(!ret) {
+ /* this packet was rejected by the dissector
+ * so return FALSE in case our caller wants
+ * to do some cleaning up.
+ */
+ return FALSE;
+ }
return TRUE;
}
return FALSE;