2 * Routines for capture file summary info
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>
33 #include "capture_ui_utils.h"
38 secs_usecs( guint32 s, guint32 us)
40 return (us / 1000000.0) + (double)s;
44 tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally)
48 cur_time = secs_usecs(cur_frame->abs_secs, cur_frame->abs_usecs);
50 if (cur_time < sum_tally->start_time) {
51 sum_tally->start_time = cur_time;
53 if (cur_time > sum_tally->stop_time){
54 sum_tally->stop_time = cur_time;
56 sum_tally->bytes += cur_frame->pkt_len;
57 if (cur_frame->flags.passed_dfilter){
58 if (sum_tally->filtered_count==0){
59 sum_tally->filtered_start= cur_time;
60 sum_tally->filtered_stop = cur_time;
62 if (cur_time < sum_tally->filtered_start) {
63 sum_tally->start_time = cur_time;
65 if (cur_time > sum_tally->filtered_stop) {
66 sum_tally->filtered_stop = cur_time;
69 sum_tally->filtered_count++;
70 sum_tally->filtered_bytes += cur_frame->pkt_len ;
72 if (cur_frame->flags.marked)
73 sum_tally->marked_count++;
78 summary_fill_in(capture_file *cf, summary_tally *st)
81 frame_data *first_frame, *cur_frame;
83 frame_data *cur_glist;
88 st->filtered_count = 0;
89 st->filtered_start = 0;
90 st->filtered_stop = 0;
91 st->filtered_bytes = 0;
94 /* initialize the tally */
95 if (cf->plist != NULL) {
96 first_frame = cf->plist;
97 st->start_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs);
98 st->stop_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs);
99 cur_glist = cf->plist;
101 for (i = 0; i < cf->count; i++) {
102 cur_frame = cur_glist;
103 tally_frame_data(cur_frame, st);
104 cur_glist = cur_glist->next;
108 st->filename = cf->filename;
109 st->file_length = cf->f_datalen;
110 st->encap_type = cf->cd_t;
111 st->has_snap = cf->has_snap;
113 st->elapsed_time = secs_usecs(cf->esec, cf->eusec);
114 st->packet_count = cf->count;
115 st->drops_known = cf->drops_known;
116 st->drops = cf->drops;
117 st->dfilter = cf->dfilter;
119 /* capture related */
122 st->iface_descr = NULL;
128 summary_fill_in_capture(capture_options *capture_opts, summary_tally *st)
130 st->cfilter = capture_opts->cfilter;
131 st->iface = capture_opts->iface;
133 st->iface_descr = get_interface_descriptive_name(st->iface);
135 st->iface_descr = NULL;