diff options
author | Michael Mann <mmann78@netscape.net> | 2014-07-25 11:34:51 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-08-18 04:24:39 +0000 |
commit | 018b84de84343306f731ca04b3d20dd07064cdef (patch) | |
tree | e240d07f614c2a910745351f9cf9c1602d2d5da3 /epan/dissectors | |
parent | a76c888cd981bbe77dd8306871791578cd6ba9ca (diff) | |
download | wireshark-018b84de84343306f731ca04b3d20dd07064cdef.tar.gz |
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 <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/packet-eth.c | 30 | ||||
-rw-r--r-- | epan/dissectors/packet-fc.c | 27 | ||||
-rw-r--r-- | epan/dissectors/packet-fddi.c | 27 | ||||
-rw-r--r-- | epan/dissectors/packet-ieee80211.c | 26 | ||||
-rw-r--r-- | epan/dissectors/packet-ip.c | 26 | ||||
-rw-r--r-- | epan/dissectors/packet-ipv6.c | 30 | ||||
-rw-r--r-- | epan/dissectors/packet-ipx.c | 27 | ||||
-rw-r--r-- | epan/dissectors/packet-jxta.c | 26 | ||||
-rw-r--r-- | epan/dissectors/packet-ncp.c | 24 | ||||
-rw-r--r-- | epan/dissectors/packet-rsvp.c | 25 | ||||
-rw-r--r-- | epan/dissectors/packet-sctp.c | 24 | ||||
-rw-r--r-- | epan/dissectors/packet-tcp.c | 30 | ||||
-rw-r--r-- | epan/dissectors/packet-tr.c | 29 | ||||
-rw-r--r-- | epan/dissectors/packet-udp.c | 36 | ||||
-rw-r--r-- | epan/dissectors/packet-usb.c | 26 |
15 files changed, 394 insertions, 19 deletions
diff --git a/epan/dissectors/packet-eth.c b/epan/dissectors/packet-eth.c index 4c3e040781..7e75a503ec 100644 --- a/epan/dissectors/packet-eth.c +++ b/epan/dissectors/packet-eth.c @@ -135,6 +135,34 @@ eth_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* eth_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 "eth.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t eth_host_dissector_info = {ð_host_get_filter_type}; + +static int +eth_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const eth_hdr *ehdr=(const eth_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, &ehdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, ð_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &ehdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, ð_host_dissector_info, PT_NONE); + + return 1; +} + + + + /* These are the Netware-ish names for the different Ethernet frame types. EthernetII: The ethernet with a Type field instead of a length field Ethernet802.2: An 802.3 header followed by an 802.2 header @@ -971,7 +999,7 @@ proto_register_eth(void) register_dissector("eth", dissect_eth_maybefcs, proto_eth); eth_tap = register_tap("eth"); - register_conversation_table(proto_eth, TRUE, eth_conversation_packet); + register_conversation_table(proto_eth, TRUE, eth_conversation_packet, eth_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-fc.c b/epan/dissectors/packet-fc.c index 82a5bd69dc..e4a5b512be 100644 --- a/epan/dissectors/packet-fc.c +++ b/epan/dissectors/packet-fc.c @@ -233,6 +233,31 @@ fc_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, c return 1; } +static const char* fc_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_FC)) + return "fc.id"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t fc_host_dissector_info = {&fc_host_get_filter_type}; + +static int +fc_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const fc_hdr *fchdr=(const fc_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, &fchdr->s_id, 0, TRUE, 1, pinfo->fd->pkt_len, &fc_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &fchdr->d_id, 0, FALSE, 1, pinfo->fd->pkt_len, &fc_host_dissector_info, PT_NONE); + + return 1; +} + const value_string fc_fc4_val[] = { {FC_TYPE_BLS, "Basic Link Svc"}, {FC_TYPE_ELS, "Ext Link Svc"}, @@ -1607,7 +1632,7 @@ proto_register_fc(void) fcsof_handle = register_dissector("fcsof", dissect_fcsof, proto_fcsof); - register_conversation_table(proto_fc, TRUE, fc_conversation_packet); + register_conversation_table(proto_fc, TRUE, fc_conversation_packet, fc_hostlist_packet, NULL); } diff --git a/epan/dissectors/packet-fddi.c b/epan/dissectors/packet-fddi.c index e14f1bad1a..bf4652738d 100644 --- a/epan/dissectors/packet-fddi.c +++ b/epan/dissectors/packet-fddi.c @@ -170,6 +170,31 @@ fddi_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* fddi_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 "fddi.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t fddi_host_dissector_info = {&fddi_host_get_filter_type}; + +static int +fddi_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const fddi_hdr *ehdr=(const fddi_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, &ehdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, &fddi_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &ehdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, &fddi_host_dissector_info, PT_NONE); + + return 1; +} + void capture_fddi(const guchar *pd, int len, packet_counts *ld) { @@ -505,7 +530,7 @@ proto_register_fddi(void) &fddi_padding); fddi_tap = register_tap("fddi"); - register_conversation_table(proto_fddi, TRUE, fddi_conversation_packet); + register_conversation_table(proto_fddi, TRUE, fddi_conversation_packet, fddi_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c index defb9920d0..3d14a159de 100644 --- a/epan/dissectors/packet-ieee80211.c +++ b/epan/dissectors/packet-ieee80211.c @@ -5266,6 +5266,30 @@ wlan_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* wlan_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 "wlan.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t wlan_host_dissector_info = {&wlan_host_get_filter_type}; + +static int +wlan_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const wlan_hdr *whdr=(const wlan_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, &whdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, &wlan_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &whdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, &wlan_host_dissector_info, PT_NONE); + + return 1; +} static void beacon_interval_base_custom(gchar *result, guint32 beacon_interval) { @@ -26211,7 +26235,7 @@ proto_register_ieee80211 (void) register_init_routine(ieee80211_gas_reassembly_init); wlan_tap = register_tap("wlan"); - register_conversation_table(proto_wlan, TRUE, wlan_conversation_packet); + register_conversation_table(proto_wlan, TRUE, wlan_conversation_packet, wlan_hostlist_packet, NULL); /* Register configuration options */ wlan_module = prefs_register_protocol(proto_wlan, init_wepkeys); diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c index ed0b8991f6..5fedb0b4cb 100644 --- a/epan/dissectors/packet-ip.c +++ b/epan/dissectors/packet-ip.c @@ -501,6 +501,30 @@ ip_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, c return 1; } +static const char* ip_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_IPv4)) + return "ip.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t ip_host_dissector_info = {&ip_host_get_filter_type}; + +static int +ip_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const ws_ip *iph=(const ws_ip *)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, &iph->ip_src, 0, TRUE, 1, pinfo->fd->pkt_len, &ip_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &iph->ip_dst, 0, FALSE, 1, pinfo->fd->pkt_len, &ip_host_dissector_info, PT_NONE); + return 1; +} + /* * defragmentation of IPv4 */ @@ -3067,7 +3091,7 @@ proto_register_ip(void) ip_tap = register_tap("ip"); register_decode_as(&ip_da); - register_conversation_table(proto_ip, TRUE, ip_conversation_packet); + register_conversation_table(proto_ip, TRUE, ip_conversation_packet, ip_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-ipv6.c b/epan/dissectors/packet-ipv6.c index f4b67084cf..3857f465b5 100644 --- a/epan/dissectors/packet-ipv6.c +++ b/epan/dissectors/packet-ipv6.c @@ -383,6 +383,34 @@ ipv6_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* ipv6_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_IPv6)) + return "ipv6.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t ipv6_host_dissector_info = {&ipv6_host_get_filter_type}; + +static int +ipv6_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const struct ip6_hdr *ip6h = (const struct ip6_hdr *)vip; + address src; + address dst; + + /* Addresses aren't implemented as 'address' type in struct ip6_hdr */ + SET_ADDRESS(&src, AT_IPv6, sizeof(struct e_in6_addr), &ip6h->ip6_src); + SET_ADDRESS(&dst, AT_IPv6, sizeof(struct e_in6_addr), &ip6h->ip6_dst); + + add_hostlist_table_data(hash, &src, 0, TRUE, 1, pinfo->fd->pkt_len, &ipv6_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &dst, 0, FALSE, 1, pinfo->fd->pkt_len, &ipv6_host_dissector_info, PT_NONE); + + return 1; +} + static const fragment_items ipv6_frag_items = { &ett_ipv6_fragment, &ett_ipv6_fragments, @@ -2944,7 +2972,7 @@ proto_register_ipv6(void) register_decode_as(&ipv6_da); register_decode_as(&ipv6_next_header_da); - register_conversation_table(proto_ipv6, TRUE, ipv6_conversation_packet); + register_conversation_table(proto_ipv6, TRUE, ipv6_conversation_packet, ipv6_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-ipx.c b/epan/dissectors/packet-ipx.c index f632d8d0a8..4ce7fc211f 100644 --- a/epan/dissectors/packet-ipx.c +++ b/epan/dissectors/packet-ipx.c @@ -174,6 +174,31 @@ ipx_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* ipx_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_IPX)) + return "ipx.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t ipx_host_dissector_info = {&ipx_host_get_filter_type}; + +static int +ipx_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const ipxhdr_t *ipxh=(const ipxhdr_t *)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, &ipxh->ipx_src, 0, TRUE, 1, pinfo->fd->pkt_len, &ipx_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &ipxh->ipx_dst, 0, FALSE, 1, pinfo->fd->pkt_len, &ipx_host_dissector_info, PT_NONE); + + return 1; +} + /* ================================================================= */ /* IPX */ /* ================================================================= */ @@ -1568,7 +1593,7 @@ proto_register_ipx(void) register_postseq_cleanup_routine(&spx_postseq_cleanup); ipx_tap=register_tap("ipx"); - register_conversation_table(proto_ipx, TRUE, ipx_conversation_packet); + register_conversation_table(proto_ipx, TRUE, ipx_conversation_packet, ipx_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-jxta.c b/epan/dissectors/packet-jxta.c index 3cefa18000..c89ba42bcc 100644 --- a/epan/dissectors/packet-jxta.c +++ b/epan/dissectors/packet-jxta.c @@ -223,6 +223,30 @@ jxta_conversation_packet(void *pct, packet_info *pinfo _U_, epan_dissect_t *edt return 1; } +static const char* jxta_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_URI)) + return "jxta.message.address"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t jxta_host_dissector_info = {&jxta_host_get_filter_type}; + +static int +jxta_hostlist_packet(void *pit, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const jxta_tap_header *jxtahdr = (const jxta_tap_header *)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, &jxtahdr->src_address, 0, TRUE, 1, jxtahdr->size, &jxta_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &jxtahdr->dest_address, 0, FALSE, 1, jxtahdr->size, &jxta_host_dissector_info, PT_NONE); + return 1; +} + /** * Prototypes **/ @@ -2352,7 +2376,7 @@ void proto_register_jxta(void) prefs_register_bool_preference(jxta_module, "sctp.heuristic", "Try to discover JXTA in SCTP connections", "Enable to inspect SCTP connections for JXTA conversations.", &gSCTP_HEUR); - register_conversation_table(proto_jxta, TRUE, jxta_conversation_packet); + register_conversation_table(proto_jxta, TRUE, jxta_conversation_packet, jxta_hostlist_packet, NULL); } diff --git a/epan/dissectors/packet-ncp.c b/epan/dissectors/packet-ncp.c index f1695ef86c..503262fd10 100644 --- a/epan/dissectors/packet-ncp.c +++ b/epan/dissectors/packet-ncp.c @@ -321,6 +321,28 @@ ncp_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* ncp_host_get_filter_type(hostlist_talker_t* host _U_, conv_filter_type_e filter) +{ + return ncp_conv_get_filter_type(NULL, filter); +} + +static hostlist_dissector_info_t ncp_host_dissector_info = {&ncp_host_get_filter_type}; + +static int +ncp_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip _U_) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + /*const ncp_common_header *ncphdr=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, &pinfo->src, 0, TRUE, 1, pinfo->fd->pkt_len, &ncp_host_dissector_info, PT_NCP); + add_hostlist_table_data(hash, &pinfo->dst, 0, FALSE, 1, pinfo->fd->pkt_len, &ncp_host_dissector_info, PT_NCP); + + return 1; +} + /* * Burst packet system flags. */ @@ -1127,7 +1149,7 @@ proto_register_ncp(void) ncp_tap.hdr=register_tap("ncp"); register_postseq_cleanup_routine(&mncp_postseq_cleanup); - register_conversation_table(proto_ncp, FALSE, ncp_conversation_packet); + register_conversation_table(proto_ncp, FALSE, ncp_conversation_packet, ncp_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-rsvp.c b/epan/dissectors/packet-rsvp.c index 8917691c4a..95dbf6d4da 100644 --- a/epan/dissectors/packet-rsvp.c +++ b/epan/dissectors/packet-rsvp.c @@ -1892,6 +1892,29 @@ rsvp_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* rsvp_host_get_filter_type(hostlist_talker_t* host _U_, conv_filter_type_e filter) +{ + return rsvp_conv_get_filter_type(NULL, filter); +} + +static hostlist_dissector_info_t rsvp_host_dissector_info = {&rsvp_host_get_filter_type}; + +static int +rsvp_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const rsvp_conversation_info *rsvph = (const rsvp_conversation_info *)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, &rsvph->source, 0, TRUE, 1, pinfo->fd->pkt_len, &rsvp_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &rsvph->destination, 0, FALSE, 1, pinfo->fd->pkt_len, &rsvp_host_dissector_info, PT_NONE); + return 1; +} + static inline int rsvp_class_to_filter_num(int classnum) { @@ -9177,7 +9200,7 @@ proto_register_rsvp(void) /* Initialization routine for RSVP conversations */ register_init_routine(&rsvp_init_protocol); - register_conversation_table(proto_rsvp, TRUE, rsvp_conversation_packet); + register_conversation_table(proto_rsvp, TRUE, rsvp_conversation_packet, rsvp_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c index dd7d32e378..743b1b6b9b 100644 --- a/epan/dissectors/packet-sctp.c +++ b/epan/dissectors/packet-sctp.c @@ -825,6 +825,28 @@ sctp_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* sctp_host_get_filter_type(hostlist_talker_t* host _U_, conv_filter_type_e filter) +{ + return sctp_conv_get_filter_type(NULL, filter); +} + +static hostlist_dissector_info_t sctp_host_dissector_info = {&sctp_host_get_filter_type}; + +static int +sctp_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const struct _sctp_info *sctphdr=(const struct _sctp_info *)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, &sctphdr->ip_src, sctphdr->sport, TRUE, 1, pinfo->fd->pkt_len, &sctp_host_dissector_info, PT_SCTP); + add_hostlist_table_data(hash, &sctphdr->ip_dst, sctphdr->dport, FALSE, 1, pinfo->fd->pkt_len, &sctp_host_dissector_info, PT_SCTP); + + return 1; +} + static unsigned int sctp_adler32(tvbuff_t *tvb, unsigned int len) { @@ -4887,7 +4909,7 @@ proto_register_sctp(void) register_decode_as(&sctp_da_port); register_decode_as(&sctp_da_ppi); - register_conversation_table(proto_sctp, FALSE, sctp_conversation_packet); + register_conversation_table(proto_sctp, FALSE, sctp_conversation_packet, sctp_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index 47cef7aa2d..1c993b9ba3 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -574,6 +574,34 @@ tcpip_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_ return 1; } +static const char* tcp_host_get_filter_type(hostlist_talker_t* host _U_, conv_filter_type_e filter) +{ + return tcp_conv_get_filter_type(NULL, filter); +} + +static hostlist_dissector_info_t tcp_host_dissector_info = {&tcp_host_get_filter_type}; + +static int +tcpip_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const struct tcpheader *tcphdr=(const struct tcpheader *)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, &tcphdr->ip_src, tcphdr->th_sport, TRUE, 1, pinfo->fd->pkt_len, &tcp_host_dissector_info, PT_TCP); + add_hostlist_table_data(hash, &tcphdr->ip_dst, tcphdr->th_dport, FALSE, 1, pinfo->fd->pkt_len, &tcp_host_dissector_info, PT_TCP); + + return 1; +} + +static const char* +tcpip_hostlist_prefix(void) +{ + return "endpoints"; +} + /* TCP structs and definitions */ /* ************************************************************************** @@ -5874,7 +5902,7 @@ proto_register_tcp(void) register_decode_as(&tcp_da); - register_conversation_table(proto_tcp, FALSE, tcpip_conversation_packet); + register_conversation_table(proto_tcp, FALSE, tcpip_conversation_packet, tcpip_hostlist_packet, tcpip_hostlist_prefix); } void 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 diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c index 5730403cc6..cacd5d9b1e 100644 --- a/epan/dissectors/packet-udp.c +++ b/epan/dissectors/packet-udp.c @@ -321,12 +321,40 @@ static ct_dissector_info_t udp_ct_dissector_info = {&udp_conv_get_filter_type}; static int udpip_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) { - conv_hash_t *hash = (conv_hash_t*) pct; - const e_udphdr *udphdr=(const e_udphdr *)vip; + conv_hash_t *hash = (conv_hash_t*) pct; + const e_udphdr *udphdr=(const e_udphdr *)vip; add_conversation_table_data(hash, &udphdr->ip_src, &udphdr->ip_dst, udphdr->uh_sport, udphdr->uh_dport, 1, pinfo->fd->pkt_len, &pinfo->rel_ts, &pinfo->fd->abs_ts, &udp_ct_dissector_info, PT_UDP); - return 1; + return 1; +} + +static const char* udp_host_get_filter_type(hostlist_talker_t* host _U_, conv_filter_type_e filter) +{ + return udp_conv_get_filter_type(NULL, filter); +} + +static hostlist_dissector_info_t udp_host_dissector_info = {&udp_host_get_filter_type}; + +static int +udpip_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const e_udphdr *udphdr=(const e_udphdr *)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, &udphdr->ip_src, udphdr->uh_sport, TRUE, 1, pinfo->fd->pkt_len, &udp_host_dissector_info, PT_UDP); + add_hostlist_table_data(hash, &udphdr->ip_dst, udphdr->uh_dport, FALSE, 1, pinfo->fd->pkt_len, &udp_host_dissector_info, PT_UDP); + + return 1; +} + +static const char* +udpip_hostlist_prefix(void) +{ + return "endpoints"; } /* Attach process info to a flow */ @@ -936,7 +964,7 @@ proto_register_udp(void) &udplite_check_checksum); register_decode_as(&udp_da); - register_conversation_table(proto_udp, FALSE, udpip_conversation_packet); + register_conversation_table(proto_udp, FALSE, udpip_conversation_packet, udpip_hostlist_packet, udpip_hostlist_prefix); register_init_routine(udp_init); diff --git a/epan/dissectors/packet-usb.c b/epan/dissectors/packet-usb.c index b993793120..6ab86bec49 100644 --- a/epan/dissectors/packet-usb.c +++ b/epan/dissectors/packet-usb.c @@ -1135,6 +1135,30 @@ usb_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* usb_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_USB)) + return "usb.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t usb_host_dissector_info = {&usb_host_get_filter_type}; + +static int +usb_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip _U_) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + + /* 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, &pinfo->src, 0, TRUE, 1, pinfo->fd->pkt_len, &usb_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &pinfo->dst, 0, FALSE, 1, pinfo->fd->pkt_len, &usb_host_dissector_info, PT_NONE); + + return 1; +} + /* SETUP dissectors */ @@ -4189,7 +4213,7 @@ proto_register_usb(void) register_decode_as(&usb_product_da); register_decode_as(&usb_device_da); - register_conversation_table(proto_usb, TRUE, usb_conversation_packet); + register_conversation_table(proto_usb, TRUE, usb_conversation_packet, usb_hostlist_packet, NULL); } void |