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
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
1999-06-22 22:02:39 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
1999-06-22 22:02:39 +00:00
|
|
|
* 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
|
|
|
|
|
2007-08-30 00:24:40 +00:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2005-02-04 19:29:27 +00:00
|
|
|
#include "cfile.h"
|
1999-06-22 22:02:39 +00:00
|
|
|
#include "summary.h"
|
2005-02-06 21:20:35 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
#include "capture_ui_utils.h"
|
|
|
|
#endif
|
1999-06-22 22:02:39 +00:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2005-08-24 21:31:56 +00:00
|
|
|
cur_time = nstime_to_sec(&cur_frame->abs_ts);
|
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;
|
2003-09-02 22:10:32 +00:00
|
|
|
if (cur_frame->flags.passed_dfilter){
|
|
|
|
if (sum_tally->filtered_count==0){
|
|
|
|
sum_tally->filtered_start= cur_time;
|
|
|
|
sum_tally->filtered_stop = cur_time;
|
|
|
|
} else {
|
|
|
|
if (cur_time < sum_tally->filtered_start) {
|
2007-11-28 01:04:11 +00:00
|
|
|
sum_tally->filtered_start = cur_time;
|
2003-09-02 22:10:32 +00:00
|
|
|
}
|
|
|
|
if (cur_time > sum_tally->filtered_stop) {
|
|
|
|
sum_tally->filtered_stop = cur_time;
|
|
|
|
}
|
|
|
|
}
|
1999-12-29 21:30:28 +00:00
|
|
|
sum_tally->filtered_count++;
|
2003-09-02 22:10:32 +00:00
|
|
|
sum_tally->filtered_bytes += cur_frame->pkt_len ;
|
|
|
|
}
|
2007-11-28 01:09:02 +00:00
|
|
|
if (cur_frame->flags.marked){
|
|
|
|
if (sum_tally->marked_count==0){
|
|
|
|
sum_tally->marked_start= cur_time;
|
|
|
|
sum_tally->marked_stop = cur_time;
|
|
|
|
} else {
|
|
|
|
if (cur_time < sum_tally->marked_start) {
|
|
|
|
sum_tally->marked_start = cur_time;
|
|
|
|
}
|
|
|
|
if (cur_time > sum_tally->marked_stop) {
|
|
|
|
sum_tally->marked_stop = cur_time;
|
|
|
|
}
|
|
|
|
}
|
2000-08-21 18:20:19 +00:00
|
|
|
sum_tally->marked_count++;
|
2007-11-28 01:09:02 +00:00
|
|
|
sum_tally->marked_bytes += cur_frame->pkt_len ;
|
|
|
|
}
|
2009-12-17 12:05:13 +00:00
|
|
|
if (cur_frame->flags.ignored){
|
|
|
|
sum_tally->ignored_count++;
|
|
|
|
}
|
1999-06-22 22:02:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-02-04 19:29:27 +00:00
|
|
|
summary_fill_in(capture_file *cf, summary_tally *st)
|
1999-12-10 04:21:04 +00:00
|
|
|
{
|
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;
|
2003-09-02 22:10:32 +00:00
|
|
|
st->filtered_start = 0;
|
2007-11-28 01:09:02 +00:00
|
|
|
st->filtered_stop = 0;
|
2003-09-02 22:10:32 +00:00
|
|
|
st->filtered_bytes = 0;
|
2000-08-21 18:20:19 +00:00
|
|
|
st->marked_count = 0;
|
2007-11-28 01:09:02 +00:00
|
|
|
st->marked_start = 0;
|
|
|
|
st->marked_stop = 0;
|
|
|
|
st->marked_bytes = 0;
|
2009-12-17 12:05:13 +00:00
|
|
|
st->ignored_count = 0;
|
1999-06-22 22:02:39 +00:00
|
|
|
|
1999-12-29 21:30:28 +00:00
|
|
|
/* initialize the tally */
|
2009-09-21 18:09:19 +00:00
|
|
|
if (cf->plist_start != NULL) {
|
|
|
|
first_frame = cf->plist_start;
|
2005-08-24 21:31:56 +00:00
|
|
|
st->start_time = nstime_to_sec(&first_frame->abs_ts);
|
|
|
|
st->stop_time = nstime_to_sec(&first_frame->abs_ts);
|
2009-09-21 18:09:19 +00:00
|
|
|
cur_glist = cf->plist_start;
|
1999-12-29 21:30:28 +00:00
|
|
|
|
2005-02-04 19:29:27 +00:00
|
|
|
for (i = 0; i < cf->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
|
|
|
|
2005-02-04 19:29:27 +00:00
|
|
|
st->filename = cf->filename;
|
2005-08-19 01:17:24 +00:00
|
|
|
st->file_length = cf->f_datalen;
|
2008-10-14 22:55:16 +00:00
|
|
|
st->file_type = cf->cd_t;
|
|
|
|
st->encap_type = cf->lnk_t;
|
2005-02-04 19:29:27 +00:00
|
|
|
st->has_snap = cf->has_snap;
|
|
|
|
st->snap = cf->snap;
|
2005-08-24 21:31:56 +00:00
|
|
|
st->elapsed_time = nstime_to_sec(&cf->elapsed_time);
|
2005-02-04 19:29:27 +00:00
|
|
|
st->packet_count = cf->count;
|
|
|
|
st->drops_known = cf->drops_known;
|
|
|
|
st->drops = cf->drops;
|
|
|
|
st->dfilter = cf->dfilter;
|
1999-06-22 22:02:39 +00:00
|
|
|
|
2005-02-06 21:20:35 +00:00
|
|
|
/* capture related */
|
1999-12-10 04:21:04 +00:00
|
|
|
st->cfilter = NULL;
|
2005-02-06 21:20:35 +00:00
|
|
|
st->iface = NULL;
|
|
|
|
st->iface_descr = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
void
|
|
|
|
summary_fill_in_capture(capture_options *capture_opts, summary_tally *st)
|
|
|
|
{
|
|
|
|
st->cfilter = capture_opts->cfilter;
|
|
|
|
st->iface = capture_opts->iface;
|
2007-08-22 18:56:20 +00:00
|
|
|
st->iface_descr = get_iface_description(capture_opts);
|
1999-12-10 04:21:04 +00:00
|
|
|
}
|
2005-02-06 21:20:35 +00:00
|
|
|
#endif
|