From b9ce30cd35b1a499c38b34b51900c7a6d195fd9d Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Wed, 3 Sep 2003 10:49:03 +0000 Subject: [PATCH] And for Cal, Ethereal presents a column to display culmulative bytes into the capture. A new column type is added : Culmulative Bytes. While PacketLength column type specifies the number of bytes in the current packet, Culmulative Bytes specifies the culmulative number of bytes from the start of the capture. svn path=/trunk/; revision=8359 --- column.c | 13 +++++++++++-- epan/column-utils.c | 6 +++++- epan/column_info.h | 3 ++- epan/frame_data.h | 3 ++- file.c | 7 ++++++- gtk/main.c | 4 ++-- tethereal.c | 5 ++++- 7 files changed, 32 insertions(+), 9 deletions(-) diff --git a/column.c b/column.c index cc4a8e11a7..5a9616222d 100644 --- a/column.c +++ b/column.c @@ -1,7 +1,7 @@ /* column.c * Routines for handling column preferences * - * $Id: column.c,v 1.42 2003/01/27 20:45:42 guy Exp $ + * $Id: column.c,v 1.43 2003/09/03 10:49:01 sahlberg Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -52,7 +52,8 @@ col_format_to_string(gint fmt) { "%us","%hs", "%rhs", "%uhs", "%ns", "%rns", "%uns", "%d", "%rd", "%ud", "%hd", "%rhd", "%uhd", "%nd", "%rnd", "%und", "%S", "%rS", "%uS", "%D", "%rD", "%uD", "%p", - "%i", "%L", "%XO", "%XR", "%I", "%c", "%Xs", "%Xd", "%V" }; + "%i", "%L", "%B", "%XO", "%XR", "%I", "%c", "%Xs", + "%Xd", "%V" }; if (fmt < 0 || fmt > NUM_COL_FMTS) return NULL; @@ -96,6 +97,7 @@ static gchar *dlist[NUM_COL_FMTS] = { "Protocol", "Information", "Packet length (bytes)" , + "Culmulative Bytes" , "OXID", "RXID", "FW-1 monitor if/direction", @@ -261,6 +263,9 @@ get_column_longest_string(gint format) case COL_PACKET_LENGTH: return "000000"; break; + case COL_CULMULATIVE_BYTES: + return "00000000"; + break; case COL_RXID: case COL_OXID: return "000000"; @@ -309,6 +314,7 @@ get_column_resize_type(gint format) { case COL_UNRES_DST_PORT: case COL_PROTOCOL: case COL_PACKET_LENGTH: + case COL_CULMULATIVE_BYTES: case COL_IF_DIR: case COL_CIRCUIT_ID: /* We don't want these to resize during a live capture, as that @@ -453,6 +459,9 @@ get_column_format_from_str(gchar *str) { case 'L': return COL_PACKET_LENGTH; break; + case 'B': + return COL_CULMULATIVE_BYTES; + break; case 'X': prev_code = COL_OXID; break; diff --git a/epan/column-utils.c b/epan/column-utils.c index 3b6634af2b..9f68dda50b 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -1,7 +1,7 @@ /* column-utils.c * Routines for column utilities. * - * $Id: column-utils.c,v 1.37 2003/08/26 06:40:25 guy Exp $ + * $Id: column-utils.c,v 1.38 2003/09/03 10:49:02 sahlberg Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -830,6 +830,10 @@ fill_in_columns(packet_info *pinfo) strcpy(pinfo->cinfo->col_expr[i], "frame.pkt_len"); strcpy(pinfo->cinfo->col_expr_val[i], pinfo->cinfo->col_buf[i]); break; + case COL_CULMULATIVE_BYTES: + snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "%u", pinfo->fd->cul_bytes); + pinfo->cinfo->col_data[i] = pinfo->cinfo->col_buf[i]; + break; case COL_OXID: snprintf(pinfo->cinfo->col_buf[i], COL_MAX_LEN, "0x%x", pinfo->oxid); diff --git a/epan/column_info.h b/epan/column_info.h index 8498fd1bba..2d3a1e9b65 100644 --- a/epan/column_info.h +++ b/epan/column_info.h @@ -1,7 +1,7 @@ /* column.h * Definitions for column structures and routines * - * $Id: column_info.h,v 1.8 2003/04/16 04:52:53 guy Exp $ + * $Id: column_info.h,v 1.9 2003/09/03 10:49:02 sahlberg Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -84,6 +84,7 @@ enum { COL_PROTOCOL, /* Protocol */ COL_INFO, /* Description */ COL_PACKET_LENGTH, /* Packet length in bytes */ + COL_CULMULATIVE_BYTES, /* Culmulative number of bytes */ COL_OXID, /* Fibre Channel OXID */ COL_RXID, /* Fibre Channel RXID */ COL_IF_DIR, /* FW-1 monitor interface/direction */ diff --git a/epan/frame_data.h b/epan/frame_data.h index d2009e4275..fc68f0b6d9 100644 --- a/epan/frame_data.h +++ b/epan/frame_data.h @@ -1,7 +1,7 @@ /* frame_data.h * Definitions for frame_data structures and routines * - * $Id: frame_data.h,v 1.8 2003/07/08 05:29:42 tpot Exp $ + * $Id: frame_data.h,v 1.9 2003/09/03 10:49:02 sahlberg Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -38,6 +38,7 @@ typedef struct _frame_data { guint32 num; /* Frame number */ guint32 pkt_len; /* Packet length */ guint32 cap_len; /* Amount actually captured */ + guint32 cul_bytes; /* Culmulative bytes into the capture */ gint32 rel_secs; /* Relative seconds (yes, it can be negative) */ gint32 rel_usecs; /* Relative microseconds (yes, it can be negative) */ guint32 abs_secs; /* Absolute seconds */ diff --git a/file.c b/file.c index 53d74b0969..20310aa4cd 100644 --- a/file.c +++ b/file.c @@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.304 2003/08/29 04:03:45 guy Exp $ + * $Id: file.c,v 1.305 2003/09/03 10:49:01 sahlberg Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -92,6 +92,7 @@ gboolean auto_scroll_live; static guint32 firstsec, firstusec; static guint32 prevsec, prevusec; +static guint32 cul_bytes = 0; static void read_packet(capture_file *cf, long offset); @@ -351,6 +352,7 @@ read_cap_file(capture_file *cf, int *err) GTimeVal start_time; gchar status_str[100]; + cul_bytes=0; reset_tap_listeners(); name_ptr = get_basename(cf->filename); @@ -838,6 +840,8 @@ read_packet(capture_file *cf, long offset) fdata->prev = NULL; fdata->pfd = NULL; fdata->pkt_len = phdr->len; + cul_bytes += phdr->len; + fdata->cul_bytes = cul_bytes; fdata->cap_len = phdr->caplen; fdata->file_off = offset; fdata->lnk_t = phdr->pkt_encap; @@ -968,6 +972,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, GTimeVal start_time; gchar status_str[100]; + cul_bytes=0; reset_tap_listeners(); /* Which frame, if any, is the currently selected frame? XXX - should the selected frame or the focus frame be the "current" diff --git a/gtk/main.c b/gtk/main.c index 54cf3767f4..8cbe7080eb 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.307 2003/08/28 20:33:14 oabad Exp $ + * $Id: main.c,v 1.308 2003/09/03 10:49:03 sahlberg Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -660,7 +660,7 @@ packet_list_compare(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2) (col_fmt == COL_UNRES_SRC_PORT) || (col_fmt == COL_UNRES_DST_PORT) || ((num1 != 0) && (num2 != 0) && ((col_fmt == COL_DEF_SRC_PORT) || (col_fmt == COL_RES_SRC_PORT) || (col_fmt == COL_DEF_DST_PORT) || (col_fmt == COL_RES_DST_PORT))) || - (col_fmt == COL_PACKET_LENGTH)) { + (col_fmt == COL_PACKET_LENGTH) || (col_fmt == COL_CULMULATIVE_BYTES)) { /* Compare numeric column */ diff --git a/tethereal.c b/tethereal.c index c6dfa7a4e0..ca7cde4858 100644 --- a/tethereal.c +++ b/tethereal.c @@ -1,6 +1,6 @@ /* tethereal.c * - * $Id: tethereal.c,v 1.191 2003/08/07 00:41:27 guy Exp $ + * $Id: tethereal.c,v 1.192 2003/09/03 10:49:02 sahlberg Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -116,6 +116,7 @@ static gboolean decode; static gboolean verbose; static gboolean print_hex; static gboolean line_buffered; +static guint32 cul_bytes = 0; #ifdef HAVE_LIBPCAP typedef struct _loop_data { @@ -2031,6 +2032,8 @@ fill_in_fdata(frame_data *fdata, capture_file *cf, fdata->pfd = NULL; fdata->num = cf->count; fdata->pkt_len = phdr->len; + cul_bytes += phdr->len; + fdata->cul_bytes = cul_bytes; fdata->cap_len = phdr->caplen; fdata->file_off = offset; fdata->lnk_t = phdr->pkt_encap;