Have find_or_create_conversation() use pinfo->conv_endpoint if present.
authorGuy Harris <guy@alum.mit.edu>
Tue, 31 Jul 2018 22:52:46 +0000 (15:52 -0700)
committerGuy Harris <guy@alum.mit.edu>
Tue, 31 Jul 2018 22:53:27 +0000 (22:53 +0000)
Add conversation_new_pinfo(), which uses the endpoint if present, and
have find_or_create_conversation() use it rather than
conversation_new().

Remove find_or_create_conversation_by_id() - it's no longer needed.

Bug: 15018
Change-Id: Ib13e539751af0f071aede4ee0ed751d0cb72ba3f
Reviewed-on: https://code.wireshark.org/review/28908
Reviewed-by: Guy Harris <guy@alum.mit.edu>
debian/libwireshark0.symbols
epan/conversation.c
epan/conversation.h
epan/dissectors/packet-isdn.c

index de8897f2ac2c024b99c70df7fdc2d1f473883d4e..2c745b0aa01cfffd1675cf7a92687ee68a83f85f 100644 (file)
@@ -164,6 +164,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
  conversation_key_port2@Base 2.5.0
  conversation_new@Base 1.9.1
  conversation_new_by_id@Base 2.5.0
+ conversation_new_pinfo@Base 2.6.3
  conversation_pt_to_endpoint_type@Base 2.5.0
  conversation_set_dissector@Base 1.9.1
  conversation_set_dissector_from_frame_number@Base 2.0.0
@@ -632,7 +633,6 @@ 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
index fc94e3d65beaa44b99a3c34abbf3de9d1e2b071c..e1f1a03b8542941830a51583fe43af2469ee63b1 100644 (file)
@@ -765,6 +765,28 @@ conversation_t *conversation_new_by_id(const guint32 setup_frame, const endpoint
        return conversation_new(setup_frame, NULL, NULL, etype, id, 0, options | NO_ADDR2 | NO_PORT2);
 }
 
+conversation_t *
+conversation_new_pinfo(packet_info *pinfo)
+{
+       if (pinfo->use_endpoint) {
+               return conversation_new(pinfo->num,
+                                       &pinfo->conv_endpoint->addr1,
+                                       &pinfo->conv_endpoint->addr2,
+                                       pinfo->conv_endpoint->etype,
+                                       pinfo->conv_endpoint->port1,
+                                       pinfo->conv_endpoint->port2,
+                                       pinfo->conv_endpoint->options);
+       } else {
+               return conversation_new(pinfo->num,
+                                       &pinfo->src,
+                                       &pinfo->dst,
+                                       conversation_pt_to_endpoint_type(pinfo->ptype),
+                                       pinfo->srcport,
+                                       pinfo->destport,
+                                       0);
+       }
+}
+
 /*
  * Set the port 2 value in a key.  Remove the original from table,
  * update the options and port values, insert the updated key.
@@ -1497,29 +1519,7 @@ find_or_create_conversation(packet_info *pinfo)
                DPRINT(("did not find previous conversation for frame #%u",
                                pinfo->num));
                DINDENT();
-               conv = conversation_new(pinfo->num, &pinfo->src,
-                                       &pinfo->dst, conversation_pt_to_endpoint_type(pinfo->ptype),
-                                       pinfo->srcport, pinfo->destport, 0);
-               DENDENT();
-       }
-
-       DENDENT();
-
-       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);
+               conv = conversation_new_pinfo(pinfo);
                DENDENT();
        }
 
index cd8d41612cb53b23c07706fb1efa650195632598..d1d01c7ffbda11e3ae1c7dff796c57634d11f2dc 100644 (file)
@@ -134,6 +134,9 @@ WS_DLL_PUBLIC conversation_t *conversation_new(const guint32 setup_frame, const
 
 WS_DLL_PUBLIC conversation_t *conversation_new_by_id(const guint32 setup_frame, const endpoint_type etype, const guint32 id, const guint options);
 
+WS_DLL_PUBLIC
+conversation_t *conversation_new_pinfo(packet_info *pinfo);
+
 /**
  * Given two address/port pairs for a packet, search for a conversation
  * containing packets between those address/port pairs.  Returns NULL if
@@ -188,12 +191,6 @@ 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);
index a2171eed835a76dec23d803e74e844051d95f66c..846996b278ff278873759fe3ebdf64b17790c2e8 100644 (file)
@@ -96,6 +96,8 @@ 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);
@@ -107,8 +109,7 @@ 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_by_id(pinfo, ENDPOINT_ISDN,
-           pinfo->pseudo_header->isdn.channel);
+       conv = find_or_create_conversation(pinfo);
 
        if (conversation_get_dissector(conv, 0) == NULL) {
                /*