From 66b441f3d63e21949530d672bf1406dea94ed254 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Mon, 30 Oct 2017 15:57:34 -0400 Subject: Add ability to create endpoints through conversations Add endpoint information to the packet_info structure for dissectors to potentially use as their data to create conversations. This patch includes a simple "example" of using conversation_create_endpoint with TDMoP. The assignment of the PT_TDMOP "port type" has been replaced by setting ENDPOINT_TDMOP within the endpoint structure. Then when subdissectors of TDMoP call find_or_create_conversation(), it implicitly picks up the conversation information set by TDMoP Change-Id: I11dc29989cccd3b0f0349ee901babb455ca02d19 Reviewed-on: https://code.wireshark.org/review/24190 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Andrew Chernyh Reviewed-by: Michael Mann --- epan/conversation.c | 56 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 9 deletions(-) (limited to 'epan/conversation.c') diff --git a/epan/conversation.c b/epan/conversation.c index b473511ed4..d337a94b44 100644 --- a/epan/conversation.c +++ b/epan/conversation.c @@ -36,6 +36,15 @@ int _debug_conversation_indent = 0; #endif +struct endpoint { + address addr1; + address addr2; + endpoint_type etype; + guint32 port1; + guint32 port2; + guint options; +}; + struct conversation_key { struct conversation_key *next; address addr1; @@ -1254,13 +1263,26 @@ find_conversation_pinfo(packet_info *pinfo, const guint options) DINDENT(); /* Have we seen this conversation before? */ - if((conv = find_conversation(pinfo->num, &pinfo->src, &pinfo->dst, - conversation_pt_to_endpoint_type(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; + if (pinfo->use_endpoint) { + DISSECTOR_ASSERT(pinfo->conv_endpoint); + if((conv = find_conversation(pinfo->num, &pinfo->conv_endpoint->addr1, &pinfo->conv_endpoint->addr2, + pinfo->conv_endpoint->etype, pinfo->conv_endpoint->port1, + pinfo->conv_endpoint->port2, 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; + } + } + } else { + if((conv = find_conversation(pinfo->num, &pinfo->src, &pinfo->dst, + conversation_pt_to_endpoint_type(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; + } } } @@ -1295,6 +1317,24 @@ find_or_create_conversation(packet_info *pinfo) return conv; } +void conversation_create_endpoint(struct _packet_info *pinfo, address* addr1, address* addr2, + endpoint_type etype, guint32 port1, guint32 port2, const guint options) +{ + pinfo->conv_endpoint = wmem_new0(pinfo->pool, struct endpoint); + pinfo->use_endpoint = TRUE; + + if (addr1 != NULL) + copy_address_wmem(pinfo->pool, &pinfo->conv_endpoint->addr1, addr1); + + if (addr2 != NULL) + copy_address_wmem(pinfo->pool, &pinfo->conv_endpoint->addr2, addr2); + + pinfo->conv_endpoint->etype = etype; + pinfo->conv_endpoint->port1 = port1; + pinfo->conv_endpoint->port2 = port2; + pinfo->conv_endpoint->options = options; +} + wmem_map_t * get_conversation_hashtable_exact(void) { @@ -1376,8 +1416,6 @@ endpoint_type conversation_pt_to_endpoint_type(port_type pt) return ENDPOINT_IBQP; case PT_BLUETOOTH: return ENDPOINT_BLUETOOTH; - case PT_TDMOP: - return ENDPOINT_TDMOP; } DISSECTOR_ASSERT(FALSE); -- cgit v1.2.3