Add find_conversation_pinfo

Convenience function to add the same parameters to find_conversation as
find_or_create_conversation.

Change-Id: I3a92541cb9c1e827a9de8248825636debbd989cd
Reviewed-on: https://code.wireshark.org/review/24118
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Michael Mann 2017-10-27 16:39:50 -04:00
parent f24651493d
commit 3a6552744f
4 changed files with 53 additions and 6 deletions

View File

@ -594,6 +594,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
find_capture_dissector@Base 2.3.0
find_circuit@Base 1.9.1
find_conversation@Base 1.9.1
find_conversation_pinfo@Base 2.5.0
find_conversation_filter@Base 2.0.0
find_depend_dissector_list@Base 2.1.0
find_dissector@Base 1.9.1

View File

@ -2578,10 +2578,24 @@ NO_ADDR_B|NO_PORT_B, the "addr_b" address will be treated as matching
any "wildcarded" address and the "port_b" port will be treated as
matching any "wildcarded" port.
2.2.1.4 The find_conversation_pinfo function.
2.2.1.4 The find_or_create_conversation function.
This convenience function will find an existing conversation (by calling
find_conversation())
This convenience function will create find an existing conversation (by calling
The find_conversation_pinfo prototype:
extern conversation_t *find_conversation_pinfo(packet_info *pinfo);
Where:
packet_info *pinfo = the packet_info structure
The frame number and the addresses necessary for find_conversation() are
taken from the pinfo structure (as is commonly done).
2.2.1.5 The find_or_create_conversation function.
This convenience function will find an existing conversation (by calling
find_conversation()) and, if a conversation does not already exist, create a
new conversation by calling conversation_new().
@ -2597,7 +2611,7 @@ conversation_new() are taken from the pinfo structure (as is commonly done)
and no 'options' are used.
2.2.1.5 The conversation_add_proto_data function.
2.2.1.6 The conversation_add_proto_data function.
Once you have created a conversation with conversation_new, you can
associate data with it using this function.
@ -2623,7 +2637,7 @@ Using the protocol number allows several dissectors to
associate data with a given conversation.
2.2.1.6 The conversation_get_proto_data function.
2.2.1.7 The conversation_get_proto_data function.
After you have located a conversation with find_conversation, you can use
this function to retrieve any data associated with it.
@ -2642,7 +2656,7 @@ typically in the proto_register_XXXX portion of a dissector. The function
returns a pointer to the data requested, or NULL if no data was found.
2.2.1.7 The conversation_delete_proto_data function.
2.2.1.8 The conversation_delete_proto_data function.
After you are finished with a conversation, you can remove your association
with this function. Please note that ONLY the conversation entry is
@ -2661,7 +2675,7 @@ Where:
is a unique protocol number created with proto_register_protocol,
typically in the proto_register_XXXX portion of a dissector.
2.2.1.8 The conversation_set_dissector function
2.2.1.9 The conversation_set_dissector function
This function sets the protocol dissector to be invoked whenever
conversation parameters (addresses, port_types, ports, etc) are matched

View File

@ -1231,6 +1231,33 @@ try_conversation_dissector(const address *addr_a, const address *addr_b, const p
return FALSE;
}
/** A helper function that calls find_conversation() using data from pinfo
* The frame number and addresses are taken from pinfo.
*/
conversation_t *
find_conversation_pinfo(packet_info *pinfo, const guint options)
{
conversation_t *conv=NULL;
DPRINT(("called for frame #%d: %s:%d -> %s:%d (ptype=%d)",
pinfo->num, address_to_str(wmem_packet_scope(), &pinfo->src), pinfo->srcport,
address_to_str(wmem_packet_scope(), &pinfo->dst), pinfo->destport, pinfo->ptype));
DINDENT();
/* Have we seen this conversation before? */
if((conv = find_conversation(pinfo->num, &pinfo->src, &pinfo->dst,
pinfo->ptype, pinfo->srcport,
pinfo->destport, options)) != NULL) {
DPRINT(("found previous conversation for frame #%d (last_frame=%d)",
pinfo->num, conv->last_frame));
if (pinfo->num > conv->last_frame) {
conv->last_frame = pinfo->num;
}
}
return conv;
}
/* A helper function that calls find_conversation() and, if a conversation is
* not found, calls conversation_new().
* The frame number and addresses are taken from pinfo.

View File

@ -145,6 +145,11 @@ WS_DLL_PUBLIC conversation_t *conversation_new(const guint32 setup_frame, const
WS_DLL_PUBLIC conversation_t *find_conversation(const guint32 frame_num, const address *addr_a, const address *addr_b,
const port_type ptype, const guint32 port_a, const guint32 port_b, const guint options);
/** A helper function that calls find_conversation() using data from pinfo
* The frame number and addresses are taken from pinfo.
*/
WS_DLL_PUBLIC conversation_t *find_conversation_pinfo(packet_info *pinfo, const guint options);
/** A helper function that calls find_conversation() and, if a conversation is
* not found, calls conversation_new().
* The frame number and addresses are taken from pinfo.