diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/conversation_ui.h | 2 | ||||
-rw-r--r-- | ui/gtk/CMakeLists.txt | 15 | ||||
-rw-r--r-- | ui/gtk/Makefile.common | 15 | ||||
-rw-r--r-- | ui/gtk/conversations_table.h | 2 | ||||
-rw-r--r-- | ui/gtk/hostlist_eth.c | 85 | ||||
-rw-r--r-- | ui/gtk/hostlist_fc.c | 85 | ||||
-rw-r--r-- | ui/gtk/hostlist_fddi.c | 84 | ||||
-rw-r--r-- | ui/gtk/hostlist_ip.c | 83 | ||||
-rw-r--r-- | ui/gtk/hostlist_ipv6.c | 88 | ||||
-rw-r--r-- | ui/gtk/hostlist_ipx.c | 84 | ||||
-rw-r--r-- | ui/gtk/hostlist_jxta.c | 81 | ||||
-rw-r--r-- | ui/gtk/hostlist_ncp.c | 82 | ||||
-rw-r--r-- | ui/gtk/hostlist_rsvp.c | 88 | ||||
-rw-r--r-- | ui/gtk/hostlist_sctp.c | 82 | ||||
-rw-r--r-- | ui/gtk/hostlist_table.c | 674 | ||||
-rw-r--r-- | ui/gtk/hostlist_table.h | 104 | ||||
-rw-r--r-- | ui/gtk/hostlist_tcpip.c | 84 | ||||
-rw-r--r-- | ui/gtk/hostlist_tr.c | 84 | ||||
-rw-r--r-- | ui/gtk/hostlist_udpip.c | 84 | ||||
-rw-r--r-- | ui/gtk/hostlist_usb.c | 81 | ||||
-rw-r--r-- | ui/gtk/hostlist_wlan.c | 82 | ||||
-rw-r--r-- | ui/gtk/main.c | 2 | ||||
-rw-r--r-- | ui/gtk/main_menubar.c | 96 | ||||
-rw-r--r-- | ui/qt/main.cpp | 1 |
24 files changed, 309 insertions, 1859 deletions
diff --git a/ui/conversation_ui.h b/ui/conversation_ui.h index b0e02a08d9..fff938cf75 100644 --- a/ui/conversation_ui.h +++ b/ui/conversation_ui.h @@ -49,7 +49,7 @@ typedef enum { CONV_COLUMN_BPS_BA, CONV_NUM_COLUMNS, CONV_INDEX_COLUMN = CONV_NUM_COLUMNS -} column_type_e; +} conversation_column_type_e; extern const char *column_titles[CONV_NUM_COLUMNS]; diff --git a/ui/gtk/CMakeLists.txt b/ui/gtk/CMakeLists.txt index 6f1b9f6079..a97a72e893 100644 --- a/ui/gtk/CMakeLists.txt +++ b/ui/gtk/CMakeLists.txt @@ -142,21 +142,6 @@ set(WIRESHARK_TAP_SRC gtp_stat.c h225_counter.c h225_ras_srt.c - hostlist_eth.c - hostlist_fc.c - hostlist_fddi.c - hostlist_ip.c - hostlist_ipv6.c - hostlist_ipx.c - hostlist_jxta.c - hostlist_ncp.c - hostlist_rsvp.c - hostlist_sctp.c - hostlist_tcpip.c - hostlist_tr.c - hostlist_udpip.c - hostlist_usb.c - hostlist_wlan.c iax2_analysis.c io_stat.c lbm_stream_dlg.c diff --git a/ui/gtk/Makefile.common b/ui/gtk/Makefile.common index 2d644d9009..405ae13c9a 100644 --- a/ui/gtk/Makefile.common +++ b/ui/gtk/Makefile.common @@ -167,21 +167,6 @@ WIRESHARK_TAP_SRC = \ gtp_stat.c \ h225_counter.c \ h225_ras_srt.c \ - hostlist_eth.c \ - hostlist_fc.c \ - hostlist_fddi.c \ - hostlist_ip.c \ - hostlist_ipv6.c \ - hostlist_ipx.c \ - hostlist_jxta.c \ - hostlist_ncp.c \ - hostlist_rsvp.c \ - hostlist_sctp.c \ - hostlist_tcpip.c \ - hostlist_tr.c \ - hostlist_udpip.c \ - hostlist_usb.c \ - hostlist_wlan.c \ iax2_analysis.c \ io_stat.c \ lbm_stream_dlg.c \ diff --git a/ui/gtk/conversations_table.h b/ui/gtk/conversations_table.h index e4062b5327..d1e2ec3fe9 100644 --- a/ui/gtk/conversations_table.h +++ b/ui/gtk/conversations_table.h @@ -55,8 +55,8 @@ typedef struct _conversations_table { /** Init the conversation table for the single conversation window. * + * @param ct the registered conversation * @param filter the optional filter name or NULL - * @param packet_func the function to be called for each incoming packet */ extern void init_conversation_table(struct register_ct* ct, const char *filter); diff --git a/ui/gtk/hostlist_eth.c b/ui/gtk/hostlist_eth.c deleted file mode 100644 index 3785753415..0000000000 --- a/ui/gtk/hostlist_eth.c +++ /dev/null @@ -1,85 +0,0 @@ -/* hostlist_eth.c 2004 Ian Schorr - * modified from endpoint_talkers_eth.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-eth.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_eth_hostlist(void); - -static int -eth_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)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(hosts, &ehdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_ETHERNET, PT_NONE); - add_hostlist_table_data(hosts, &ehdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_ETHERNET, PT_NONE); - - return 1; -} - - - -static void -gtk_eth_hostlist_init(const char *opt_arg, - void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,eth,",10)){ - filter=opt_arg+10; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "Ethernet", "eth", filter, eth_hostlist_packet); - -} - -void -gtk_eth_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_eth_hostlist_init("hosts,eth",NULL); -} - -void -register_tap_listener_eth_hostlist(void) -{ - register_stat_cmd_arg("hosts,eth", gtk_eth_hostlist_init,NULL); - register_hostlist_table(TRUE, "Ethernet", "eth", NULL /*filter*/, eth_hostlist_packet); -} diff --git a/ui/gtk/hostlist_fc.c b/ui/gtk/hostlist_fc.c deleted file mode 100644 index 401681b57c..0000000000 --- a/ui/gtk/hostlist_fc.c +++ /dev/null @@ -1,85 +0,0 @@ -/* hostlist_fc.c 2004 Ian Schorr - * modified from endpoint_talkers_fc.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/conversation.h> -#include <epan/dissectors/packet-fc.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_fc_hostlist(void); - -static int -fc_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)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(hosts, &fchdr->s_id, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_FIBRE_CHANNEL, PT_NONE); - add_hostlist_table_data(hosts, &fchdr->d_id, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_FIBRE_CHANNEL, PT_NONE); - - return 1; -} - - - -static void -gtk_fc_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,fc,",9)){ - filter=opt_arg+9; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "Fibre Channel", "fc", filter, fc_hostlist_packet); - -} - -void -gtk_fc_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_fc_hostlist_init("hosts,fc",NULL); -} - -void -register_tap_listener_fc_hostlist(void) -{ - register_stat_cmd_arg("hosts,fc", gtk_fc_hostlist_init,NULL); - register_hostlist_table(TRUE, "Fibre Channel", "fc", NULL /*filter*/, fc_hostlist_packet); -} diff --git a/ui/gtk/hostlist_fddi.c b/ui/gtk/hostlist_fddi.c deleted file mode 100644 index f93c9881c5..0000000000 --- a/ui/gtk/hostlist_fddi.c +++ /dev/null @@ -1,84 +0,0 @@ -/* hostlist_fddi.c 2004 Ian Schorr - * modified from endpoint_talkers_fddi.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-fddi.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_fddi_hostlist(void); - -static int -fddi_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)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(hosts, &ehdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_FDDI, PT_NONE); - add_hostlist_table_data(hosts, &ehdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_FDDI, PT_NONE); - - return 1; -} - - - -static void -gtk_fddi_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,fddi,",11)){ - filter=opt_arg+11; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "FDDI", "fddi", filter, fddi_hostlist_packet); - -} - -void -gtk_fddi_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_fddi_hostlist_init("hosts,fddi",NULL); -} - -void -register_tap_listener_fddi_hostlist(void) -{ - register_stat_cmd_arg("hosts,fddi", gtk_fddi_hostlist_init,NULL); - register_hostlist_table(TRUE, "FDDI", "fddi", NULL /*filter*/, fddi_hostlist_packet); -} diff --git a/ui/gtk/hostlist_ip.c b/ui/gtk/hostlist_ip.c deleted file mode 100644 index 2b2ac5ee55..0000000000 --- a/ui/gtk/hostlist_ip.c +++ /dev/null @@ -1,83 +0,0 @@ -/* hostlist_ip.c 2004 Ian Schorr - * modified from endpoint_talkers_ip.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-ip.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_ip_hostlist(void); - -static int -ip_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)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(hosts, &iph->ip_src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_IPV4, PT_NONE); - add_hostlist_table_data(hosts, &iph->ip_dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_IPV4, PT_NONE); - return 1; -} - -static void -gtk_ip_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,ip,",9)){ - filter=opt_arg+9; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "IPv4", "ip", filter, ip_hostlist_packet); - -} - -void -gtk_ip_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_ip_hostlist_init("hosts,ip",NULL); -} - -void -register_tap_listener_ip_hostlist(void) -{ - register_stat_cmd_arg("hosts,ip", gtk_ip_hostlist_init,NULL); - register_hostlist_table(TRUE, "IPv4", "ip", NULL /*filter*/, ip_hostlist_packet); -} diff --git a/ui/gtk/hostlist_ipv6.c b/ui/gtk/hostlist_ipv6.c deleted file mode 100644 index b292479f98..0000000000 --- a/ui/gtk/hostlist_ipv6.c +++ /dev/null @@ -1,88 +0,0 @@ -/* hostlist_ipv6.c 2009 Clif Bratcher - * Modified from hostlist_ip.c 2004 Ian Schorr - * modified from endpoint_talkers_ip.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-ipv6.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_ipv6_hostlist(void); - -static int -ipv6_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts = (hostlist_table *)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(hosts, &src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_IPV6, PT_NONE); - add_hostlist_table_data(hosts, &dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_IPV6, PT_NONE); - - return 1; -} - - -static void -gtk_ipv6_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,ipv6,",10)){ - filter = opt_arg + 10; - } else { - filter = NULL; - } - - init_hostlist_table(TRUE, "IPv6", "ipv6", filter, ipv6_hostlist_packet); -} - -void -gtk_ipv6_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_ipv6_hostlist_init("hosts,ipv6", NULL); -} - -void -register_tap_listener_ipv6_hostlist(void) -{ - register_stat_cmd_arg("hosts,ipv6", gtk_ipv6_hostlist_init, NULL); - register_hostlist_table(TRUE, "IPv6", "ipv6", NULL /*filter*/, ipv6_hostlist_packet); -} diff --git a/ui/gtk/hostlist_ipx.c b/ui/gtk/hostlist_ipx.c deleted file mode 100644 index d93acc8510..0000000000 --- a/ui/gtk/hostlist_ipx.c +++ /dev/null @@ -1,84 +0,0 @@ -/* hostlist_ipx.c 2004 Ian Schorr - * modified from endpoint_talkers_ipx.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-ipx.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_ipx_hostlist(void); - -static int -ipx_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)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(hosts, &ipxh->ipx_src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_IPX, PT_NONE); - add_hostlist_table_data(hosts, &ipxh->ipx_dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_IPX, PT_NONE); - - return 1; -} - - - -static void -gtk_ipx_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,ipx,",10)){ - filter=opt_arg+10; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "IPX", "ipx", filter, ipx_hostlist_packet); - -} - -void -gtk_ipx_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_ipx_hostlist_init("hosts,ipx",NULL); -} - -void -register_tap_listener_ipx_hostlist(void) -{ - register_stat_cmd_arg("hosts,ipx", gtk_ipx_hostlist_init,NULL); - register_hostlist_table(TRUE, "IPX", "ipx", NULL /*filter*/, ipx_hostlist_packet); -} diff --git a/ui/gtk/hostlist_jxta.c b/ui/gtk/hostlist_jxta.c deleted file mode 100644 index c3876d95fb..0000000000 --- a/ui/gtk/hostlist_jxta.c +++ /dev/null @@ -1,81 +0,0 @@ -/* hostlist_jxta.c 2005 Mike Duigou - * modified from hostlist_eth.c 2004 Ian Schorr - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-jxta.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_jxta_hostlist(void); - -static int -jxta_hostlist_packet(void *pit, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts = (hostlist_table *) 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(hosts, &jxtahdr->src_address, 0, TRUE, 1, jxtahdr->size, CONV_TYPE_JXTA, PT_NONE); - add_hostlist_table_data(hosts, &jxtahdr->dest_address, 0, FALSE, 1, jxtahdr->size, CONV_TYPE_JXTA, PT_NONE); - return 1; -} - -static void -gtk_jxta_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,jxta,",11)){ - filter=opt_arg+11; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "JXTA", "jxta", filter, jxta_hostlist_packet); - -} - -void -gtk_jxta_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_jxta_hostlist_init("hosts,jxta",NULL); -} - -void -register_tap_listener_jxta_hostlist(void) -{ - register_stat_cmd_arg("hosts,jxta", gtk_jxta_hostlist_init,NULL); - register_hostlist_table(TRUE, "JXTA", "jxta", NULL /*filter*/, jxta_hostlist_packet); -} diff --git a/ui/gtk/hostlist_ncp.c b/ui/gtk/hostlist_ncp.c deleted file mode 100644 index 9889890c37..0000000000 --- a/ui/gtk/hostlist_ncp.c +++ /dev/null @@ -1,82 +0,0 @@ -/* hostlist_ncp.c 2006 Greg Morris - * modified from endpoint_talkers_eth.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -/*#include <epan/dissectors/packet-ncp-int.h>*/ - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_ncp_hostlist(void); - -static int -ncp_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip _U_) -{ - hostlist_table *hosts=(hostlist_table *)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(hosts, &pinfo->src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_ETHERNET, PT_NCP); - add_hostlist_table_data(hosts, &pinfo->dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_ETHERNET, PT_NCP); - - return 1; -} - -static void -gtk_ncp_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,ncp,",10)){ - filter=opt_arg+10; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "NCP", "ncp", filter, ncp_hostlist_packet); - -} - -void -gtk_ncp_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_ncp_hostlist_init("hosts,ncp",NULL); -} - -void -register_tap_listener_ncp_hostlist(void) -{ - register_stat_cmd_arg("hosts,ncp", gtk_ncp_hostlist_init,NULL); - register_hostlist_table(TRUE, "NCP", "ncp", NULL /*filter*/, ncp_hostlist_packet); -} diff --git a/ui/gtk/hostlist_rsvp.c b/ui/gtk/hostlist_rsvp.c deleted file mode 100644 index d6986a9abb..0000000000 --- a/ui/gtk/hostlist_rsvp.c +++ /dev/null @@ -1,88 +0,0 @@ -/* hostlist_rsvp.c - * hostlist_rsvp.c August 2005, Manu Pathak <mapathak@cisco.com> - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-rsvp.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_rsvp_hostlist(void); - -static int -rsvp_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)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(hosts, &rsvph->source, 0, TRUE, 1, - pinfo->fd->pkt_len, CONV_TYPE_RSVP, PT_NONE); - add_hostlist_table_data(hosts, &rsvph->destination, 0, FALSE, 1, - pinfo->fd->pkt_len, CONV_TYPE_RSVP, PT_NONE); - return 1; -} - -static void -gtk_rsvp_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,rsvp,",11)){ - filter=opt_arg+11; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "RSVP", "rsvp", filter, - rsvp_hostlist_packet); - -} - -void -gtk_rsvp_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_rsvp_hostlist_init("hosts,rsvp",NULL); -} - -void -register_tap_listener_rsvp_hostlist(void) -{ - register_stat_cmd_arg("hosts,rsvp", gtk_rsvp_hostlist_init,NULL); - register_hostlist_table(TRUE, "RSVP", "rsvp", NULL /*filter*/, - rsvp_hostlist_packet); -} diff --git a/ui/gtk/hostlist_sctp.c b/ui/gtk/hostlist_sctp.c deleted file mode 100644 index 09ddfbe808..0000000000 --- a/ui/gtk/hostlist_sctp.c +++ /dev/null @@ -1,82 +0,0 @@ -/* hostlist_sctp.c 2008 Stig Bjorlykke - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-sctp.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_sctp_hostlist(void); - -static int -sctp_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)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(hosts, &sctphdr->ip_src, sctphdr->sport, TRUE, 1, - pinfo->fd->pkt_len, CONV_TYPE_SCTP, PT_SCTP); - add_hostlist_table_data(hosts, &sctphdr->ip_dst, sctphdr->dport, FALSE, 1, - pinfo->fd->pkt_len, CONV_TYPE_SCTP, PT_SCTP); - - return 1; -} - -static void -gtk_sctp_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,sctp,",11)){ - filter=opt_arg+11; - } else { - filter=NULL; - } - - init_hostlist_table(FALSE, "SCTP", "sctp", filter, sctp_hostlist_packet); -} - -void -gtk_sctp_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_sctp_hostlist_init("hosts,sctp",NULL); -} - -void -register_tap_listener_sctp_hostlist(void) -{ - register_stat_cmd_arg("hosts,sctp", gtk_sctp_hostlist_init,NULL); - register_hostlist_table(FALSE, "SCTP", "sctp", NULL /*filter*/, sctp_hostlist_packet); -} diff --git a/ui/gtk/hostlist_table.c b/ui/gtk/hostlist_table.c index 3f5a65adfe..b8dfa4424e 100644 --- a/ui/gtk/hostlist_table.c +++ b/ui/gtk/hostlist_table.c @@ -79,105 +79,9 @@ #define COL_STR_LEN 32 -/* convert a port number into a string */ -static char * -hostlist_port_to_str(int port_type_val, guint32 port) -{ - static int i=0; - static gchar *strp, str[4][12]; - gchar *bp; - - switch(port_type_val){ - case PT_TCP: - case PT_UDP: - case PT_SCTP: - i = (i+1)%4; - strp=str[i]; - bp = &strp[11]; - - *bp = 0; - do { - *--bp = (port % 10) +'0'; - } while ((port /= 10) != 0 && bp > strp); - return bp; - } - return NULL; -} - - -#define FN_ANY_ADDRESS 0 -#define FN_ANY_PORT 1 - -/* Given an address (to distinguish between ipv4 and ipv6 for tcp/udp, - a port_type and a name_type (FN_...) - return a string for the filter name. - - Some addresses, like AT_ETHER may actually be any of multiple types - of protocols, either ethernet, tokenring, fddi etc so we must be more - specific there; that's why we need specific_addr_type. -*/ -static const char * -hostlist_get_filter_name(address *addr, int specific_addr_type_val, int port_type_val, int name_type_val) -{ - switch(name_type_val){ - case FN_ANY_ADDRESS: - switch(addr->type){ - case AT_ETHER: - switch(specific_addr_type_val){ - case CONV_TYPE_ETHERNET: - return "eth.addr"; - case CONV_TYPE_WLAN: - return "wlan.addr"; - case CONV_TYPE_FDDI: - return "fddi.addr"; - case CONV_TYPE_TOKEN_RING: - return "tr.addr"; - default: - break; - } - break; - case AT_IPv4: - return "ip.addr"; - case AT_IPv6: - return "ipv6.addr"; - case AT_IPX: - return "ipx.addr"; - case AT_FC: - return "fc.id"; - case AT_URI: - switch(specific_addr_type_val){ - case CONV_TYPE_JXTA: - return "jxta.message.address"; - default: - break; - } - break; - case AT_USB: - return "usb.addr"; - default: - break; - } - break; - case FN_ANY_PORT: - switch(port_type_val){ - case PT_TCP: - return "tcp.port"; - case PT_UDP: - return "udp.port"; - case PT_SCTP: - return "sctp.port"; - } - break; - } - - g_assert_not_reached(); - return NULL; -} - static void -reset_hostlist_table_data(hostlist_table *hosts) +reset_host_table_data(hostlist_table *hosts) { - guint32 i; char *display_name; char title[256]; GString *error_string; @@ -228,26 +132,15 @@ reset_hostlist_table_data(hostlist_table *hosts) gtk_list_store_clear(store); /* delete all hosts */ - for(i=0;i<hosts->num_hosts;i++){ - hostlist_talker_t *host = &g_array_index(hosts->hosts, hostlist_talker_t, i); - g_free((gpointer)host->myaddress.data); - } - - if (hosts->hosts) - g_array_free(hosts->hosts, TRUE); - - if (hosts->hashtable != NULL) - g_hash_table_destroy(hosts->hashtable); - - hosts->hosts=NULL; - hosts->hashtable=NULL; - hosts->num_hosts=0; + reset_hostlist_table_data(&hosts->hash); } static void reset_hostlist_table_data_cb(void *arg) { - reset_hostlist_table_data((hostlist_table *)arg); + conv_hash_t *hash = (conv_hash_t*)arg; + + reset_host_table_data((hostlist_table *)hash->user_data); } static void @@ -255,41 +148,12 @@ hostlist_win_destroy_cb(GtkWindow *win _U_, gpointer data) { hostlist_table *hosts=(hostlist_table *)data; - remove_tap_listener(hosts); + remove_tap_listener(&hosts->hash); - reset_hostlist_table_data(hosts); + reset_host_table_data(hosts); g_free(hosts); } -enum -{ - ADR_COLUMN, - PORT_COLUMN, - PACKETS_COLUMN, - BYTES_COLUMN, - PKT_AB_COLUMN, - BYTES_AB_COLUMN, - PKT_BA_COLUMN, - BYTES_BA_COLUMN, -#ifdef HAVE_GEOIP - GEOIP1_COLUMN, - GEOIP2_COLUMN, - GEOIP3_COLUMN, - GEOIP4_COLUMN, - GEOIP5_COLUMN, - GEOIP6_COLUMN, - GEOIP7_COLUMN, - GEOIP8_COLUMN, - GEOIP9_COLUMN, - GEOIP10_COLUMN, - GEOIP11_COLUMN, - GEOIP12_COLUMN, - GEOIP13_COLUMN, -#endif - INDEX_COLUMN, - N_COLUMNS -}; - static gint hostlist_sort_column(GtkTreeModel *model, GtkTreeIter *a, @@ -303,19 +167,19 @@ hostlist_sort_column(GtkTreeModel *model, hostlist_talker_t *host1 = NULL; hostlist_talker_t *host2 = NULL; - gtk_tree_model_get(model, a, INDEX_COLUMN, &idx1, -1); - gtk_tree_model_get(model, b, INDEX_COLUMN, &idx2, -1); + gtk_tree_model_get(model, a, HOST_INDEX_COLUMN, &idx1, -1); + gtk_tree_model_get(model, b, HOST_INDEX_COLUMN, &idx2, -1); - if (!hl || idx1 >= hl->num_hosts || idx2 >= hl->num_hosts) + if (!hl || idx1 >= hl->hash.conv_array->len || idx2 >= hl->hash.conv_array->len) return 0; - host1 = &g_array_index(hl->hosts, hostlist_talker_t, idx1); - host2 = &g_array_index(hl->hosts, hostlist_talker_t, idx2); + host1 = &g_array_index(hl->hash.conv_array, hostlist_talker_t, idx1); + host2 = &g_array_index(hl->hash.conv_array, hostlist_talker_t, idx2); switch(data_column){ - case 0: /* Address */ + case HOST_ADR_COLUMN: /* Address */ return(CMP_ADDRESS(&host1->myaddress, &host2->myaddress)); - case 1: /* (Port) */ + case HOST_PORT_COLUMN: /* (Port) */ CMP_INT(host1->port, host2->port); #ifdef HAVE_GEOIP default: @@ -349,36 +213,27 @@ hostlist_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint c { guint idx; hostlist_table *hl=(hostlist_table *)callback_data; - char *str = NULL; - char *sport; + char *str; GtkTreeIter iter; GtkTreeModel *model; GtkTreeSelection *sel; - hostlist_talker_t *host = NULL; + hostlist_talker_t *host; sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(hl->table)); if (!gtk_tree_selection_get_selected(sel, &model, &iter)) return; gtk_tree_model_get (model, &iter, - INDEX_COLUMN, &idx, + HOST_INDEX_COLUMN, &idx, -1); - if(idx>= hl->num_hosts){ + if(idx>= hl->hash.conv_array->len){ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "No hostlist selected"); return; } - host = &g_array_index(hl->hosts, hostlist_talker_t, idx); - - sport=hostlist_port_to_str(host->port_type, host->port); + host = &g_array_index(hl->hash.conv_array, hostlist_talker_t, idx); - str = g_strdup_printf("%s==%s%s%s%s%s", - hostlist_get_filter_name(&host->myaddress, host->sat, host->port_type, FN_ANY_ADDRESS), - ep_address_to_str(&host->myaddress), - sport?" && ":"", - sport?hostlist_get_filter_name(&host->myaddress, host->sat, host->port_type, FN_ANY_PORT):"", - sport?"==":"", - sport?sport:""); + str = (char*)get_hostlist_filter(host); apply_selected_filter (callback_action, str); @@ -614,56 +469,32 @@ hostlist_create_popup_menu(hostlist_table *hl) g_signal_connect(hl->table, "button_press_event", G_CALLBACK(hostlist_show_popup_menu_cb), hl); } - -/* Draw/refresh the address field of a single entry at the specified index */ -static void -get_hostlist_table_address(hostlist_table *hl, hostlist_talker_t *host, const char **entries) -{ - char *port; - guint32 pt; - - if (!hl->resolve_names) - entries[0] = ep_address_to_str(&host->myaddress); - else - entries[0] = (char *)ep_address_to_display(&host->myaddress); - - pt = host->port_type; - if(!hl->resolve_names) pt = PT_NONE; - switch(pt) { - case(PT_TCP): - entries[1] = ep_tcp_port_to_display(host->port); - break; - case(PT_UDP): - entries[1] = ep_udp_port_to_display(host->port); - break; - case(PT_SCTP): - entries[1] = ep_sctp_port_to_display(host->port); - break; - default: - port=hostlist_port_to_str(host->port_type, host->port); - entries[1] = port?port:""; - } -} - /* Refresh the address fields of all entries in the list */ static void draw_hostlist_table_addresses(hostlist_table *hl) { - guint32 i; - const char *entries[2]; + guint idx; GtkListStore *store; + GtkTreeIter iter; + gboolean iter_valid; store = GTK_LIST_STORE(gtk_tree_view_get_model(hl->table)); g_object_ref(store); gtk_tree_view_set_model(GTK_TREE_VIEW(hl->table), NULL); + iter_valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); + + while (iter_valid) { + hostlist_talker_t *host; + + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, HOST_INDEX_COLUMN, &idx, -1); + host = &g_array_index(hl->hash.conv_array, hostlist_talker_t, idx); - for(i=0;i<hl->num_hosts;i++){ - hostlist_talker_t *host = &g_array_index(hl->hosts, hostlist_talker_t, i); - get_hostlist_table_address(hl, host, entries); - gtk_list_store_set (store, &host->iter, - ADR_COLUMN, entries[0], - PORT_COLUMN, entries[1], + gtk_list_store_set (store, &iter, + HOST_ADR_COLUMN, get_conversation_address(&host->myaddress, hl->resolve_names), + HOST_PORT_COLUMN, get_conversation_port(host->port, host->ptype, hl->resolve_names), -1); + + iter_valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); } gtk_tree_view_set_model(GTK_TREE_VIEW(hl->table), GTK_TREE_MODEL(store)); g_object_unref(store); @@ -673,22 +504,24 @@ draw_hostlist_table_addresses(hostlist_table *hl) static void draw_hostlist_table_data(hostlist_table *hl) { - guint32 i; + guint idx, new_idx; char title[256]; GtkListStore *store; + GtkTreeIter iter; + gboolean iter_valid; gboolean first = TRUE; if (hl->page_lb) { - if(hl->num_hosts) { - g_snprintf(title, sizeof(title), "%s: %u", hl->name, hl->num_hosts); + if(hl->hash.conv_array && hl->hash.conv_array->len) { + g_snprintf(title, sizeof(title), "%s: %u", hl->name, hl->hash.conv_array->len); } else { g_snprintf(title, sizeof(title), "%s", hl->name); } gtk_label_set_text(GTK_LABEL(hl->page_lb), title); - gtk_widget_set_sensitive(hl->page_lb, hl->num_hosts); + gtk_widget_set_sensitive(hl->page_lb, hl->hash.conv_array && hl->hash.conv_array->len); } else { - if(hl->num_hosts) { - g_snprintf(title, sizeof(title), "%s Endpoints: %u", hl->name, hl->num_hosts); + if(hl->hash.conv_array && hl->hash.conv_array->len) { + g_snprintf(title, sizeof(title), "%s Endpoints: %u", hl->name, hl->hash.conv_array->len); } else { g_snprintf(title, sizeof(title), "%s Endpoints", hl->name); } @@ -696,11 +529,24 @@ draw_hostlist_table_data(hostlist_table *hl) } store = GTK_LIST_STORE(gtk_tree_view_get_model(hl->table)); - for(i=0;i<hl->num_hosts;i++){ - hostlist_talker_t *host = &g_array_index(hl->hosts, hostlist_talker_t, i); + iter_valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); + new_idx = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); + + while (iter_valid || (hl->hash.conv_array && new_idx < hl->hash.conv_array->len)) { + hostlist_talker_t *host; + + if (iter_valid) { + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, HOST_INDEX_COLUMN, &idx, -1); + } else { + idx = new_idx; + new_idx++; + } + host = &g_array_index(hl->hash.conv_array, hostlist_talker_t, idx); - if (!host->modified) + if (!host->modified) { + iter_valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); continue; + } if (first) { g_object_ref(store); @@ -709,8 +555,7 @@ draw_hostlist_table_data(hostlist_table *hl) first = FALSE; } host->modified = FALSE; - if (!host->iter_valid) { - const char *entries[2]; + if (!iter_valid) { #ifdef HAVE_GEOIP char *geoip[NUM_GEOIP_COLS]; guint j; @@ -727,7 +572,7 @@ draw_hostlist_table_data(hostlist_table *hl) column = (GtkTreeViewColumn *)columns->data; title_p = gtk_tree_view_column_get_title(column); id = gtk_tree_view_column_get_sort_column_id(column); - if (title_p[0] != 0 && id >= GEOIP1_COLUMN) { + if (title_p[0] != 0 && id >= HOST_GEOIP1_COLUMN) { gtk_tree_view_column_set_visible(column, TRUE); } columns = g_list_next(columns); @@ -753,33 +598,31 @@ draw_hostlist_table_data(hostlist_table *hl) } #endif /* HAVE_GEOIP */ - get_hostlist_table_address(hl, host, entries); - host->iter_valid = TRUE; - gtk_list_store_insert_with_values( store , &host->iter, G_MAXINT, - ADR_COLUMN, entries[0], - PORT_COLUMN, entries[1], - PACKETS_COLUMN, host->tx_frames+host->rx_frames, - BYTES_COLUMN, host->tx_bytes+host->rx_bytes, - PKT_AB_COLUMN, host->tx_frames, - BYTES_AB_COLUMN, host->tx_bytes, - PKT_BA_COLUMN, host->rx_frames, - BYTES_BA_COLUMN, host->rx_bytes, + gtk_list_store_insert_with_values( store, &iter, G_MAXINT, + HOST_ADR_COLUMN, get_conversation_address(&host->myaddress, hl->resolve_names), + HOST_PORT_COLUMN, get_conversation_port(host->port, host->ptype, hl->resolve_names), + HOST_PACKETS_COLUMN, host->tx_frames+host->rx_frames, + HOST_BYTES_COLUMN, host->tx_bytes+host->rx_bytes, + HOST_PKT_AB_COLUMN, host->tx_frames, + HOST_BYTES_AB_COLUMN, host->tx_bytes, + HOST_PKT_BA_COLUMN, host->rx_frames, + HOST_BYTES_BA_COLUMN, host->rx_bytes, #ifdef HAVE_GEOIP - GEOIP1_COLUMN, geoip[0], - GEOIP2_COLUMN, geoip[1], - GEOIP3_COLUMN, geoip[2], - GEOIP4_COLUMN, geoip[3], - GEOIP5_COLUMN, geoip[4], - GEOIP6_COLUMN, geoip[5], - GEOIP7_COLUMN, geoip[6], - GEOIP8_COLUMN, geoip[7], - GEOIP9_COLUMN, geoip[8], - GEOIP10_COLUMN, geoip[9], - GEOIP11_COLUMN, geoip[10], - GEOIP12_COLUMN, geoip[11], - GEOIP13_COLUMN, geoip[12], + HOST_GEOIP1_COLUMN, geoip[0], + HOST_GEOIP2_COLUMN, geoip[1], + HOST_GEOIP3_COLUMN, geoip[2], + HOST_GEOIP4_COLUMN, geoip[3], + HOST_GEOIP5_COLUMN, geoip[4], + HOST_GEOIP6_COLUMN, geoip[5], + HOST_GEOIP7_COLUMN, geoip[6], + HOST_GEOIP8_COLUMN, geoip[7], + HOST_GEOIP9_COLUMN, geoip[8], + HOST_GEOIP10_COLUMN, geoip[9], + HOST_GEOIP11_COLUMN, geoip[10], + HOST_GEOIP12_COLUMN, geoip[11], + HOST_GEOIP13_COLUMN, geoip[12], #endif - INDEX_COLUMN, i, + HOST_INDEX_COLUMN, idx, -1); #ifdef HAVE_GEOIP @@ -788,18 +631,20 @@ draw_hostlist_table_data(hostlist_table *hl) #endif /* HAVE_GEOIP */ } else { - gtk_list_store_set (store, &host->iter, - PACKETS_COLUMN, host->tx_frames+host->rx_frames, - BYTES_COLUMN, host->tx_bytes+host->rx_bytes, - PKT_AB_COLUMN, host->tx_frames, - BYTES_AB_COLUMN, host->tx_bytes, - PKT_BA_COLUMN, host->rx_frames, - BYTES_BA_COLUMN, host->rx_bytes, + gtk_list_store_set (store, &iter, + HOST_PACKETS_COLUMN, host->tx_frames+host->rx_frames, + HOST_BYTES_COLUMN, host->tx_bytes+host->rx_bytes, + HOST_PKT_AB_COLUMN, host->tx_frames, + HOST_BYTES_AB_COLUMN, host->tx_bytes, + HOST_PKT_BA_COLUMN, host->rx_frames, + HOST_BYTES_BA_COLUMN, host->rx_bytes, -1); } + + iter_valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); } if (!first) { - if (!hl->fixed_col && hl->num_hosts >= 1000) { + if (!hl->fixed_col && hl->hash.conv_array && hl->hash.conv_array->len >= 1000) { /* finding the right size for a column isn't easy * let it run in autosize a little (1000 is arbitrary) * and then switch to fixed width. @@ -816,12 +661,14 @@ draw_hostlist_table_data(hostlist_table *hl) static void draw_hostlist_table_data_cb(void *arg) { - draw_hostlist_table_data((hostlist_table *)arg); + conv_hash_t *hash = (conv_hash_t*)arg; + + draw_hostlist_table_data((hostlist_table *)hash->user_data); } typedef struct { int nb_cols; - gint columns_order[N_COLUMNS]; + gint columns_order[HOST_NUM_COLUMNS]; GString *CSV_str; hostlist_table *talkers; } csv_t; @@ -837,27 +684,27 @@ csv_handle(GtkTreeModel *model, GtkTreePath *path _U_, GtkTreeIter *iter, guint idx; guint64 value; - gtk_tree_model_get(model, iter, INDEX_COLUMN, &idx, -1); + gtk_tree_model_get(model, iter, HOST_INDEX_COLUMN, &idx, -1); for (i=0; i< csv->nb_cols; i++) { if (i) g_string_append(csv->CSV_str, ","); switch(csv->columns_order[i]) { - case ADR_COLUMN: - case PORT_COLUMN: + case HOST_ADR_COLUMN: + case HOST_PORT_COLUMN: gtk_tree_model_get(model, iter, csv->columns_order[i], &table_text, -1); if (table_text) { g_string_append_printf(csv->CSV_str, "\"%s\"", table_text); g_free(table_text); } break; - case PACKETS_COLUMN: - case BYTES_COLUMN: - case PKT_AB_COLUMN: - case BYTES_AB_COLUMN: - case PKT_BA_COLUMN: - case BYTES_BA_COLUMN: + case HOST_PACKETS_COLUMN: + case HOST_BYTES_COLUMN: + case HOST_PKT_AB_COLUMN: + case HOST_BYTES_AB_COLUMN: + case HOST_PKT_BA_COLUMN: + case HOST_BYTES_BA_COLUMN: gtk_tree_model_get(model, iter, csv->columns_order[i], &value, -1); g_string_append_printf(csv->CSV_str, "\"%" G_GINT64_MODIFIER "u\"", value); break; @@ -1176,34 +1023,34 @@ open_as_map_cb(GtkWindow *copy_bt, gpointer data _U_) } #endif /* HAVE_GEOIP */ -static gint default_col_size[N_COLUMNS]; +static gint default_col_size[HOST_NUM_COLUMNS]; static void init_default_col_size(GtkWidget *view) { - default_col_size[ADR_COLUMN] = get_default_col_size(view, "00000000.000000000000"); - default_col_size[PORT_COLUMN] = get_default_col_size(view, "000000"); - default_col_size[PACKETS_COLUMN] = get_default_col_size(view, "00 000 000"); - default_col_size[BYTES_COLUMN] = get_default_col_size(view, "0 000 000 000"); - default_col_size[PKT_AB_COLUMN] = default_col_size[PACKETS_COLUMN]; - default_col_size[PKT_BA_COLUMN] = default_col_size[PACKETS_COLUMN]; - default_col_size[BYTES_AB_COLUMN] = default_col_size[BYTES_COLUMN]; - default_col_size[BYTES_BA_COLUMN] = default_col_size[BYTES_COLUMN]; + default_col_size[HOST_ADR_COLUMN] = get_default_col_size(view, "00000000.000000000000"); + default_col_size[HOST_PORT_COLUMN] = get_default_col_size(view, "000000"); + default_col_size[HOST_PACKETS_COLUMN] = get_default_col_size(view, "00 000 000"); + default_col_size[HOST_BYTES_COLUMN] = get_default_col_size(view, "0 000 000 000"); + default_col_size[HOST_PKT_AB_COLUMN] = default_col_size[HOST_PACKETS_COLUMN]; + default_col_size[HOST_PKT_BA_COLUMN] = default_col_size[HOST_PACKETS_COLUMN]; + default_col_size[HOST_BYTES_AB_COLUMN] = default_col_size[HOST_BYTES_COLUMN]; + default_col_size[HOST_BYTES_BA_COLUMN] = default_col_size[HOST_BYTES_COLUMN]; #ifdef HAVE_GEOIP - default_col_size[GEOIP1_COLUMN] = default_col_size[ADR_COLUMN]; - default_col_size[GEOIP2_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP3_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP4_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP5_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP6_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP7_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP8_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP9_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP10_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP11_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP12_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP13_COLUMN] = default_col_size[GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP1_COLUMN] = default_col_size[HOST_ADR_COLUMN]; + default_col_size[HOST_GEOIP2_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP3_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP4_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP5_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP6_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP7_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP8_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP9_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP10_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP11_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP12_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP13_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; #endif } @@ -1247,7 +1094,6 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi } hosttable->has_ports=!hide_ports; - hosttable->num_hosts = 0; hosttable->resolve_names=TRUE; hosttable->page_lb = NULL; hosttable->fixed_col = FALSE; @@ -1258,7 +1104,7 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi gtk_box_pack_start(GTK_BOX(vbox), hosttable->name_lb, FALSE, FALSE, 0); /* Create the store */ - store = gtk_list_store_new (N_COLUMNS, /* Total number of columns */ + store = gtk_list_store_new (HOST_NUM_COLUMNS + 1, /* Total number of columns */ G_TYPE_STRING, /* Address */ G_TYPE_STRING, /* Port */ G_TYPE_UINT64, /* Packets */ @@ -1286,6 +1132,7 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi hosttable->scrolled_window=scrolled_window_new(NULL, NULL); gtk_box_pack_start(GTK_BOX(vbox), hosttable->scrolled_window, TRUE, TRUE, 0); + tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); hosttable->table = GTK_TREE_VIEW(tree); sortable = GTK_TREE_SORTABLE(store); @@ -1299,26 +1146,26 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi g_object_set_data(G_OBJECT(store), HOST_PTR_KEY, hosttable); g_object_set_data(G_OBJECT(hosttable->table), HOST_PTR_KEY, hosttable); - for (i = 0; i < N_COLUMNS -1; i++) { + for (i = 0; i < HOST_NUM_COLUMNS; i++) { renderer = gtk_cell_renderer_text_new (); g_object_set(renderer, "ypad", 0, NULL); switch(i) { - case 0: /* address and port */ - case 1: + case HOST_ADR_COLUMN: /* address and port */ + case HOST_PORT_COLUMN: column = gtk_tree_view_column_new_with_attributes (hosttable->default_titles[i], renderer, "text", i, NULL); - if(hide_ports && i == 1){ + if(hide_ports && i == HOST_PORT_COLUMN){ /* hide srcport and dstport if we don't use ports */ gtk_tree_view_column_set_visible(column, FALSE); } gtk_tree_sortable_set_sort_func(sortable, i, hostlist_sort_column, GINT_TO_POINTER(i), NULL); break; - case 2: /* counts */ - case 3: - case 4: - case 5: - case 6: - case 7: /* right align numbers */ + case HOST_PACKETS_COLUMN: /* counts */ + case HOST_BYTES_COLUMN: + case HOST_PKT_AB_COLUMN: + case HOST_BYTES_AB_COLUMN: + case HOST_PKT_BA_COLUMN: + case HOST_BYTES_BA_COLUMN: /* right align numbers */ g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL); column = gtk_tree_view_column_new_with_attributes (hosttable->default_titles[i], renderer, NULL); gtk_tree_view_column_set_cell_data_func(column, renderer, u64_data_func, GINT_TO_POINTER(i), NULL); @@ -1354,15 +1201,14 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi } gtk_container_add(GTK_CONTAINER(hosttable->scrolled_window), (GtkWidget *)hosttable->table); - - hosttable->num_hosts=0; - hosttable->hosts=NULL; - hosttable->hashtable=NULL; - gtk_tree_view_set_rules_hint(hosttable->table, TRUE); gtk_tree_view_set_headers_clickable(hosttable->table, TRUE); gtk_tree_view_set_reorderable (hosttable->table, TRUE); + hosttable->hash.conv_array = NULL; + hosttable->hash.hashtable = NULL; + hosttable->hash.user_data = hosttable; + sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(hosttable->table)); gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); @@ -1370,7 +1216,7 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi hostlist_create_popup_menu(hosttable); /* register the tap and rerun the taps on the packet list */ - error_string=register_tap_listener(tap_name, hosttable, filter, 0, reset_hostlist_table_data_cb, packet_func, draw_hostlist_table_data_cb); + error_string=register_tap_listener(tap_name, &hosttable->hash, filter, 0, reset_hostlist_table_data_cb, packet_func, draw_hostlist_table_data_cb); if(error_string){ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); g_string_free(error_string, TRUE); @@ -1382,7 +1228,7 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi void -init_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap_name, const char *filter, tap_packet_cb packet_func) +init_hostlist_table(struct register_ct* ct, const char *filter) { hostlist_table *hosttable; char *display_name; @@ -1397,13 +1243,13 @@ init_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap #endif window_geometry_t tl_geom; - hosttable=g_new(hostlist_table,1); + hosttable=g_new0(hostlist_table,1); - hosttable->name=table_name; + hosttable->name=proto_get_protocol_short_name(find_protocol_by_id(get_conversation_proto_id(ct))); hosttable->filter=filter; hosttable->use_dfilter=FALSE; display_name = cf_get_display_name(&cfile); - g_snprintf(title, sizeof(title), "%s Endpoints: %s", table_name, display_name); + g_snprintf(title, sizeof(title), "%s Endpoints: %s", hosttable->name, display_name); g_free(display_name); hosttable->win = dlg_window_new(title); /* transient_for top_level */ gtk_window_set_destroy_with_parent (GTK_WINDOW(hosttable->win), TRUE); @@ -1415,7 +1261,8 @@ init_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap gtk_container_add(GTK_CONTAINER(hosttable->win), vbox); gtk_container_set_border_width(GTK_CONTAINER(vbox), DLG_OUTER_MARGIN); - ret = init_hostlist_table_page(hosttable, vbox, hide_ports, table_name, tap_name, filter, packet_func); + ret = init_hostlist_table_page(hosttable, vbox, get_conversation_hide_ports(ct), hosttable->name, + proto_get_protocol_filter_name(get_conversation_proto_id(ct)), filter, get_hostlist_packet_func(ct)); if(ret == FALSE) { g_free(hosttable); return; @@ -1425,7 +1272,7 @@ init_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap /* XXX - maybe we want to have a "Copy as CSV" stock button here? */ /*copy_bt = gtk_button_new_with_label ("Copy content to clipboard as CSV");*/ #ifdef HAVE_GEOIP - if( strstr(table_name, "IPv4") || strstr(table_name, "IPv6") ) { + if( strstr(hosttable->name, "IPv4") || strstr(hosttable->name, "IPv6") ) { bbox = dlg_button_row_new(GTK_STOCK_CLOSE, GTK_STOCK_COPY, WIRESHARK_STOCK_MAP, GTK_STOCK_HELP, NULL); } else { bbox = dlg_button_row_new(GTK_STOCK_CLOSE, GTK_STOCK_COPY, GTK_STOCK_HELP, NULL); @@ -1519,15 +1366,14 @@ hostlist_win_destroy_notebook_cb(GtkWindow *win _U_, gpointer data) static hostlist_table * -init_hostlist_notebook_page_cb(gboolean hide_ports, const char *table_name, const char *tap_name, const char *filter, - tap_packet_cb packet_func) +init_hostlist_notebook_page_cb(register_ct_t *table, const char *filter) { gboolean ret; GtkWidget *page_vbox; hostlist_table *hosttable; - hosttable=g_new(hostlist_table,1); - hosttable->name=table_name; + hosttable=g_new0(hostlist_table,1); + hosttable->name=proto_get_protocol_short_name(find_protocol_by_id(get_conversation_proto_id(table))); hosttable->filter=filter; hosttable->use_dfilter=FALSE; @@ -1535,7 +1381,8 @@ init_hostlist_notebook_page_cb(gboolean hide_ports, const char *table_name, cons hosttable->win = page_vbox; gtk_container_set_border_width(GTK_CONTAINER(page_vbox), 6); - ret = init_hostlist_table_page(hosttable, page_vbox, hide_ports, table_name, tap_name, filter, packet_func); + ret = init_hostlist_table_page(hosttable, page_vbox, get_conversation_hide_ports(table), hosttable->name, + proto_get_protocol_filter_name(get_conversation_proto_id(table)), filter, get_hostlist_packet_func(table)); if(ret == FALSE) { g_free(hosttable); return NULL; @@ -1544,35 +1391,6 @@ init_hostlist_notebook_page_cb(gboolean hide_ports, const char *table_name, cons return hosttable; } - -typedef struct { - gboolean hide_ports; /* hide TCP / UDP port columns */ - const char *table_name; /* GUI output name */ - const char *tap_name; /* internal name */ - const char *filter; /* display filter string (unused) */ - tap_packet_cb packet_func; /* function to be called for new incoming packets */ -} register_hostlist_t; - - -static GSList *registered_hostlist_tables = NULL; - -void -register_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap_name, const char *filter, tap_packet_cb packet_func) -{ - register_hostlist_t *table; - - table = g_new(register_hostlist_t,1); - - table->hide_ports = hide_ports; - table->table_name = table_name; - table->tap_name = tap_name; - table->filter = filter; - table->packet_func = packet_func; - - registered_hostlist_tables = g_slist_append(registered_hostlist_tables, table); -} - - static void hostlist_resolve_toggle_dest(GtkWidget *widget, gpointer data) { @@ -1605,7 +1423,7 @@ hostlist_filter_toggle_dest(GtkWidget *widget, gpointer data) for (page=1; page<=GPOINTER_TO_INT(pages[0]); page++) { hosttable = (hostlist_table *)pages[page]; hosttable->use_dfilter = use_filter; - reset_hostlist_table_data(hosttable); + reset_host_table_data(hosttable); } cf_retap_packets(&cfile); @@ -1614,11 +1432,36 @@ hostlist_filter_toggle_dest(GtkWidget *widget, gpointer data) } } +typedef struct _init_host_page_data { + int page; + void ** pages; + GtkWidget *nb; + GtkWidget *win; +} init_host_page_data; + +static void +init_host_page(gpointer data, gpointer user_data) +{ + register_ct_t *table = (register_ct_t*)data; + init_host_page_data* host_page_data = (init_host_page_data*)user_data; + + hostlist_table *hosttable; + GtkWidget *page_lb; + + hosttable = init_hostlist_notebook_page_cb(table, NULL /*filter*/); + if (hosttable) { + g_object_set_data(G_OBJECT(hosttable->win), HOST_PTR_KEY, hosttable); + page_lb = gtk_label_new(""); + gtk_notebook_append_page(GTK_NOTEBOOK(host_page_data->nb), hosttable->win, page_lb); + hosttable->win = host_page_data->win; + hosttable->page_lb = page_lb; + host_page_data->pages[++host_page_data->page] = hosttable; + } +} void init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_) { - hostlist_table *hosttable; char *display_name; char title[256]; GtkWidget *vbox; @@ -1628,19 +1471,16 @@ init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_) GtkWidget *win; GtkWidget *resolv_cb; GtkWidget *filter_cb; - int page; void ** pages; GtkWidget *nb; - GtkWidget *page_lb; - GSList *current_table; - register_hostlist_t *registered; GtkWidget *copy_bt; #ifdef HAVE_GEOIP GtkWidget *map_bt; #endif window_geometry_t tl_geom; + init_host_page_data host_page_iter_data; - pages = (void **)g_malloc(sizeof(void *) * (g_slist_length(registered_hostlist_tables) + 1)); + pages = (void **)g_malloc(sizeof(void *) * (conversation_table_get_num() + 1)); win = dlg_window_new("hostlist"); /* transient_for top_level */ gtk_window_set_destroy_with_parent (GTK_WINDOW(win), TRUE); @@ -1661,25 +1501,14 @@ init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_) gtk_box_pack_start(GTK_BOX(vbox), nb, TRUE, TRUE, 0); g_object_set_data(G_OBJECT(nb), NB_PAGES_KEY, pages); - page = 0; + host_page_iter_data.page = 0; + host_page_iter_data.pages = pages; + host_page_iter_data.nb = nb; + host_page_iter_data.win = win; - current_table = registered_hostlist_tables; - while(current_table) { - registered = (register_hostlist_t *)current_table->data; - page_lb = gtk_label_new(""); - hosttable = init_hostlist_notebook_page_cb(registered->hide_ports, registered->table_name, registered->tap_name, - registered->filter, registered->packet_func); - g_object_set_data(G_OBJECT(hosttable->win), HOST_PTR_KEY, hosttable); - gtk_notebook_append_page(GTK_NOTEBOOK(nb), hosttable->win, page_lb); - hosttable->win = win; - hosttable->page_lb = page_lb; - pages[++page] = hosttable; - - current_table = g_slist_next(current_table); - } - - pages[0] = GINT_TO_POINTER(page); + conversation_table_iterate_tables(init_host_page, &host_page_iter_data); + pages[0] = GINT_TO_POINTER(host_page_iter_data.page); hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DLG_UNRELATED_SPACING, FALSE); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); @@ -1706,18 +1535,20 @@ init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_) #endif gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); + /* Close */ close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); window_set_cancel_button(win, close_bt, window_cancel_button_cb); + /* Copy */ copy_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_COPY); gtk_widget_set_tooltip_text(copy_bt, "Copy all statistical values of this page to the clipboard in CSV (Comma Separated Values) format."); g_signal_connect(copy_bt, "clicked", G_CALLBACK(copy_as_csv_cb), NULL); - g_object_set_data(G_OBJECT(copy_bt), HOST_PTR_KEY, pages[page]); + g_object_set_data(G_OBJECT(copy_bt), HOST_PTR_KEY, pages[host_page_iter_data.page]); #ifdef HAVE_GEOIP map_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_MAP); gtk_widget_set_tooltip_text(map_bt, "Show a map of the IP addresses (internet connection required)."); - g_object_set_data(G_OBJECT(map_bt), HOST_PTR_KEY, pages[page]); + g_object_set_data(G_OBJECT(map_bt), HOST_PTR_KEY, pages[host_page_iter_data.page]); g_signal_connect(map_bt, "clicked", G_CALLBACK(open_as_map_cb), NULL); g_signal_connect(nb, "switch-page", G_CALLBACK(ct_nb_map_switch_page_cb), map_bt); gtk_widget_set_sensitive(map_bt, FALSE); @@ -1738,115 +1569,14 @@ init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_) gdk_window_raise(gtk_widget_get_window(win)); } -/* - * Compute the hash value for a given address/port pairs if the match - * is to be exact. - */ -typedef struct { - address myaddress; - guint32 port; -} host_key_t; - -static guint -host_hash(gconstpointer v) +void hostlist_endpoint_cb(register_ct_t* table) { - const host_key_t *key = (const host_key_t *)v; - guint hash_val; - - hash_val = 0; - ADD_ADDRESS_TO_HASH(hash_val, &key->myaddress); - hash_val += key->port; - return hash_val; -} + char cmd_str[50]; -/* - * Compare two host keys for an exact match. - */ -static gint -host_match(gconstpointer v, gconstpointer w) -{ - const host_key_t *v1 = (const host_key_t *)v; - const host_key_t *v2 = (const host_key_t *)w; + g_snprintf(cmd_str, 50, "%s,%s", (get_hostlist_prefix_func(table) != NULL) ? get_hostlist_prefix_func(table)() : "host", + proto_get_protocol_filter_name(get_conversation_proto_id(table))); - if (v1->port == v2->port && - ADDRESSES_EQUAL(&v1->myaddress, &v2->myaddress)) { - return 1; - } - /* - * The addresses or the ports don't match. - */ - return 0; -} - -void -add_hostlist_table_data(hostlist_table *hl, const address *addr, guint32 port, gboolean sender, int num_frames, int num_bytes, conversation_type_e conv_type, int port_type_val) -{ - hostlist_talker_t *talker=NULL; - int talker_idx=0; - - /* XXX should be optimized to allocate n extra entries at a time - instead of just one */ - /* if we dont have any entries at all yet */ - if(hl->hosts==NULL){ - hl->hosts=g_array_sized_new(FALSE, FALSE, sizeof(hostlist_talker_t), 10000); - hl->hashtable = g_hash_table_new_full(host_hash, - host_match, /* key_equal_func */ - g_free, /* key_destroy_func */ - NULL); /* value_destroy_func */ - } - else { - /* try to find it among the existing known conversations */ - host_key_t existing_key; - - existing_key.myaddress = *addr; - existing_key.port = port; - talker_idx = GPOINTER_TO_UINT(g_hash_table_lookup(hl->hashtable, &existing_key)); - if (talker_idx) { - talker_idx--; - talker=&g_array_index(hl->hosts, hostlist_talker_t, talker_idx); - } - } - - /* if we still dont know what talker this is it has to be a new one - and we have to allocate it and append it to the end of the list */ - if(talker==NULL){ - host_key_t *new_key; - hostlist_talker_t host; - - COPY_ADDRESS(&host.myaddress, addr); - host.sat=conv_type; - host.port_type=port_type_val; - host.port=port; - host.rx_frames=0; - host.tx_frames=0; - host.rx_bytes=0; - host.tx_bytes=0; - host.iter_valid = FALSE; - host.modified = TRUE; - - g_array_append_val(hl->hosts, host); - talker_idx= hl->num_hosts; - talker=&g_array_index(hl->hosts, hostlist_talker_t, talker_idx); - - /* hl->hosts address is not a constant but address.data is */ - new_key = g_new(host_key_t,1); - SET_ADDRESS(&new_key->myaddress, talker->myaddress.type, talker->myaddress.len, talker->myaddress.data); - new_key->port = port; - g_hash_table_insert(hl->hashtable, new_key, GUINT_TO_POINTER(talker_idx +1)); - hl->num_hosts++; - } - - /* if this is a new talker we need to initialize the struct */ - talker->modified = TRUE; - - /* update the talker struct */ - if( sender ){ - talker->tx_frames+=num_frames; - talker->tx_bytes+=num_bytes; - } else { - talker->rx_frames+=num_frames; - talker->rx_bytes+=num_bytes; - } + dissector_hostlist_init(cmd_str, table); } /* diff --git a/ui/gtk/hostlist_table.h b/ui/gtk/hostlist_table.h index eb1f157662..e7742b8be1 100644 --- a/ui/gtk/hostlist_table.h +++ b/ui/gtk/hostlist_table.h @@ -24,51 +24,42 @@ #ifndef __HOSTLIST_TABLE_H__ #define __HOSTLIST_TABLE_H__ -#include <ui/conversation_ui.h> +#include <epan/conversation_table.h> /** @file * Hostlist definitions. */ -/** Conversation types */ -/* Sort alphabetically by title */ -typedef enum { - CONV_TYPE_ETHERNET, - CONV_TYPE_FIBRE_CHANNEL, - CONV_TYPE_FDDI, - CONV_TYPE_IPV4, - CONV_TYPE_IPV6, - CONV_TYPE_IPX, - CONV_TYPE_JXTA, - CONV_TYPE_NCP, - CONV_TYPE_RSVP, - CONV_TYPE_SCTP, - CONV_TYPE_TCP, - CONV_TYPE_TOKEN_RING, - CONV_TYPE_UDP, - CONV_TYPE_USB, - CONV_TYPE_WLAN, - N_CONV_TYPES -} conversation_type_e; - - -/** Hostlist information */ -typedef struct _hostlist_talker_t { - address myaddress; /**< address */ - conversation_type_e sat; /**< address type */ - guint32 port_type; /**< port_type (e.g. PT_TCP) */ - guint32 port; /**< port */ - - guint64 rx_frames; /**< number of received packets */ - guint64 tx_frames; /**< number of transmitted packets */ - guint64 rx_bytes; /**< number of received bytes */ - guint64 tx_bytes; /**< number of transmitted bytes */ +typedef enum +{ + HOST_ADR_COLUMN, + HOST_PORT_COLUMN, + HOST_PACKETS_COLUMN, + HOST_BYTES_COLUMN, + HOST_PKT_AB_COLUMN, + HOST_BYTES_AB_COLUMN, + HOST_PKT_BA_COLUMN, + HOST_BYTES_BA_COLUMN, +#ifdef HAVE_GEOIP + HOST_GEOIP1_COLUMN, + HOST_GEOIP2_COLUMN, + HOST_GEOIP3_COLUMN, + HOST_GEOIP4_COLUMN, + HOST_GEOIP5_COLUMN, + HOST_GEOIP6_COLUMN, + HOST_GEOIP7_COLUMN, + HOST_GEOIP8_COLUMN, + HOST_GEOIP9_COLUMN, + HOST_GEOIP10_COLUMN, + HOST_GEOIP11_COLUMN, + HOST_GEOIP12_COLUMN, + HOST_GEOIP13_COLUMN, +#endif + HOST_NUM_COLUMNS, + HOST_INDEX_COLUMN = HOST_NUM_COLUMNS +} hostlist_column_type_e; - gboolean modified; /**< new to redraw the row */ - GtkTreeIter iter; - gboolean iter_valid; /**< not a new row */ -} hostlist_talker_t; #define NUM_BUILTIN_COLS 8 #ifdef HAVE_GEOIP @@ -91,33 +82,18 @@ typedef struct _hostlist_table { const char *default_titles[NUM_HOSTLIST_COLS]; /**< Column headers */ GtkWidget *menu; /**< context menu */ gboolean has_ports; /**< table has ports */ - guint32 num_hosts; /**< number of hosts (0 or 1) */ - GArray *hosts; /**< array of host values */ - GHashTable *hashtable; /**< conversations hash table */ - gboolean fixed_col; /**< if switched to fixed column */ + conv_hash_t hash; /**< hostlist hash table */ + gboolean fixed_col; /**< if switched to fixed column */ gboolean resolve_names; /**< resolve address names? */ gboolean geoip_visible; /**< if geoip columns are visible */ } hostlist_table; -/** Register the hostlist table for the multiple hostlist window. - * - * @param hide_ports hide the port columns - * @param table_name the table name to be displayed - * @param tap_name the registered tap name - * @param filter the optional filter name or NULL - * @param packet_func the function to be called for each incoming packet - */ -extern void register_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap_name, const char *filter, tap_packet_cb packet_func); - /** Init the hostlist table for the single hostlist window. * - * @param hide_ports hide the port columns - * @param table_name the table name to be displayed - * @param tap_name the registered tap name + * @param ct the registered hostlist (conversation) * @param filter the optional filter name or NULL - * @param packet_func the function to be called for each incoming packet */ -extern void init_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap_name, const char *filter, tap_packet_cb packet_func); +extern void init_hostlist_table(struct register_ct* ct, const char *filter); /** Callback for "Endpoints" statistics item. * @@ -126,18 +102,10 @@ extern void init_hostlist_table(gboolean hide_ports, const char *table_name, con */ extern void init_hostlist_notebook_cb(GtkWidget *w, gpointer d); -/** Add some data to the table. +/** Function called to instantiate the "GTK hostlist display" * - * @param hl the table to add the data to - * @param addr address - * @param port port - * @param sender TRUE, if this is a sender - * @param num_frames number of packets - * @param num_bytes number of bytes - * @param sat address type - * @param port_type the port type (e.g. PT_TCP) + * @param table conversation table to be created */ -void add_hostlist_table_data(hostlist_table *hl, const address *addr, - guint32 port, gboolean sender, int num_frames, int num_bytes, conversation_type_e sat, int port_type); +extern void hostlist_endpoint_cb(register_ct_t* table); #endif /* __HOSTLIST_TABLE_H__ */ diff --git a/ui/gtk/hostlist_tcpip.c b/ui/gtk/hostlist_tcpip.c deleted file mode 100644 index 8f9657b143..0000000000 --- a/ui/gtk/hostlist_tcpip.c +++ /dev/null @@ -1,84 +0,0 @@ -/* hostlist_tcpip.c 2004 Ian Schorr - * modified from endpoint_talkers_tcpip.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-tcp.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_tcpip_hostlist(void); - -static int -tcpip_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)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(hosts, &tcphdr->ip_src, tcphdr->th_sport, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_TCP, PT_TCP); - add_hostlist_table_data(hosts, &tcphdr->ip_dst, tcphdr->th_dport, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_TCP, PT_TCP); - - return 1; -} - - - -static void -gtk_tcpip_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"endpoints,tcp,",14)){ - filter=opt_arg+14; - } else { - filter=NULL; - } - - init_hostlist_table(FALSE, "TCP", "tcp", filter, tcpip_hostlist_packet); - -} - -void -gtk_tcpip_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_tcpip_hostlist_init("endpoints,tcp",NULL); -} - -void -register_tap_listener_tcpip_hostlist(void) -{ - register_stat_cmd_arg("endpoints,tcp", gtk_tcpip_hostlist_init,NULL); - register_hostlist_table(FALSE, "TCP", "tcp", NULL /*filter*/, tcpip_hostlist_packet); -} diff --git a/ui/gtk/hostlist_tr.c b/ui/gtk/hostlist_tr.c deleted file mode 100644 index a42ecdf355..0000000000 --- a/ui/gtk/hostlist_tr.c +++ /dev/null @@ -1,84 +0,0 @@ -/* hostlist_tr.c 2004 Ian Schorr - * modified from endpoint_talkers_tr.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-tr.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_tr_hostlist(void); - -static int -tr_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)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(hosts, &trhdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_TOKEN_RING, PT_NONE); - add_hostlist_table_data(hosts, &trhdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_TOKEN_RING, PT_NONE); - - return 1; -} - - - -static void -gtk_tr_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,tr,",9)){ - filter=opt_arg+9; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "Token Ring", "tr", filter, tr_hostlist_packet); - -} - -void -gtk_tr_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_tr_hostlist_init("hosts,tr",NULL); -} - -void -register_tap_listener_tr_hostlist(void) -{ - register_stat_cmd_arg("hosts,tr", gtk_tr_hostlist_init,NULL); - register_hostlist_table(TRUE, "Token Ring", "tr", NULL /*filter*/, tr_hostlist_packet); -} diff --git a/ui/gtk/hostlist_udpip.c b/ui/gtk/hostlist_udpip.c deleted file mode 100644 index de72c18904..0000000000 --- a/ui/gtk/hostlist_udpip.c +++ /dev/null @@ -1,84 +0,0 @@ -/* hostlist_udpip.c 2004 Ian Schorr - * modified from endpoint_talkers_udpip.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-udp.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_udpip_hostlist(void); - -static int -udpip_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)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(hosts, &udphdr->ip_src, udphdr->uh_sport, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_UDP, PT_UDP); - add_hostlist_table_data(hosts, &udphdr->ip_dst, udphdr->uh_dport, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_UDP, PT_UDP); - - return 1; -} - - - -static void -gtk_udpip_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"endpoints,udp,",14)){ - filter=opt_arg+14; - } else { - filter=NULL; - } - - init_hostlist_table(FALSE, "UDP", "udp", filter, udpip_hostlist_packet); - -} - -void -gtk_udpip_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_udpip_hostlist_init("endpoints,udp",NULL); -} - -void -register_tap_listener_udpip_hostlist(void) -{ - register_stat_cmd_arg("endpoints,udp", gtk_udpip_hostlist_init,NULL); - register_hostlist_table(FALSE, "UDP", "udp", NULL /*filter*/, udpip_hostlist_packet); -} diff --git a/ui/gtk/hostlist_usb.c b/ui/gtk/hostlist_usb.c deleted file mode 100644 index abecdb0b18..0000000000 --- a/ui/gtk/hostlist_usb.c +++ /dev/null @@ -1,81 +0,0 @@ -/* hostlist_usb.c 2007 Jon Smirl - * modified from endpoint_talkers_eth.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-usb.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_usb_hostlist(void); - -static int -usb_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip _U_) -{ - hostlist_table *hosts=(hostlist_table *)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(hosts, &pinfo->src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_USB, PT_NONE); - add_hostlist_table_data(hosts, &pinfo->dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_USB, PT_NONE); - - return 1; -} - -static void -gtk_usb_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if (!strncmp(opt_arg, "hosts,usb," ,10)) { - filter = opt_arg + 10; - } else { - filter = NULL; - } - - init_hostlist_table(TRUE, "USB", "usb", filter, usb_hostlist_packet); - -} - -void -gtk_usb_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_usb_hostlist_init("hosts,usb", NULL); -} - -void -register_tap_listener_usb_hostlist(void) -{ - register_stat_cmd_arg("hosts,usb", gtk_usb_hostlist_init, NULL); - register_hostlist_table(TRUE, "USB", "usb", NULL /*filter*/, usb_hostlist_packet); -} diff --git a/ui/gtk/hostlist_wlan.c b/ui/gtk/hostlist_wlan.c deleted file mode 100644 index b83b1966f7..0000000000 --- a/ui/gtk/hostlist_wlan.c +++ /dev/null @@ -1,82 +0,0 @@ -/* hostlist_wlan.c 2004 Giles Scott - * modified from endpoint_talkers_eth.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-ieee80211.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_wlan_hostlist(void); - -static int -wlan_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)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(hosts, &whdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_WLAN, PT_NONE); - add_hostlist_table_data(hosts, &whdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_WLAN, PT_NONE); - - return 1; -} - -static void -gtk_wlan_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,wlan,",11)){ - filter=opt_arg+11; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "WLAN", "wlan", filter, wlan_hostlist_packet); - -} - -void -gtk_wlan_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_wlan_hostlist_init("hosts,wlan",NULL); -} - -void -register_tap_listener_wlan_hostlist(void) -{ - register_stat_cmd_arg("hosts,wlan", gtk_wlan_hostlist_init,NULL); - register_hostlist_table(TRUE, "WLAN", "wlan", NULL /*filter*/, wlan_hostlist_packet); -} diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 00facabdff..a057ca7022 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -191,6 +191,7 @@ #include "ui/gtk/packet_list.h" #include "ui/gtk/filter_expression_save_dlg.h" #include "ui/gtk/conversations_table.h" +#include "ui/gtk/hostlist_table.h" #include "ui/gtk/old-gtk-compat.h" @@ -2578,6 +2579,7 @@ main(int argc, char *argv[]) register_all_tap_listeners(); conversation_table_set_gui_info(init_conversation_table); + hostlist_table_set_gui_info(init_hostlist_table); splash_update(RA_PREFERENCES, NULL, (gpointer)splash_win); diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index d36bc7c51f..fa6cab1bc4 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -1190,21 +1190,7 @@ static const char *ui_desc_menubar = " <placeholder name='Conversations'/>\n" " </menu>\n" " <menu name= 'EndpointListMenu' action='/Statistics/EndpointList'>\n" -" <menuitem name='Ethernet' action='/Statistics/EndpointList/Ethernet'/>\n" -" <menuitem name='FibreChannel' action='/Statistics/EndpointList/FibreChannel'/>\n" -" <menuitem name='FDDI' action='/Statistics/EndpointList/FDDI'/>\n" -" <menuitem name='IP' action='/Statistics/EndpointList/IP'/>\n" -" <menuitem name='IPv6' action='/Statistics/EndpointList/IPv6'/>\n" -" <menuitem name='IPX' action='/Statistics/EndpointList/IPX'/>\n" -" <menuitem name='JXTA' action='/Statistics/EndpointList/JXTA'/>\n" -" <menuitem name='NCP' action='/Statistics/EndpointList/NCP'/>\n" -" <menuitem name='RSVP' action='/Statistics/EndpointList/RSVP'/>\n" -" <menuitem name='SCTP' action='/Statistics/EndpointList/SCTP'/>\n" -" <menuitem name='TCPIP' action='/Statistics/EndpointList/TCPIP'/>\n" -" <menuitem name='TR' action='/Statistics/EndpointList/TR'/>\n" -" <menuitem name='UDPIP' action='/Statistics/EndpointList/UDPIP'/>\n" -" <menuitem name='USB' action='/Statistics/EndpointList/USB'/>\n" -" <menuitem name='WLAN' action='/Statistics/EndpointList/WLAN'/>\n" +" <placeholder name='Endpoints'/>\n" " </menu>\n" " <menu name='ServiceResponseTimeMenu' action='/Statistics/ServiceResponseTime'>\n" " <menuitem name='DCE-RPC' action='/Statistics/ServiceResponseTime/DCE-RPC'/>\n" @@ -1642,21 +1628,6 @@ static const GtkActionEntry main_menu_bar_entries[] = { { "/Statistics/ConversationList", NULL, "_Conversation List", NULL, NULL, NULL }, { "/Statistics/EndpointList", NULL, "_Endpoint List", NULL, NULL, NULL }, - { "/Statistics/EndpointList/Ethernet", WIRESHARK_STOCK_ENDPOINTS, "Ethernet", NULL, NULL, G_CALLBACK(gtk_eth_hostlist_cb) }, - { "/Statistics/EndpointList/FibreChannel", WIRESHARK_STOCK_ENDPOINTS, "Fibre Channel", NULL, NULL, G_CALLBACK(gtk_fc_hostlist_cb) }, - { "/Statistics/EndpointList/FDDI", WIRESHARK_STOCK_ENDPOINTS, "FDDI", NULL, NULL, G_CALLBACK(gtk_fddi_hostlist_cb) }, - { "/Statistics/EndpointList/IP", WIRESHARK_STOCK_ENDPOINTS, "IPv4", NULL, NULL, G_CALLBACK(gtk_ip_hostlist_cb) }, - { "/Statistics/EndpointList/IPv6", WIRESHARK_STOCK_ENDPOINTS, "IPv6", NULL, NULL, G_CALLBACK(gtk_ipv6_hostlist_cb) }, - { "/Statistics/EndpointList/IPX", WIRESHARK_STOCK_ENDPOINTS, "IPX", NULL, NULL, G_CALLBACK(gtk_ipx_hostlist_cb) }, - { "/Statistics/EndpointList/JXTA", WIRESHARK_STOCK_ENDPOINTS, "JXTA", NULL, NULL, G_CALLBACK(gtk_jxta_hostlist_cb) }, - { "/Statistics/EndpointList/NCP", WIRESHARK_STOCK_ENDPOINTS, "NCP", NULL, NULL, G_CALLBACK(gtk_ncp_hostlist_cb) }, - { "/Statistics/EndpointList/RSVP", WIRESHARK_STOCK_ENDPOINTS, "RSVP", NULL, NULL, G_CALLBACK(gtk_rsvp_hostlist_cb) }, - { "/Statistics/EndpointList/SCTP", WIRESHARK_STOCK_ENDPOINTS, "SCTP", NULL, NULL, G_CALLBACK(gtk_sctp_hostlist_cb) }, - { "/Statistics/EndpointList/TCPIP", WIRESHARK_STOCK_ENDPOINTS, "TCP (IPv4 & IPv6)", NULL, NULL, G_CALLBACK(gtk_tcpip_hostlist_cb) }, - { "/Statistics/EndpointList/TR", WIRESHARK_STOCK_ENDPOINTS, "Token Ring", NULL, NULL, G_CALLBACK(gtk_tr_hostlist_cb) }, - { "/Statistics/EndpointList/UDPIP", WIRESHARK_STOCK_ENDPOINTS, "UDP (IPv4 & IPv6)", NULL, NULL, G_CALLBACK(gtk_udpip_hostlist_cb) }, - { "/Statistics/EndpointList/USB", WIRESHARK_STOCK_ENDPOINTS, "USB", NULL, NULL, G_CALLBACK(gtk_usb_hostlist_cb) }, - { "/Statistics/EndpointList/WLAN", WIRESHARK_STOCK_ENDPOINTS, "WLAN", NULL, NULL, G_CALLBACK(gtk_wlan_hostlist_cb) }, { "/Statistics/ServiceResponseTime", NULL, "Service _Response Time", NULL, NULL, NULL }, { "/Statistics/ServiceResponseTime/DCE-RPC", WIRESHARK_STOCK_TIME, "DCE-RPC...", NULL, NULL, G_CALLBACK(gtk_dcerpcstat_cb) }, @@ -3406,6 +3377,70 @@ menu_conversation_list(capture_file *cf) } static void +menu_hostlist_cb(GtkAction *action _U_, gpointer user_data) +{ + register_ct_t *table = (register_ct_t*)user_data; + + hostlist_endpoint_cb(table); +} + +static void +add_hostlist_menuitem(gpointer data, gpointer user_data) +{ + register_ct_t *table = (register_ct_t*)data; + conv_menu_t *conv = (conv_menu_t*)user_data; + gchar *action_name; + GtkAction *action; + + action_name = g_strdup_printf ("hostlist-%u", conv->counter); + /*g_warning("action_name %s, filter_entry->name %s",action_name,filter_entry->name);*/ + action = (GtkAction *)g_object_new (GTK_TYPE_ACTION, + "name", action_name, + "label", proto_get_protocol_short_name(find_protocol_by_id(get_conversation_proto_id(table))), + "sensitive", TRUE, + NULL); + g_signal_connect (action, "activate", + G_CALLBACK (menu_hostlist_cb), table); + gtk_action_group_add_action (conv->action_group, action); + g_object_unref (action); + + gtk_ui_manager_add_ui (ui_manager_main_menubar, conv->merge_id, + "/Menubar/StatisticsMenu/EndpointListMenu/Endpoints", + action_name, + action_name, + GTK_UI_MANAGER_MENUITEM, + FALSE); + g_free(action_name); + conv->counter++; +} + +static void +menu_hostlist_list(capture_file *cf) +{ + GtkWidget *submenu_hostlist; + conv_menu_t conv_data; + + conv_data.merge_id = gtk_ui_manager_new_merge_id (ui_manager_main_menubar); + + conv_data.action_group = gtk_action_group_new ("endpoint-list-group"); + + submenu_hostlist = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/StatisticsMenu/EndpointListMenu"); + if(!submenu_hostlist){ + g_warning("add_recent_items: No submenu_conversation_list found, path= /Menubar/StatisticsMenu/EndpointListMenu"); + } + + gtk_ui_manager_insert_action_group (ui_manager_main_menubar, conv_data.action_group, 0); + g_object_set_data (G_OBJECT (ui_manager_main_menubar), + "endpoint-list-merge-id", GUINT_TO_POINTER (conv_data.merge_id)); + + conv_data.cf = cf; + conv_data.counter = 0; + conversation_table_iterate_tables(add_hostlist_menuitem, &conv_data); +} + + + +static void menus_init(void) { GtkActionGroup *packet_list_heading_action_group, *packet_list_action_group, @@ -3669,6 +3704,7 @@ menus_init(void) menu_dissector_filter(&cfile); menu_conversation_list(&cfile); + menu_hostlist_list(&cfile); merge_menu_items(merge_menu_items_list); /* Add external menus and items */ diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index d121b13693..4507920fc2 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -911,6 +911,7 @@ int main(int argc, char *argv[]) register_all_tap_listeners(); conversation_table_set_gui_info(init_conversation_table); + hostlist_table_set_gui_info(NULL); /* XXX - TODO: Provide "GUI" function for Qt */ if (ex_opt_count("read_format") > 0) { in_file_type = open_info_name_to_type(ex_opt_get_next("read_format")); |