diff options
author | Sake Blok <sake@euronet.nl> | 2007-10-03 14:02:08 +0000 |
---|---|---|
committer | Sake Blok <sake@euronet.nl> | 2007-10-03 14:02:08 +0000 |
commit | a592e6412ca6ecf71129fbf12a3de46a327239e6 (patch) | |
tree | 1c21dab32b2f4b96276394ee9f42edd7d72a0794 /epan | |
parent | 022aaeb39df43f0a478027101775f6b259525b50 (diff) |
This patch adds two new column types:
- COL_REL_CONV_TIME which is used to display the time relative to the first frame that was seen in the conversation
- COL_DELTA_CONV_TIME which is used to display the delta time from the previous frame of the conversation
It also adds the function "col_set_time()" to "epan/column-utils.[ch]" which can be called from within a dissector to set either of these two columns to the appropiate time.
Last but not least, it lets the tcp-dissector make use of these two columns.
svn path=/trunk/; revision=23058
Diffstat (limited to 'epan')
-rw-r--r-- | epan/column-utils.c | 54 | ||||
-rw-r--r-- | epan/column-utils.h | 14 | ||||
-rw-r--r-- | epan/column.c | 8 | ||||
-rw-r--r-- | epan/column_info.h | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-tcp.c | 28 | ||||
-rw-r--r-- | epan/libwireshark.def | 1 |
6 files changed, 104 insertions, 3 deletions
diff --git a/epan/column-utils.c b/epan/column-utils.c index 3da93a755a..81aa9951dd 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -909,6 +909,56 @@ col_set_cls_time(frame_data *fd, column_info *cinfo, gint col) } } +void +col_set_time(column_info *cinfo, gint el, nstime_t *ts, char *fieldname) +{ + int col; + + g_assert(cinfo->col_first[el] >= 0); + + for (col = cinfo->col_first[el]; col <= cinfo->col_last[el]; col++) { + if (cinfo->fmt_matx[col][el]) { + switch(timestamp_get_precision()) { + case(TS_PREC_FIXED_SEC): + case(TS_PREC_AUTO_SEC): + display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + (gint32) ts->secs, ts->nsecs / 1000000000, SECS); + break; + case(TS_PREC_FIXED_DSEC): + case(TS_PREC_AUTO_DSEC): + display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + (gint32) ts->secs, ts->nsecs / 100000000, DSECS); + break; + case(TS_PREC_FIXED_CSEC): + case(TS_PREC_AUTO_CSEC): + display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + (gint32) ts->secs, ts->nsecs / 10000000, CSECS); + break; + case(TS_PREC_FIXED_MSEC): + case(TS_PREC_AUTO_MSEC): + display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + (gint32) ts->secs, ts->nsecs / 1000000, MSECS); + break; + case(TS_PREC_FIXED_USEC): + case(TS_PREC_AUTO_USEC): + display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + (gint32) ts->secs, ts->nsecs / 1000, USECS); + break; + case(TS_PREC_FIXED_NSEC): + case(TS_PREC_AUTO_NSEC): + display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + (gint32) ts->secs, ts->nsecs, NSECS); + break; + default: + g_assert_not_reached(); + } + cinfo->col_data[col] = cinfo->col_buf[col]; + strcpy(cinfo->col_expr[col],fieldname); + strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]); + } + } +} + static void col_set_addr(packet_info *pinfo, int col, address *addr, gboolean is_res, gboolean is_src) @@ -1200,6 +1250,10 @@ col_fill_in(packet_info *pinfo) col_set_delta_time_dis(pinfo->fd, pinfo->cinfo, i); break; + case COL_REL_CONV_TIME: + case COL_DELTA_CONV_TIME: + break; /* Will be set by various dissectors */ + case COL_DEF_SRC: case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */ col_set_addr(pinfo, i, &pinfo->src, TRUE, TRUE); diff --git a/epan/column-utils.h b/epan/column-utils.h index 141e9ce25d..946df43680 100644 --- a/epan/column-utils.h +++ b/epan/column-utils.h @@ -209,6 +209,20 @@ extern void col_append_sep_fstr(column_info *cinfo, gint col, const gchar *sep, const gchar *format, ...) GNUC_FORMAT_CHECK(printf, 4, 5); +/** Set the given (relative) time to a column element. + * + * Used by multiple dissectors to set the time in the columns + * COL_REL_CONV_TIME and COL_DELTA_CONV_TIME + * + * @param cinfo the current packet row + * @param col the column to use, e.g. COL_INFO + * @param ts the time to set in the column + * @param fieldname the fieldname to use for creating a filter (when + * applying/preparing/copying as filter) + */ +extern void col_set_time(column_info *cinfo, int col, + nstime_t *ts, char *fieldname); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/epan/column.c b/epan/column.c index 6a9a386490..7afaded3e3 100644 --- a/epan/column.c +++ b/epan/column.c @@ -55,6 +55,8 @@ col_format_to_string(gint fmt) { "%Yt", "%Tt", "%Gt", + "%rct", + "%dct", "%s", "%rs", "%us", @@ -122,6 +124,8 @@ static const gchar *dlist[NUM_COL_FMTS] = { "Absolute date and time", /* COL_ABS_DATE_TIME */ "Delta time", /* COL_DELTA_TIME */ "Delta time displayed", /* COL_DELTA_TIME_DIS */ + "Relative time (conversation)", /* COL_REL_CONV_TIME */ + "Delta time (conversation)", /* COL_DELTA_CONV_TIME */ "Source address", /* COL_DEF_SRC */ "Src addr (resolved)", /* COL_RES_SRC */ "Src addr (unresolved)", /* COL_UNRES_SRC */ @@ -490,6 +494,10 @@ get_column_longest_string(gint format) case COL_DELTA_TIME_DIS: return get_timestamp_column_longest_string(TS_DELTA_DIS, timestamp_get_precision()); break; + case COL_REL_CONV_TIME: /* 'abuse' TS_RELATIVE to set the time format */ + case COL_DELTA_CONV_TIME: /* for the conversation related time columns */ + return get_timestamp_column_longest_string(TS_RELATIVE, timestamp_get_precision()); + break; case COL_DEF_SRC: case COL_RES_SRC: case COL_UNRES_SRC: diff --git a/epan/column_info.h b/epan/column_info.h index 5b8bd64c7f..a355797b99 100644 --- a/epan/column_info.h +++ b/epan/column_info.h @@ -64,6 +64,8 @@ enum { COL_ABS_DATE_TIME, /* Absolute date and time */ COL_DELTA_TIME, /* Delta time */ COL_DELTA_TIME_DIS, /* Delta time displayed*/ + COL_REL_CONV_TIME, /* Relative time to beginning of conversation */ + COL_DELTA_CONV_TIME,/* Delta time to last frame in conversation */ COL_DEF_SRC, /* Source address */ COL_RES_SRC, /* Resolved source */ COL_UNRES_SRC, /* Unresolved source */ diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index 3b45d2860d..57ee3f334b 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -2491,6 +2491,7 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) struct tcp_per_packet_data_t *tcppd=NULL; proto_item *item; proto_tree *checksum_tree; + nstime_t ts; tcph=ep_alloc(sizeof(struct tcpheader)); @@ -2565,9 +2566,30 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* find(or create if needed) the conversation for this tcp session */ tcpd=get_tcp_conversation_data(pinfo); - /* Calculate the timestamps relative to this conversation */ - if(!(pinfo->fd->flags.visited) && tcp_calculate_ts){ - tcp_calculate_timestamps(pinfo, tcpd, tcppd); + /* Do we need to calculate timestamps relative to the tcp-stream? */ + if (tcp_calculate_ts) { + + /* + * Calculate the timestamps relative to this conversation (but only on the + * first run when frames are accessed sequentially) + */ + if (!(pinfo->fd->flags.visited)) + tcp_calculate_timestamps(pinfo, tcpd, tcppd); + + + /* Fill the conversation timestamp columns */ + if (check_col(pinfo->cinfo, COL_REL_CONV_TIME)) { + nstime_delta(&ts, &pinfo->fd->abs_ts, &tcpd->ts_first); + col_set_time(pinfo->cinfo, COL_REL_CONV_TIME, &ts, "tcp.time_relative"); + } + + if (check_col(pinfo->cinfo, COL_DELTA_CONV_TIME)) { + if( !tcppd ) + tcppd = p_get_proto_data(pinfo->fd, proto_tcp); + + if( tcppd ) + col_set_time(pinfo->cinfo, COL_DELTA_CONV_TIME, &tcppd->ts_del, "tcp.time_delta"); + } } diff --git a/epan/libwireshark.def b/epan/libwireshark.def index 5fa25162ba..b88d041423 100644 --- a/epan/libwireshark.def +++ b/epan/libwireshark.def @@ -82,6 +82,7 @@ col_setup col_set_cls_time col_set_fence col_set_str +col_set_time col_set_writable CommandCode_vals DATA conversation_add_proto_data |