From Håkon Nessjøen
[obnox/wireshark/wip.git] / summary.c
index 3e60f58e5917cff29edc176889054f3a7e257c3d..82831b78d4ac6ac662ab40de187a1b49c12fe579 100644 (file)
--- a/summary.c
+++ b/summary.c
@@ -1,13 +1,12 @@
 /* summary.c
  * Routines for capture file summary info
  *
- * $Id: summary.c,v 1.18 2000/06/27 04:35:46 guy Exp $
+ * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * 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
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
-#include "packet.h"
-#include "globals.h"
-#include "summary.h"
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
 
+#include <epan/packet.h>
+#include "cfile.h"
+#include "summary.h"
+#ifdef HAVE_LIBPCAP
+#include "capture_ui_utils.h"
+#endif
 
-static double
-secs_usecs( guint32 s, guint32 us)
-{
-  return (us / 1000000.0) + (double)s;
-}
 
 static void
 tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally)
 {
   double cur_time;
 
-  cur_time = secs_usecs(cur_frame->abs_secs, cur_frame->abs_usecs);
+  cur_time = nstime_to_sec(&cur_frame->abs_ts);
 
   if (cur_time < sum_tally->start_time) {
     sum_tally->start_time = cur_time;
@@ -53,12 +52,43 @@ tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally)
     sum_tally->stop_time = cur_time;
   }
   sum_tally->bytes += cur_frame->pkt_len;
-  if (cur_frame->flags.passed_dfilter)
+  if (cur_frame->flags.passed_dfilter){
+    if (sum_tally->filtered_count==0){
+           sum_tally->filtered_start= cur_time;
+           sum_tally->filtered_stop = cur_time;
+    } else {
+           if (cur_time < sum_tally->filtered_start) {
+                   sum_tally->filtered_start = cur_time;
+           }
+           if (cur_time > sum_tally->filtered_stop) {
+                   sum_tally->filtered_stop = cur_time;
+           }
+    }
     sum_tally->filtered_count++;
+    sum_tally->filtered_bytes += cur_frame->pkt_len ;
+  }
+  if (cur_frame->flags.marked){
+    if (sum_tally->marked_count==0){
+           sum_tally->marked_start= cur_time;
+           sum_tally->marked_stop = cur_time;
+    } else {
+           if (cur_time < sum_tally->marked_start) {
+                   sum_tally->marked_start = cur_time;
+           }
+           if (cur_time > sum_tally->marked_stop) {
+                   sum_tally->marked_stop = cur_time;
+           }
+    }
+    sum_tally->marked_count++;
+    sum_tally->marked_bytes += cur_frame->pkt_len ;
+  }
+  if (cur_frame->flags.ignored){
+    sum_tally->ignored_count++;
+  }
 }
 
 void
-summary_fill_in(summary_tally *st)
+summary_fill_in(capture_file *cf, summary_tally *st)
 {
 
   frame_data    *first_frame, *cur_frame;
@@ -69,34 +99,54 @@ summary_fill_in(summary_tally *st)
   st->stop_time = 0;
   st->bytes = 0;
   st->filtered_count = 0;
+  st->filtered_start = 0;
+  st->filtered_stop = 0;
+  st->filtered_bytes = 0;
+  st->marked_count = 0;
+  st->marked_start = 0;
+  st->marked_stop = 0;
+  st->marked_bytes = 0;
+  st->ignored_count = 0;
 
   /* initialize the tally */
-  if (cfile.plist != NULL) {
-    first_frame = cfile.plist;
-    st->start_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs);
-    st->stop_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs);
-    cur_glist = cfile.plist;
+  if (cf->plist_start != NULL) {
+    first_frame = cf->plist_start;
+    st->start_time     = nstime_to_sec(&first_frame->abs_ts);
+    st->stop_time = nstime_to_sec(&first_frame->abs_ts);
+    cur_glist = cf->plist_start;
 
-    for (i = 0; i < cfile.count; i++) {
+    for (i = 0; i < cf->count; i++) {
       cur_frame = cur_glist;
       tally_frame_data(cur_frame, st);
       cur_glist = cur_glist->next;
     }
   }
 
-  st->filename = cfile.filename;
-  st->file_length = cfile.f_len;
-  st->encap_type = cfile.cd_t;
-  st->snap = cfile.snap;
-  st->elapsed_time = secs_usecs(cfile.esec, cfile.eusec);
-  st->packet_count = cfile.count;
-  st->drops = cfile.drops;
-  st->iface = cfile.iface;
-  st->dfilter = cfile.dfilter;
+  st->filename = cf->filename;
+  st->file_length = cf->f_datalen;
+  st->file_type = cf->cd_t;
+  st->encap_type = cf->lnk_t;
+  st->has_snap = cf->has_snap;
+  st->snap = cf->snap;
+  st->elapsed_time = nstime_to_sec(&cf->elapsed_time);
+  st->packet_count = cf->count;
+  st->drops_known = cf->drops_known;
+  st->drops = cf->drops;
+  st->dfilter = cf->dfilter;
 
-#ifdef HAVE_LIBPCAP
-  st->cfilter = cfile.cfilter;
-#else
+  /* capture related */
   st->cfilter = NULL;
-#endif
+  st->iface = NULL;
+  st->iface_descr = NULL;
 }
+
+
+#ifdef HAVE_LIBPCAP
+void
+summary_fill_in_capture(capture_options *capture_opts, summary_tally *st)
+{
+  st->cfilter = capture_opts->cfilter;
+  st->iface = capture_opts->iface;
+  st->iface_descr = get_iface_description(capture_opts);
+}
+#endif