forked from osmocom/wireshark
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
This commit is contained in:
parent
022aaeb39d
commit
a592e6412c
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue