aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gtk/Makefile.am20
-rw-r--r--gtk/Makefile.nmake8
-rw-r--r--gtk/endpoint_talkers_eth.c191
-rw-r--r--gtk/endpoint_talkers_ip.c191
-rw-r--r--gtk/endpoint_talkers_table.c394
-rw-r--r--gtk/endpoint_talkers_table.h57
-rw-r--r--gtk/endpoint_talkers_tcpip.c216
-rw-r--r--gtk/endpoint_talkers_tr.c191
-rw-r--r--gtk/endpoint_talkers_udpip.c216
-rw-r--r--packet-eth.c60
-rw-r--r--packet-eth.h6
-rw-r--r--packet-ip.c29
-rw-r--r--packet-ip.h6
-rw-r--r--packet-tcp.c6
-rw-r--r--packet-tcp.h7
-rw-r--r--packet-tr.c22
-rw-r--r--packet-tr.h6
-rw-r--r--packet-udp.c5
-rw-r--r--packet-udp.h7
-rw-r--r--tap-iousers.c133
20 files changed, 1621 insertions, 150 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(&eth_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(&eth_talkers->talkers);
+}
+
+
+static void
+eth_talkers_draw(void *pit)
+{
+ eth_talkers_t *eth_talkers=(eth_talkers_t *)pit;
+
+ draw_ett_table_data(&eth_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(&eth_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(&eth_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);
+}
+
diff --git a/packet-eth.c b/packet-eth.c
index 02532499c9..c6627e3639 100644
--- a/packet-eth.c
+++ b/packet-eth.c
@@ -1,7 +1,7 @@
/* packet-eth.c
* Routines for ethernet packet disassembly
*
- * $Id: packet-eth.c,v 1.80 2003/08/21 21:05:29 guy Exp $
+ * $Id: packet-eth.c,v 1.81 2003/08/23 09:09:32 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -159,21 +159,33 @@ static void
dissect_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti;
- static eth_hdr ehdr;
+ eth_hdr *ehdr;
volatile gboolean is_802_2;
proto_tree *volatile fh_tree = NULL;
+ char *src_addr, *dst_addr;
+ static eth_hdr ehdrs[4];
+ static int ehdr_num=0;
+
+ ehdr_num++;
+ if(ehdr_num>=4){
+ ehdr_num=0;
+ }
+ ehdr=&ehdrs[ehdr_num];
+
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Ethernet");
- tvb_memcpy(tvb, ehdr.src, 6, 6);
- tvb_memcpy(tvb, ehdr.dst, 0, 6);
- SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, ehdr.src);
- SET_ADDRESS(&pinfo->src, AT_ETHER, 6, ehdr.src);
- SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, ehdr.dst);
- SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, ehdr.dst);
+ src_addr=tvb_get_ptr(tvb, 6, 6);
+ SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, src_addr);
+ SET_ADDRESS(&pinfo->src, AT_ETHER, 6, src_addr);
+ SET_ADDRESS(&ehdr->src, AT_ETHER, 6, src_addr);
+ dst_addr=tvb_get_ptr(tvb, 0, 6);
+ SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, dst_addr);
+ SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, dst_addr);
+ SET_ADDRESS(&ehdr->dst, AT_ETHER, 6, dst_addr);
- ehdr.type = tvb_get_ntohs(tvb, 12);
+ ehdr->type = tvb_get_ntohs(tvb, 12);
/*
* If the type/length field is <= the maximum 802.3 length,
@@ -191,7 +203,7 @@ dissect_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* frame; the dissector for those frames registers itself with
* an ethernet type of ETHERTYPE_UNK.
*/
- if (ehdr.type <= IEEE_802_3_MAX_LEN && ehdr.type != ETHERTYPE_UNK) {
+ if (ehdr->type <= IEEE_802_3_MAX_LEN && ehdr->type != ETHERTYPE_UNK) {
/* Oh, yuck. Cisco ISL frames require special interpretation of the
destination address field; fortunately, they can be recognized by
checking the first 5 octets of the destination address, which are
@@ -232,16 +244,16 @@ dissect_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
"IEEE 802.3 Ethernet %s", (is_802_2 ? "" : "Raw "));
fh_tree = proto_item_add_subtree(ti, ett_ieee8023);
+ }
- proto_tree_add_ether(fh_tree, hf_eth_dst, tvb, 0, 6, ehdr.dst);
- proto_tree_add_ether(fh_tree, hf_eth_src, tvb, 6, 6, ehdr.src);
+ proto_tree_add_ether(fh_tree, hf_eth_dst, tvb, 0, 6, dst_addr);
+ proto_tree_add_ether(fh_tree, hf_eth_src, tvb, 6, 6, src_addr);
/* add items for eth.addr filter */
- proto_tree_add_ether_hidden(fh_tree, hf_eth_addr, tvb, 0, 6, ehdr.dst);
- proto_tree_add_ether_hidden(fh_tree, hf_eth_addr, tvb, 6, 6, ehdr.src);
- }
+ proto_tree_add_ether_hidden(fh_tree, hf_eth_addr, tvb, 0, 6, dst_addr);
+ proto_tree_add_ether_hidden(fh_tree, hf_eth_addr, tvb, 6, 6, src_addr);
- dissect_802_3(ehdr.type, is_802_2, tvb, ETH_HEADER_SIZE, pinfo, tree, fh_tree,
+ dissect_802_3(ehdr->type, is_802_2, tvb, ETH_HEADER_SIZE, pinfo, tree, fh_tree,
hf_eth_len, hf_eth_trailer);
} else {
if (eth_interpret_as_fw1_monitor) {
@@ -254,23 +266,23 @@ dissect_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (tree) {
ti = proto_tree_add_protocol_format(tree, proto_eth, tvb, 0, ETH_HEADER_SIZE,
"Ethernet II, Src: %s, Dst: %s",
- ether_to_str(ehdr.src), ether_to_str(ehdr.dst));
+ ether_to_str(src_addr), ether_to_str(dst_addr));
fh_tree = proto_item_add_subtree(ti, ett_ether2);
+ }
- proto_tree_add_ether(fh_tree, hf_eth_dst, tvb, 0, 6, ehdr.dst);
- proto_tree_add_ether(fh_tree, hf_eth_src, tvb, 6, 6, ehdr.src);
+ proto_tree_add_ether(fh_tree, hf_eth_dst, tvb, 0, 6, dst_addr);
+ proto_tree_add_ether(fh_tree, hf_eth_src, tvb, 6, 6, src_addr);
/* add items for eth.addr filter */
- proto_tree_add_ether_hidden(fh_tree, hf_eth_addr, tvb, 0, 6, ehdr.dst);
- proto_tree_add_ether_hidden(fh_tree, hf_eth_addr, tvb, 6, 6, ehdr.src);
- }
+ proto_tree_add_ether_hidden(fh_tree, hf_eth_addr, tvb, 0, 6, dst_addr);
+ proto_tree_add_ether_hidden(fh_tree, hf_eth_addr, tvb, 6, 6, src_addr);
- ethertype(ehdr.type, tvb, ETH_HEADER_SIZE, pinfo, tree, fh_tree, hf_eth_type,
+ ethertype(ehdr->type, tvb, ETH_HEADER_SIZE, pinfo, tree, fh_tree, hf_eth_type,
hf_eth_trailer);
}
end_of_eth:
- tap_queue_packet(eth_tap, pinfo, &ehdr);
+ tap_queue_packet(eth_tap, pinfo, ehdr);
return;
}
diff --git a/packet-eth.h b/packet-eth.h
index d10309e639..86b1fd7be6 100644
--- a/packet-eth.h
+++ b/packet-eth.h
@@ -1,6 +1,6 @@
/* packet-eth.h
*
- * $Id: packet-eth.h,v 1.11 2003/08/21 21:05:29 guy Exp $
+ * $Id: packet-eth.h,v 1.12 2003/08/23 09:09:32 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -25,8 +25,8 @@
#define __PACKET_ETH_H__
typedef struct _eth_hdr {
- gchar dst[6];
- gchar src[6];
+ address dst;
+ address src;
guint16 type;
} eth_hdr;
diff --git a/packet-ip.c b/packet-ip.c
index 4fb016b85b..06a97afede 100644
--- a/packet-ip.c
+++ b/packet-ip.c
@@ -1,7 +1,7 @@
/* packet-ip.c
* Routines for IP and miscellaneous IP protocol packet disassembly
*
- * $Id: packet-ip.c,v 1.194 2003/07/11 09:30:48 guy Exp $
+ * $Id: packet-ip.c,v 1.195 2003/08/23 09:09:32 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -830,7 +830,6 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
eip_current=0;
}
iph=&eip_arr[eip_current];
- pinfo->private_data=iph;
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "IP");
@@ -966,24 +965,29 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_uint(ip_tree, hf_ip_checksum, tvb, offset + 10, 2, iph->ip_sum);
}
- tvb_memcpy(tvb, (guint8 *)&iph->ip_src, offset + 12, 4);
+ SET_ADDRESS(&pinfo->net_src, AT_IPv4, 4, tvb_get_ptr(tvb, offset + IPH_SRC, 4));
+ SET_ADDRESS(&pinfo->src, AT_IPv4, 4, tvb_get_ptr(tvb, offset + IPH_SRC, 4));
+ SET_ADDRESS(&iph->ip_src, AT_IPv4, 4, tvb_get_ptr(tvb, offset + IPH_SRC, 4));
if (tree) {
if (ip_summary_in_tree) {
proto_item_append_text(ti, ", Src Addr: %s (%s)",
- get_hostname(iph->ip_src), ip_to_str((guint8 *) &iph->ip_src));
+ get_hostname((guint)(*((guint *)iph->ip_src.data))), ip_to_str((guint8 *) iph->ip_src.data));
}
- proto_tree_add_ipv4(ip_tree, hf_ip_src, tvb, offset + 12, 4, iph->ip_src);
- proto_tree_add_ipv4_hidden(ip_tree, hf_ip_addr, tvb, offset + 12, 4, iph->ip_src);
+ proto_tree_add_ipv4(ip_tree, hf_ip_src, tvb, offset + 12, 4, (guint)(*((guint *)iph->ip_src.data)));
+ proto_tree_add_ipv4_hidden(ip_tree, hf_ip_addr, tvb, offset + 12, 4, (guint)(*((guint *)iph->ip_src.data)));
}
- tvb_memcpy(tvb, (guint8 *)&iph->ip_dst, offset + 16, 4);
+ SET_ADDRESS(&pinfo->net_dst, AT_IPv4, 4, tvb_get_ptr(tvb, offset + IPH_DST, 4));
+ SET_ADDRESS(&pinfo->dst, AT_IPv4, 4, tvb_get_ptr(tvb, offset + IPH_DST, 4));
+ SET_ADDRESS(&iph->ip_dst, AT_IPv4, 4, tvb_get_ptr(tvb, offset + IPH_DST, 4));
+
if (tree) {
if (ip_summary_in_tree) {
proto_item_append_text(ti, ", Dst Addr: %s (%s)",
- get_hostname(iph->ip_dst), ip_to_str((guint8 *) &iph->ip_dst));
+ get_hostname((guint)(*((guint *)iph->ip_dst.data))), ip_to_str((guint8 *) &iph->ip_dst.data));
}
- proto_tree_add_ipv4(ip_tree, hf_ip_dst, tvb, offset + 16, 4, iph->ip_dst);
- proto_tree_add_ipv4_hidden(ip_tree, hf_ip_addr, tvb, offset + 16, 4, iph->ip_dst);
+ proto_tree_add_ipv4(ip_tree, hf_ip_dst, tvb, offset + 16, 4, (guint)(*((guint *)iph->ip_dst.data)));
+ proto_tree_add_ipv4_hidden(ip_tree, hf_ip_addr, tvb, offset + 16, 4, (guint)(*((guint *)iph->ip_dst.data)));
}
if (tree) {
@@ -1006,11 +1010,6 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
pinfo->iphdrlen = hlen;
- SET_ADDRESS(&pinfo->net_src, AT_IPv4, 4, tvb_get_ptr(tvb, offset + IPH_SRC, 4));
- SET_ADDRESS(&pinfo->src, AT_IPv4, 4, tvb_get_ptr(tvb, offset + IPH_SRC, 4));
- SET_ADDRESS(&pinfo->net_dst, AT_IPv4, 4, tvb_get_ptr(tvb, offset + IPH_DST, 4));
- SET_ADDRESS(&pinfo->dst, AT_IPv4, 4, tvb_get_ptr(tvb, offset + IPH_DST, 4));
-
/* Skip over header + options */
offset += hlen;
nxt = iph->ip_p; /* XXX - what if this isn't the same for all fragments? */
diff --git a/packet-ip.h b/packet-ip.h
index 9170983d9b..60df820ab3 100644
--- a/packet-ip.h
+++ b/packet-ip.h
@@ -1,7 +1,7 @@
/* packet-ip.h
* Definitions for IP packet disassembly structures and routines
*
- * $Id: packet-ip.h,v 1.28 2003/07/11 09:30:48 guy Exp $
+ * $Id: packet-ip.h,v 1.29 2003/08/23 09:09:33 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -36,8 +36,8 @@ typedef struct _e_ip
guint8 ip_ttl;
guint8 ip_p;
guint16 ip_sum;
- guint32 ip_src;
- guint32 ip_dst;
+ address ip_src;
+ address ip_dst;
} e_ip;
void capture_ip(const guchar *, int, int, packet_counts *);
diff --git a/packet-tcp.c b/packet-tcp.c
index eec2304bb5..1f76df892e 100644
--- a/packet-tcp.c
+++ b/packet-tcp.c
@@ -1,7 +1,7 @@
/* packet-tcp.c
* Routines for TCP packet disassembly
*
- * $Id: packet-tcp.c,v 1.200 2003/07/24 21:11:19 guy Exp $
+ * $Id: packet-tcp.c,v 1.201 2003/08/23 09:09:33 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -2106,8 +2106,8 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
tcph_count=0;
}
tcph=&tcphstruct[tcph_count];
- /* XXX add to ipv6 so this works for that protocol as well */
- tcph->ip_header=pinfo->private_data;
+ SET_ADDRESS(&tcph->ip_src, pinfo->src.type, pinfo->src.len, pinfo->src.data);
+ SET_ADDRESS(&tcph->ip_dst, pinfo->dst.type, pinfo->dst.len, pinfo->dst.data);
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "TCP");
diff --git a/packet-tcp.h b/packet-tcp.h
index 391260cd88..7094143005 100644
--- a/packet-tcp.h
+++ b/packet-tcp.h
@@ -1,6 +1,6 @@
/* packet-tcp.h
*
- * $Id: packet-tcp.h,v 1.16 2003/05/21 06:28:03 guy Exp $
+ * $Id: packet-tcp.h,v 1.17 2003/08/23 09:09:34 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -46,9 +46,8 @@ struct tcpheader {
guint16 th_dport;
guint8 th_hlen;
guint8 th_flags;
- /* this can either be ipv4 or ipv6, make sure you know which
- one you get. */
- void *ip_header;
+ address ip_src;
+ address ip_dst;
};
/*
diff --git a/packet-tr.c b/packet-tr.c
index 3e3396b7a0..cf63cb3a52 100644
--- a/packet-tr.c
+++ b/packet-tr.c
@@ -2,7 +2,7 @@
* Routines for Token-Ring packet disassembly
* Gilbert Ramirez <gram@alumni.rice.edu>
*
- * $Id: packet-tr.c,v 1.76 2003/02/08 05:31:05 guy Exp $
+ * $Id: packet-tr.c,v 1.77 2003/08/23 09:09:33 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -374,10 +374,10 @@ dissect_tr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* Get the data */
trh->fc = tvb_get_guint8(tr_tvb, 1);
- tvb_memcpy(tr_tvb, trh->dst, 2, 6);
- tvb_memcpy(tr_tvb, trh->src, 8, 6);
+ SET_ADDRESS(&trh->src, AT_ETHER, 6, tvb_get_ptr(tr_tvb, 8, 6));
+ SET_ADDRESS(&trh->dst, AT_ETHER, 6, tvb_get_ptr(tr_tvb, 2, 6));
- memcpy(trn_shost_nonsr, trh->src, 6);
+ memcpy(trn_shost_nonsr, trh->src.data, 6);
trn_shost_nonsr[0] &= 127;
frame_type = (trh->fc & 192) >> 6;
@@ -386,7 +386,7 @@ dissect_tr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* if the high bit on the first byte of src hwaddr is 1, then
this packet is source-routed */
- source_routed = trh->src[0] & 128;
+ source_routed = trh->src.data[0] & 128;
trn_rif_bytes = tvb_get_guint8(tr_tvb, 14) & 31;
@@ -492,8 +492,8 @@ dissect_tr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
just making "trn_shost_nonsr" static? */
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, trn_shost_nonsr);
SET_ADDRESS(&pinfo->src, AT_ETHER, 6, trn_shost_nonsr);
- SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, trh->dst);
- SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, trh->dst);
+ SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, trh->dst.data);
+ SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, trh->dst.data);
/* protocol analysis tree */
if (tree) {
@@ -517,10 +517,10 @@ dissect_tr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_uint(bf_tree, hf_tr_fc_type, tr_tvb, 1, 1, trh->fc);
proto_tree_add_uint(bf_tree, hf_tr_fc_pcf, tr_tvb, 1, 1, trh->fc);
- proto_tree_add_ether(tr_tree, hf_tr_dst, tr_tvb, 2, 6, trh->dst);
- proto_tree_add_ether(tr_tree, hf_tr_src, tr_tvb, 8, 6, trh->src);
- proto_tree_add_ether_hidden(tr_tree, hf_tr_addr, tr_tvb, 2, 6, trh->dst);
- proto_tree_add_ether_hidden(tr_tree, hf_tr_addr, tr_tvb, 8, 6, trh->src);
+ proto_tree_add_ether(tr_tree, hf_tr_dst, tr_tvb, 2, 6, trh->dst.data);
+ proto_tree_add_ether(tr_tree, hf_tr_src, tr_tvb, 8, 6, trh->src.data);
+ proto_tree_add_ether_hidden(tr_tree, hf_tr_addr, tr_tvb, 2, 6, trh->dst.data);
+ proto_tree_add_ether_hidden(tr_tree, hf_tr_addr, tr_tvb, 8, 6, trh->src.data);
proto_tree_add_boolean(tr_tree, hf_tr_sr, tr_tvb, 8, 1, source_routed);
diff --git a/packet-tr.h b/packet-tr.h
index 7a0bb3fb07..d47271ca86 100644
--- a/packet-tr.h
+++ b/packet-tr.h
@@ -1,6 +1,6 @@
/* packet-tr.h
*
- * $Id: packet-tr.h,v 1.8 2003/01/22 01:17:01 sahlberg Exp $
+ * $Id: packet-tr.h,v 1.9 2003/08/23 09:09:33 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -27,8 +27,8 @@
typedef struct _tr_hdr {
guint8 ac;
guint8 fc;
- guint8 dst[6];
- guint8 src[6];
+ address dst;
+ address src;
} tr_hdr;
void capture_tr(const guchar *, int, int, packet_counts *);
diff --git a/packet-udp.c b/packet-udp.c
index 63c91a408f..0f08f13a10 100644
--- a/packet-udp.c
+++ b/packet-udp.c
@@ -1,7 +1,7 @@
/* packet-udp.c
* Routines for UDP packet disassembly
*
- * $Id: packet-udp.c,v 1.109 2003/07/24 21:11:20 guy Exp $
+ * $Id: packet-udp.c,v 1.110 2003/08/23 09:09:33 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -152,7 +152,8 @@ dissect_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
udph_count=0;
}
udph=&udphstruct[udph_count];
- udph->ip_header=pinfo->private_data;
+ SET_ADDRESS(&udph->ip_src, pinfo->src.type, pinfo->src.len, pinfo->src.data);
+ SET_ADDRESS(&udph->ip_dst, pinfo->dst.type, pinfo->dst.len, pinfo->dst.data);
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "UDP");
diff --git a/packet-udp.h b/packet-udp.h
index 30dd8ecda5..45a967d293 100644
--- a/packet-udp.h
+++ b/packet-udp.h
@@ -1,6 +1,6 @@
/* packet-udp.h
*
- * $Id: packet-udp.h,v 1.7 2003/03/03 23:46:48 sahlberg Exp $
+ * $Id: packet-udp.h,v 1.8 2003/08/23 09:09:33 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -31,9 +31,8 @@ typedef struct _e_udphdr {
guint16 uh_dport;
guint16 uh_ulen;
guint16 uh_sum;
- /* This can be either a ipv4 or a ipv6 header struct so make sure you know
- what you try to dereference */
- void *ip_header;
+ address ip_src;
+ address ip_dst;
} e_udphdr;
diff --git a/tap-iousers.c b/tap-iousers.c
index 1ea6e6e835..313f5447da 100644
--- a/tap-iousers.c
+++ b/tap-iousers.c
@@ -1,7 +1,8 @@
+/* should be almost trivial to fix tcp and udp to also handle ipv6 */
/* tap-iousers.c
* iostat 2003 Ronnie Sahlberg
*
- * $Id: tap-iousers.c,v 1.7 2003/05/19 11:16:29 sahlberg Exp $
+ * $Id: tap-iousers.c,v 1.8 2003/08/23 09:09:34 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -55,8 +56,8 @@ typedef struct _io_users_item_t {
struct _io_users_item_t *next;
char *name1;
char *name2;
- void *addr1;
- void *addr2;
+ address addr1;
+ address addr2;
guint32 frames1;
guint32 frames2;
guint32 bytes1;
@@ -73,19 +74,17 @@ iousers_udpip_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_
e_udphdr *udph=vudph;
char name1[256],name2[256];
io_users_item_t *iui;
- e_ip *ipv4_header;
int direction=0;
- ipv4_header=udph->ip_header;
- switch(ipv4_header->ip_v_hl>>4){
- case 4:
- if(ipv4_header->ip_src>ipv4_header->ip_dst){
- snprintf(name1,256,"%s:%s",get_hostname(ipv4_header->ip_src),get_udp_port(udph->uh_sport));
- snprintf(name2,256,"%s:%s",get_hostname(ipv4_header->ip_dst),get_udp_port(udph->uh_dport));
+ switch(udph->ip_src.type){
+ case AT_IPv4:
+ if(CMP_ADDRESS(&udph->ip_src, &udph->ip_dst)>0){
+ snprintf(name1,256,"%s:%s",get_hostname((guint)(*((guint *)udph->ip_src.data))),get_udp_port(udph->uh_sport));
+ snprintf(name2,256,"%s:%s",get_hostname((guint)(*((guint *)udph->ip_dst.data))),get_udp_port(udph->uh_dport));
} else {
direction=1;
- snprintf(name2,256,"%s:%s",get_hostname(ipv4_header->ip_src),get_udp_port(udph->uh_sport));
- snprintf(name1,256,"%s:%s",get_hostname(ipv4_header->ip_dst),get_udp_port(udph->uh_dport));
+ snprintf(name2,256,"%s:%s",get_hostname((guint)(*((guint *)udph->ip_src.data))),get_udp_port(udph->uh_sport));
+ snprintf(name1,256,"%s:%s",get_hostname((guint)(*((guint *)udph->ip_dst.data))),get_udp_port(udph->uh_dport));
}
break;
default:
@@ -103,9 +102,9 @@ iousers_udpip_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_
iui=g_malloc(sizeof(io_users_item_t));
iui->next=iu->items;
iu->items=iui;
- iui->addr1=NULL;
+/* iui->addr1=NULL;*/
iui->name1=strdup(name1);
- iui->addr2=NULL;
+/* iui->addr2=NULL;*/
iui->name2=strdup(name2);
iui->frames1=0;
iui->frames2=0;
@@ -124,6 +123,7 @@ iousers_udpip_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_
return 1;
}
+
/* XXX for now we only handle ipv4 as transport for tcp.
should extend in the future to also handle ipv6
*/
@@ -133,19 +133,17 @@ iousers_tcpip_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_
struct tcpheader *tcph=vtcph;
char name1[256],name2[256];
io_users_item_t *iui;
- e_ip *ipv4_header;
int direction=0;
- ipv4_header=tcph->ip_header;
- switch(ipv4_header->ip_v_hl>>4){
- case 4:
- if(ipv4_header->ip_src>ipv4_header->ip_dst){
- snprintf(name1,256,"%s:%s",get_hostname(ipv4_header->ip_src),get_tcp_port(tcph->th_sport));
- snprintf(name2,256,"%s:%s",get_hostname(ipv4_header->ip_dst),get_tcp_port(tcph->th_dport));
+ switch(tcph->ip_src.type){
+ case AT_IPv4:
+ if(CMP_ADDRESS(&tcph->ip_src, &tcph->ip_dst)>0){
+ snprintf(name1,256,"%s:%s",get_hostname((guint)(*((guint *)tcph->ip_src.data))),get_tcp_port(tcph->th_sport));
+ snprintf(name2,256,"%s:%s",get_hostname((guint)(*((guint *)tcph->ip_dst.data))),get_tcp_port(tcph->th_dport));
} else {
direction=1;
- snprintf(name2,256,"%s:%s",get_hostname(ipv4_header->ip_src),get_tcp_port(tcph->th_sport));
- snprintf(name1,256,"%s:%s",get_hostname(ipv4_header->ip_dst),get_tcp_port(tcph->th_dport));
+ snprintf(name2,256,"%s:%s",get_hostname((guint)(*((guint *)tcph->ip_src.data))),get_tcp_port(tcph->th_sport));
+ snprintf(name1,256,"%s:%s",get_hostname((guint)(*((guint *)tcph->ip_dst.data))),get_tcp_port(tcph->th_dport));
}
break;
default:
@@ -163,9 +161,9 @@ iousers_tcpip_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_
iui=g_malloc(sizeof(io_users_item_t));
iui->next=iu->items;
iu->items=iui;
- iui->addr1=NULL;
+/* iui->addr1=NULL;*/
iui->name1=strdup(name1);
- iui->addr2=NULL;
+/* iui->addr2=NULL;*/
iui->name2=strdup(name2);
iui->frames1=0;
iui->frames2=0;
@@ -189,20 +187,20 @@ static int
iousers_ip_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_, void *vip)
{
e_ip *iph=vip;
- guint32 addr1, addr2;
+ address *addr1, *addr2;
io_users_item_t *iui;
- if(iph->ip_src>iph->ip_dst){
- addr1=iph->ip_src;
- addr2=iph->ip_dst;
+ if(CMP_ADDRESS(&iph->ip_src, &iph->ip_dst)>0){
+ addr1=&iph->ip_src;
+ addr2=&iph->ip_dst;
} else {
- addr2=iph->ip_src;
- addr1=iph->ip_dst;
+ addr2=&iph->ip_src;
+ addr1=&iph->ip_dst;
}
for(iui=iu->items;iui;iui=iui->next){
- if((!memcmp(iui->addr1, &addr1, 4))
- &&(!memcmp(iui->addr2, &addr2, 4)) ){
+ if((!CMP_ADDRESS(&iui->addr1, addr1))
+ &&(!CMP_ADDRESS(&iui->addr2, addr2)) ){
break;
}
}
@@ -211,19 +209,17 @@ iousers_ip_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_, v
iui=g_malloc(sizeof(io_users_item_t));
iui->next=iu->items;
iu->items=iui;
- iui->addr1=g_malloc(4);
- memcpy(iui->addr1, &addr1, 4);
- iui->name1=strdup(get_hostname(addr1));
- iui->addr2=g_malloc(4);
- memcpy(iui->addr2, &addr2, 4);
- iui->name2=strdup(get_hostname(addr2));
+ COPY_ADDRESS(&iui->addr1, addr1);
+ iui->name1=strdup(get_hostname((guint)(*((guint *)addr1->data))));
+ COPY_ADDRESS(&iui->addr2, addr2);
+ iui->name2=strdup(get_hostname((guint)(*((guint *)addr2->data))));
iui->frames1=0;
iui->frames2=0;
iui->bytes1=0;
iui->bytes2=0;
}
- if(!memcmp(&iph->ip_dst,iui->addr1,4)){
+ if(!CMP_ADDRESS(&iph->ip_dst, &iui->addr1)){
iui->frames1++;
iui->bytes1+=pinfo->fd->pkt_len;
} else {
@@ -238,20 +234,20 @@ static int
iousers_eth_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_, void *veth)
{
eth_hdr *ehdr=veth;
- gchar *addr1, *addr2;
+ address *addr1, *addr2;
io_users_item_t *iui;
- if(memcmp(ehdr->src, ehdr->dst, 6)<0){
- addr1=ehdr->src;
- addr2=ehdr->dst;
+ if(CMP_ADDRESS(&ehdr->src, &ehdr->dst)<0){
+ addr1=&ehdr->src;
+ addr2=&ehdr->dst;
} else {
- addr2=ehdr->src;
- addr1=ehdr->dst;
+ addr2=&ehdr->src;
+ addr1=&ehdr->dst;
}
for(iui=iu->items;iui;iui=iui->next){
- if((!memcmp(iui->addr1, addr1, 6))
- &&(!memcmp(iui->addr2, addr2, 6)) ){
+ if((!CMP_ADDRESS(&iui->addr1, addr1))
+ &&(!CMP_ADDRESS(&iui->addr2, addr2)) ){
break;
}
}
@@ -260,19 +256,17 @@ iousers_eth_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_,
iui=g_malloc(sizeof(io_users_item_t));
iui->next=iu->items;
iu->items=iui;
- iui->addr1=g_malloc(6);
- memcpy(iui->addr1, addr1, 6);
- iui->name1=strdup(ether_to_str(addr1));
- iui->addr2=g_malloc(6);
- memcpy(iui->addr2, addr2, 6);
- iui->name2=strdup(ether_to_str(addr2));
+ COPY_ADDRESS(&iui->addr1, addr1);
+ iui->name1=strdup(ether_to_str(addr1->data));
+ COPY_ADDRESS(&iui->addr2, addr2);
+ iui->name2=strdup(ether_to_str(addr2->data));
iui->frames1=0;
iui->frames2=0;
iui->bytes1=0;
iui->bytes2=0;
}
- if(!memcmp(ehdr->dst,iui->addr1,6)){
+ if(!CMP_ADDRESS(&ehdr->dst,&iui->addr1)){
iui->frames1++;
iui->bytes1+=pinfo->fd->pkt_len;
} else {
@@ -283,25 +277,24 @@ iousers_eth_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_,
return 1;
}
-
static int
iousers_tr_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_, void *vtr)
{
tr_hdr *trhdr=vtr;
- gchar *addr1, *addr2;
+ address *addr1, *addr2;
io_users_item_t *iui;
- if(memcmp(trhdr->src, trhdr->dst, 6)<0){
- addr1=trhdr->src;
- addr2=trhdr->dst;
+ if(CMP_ADDRESS(&trhdr->src, &trhdr->dst)<0){
+ addr1=&trhdr->src;
+ addr2=&trhdr->dst;
} else {
- addr2=trhdr->src;
- addr1=trhdr->dst;
+ addr2=&trhdr->src;
+ addr1=&trhdr->dst;
}
for(iui=iu->items;iui;iui=iui->next){
- if((!memcmp(iui->addr1, addr1, 6))
- &&(!memcmp(iui->addr2, addr2, 6)) ){
+ if((!CMP_ADDRESS(&iui->addr1, addr1))
+ &&(!CMP_ADDRESS(&iui->addr2, addr2)) ){
break;
}
}
@@ -310,19 +303,17 @@ iousers_tr_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_, v
iui=g_malloc(sizeof(io_users_item_t));
iui->next=iu->items;
iu->items=iui;
- iui->addr1=g_malloc(6);
- memcpy(iui->addr1, addr1, 6);
- iui->name1=strdup(ether_to_str(addr1));
- iui->addr2=g_malloc(6);
- memcpy(iui->addr2, addr2, 6);
- iui->name2=strdup(ether_to_str(addr2));
+ COPY_ADDRESS(&iui->addr1, addr1);
+ iui->name1=strdup(ether_to_str(addr1->data));
+ COPY_ADDRESS(&iui->addr2, addr2);
+ iui->name2=strdup(ether_to_str(addr2->data));
iui->frames1=0;
iui->frames2=0;
iui->bytes1=0;
iui->bytes2=0;
}
- if(!memcmp(trhdr->dst,iui->addr1,6)){
+ if(!CMP_ADDRESS(&trhdr->dst,&iui->addr1)){
iui->frames1++;
iui->bytes1+=pinfo->fd->pkt_len;
} else {