diff options
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/Makefile.am | 20 | ||||
-rw-r--r-- | gtk/Makefile.nmake | 8 | ||||
-rw-r--r-- | gtk/endpoint_talkers_eth.c | 191 | ||||
-rw-r--r-- | gtk/endpoint_talkers_ip.c | 191 | ||||
-rw-r--r-- | gtk/endpoint_talkers_table.c | 394 | ||||
-rw-r--r-- | gtk/endpoint_talkers_table.h | 57 | ||||
-rw-r--r-- | gtk/endpoint_talkers_tcpip.c | 216 | ||||
-rw-r--r-- | gtk/endpoint_talkers_tr.c | 191 | ||||
-rw-r--r-- | gtk/endpoint_talkers_udpip.c | 216 |
9 files changed, 1477 insertions, 7 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 05abd546e2..f5112f7dc6 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for the GTK interface routines for Ethereal # -# $Id: Makefile.am,v 1.61 2003/06/25 11:15:34 sahlberg Exp $ +# $Id: Makefile.am,v 1.62 2003/08/23 09:09:35 sahlberg Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs <gerald@ethereal.com> @@ -29,6 +29,11 @@ CLEANFILES = \ ETHEREAL_TAP_SRC = \ dcerpc_stat.c \ + endpoint_talkers_eth.c \ + endpoint_talkers_ip.c \ + endpoint_talkers_tcpip.c \ + endpoint_talkers_tr.c \ + endpoint_talkers_udpip.c \ fc_stat.c \ io_stat.c \ mgcp_stat.c \ @@ -40,7 +45,6 @@ ETHEREAL_TAP_SRC = \ ethereal-tap-register.c: $(ETHEREAL_TAP_SRC) $(top_srcdir)/make-tapreg-dotc @echo Making ethereal-tap-register.c @$(top_srcdir)/make-tapreg-dotc ethereal-tap-register.c $(srcdir) $(ETHEREAL_TAP_SRC) - if USE_GTK2 libui_a_SOURCES = \ @@ -59,14 +63,16 @@ libui_a_SOURCES = \ column_prefs.c \ column_prefs.h \ compat_macros.h \ - decode_as_dlg.c \ - decode_as_dlg.h \ + decode_as_dlg.c \ + decode_as_dlg.h \ dfilter_expr_dlg.c \ dfilter_expr_dlg.h \ display_opts.c \ display_opts.h \ dlg_utils.c \ dlg_utils.h \ + endpoint_talkers_table.c \ + endpoint_talkers_table.h \ ethereal-tap-register.c \ file_dlg.c \ file_dlg.h \ @@ -136,14 +142,16 @@ libui_a_SOURCES = \ colors.h \ column_prefs.c \ column_prefs.h \ - decode_as_dlg.c \ - decode_as_dlg.h \ + decode_as_dlg.c \ + decode_as_dlg.h \ dfilter_expr_dlg.c \ dfilter_expr_dlg.h \ display_opts.c \ display_opts.h \ dlg_utils.c \ dlg_utils.h \ + endpoint_talkers_table.c \ + endpoint_talkers_table.h \ ethereal-tap-register.c \ file_dlg.c \ file_dlg.h \ diff --git a/gtk/Makefile.nmake b/gtk/Makefile.nmake index 4e4ef3e8e1..6d2c38ad3b 100644 --- a/gtk/Makefile.nmake +++ b/gtk/Makefile.nmake @@ -1,7 +1,7 @@ ## Makefile for building ethereal.exe with Microsoft C and nmake ## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake # -# $Id: Makefile.nmake,v 1.46 2003/06/25 11:15:34 sahlberg Exp $ +# $Id: Makefile.nmake,v 1.47 2003/08/23 09:09:35 sahlberg Exp $ include ..\config.nmake @@ -21,6 +21,11 @@ CVARSDLL=-DWIN32 -DNULL=0 -D_MT -D_DLL ETHEREAL_TAP_SRC = \ dcerpc_stat.c \ + endpoint_talkers_eth.c \ + endpoint_talkers_ip.c \ + endpoint_talkers_tcpip.c \ + endpoint_talkers_tr.c \ + endpoint_talkers_udpip.c \ fc_stat.c \ io_stat.c \ mgcp_stat.c \ @@ -46,6 +51,7 @@ OBJECTS=capture_dlg.obj \ dfilter_expr_dlg.obj \ display_opts.obj \ dlg_utils.obj \ + endpoint_talkers_table.obj \ ethereal-tap-register.obj \ file_dlg.obj \ filter_prefs.obj \ diff --git a/gtk/endpoint_talkers_eth.c b/gtk/endpoint_talkers_eth.c new file mode 100644 index 0000000000..5804f47f4f --- /dev/null +++ b/gtk/endpoint_talkers_eth.c @@ -0,0 +1,191 @@ +/* endpoint_talkers_eth.c + * endpoint_talkers_eth 2003 Ronnie Sahlberg + * + * $Id: endpoint_talkers_eth.c,v 1.1 2003/08/23 09:09:35 sahlberg Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#include <gtk/gtk.h> +#include <string.h> +#include "menu.h" +#include "../epan/packet_info.h" +#include "../tap.h" +#include "../register.h" +#include "compat_macros.h" +#include "../simple_dialog.h" +#include "../file.h" +#include "../globals.h" +#include "endpoint_talkers_table.h" +#include "packet-eth.h" + +/* used to keep track of the statistics for one instance of the stats */ +typedef struct _eth_talkers_t { + GtkWidget *win; + endpoints_table talkers; +} eth_talkers_t; + + +void protect_thread_critical_region(void); +void unprotect_thread_critical_region(void); +static void +win_destroy_cb(GtkWindow *win _U_, gpointer data) +{ + eth_talkers_t *eth_talkers=(eth_talkers_t *)data; + + protect_thread_critical_region(); + remove_tap_listener(eth_talkers); + unprotect_thread_critical_region(); + + reset_ett_table_data(ð_talkers->talkers); + g_free(eth_talkers); +} + + +static char * +eth_address_to_str(address *addr) +{ + static int i=0; + static char *strp, str[4][18]; + + i++; + if(i>=4){ + i=0; + } + strp=str[i]; + + sprintf(strp, "%02x:%02x:%02x:%02x:%02x:%02x", addr->data[0], addr->data[1], addr->data[2], addr->data[3], addr->data[4], addr->data[5]); + + return strp; +} + +static void +eth_talkers_reset(void *pit) +{ + eth_talkers_t *eth_talkers=(eth_talkers_t *)pit; + + reset_ett_table_data(ð_talkers->talkers); +} + + +static void +eth_talkers_draw(void *pit) +{ + eth_talkers_t *eth_talkers=(eth_talkers_t *)pit; + + draw_ett_table_data(ð_talkers->talkers); +} + + +static int +eth_talkers_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, void *vip) +{ + eth_talkers_t *eth_talkers=(eth_talkers_t *)pit; + eth_hdr *ehdr=vip; + + add_ett_table_data(ð_talkers->talkers, &ehdr->src, &ehdr->dst, 0, 0, 1, pinfo->fd->pkt_len); + + return 1; +} + + + +static void +gtk_eth_talkers_init(char *optarg) +{ + char *filter=NULL; + eth_talkers_t *eth_talkers; + GtkWidget *vbox; + GtkWidget *label; + GString *error_string; + + + if(!strncmp(optarg,"talkers,eth,",12)){ + filter=optarg+12; + } else { + filter=NULL; + } + + eth_talkers=g_malloc(sizeof(eth_talkers_t)); + + eth_talkers->win=gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(eth_talkers->win), 750, 400); + gtk_window_set_title(GTK_WINDOW(eth_talkers->win), "Ethernet Talkers"); + + SIGNAL_CONNECT(eth_talkers->win, "destroy", win_destroy_cb, eth_talkers); + + vbox=gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(eth_talkers->win), vbox); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); + gtk_widget_show(vbox); + + label=gtk_label_new("Ethernet Talkers"); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + /* We must display TOP LEVEL Widget before calling init_ett_table() */ + gtk_widget_show(eth_talkers->win); + + init_ett_table(ð_talkers->talkers, vbox, eth_address_to_str, NULL); + + error_string=register_tap_listener("eth", eth_talkers, filter, eth_talkers_reset, eth_talkers_packet, eth_talkers_draw); + if(error_string){ + simple_dialog(ESD_TYPE_WARN, NULL, error_string->str); + g_string_free(error_string, TRUE); + g_free(eth_talkers); + return; + } + + gtk_widget_show_all(eth_talkers->win); + redissect_packets(&cfile); +} + + +static void +gtk_eth_endpoints_cb(GtkWidget *w _U_, gpointer d _U_) +{ + gtk_eth_talkers_init("talkers,eth"); +} + + +void +register_tap_menu_eth_talkers(void) +{ + register_tap_menu_item("Endpoint Talkers/Ethernet", gtk_eth_endpoints_cb); +} + + + + +void +register_tap_listener_eth_talkers(void) +{ + register_ethereal_tap("talkers,eth", gtk_eth_talkers_init); +} + diff --git a/gtk/endpoint_talkers_ip.c b/gtk/endpoint_talkers_ip.c new file mode 100644 index 0000000000..965b213ccd --- /dev/null +++ b/gtk/endpoint_talkers_ip.c @@ -0,0 +1,191 @@ +/* endpoint_talkers_ip.c + * endpoint_talkers_ip 2003 Ronnie Sahlberg + * + * $Id: endpoint_talkers_ip.c,v 1.1 2003/08/23 09:09:35 sahlberg Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#include <gtk/gtk.h> +#include <string.h> +#include "menu.h" +#include "../epan/packet_info.h" +#include "../tap.h" +#include "../register.h" +#include "compat_macros.h" +#include "../simple_dialog.h" +#include "../file.h" +#include "../globals.h" +#include "endpoint_talkers_table.h" +#include "packet-ip.h" + +/* used to keep track of the statistics for one instance of the stats */ +typedef struct _ip_talkers_t { + GtkWidget *win; + endpoints_table talkers; +} ip_talkers_t; + + +void protect_thread_critical_region(void); +void unprotect_thread_critical_region(void); +static void +win_destroy_cb(GtkWindow *win _U_, gpointer data) +{ + ip_talkers_t *ip_talkers=(ip_talkers_t *)data; + + protect_thread_critical_region(); + remove_tap_listener(ip_talkers); + unprotect_thread_critical_region(); + + reset_ett_table_data(&ip_talkers->talkers); + g_free(ip_talkers); +} + + +static char * +ipv4_address_to_str(address *addr) +{ + static int i=0; + static char *strp, str[4][16]; + + i++; + if(i>=4){ + i=0; + } + strp=str[i]; + + sprintf(strp, "%d.%d.%d.%d", addr->data[0], addr->data[1], addr->data[2], addr->data[3]); + + return strp; +} + +static void +ip_talkers_reset(void *pit) +{ + ip_talkers_t *ip_talkers=(ip_talkers_t *)pit; + + reset_ett_table_data(&ip_talkers->talkers); +} + + +static void +ip_talkers_draw(void *pit) +{ + ip_talkers_t *ip_talkers=(ip_talkers_t *)pit; + + draw_ett_table_data(&ip_talkers->talkers); +} + + +static int +ip_talkers_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, void *vip) +{ + ip_talkers_t *ip_talkers=(ip_talkers_t *)pit; + e_ip *iph=vip; + + add_ett_table_data(&ip_talkers->talkers, &iph->ip_src, &iph->ip_dst, 0, 0, 1, pinfo->fd->pkt_len); + + return 1; +} + + + +static void +gtk_ip_talkers_init(char *optarg) +{ + char *filter=NULL; + ip_talkers_t *ip_talkers; + GtkWidget *vbox; + GtkWidget *label; + GString *error_string; + + + if(!strncmp(optarg,"talkers,ip,",11)){ + filter=optarg+11; + } else { + filter=NULL; + } + + ip_talkers=g_malloc(sizeof(ip_talkers_t)); + + ip_talkers->win=gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(ip_talkers->win), 750, 400); + gtk_window_set_title(GTK_WINDOW(ip_talkers->win), "IPv4 Talkers"); + + SIGNAL_CONNECT(ip_talkers->win, "destroy", win_destroy_cb, ip_talkers); + + vbox=gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(ip_talkers->win), vbox); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); + gtk_widget_show(vbox); + + label=gtk_label_new("IPv4 Talkers"); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + /* We must display TOP LEVEL Widget before calling init_ett_table() */ + gtk_widget_show(ip_talkers->win); + + init_ett_table(&ip_talkers->talkers, vbox, ipv4_address_to_str, NULL); + + error_string=register_tap_listener("ip", ip_talkers, filter, ip_talkers_reset, ip_talkers_packet, ip_talkers_draw); + if(error_string){ + simple_dialog(ESD_TYPE_WARN, NULL, error_string->str); + g_string_free(error_string, TRUE); + g_free(ip_talkers); + return; + } + + gtk_widget_show_all(ip_talkers->win); + redissect_packets(&cfile); +} + + +static void +gtk_ip_endpoints_cb(GtkWidget *w _U_, gpointer d _U_) +{ + gtk_ip_talkers_init("talkers,ip"); +} + + +void +register_tap_menu_ip_talkers(void) +{ + register_tap_menu_item("Endpoint Talkers/IPv4", gtk_ip_endpoints_cb); +} + + + + +void +register_tap_listener_ip_talkers(void) +{ + register_ethereal_tap("talkers,ip", gtk_ip_talkers_init); +} + diff --git a/gtk/endpoint_talkers_table.c b/gtk/endpoint_talkers_table.c new file mode 100644 index 0000000000..2fe2f7a03a --- /dev/null +++ b/gtk/endpoint_talkers_table.c @@ -0,0 +1,394 @@ +/* mem leak should free the column_arrows when the table is destroyed */ + +/* endpoint_talkers_table.c + * endpoint_talkers_table 2003 Ronnie Sahlberg + * Helper routines common to all endpoint talkers tap. + * + * $Id: endpoint_talkers_table.c,v 1.1 2003/08/23 09:09:35 sahlberg Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <string.h> +#include <stdlib.h> +#include <stdio.h> +#include <math.h> +#include <gtk/gtk.h> +#include "compat_macros.h" +#include "epan/packet_info.h" +#include "endpoint_talkers_table.h" +#include "image/clist_ascend.xpm" +#include "image/clist_descend.xpm" + + +#define NUM_COLS 10 + +typedef struct column_arrows { + GtkWidget *table; + GtkWidget *ascend_pm; + GtkWidget *descend_pm; +} column_arrows; + + +void +reset_ett_table_data(endpoints_table *et) +{ + guint32 i; + + /* remove all entries from the clist */ + gtk_clist_freeze(et->table); + for(i=0;i<et->num_endpoints;i++){ + gtk_clist_remove(et->table, et->num_endpoints-1-i); + } + gtk_clist_thaw(et->table); + + /* delete all endpoints */ + for(i=0;i<et->num_endpoints;i++){ + g_free(et->endpoints[i].src_address.data); + g_free(et->endpoints[i].dst_address.data); + } + g_free(et->endpoints); + et->endpoints=NULL; + et->num_endpoints=0; +} + +static gint +ett_sort_column(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2) +{ + char *text1 = NULL; + char *text2 = NULL; + int i1, i2; + + GtkCListRow *row1 = (GtkCListRow *) ptr1; + GtkCListRow *row2 = (GtkCListRow *) ptr2; + + text1 = GTK_CELL_TEXT (row1->cell[clist->sort_column])->text; + text2 = GTK_CELL_TEXT (row2->cell[clist->sort_column])->text; + + switch(clist->sort_column){ + case 0: + case 2: + return strcmp (text1, text2); + case 1: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + i1=atoi(text1); + i2=atoi(text2); + return i1-i2; + } + g_assert_not_reached(); + return 0; +} + + +static void +ett_click_column_cb(GtkCList *clist, gint column, gpointer data) +{ + column_arrows *col_arrows = (column_arrows *) data; + int i; + + gtk_clist_freeze(clist); + + for (i = 0; i < NUM_COLS; i++) { + gtk_widget_hide(col_arrows[i].ascend_pm); + gtk_widget_hide(col_arrows[i].descend_pm); + } + + if (column == clist->sort_column) { + if (clist->sort_type == GTK_SORT_ASCENDING) { + clist->sort_type = GTK_SORT_DESCENDING; + gtk_widget_show(col_arrows[column].descend_pm); + } else { + clist->sort_type = GTK_SORT_ASCENDING; + gtk_widget_show(col_arrows[column].ascend_pm); + } + } else { + clist->sort_type = GTK_SORT_DESCENDING; + gtk_widget_show(col_arrows[column].descend_pm); + gtk_clist_set_sort_column(clist, column); + } + gtk_clist_thaw(clist); + + gtk_clist_sort(clist); +} + + +void +init_ett_table(endpoints_table *et, GtkWidget *vbox, char *(*address_to_str)(address *), char *(*port_to_str)(guint32)) +{ + int i; + column_arrows *col_arrows; + GdkBitmap *ascend_bm, *descend_bm; + GdkPixmap *ascend_pm, *descend_pm; + GtkStyle *win_style; + GtkWidget *column_lb; + char *default_titles[] = { "Address", "Port", "Address", "Port", "Frames", "Bytes", "-> Frames", "-> Bytes", "<- Frames", "<- Bytes" }; + + + et->scrolled_window=gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(et->scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); + gtk_box_pack_start(GTK_BOX(vbox), et->scrolled_window, TRUE, TRUE, 0); + + et->table=(GtkCList *)gtk_clist_new(NUM_COLS); + + gtk_widget_show(GTK_WIDGET(et->table)); + gtk_widget_show(et->scrolled_window); + + col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) * NUM_COLS); + win_style = gtk_widget_get_style(et->scrolled_window); + ascend_pm = gdk_pixmap_create_from_xpm_d(et->scrolled_window->window, + &ascend_bm, + &win_style->bg[GTK_STATE_NORMAL], + (gchar **)clist_ascend_xpm); + descend_pm = gdk_pixmap_create_from_xpm_d(et->scrolled_window->window, + &descend_bm, + &win_style->bg[GTK_STATE_NORMAL], + (gchar **)clist_descend_xpm); + for (i = 0; i < NUM_COLS; i++) { + col_arrows[i].table = gtk_table_new(2, 2, FALSE); + gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5); + column_lb = gtk_label_new(default_titles[i]); + gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0); + gtk_widget_show(column_lb); + + col_arrows[i].ascend_pm = gtk_pixmap_new(ascend_pm, ascend_bm); + gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0); + col_arrows[i].descend_pm = gtk_pixmap_new(descend_pm, descend_bm); + gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0); + /* make total frames be the default sort order */ + if (i == 4) { + gtk_widget_show(col_arrows[i].descend_pm); + } + gtk_clist_set_column_widget(GTK_CLIST(et->table), i, col_arrows[i].table); + gtk_widget_show(col_arrows[i].table); + } + gtk_clist_column_titles_show(GTK_CLIST(et->table)); + + gtk_clist_set_compare_func(et->table, ett_sort_column); + gtk_clist_set_sort_column(et->table, 4); + gtk_clist_set_sort_type(et->table, GTK_SORT_DESCENDING); + + + /*XXX instead of this we should probably have some code to + dynamically adjust the width of the columns */ + gtk_clist_set_column_width(et->table, 0, 100); + gtk_clist_set_column_width(et->table, 1, 40); + gtk_clist_set_column_width(et->table, 2, 100); + gtk_clist_set_column_width(et->table, 3, 40); + gtk_clist_set_column_width(et->table, 4, 70); + gtk_clist_set_column_width(et->table, 5, 60); + gtk_clist_set_column_width(et->table, 6, 70); + gtk_clist_set_column_width(et->table, 7, 60); + gtk_clist_set_column_width(et->table, 8, 70); + gtk_clist_set_column_width(et->table, 9, 60); + + + gtk_clist_set_shadow_type(et->table, GTK_SHADOW_IN); + gtk_clist_column_titles_show(et->table); + gtk_container_add(GTK_CONTAINER(et->scrolled_window), (GtkWidget *)et->table); + + SIGNAL_CONNECT(et->table, "click-column", ett_click_column_cb, col_arrows); + + gtk_widget_show(GTK_WIDGET(et->table)); + gtk_widget_show(et->scrolled_window); + + et->num_endpoints=0; + et->endpoints=NULL; + et->address_to_str=address_to_str; + et->port_to_str=port_to_str; + + /* hide srcport and dstport if we dont use ports */ + if(!port_to_str){ + gtk_clist_set_column_visibility(et->table, 1, FALSE); + gtk_clist_set_column_visibility(et->table, 3, FALSE); + } +} + + +void +add_ett_table_data(endpoints_table *et, address *src, address *dst, guint32 src_port, guint32 dst_port, int num_frames, int num_bytes) +{ + address *addr1, *addr2; + guint32 port1, port2; + endpoint_talker_t *talker=NULL; + int talker_idx=0; + gboolean new_talker; + int res; + + res=CMP_ADDRESS(src, dst); + + if(res<0){ + addr1=src; + addr2=dst; + port1=src_port; + port2=dst_port; + } else if(res>0) { + addr2=src; + addr1=dst; + port2=src_port; + port1=dst_port; + } else { + if(src_port>dst_port){ + addr1=src; + addr2=dst; + port1=src_port; + port2=dst_port; + } else { + addr2=src; + addr1=dst; + port2=src_port; + port1=dst_port; + } + } + + + new_talker=FALSE; + /* 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(et->endpoints==NULL){ + et->endpoints=g_malloc(sizeof(endpoint_talker_t)); + et->num_endpoints=1; + talker=&et->endpoints[0]; + talker_idx=0; + new_talker=TRUE; + } + + /* try to find it among the existing known talkers */ + if(talker==NULL){ + guint32 i; + for(i=0;i<et->num_endpoints;i++){ + if( (!CMP_ADDRESS(&et->endpoints[i].src_address, addr1))&&(!CMP_ADDRESS(&et->endpoints[i].dst_address, addr2))&&(et->endpoints[i].src_port==port1)&&(et->endpoints[i].dst_port==port2) ){ + talker=&et->endpoints[i]; + talker_idx=i; + break; + } + if( (!CMP_ADDRESS(&et->endpoints[i].src_address, addr2))&&(!CMP_ADDRESS(&et->endpoints[i].dst_address, addr1))&&(et->endpoints[i].src_port==port2)&&(et->endpoints[i].dst_port==port1) ){ + talker=&et->endpoints[i]; + talker_idx=i; + break; + } + } + } + + /* 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){ + new_talker=TRUE; + et->num_endpoints++; + et->endpoints=g_realloc(et->endpoints, et->num_endpoints*sizeof(endpoint_talker_t)); + talker=&et->endpoints[et->num_endpoints-1]; + talker_idx=et->num_endpoints-1; + } + + /* if this is a new talker we need to initialize the struct */ + if(new_talker){ + COPY_ADDRESS(&talker->src_address, addr1); + COPY_ADDRESS(&talker->dst_address, addr2); + talker->src_port=port1; + talker->dst_port=port2; + talker->rx_frames=0; + talker->tx_frames=0; + talker->rx_bytes=0; + talker->tx_bytes=0; + } + + /* update the talker struct */ + if( (!CMP_ADDRESS(src, addr1))&&(!CMP_ADDRESS(dst, addr2))&&(src_port==port1)&&(dst_port==port2) ){ + talker->tx_frames+=num_frames; + talker->tx_bytes+=num_bytes; + } else { + talker->rx_frames+=num_frames; + talker->rx_bytes+=num_bytes; + } + + /* if this was a new talker we have to create a clist row for it */ + if(new_talker){ + char *entries[NUM_COLS]; + char frames[16],bytes[16],txframes[16],txbytes[16],rxframes[16],rxbytes[16]; + + entries[0]=et->address_to_str(&talker->src_address); + entries[1]=(et->port_to_str)?et->port_to_str(talker->src_port):""; + entries[2]=et->address_to_str(&talker->dst_address); + entries[3]=(et->port_to_str)?et->port_to_str(talker->dst_port):""; + + sprintf(frames,"%d", talker->tx_frames+talker->rx_frames); + entries[4]=frames; + sprintf(bytes,"%d", talker->tx_bytes+talker->rx_bytes); + entries[5]=bytes; + + sprintf(txframes,"%d", talker->tx_frames); + entries[6]=txframes; + sprintf(txbytes,"%d", talker->tx_bytes); + entries[7]=txbytes; + + sprintf(rxframes,"%d", talker->rx_frames); + entries[8]=rxframes; + sprintf(rxbytes,"%d", talker->rx_bytes); + entries[9]=rxbytes; + + gtk_clist_insert(et->table, talker_idx, entries); + gtk_clist_set_row_data(et->table, talker_idx, (gpointer) talker_idx); + } +} + + +/* XXX should freeze/thaw table here and in the srt thingy? */ +void +draw_ett_table_data(endpoints_table *et) +{ + guint32 i; + int j; + + for(i=0;i<et->num_endpoints;i++){ + char str[16]; + + j=gtk_clist_find_row_from_data(et->table, (gpointer)i); + + sprintf(str, "%d", et->endpoints[i].tx_frames+et->endpoints[i].rx_frames); + gtk_clist_set_text(et->table, j, 4, str); + sprintf(str, "%d", et->endpoints[i].tx_bytes+et->endpoints[i].rx_bytes); + gtk_clist_set_text(et->table, j, 5, str); + + + sprintf(str, "%d", et->endpoints[i].tx_frames); + gtk_clist_set_text(et->table, j, 6, str); + sprintf(str, "%d", et->endpoints[i].tx_bytes); + gtk_clist_set_text(et->table, j, 7, str); + + + sprintf(str, "%d", et->endpoints[i].rx_frames); + gtk_clist_set_text(et->table, j, 8, str); + sprintf(str, "%d", et->endpoints[i].rx_bytes); + gtk_clist_set_text(et->table, j, 9, str); + + } + gtk_clist_sort(et->table); +} + + diff --git a/gtk/endpoint_talkers_table.h b/gtk/endpoint_talkers_table.h new file mode 100644 index 0000000000..89578e2a37 --- /dev/null +++ b/gtk/endpoint_talkers_table.h @@ -0,0 +1,57 @@ +/* endpoint_talkers_table.h + * endpoint_talkers_table 2003 Ronnie Sahlberg + * Helper routines common to all endpoint talkers taps. + * + * $Id: endpoint_talkers_table.h,v 1.1 2003/08/23 09:09:35 sahlberg Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <gtk/gtk.h> + +typedef struct _endpoint_talker_t { + address src_address; + address dst_address; + guint32 src_port; + guint32 dst_port; + + guint32 rx_frames; + guint32 tx_frames; + guint32 rx_bytes; + guint32 tx_bytes; +} endpoint_talker_t; + +typedef struct _endpoints_table { + GtkWidget *scrolled_window; + GtkCList *table; + gboolean has_ports; + guint32 num_endpoints; + endpoint_talker_t *endpoints; + char *(*address_to_str)(address *); + char *(*port_to_str)(guint32); +} endpoints_table; + +void reset_ett_table_data(endpoints_table *et); + +void init_ett_table(endpoints_table *et, GtkWidget *vbox, char *(*address_to_str)(address *),char *(*port_to_str)(guint32)); + +void add_ett_table_data(endpoints_table *et, address *src, address *dst, guint32 src_port, guint32 dst_port, int num_frames, int num_bytes); + +void draw_ett_table_data(endpoints_table *et); + diff --git a/gtk/endpoint_talkers_tcpip.c b/gtk/endpoint_talkers_tcpip.c new file mode 100644 index 0000000000..3e16990345 --- /dev/null +++ b/gtk/endpoint_talkers_tcpip.c @@ -0,0 +1,216 @@ +/* should be trivial to extend to handle ipv6 as well. currently only support +for ipv4*/ +/* endpoint_talkers_tcpip.c + * endpoint_talkers_tcpip 2003 Ronnie Sahlberg + * + * $Id: endpoint_talkers_tcpip.c,v 1.1 2003/08/23 09:09:35 sahlberg Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#include <gtk/gtk.h> +#include <string.h> +#include "menu.h" +#include "../epan/packet_info.h" +#include "../tap.h" +#include "../register.h" +#include "compat_macros.h" +#include "../simple_dialog.h" +#include "../file.h" +#include "../globals.h" +#include "endpoint_talkers_table.h" +#include "packet-tcp.h" + +/* used to keep track of the statistics for one instance of the stats */ +typedef struct _tcpip_talkers_t { + GtkWidget *win; + endpoints_table talkers; +} tcpip_talkers_t; + + +void protect_thread_critical_region(void); +void unprotect_thread_critical_region(void); +static void +win_destroy_cb(GtkWindow *win _U_, gpointer data) +{ + tcpip_talkers_t *tcpip_talkers=(tcpip_talkers_t *)data; + + protect_thread_critical_region(); + remove_tap_listener(tcpip_talkers); + unprotect_thread_critical_region(); + + reset_ett_table_data(&tcpip_talkers->talkers); + g_free(tcpip_talkers); +} + + +static char * +tcpip_address_to_str(address *addr) +{ + static int i=0; + static char *strp, str[4][256]; + + i++; + if(i>=4){ + i=0; + } + strp=str[i]; + + switch(addr->type){ + case AT_IPv4: + sprintf(strp, "%d.%d.%d.%d", addr->data[0], addr->data[1], addr->data[2], addr->data[3]); + break; + default: + fprintf(stderr, "Unsupported transport for TCP in the TCP talkers tap.\n"); + } + + return strp; +} + +static char * +tcpip_port_to_str(guint32 port) +{ + static int i=0; + static char *strp, str[4][6]; + + i++; + if(i>=4){ + i=0; + } + strp=str[i]; + + sprintf(strp, "%d", port); + + return strp; +} + +static void +tcpip_talkers_reset(void *pit) +{ + tcpip_talkers_t *tcpip_talkers=(tcpip_talkers_t *)pit; + + reset_ett_table_data(&tcpip_talkers->talkers); +} + + +static void +tcpip_talkers_draw(void *pit) +{ + tcpip_talkers_t *tcpip_talkers=(tcpip_talkers_t *)pit; + + draw_ett_table_data(&tcpip_talkers->talkers); +} + + +static int +tcpip_talkers_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, void *vip) +{ + tcpip_talkers_t *tcpip_talkers=(tcpip_talkers_t *)pit; + struct tcpheader *tcphdr=vip; + + add_ett_table_data(&tcpip_talkers->talkers, &tcphdr->ip_src, &tcphdr->ip_dst, tcphdr->th_sport, tcphdr->th_dport, 1, pinfo->fd->pkt_len); + + return 1; +} + + + +static void +gtk_tcpip_talkers_init(char *optarg) +{ + char *filter=NULL; + tcpip_talkers_t *tcpip_talkers; + GtkWidget *vbox; + GtkWidget *label; + GString *error_string; + + + if(!strncmp(optarg,"talkers,tcpip,",14)){ + filter=optarg+14; + } else { + filter=NULL; + } + + tcpip_talkers=g_malloc(sizeof(tcpip_talkers_t)); + + tcpip_talkers->win=gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(tcpip_talkers->win), 750, 400); + gtk_window_set_title(GTK_WINDOW(tcpip_talkers->win), "TCP/IP Talkers"); + + SIGNAL_CONNECT(tcpip_talkers->win, "destroy", win_destroy_cb, tcpip_talkers); + + vbox=gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(tcpip_talkers->win), vbox); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); + gtk_widget_show(vbox); + + label=gtk_label_new("TCPIP Talkers"); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + /* We must display TOP LEVEL Widget before calling init_ett_table() */ + gtk_widget_show(tcpip_talkers->win); + + init_ett_table(&tcpip_talkers->talkers, vbox, tcpip_address_to_str, tcpip_port_to_str); + + error_string=register_tap_listener("tcp", tcpip_talkers, filter, tcpip_talkers_reset, tcpip_talkers_packet, tcpip_talkers_draw); + if(error_string){ + simple_dialog(ESD_TYPE_WARN, NULL, error_string->str); + g_string_free(error_string, TRUE); + g_free(tcpip_talkers); + return; + } + + gtk_widget_show_all(tcpip_talkers->win); + redissect_packets(&cfile); +} + + +static void +gtk_tcpip_endpoints_cb(GtkWidget *w _U_, gpointer d _U_) +{ + gtk_tcpip_talkers_init("talkers,tcpip"); +} + + +void +register_tap_menu_tcpip_talkers(void) +{ + register_tap_menu_item("Endpoint Talkers/TCPIP", gtk_tcpip_endpoints_cb); +} + + + + +void +register_tap_listener_tcpip_talkers(void) +{ + register_ethereal_tap("talkers,tcpip", gtk_tcpip_talkers_init); +} + diff --git a/gtk/endpoint_talkers_tr.c b/gtk/endpoint_talkers_tr.c new file mode 100644 index 0000000000..5532036dec --- /dev/null +++ b/gtk/endpoint_talkers_tr.c @@ -0,0 +1,191 @@ +/* endpoint_talkers_tr.c + * endpoint_talkers_tr 2003 Ronnie Sahlberg + * + * $Id: endpoint_talkers_tr.c,v 1.1 2003/08/23 09:09:35 sahlberg Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#include <gtk/gtk.h> +#include <string.h> +#include "menu.h" +#include "../epan/packet_info.h" +#include "../tap.h" +#include "../register.h" +#include "compat_macros.h" +#include "../simple_dialog.h" +#include "../file.h" +#include "../globals.h" +#include "endpoint_talkers_table.h" +#include "packet-tr.h" + +/* used to keep track of the statistics for one instance of the stats */ +typedef struct _tr_talkers_t { + GtkWidget *win; + endpoints_table talkers; +} tr_talkers_t; + + +void protect_thread_critical_region(void); +void unprotect_thread_critical_region(void); +static void +win_destroy_cb(GtkWindow *win _U_, gpointer data) +{ + tr_talkers_t *tr_talkers=(tr_talkers_t *)data; + + protect_thread_critical_region(); + remove_tap_listener(tr_talkers); + unprotect_thread_critical_region(); + + reset_ett_table_data(&tr_talkers->talkers); + g_free(tr_talkers); +} + + +static char * +tr_address_to_str(address *addr) +{ + static int i=0; + static char *strp, str[4][18]; + + i++; + if(i>=4){ + i=0; + } + strp=str[i]; + + sprintf(strp, "%02x:%02x:%02x:%02x:%02x:%02x", addr->data[0], addr->data[1], addr->data[2], addr->data[3], addr->data[4], addr->data[5]); + + return strp; +} + +static void +tr_talkers_reset(void *pit) +{ + tr_talkers_t *tr_talkers=(tr_talkers_t *)pit; + + reset_ett_table_data(&tr_talkers->talkers); +} + + +static void +tr_talkers_draw(void *pit) +{ + tr_talkers_t *tr_talkers=(tr_talkers_t *)pit; + + draw_ett_table_data(&tr_talkers->talkers); +} + + +static int +tr_talkers_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, void *vip) +{ + tr_talkers_t *tr_talkers=(tr_talkers_t *)pit; + tr_hdr *trhdr=vip; + + add_ett_table_data(&tr_talkers->talkers, &trhdr->src, &trhdr->dst, 0, 0, 1, pinfo->fd->pkt_len); + + return 1; +} + + + +static void +gtk_tr_talkers_init(char *optarg) +{ + char *filter=NULL; + tr_talkers_t *tr_talkers; + GtkWidget *vbox; + GtkWidget *label; + GString *error_string; + + + if(!strncmp(optarg,"talkers,tr,",11)){ + filter=optarg+11; + } else { + filter=NULL; + } + + tr_talkers=g_malloc(sizeof(tr_talkers_t)); + + tr_talkers->win=gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(tr_talkers->win), 750, 400); + gtk_window_set_title(GTK_WINDOW(tr_talkers->win), "TokenRing Talkers"); + + SIGNAL_CONNECT(tr_talkers->win, "destroy", win_destroy_cb, tr_talkers); + + vbox=gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(tr_talkers->win), vbox); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); + gtk_widget_show(vbox); + + label=gtk_label_new("TokenRing Talkers"); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + /* We must display TOP LEVEL Widget before calling init_ett_table() */ + gtk_widget_show(tr_talkers->win); + + init_ett_table(&tr_talkers->talkers, vbox, tr_address_to_str, NULL); + + error_string=register_tap_listener("tr", tr_talkers, filter, tr_talkers_reset, tr_talkers_packet, tr_talkers_draw); + if(error_string){ + simple_dialog(ESD_TYPE_WARN, NULL, error_string->str); + g_string_free(error_string, TRUE); + g_free(tr_talkers); + return; + } + + gtk_widget_show_all(tr_talkers->win); + redissect_packets(&cfile); +} + + +static void +gtk_tr_endpoints_cb(GtkWidget *w _U_, gpointer d _U_) +{ + gtk_tr_talkers_init("talkers,tr"); +} + + +void +register_tap_menu_tr_talkers(void) +{ + register_tap_menu_item("Endpoint Talkers/TokenRing", gtk_tr_endpoints_cb); +} + + + + +void +register_tap_listener_tr_talkers(void) +{ + register_ethereal_tap("talkers,tr", gtk_tr_talkers_init); +} + diff --git a/gtk/endpoint_talkers_udpip.c b/gtk/endpoint_talkers_udpip.c new file mode 100644 index 0000000000..9fa3b85b0b --- /dev/null +++ b/gtk/endpoint_talkers_udpip.c @@ -0,0 +1,216 @@ +/* should be trivial to extend to handle ipv6 as well. currently only support +for ipv4*/ +/* endpoint_talkers_udpip.c + * endpoint_talkers_udpip 2003 Ronnie Sahlberg + * + * $Id: endpoint_talkers_udpip.c,v 1.1 2003/08/23 09:09:35 sahlberg Exp $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#include <gtk/gtk.h> +#include <string.h> +#include "menu.h" +#include "../epan/packet_info.h" +#include "../tap.h" +#include "../register.h" +#include "compat_macros.h" +#include "../simple_dialog.h" +#include "../file.h" +#include "../globals.h" +#include "endpoint_talkers_table.h" +#include "packet-udp.h" + +/* used to keep track of the statistics for one instance of the stats */ +typedef struct _udpip_talkers_t { + GtkWidget *win; + endpoints_table talkers; +} udpip_talkers_t; + + +void protect_thread_critical_region(void); +void unprotect_thread_critical_region(void); +static void +win_destroy_cb(GtkWindow *win _U_, gpointer data) +{ + udpip_talkers_t *udpip_talkers=(udpip_talkers_t *)data; + + protect_thread_critical_region(); + remove_tap_listener(udpip_talkers); + unprotect_thread_critical_region(); + + reset_ett_table_data(&udpip_talkers->talkers); + g_free(udpip_talkers); +} + + +static char * +udpip_address_to_str(address *addr) +{ + static int i=0; + static char *strp, str[4][256]; + + i++; + if(i>=4){ + i=0; + } + strp=str[i]; + + switch(addr->type){ + case AT_IPv4: + sprintf(strp, "%d.%d.%d.%d", addr->data[0], addr->data[1], addr->data[2], addr->data[3]); + break; + default: + fprintf(stderr, "Unsupported transport for TCP in the TCP talkers tap.\n"); + } + + return strp; +} + +static char * +udpip_port_to_str(guint32 port) +{ + static int i=0; + static char *strp, str[4][6]; + + i++; + if(i>=4){ + i=0; + } + strp=str[i]; + + sprintf(strp, "%d", port); + + return strp; +} + +static void +udpip_talkers_reset(void *pit) +{ + udpip_talkers_t *udpip_talkers=(udpip_talkers_t *)pit; + + reset_ett_table_data(&udpip_talkers->talkers); +} + + +static void +udpip_talkers_draw(void *pit) +{ + udpip_talkers_t *udpip_talkers=(udpip_talkers_t *)pit; + + draw_ett_table_data(&udpip_talkers->talkers); +} + + +static int +udpip_talkers_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, void *vip) +{ + udpip_talkers_t *udpip_talkers=(udpip_talkers_t *)pit; + e_udphdr *udphdr=vip; + + add_ett_table_data(&udpip_talkers->talkers, &udphdr->ip_src, &udphdr->ip_dst, udphdr->uh_sport, udphdr->uh_dport, 1, pinfo->fd->pkt_len); + + return 1; +} + + + +static void +gtk_udpip_talkers_init(char *optarg) +{ + char *filter=NULL; + udpip_talkers_t *udpip_talkers; + GtkWidget *vbox; + GtkWidget *label; + GString *error_string; + + + if(!strncmp(optarg,"talkers,udpip,",14)){ + filter=optarg+14; + } else { + filter=NULL; + } + + udpip_talkers=g_malloc(sizeof(udpip_talkers_t)); + + udpip_talkers->win=gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(udpip_talkers->win), 750, 400); + gtk_window_set_title(GTK_WINDOW(udpip_talkers->win), "UDP/IP Talkers"); + + SIGNAL_CONNECT(udpip_talkers->win, "destroy", win_destroy_cb, udpip_talkers); + + vbox=gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(udpip_talkers->win), vbox); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); + gtk_widget_show(vbox); + + label=gtk_label_new("UDP/IP Talkers"); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + + /* We must display TOP LEVEL Widget before calling init_ett_table() */ + gtk_widget_show(udpip_talkers->win); + + init_ett_table(&udpip_talkers->talkers, vbox, udpip_address_to_str, udpip_port_to_str); + + error_string=register_tap_listener("udp", udpip_talkers, filter, udpip_talkers_reset, udpip_talkers_packet, udpip_talkers_draw); + if(error_string){ + simple_dialog(ESD_TYPE_WARN, NULL, error_string->str); + g_string_free(error_string, TRUE); + g_free(udpip_talkers); + return; + } + + gtk_widget_show_all(udpip_talkers->win); + redissect_packets(&cfile); +} + + +static void +gtk_udpip_endpoints_cb(GtkWidget *w _U_, gpointer d _U_) +{ + gtk_udpip_talkers_init("talkers,udpip"); +} + + +void +register_tap_menu_udpip_talkers(void) +{ + register_tap_menu_item("Endpoint Talkers/UDPIP", gtk_udpip_endpoints_cb); +} + + + + +void +register_tap_listener_udpip_talkers(void) +{ + register_ethereal_tap("talkers,udpip", gtk_udpip_talkers_init); +} + |