1999-12-10 04:21:04 +00:00
|
|
|
/* summary_dlg.c
|
|
|
|
* Routines for capture file summary window
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
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
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
1999-12-10 04:21:04 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 01:48:30 +00:00
|
|
|
#include "config.h"
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2004-02-02 22:51:30 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
1999-12-10 04:21:04 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
|
2008-04-13 03:32:24 +00:00
|
|
|
|
2017-09-26 14:04:56 +00:00
|
|
|
#include <version_info.h>
|
2014-06-22 01:02:27 +00:00
|
|
|
|
2016-02-18 12:06:13 +00:00
|
|
|
#include "../../file.h"
|
|
|
|
#include "../../summary.h"
|
2012-12-26 12:29:43 +00:00
|
|
|
|
2005-02-06 21:20:35 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2014-06-30 05:38:29 +00:00
|
|
|
#include "ui/capture.h"
|
2012-08-03 23:30:47 +00:00
|
|
|
#include "ui/capture_globals.h"
|
2005-02-06 21:20:35 +00:00
|
|
|
#endif
|
2012-10-01 19:11:14 +00:00
|
|
|
#include "ui/main_statusbar.h"
|
2012-06-04 03:09:54 +00:00
|
|
|
#include "ui/gtk/main.h"
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/summary_dlg.h"
|
|
|
|
#include "ui/gtk/dlg_utils.h"
|
|
|
|
#include "ui/gtk/gui_utils.h"
|
|
|
|
#include "ui/gtk/help_dlg.h"
|
2012-12-26 12:29:43 +00:00
|
|
|
#include "ui/gtk/packet_list.h"
|
2008-04-13 03:32:24 +00:00
|
|
|
|
2013-01-16 17:09:22 +00:00
|
|
|
#define SUM_STR_MAX 1024
|
|
|
|
#define FILTER_SNIP_LEN 50
|
|
|
|
#define SHB_STR_SNIP_LEN 50
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2012-05-24 21:33:25 +00:00
|
|
|
static GtkWidget *summary_dlg = NULL;
|
2012-12-26 12:29:43 +00:00
|
|
|
static GtkWidget *view_capture_and_pkt_comments_dlg = NULL;
|
|
|
|
|
1999-12-10 04:21:04 +00:00
|
|
|
|
|
|
|
static void
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid_sensitive(GtkWidget *grid, guint *row, const gchar *title, const gchar *value, gboolean sensitive)
|
1999-12-10 04:21:04 +00:00
|
|
|
{
|
2004-05-20 23:01:53 +00:00
|
|
|
GtkWidget *label;
|
|
|
|
gchar *indent;
|
|
|
|
|
|
|
|
if(strlen(value) != 0) {
|
|
|
|
indent = g_strdup_printf(" %s", title);
|
|
|
|
} else {
|
|
|
|
indent = g_strdup(title);
|
|
|
|
}
|
|
|
|
label = gtk_label_new(indent);
|
2009-02-23 17:28:31 +00:00
|
|
|
if (strlen(value) == 0) {
|
|
|
|
gchar *message = g_strdup_printf("<span weight=\"bold\">%s</span>", title);
|
|
|
|
gtk_label_set_markup(GTK_LABEL(label), message);
|
|
|
|
g_free (message);
|
|
|
|
}
|
2004-05-20 23:01:53 +00:00
|
|
|
g_free(indent);
|
2009-04-21 16:57:52 +00:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
|
2004-05-20 23:01:53 +00:00
|
|
|
gtk_widget_set_sensitive(label, sensitive);
|
2013-01-16 17:09:22 +00:00
|
|
|
ws_gtk_grid_attach_defaults(GTK_GRID(grid), label, 0, *row, 1, 1);
|
2004-05-20 23:01:53 +00:00
|
|
|
|
|
|
|
label = gtk_label_new(value);
|
2013-11-12 20:47:03 +00:00
|
|
|
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
2009-04-21 16:57:52 +00:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
|
2004-05-20 23:01:53 +00:00
|
|
|
gtk_widget_set_sensitive(label, sensitive);
|
2013-01-16 17:09:22 +00:00
|
|
|
ws_gtk_grid_attach_defaults(GTK_GRID(grid), label, 1, *row, 1, 1);
|
2004-05-20 23:01:53 +00:00
|
|
|
|
|
|
|
*row = *row + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(GtkWidget *grid, guint *row, const gchar *title, const gchar *value)
|
2004-05-20 23:01:53 +00:00
|
|
|
{
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid_sensitive(grid, row, title, value, TRUE);
|
1999-12-10 04:21:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-20 23:01:53 +00:00
|
|
|
static void
|
2012-09-30 18:28:04 +00:00
|
|
|
add_string_to_list(GtkWidget *list, const gchar *title, gchar *captured,
|
|
|
|
gchar *displayed, gchar *pct_displayed, gchar *marked,
|
|
|
|
gchar *pct_marked)
|
2004-05-20 23:01:53 +00:00
|
|
|
{
|
2012-09-30 18:28:04 +00:00
|
|
|
simple_list_append(list,
|
|
|
|
0, title,
|
|
|
|
1, captured,
|
|
|
|
2, displayed,
|
|
|
|
3, pct_displayed,
|
|
|
|
4, marked,
|
|
|
|
5, pct_marked,
|
|
|
|
-1);
|
2004-05-20 23:01:53 +00:00
|
|
|
}
|
|
|
|
|
2011-11-16 03:13:02 +00:00
|
|
|
static void
|
|
|
|
time_to_string(char *string_buff, gulong string_buff_size, time_t ti_time)
|
|
|
|
{
|
|
|
|
struct tm *ti_tm;
|
|
|
|
|
|
|
|
ti_tm = localtime(&ti_time);
|
|
|
|
if (ti_tm == NULL) {
|
|
|
|
g_snprintf(string_buff, string_buff_size, "Not representable");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
g_snprintf(string_buff, string_buff_size,
|
|
|
|
"%04d-%02d-%02d %02d:%02d:%02d",
|
|
|
|
ti_tm->tm_year + 1900,
|
|
|
|
ti_tm->tm_mon + 1,
|
|
|
|
ti_tm->tm_mday,
|
|
|
|
ti_tm->tm_hour,
|
|
|
|
ti_tm->tm_min,
|
|
|
|
ti_tm->tm_sec);
|
|
|
|
}
|
|
|
|
|
2012-02-26 17:04:28 +00:00
|
|
|
static void
|
2012-05-24 21:33:25 +00:00
|
|
|
summary_ok_cb(GtkWidget *w _U_, GtkWidget *view)
|
2012-02-26 17:04:28 +00:00
|
|
|
{
|
|
|
|
GtkTextBuffer *buffer;
|
|
|
|
GtkTextIter start_iter;
|
|
|
|
GtkTextIter end_iter;
|
|
|
|
gchar *new_comment = NULL;
|
|
|
|
|
2014-06-19 21:42:37 +00:00
|
|
|
if (view != NULL && cfile.filename != NULL) {
|
2013-04-02 20:19:54 +00:00
|
|
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
|
|
|
gtk_text_buffer_get_start_iter (buffer, &start_iter);
|
|
|
|
gtk_text_buffer_get_end_iter (buffer, &end_iter);
|
2012-02-26 17:04:28 +00:00
|
|
|
|
2013-04-02 20:19:54 +00:00
|
|
|
new_comment = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE /* whether to include invisible text */);
|
2012-02-26 17:04:28 +00:00
|
|
|
|
2017-07-17 03:37:32 +00:00
|
|
|
cf_update_section_comment(&cfile, new_comment);
|
2012-02-26 17:04:28 +00:00
|
|
|
|
2013-04-02 20:19:54 +00:00
|
|
|
/* Update the main window */
|
|
|
|
main_update_for_unsaved_changes(&cfile);
|
2012-05-24 21:33:25 +00:00
|
|
|
|
2013-04-02 20:19:54 +00:00
|
|
|
status_capture_comment_update();
|
|
|
|
}
|
2012-10-01 19:11:14 +00:00
|
|
|
|
2012-05-24 21:33:25 +00:00
|
|
|
window_destroy(summary_dlg);
|
2012-02-26 17:04:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-24 21:33:25 +00:00
|
|
|
summary_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
2012-02-26 17:04:28 +00:00
|
|
|
{
|
2012-05-24 21:33:25 +00:00
|
|
|
/* Note that we no longer have a Summary dialog box. */
|
|
|
|
summary_dlg = NULL;
|
2012-02-26 17:04:28 +00:00
|
|
|
}
|
|
|
|
|
1999-12-10 04:21:04 +00:00
|
|
|
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
|
|
|
{
|
2013-01-16 17:09:22 +00:00
|
|
|
summary_tally summary;
|
|
|
|
GtkWidget *main_vb, *bbox, *cancel_bt, *ok_bt, *help_bt;
|
|
|
|
GtkWidget *grid, *scrolled_window;
|
|
|
|
GtkWidget *list, *treeview;
|
2013-04-02 20:19:54 +00:00
|
|
|
GtkWidget *comment_view = NULL, *comment_frame, *comment_vbox;
|
2013-01-16 17:09:22 +00:00
|
|
|
GtkTextBuffer *buffer = NULL;
|
|
|
|
GtkListStore *store;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkCellRenderer *renderer;
|
2011-07-05 20:34:03 +00:00
|
|
|
GtkTreeViewColumn *column;
|
2012-09-30 18:28:04 +00:00
|
|
|
static const char *titles[] = {
|
|
|
|
"Traffic", "Captured", "Displayed", "Displayed %", "Marked", "Marked %" };
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2004-02-01 13:13:33 +00:00
|
|
|
gchar string_buff[SUM_STR_MAX];
|
2007-11-30 13:28:12 +00:00
|
|
|
gchar string_buff2[SUM_STR_MAX];
|
|
|
|
gchar string_buff3[SUM_STR_MAX];
|
2011-07-05 20:34:03 +00:00
|
|
|
gchar string_buff4[SUM_STR_MAX];
|
|
|
|
gchar string_buff5[SUM_STR_MAX];
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2004-02-01 13:13:33 +00:00
|
|
|
double seconds;
|
2004-05-20 23:01:53 +00:00
|
|
|
double disp_seconds;
|
2007-11-28 01:09:02 +00:00
|
|
|
double marked_seconds;
|
2004-05-20 23:01:53 +00:00
|
|
|
guint row;
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2004-06-18 20:23:10 +00:00
|
|
|
unsigned int elapsed_time;
|
2011-07-05 20:34:03 +00:00
|
|
|
iface_options iface;
|
2016-07-14 23:01:57 +00:00
|
|
|
wtap_block_t shb_inf;
|
2011-07-05 20:34:03 +00:00
|
|
|
unsigned int i;
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2012-05-24 21:33:25 +00:00
|
|
|
if (summary_dlg != NULL) {
|
|
|
|
/* There's already a Summary dialog box; reactivate it. */
|
|
|
|
reactivate_window(summary_dlg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-02-01 13:13:33 +00:00
|
|
|
/* initial computations */
|
2005-02-04 19:29:27 +00:00
|
|
|
summary_fill_in(&cfile, &summary);
|
2005-02-06 21:20:35 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2012-02-23 15:40:31 +00:00
|
|
|
summary_fill_in_capture(&cfile, &global_capture_opts, &summary);
|
2005-02-06 21:20:35 +00:00
|
|
|
#endif
|
2012-02-26 08:02:02 +00:00
|
|
|
/*
|
|
|
|
* Note: the start and stop times are initialized to 0, so if we
|
|
|
|
* have zero or one packets of the type in question that have
|
|
|
|
* time stamps, the elapsed times will be zero, just as if we
|
|
|
|
* have both start and stop time stamps but they're the same.
|
|
|
|
* That means we can avoid some checks for whether we have more
|
|
|
|
* than one packet of the type in question with time stamps.
|
|
|
|
*/
|
1999-12-10 04:21:04 +00:00
|
|
|
seconds = summary.stop_time - summary.start_time;
|
2004-05-20 23:01:53 +00:00
|
|
|
disp_seconds = summary.filtered_stop - summary.filtered_start;
|
2007-11-28 01:09:02 +00:00
|
|
|
marked_seconds = summary.marked_stop - summary.marked_start;
|
2004-05-20 23:01:53 +00:00
|
|
|
|
2012-05-24 21:33:25 +00:00
|
|
|
summary_dlg = window_new(GTK_WINDOW_TOPLEVEL, "Wireshark: Summary");
|
2012-12-29 19:07:48 +00:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(summary_dlg), 400, 750);
|
|
|
|
|
|
|
|
/* Scrolled Window to hold them all */
|
|
|
|
scrolled_window = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_container_add(GTK_CONTAINER(summary_dlg), scrolled_window);
|
1999-12-10 04:21:04 +00:00
|
|
|
|
|
|
|
/* Container for each row of widgets */
|
2012-04-21 16:40:14 +00:00
|
|
|
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 12, FALSE);
|
2008-06-29 15:51:43 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 12);
|
2013-03-04 19:20:39 +00:00
|
|
|
#if ! GTK_CHECK_VERSION(3,8,0)
|
2012-12-29 19:07:48 +00:00
|
|
|
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), main_vb);
|
2013-03-04 19:20:39 +00:00
|
|
|
#else
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrolled_window), main_vb);
|
|
|
|
#endif
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2013-01-16 17:09:22 +00:00
|
|
|
/* grid */
|
|
|
|
grid = ws_gtk_grid_new();
|
|
|
|
ws_gtk_grid_set_column_spacing(GTK_GRID(grid), 6);
|
|
|
|
ws_gtk_grid_set_row_spacing(GTK_GRID(grid), 3);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), grid, TRUE, TRUE, 0);
|
2004-05-20 23:01:53 +00:00
|
|
|
row = 0;
|
|
|
|
|
|
|
|
/* File */
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "File", "");
|
1999-12-10 04:21:04 +00:00
|
|
|
|
|
|
|
/* filename */
|
2004-05-20 23:01:53 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "%s", summary.filename);
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "Name:", string_buff);
|
1999-12-10 04:21:04 +00:00
|
|
|
|
|
|
|
/* length */
|
2012-05-24 15:16:18 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "%" G_GINT64_MODIFIER "d bytes",
|
|
|
|
summary.file_length);
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "Length:", string_buff);
|
2004-05-20 23:01:53 +00:00
|
|
|
|
1999-12-10 04:21:04 +00:00
|
|
|
/* format */
|
2012-05-24 05:05:29 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "%s%s",
|
2013-11-08 09:53:01 +00:00
|
|
|
wtap_file_type_subtype_string(summary.file_type),
|
2012-05-24 05:05:29 +00:00
|
|
|
summary.iscompressed? " (gzip compressed)" : "");
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "Format:", string_buff);
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2008-10-14 22:55:16 +00:00
|
|
|
/* encapsulation */
|
2012-06-15 23:54:05 +00:00
|
|
|
if (summary.file_encap_type == WTAP_ENCAP_PER_PACKET) {
|
|
|
|
for (i = 0; i < summary.packet_encap_types->len; i++) {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "%s",
|
|
|
|
wtap_encap_string(g_array_index(summary.packet_encap_types, int, i)));
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, (i == 0) ? "Encapsulation:" : "",
|
2012-06-15 23:54:05 +00:00
|
|
|
string_buff);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "%s", wtap_encap_string(summary.file_encap_type));
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "Encapsulation:", string_buff);
|
2012-06-15 23:54:05 +00:00
|
|
|
}
|
Allow bigger snapshot lengths for D-Bus captures.
Use WTAP_MAX_PACKET_SIZE_STANDARD, set to 256KB, for everything except
for D-Bus captures. Use WTAP_MAX_PACKET_SIZE_DBUS, set to 128MB, for
them, because that's the largest possible D-Bus message size. See
https://bugs.freedesktop.org/show_bug.cgi?id=100220
for an example of the problems caused by limiting the snapshot length to
256KB for D-Bus.
Have a snapshot length of 0 in a capture_file structure mean "there is
no snapshot length for the file"; we don't need the has_snap field in
that case, a value of 0 mean "no, we don't have a snapshot length".
In dumpcap, start out with a pipe buffer size of 2KB, and grow it as
necessary. When checking for a too-big packet from a pipe, check
against the appropriate maximum - 128MB for DLT_DBUS, 256KB for
everything else.
Change-Id: Ib2ce7a0cf37b971fbc0318024fd011e18add8b20
Reviewed-on: https://code.wireshark.org/review/21952
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-05 01:58:40 +00:00
|
|
|
if (summary.snap != 0) {
|
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
|
|
|
/* snapshot length */
|
2004-05-20 23:01:53 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "%u bytes", summary.snap);
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "Packet size limit:", string_buff);
|
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
|
|
|
}
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2017-12-08 03:31:43 +00:00
|
|
|
shb_inf = wtap_file_get_shb(cfile.provider.wth);
|
2016-06-06 00:21:23 +00:00
|
|
|
|
2012-05-24 21:33:25 +00:00
|
|
|
/* Capture file comment area */
|
2013-04-02 20:01:10 +00:00
|
|
|
if (wtap_dump_can_write(cfile.linktypes, WTAP_COMMENT_PER_SECTION)) {
|
|
|
|
comment_frame = gtk_frame_new("Capture file comments");
|
|
|
|
gtk_frame_set_shadow_type(GTK_FRAME(comment_frame), GTK_SHADOW_ETCHED_IN);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), comment_frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(comment_frame);
|
|
|
|
|
|
|
|
comment_vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
|
|
|
gtk_container_add(GTK_CONTAINER(comment_frame), comment_vbox);
|
|
|
|
gtk_widget_show(comment_vbox);
|
|
|
|
|
|
|
|
comment_view = gtk_text_view_new();
|
|
|
|
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(comment_view), GTK_WRAP_WORD);
|
|
|
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (comment_view));
|
2016-06-06 00:21:23 +00:00
|
|
|
gtk_text_buffer_set_text (buffer, "", -1);
|
|
|
|
if (shb_inf != NULL) {
|
2016-07-14 23:01:57 +00:00
|
|
|
char *opt_comment;
|
|
|
|
|
|
|
|
/* XXX - this only shows the last comment */
|
|
|
|
for (i = 0; wtap_block_get_nth_string_option_value(shb_inf, OPT_COMMENT, i, &opt_comment) == WTAP_OPTTYPE_SUCCESS; i++) {
|
2016-07-21 00:27:36 +00:00
|
|
|
if (opt_comment[0] != '\0')
|
2016-06-06 01:04:23 +00:00
|
|
|
gtk_text_buffer_set_text (buffer, opt_comment, -1);
|
|
|
|
}
|
2013-04-02 20:01:10 +00:00
|
|
|
}
|
|
|
|
gtk_box_pack_start(GTK_BOX(comment_vbox), comment_view, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (comment_view);
|
2012-05-24 21:33:25 +00:00
|
|
|
}
|
2012-02-26 10:20:40 +00:00
|
|
|
|
2012-02-26 08:02:02 +00:00
|
|
|
/*
|
|
|
|
* We must have no un-time-stamped packets (i.e., the number of
|
|
|
|
* time-stamped packets must be the same as the number of packets),
|
|
|
|
* and at least one time-stamped packet, in order for the start
|
|
|
|
* and stop times to be valid.
|
|
|
|
*/
|
|
|
|
if (summary.packet_count_ts == summary.packet_count &&
|
|
|
|
summary.packet_count >= 1) {
|
|
|
|
/* Time */
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "", "");
|
|
|
|
add_string_to_grid(grid, &row, "Time", "");
|
2012-02-26 08:02:02 +00:00
|
|
|
|
|
|
|
/* start time */
|
|
|
|
time_to_string(string_buff, SUM_STR_MAX, (time_t)summary.start_time);
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "First packet:", string_buff);
|
2012-02-26 08:02:02 +00:00
|
|
|
|
|
|
|
/* stop time */
|
|
|
|
time_to_string(string_buff, SUM_STR_MAX, (time_t)summary.stop_time);
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "Last packet:", string_buff);
|
2012-02-26 08:02:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We must have at least two time-stamped packets for the elapsed time
|
|
|
|
* to be valid.
|
|
|
|
*/
|
|
|
|
if (summary.packet_count_ts >= 2) {
|
|
|
|
/* elapsed seconds */
|
|
|
|
elapsed_time = (unsigned int)summary.elapsed_time;
|
|
|
|
if(elapsed_time/86400) {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "%02u days %02u:%02u:%02u",
|
|
|
|
elapsed_time/86400, elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
|
|
|
|
} else {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "%02u:%02u:%02u",
|
|
|
|
elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
|
|
|
|
}
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "Elapsed:", string_buff);
|
2012-02-26 08:02:02 +00:00
|
|
|
}
|
2004-06-18 14:11:09 +00:00
|
|
|
}
|
|
|
|
|
2004-05-20 23:01:53 +00:00
|
|
|
/* Capture */
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "", "");
|
|
|
|
add_string_to_grid_sensitive(grid, &row, "Capture", "", (summary.ifaces->len > 0));
|
2016-06-06 00:21:23 +00:00
|
|
|
if (shb_inf != NULL) {
|
|
|
|
char *str;
|
|
|
|
|
2016-07-14 23:01:57 +00:00
|
|
|
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_HARDWARE, &str) == WTAP_OPTTYPE_SUCCESS &&
|
2016-07-21 00:27:36 +00:00
|
|
|
str[0] != '\0') {
|
2016-06-06 00:21:23 +00:00
|
|
|
g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s", str);
|
|
|
|
add_string_to_grid(grid, &row, "Capture HW:",string_buff);
|
|
|
|
}
|
|
|
|
|
2016-07-14 23:01:57 +00:00
|
|
|
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_OS, &str) == WTAP_OPTTYPE_SUCCESS &&
|
2016-07-21 00:27:36 +00:00
|
|
|
str[0] != '\0') {
|
2016-06-06 00:21:23 +00:00
|
|
|
/* truncate the strings to a reasonable length */
|
|
|
|
g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s", str);
|
|
|
|
add_string_to_grid(grid, &row, "OS:", string_buff);
|
|
|
|
}
|
|
|
|
|
2016-07-14 23:01:57 +00:00
|
|
|
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_USERAPPL, &str) == WTAP_OPTTYPE_SUCCESS &&
|
2016-07-21 00:27:36 +00:00
|
|
|
str[0] != '\0') {
|
2016-06-06 00:21:23 +00:00
|
|
|
/* truncate the strings to a reasonable length */
|
|
|
|
g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s", str);
|
|
|
|
add_string_to_grid(grid, &row, "Capture application:", string_buff);
|
|
|
|
}
|
2012-02-23 21:29:13 +00:00
|
|
|
}
|
2011-07-05 20:34:03 +00:00
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 5);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_widget_set_size_request(scrolled_window, -1, 120);
|
|
|
|
|
|
|
|
treeview = gtk_tree_view_new();
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes("Interface", renderer, "text", 0, NULL);
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes("Dropped Packets", renderer, "text", 1, NULL);
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes("Capture Filter", renderer, "text", 2, NULL);
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes("Link type", renderer, "text", 3, NULL);
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes("Packet size limit", renderer, "text", 4, NULL);
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
|
2012-03-07 22:19:06 +00:00
|
|
|
|
2011-07-05 20:34:03 +00:00
|
|
|
store = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
|
|
|
|
for (i = 0; i < summary.ifaces->len; i++) {
|
|
|
|
iface = g_array_index(summary.ifaces, iface_options, i);
|
|
|
|
/* interface */
|
|
|
|
if (iface.descr) {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "%s", iface.descr);
|
|
|
|
} else if (iface.name) {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "%s", iface.name);
|
2004-06-18 14:11:09 +00:00
|
|
|
} else {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "unknown");
|
|
|
|
}
|
2011-07-05 20:34:03 +00:00
|
|
|
/* Dropped count */
|
|
|
|
if (iface.drops_known) {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(string_buff2, SUM_STR_MAX, "%" G_GINT64_MODIFIER "u (%.3f%%)",
|
|
|
|
iface.drops, summary.packet_count ? (100.0 * iface.drops)/summary.packet_count : 0.0);
|
2011-07-05 20:34:03 +00:00
|
|
|
} else {
|
|
|
|
g_snprintf(string_buff2, SUM_STR_MAX, "unknown");
|
|
|
|
}
|
|
|
|
/* Capture filter */
|
|
|
|
if (iface.cfilter && iface.cfilter[0] != '\0') {
|
|
|
|
g_snprintf(string_buff3, SUM_STR_MAX, "%s", iface.cfilter);
|
|
|
|
} else {
|
2011-07-05 21:11:24 +00:00
|
|
|
if (iface.name) {
|
2011-07-05 20:34:03 +00:00
|
|
|
g_snprintf(string_buff3, SUM_STR_MAX, "none");
|
|
|
|
} else {
|
|
|
|
g_snprintf(string_buff3, SUM_STR_MAX, "unknown");
|
|
|
|
}
|
|
|
|
}
|
2012-05-28 00:31:27 +00:00
|
|
|
g_snprintf(string_buff4, SUM_STR_MAX, "%s", wtap_encap_string(iface.encap_type));
|
2012-03-10 09:01:48 +00:00
|
|
|
g_snprintf(string_buff5, SUM_STR_MAX, "%u bytes", iface.snap);
|
2011-07-05 20:34:03 +00:00
|
|
|
gtk_list_store_append(store, &iter);
|
|
|
|
gtk_list_store_set(store, &iter, 0, string_buff, 1, string_buff2, 2, string_buff3, 3, string_buff4, 4, string_buff5,-1);
|
|
|
|
}
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(store));
|
|
|
|
g_object_unref (store);
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrolled_window), treeview);
|
2012-07-20 21:35:45 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), scrolled_window, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show_all(scrolled_window);
|
2013-01-16 17:09:22 +00:00
|
|
|
grid = ws_gtk_grid_new();
|
|
|
|
ws_gtk_grid_set_column_spacing(GTK_GRID(grid), 6);
|
|
|
|
ws_gtk_grid_set_row_spacing(GTK_GRID(grid), 3);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), grid, TRUE, TRUE, 0);
|
2011-07-05 20:34:03 +00:00
|
|
|
row = 0;
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2003-09-02 22:10:32 +00:00
|
|
|
|
2004-05-20 23:01:53 +00:00
|
|
|
/* Data */
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "", "");
|
|
|
|
add_string_to_grid(grid, &row, "Display", "");
|
2003-09-02 22:10:32 +00:00
|
|
|
|
2003-12-20 12:03:35 +00:00
|
|
|
if (summary.dfilter) {
|
|
|
|
/* Display filter */
|
2013-11-12 20:47:03 +00:00
|
|
|
add_string_to_grid(grid, &row, "Display filter:", summary.dfilter);
|
2004-05-20 23:01:53 +00:00
|
|
|
} else {
|
|
|
|
/* Display filter */
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "Display filter:", "none");
|
2004-05-20 23:01:53 +00:00
|
|
|
}
|
2003-09-02 22:10:32 +00:00
|
|
|
|
2009-12-17 12:05:13 +00:00
|
|
|
/* Ignored packet count */
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "%i (%.3f%%)", summary.ignored_count,
|
|
|
|
summary.packet_count ? (100.0 * summary.ignored_count)/summary.packet_count : 0.0);
|
2013-01-16 17:09:22 +00:00
|
|
|
add_string_to_grid(grid, &row, "Ignored packets:", string_buff);
|
2009-12-17 12:05:13 +00:00
|
|
|
|
2004-05-20 23:01:53 +00:00
|
|
|
/* Traffic */
|
2012-09-30 18:28:04 +00:00
|
|
|
list = simple_list_new(6, titles);
|
2012-07-20 21:35:45 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), list, TRUE, TRUE, 0);
|
2003-09-02 22:10:32 +00:00
|
|
|
|
2012-09-30 18:28:04 +00:00
|
|
|
#define cap_buf string_buff
|
|
|
|
#define disp_buf string_buff2
|
|
|
|
#define disp_pct_buf string_buff3
|
|
|
|
#define mark_buf string_buff4
|
|
|
|
#define mark_pct_buf string_buff5
|
|
|
|
|
2007-11-30 13:28:12 +00:00
|
|
|
/* Packet count */
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(cap_buf, SUM_STR_MAX, "%i", summary.packet_count);
|
2007-11-28 01:09:02 +00:00
|
|
|
if (summary.dfilter) {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(disp_buf, SUM_STR_MAX, "%i", summary.filtered_count);
|
|
|
|
g_snprintf(disp_pct_buf, SUM_STR_MAX, "%.3f%%", summary.packet_count ?
|
|
|
|
(100.0 * summary.filtered_count)/summary.packet_count : 0.0);
|
2004-05-20 23:01:53 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_strlcpy(disp_buf, cap_buf, SUM_STR_MAX);
|
|
|
|
g_strlcpy(disp_pct_buf, "100.000%", SUM_STR_MAX);
|
2004-05-20 23:01:53 +00:00
|
|
|
}
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(mark_buf, SUM_STR_MAX, "%i", summary.marked_count);
|
|
|
|
g_snprintf(mark_pct_buf, SUM_STR_MAX, "%.3f%%", summary.packet_count ?
|
|
|
|
(100.0 * summary.marked_count)/summary.packet_count : 0.0);
|
|
|
|
add_string_to_list(list, "Packets", cap_buf,
|
|
|
|
disp_buf, disp_pct_buf, mark_buf, mark_pct_buf);
|
2007-11-28 01:09:02 +00:00
|
|
|
|
|
|
|
/* Time between first and last */
|
2007-11-30 13:28:12 +00:00
|
|
|
if (seconds > 0) {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(cap_buf, SUM_STR_MAX, "%.3f sec", seconds);
|
2007-11-30 13:28:12 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
cap_buf[0] = '\0';
|
2007-11-28 01:09:02 +00:00
|
|
|
}
|
2007-11-30 13:28:12 +00:00
|
|
|
if (summary.dfilter && disp_seconds > 0) {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(disp_buf, SUM_STR_MAX, "%.3f sec", disp_seconds);
|
2007-11-30 13:28:12 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
disp_buf[0] = '\0';
|
2007-11-28 01:09:02 +00:00
|
|
|
}
|
2012-09-30 18:28:04 +00:00
|
|
|
disp_pct_buf[0] = '\0';
|
2007-11-30 13:28:12 +00:00
|
|
|
if (summary.marked_count && marked_seconds > 0) {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(mark_buf, SUM_STR_MAX, "%.3f sec", marked_seconds);
|
2007-11-30 13:28:12 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
mark_buf[0] = '\0';
|
|
|
|
}
|
|
|
|
mark_pct_buf[0] = '\0';
|
|
|
|
if (cap_buf[0] != '\0' || disp_buf[0] != '\0' || mark_buf[0] != '\0') {
|
|
|
|
add_string_to_list(list, "Between first and last packet", cap_buf,
|
|
|
|
disp_buf, disp_pct_buf, mark_buf, mark_pct_buf);
|
2004-05-20 23:01:53 +00:00
|
|
|
}
|
2003-09-02 22:10:32 +00:00
|
|
|
|
2012-09-30 18:28:04 +00:00
|
|
|
/* Average packets per second */
|
2007-11-28 01:09:02 +00:00
|
|
|
if (seconds > 0) {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(cap_buf, SUM_STR_MAX, "%.3f", summary.packet_count/seconds);
|
2003-12-20 12:03:35 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
cap_buf[0] = '\0';
|
2004-05-20 23:01:53 +00:00
|
|
|
}
|
2007-11-30 13:28:12 +00:00
|
|
|
if(summary.dfilter && disp_seconds > 0) {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(disp_buf, SUM_STR_MAX, "%.3f", summary.filtered_count/disp_seconds);
|
2007-11-30 13:28:12 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
disp_buf[0] = '\0';
|
2003-09-02 22:10:32 +00:00
|
|
|
}
|
2012-09-30 18:28:04 +00:00
|
|
|
disp_pct_buf[0] = '\0';
|
2007-11-30 13:28:12 +00:00
|
|
|
if(summary.marked_count && marked_seconds > 0) {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(mark_buf, SUM_STR_MAX, "%.3f", summary.marked_count/marked_seconds);
|
2007-11-30 13:28:12 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
mark_buf[0] = '\0';
|
|
|
|
}
|
|
|
|
mark_pct_buf[0] = '\0';
|
|
|
|
if (cap_buf[0] != '\0' || disp_buf[0] != '\0' || mark_buf[0] != '\0') {
|
|
|
|
add_string_to_list(list, "Avg. packets/sec", cap_buf,
|
|
|
|
disp_buf, disp_pct_buf, mark_buf, mark_pct_buf);
|
2007-11-28 01:09:02 +00:00
|
|
|
}
|
2003-09-02 22:10:32 +00:00
|
|
|
|
2012-09-30 18:28:04 +00:00
|
|
|
/* Average packet size */
|
2007-11-30 13:28:12 +00:00
|
|
|
if (summary.packet_count > 1) {
|
2014-03-15 19:58:40 +00:00
|
|
|
g_snprintf(cap_buf, SUM_STR_MAX, "%" G_GUINT64_FORMAT " bytes",
|
|
|
|
(guint64) ((double)summary.bytes/summary.packet_count + 0.5) );
|
2004-05-20 23:01:53 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
cap_buf[0] = '\0';
|
2004-05-20 23:01:53 +00:00
|
|
|
}
|
2007-11-30 13:28:12 +00:00
|
|
|
if (summary.dfilter && summary.filtered_count > 1) {
|
2014-03-15 19:58:40 +00:00
|
|
|
g_snprintf(disp_buf, SUM_STR_MAX, "%" G_GUINT64_FORMAT " bytes",
|
|
|
|
(guint64) ((double)summary.filtered_bytes/summary.filtered_count + 0.5));
|
2007-11-30 13:28:12 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
disp_buf[0] = '\0';
|
2004-05-20 23:01:53 +00:00
|
|
|
}
|
2012-09-30 18:28:04 +00:00
|
|
|
disp_pct_buf[0] = '\0';
|
2007-11-30 13:28:12 +00:00
|
|
|
if (summary.marked_count > 1) {
|
2014-03-15 19:58:40 +00:00
|
|
|
g_snprintf(mark_buf, SUM_STR_MAX, "%" G_GUINT64_FORMAT " bytes",
|
|
|
|
(guint64) ((double)summary.marked_bytes/summary.marked_count + 0.5));
|
2007-11-30 13:28:12 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
mark_buf[0] = '\0';
|
|
|
|
}
|
|
|
|
mark_pct_buf[0] = '\0';
|
|
|
|
if (cap_buf[0] != '\0' || disp_buf[0] != '\0' || mark_buf[0] != '\0') {
|
|
|
|
add_string_to_list(list, "Avg. packet size", cap_buf,
|
|
|
|
disp_buf, disp_pct_buf, mark_buf, mark_pct_buf);
|
2007-11-28 01:09:02 +00:00
|
|
|
}
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2004-05-20 23:01:53 +00:00
|
|
|
/* Byte count */
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(cap_buf, SUM_STR_MAX, "%" G_GINT64_MODIFIER "u", summary.bytes);
|
|
|
|
if (summary.dfilter) {
|
|
|
|
g_snprintf(disp_buf, SUM_STR_MAX, "%" G_GINT64_MODIFIER "u", summary.filtered_bytes);
|
|
|
|
g_snprintf(disp_pct_buf, SUM_STR_MAX, "%.3f%%", summary.bytes ?
|
|
|
|
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
|
|
|
|
(100.0 * (gint64) summary.filtered_bytes)/summary.bytes : 0.0);
|
2007-11-30 13:28:12 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_strlcpy(disp_buf, cap_buf, SUM_STR_MAX);
|
|
|
|
g_strlcpy(disp_pct_buf, "100.000%", SUM_STR_MAX);
|
2004-05-20 23:01:53 +00:00
|
|
|
}
|
2007-11-28 01:09:02 +00:00
|
|
|
if (summary.marked_count) {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(mark_buf, SUM_STR_MAX, "%" G_GINT64_MODIFIER "u", summary.marked_bytes);
|
|
|
|
g_snprintf(mark_pct_buf, SUM_STR_MAX, "%.3f%%", summary.bytes ?
|
|
|
|
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
|
|
|
|
(100.0 * (gint64) summary.marked_bytes)/summary.bytes : 0.0);
|
2007-11-30 13:28:12 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_strlcpy(mark_buf, "0", SUM_STR_MAX);
|
|
|
|
g_strlcpy(mark_pct_buf, "0.000%", SUM_STR_MAX);
|
|
|
|
}
|
|
|
|
if (cap_buf[0] != '\0' || disp_buf[0] != '\0' || mark_buf[0] != '\0') {
|
|
|
|
add_string_to_list(list, "Bytes", cap_buf,
|
|
|
|
disp_buf, disp_pct_buf, mark_buf, mark_pct_buf);
|
2007-11-28 01:09:02 +00:00
|
|
|
}
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2004-05-20 23:01:53 +00:00
|
|
|
/* Bytes per second */
|
|
|
|
if (seconds > 0){
|
2005-07-09 11:28:13 +00:00
|
|
|
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(cap_buf, SUM_STR_MAX, "%.3f", ((gint64) summary.bytes)/seconds);
|
2004-05-20 23:01:53 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
cap_buf[0] = '\0';
|
2004-05-20 23:01:53 +00:00
|
|
|
}
|
2007-11-30 13:28:12 +00:00
|
|
|
if (summary.dfilter && disp_seconds > 0) {
|
|
|
|
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(disp_buf, SUM_STR_MAX, "%.3f", ((gint64) summary.filtered_bytes)/disp_seconds);
|
2007-11-30 13:28:12 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
disp_buf[0] = '\0';
|
1999-12-10 04:21:04 +00:00
|
|
|
}
|
2012-09-30 18:28:04 +00:00
|
|
|
disp_pct_buf[0] = '\0';
|
2007-11-30 13:28:12 +00:00
|
|
|
if (summary.marked_count && marked_seconds > 0) {
|
|
|
|
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(mark_buf, SUM_STR_MAX, "%.3f", ((gint64) summary.marked_bytes)/marked_seconds);
|
2007-11-30 13:28:12 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
mark_buf[0] = '\0';
|
|
|
|
}
|
|
|
|
mark_pct_buf[0] = '\0';
|
|
|
|
if (cap_buf[0] != '\0' || disp_buf[0] != '\0' || mark_buf[0] != '\0') {
|
|
|
|
add_string_to_list(list, "Avg. bytes/sec", cap_buf,
|
|
|
|
disp_buf, disp_pct_buf, mark_buf, mark_pct_buf);
|
2007-11-28 01:09:02 +00:00
|
|
|
}
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2004-05-20 23:01:53 +00:00
|
|
|
/* MBit per second */
|
2007-11-28 01:09:02 +00:00
|
|
|
if (seconds > 0) {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(cap_buf, SUM_STR_MAX, "%.3f",
|
2012-05-24 15:16:18 +00:00
|
|
|
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
|
|
|
|
((gint64) summary.bytes) * 8.0 / (seconds * 1000.0 * 1000.0));
|
1999-12-10 04:21:04 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
cap_buf[0] = '\0';
|
1999-12-10 04:21:04 +00:00
|
|
|
}
|
2007-11-30 13:28:12 +00:00
|
|
|
if (summary.dfilter && disp_seconds > 0) {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(disp_buf, SUM_STR_MAX, "%.3f",
|
2012-05-24 15:16:18 +00:00
|
|
|
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
|
|
|
|
((gint64) summary.filtered_bytes) * 8.0 / (disp_seconds * 1000.0 * 1000.0));
|
2007-11-30 13:28:12 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
disp_buf[0] = '\0';
|
2007-11-28 01:09:02 +00:00
|
|
|
}
|
2012-09-30 18:28:04 +00:00
|
|
|
disp_pct_buf[0] = '\0';
|
2007-11-30 13:28:12 +00:00
|
|
|
if (summary.marked_count && marked_seconds > 0) {
|
2012-09-30 18:28:04 +00:00
|
|
|
g_snprintf(mark_buf, SUM_STR_MAX, "%.3f",
|
2012-05-24 15:16:18 +00:00
|
|
|
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
|
|
|
|
((gint64) summary.marked_bytes) * 8.0 / (marked_seconds * 1000.0 * 1000.0));
|
2007-11-30 13:28:12 +00:00
|
|
|
} else {
|
2012-09-30 18:28:04 +00:00
|
|
|
mark_buf[0] = '\0';
|
|
|
|
}
|
|
|
|
mark_pct_buf[0] = '\0';
|
|
|
|
if (cap_buf[0] != '\0' || disp_buf[0] != '\0' || mark_buf[0] != '\0') {
|
|
|
|
add_string_to_list(list, "Avg. MBit/sec", cap_buf,
|
|
|
|
disp_buf, disp_pct_buf, mark_buf, mark_pct_buf);
|
2004-05-20 23:01:53 +00:00
|
|
|
}
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2007-08-30 00:24:40 +00:00
|
|
|
|
2004-01-21 21:19:34 +00:00
|
|
|
/* Button row. */
|
2012-05-24 21:33:25 +00:00
|
|
|
bbox = dlg_button_row_new(GTK_STOCK_CANCEL, GTK_STOCK_OK, GTK_STOCK_HELP, NULL);
|
2012-07-20 21:35:45 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), bbox, TRUE, TRUE, 0);
|
2000-07-05 06:19:27 +00:00
|
|
|
|
2013-03-21 02:29:09 +00:00
|
|
|
cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
2012-05-24 21:33:25 +00:00
|
|
|
window_set_cancel_button(summary_dlg, cancel_bt, window_cancel_button_cb);
|
|
|
|
|
2013-03-21 02:29:09 +00:00
|
|
|
ok_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
|
2012-05-24 21:33:25 +00:00
|
|
|
g_signal_connect (ok_bt, "clicked",
|
|
|
|
G_CALLBACK(summary_ok_cb), comment_view);
|
|
|
|
gtk_widget_grab_focus(ok_bt);
|
2004-05-23 23:24:07 +00:00
|
|
|
|
2013-03-21 02:29:09 +00:00
|
|
|
help_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
2008-06-21 13:36:31 +00:00
|
|
|
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_STATS_SUMMARY_DIALOG);
|
2005-01-20 23:17:23 +00:00
|
|
|
|
2000-05-03 07:44:12 +00:00
|
|
|
|
2012-05-24 21:33:25 +00:00
|
|
|
g_signal_connect(summary_dlg, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
|
|
|
g_signal_connect(summary_dlg, "destroy", G_CALLBACK(summary_destroy_cb), NULL);
|
1999-12-10 04:21:04 +00:00
|
|
|
|
2012-05-24 21:33:25 +00:00
|
|
|
gtk_widget_show_all(summary_dlg);
|
|
|
|
window_present(summary_dlg);
|
1999-12-10 04:21:04 +00:00
|
|
|
}
|
2012-11-27 13:35:33 +00:00
|
|
|
|
|
|
|
#define INDENT " "
|
|
|
|
void
|
|
|
|
summary_to_texbuff(GtkTextBuffer *buffer)
|
|
|
|
{
|
|
|
|
summary_tally summary;
|
|
|
|
gchar string_buff[SUM_STR_MAX];
|
2013-08-07 10:02:03 +00:00
|
|
|
gchar tmp_buff[SUM_STR_MAX];
|
2016-07-14 23:01:57 +00:00
|
|
|
wtap_block_t shb_inf;
|
2012-11-27 13:35:33 +00:00
|
|
|
unsigned int i;
|
|
|
|
unsigned int elapsed_time;
|
2012-11-27 16:46:00 +00:00
|
|
|
iface_options iface;
|
2016-06-06 00:21:23 +00:00
|
|
|
double seconds;
|
2012-11-27 13:35:33 +00:00
|
|
|
|
|
|
|
/* initial computations */
|
|
|
|
summary_fill_in(&cfile, &summary);
|
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
summary_fill_in_capture(&cfile, &global_capture_opts, &summary);
|
|
|
|
#endif
|
|
|
|
|
2012-11-27 16:46:00 +00:00
|
|
|
/* Add Wireshark version*/
|
2014-06-22 01:02:27 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "Summary created by Wireshark %s\n\n", get_ws_vcs_version_info());
|
2012-11-27 16:46:00 +00:00
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
2012-11-27 13:35:33 +00:00
|
|
|
|
|
|
|
/* Info about file */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "File: \n");
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
/* Filename */
|
2013-08-07 10:02:03 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Name: %s\n", summary.filename);
|
2012-11-27 13:35:33 +00:00
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
/* length */
|
2013-08-07 10:02:03 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Length: %" G_GINT64_MODIFIER "d bytes\n",
|
2012-11-27 13:35:33 +00:00
|
|
|
summary.file_length);
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
/* format */
|
2013-08-07 10:02:03 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Format: %s%s",
|
2013-11-08 09:53:01 +00:00
|
|
|
wtap_file_type_subtype_string(summary.file_type),
|
2012-11-27 13:35:33 +00:00
|
|
|
summary.iscompressed? " (gzip compressed)\n" : "\n");
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
/* encapsulation */
|
|
|
|
if (summary.file_encap_type == WTAP_ENCAP_PER_PACKET) {
|
|
|
|
for (i = 0; i < summary.packet_encap_types->len; i++) {
|
2013-08-07 10:02:03 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Encapsulation: %s\n",
|
2012-11-27 13:35:33 +00:00
|
|
|
wtap_encap_string(g_array_index(summary.packet_encap_types, int, i)));
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
}
|
|
|
|
} else {
|
2013-08-07 10:02:03 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Encapsulation: %s\n", wtap_encap_string(summary.file_encap_type));
|
2012-11-27 13:35:33 +00:00
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
}
|
Allow bigger snapshot lengths for D-Bus captures.
Use WTAP_MAX_PACKET_SIZE_STANDARD, set to 256KB, for everything except
for D-Bus captures. Use WTAP_MAX_PACKET_SIZE_DBUS, set to 128MB, for
them, because that's the largest possible D-Bus message size. See
https://bugs.freedesktop.org/show_bug.cgi?id=100220
for an example of the problems caused by limiting the snapshot length to
256KB for D-Bus.
Have a snapshot length of 0 in a capture_file structure mean "there is
no snapshot length for the file"; we don't need the has_snap field in
that case, a value of 0 mean "no, we don't have a snapshot length".
In dumpcap, start out with a pipe buffer size of 2KB, and grow it as
necessary. When checking for a too-big packet from a pipe, check
against the appropriate maximum - 128MB for DLT_DBUS, 256KB for
everything else.
Change-Id: Ib2ce7a0cf37b971fbc0318024fd011e18add8b20
Reviewed-on: https://code.wireshark.org/review/21952
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-05 01:58:40 +00:00
|
|
|
if (summary.snap != 0) {
|
2012-11-27 13:35:33 +00:00
|
|
|
/* snapshot length */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Packet size limit: %u bytes\n", summary.snap);
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add two empty lines */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "\n\n");
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
/* Time Section */
|
|
|
|
if (summary.packet_count_ts == summary.packet_count &&
|
|
|
|
summary.packet_count >= 1) {
|
|
|
|
/* Add heading Time */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "Time:\n");
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
/* start time */
|
2013-08-07 10:02:03 +00:00
|
|
|
time_to_string(tmp_buff, SUM_STR_MAX, (time_t)summary.start_time);
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "First packet: %s\n",tmp_buff);
|
2012-11-27 13:35:33 +00:00
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
/* stop time */
|
2013-08-07 10:02:03 +00:00
|
|
|
time_to_string(tmp_buff, SUM_STR_MAX, (time_t)summary.stop_time);
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Last packet: %s\n", tmp_buff);
|
2012-11-27 13:35:33 +00:00
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We must have at least two time-stamped packets for the elapsed time
|
|
|
|
* to be valid.
|
|
|
|
*/
|
|
|
|
if (summary.packet_count_ts >= 2) {
|
|
|
|
/* elapsed seconds */
|
|
|
|
elapsed_time = (unsigned int)summary.elapsed_time;
|
|
|
|
if(elapsed_time/86400) {
|
2013-08-07 10:02:03 +00:00
|
|
|
g_snprintf(tmp_buff, SUM_STR_MAX, "%02u days %02u:%02u:%02u",
|
2012-11-27 13:35:33 +00:00
|
|
|
elapsed_time/86400, elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
|
|
|
|
} else {
|
2013-08-07 10:02:03 +00:00
|
|
|
g_snprintf(tmp_buff, SUM_STR_MAX, "%02u:%02u:%02u",
|
2012-11-27 13:35:33 +00:00
|
|
|
elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
|
|
|
|
}
|
2013-08-07 10:02:03 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Elapsed: %s\n", tmp_buff);
|
2013-01-16 17:09:22 +00:00
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
2012-11-27 13:35:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add two empty lines */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "\n\n");
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "Capture:\n");
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
2017-12-08 03:31:43 +00:00
|
|
|
shb_inf = wtap_file_get_shb(cfile.provider.wth);
|
2016-06-06 00:21:23 +00:00
|
|
|
if (shb_inf != NULL) {
|
|
|
|
char *str;
|
|
|
|
|
2016-07-14 23:01:57 +00:00
|
|
|
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_HARDWARE, &str) == WTAP_OPTTYPE_SUCCESS &&
|
2016-07-21 00:27:36 +00:00
|
|
|
str[0] != '\0') {
|
2016-06-06 00:21:23 +00:00
|
|
|
/* truncate the string to a reasonable length */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Capture HW: %s\n", str);
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
}
|
2016-07-14 23:01:57 +00:00
|
|
|
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_OS, &str) == WTAP_OPTTYPE_SUCCESS &&
|
2016-07-21 00:27:36 +00:00
|
|
|
str[0] != '\0') {
|
2016-06-06 00:21:23 +00:00
|
|
|
/* truncate the strings to a reasonable length */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "OS: %s\n", str);
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
}
|
2016-07-14 23:01:57 +00:00
|
|
|
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_USERAPPL, &str) == WTAP_OPTTYPE_SUCCESS &&
|
2016-07-21 00:27:36 +00:00
|
|
|
str[0] != '\0') {
|
2016-06-06 00:21:23 +00:00
|
|
|
/* truncate the string to a reasonable length */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Capture application: %s\n", str);
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
}
|
2012-11-27 16:46:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Add empty line */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "\n");
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
/* Interface info */
|
|
|
|
for (i = 0; i < summary.ifaces->len; i++) {
|
|
|
|
iface = g_array_index(summary.ifaces, iface_options, i);
|
|
|
|
/* interface */
|
|
|
|
if (iface.descr) {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "%s:\n", iface.descr);
|
|
|
|
} else if (iface.name) {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "%s:\n", iface.name);
|
|
|
|
} else {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Unknown interface:\n");
|
|
|
|
}
|
2013-01-16 17:09:22 +00:00
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
2012-11-27 16:46:00 +00:00
|
|
|
|
|
|
|
/* Dropped count */
|
|
|
|
if (iface.drops_known) {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT INDENT "Dropped packets: %" G_GINT64_MODIFIER "u (%.3f%%)\n",
|
|
|
|
iface.drops, summary.packet_count ? (100.0 * iface.drops)/summary.packet_count : 0.0);
|
|
|
|
} else {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT INDENT "Dropped packets: unknown\n");
|
|
|
|
}
|
2013-01-16 17:09:22 +00:00
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
2012-11-27 16:46:00 +00:00
|
|
|
|
2013-01-16 17:09:22 +00:00
|
|
|
/* Capture filter */
|
2012-11-27 16:46:00 +00:00
|
|
|
if (iface.cfilter && iface.cfilter[0] != '\0') {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT INDENT "Capture filter: %s\n", iface.cfilter);
|
|
|
|
} else {
|
|
|
|
if (iface.name) {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT INDENT "Capture filter: none\n");
|
|
|
|
} else {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT INDENT "Capture filter: unknown\n");
|
|
|
|
}
|
|
|
|
}
|
2013-01-16 17:09:22 +00:00
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
2012-11-27 16:46:00 +00:00
|
|
|
|
2013-01-16 17:09:22 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT INDENT "Link type: %s\n", wtap_encap_string(iface.encap_type));
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
2012-11-27 16:46:00 +00:00
|
|
|
|
2013-01-16 17:09:22 +00:00
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT INDENT "Packet size limit %u bytes\n", iface.snap);
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
2012-11-27 16:46:00 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add empty line */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "\n");
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
/* Statistics */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "Statistics:\n");
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
/* Packet count */
|
|
|
|
g_snprintf(cap_buf, SUM_STR_MAX, INDENT "Packets: %i\n", summary.packet_count);
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note: the start and stop times are initialized to 0, so if we
|
|
|
|
* have zero or one packets of the type in question that have
|
|
|
|
* time stamps, the elapsed times will be zero, just as if we
|
|
|
|
* have both start and stop time stamps but they're the same.
|
|
|
|
* That means we can avoid some checks for whether we have more
|
|
|
|
* than one packet of the type in question with time stamps.
|
|
|
|
*/
|
|
|
|
seconds = summary.stop_time - summary.start_time;
|
|
|
|
/* Time between first and last */
|
|
|
|
if (seconds > 0) {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Between first and last packet:%.3f sec\n", seconds);
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Average packets per second */
|
|
|
|
if (seconds > 0) {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Avg. packets/sec: %.3f\n", summary.packet_count/seconds);
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Average packet size */
|
|
|
|
if (summary.packet_count > 1) {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Avg packet size: %.3f bytes\n",
|
|
|
|
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
|
|
|
|
(float) ((gint64) summary.bytes)/summary.packet_count);
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Byte count */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Bytes: %" G_GINT64_MODIFIER "u\n", summary.bytes);
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
|
|
|
/* Bytes per second */
|
|
|
|
if (seconds > 0){
|
|
|
|
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Avg bytes/sec: %.3f\n", ((gint64) summary.bytes)/seconds);
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MBit per second */
|
|
|
|
if (seconds > 0) {
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Avg Mbit/sec: %.3f\n",
|
|
|
|
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
|
|
|
|
((gint64) summary.bytes) * 8.0 / (seconds * 1000.0 * 1000.0));
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add empty line */
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "\n");
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
2012-11-27 13:35:33 +00:00
|
|
|
/* Trace file comments from SHB */
|
2017-12-08 03:31:43 +00:00
|
|
|
shb_inf = wtap_file_get_shb(cfile.provider.wth);
|
2016-06-06 00:21:23 +00:00
|
|
|
if (shb_inf != NULL) {
|
2016-07-14 23:01:57 +00:00
|
|
|
char *opt_comment;
|
|
|
|
|
|
|
|
for (i = 0; wtap_block_get_nth_string_option_value(shb_inf, OPT_COMMENT, i, &opt_comment) == WTAP_OPTTYPE_SUCCESS; i++) {
|
2016-06-06 01:04:23 +00:00
|
|
|
/* XXX - separator between comments? */
|
2016-07-21 00:27:36 +00:00
|
|
|
if (opt_comment[0] != '\0')
|
2016-06-06 01:04:23 +00:00
|
|
|
gtk_text_buffer_insert_at_cursor(buffer, opt_comment, -1);
|
|
|
|
}
|
2012-11-27 13:35:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
g_snprintf(string_buff, SUM_STR_MAX, "\n\n");
|
|
|
|
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
|
|
|
|
2012-11-29 14:57:06 +00:00
|
|
|
}
|
2012-12-26 12:29:43 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
comment_summary_copy_to_clipboard_cb(GtkWidget *w _U_, GtkWidget *view)
|
|
|
|
{
|
|
|
|
GtkTextBuffer *buffer;
|
|
|
|
GtkTextIter start_iter, end_iter;
|
|
|
|
GtkClipboard *clipboard;
|
|
|
|
|
|
|
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
|
|
|
|
|
|
|
gtk_text_buffer_get_bounds(buffer, &start_iter, &end_iter);
|
|
|
|
|
|
|
|
gtk_text_buffer_select_range(buffer, &start_iter, &end_iter);
|
|
|
|
|
|
|
|
clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); /* Get the default clipboard */
|
|
|
|
gtk_text_buffer_copy_clipboard (buffer, clipboard);
|
|
|
|
|
|
|
|
gtk_text_buffer_select_range(buffer, &end_iter, &end_iter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
show_packet_comment_summary_dlg (GtkAction *action _U_, gpointer data _U_)
|
|
|
|
{
|
|
|
|
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *view;
|
|
|
|
GtkWidget *scroll;
|
|
|
|
GtkWidget *bbox;
|
|
|
|
GtkWidget *copy_bt, *cancel_bt, *help_bt;
|
|
|
|
GtkTextBuffer *buffer;
|
|
|
|
|
|
|
|
view_capture_and_pkt_comments_dlg = dlg_window_new ("Comments Summary");
|
|
|
|
gtk_widget_set_size_request (view_capture_and_pkt_comments_dlg, 700, 350);
|
|
|
|
gtk_window_set_resizable (GTK_WINDOW (view_capture_and_pkt_comments_dlg), TRUE);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (view_capture_and_pkt_comments_dlg), DLG_OUTER_MARGIN);
|
|
|
|
|
|
|
|
vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_UNRELATED_SPACING, FALSE);
|
|
|
|
gtk_container_add (GTK_CONTAINER (view_capture_and_pkt_comments_dlg), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
view = gtk_text_view_new ();
|
|
|
|
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
|
|
|
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
|
|
|
gtk_widget_show (view);
|
|
|
|
|
|
|
|
scroll = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
|
|
|
|
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_container_add(GTK_CONTAINER(scroll), view);
|
|
|
|
gtk_widget_show(scroll);
|
|
|
|
gtk_box_pack_start(GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
/* Add capture summary information */
|
|
|
|
summary_to_texbuff(buffer);
|
|
|
|
|
|
|
|
/* Add all packet comments */
|
|
|
|
packet_list_return_all_comments(buffer);
|
|
|
|
|
|
|
|
/* Button row. */
|
|
|
|
bbox = dlg_button_row_new (GTK_STOCK_COPY, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
|
|
|
gtk_box_pack_end (GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
|
|
|
|
2013-03-21 02:29:09 +00:00
|
|
|
copy_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_COPY);
|
2012-12-26 12:29:43 +00:00
|
|
|
g_signal_connect (copy_bt, "clicked", G_CALLBACK(comment_summary_copy_to_clipboard_cb), view);
|
|
|
|
gtk_widget_set_sensitive (copy_bt, TRUE);
|
|
|
|
|
2013-03-21 02:29:09 +00:00
|
|
|
cancel_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
2012-12-26 12:29:43 +00:00
|
|
|
window_set_cancel_button (view_capture_and_pkt_comments_dlg, cancel_bt, window_cancel_button_cb);
|
|
|
|
|
2013-03-21 02:29:09 +00:00
|
|
|
help_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_HELP);
|
2012-12-26 12:29:43 +00:00
|
|
|
#if 0
|
|
|
|
g_signal_connect (help_bt, "clicked",/* G_CALLBACK(topic_cb)*/NULL, /*(gpointer)HELP_MANUAL_ADDR_RESOLVE_DIALOG*/NULL);
|
|
|
|
#endif
|
|
|
|
gtk_widget_set_sensitive (help_bt, FALSE);
|
|
|
|
|
|
|
|
gtk_widget_grab_default (copy_bt);
|
|
|
|
|
|
|
|
|
|
|
|
gtk_widget_show (view_capture_and_pkt_comments_dlg);
|
2012-12-29 19:07:48 +00:00
|
|
|
}
|
2013-01-16 17:09:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=2 tabstop=8 expandtab:
|
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
|
|
|
*/
|