Don't prime the display filter unless we're re-applying it; otherwise,
[obnox/wireshark/wip.git] / summary.c
1 /* summary.c
2  * Routines for capture file summary info
3  *
4  * $Id: summary.c,v 1.22 2002/02/08 10:07:34 guy Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
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 <epan/packet.h>
30 #include "globals.h"
31 #include "summary.h"
32
33
34 static double
35 secs_usecs( guint32 s, guint32 us)
36 {
37   return (us / 1000000.0) + (double)s;
38 }
39
40 static void
41 tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally)
42 {
43   double cur_time;
44
45   cur_time = secs_usecs(cur_frame->abs_secs, cur_frame->abs_usecs);
46
47   if (cur_time < sum_tally->start_time) {
48     sum_tally->start_time = cur_time;
49   }
50   if (cur_time > sum_tally->stop_time){
51     sum_tally->stop_time = cur_time;
52   }
53   sum_tally->bytes += cur_frame->pkt_len;
54   if (cur_frame->flags.passed_dfilter)
55     sum_tally->filtered_count++;
56   if (cur_frame->flags.marked)
57     sum_tally->marked_count++;
58
59 }
60
61 void
62 summary_fill_in(summary_tally *st)
63 {
64
65   frame_data    *first_frame, *cur_frame;
66   int           i;
67   frame_data    *cur_glist;
68
69   st->start_time = 0;
70   st->stop_time = 0;
71   st->bytes = 0;
72   st->filtered_count = 0;
73   st->marked_count = 0;
74
75   /* initialize the tally */
76   if (cfile.plist != NULL) {
77     first_frame = cfile.plist;
78     st->start_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs);
79     st->stop_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs);
80     cur_glist = cfile.plist;
81
82     for (i = 0; i < cfile.count; i++) {
83       cur_frame = cur_glist;
84       tally_frame_data(cur_frame, st);
85       cur_glist = cur_glist->next;
86     }
87   }
88
89   st->filename = cfile.filename;
90   st->file_length = cfile.f_len;
91   st->encap_type = cfile.cd_t;
92   st->has_snap = cfile.has_snap;
93   st->snap = cfile.snap;
94   st->elapsed_time = secs_usecs(cfile.esec, cfile.eusec);
95   st->packet_count = cfile.count;
96   st->drops_known = cfile.drops_known;
97   st->drops = cfile.drops;
98   st->iface = cfile.iface;
99   st->dfilter = cfile.dfilter;
100
101 #ifdef HAVE_LIBPCAP
102   st->cfilter = cfile.cfilter;
103 #else
104   st->cfilter = NULL;
105 #endif
106 }