1999-06-22 22:02:39 +00:00
|
|
|
/* summary.c
|
1999-12-10 04:21:04 +00:00
|
|
|
* Routines for capture file summary info
|
1999-06-22 22:02:39 +00:00
|
|
|
*
|
2001-02-11 09:28:17 +00:00
|
|
|
* $Id: summary.c,v 1.20 2001/02/11 09:28:15 guy Exp $
|
1999-06-22 22:02:39 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@zing.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
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "packet.h"
|
1999-12-10 04:21:04 +00:00
|
|
|
#include "globals.h"
|
1999-06-22 22:02:39 +00:00
|
|
|
#include "summary.h"
|
|
|
|
|
|
|
|
|
1999-12-10 04:21:04 +00:00
|
|
|
static double
|
|
|
|
secs_usecs( guint32 s, guint32 us)
|
|
|
|
{
|
1999-06-22 22:02:39 +00:00
|
|
|
return (us / 1000000.0) + (double)s;
|
|
|
|
}
|
|
|
|
|
1999-12-10 04:21:04 +00:00
|
|
|
static void
|
|
|
|
tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally)
|
|
|
|
{
|
1999-06-22 22:02:39 +00:00
|
|
|
double cur_time;
|
|
|
|
|
|
|
|
cur_time = secs_usecs(cur_frame->abs_secs, cur_frame->abs_usecs);
|
1999-12-10 04:21:04 +00:00
|
|
|
|
1999-12-29 21:30:28 +00:00
|
|
|
if (cur_time < sum_tally->start_time) {
|
|
|
|
sum_tally->start_time = cur_time;
|
|
|
|
}
|
|
|
|
if (cur_time > sum_tally->stop_time){
|
|
|
|
sum_tally->stop_time = cur_time;
|
|
|
|
}
|
|
|
|
sum_tally->bytes += cur_frame->pkt_len;
|
2000-04-13 20:39:38 +00:00
|
|
|
if (cur_frame->flags.passed_dfilter)
|
1999-12-29 21:30:28 +00:00
|
|
|
sum_tally->filtered_count++;
|
2000-08-21 18:20:19 +00:00
|
|
|
if (cur_frame->flags.marked)
|
|
|
|
sum_tally->marked_count++;
|
|
|
|
|
1999-06-22 22:02:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-12-10 04:21:04 +00:00
|
|
|
summary_fill_in(summary_tally *st)
|
|
|
|
{
|
1999-06-22 22:02:39 +00:00
|
|
|
|
|
|
|
frame_data *first_frame, *cur_frame;
|
1999-12-10 04:21:04 +00:00
|
|
|
int i;
|
|
|
|
frame_data *cur_glist;
|
1999-06-22 22:02:39 +00:00
|
|
|
|
1999-12-29 21:30:28 +00:00
|
|
|
st->start_time = 0;
|
|
|
|
st->stop_time = 0;
|
1999-06-22 22:02:39 +00:00
|
|
|
st->bytes = 0;
|
1999-07-07 22:52:57 +00:00
|
|
|
st->filtered_count = 0;
|
2000-08-21 18:20:19 +00:00
|
|
|
st->marked_count = 0;
|
1999-06-22 22:02:39 +00:00
|
|
|
|
1999-12-29 21:30:28 +00:00
|
|
|
/* initialize the tally */
|
2000-06-27 04:36:03 +00:00
|
|
|
if (cfile.plist != NULL) {
|
|
|
|
first_frame = cfile.plist;
|
1999-12-29 21:30:28 +00:00
|
|
|
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);
|
2000-06-27 04:36:03 +00:00
|
|
|
cur_glist = cfile.plist;
|
1999-12-29 21:30:28 +00:00
|
|
|
|
2000-06-27 04:36:03 +00:00
|
|
|
for (i = 0; i < cfile.count; i++) {
|
1999-12-29 21:30:28 +00:00
|
|
|
cur_frame = cur_glist;
|
|
|
|
tally_frame_data(cur_frame, st);
|
|
|
|
cur_glist = cur_glist->next;
|
|
|
|
}
|
1999-08-10 04:13:37 +00:00
|
|
|
}
|
1999-06-22 22:02:39 +00:00
|
|
|
|
2000-06-27 04:36:03 +00:00
|
|
|
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;
|
2001-02-11 09:28:17 +00:00
|
|
|
st->drops_known = cfile.drops_known;
|
2000-06-27 04:36:03 +00:00
|
|
|
st->drops = cfile.drops;
|
|
|
|
st->iface = cfile.iface;
|
|
|
|
st->dfilter = cfile.dfilter;
|
1999-06-22 22:02:39 +00:00
|
|
|
|
1999-07-09 04:18:36 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2000-06-27 04:36:03 +00:00
|
|
|
st->cfilter = cfile.cfilter;
|
1999-12-10 04:21:04 +00:00
|
|
|
#else
|
|
|
|
st->cfilter = NULL;
|
1999-07-09 04:18:36 +00:00
|
|
|
#endif
|
1999-12-10 04:21:04 +00:00
|
|
|
}
|