From d950b14f26432dae1e805853ca90dd35ef4984cf Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 31 Jul 2018 14:14:04 -0700 Subject: [PATCH] For ISDN, don't create an endpoint by ID and then use it. That isn't working, because it depends on the notion that for every "endpoint type" there's a "port type" for the packet_info structure; that's not true for ISDN channels. The whole point of "use the packet_info structure when trying to find a conversation and create it if it doesn't exist" is to use address information *already filled in by somebody for use by other dissectors*; we don't do that with the ISDN channel number, because there's no *need* to do so. So just add a new find_or_create_conversation_by_id() routine, which passes the packet_info structure to get the frame number, and explicitly passes the endpoint type and ID. Use that in the ISDN dissector. Bug: 15018 Change-Id: Id0e997254b0eaf7cbc9261a2adff639ecbf083c0 Reviewed-on: https://code.wireshark.org/review/28904 Reviewed-by: Guy Harris --- debian/libwireshark0.symbols | 1 + epan/conversation.c | 20 ++++++++++++++++++++ epan/conversation.h | 6 ++++++ epan/dissectors/packet-isdn.c | 5 ++--- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols index e7ebc510a9..9392832a4b 100644 --- a/debian/libwireshark0.symbols +++ b/debian/libwireshark0.symbols @@ -630,6 +630,7 @@ libwireshark.so.0 libwireshark0 #MINVER# find_heur_dissector_by_unique_short_name@Base 1.99.8 find_heur_dissector_list@Base 1.99.2 find_or_create_conversation@Base 1.9.1 + 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 diff --git a/epan/conversation.c b/epan/conversation.c index b2a8ef8b1b..fc94e3d65b 100644 --- a/epan/conversation.c +++ b/epan/conversation.c @@ -1508,6 +1508,26 @@ find_or_create_conversation(packet_info *pinfo) return conv; } +conversation_t * +find_or_create_conversation_by_id(packet_info *pinfo, const endpoint_type etype, const guint32 id) +{ + conversation_t *conv=NULL; + + /* Have we seen this conversation before? */ + if ((conv = find_conversation_by_id(pinfo->num, etype, id, 0)) == NULL) { + /* No, this is a new conversation. */ + DPRINT(("did not find previous conversation for frame #%u", + pinfo->num)); + DINDENT(); + conv = conversation_new_by_id(pinfo->num, etype, id, 0); + DENDENT(); + } + + DENDENT(); + + return conv; +} + void conversation_create_endpoint(struct _packet_info *pinfo, address* addr1, address* addr2, endpoint_type etype, guint32 port1, guint32 port2, const guint options) { diff --git a/epan/conversation.h b/epan/conversation.h index 0059703868..d345fe19e3 100644 --- a/epan/conversation.h +++ b/epan/conversation.h @@ -188,6 +188,12 @@ WS_DLL_PUBLIC conversation_t *find_conversation_pinfo(packet_info *pinfo, const */ WS_DLL_PUBLIC conversation_t *find_or_create_conversation(packet_info *pinfo); +/** A helper function that calls find_conversation_by_id() and, if a + * conversation is not found, calls conversation_new_by_id(). + * The frame number is taken from pinfo. + */ +WS_DLL_PUBLIC conversation_t *find_or_create_conversation_by_id(packet_info *pinfo, const endpoint_type etype, const guint32 id); + WS_DLL_PUBLIC void conversation_add_proto_data(conversation_t *conv, const int proto, void *proto_data); WS_DLL_PUBLIC void *conversation_get_proto_data(const conversation_t *conv, const int proto); diff --git a/epan/dissectors/packet-isdn.c b/epan/dissectors/packet-isdn.c index 846996b278..a2171eed83 100644 --- a/epan/dissectors/packet-isdn.c +++ b/epan/dissectors/packet-isdn.c @@ -96,8 +96,6 @@ dissect_isdn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "Network"); } - conversation_create_endpoint_by_id(pinfo, ENDPOINT_ISDN, pinfo->pseudo_header->isdn.channel, 0); - if (tree) { ti = proto_tree_add_item(tree, proto_isdn, tvb, 0, 0, ENC_NA); isdn_tree = proto_item_add_subtree(ti, ett_isdn); @@ -109,7 +107,8 @@ dissect_isdn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ /* * Set up a circuit for this channel, and assign it a dissector. */ - conv = find_or_create_conversation(pinfo); + conv = find_or_create_conversation_by_id(pinfo, ENDPOINT_ISDN, + pinfo->pseudo_header->isdn.channel); if (conversation_get_dissector(conv, 0) == NULL) { /*