/* proto_hier_stats.c
* Routines for calculating statistics based on protocol.
*
- * $Id: proto_hier_stats.c,v 1.22 2004/01/21 22:00:28 ulfl Exp $
+ * $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
#define STAT_NODE_STATS(n) ((ph_stats_node_t*)(n)->data)
#define STAT_NODE_HFINFO(n) (STAT_NODE_STATS(n)->hfinfo)
+static double
+secs_usecs(guint32 s, guint32 us)
+{
+ return (us / 1000000.0) + (double)s;
+}
+
static GNode*
find_stat_node(GNode *parent_stat_node, header_field_info *needle_hfinfo)
{
union wtap_pseudo_header phdr;
guint8 pd[WTAP_MAX_PACKET_SIZE];
int err;
+ gchar *err_info;
+ double cur_time;
/* Load the frame from the capture file */
if (!wtap_seek_read(cfile.wth, frame->file_off, &phdr, pd,
- frame->cap_len, &err)) {
- simple_dialog(ESD_TYPE_CRIT, NULL,
- file_read_error_message(err), cfile.filename);
+ frame->cap_len, &err, &err_info)) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ cf_read_error_message(err, err_info), cfile.filename);
return FALSE; /* failure */
}
/* Get stats from this protocol tree */
process_tree(edt->tree, ps, frame->pkt_len);
+ /* Update times */
+ cur_time = secs_usecs(frame->abs_secs, frame->abs_usecs);
+ if (cur_time < ps->first_time) {
+ ps->first_time = cur_time;
+ }
+ if (cur_time > ps->last_time){
+ ps->last_time = cur_time;
+ }
+
/* Free our memory. */
epan_dissect_free(edt);
return TRUE; /* success */
}
-
-
ph_stats_t*
ph_stats_new(void)
{
ps->tot_packets = 0;
ps->tot_bytes = 0;
ps->stats_tree = g_node_new(NULL);
+ ps->first_time = 0.0;
+ ps->last_time = 0.0;
/* Update the progress bar when it gets to this value. */
progbar_nextstep = 0;
probably do so for other loops (see "file.c") that
look only at those packets. */
if (frame->flags.passed_dfilter) {
+
+ if (tot_packets == 0) {
+ double cur_time = secs_usecs(frame->abs_secs,
+ frame->abs_usecs);
+ ps->first_time = cur_time;
+ ps->last_time = cur_time;
+ }
+
if (!process_frame(frame, &cfile.cinfo, ps)) {
/*
* Give up, and set "stop_flag" so we