Keep track, in Wiretap, of whether the file is compressed, and provide
[metze/wireshark/wip.git] / ui / gtk / summary_dlg.c
1 /* summary_dlg.c
2  * Routines for capture file summary window
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <string.h>
30 #include <time.h>
31
32 #include <gtk/gtk.h>
33
34 #include <epan/strutil.h>
35
36 #include <wiretap/wtap.h>
37
38 #include "../globals.h"
39 #include "../file.h"
40 #include "../summary.h"
41 #include "../capture-pcap-util.h"
42 #ifdef HAVE_LIBPCAP
43 #include "../capture.h"
44 #include "ui/gtk/main.h"
45 #include "ui/gtk/capture_globals.h"
46 #endif
47
48 #include "ui/gtk/summary_dlg.h"
49 #include "ui/gtk/dlg_utils.h"
50 #include "ui/gtk/gui_utils.h"
51 #include "ui/gtk/help_dlg.h"
52 #include "ui/gtk/menus.h"
53
54 #define SUM_STR_MAX     1024
55 #define FILTER_SNIP_LEN 50
56 #define SHB_STR_SNIP_LEN 50
57
58
59 static void
60 add_string_to_table_sensitive(GtkWidget *list, guint *row, const gchar *title, const gchar *value, gboolean sensitive)
61 {
62     GtkWidget *label;
63     gchar     *indent;
64
65     if(strlen(value) != 0) {
66         indent = g_strdup_printf("   %s", title);
67     } else {
68         indent = g_strdup(title);
69     }
70     label = gtk_label_new(indent);
71     if (strlen(value) == 0) {
72       gchar *message = g_strdup_printf("<span weight=\"bold\">%s</span>", title);
73       gtk_label_set_markup(GTK_LABEL(label), message);
74       g_free (message);
75     }
76     g_free(indent);
77     gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
78     gtk_widget_set_sensitive(label, sensitive);
79     gtk_table_attach_defaults(GTK_TABLE(list), label, 0, 1, *row, *row+1);
80
81     label = gtk_label_new(value);
82     gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
83     gtk_widget_set_sensitive(label, sensitive);
84     gtk_table_attach_defaults(GTK_TABLE(list), label, 1, 2, *row, *row+1);
85
86     *row = *row + 1;
87 }
88
89 static void
90 add_string_to_table(GtkWidget *list, guint *row, const gchar *title, const gchar *value)
91 {
92     add_string_to_table_sensitive(list, row, title, value, TRUE);
93 }
94
95
96 static void
97 add_string_to_list(GtkWidget *list, const gchar *title, gchar *captured, gchar *displayed, gchar *marked)
98 {
99     simple_list_append(list, 0, title, 1, captured, 2, displayed, 3, marked, -1);
100 }
101
102 static void
103 time_to_string(char *string_buff, gulong string_buff_size, time_t ti_time)
104 {
105   struct tm *ti_tm;
106
107 #ifdef _MSC_VER
108   /* calling localtime() on MSVC 2005 with huge values causes it to crash */
109   /* XXX - find the exact value that still does work */
110   /* XXX - using _USE_32BIT_TIME_T might be another way to circumvent this problem */
111   if (ti_time > 2000000000) {
112       ti_tm = NULL;
113   } else
114 #endif
115   ti_tm = localtime(&ti_time);
116   if (ti_tm == NULL) {
117     g_snprintf(string_buff, string_buff_size, "Not representable");
118     return;
119   }
120   g_snprintf(string_buff, string_buff_size,
121              "%04d-%02d-%02d %02d:%02d:%02d",
122              ti_tm->tm_year + 1900,
123              ti_tm->tm_mon + 1,
124              ti_tm->tm_mday,
125              ti_tm->tm_hour,
126              ti_tm->tm_min,
127              ti_tm->tm_sec);
128 }
129
130 static void
131 summary_comment_text_buff_save_cb(GtkWidget *w _U_, GtkWidget *view)
132 {
133   GtkTextBuffer *buffer;
134   GtkTextIter start_iter;
135   GtkTextIter end_iter;
136   gchar *new_comment = NULL;
137
138   buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
139   gtk_text_buffer_get_start_iter (buffer, &start_iter);
140   gtk_text_buffer_get_end_iter (buffer, &end_iter);
141
142   new_comment = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE /* whether to include invisible text */);
143
144   /*g_warning("The new comment is '%s'",new_packet_comment);*/
145
146   summary_update_comment(&cfile, new_comment);
147   /* Mark the file as having unsaved changes; this causes a popup asking to save the file if we quit the file */
148   cfile.unsaved_changes = TRUE;
149   set_menus_for_capture_file(&cfile);
150
151 }
152
153 static void
154 summary_comment_text_buff_clear_cb(GtkWidget *w _U_, GtkWidget *view)
155 {
156   GtkTextBuffer *buffer;
157
158   buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
159   gtk_text_buffer_set_text (buffer, "", -1);
160
161 }
162
163 void
164 summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
165 {
166   summary_tally summary;
167   GtkWidget     *sum_open_w,
168                 *main_vb, *bbox, *close_bt, *help_bt;
169   GtkWidget     *table, *scrolled_window;
170   GtkWidget     *list, *treeview;
171   GtkListStore  *store;
172   GtkTreeIter    iter;
173   GtkCellRenderer *renderer;
174   GtkTreeViewColumn *column;
175   const char    *dl_description;
176   static const char *titles[] = { "Traffic", "Captured", "Displayed", "Marked" };
177
178   gchar         string_buff[SUM_STR_MAX];
179   gchar         string_buff2[SUM_STR_MAX];
180   gchar         string_buff3[SUM_STR_MAX];
181   gchar         string_buff4[SUM_STR_MAX];
182   gchar         string_buff5[SUM_STR_MAX];
183
184   double        seconds;
185   double        disp_seconds;
186   double        marked_seconds;
187   guint         offset;
188   guint         snip;
189   guint         row;
190   gchar        *str_dup;
191   gchar        *str_work;
192
193   unsigned int  elapsed_time;
194   iface_options iface;
195   unsigned int  i;
196
197   /* initial computations */
198   summary_fill_in(&cfile, &summary);
199 #ifdef HAVE_LIBPCAP
200   summary_fill_in_capture(&cfile, &global_capture_opts, &summary);
201 #endif
202   /*
203    * Note: the start and stop times are initialized to 0, so if we
204    * have zero or one packets of the type in question that have
205    * time stamps, the elapsed times will be zero, just as if we
206    * have both start and stop time stamps but they're the same.
207    * That means we can avoid some checks for whether we have more
208    * than one packet of the type in question with time stamps.
209    */
210   seconds = summary.stop_time - summary.start_time;
211   disp_seconds = summary.filtered_stop - summary.filtered_start;
212   marked_seconds = summary.marked_stop - summary.marked_start;
213
214   sum_open_w = window_new(GTK_WINDOW_TOPLEVEL, "Wireshark: Summary");
215
216   /* Container for each row of widgets */
217   main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 12, FALSE);
218   gtk_container_set_border_width(GTK_CONTAINER(main_vb), 12);
219   gtk_container_add(GTK_CONTAINER(sum_open_w), main_vb);
220
221   /* table */
222   table = gtk_table_new(1, 2, FALSE);
223   gtk_table_set_col_spacings(GTK_TABLE(table), 6);
224   gtk_table_set_row_spacings(GTK_TABLE(table), 3);
225   gtk_container_add(GTK_CONTAINER(main_vb), table);
226   row = 0;
227
228
229   /* File */
230   add_string_to_table(table, &row, "File", "");
231
232   /* filename */
233   g_snprintf(string_buff, SUM_STR_MAX, "%s", summary.filename);
234   add_string_to_table(table, &row, "Name:", string_buff);
235
236   /* length */
237   g_snprintf(string_buff, SUM_STR_MAX, "%" G_GINT64_MODIFIER "d bytes", summary.file_length);
238   add_string_to_table(table, &row, "Length:", string_buff);
239
240   /* format */
241   g_snprintf(string_buff, SUM_STR_MAX, "%s%s",
242              wtap_file_type_string(summary.file_type),
243              summary.iscompressed? " (gzip compressed)" : "");
244   add_string_to_table(table, &row, "Format:", string_buff);
245
246   /* encapsulation */
247   g_snprintf(string_buff, SUM_STR_MAX, "%s", wtap_encap_string(summary.encap_type));
248   add_string_to_table(table, &row, "Encapsulation:", string_buff);
249
250   if (summary.has_snap) {
251     /* snapshot length */
252     g_snprintf(string_buff, SUM_STR_MAX, "%u bytes", summary.snap);
253     add_string_to_table(table, &row, "Packet size limit:", string_buff);
254   }
255
256   /* Only allow editing of comment if filetype is PCAPNG */
257   if(summary.file_type == WTAP_FILE_PCAPNG){
258     GtkWidget *frame;
259     GtkWidget *comment_vbox;
260     GtkWidget *view;
261     GtkTextBuffer *buffer = NULL;
262     const gchar *buf_str;
263     GtkWidget *ok_bt, *clear_bt;
264
265     frame = gtk_frame_new ("Capture comments");
266     gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
267     gtk_container_add (GTK_CONTAINER (main_vb), frame);
268     gtk_widget_show (frame);
269
270     comment_vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
271     gtk_container_add (GTK_CONTAINER (frame), comment_vbox);
272     gtk_widget_show (comment_vbox);
273
274     view = gtk_text_view_new ();
275     buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
276     if(summary.opt_comment == NULL){
277       buf_str = g_strdup_printf("[None]");
278     }else{
279       buf_str = g_strdup_printf("%s", summary.opt_comment);
280     }
281     gtk_text_buffer_set_text (buffer, buf_str, -1);
282     gtk_container_add(GTK_CONTAINER(comment_vbox), view);
283     gtk_widget_show (view);
284
285     /* Button row. */
286     bbox = dlg_button_row_new (GTK_STOCK_OK, GTK_STOCK_CLEAR, NULL);
287     gtk_box_pack_end (GTK_BOX(comment_vbox), bbox, FALSE, FALSE, 0);
288
289     ok_bt = g_object_get_data (G_OBJECT(bbox), GTK_STOCK_OK);
290     g_signal_connect (ok_bt, "clicked", G_CALLBACK(summary_comment_text_buff_save_cb), view);
291     gtk_widget_set_sensitive (ok_bt, TRUE);
292     gtk_widget_set_tooltip_text(ok_bt,
293            "Updates the comment, you need to save the the capture file as well to save the updated comment");
294
295
296     clear_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLEAR);
297     g_signal_connect(clear_bt, "clicked", G_CALLBACK(summary_comment_text_buff_clear_cb), view);
298     gtk_widget_set_tooltip_text(clear_bt,
299            "Clears the text from the box, not the capture");
300
301     gtk_widget_grab_default (ok_bt);
302
303   }else{
304     if (summary.opt_comment != NULL) {
305     /* comment */
306     add_string_to_table(table, &row, "Comment:", summary.opt_comment);
307     }
308  }
309
310   /*
311    * We must have no un-time-stamped packets (i.e., the number of
312    * time-stamped packets must be the same as the number of packets),
313    * and at least one time-stamped packet, in order for the start
314    * and stop times to be valid.
315    */
316   if (summary.packet_count_ts == summary.packet_count &&
317       summary.packet_count >= 1) {
318     /* Time */
319     add_string_to_table(table, &row, "", "");
320     add_string_to_table(table, &row, "Time", "");
321
322     /* start time */
323     time_to_string(string_buff, SUM_STR_MAX, (time_t)summary.start_time);
324     add_string_to_table(table, &row, "First packet:", string_buff);
325
326     /* stop time */
327     time_to_string(string_buff, SUM_STR_MAX, (time_t)summary.stop_time);
328     add_string_to_table(table, &row, "Last packet:", string_buff);
329
330     /*
331      * We must have at least two time-stamped packets for the elapsed time
332      * to be valid.
333      */
334     if (summary.packet_count_ts >= 2) {
335       /* elapsed seconds */
336       elapsed_time = (unsigned int)summary.elapsed_time;
337       if(elapsed_time/86400) {
338           g_snprintf(string_buff, SUM_STR_MAX, "%02u days %02u:%02u:%02u",
339             elapsed_time/86400, elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
340       } else {
341           g_snprintf(string_buff, SUM_STR_MAX, "%02u:%02u:%02u",
342             elapsed_time%86400/3600, elapsed_time%3600/60, elapsed_time%60);
343       }
344       add_string_to_table(table, &row, "Elapsed:", string_buff);
345     }
346   }
347
348   /* Capture */
349   add_string_to_table(table, &row, "", "");
350   add_string_to_table_sensitive(table, &row, "Capture", "", (summary.ifaces->len > 0));
351   if(summary.shb_hardware){
352     /* trucate the string to a reasonable length */
353     g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s",summary.shb_hardware);
354     add_string_to_table(table, &row, "Capture HW:",string_buff);
355   }
356   if(summary.shb_os){
357     /* trucate the strings to a reasonable length */
358     g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s",summary.shb_os);
359     add_string_to_table(table, &row, "OS:", string_buff);
360   }
361   if(summary.shb_user_appl){
362     /* trucate the string to a reasonable length */
363     g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s",summary.shb_user_appl);
364     add_string_to_table(table, &row, "Capture application:", string_buff);
365   }
366   scrolled_window = gtk_scrolled_window_new (NULL, NULL);
367   gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 5);
368   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
369                                   GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
370   gtk_widget_set_size_request(scrolled_window, -1, 120);
371
372   treeview = gtk_tree_view_new();
373   renderer = gtk_cell_renderer_text_new();
374   column = gtk_tree_view_column_new_with_attributes("Interface", renderer, "text", 0, NULL);
375   gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
376   renderer = gtk_cell_renderer_text_new();
377   column = gtk_tree_view_column_new_with_attributes("Dropped Packets", renderer, "text", 1, NULL);
378   gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
379   renderer = gtk_cell_renderer_text_new();
380   column = gtk_tree_view_column_new_with_attributes("Capture Filter", renderer, "text", 2, NULL);
381   gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
382   renderer = gtk_cell_renderer_text_new();
383   column = gtk_tree_view_column_new_with_attributes("Link type", renderer, "text", 3, NULL);
384   gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
385   renderer = gtk_cell_renderer_text_new();
386   column = gtk_tree_view_column_new_with_attributes("Packet size limit", renderer, "text", 4, NULL);
387   gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
388
389   store = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
390   for (i = 0; i < summary.ifaces->len; i++) {
391     iface = g_array_index(summary.ifaces, iface_options, i);
392     /* interface */
393     if (iface.descr) {
394       g_snprintf(string_buff, SUM_STR_MAX, "%s", iface.descr);
395     } else if (iface.name) {
396       g_snprintf(string_buff, SUM_STR_MAX, "%s", iface.name);
397     } else {
398       g_snprintf(string_buff, SUM_STR_MAX, "unknown");
399     }
400     /* Dropped count */
401     if (iface.drops_known) {
402       g_snprintf(string_buff2, SUM_STR_MAX, "%" G_GINT64_MODIFIER "u", iface.drops);
403     } else {
404       g_snprintf(string_buff2, SUM_STR_MAX, "unknown");
405     }
406     /* Capture filter */
407     if (iface.cfilter && iface.cfilter[0] != '\0') {
408       g_snprintf(string_buff3, SUM_STR_MAX, "%s", iface.cfilter);
409     } else {
410       if (iface.name) {
411         g_snprintf(string_buff3, SUM_STR_MAX, "none");
412       } else {
413         g_snprintf(string_buff3, SUM_STR_MAX, "unknown");
414       }
415     }
416     dl_description = wtap_encap_string(iface.linktype);
417     if (dl_description != NULL)
418       g_snprintf(string_buff4, SUM_STR_MAX, "%s", dl_description);
419     else
420       g_snprintf(string_buff4, SUM_STR_MAX, "DLT %d", iface.linktype);
421
422     g_snprintf(string_buff5, SUM_STR_MAX, "%u bytes", iface.snap);
423     gtk_list_store_append(store, &iter);
424     gtk_list_store_set(store, &iter, 0, string_buff, 1, string_buff2, 2, string_buff3, 3, string_buff4, 4, string_buff5,-1);
425   }
426   gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(store));
427   g_object_unref (store);
428   gtk_container_add(GTK_CONTAINER(scrolled_window), treeview);
429   gtk_container_add(GTK_CONTAINER(main_vb),scrolled_window);
430   gtk_widget_show_all (scrolled_window);
431   table = gtk_table_new(1, 2, FALSE);
432   gtk_table_set_col_spacings(GTK_TABLE(table), 6);
433   gtk_table_set_row_spacings(GTK_TABLE(table), 3);
434   gtk_container_add(GTK_CONTAINER(main_vb), table);
435   row = 0;
436
437
438   /* Data */
439   add_string_to_table(table, &row, "", "");
440   add_string_to_table(table, &row, "Display", "");
441
442   if (summary.dfilter) {
443     /* Display filter */
444     /* limit each row to some reasonable length */
445     str_dup = g_strdup_printf("%s", summary.dfilter);
446     str_work = g_strdup(str_dup);
447     offset = 0;
448     snip = 0;
449     while(strlen(str_work) > FILTER_SNIP_LEN) {
450         str_work[FILTER_SNIP_LEN] = '\0';
451         add_string_to_table(table, &row, (snip == 0) ? "Display filter:" : "", str_work);
452         g_free(str_work);
453         offset+=FILTER_SNIP_LEN;
454         str_work = g_strdup(&str_dup[offset]);
455         snip++;
456     }
457
458     add_string_to_table(table, &row, (snip == 0) ? "Display filter:" : "", str_work);
459     g_free(str_work);
460     g_free(str_dup);
461   } else {
462     /* Display filter */
463     add_string_to_table(table, &row, "Display filter:", "none");
464   }
465
466   /* Ignored packet count */
467   g_snprintf(string_buff, SUM_STR_MAX, "%i", summary.ignored_count);
468   add_string_to_table(table, &row, "Ignored packets:", string_buff);
469
470   /* Traffic */
471   list = simple_list_new(4, titles);
472   gtk_container_add(GTK_CONTAINER(main_vb), list);
473
474   /* Packet count */
475   g_snprintf(string_buff, SUM_STR_MAX, "%i", summary.packet_count);
476   if (summary.dfilter) {
477     g_snprintf(string_buff2, SUM_STR_MAX, "%i", summary.filtered_count);
478   } else {
479     g_strlcpy(string_buff2, string_buff, SUM_STR_MAX);
480   }
481   g_snprintf(string_buff3, SUM_STR_MAX, "%i", summary.marked_count);
482   add_string_to_list(list, "Packets", string_buff, string_buff2, string_buff3);
483
484   /* Time between first and last */
485   if (seconds > 0) {
486     g_snprintf(string_buff, SUM_STR_MAX, "%.3f sec", seconds);
487   } else {
488     string_buff[0] = '\0';
489   }
490   if (summary.dfilter && disp_seconds > 0) {
491     g_snprintf(string_buff2, SUM_STR_MAX, "%.3f sec", disp_seconds);
492   } else {
493     string_buff2[0] = '\0';
494   }
495   if (summary.marked_count && marked_seconds > 0) {
496     g_snprintf(string_buff3, SUM_STR_MAX, "%.3f sec", marked_seconds);
497   } else {
498     string_buff3[0] = '\0';
499   }
500   if (string_buff[0] != '\0' || string_buff2[0] != '\0' || string_buff3[0] != '\0')
501     add_string_to_list(list, "Between first and last packet", string_buff, string_buff2, string_buff3);
502
503   /* Packets per second */
504   if (seconds > 0) {
505     g_snprintf(string_buff, SUM_STR_MAX, "%.3f", summary.packet_count/seconds);
506   } else {
507     string_buff[0] = '\0';
508   }
509   if(summary.dfilter && disp_seconds > 0) {
510     g_snprintf(string_buff2, SUM_STR_MAX, "%.3f", summary.filtered_count/disp_seconds);
511   } else {
512     string_buff2[0] = '\0';
513   }
514   if(summary.marked_count && marked_seconds > 0) {
515     g_snprintf(string_buff3, SUM_STR_MAX, "%.3f", summary.marked_count/marked_seconds);
516   } else {
517     string_buff3[0] = '\0';
518   }
519   if (string_buff[0] != '\0' || string_buff2[0] != '\0' || string_buff3[0] != '\0')
520   add_string_to_list(list, "Avg. packets/sec", string_buff, string_buff2, string_buff3);
521
522   /* Packet size */
523   if (summary.packet_count > 1) {
524     g_snprintf(string_buff, SUM_STR_MAX, "%.3f bytes",
525                /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
526                (float) ((gint64) summary.bytes)/summary.packet_count);
527   } else {
528     string_buff[0] = '\0';
529   }
530   if (summary.dfilter && summary.filtered_count > 1) {
531     g_snprintf(string_buff2, SUM_STR_MAX, "%.3f bytes",
532                /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
533                (float) ((gint64) summary.filtered_bytes)/summary.filtered_count);
534   } else {
535     string_buff2[0] = '\0';
536   }
537   if (summary.marked_count > 1) {
538     g_snprintf(string_buff3, SUM_STR_MAX, "%.3f bytes",
539                /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
540                (float) ((gint64) summary.marked_bytes)/summary.marked_count);
541   } else {
542     string_buff3[0] = '\0';
543   }
544   if (string_buff[0] != '\0' || string_buff2[0] != '\0' || string_buff3[0] != '\0')
545     add_string_to_list(list, "Avg. packet size", string_buff, string_buff2, string_buff3);
546
547   /* Byte count */
548   g_snprintf(string_buff, SUM_STR_MAX, "%" G_GINT64_MODIFIER "u", summary.bytes);
549   if (summary.dfilter && summary.filtered_count > 0) {
550     g_snprintf(string_buff2, SUM_STR_MAX, "%" G_GINT64_MODIFIER "u", summary.filtered_bytes);
551   } else {
552     string_buff2[0] = '\0';
553   }
554   if (summary.marked_count) {
555     g_snprintf(string_buff3, SUM_STR_MAX, "%" G_GINT64_MODIFIER "u", summary.marked_bytes);
556   } else {
557     string_buff3[0] = '\0';
558   }
559   if (string_buff[0] != '\0' || string_buff2[0] != '\0' || string_buff3[0] != '\0')
560     add_string_to_list(list, "Bytes", string_buff, string_buff2, string_buff3);
561
562   /* Bytes per second */
563   if (seconds > 0){
564     /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
565     g_snprintf(string_buff, SUM_STR_MAX, "%.3f", ((gint64) summary.bytes)/seconds);
566   } else {
567     string_buff[0] = '\0';
568   }
569   if (summary.dfilter && disp_seconds > 0) {
570     /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
571     g_snprintf(string_buff2, SUM_STR_MAX, "%.3f", ((gint64) summary.filtered_bytes)/disp_seconds);
572   } else {
573     string_buff2[0] = '\0';
574   }
575   if (summary.marked_count && marked_seconds > 0) {
576     /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
577     g_snprintf(string_buff3, SUM_STR_MAX, "%.3f", ((gint64) summary.marked_bytes)/marked_seconds);
578   } else {
579     string_buff3[0] = '\0';
580   }
581   if (string_buff[0] != '\0' || string_buff2[0] != '\0' || string_buff3[0] != '\0')
582     add_string_to_list(list, "Avg. bytes/sec", string_buff, string_buff2, string_buff3);
583
584   /* MBit per second */
585   if (seconds > 0) {
586     g_snprintf(string_buff, SUM_STR_MAX, "%.3f",
587                /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
588                ((gint64) summary.bytes) * 8.0 / (seconds * 1000.0 * 1000.0));
589   } else {
590     string_buff[0] = '\0';
591   }
592   if (summary.dfilter && disp_seconds > 0) {
593     g_snprintf(string_buff2, SUM_STR_MAX, "%.3f",
594                /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
595                ((gint64) summary.filtered_bytes) * 8.0 / (disp_seconds * 1000.0 * 1000.0));
596   } else {
597     string_buff2[0] = '\0';
598   }
599   if (summary.marked_count && marked_seconds > 0) {
600     g_snprintf(string_buff3, SUM_STR_MAX, "%.3f",
601                /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
602                ((gint64) summary.marked_bytes) * 8.0 / (marked_seconds * 1000.0 * 1000.0));
603   } else {
604     string_buff3[0] = '\0';
605   }
606   if (string_buff[0] != '\0' || string_buff2[0] != '\0' || string_buff3[0] != '\0')
607     add_string_to_list(list, "Avg. MBit/sec", string_buff, string_buff2, string_buff3);
608
609
610   /* Button row. */
611   bbox = dlg_button_row_new(GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
612   gtk_container_add(GTK_CONTAINER(main_vb), bbox);
613
614   close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
615   window_set_cancel_button(sum_open_w, close_bt, window_cancel_button_cb);
616
617   help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
618   g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_STATS_SUMMARY_DIALOG);
619
620   gtk_widget_grab_focus(close_bt);
621
622   g_signal_connect(sum_open_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
623
624   gtk_widget_show_all(sum_open_w);
625   window_present(sum_open_w);
626 }