X-Git-Url: http://git.samba.org/samba.git/?a=blobdiff_plain;f=summary.c;h=21b91c29f60b1ca4fef18f80c86174a585a997f3;hb=b6ca6031a88b1e7325479f2768bb3f577aa5b2b9;hp=68dc50a3a3ea260b58ae161d7f627aa3a8d3227d;hpb=192259bb6af43c41ca17347e6dd0833f565dfeb1;p=obnox%2Fwireshark%2Fwip.git diff --git a/summary.c b/summary.c index 68dc50a3a3..21b91c29f6 100644 --- a/summary.c +++ b/summary.c @@ -1,13 +1,12 @@ /* summary.c * Routines for capture file summary info * - * $Id: summary.c,v 1.15 1999/12/10 04:20:53 gram Exp $ + * $Id$ * - * Ethereal - Network traffic analyzer - * By Gerald Combs + * Wireshark - Network traffic analyzer + * By Gerald Combs * 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 @@ -23,78 +22,148 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include "packet.h" -#include "globals.h" -#include "summary.h" +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#include +#include "cfile.h" +#include "summary.h" +#ifdef HAVE_LIBPCAP +#include "capture_ui_utils.h" +#endif -static double -secs_usecs( guint32 s, guint32 us) -{ - return (us / 1000000.0) + (double)s; -} static void tally_frame_data(frame_data *cur_frame, summary_tally *sum_tally) { double cur_time; - cur_time = secs_usecs(cur_frame->abs_secs, cur_frame->abs_usecs); + cur_time = nstime_to_sec(&cur_frame->abs_ts); - if (cur_time < sum_tally->start_time) { - sum_tally->start_time = cur_time; + 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; + 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) { + sum_tally->filtered_start = cur_time; + } + if (cur_time > sum_tally->filtered_stop) { + sum_tally->filtered_stop = cur_time; + } } - if (cur_time > sum_tally->stop_time){ - sum_tally->stop_time = cur_time; + sum_tally->filtered_count++; + sum_tally->filtered_bytes += cur_frame->pkt_len ; + } + 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; + } } - sum_tally->bytes += cur_frame->pkt_len; - if (cur_frame->passed_dfilter) - sum_tally->filtered_count++; + sum_tally->marked_count++; + sum_tally->marked_bytes += cur_frame->pkt_len ; + } + if (cur_frame->flags.ignored){ + sum_tally->ignored_count++; + } } void -summary_fill_in(summary_tally *st) +summary_fill_in(capture_file *cf, summary_tally *st) { frame_data *first_frame, *cur_frame; - int i; - frame_data *cur_glist; + guint32 framenum; - /* initialize the tally */ - first_frame = cf.plist; - 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) ; + st->start_time = 0; + st->stop_time = 0; st->bytes = 0; st->filtered_count = 0; - cur_glist = cf.plist; - - for (i = 0; i < cf.count; i++) { - cur_frame = cur_glist; - tally_frame_data(cur_frame, st); - cur_glist = cur_glist->next; + st->filtered_start = 0; + st->filtered_stop = 0; + st->filtered_bytes = 0; + st->marked_count = 0; + st->marked_start = 0; + st->marked_stop = 0; + st->marked_bytes = 0; + st->ignored_count = 0; + + /* initialize the tally */ + if (cf->count != 0) { + first_frame = frame_data_sequence_find(cf->frames, 1); + st->start_time = nstime_to_sec(&first_frame->abs_ts); + st->stop_time = nstime_to_sec(&first_frame->abs_ts); + + for (framenum = 1; framenum <= cf->count; framenum++) { + cur_frame = frame_data_sequence_find(cf->frames, framenum); + tally_frame_data(cur_frame, st); + } } - st->filename = cf.filename; - st->file_length = cf.f_len; - st->encap_type = cf.cd_t; - st->snap = cf.snap; - st->elapsed_time = secs_usecs(cf.esec, cf.eusec); - st->packet_count = cf.count; - st->drops = cf.drops; - st->iface = cf.iface; - st->dfilter = cf.dfilter; - -#ifdef HAVE_LIBPCAP - st->cfilter = cf.cfilter; -#else - st->cfilter = NULL; -#endif + st->filename = cf->filename; + st->file_length = cf->f_datalen; + st->file_type = cf->cd_t; + st->is_tempfile = cf->is_tempfile; + st->encap_type = cf->lnk_t; + st->has_snap = cf->has_snap; + st->snap = cf->snap; + st->elapsed_time = nstime_to_sec(&cf->elapsed_time); + st->packet_count = cf->count; + st->drops_known = cf->drops_known; + st->drops = cf->drops; + st->dfilter = cf->dfilter; + + st->ifaces = g_array_new(FALSE, FALSE, sizeof(iface_options)); +} +#ifdef HAVE_LIBPCAP +void +summary_fill_in_capture(capture_options *capture_opts, summary_tally *st) +{ + iface_options iface; + interface_options interface_opts; + guint i; + + while (st->ifaces->len > 0) { + iface = g_array_index(st->ifaces, iface_options, 0); + st->ifaces = g_array_remove_index(st->ifaces, 0); + g_free(iface.name); + g_free(iface.descr); + g_free(iface.cfilter); + } + if (st->is_tempfile) { + for (i = 0; i < capture_opts->ifaces->len; i++) { + interface_opts = g_array_index(capture_opts->ifaces, interface_options, i); + iface.cfilter = g_strdup(interface_opts.cfilter); + iface.name = g_strdup(interface_opts.name); + iface.descr = g_strdup(interface_opts.descr); + iface.drops_known = FALSE; + iface.drops = 0; + iface.has_snap = interface_opts.has_snaplen; + iface.snap = interface_opts.snaplen; + iface.linktype = interface_opts.linktype; + g_array_append_val(st->ifaces, iface); + } + } } - +#endif