Have "dissect_netbios_payload()" take as an argument a tvbuff containing
[obnox/wireshark/wip.git] / summary.c
1 /* summary.c
2  * Routines for capture file summary info
3  *
4  * $Id: summary.c,v 1.20 2001/02/11 09:28:15 guy Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@zing.org>
8  * Copyright 1998 Gerald Combs
9  *
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include "packet.h"
32 #include "globals.h"
33 #include "summary.h"
34
35
36 static double
37 secs_usecs( guint32 s, guint32 us)
38 {
39   return (us / 1000000.0) + (double)s;
40 }
41
42 static void
43 tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally)
44 {
45   double cur_time;
46
47   cur_time = secs_usecs(cur_frame->abs_secs, cur_frame->abs_usecs);
48
49   if (cur_time < sum_tally->start_time) {
50     sum_tally->start_time = cur_time;
51   }
52   if (cur_time > sum_tally->stop_time){
53     sum_tally->stop_time = cur_time;
54   }
55   sum_tally->bytes += cur_frame->pkt_len;
56   if (cur_frame->flags.passed_dfilter)
57     sum_tally->filtered_count++;
58   if (cur_frame->flags.marked)
59     sum_tally->marked_count++;
60
61 }
62
63 void
64 summary_fill_in(summary_tally *st)
65 {
66
67   frame_data    *first_frame, *cur_frame;
68   int           i;
69   frame_data    *cur_glist;
70
71   st->start_time = 0;
72   st->stop_time = 0;
73   st->bytes = 0;
74   st->filtered_count = 0;
75   st->marked_count = 0;
76
77   /* initialize the tally */
78   if (cfile.plist != NULL) {
79     first_frame = cfile.plist;
80     st->start_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs);
81     st->stop_time = secs_usecs(first_frame->abs_secs,first_frame->abs_usecs);
82     cur_glist = cfile.plist;
83
84     for (i = 0; i < cfile.count; i++) {
85       cur_frame = cur_glist;
86       tally_frame_data(cur_frame, st);
87       cur_glist = cur_glist->next;
88     }
89   }
90
91   st->filename = cfile.filename;
92   st->file_length = cfile.f_len;
93   st->encap_type = cfile.cd_t;
94   st->snap = cfile.snap;
95   st->elapsed_time = secs_usecs(cfile.esec, cfile.eusec);
96   st->packet_count = cfile.count;
97   st->drops_known = cfile.drops_known;
98   st->drops = cfile.drops;
99   st->iface = cfile.iface;
100   st->dfilter = cfile.dfilter;
101
102 #ifdef HAVE_LIBPCAP
103   st->cfilter = cfile.cfilter;
104 #else
105   st->cfilter = NULL;
106 #endif
107 }