From 018b84de84343306f731ca04b3d20dd07064cdef Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Fri, 25 Jul 2014 11:34:51 -0400 Subject: Refactor "common" hostlist/endpoint table functionality. This is very similar in architecture to the changes made to the Conversation table functionality. Since all conversations have endpoints/hostlists, the "registered" list is shared for both. Change-Id: Ie8c6910a68a1b3f27c5b18c4494f49b9404a7b31 Reviewed-on: https://code.wireshark.org/review/3214 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/dissectors/packet-tr.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'epan/dissectors/packet-tr.c') diff --git a/epan/dissectors/packet-tr.c b/epan/dissectors/packet-tr.c index 5ca24efa6b..5a491af82c 100644 --- a/epan/dissectors/packet-tr.c +++ b/epan/dissectors/packet-tr.c @@ -147,7 +147,7 @@ static ct_dissector_info_t tr_ct_dissector_info = {&tr_conv_get_filter_type}; static int tr_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) { - conv_hash_t *hash = (conv_hash_t*) pct; + conv_hash_t *hash = (conv_hash_t*) pct; const tr_hdr *trhdr=(const tr_hdr *)vip; add_conversation_table_data(hash, &trhdr->src, &trhdr->dst, 0, 0, 1, pinfo->fd->pkt_len, &pinfo->rel_ts, &pinfo->fd->abs_ts, &tr_ct_dissector_info, PT_NONE); @@ -155,6 +155,31 @@ tr_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, c return 1; } +static const char* tr_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_ETHER)) + return "tr.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t tr_host_dissector_info = {&tr_host_get_filter_type}; + +static int +tr_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const tr_hdr *trhdr=(const tr_hdr *)vip; + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &trhdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, &tr_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &trhdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, &tr_host_dissector_info, PT_NONE); + + return 1; +} + /* * DODGY LINUX HACK DODGY LINUX HACK * Linux 2.0.x always passes frames to the Token Ring driver for transmission with @@ -763,7 +788,7 @@ proto_register_tr(void) register_dissector("tr", dissect_tr, proto_tr); tr_tap=register_tap("tr"); - register_conversation_table(proto_tr, TRUE, tr_conversation_packet); + register_conversation_table(proto_tr, TRUE, tr_conversation_packet, tr_hostlist_packet, NULL); } void -- cgit v1.2.3