2 * Routines for capture file summary info
4 * $Id: summary.c,v 1.23 2003/09/02 22:10:32 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
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.
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.
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.
29 #include <epan/packet.h>
35 secs_usecs( guint32 s, guint32 us)
37 return (us / 1000000.0) + (double)s;
41 tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally)
45 cur_time = secs_usecs(cur_frame->abs_secs, cur_frame->abs_usecs);
47 if (cur_time < sum_tally->start_time) {
48 sum_tally->start_time = cur_time;
50 if (cur_time > sum_tally->stop_time){
51 sum_tally->stop_time = cur_time;
53 sum_tally->bytes += cur_frame->pkt_len;
54 if (cur_frame->flags.passed_dfilter){
55 if (sum_tally->filtered_count==0){
56 sum_tally->filtered_start= cur_time;
57 sum_tally->filtered_stop = cur_time;
59 if (cur_time < sum_tally->filtered_start) {
60 sum_tally->start_time = cur_time;
62 if (cur_time > sum_tally->filtered_stop) {
63 sum_tally->filtered_stop = cur_time;
66 sum_tally->filtered_count++;
67 sum_tally->filtered_bytes += cur_frame->pkt_len ;
69 if (cur_frame->flags.marked)
70 sum_tally->marked_count++;
75 summary_fill_in(summary_tally *st)
78 frame_data *first_frame, *cur_frame;
80 frame_data *cur_glist;
85 st->filtered_count = 0;
86 st->filtered_start = 0;
87 st->filtered_stop = 0;
88 st->filtered_bytes = 0;
91 /* initialize the tally */
92 if (cfile.plist != NULL) {
93 first_frame = cfile.plist;
94 st->start_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs);
95 st->stop_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs);
96 cur_glist = cfile.plist;
98 for (i = 0; i < cfile.count; i++) {
99 cur_frame = cur_glist;
100 tally_frame_data(cur_frame, st);
101 cur_glist = cur_glist->next;
105 st->filename = cfile.filename;
106 st->file_length = cfile.f_len;
107 st->encap_type = cfile.cd_t;
108 st->has_snap = cfile.has_snap;
109 st->snap = cfile.snap;
110 st->elapsed_time = secs_usecs(cfile.esec, cfile.eusec);
111 st->packet_count = cfile.count;
112 st->drops_known = cfile.drops_known;
113 st->drops = cfile.drops;
114 st->iface = cfile.iface;
115 st->dfilter = cfile.dfilter;
118 st->cfilter = cfile.cfilter;