2003-08-23 09:09:35 +00:00
|
|
|
/* endpoint_talkers_tcpip.c
|
|
|
|
* endpoint_talkers_tcpip 2003 Ronnie Sahlberg
|
|
|
|
*
|
2003-09-04 11:07:51 +00:00
|
|
|
* $Id: endpoint_talkers_tcpip.c,v 1.14 2003/09/04 11:07:51 sahlberg Exp $
|
2003-08-23 09:09:35 +00:00
|
|
|
*
|
|
|
|
* 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"
|
2003-09-02 08:27:43 +00:00
|
|
|
#include "../epan/filesystem.h"
|
2003-08-23 09:09:35 +00:00
|
|
|
#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"
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
tcpip_talkers_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, void *vip)
|
|
|
|
{
|
2003-08-30 00:47:43 +00:00
|
|
|
endpoints_table *talkers=(endpoints_table *)pit;
|
2003-08-23 09:09:35 +00:00
|
|
|
struct tcpheader *tcphdr=vip;
|
|
|
|
|
2003-09-04 11:07:51 +00:00
|
|
|
add_ett_table_data(talkers, &tcphdr->ip_src, &tcphdr->ip_dst, tcphdr->th_sport, tcphdr->th_dport, 1, pinfo->fd->pkt_len, SAT_NONE, PT_TCP);
|
2003-08-23 09:09:35 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tcpip_talkers_init(char *optarg)
|
|
|
|
{
|
|
|
|
char *filter=NULL;
|
2003-08-30 00:47:43 +00:00
|
|
|
endpoints_table *talkers;
|
2003-08-23 09:09:35 +00:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
GString *error_string;
|
2003-08-25 11:06:32 +00:00
|
|
|
char title[256];
|
2003-08-23 09:09:35 +00:00
|
|
|
|
2003-08-23 13:56:40 +00:00
|
|
|
if(!strncmp(optarg,"talkers,tcp,",12)){
|
|
|
|
filter=optarg+12;
|
2003-08-23 09:09:35 +00:00
|
|
|
} else {
|
|
|
|
filter=NULL;
|
|
|
|
}
|
|
|
|
|
2003-08-30 00:47:43 +00:00
|
|
|
talkers=g_malloc(sizeof(endpoints_table));
|
2003-08-23 09:09:35 +00:00
|
|
|
|
2003-08-30 01:18:16 +00:00
|
|
|
talkers->name="TCP";
|
2003-08-30 00:47:43 +00:00
|
|
|
talkers->win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_window_set_default_size(GTK_WINDOW(talkers->win), 750, 400);
|
2003-09-02 08:27:43 +00:00
|
|
|
snprintf(title, 255, "TCP Talkers: %s", get_basename(cfile.filename));
|
2003-08-30 00:47:43 +00:00
|
|
|
gtk_window_set_title(GTK_WINDOW(talkers->win), title);
|
2003-08-23 09:09:35 +00:00
|
|
|
|
2003-08-30 00:53:15 +00:00
|
|
|
SIGNAL_CONNECT(talkers->win, "destroy", ett_win_destroy_cb, talkers);
|
2003-08-23 09:09:35 +00:00
|
|
|
|
|
|
|
vbox=gtk_vbox_new(FALSE, 0);
|
2003-08-30 00:47:43 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(talkers->win), vbox);
|
2003-08-23 09:09:35 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
|
2003-08-23 13:56:40 +00:00
|
|
|
label=gtk_label_new("TCP Talkers");
|
2003-08-23 09:09:35 +00:00
|
|
|
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() */
|
2003-08-30 00:47:43 +00:00
|
|
|
gtk_widget_show(talkers->win);
|
2003-08-23 09:09:35 +00:00
|
|
|
|
2003-09-04 11:07:51 +00:00
|
|
|
init_ett_table(talkers, vbox, FALSE);
|
2003-08-23 09:09:35 +00:00
|
|
|
|
2003-08-30 01:18:16 +00:00
|
|
|
error_string=register_tap_listener("tcp", talkers, filter, (void *)reset_ett_table_data, tcpip_talkers_packet, (void *)draw_ett_table_data);
|
2003-08-23 09:09:35 +00:00
|
|
|
if(error_string){
|
|
|
|
simple_dialog(ESD_TYPE_WARN, NULL, error_string->str);
|
|
|
|
g_string_free(error_string, TRUE);
|
2003-08-30 00:47:43 +00:00
|
|
|
g_free(talkers);
|
2003-08-23 09:09:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-08-30 00:47:43 +00:00
|
|
|
gtk_widget_show_all(talkers->win);
|
2003-08-23 09:09:35 +00:00
|
|
|
redissect_packets(&cfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_tcpip_endpoints_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
2003-08-23 13:56:40 +00:00
|
|
|
gtk_tcpip_talkers_init("talkers,tcp");
|
2003-08-23 09:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
register_tap_menu_tcpip_talkers(void)
|
|
|
|
{
|
2003-08-23 13:56:40 +00:00
|
|
|
register_tap_menu_item("Endpoint Talkers/TCP (IPv4 IPv6)", gtk_tcpip_endpoints_cb);
|
2003-08-23 09:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
register_tap_listener_tcpip_talkers(void)
|
|
|
|
{
|
2003-08-23 13:56:40 +00:00
|
|
|
register_ethereal_tap("talkers,tcp", gtk_tcpip_talkers_init);
|
2003-08-23 09:09:35 +00:00
|
|
|
}
|
|
|
|
|