1999-12-10 04:21:04 +00:00
|
|
|
/* summary_dlg.c
|
|
|
|
* Routines for capture file summary window
|
|
|
|
*
|
2004-02-02 22:51:30 +00:00
|
|
|
* $Id: summary_dlg.c,v 1.26 2004/02/02 22:51:30 guy Exp $
|
1999-12-10 04:21:04 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
2003-09-02 22:10:32 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
1999-12-10 04:21:04 +00:00
|
|
|
* 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
|
|
|
|
|
2004-02-02 22:51:30 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
1999-12-10 04:21:04 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include <wtap.h>
|
|
|
|
|
|
|
|
#ifdef NEED_SNPRINTF_H
|
|
|
|
# include "snprintf.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "summary.h"
|
|
|
|
#include "summary_dlg.h"
|
2000-05-03 07:44:12 +00:00
|
|
|
#include "dlg_utils.h"
|
2001-12-12 21:39:01 +00:00
|
|
|
#include "ui_util.h"
|
2002-11-11 15:39:06 +00:00
|
|
|
#include "compat_macros.h"
|
1999-12-10 04:21:04 +00:00
|
|
|
|
|
|
|
#define SUM_STR_MAX 1024
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_string_to_box(gchar *str, GtkWidget *box)
|
|
|
|
{
|
|
|
|
GtkWidget *lb;
|
|
|
|
lb = gtk_label_new(str);
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(lb), 0.0, 0.5);
|
|
|
|
gtk_box_pack_start(GTK_BOX(box), lb,FALSE,FALSE, 0);
|
|
|
|
gtk_widget_show(lb);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
|
1999-12-10 04:21:04 +00:00
|
|
|
{
|
|
|
|
summary_tally summary;
|
|
|
|
GtkWidget *sum_open_w,
|
2002-08-28 21:04:11 +00:00
|
|
|
*main_vb, *file_fr, *data_fr, *capture_fr, *file_box,
|
2003-09-02 22:10:32 +00:00
|
|
|
*filter_box, *filter_fr,
|
2000-07-05 06:19:27 +00:00
|
|
|
*data_box, *capture_box, *bbox, *close_bt;
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2004-02-01 13:13:33 +00:00
|
|
|
gchar string_buff[SUM_STR_MAX];
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2004-02-01 13:13:33 +00:00
|
|
|
double seconds;
|
|
|
|
guint offset;
|
|
|
|
gchar *str_dup;
|
|
|
|
gchar *str_work;
|
1999-12-10 04:21:04 +00:00
|
|
|
|
|
|
|
/* initialize the tally */
|
|
|
|
summary_fill_in(&summary);
|
|
|
|
|
2004-02-01 13:13:33 +00:00
|
|
|
/* initial computations */
|
1999-12-10 04:21:04 +00:00
|
|
|
seconds = summary.stop_time - summary.start_time;
|
|
|
|
sum_open_w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_window_set_title(GTK_WINDOW(sum_open_w), "Ethereal: Summary");
|
2002-11-11 15:39:06 +00:00
|
|
|
SIGNAL_CONNECT(sum_open_w, "realize", window_icon_realize_cb, NULL);
|
1999-12-10 04:21:04 +00:00
|
|
|
|
|
|
|
/* Container for each row of widgets */
|
|
|
|
main_vb = gtk_vbox_new(FALSE, 3);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
|
|
|
|
gtk_container_add(GTK_CONTAINER(sum_open_w), main_vb);
|
|
|
|
gtk_widget_show(main_vb);
|
|
|
|
|
|
|
|
/* File frame */
|
|
|
|
file_fr = gtk_frame_new("File");
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), file_fr);
|
|
|
|
gtk_widget_show(file_fr);
|
|
|
|
|
|
|
|
file_box = gtk_vbox_new(FALSE, 3);
|
2004-02-01 15:33:08 +00:00
|
|
|
gtk_container_border_width(GTK_CONTAINER(file_box), 5);
|
1999-12-10 04:21:04 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(file_fr), file_box);
|
|
|
|
gtk_widget_show(file_box);
|
|
|
|
|
|
|
|
/* filename */
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Name: %s", summary.filename);
|
|
|
|
add_string_to_box(string_buff, file_box);
|
|
|
|
|
|
|
|
/* length */
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Length: %lu", summary.file_length);
|
|
|
|
add_string_to_box(string_buff, file_box);
|
|
|
|
|
|
|
|
/* format */
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Format: %s", wtap_file_type_string(summary.encap_type));
|
|
|
|
add_string_to_box(string_buff, file_box);
|
|
|
|
|
Have Wiretap set the snapshot length to 0 if it can't be derived from
reading the capture file. Have callers of "wtap_snapshot_length()"
treat a value of 0 as "unknown", and default to WTAP_MAX_PACKET_SIZE (so
that, when writing a capture file in a format that *does* store the
snapshot length, we can at least put *something* in the file).
If we don't know the snapshot length of the current capture file, don't
display a value in the summary window.
Don't use "cfile.snap" as the snapshot length option when capturing -
doing so causes Ethereal to default, when capturing, to the snapshot
length of the last capture file that you read in, rather than to the
snapshot length of the last capture you did (or the initial default of
"no snapshot length").
Redo the "Capture Options" dialog box to group options into sections
with frames around them, and add units to the snapshot length, maximum
file size, and capture duration options, as per a suggestion by Ulf
Lamping. Also add units to the capture count option.
Make the snapshot length, capture count, maximum file size, and capture
duration options into a combination of a check box and a spin button.
If the check box is not checked, the limit in question is inactive
(snapshot length of 65535, no max packet count, no max file size, no max
capture duration); if it's checked, the spinbox specifies the limit.
Default all of the check boxes to "not checked" and all of the spin
boxes to small values.
Use "gtk_toggle_button_get_active()" rather than directly fetching the
state of a check box.
svn path=/trunk/; revision=4709
2002-02-08 10:07:41 +00:00
|
|
|
if (summary.has_snap) {
|
|
|
|
/* snapshot length */
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Snapshot length: %u", summary.snap);
|
|
|
|
add_string_to_box(string_buff, file_box);
|
|
|
|
}
|
1999-12-10 04:21:04 +00:00
|
|
|
|
|
|
|
/* Data frame */
|
|
|
|
data_fr = gtk_frame_new("Data");
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), data_fr);
|
|
|
|
gtk_widget_show(data_fr);
|
|
|
|
|
|
|
|
data_box = gtk_vbox_new(FALSE, 3);
|
2004-02-01 15:33:08 +00:00
|
|
|
gtk_container_border_width(GTK_CONTAINER(data_box), 5);
|
1999-12-10 04:21:04 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(data_fr), data_box);
|
|
|
|
gtk_widget_show(data_box);
|
|
|
|
|
|
|
|
/* seconds */
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Elapsed time: %.3f seconds", summary.elapsed_time);
|
|
|
|
add_string_to_box(string_buff, data_box);
|
|
|
|
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Between first and last packet: %.3f seconds", seconds);
|
|
|
|
add_string_to_box(string_buff, data_box);
|
|
|
|
|
|
|
|
/* Packet count */
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Packet count: %i", summary.packet_count);
|
|
|
|
add_string_to_box(string_buff, data_box);
|
|
|
|
|
|
|
|
/* Filtered Packet count */
|
2003-09-02 22:10:32 +00:00
|
|
|
/* Unless there is none filter, we move informations about filtered packets in a separate frame */
|
|
|
|
if (!summary.dfilter)
|
|
|
|
add_string_to_box("Filtered packet count: 0", data_box);
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2000-08-21 18:20:19 +00:00
|
|
|
/* Marked Packet count */
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Marked packet count: %i", summary.marked_count);
|
|
|
|
add_string_to_box(string_buff, data_box);
|
|
|
|
|
1999-12-10 04:21:04 +00:00
|
|
|
/* Packets per second */
|
|
|
|
if (seconds > 0){
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Avg. packets/sec: %.3f", summary.packet_count/seconds);
|
|
|
|
add_string_to_box(string_buff, data_box);
|
|
|
|
}
|
|
|
|
|
2003-03-07 20:27:02 +00:00
|
|
|
/* Packet size */
|
2003-12-21 22:32:07 +00:00
|
|
|
if (summary.packet_count > 0){
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Avg. packet size: %.3f bytes",
|
|
|
|
(float)summary.bytes/summary.packet_count);
|
|
|
|
add_string_to_box(string_buff, data_box);
|
|
|
|
}
|
2003-03-07 20:27:02 +00:00
|
|
|
|
1999-12-10 04:21:04 +00:00
|
|
|
/* Dropped count */
|
2001-02-11 09:28:17 +00:00
|
|
|
if (summary.drops_known) {
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Dropped packets: %u", summary.drops);
|
|
|
|
add_string_to_box(string_buff, data_box);
|
|
|
|
}
|
1999-12-10 04:21:04 +00:00
|
|
|
|
|
|
|
/* Byte count */
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Bytes of traffic: %d", summary.bytes);
|
|
|
|
add_string_to_box(string_buff, data_box);
|
|
|
|
|
|
|
|
/* Bytes per second */
|
|
|
|
if (seconds > 0){
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Avg. bytes/sec: %.3f", summary.bytes/seconds);
|
|
|
|
add_string_to_box(string_buff, data_box);
|
2000-08-19 21:36:51 +00:00
|
|
|
|
|
|
|
/* MBit per second */
|
2002-11-03 17:38:45 +00:00
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Avg. Mbit/sec: %.3f",
|
|
|
|
summary.bytes * 8.0 / (seconds * 1000.0 * 1000.0));
|
2000-08-19 21:36:51 +00:00
|
|
|
add_string_to_box(string_buff, data_box);
|
1999-12-10 04:21:04 +00:00
|
|
|
}
|
|
|
|
|
2003-12-20 12:03:35 +00:00
|
|
|
/* Filtered packets frame */
|
|
|
|
filter_fr = gtk_frame_new("Data in filtered packets");
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), filter_fr);
|
|
|
|
gtk_widget_show(filter_fr);
|
2003-09-02 22:10:32 +00:00
|
|
|
|
2003-12-20 12:03:35 +00:00
|
|
|
filter_box = gtk_vbox_new( FALSE, 3);
|
2004-02-01 15:33:08 +00:00
|
|
|
gtk_container_border_width(GTK_CONTAINER(filter_box), 5);
|
2003-12-20 12:03:35 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(filter_fr), filter_box);
|
|
|
|
gtk_widget_show(filter_box);
|
2003-09-02 22:10:32 +00:00
|
|
|
|
2003-12-20 12:03:35 +00:00
|
|
|
if (summary.dfilter) {
|
|
|
|
double seconds;
|
2003-09-02 22:10:32 +00:00
|
|
|
|
2003-12-20 12:03:35 +00:00
|
|
|
/* Display filter */
|
2004-02-01 13:13:33 +00:00
|
|
|
/* limit each row to some reasonable length */
|
|
|
|
str_dup = g_strdup_printf("Display filter: %s", summary.dfilter);
|
|
|
|
str_work = g_strdup(str_dup);
|
|
|
|
offset = 0;
|
|
|
|
while(strlen(str_work) > 100) {
|
|
|
|
str_work[100] = '\0';
|
|
|
|
add_string_to_box(str_work, filter_box);
|
|
|
|
g_free(str_work);
|
|
|
|
offset+=100;
|
|
|
|
str_work = g_strdup(&str_dup[offset]);
|
|
|
|
}
|
|
|
|
|
|
|
|
add_string_to_box(str_work, filter_box);
|
|
|
|
g_free(str_work);
|
|
|
|
g_free(str_dup);
|
2003-09-02 22:10:32 +00:00
|
|
|
|
|
|
|
/* seconds */
|
2003-12-20 12:03:35 +00:00
|
|
|
seconds = (summary.filtered_stop - summary.filtered_start);
|
2003-09-02 22:10:32 +00:00
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Between first and last packet: %.3f seconds", seconds);
|
|
|
|
add_string_to_box(string_buff, filter_box);
|
|
|
|
|
|
|
|
/* Packet count */
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Packet count: %i", summary.filtered_count);
|
|
|
|
add_string_to_box(string_buff, filter_box);
|
|
|
|
|
|
|
|
/* Packets per second */
|
|
|
|
if (seconds > 0){
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Avg. packets/sec: %.3f", summary.filtered_count/seconds);
|
|
|
|
add_string_to_box(string_buff, filter_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Packet size */
|
2003-12-21 22:32:07 +00:00
|
|
|
if (summary.filtered_count > 0){
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Avg. packet size: %.3f bytes",
|
|
|
|
(float) summary.filtered_bytes/summary.filtered_count);
|
|
|
|
add_string_to_box(string_buff, filter_box);
|
|
|
|
}
|
2003-09-02 22:10:32 +00:00
|
|
|
|
|
|
|
/* Byte count */
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Bytes of traffic: %d", summary.filtered_bytes);
|
|
|
|
add_string_to_box(string_buff, filter_box);
|
|
|
|
|
|
|
|
/* Bytes per second */
|
|
|
|
if (seconds > 0){
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Avg. bytes/sec: %.3f", summary.filtered_bytes/seconds);
|
|
|
|
add_string_to_box(string_buff, filter_box);
|
|
|
|
|
|
|
|
/* MBit per second */
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Avg. Mbit/sec: %.3f",
|
|
|
|
summary.filtered_bytes * 8.0 / (seconds * 1000.0 * 1000.0));
|
|
|
|
add_string_to_box(string_buff, filter_box);
|
|
|
|
}
|
2003-12-20 12:03:35 +00:00
|
|
|
} else {
|
|
|
|
/* Display filter */
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Display filter: none");
|
|
|
|
add_string_to_box(string_buff, filter_box);
|
2003-09-02 22:10:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Capture Frame */
|
1999-12-10 04:21:04 +00:00
|
|
|
capture_fr = gtk_frame_new("Capture");
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), capture_fr);
|
|
|
|
gtk_widget_show(capture_fr);
|
|
|
|
|
|
|
|
capture_box = gtk_vbox_new(FALSE, 3);
|
2004-02-01 15:33:08 +00:00
|
|
|
gtk_container_border_width(GTK_CONTAINER(capture_box), 5);
|
1999-12-10 04:21:04 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(capture_fr), capture_box);
|
|
|
|
gtk_widget_show(capture_box);
|
|
|
|
|
|
|
|
/* interface */
|
|
|
|
if (summary.iface) {
|
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Interface: %s", summary.iface);
|
|
|
|
} else {
|
|
|
|
sprintf(string_buff, "Interface: unknown");
|
|
|
|
}
|
|
|
|
add_string_to_box(string_buff, capture_box);
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
/* Capture filter */
|
2000-04-13 09:17:09 +00:00
|
|
|
if (summary.cfilter && summary.cfilter[0] != '\0') {
|
1999-12-10 04:21:04 +00:00
|
|
|
snprintf(string_buff, SUM_STR_MAX, "Capture filter: %s", summary.cfilter);
|
|
|
|
} else {
|
|
|
|
sprintf(string_buff, "Capture filter: none");
|
|
|
|
}
|
|
|
|
add_string_to_box(string_buff, capture_box);
|
|
|
|
#endif
|
|
|
|
|
2004-01-21 21:19:34 +00:00
|
|
|
/* Button row. */
|
|
|
|
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
|
2000-07-05 06:19:27 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(main_vb), bbox);
|
|
|
|
gtk_widget_show(bbox);
|
|
|
|
|
2004-01-21 21:19:34 +00:00
|
|
|
close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
|
2002-11-11 15:39:06 +00:00
|
|
|
SIGNAL_CONNECT_OBJECT(close_bt, "clicked", gtk_widget_destroy, sum_open_w);
|
2000-05-03 07:44:12 +00:00
|
|
|
gtk_widget_grab_default(close_bt);
|
|
|
|
|
|
|
|
/* Catch the "key_press_event" signal in the window, so that we can catch
|
|
|
|
the ESC key being pressed and act as if the "Close" button had
|
|
|
|
been selected. */
|
|
|
|
dlg_set_cancel(sum_open_w, close_bt);
|
1999-12-10 04:21:04 +00:00
|
|
|
|
|
|
|
gtk_window_set_position(GTK_WINDOW(sum_open_w), GTK_WIN_POS_MOUSE);
|
|
|
|
gtk_widget_show(sum_open_w);
|
|
|
|
}
|