forked from osmocom/wireshark
Added an option to display seconds as hours, minutes and seconds
in the packet list, on this format: "1h 2m 3.456s". svn path=/trunk/; revision=32683
This commit is contained in:
parent
7ff0da2933
commit
6efcb1adf0
|
@ -613,8 +613,8 @@ set_abs_date_time(const frame_data *fd, gchar *buf)
|
|||
tmp = localtime(&then);
|
||||
if (tmp != NULL) {
|
||||
switch(timestamp_get_precision()) {
|
||||
case(TS_PREC_FIXED_SEC):
|
||||
case(TS_PREC_AUTO_SEC):
|
||||
case TS_PREC_FIXED_SEC:
|
||||
case TS_PREC_AUTO_SEC:
|
||||
g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d",
|
||||
tmp->tm_year + 1900,
|
||||
tmp->tm_mon + 1,
|
||||
|
@ -623,8 +623,8 @@ set_abs_date_time(const frame_data *fd, gchar *buf)
|
|||
tmp->tm_min,
|
||||
tmp->tm_sec);
|
||||
break;
|
||||
case(TS_PREC_FIXED_DSEC):
|
||||
case(TS_PREC_AUTO_DSEC):
|
||||
case TS_PREC_FIXED_DSEC:
|
||||
case TS_PREC_AUTO_DSEC:
|
||||
g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d.%01ld",
|
||||
tmp->tm_year + 1900,
|
||||
tmp->tm_mon + 1,
|
||||
|
@ -634,8 +634,8 @@ set_abs_date_time(const frame_data *fd, gchar *buf)
|
|||
tmp->tm_sec,
|
||||
(long)fd->abs_ts.nsecs / 100000000);
|
||||
break;
|
||||
case(TS_PREC_FIXED_CSEC):
|
||||
case(TS_PREC_AUTO_CSEC):
|
||||
case TS_PREC_FIXED_CSEC:
|
||||
case TS_PREC_AUTO_CSEC:
|
||||
g_snprintf(buf, COL_MAX_LEN,"%04d-%02d-%02d %02d:%02d:%02d.%02ld",
|
||||
tmp->tm_year + 1900,
|
||||
tmp->tm_mon + 1,
|
||||
|
@ -645,8 +645,8 @@ set_abs_date_time(const frame_data *fd, gchar *buf)
|
|||
tmp->tm_sec,
|
||||
(long)fd->abs_ts.nsecs / 10000000);
|
||||
break;
|
||||
case(TS_PREC_FIXED_MSEC):
|
||||
case(TS_PREC_AUTO_MSEC):
|
||||
case TS_PREC_FIXED_MSEC:
|
||||
case TS_PREC_AUTO_MSEC:
|
||||
g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%03ld",
|
||||
tmp->tm_year + 1900,
|
||||
tmp->tm_mon + 1,
|
||||
|
@ -656,8 +656,8 @@ set_abs_date_time(const frame_data *fd, gchar *buf)
|
|||
tmp->tm_sec,
|
||||
(long)fd->abs_ts.nsecs / 1000000);
|
||||
break;
|
||||
case(TS_PREC_FIXED_USEC):
|
||||
case(TS_PREC_AUTO_USEC):
|
||||
case TS_PREC_FIXED_USEC:
|
||||
case TS_PREC_AUTO_USEC:
|
||||
g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%06ld",
|
||||
tmp->tm_year + 1900,
|
||||
tmp->tm_mon + 1,
|
||||
|
@ -667,8 +667,8 @@ set_abs_date_time(const frame_data *fd, gchar *buf)
|
|||
tmp->tm_sec,
|
||||
(long)fd->abs_ts.nsecs / 1000);
|
||||
break;
|
||||
case(TS_PREC_FIXED_NSEC):
|
||||
case(TS_PREC_AUTO_NSEC):
|
||||
case TS_PREC_FIXED_NSEC:
|
||||
case TS_PREC_AUTO_NSEC:
|
||||
g_snprintf(buf, COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%09ld",
|
||||
tmp->tm_year + 1900,
|
||||
tmp->tm_mon + 1,
|
||||
|
@ -698,38 +698,38 @@ col_set_abs_date_time(const frame_data *fd, column_info *cinfo, const int col)
|
|||
}
|
||||
|
||||
static gint
|
||||
set_rel_time(const frame_data *fd, gchar *buf)
|
||||
set_time_seconds(const nstime_t *ts, gchar *buf)
|
||||
{
|
||||
switch(timestamp_get_precision()) {
|
||||
case(TS_PREC_FIXED_SEC):
|
||||
case(TS_PREC_AUTO_SEC):
|
||||
case TS_PREC_FIXED_SEC:
|
||||
case TS_PREC_AUTO_SEC:
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
|
||||
(gint32) ts->secs, ts->nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_DSEC):
|
||||
case(TS_PREC_AUTO_DSEC):
|
||||
case TS_PREC_FIXED_DSEC:
|
||||
case TS_PREC_AUTO_DSEC:
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
|
||||
(gint32) ts->secs, ts->nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_CSEC):
|
||||
case(TS_PREC_AUTO_CSEC):
|
||||
case TS_PREC_FIXED_CSEC:
|
||||
case TS_PREC_AUTO_CSEC:
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
|
||||
(gint32) ts->secs, ts->nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_MSEC):
|
||||
case(TS_PREC_AUTO_MSEC):
|
||||
case TS_PREC_FIXED_MSEC:
|
||||
case TS_PREC_AUTO_MSEC:
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
|
||||
(gint32) ts->secs, ts->nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_USEC):
|
||||
case(TS_PREC_AUTO_USEC):
|
||||
case TS_PREC_FIXED_USEC:
|
||||
case TS_PREC_AUTO_USEC:
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->rel_ts.secs, fd->rel_ts.nsecs / 1000, TO_STR_TIME_RES_T_USECS);
|
||||
(gint32) ts->secs, ts->nsecs / 1000, TO_STR_TIME_RES_T_USECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_NSEC):
|
||||
case(TS_PREC_AUTO_NSEC):
|
||||
case TS_PREC_FIXED_NSEC:
|
||||
case TS_PREC_AUTO_NSEC:
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->rel_ts.secs, fd->rel_ts.nsecs, TO_STR_TIME_RES_T_NSECS);
|
||||
(gint32) ts->secs, ts->nsecs, TO_STR_TIME_RES_T_NSECS);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
|
@ -737,113 +737,193 @@ set_rel_time(const frame_data *fd, gchar *buf)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static gint
|
||||
set_time_hour_min_sec(const nstime_t *ts, gchar *buf)
|
||||
{
|
||||
switch(timestamp_get_precision()) {
|
||||
case TS_PREC_FIXED_SEC:
|
||||
case TS_PREC_AUTO_SEC:
|
||||
if (ts->secs >= (60*60)) {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%dh %dm %ds",
|
||||
(gint32) ts->secs / (60 * 60),
|
||||
(gint32) (ts->secs / 60) % 60,
|
||||
(gint32) ts->secs % 60);
|
||||
} else if (ts->secs >= 60) {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%dh %ds",
|
||||
(gint32) (ts->secs / 60),
|
||||
(gint32) ts->secs % 60);
|
||||
} else {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%ds",
|
||||
(gint32) ts->secs);
|
||||
}
|
||||
break;
|
||||
case TS_PREC_FIXED_DSEC:
|
||||
case TS_PREC_AUTO_DSEC:
|
||||
if (ts->secs >= (60*60)) {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%dh %dm %d.%01lds",
|
||||
(gint32) ts->secs / (60 * 60),
|
||||
(gint32) (ts->secs / 60) % 60,
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs / 100000000);
|
||||
} else if (ts->secs >= 60) {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%dm %d.%01lds",
|
||||
(gint32) (ts->secs / 60) % 60,
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs / 100000000);
|
||||
} else {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%d.%01lds",
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs / 100000000);
|
||||
}
|
||||
break;
|
||||
case TS_PREC_FIXED_CSEC:
|
||||
case TS_PREC_AUTO_CSEC:
|
||||
if (ts->secs >= (60*60)) {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%dh %dm %d.%02lds",
|
||||
(gint32) ts->secs / (60 * 60),
|
||||
(gint32) (ts->secs / 60) % 60,
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs / 10000000);
|
||||
} else if (ts->secs >= 60) {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%dm %d.%02lds",
|
||||
(gint32) (ts->secs / 60) % 60,
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs / 10000000);
|
||||
} else {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%d.%02lds",
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs / 10000000);
|
||||
}
|
||||
break;
|
||||
case TS_PREC_FIXED_MSEC:
|
||||
case TS_PREC_AUTO_MSEC:
|
||||
if (ts->secs >= (60*60)) {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%dh %dm %d.%03lds",
|
||||
(gint32) ts->secs / (60 * 60),
|
||||
(gint32) (ts->secs / 60) % 60,
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs / 1000000);
|
||||
} else if (ts->secs >= 60) {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%dm %d.%03lds",
|
||||
(gint32) (ts->secs / 60) % 60,
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs / 1000000);
|
||||
} else {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%d.%03lds",
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs / 1000000);
|
||||
}
|
||||
break;
|
||||
case TS_PREC_FIXED_USEC:
|
||||
case TS_PREC_AUTO_USEC:
|
||||
if (ts->secs >= (60*60)) {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%dh %dm %d.%06lds",
|
||||
(gint32) ts->secs / (60 * 60),
|
||||
(gint32) (ts->secs / 60) % 60,
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs / 1000);
|
||||
} else if (ts->secs >= 60) {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%dm %d.%06lds",
|
||||
(gint32) (ts->secs / 60) % 60,
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs / 1000);
|
||||
} else {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%d.%06lds",
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs / 1000);
|
||||
}
|
||||
break;
|
||||
case TS_PREC_FIXED_NSEC:
|
||||
case TS_PREC_AUTO_NSEC:
|
||||
if (ts->secs >= (60*60)) {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%dh %dm %d.%09lds",
|
||||
(gint32) ts->secs / (60 * 60),
|
||||
(gint32) (ts->secs / 60) % 60,
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs);
|
||||
} else if (ts->secs >= 60) {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%dm %d.%09lds",
|
||||
(gint32) (ts->secs / 60) % 60,
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs);
|
||||
} else {
|
||||
g_snprintf(buf, COL_MAX_LEN,"%d.%09lds",
|
||||
(gint32) ts->secs % 60,
|
||||
(long)ts->nsecs);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
col_set_rel_time(const frame_data *fd, column_info *cinfo, const int col)
|
||||
{
|
||||
if (set_rel_time(fd, cinfo->col_buf[col])) {
|
||||
switch (timestamp_get_seconds_type()) {
|
||||
case TS_SECONDS_DEFAULT:
|
||||
if (set_time_seconds(&fd->rel_ts, cinfo->col_buf[col])) {
|
||||
cinfo->col_expr.col_expr[col] = "frame.time_relative";
|
||||
g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
|
||||
}
|
||||
break;
|
||||
case TS_SECONDS_HOUR_MIN_SEC:
|
||||
if (set_time_hour_min_sec(&fd->rel_ts, cinfo->col_buf[col])) {
|
||||
cinfo->col_expr.col_expr[col] = "frame.time_relative";
|
||||
set_time_seconds(&fd->rel_ts, cinfo->col_expr.col_expr_val[col]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
cinfo->col_data[col] = cinfo->col_buf[col];
|
||||
}
|
||||
|
||||
static gint
|
||||
set_delta_time(const frame_data *fd, gchar *buf)
|
||||
{
|
||||
switch(timestamp_get_precision()) {
|
||||
case(TS_PREC_FIXED_SEC):
|
||||
case(TS_PREC_AUTO_SEC):
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_DSEC):
|
||||
case(TS_PREC_AUTO_DSEC):
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_CSEC):
|
||||
case(TS_PREC_AUTO_CSEC):
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_MSEC):
|
||||
case(TS_PREC_AUTO_MSEC):
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_USEC):
|
||||
case(TS_PREC_AUTO_USEC):
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs / 1000, TO_STR_TIME_RES_T_USECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_NSEC):
|
||||
case(TS_PREC_AUTO_NSEC):
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->del_cap_ts.secs, fd->del_cap_ts.nsecs, TO_STR_TIME_RES_T_NSECS);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
col_set_delta_time(const frame_data *fd, column_info *cinfo, const int col)
|
||||
{
|
||||
if (set_delta_time(fd, cinfo->col_buf[col])) {
|
||||
switch (timestamp_get_seconds_type()) {
|
||||
case TS_SECONDS_DEFAULT:
|
||||
if (set_time_seconds(&fd->del_cap_ts, cinfo->col_buf[col])) {
|
||||
cinfo->col_expr.col_expr[col] = "frame.time_delta";
|
||||
g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
|
||||
}
|
||||
break;
|
||||
case TS_SECONDS_HOUR_MIN_SEC:
|
||||
if (set_time_hour_min_sec(&fd->del_cap_ts, cinfo->col_buf[col])) {
|
||||
cinfo->col_expr.col_expr[col] = "frame.time_delta";
|
||||
set_time_seconds(&fd->del_cap_ts, cinfo->col_expr.col_expr_val[col]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
cinfo->col_data[col] = cinfo->col_buf[col];
|
||||
}
|
||||
|
||||
static gint
|
||||
set_delta_time_dis(const frame_data *fd, gchar *buf)
|
||||
{
|
||||
switch(timestamp_get_precision()) {
|
||||
case(TS_PREC_FIXED_SEC):
|
||||
case(TS_PREC_AUTO_SEC):
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_DSEC):
|
||||
case(TS_PREC_AUTO_DSEC):
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_CSEC):
|
||||
case(TS_PREC_AUTO_CSEC):
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_MSEC):
|
||||
case(TS_PREC_AUTO_MSEC):
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_USEC):
|
||||
case(TS_PREC_AUTO_USEC):
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs / 1000, TO_STR_TIME_RES_T_USECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_NSEC):
|
||||
case(TS_PREC_AUTO_NSEC):
|
||||
display_signed_time(buf, COL_MAX_LEN,
|
||||
(gint32) fd->del_dis_ts.secs, fd->del_dis_ts.nsecs, TO_STR_TIME_RES_T_NSECS);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
return 1;
|
||||
cinfo->col_data[col] = cinfo->col_buf[col];
|
||||
}
|
||||
|
||||
static void
|
||||
col_set_delta_time_dis(const frame_data *fd, column_info *cinfo, const int col)
|
||||
{
|
||||
if (set_delta_time_dis(fd, cinfo->col_buf[col])) {
|
||||
cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed";
|
||||
g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
|
||||
switch (timestamp_get_seconds_type()) {
|
||||
case TS_SECONDS_DEFAULT:
|
||||
if (set_time_seconds(&fd->del_dis_ts, cinfo->col_buf[col])) {
|
||||
cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed";
|
||||
g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
|
||||
}
|
||||
break;
|
||||
case TS_SECONDS_HOUR_MIN_SEC:
|
||||
if (set_time_hour_min_sec(&fd->del_dis_ts, cinfo->col_buf[col])) {
|
||||
cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed";
|
||||
set_time_seconds(&fd->del_dis_ts, cinfo->col_expr.col_expr_val[col]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
cinfo->col_data[col] = cinfo->col_buf[col];
|
||||
}
|
||||
|
||||
|
@ -857,47 +937,47 @@ set_abs_time(const frame_data *fd, gchar *buf)
|
|||
tmp = localtime(&then);
|
||||
if (tmp != NULL) {
|
||||
switch(timestamp_get_precision()) {
|
||||
case(TS_PREC_FIXED_SEC):
|
||||
case(TS_PREC_AUTO_SEC):
|
||||
case TS_PREC_FIXED_SEC:
|
||||
case TS_PREC_AUTO_SEC:
|
||||
g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d",
|
||||
tmp->tm_hour,
|
||||
tmp->tm_min,
|
||||
tmp->tm_sec);
|
||||
break;
|
||||
case(TS_PREC_FIXED_DSEC):
|
||||
case(TS_PREC_AUTO_DSEC):
|
||||
case TS_PREC_FIXED_DSEC:
|
||||
case TS_PREC_AUTO_DSEC:
|
||||
g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%01ld",
|
||||
tmp->tm_hour,
|
||||
tmp->tm_min,
|
||||
tmp->tm_sec,
|
||||
(long)fd->abs_ts.nsecs / 100000000);
|
||||
break;
|
||||
case(TS_PREC_FIXED_CSEC):
|
||||
case(TS_PREC_AUTO_CSEC):
|
||||
case TS_PREC_FIXED_CSEC:
|
||||
case TS_PREC_AUTO_CSEC:
|
||||
g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%02ld",
|
||||
tmp->tm_hour,
|
||||
tmp->tm_min,
|
||||
tmp->tm_sec,
|
||||
(long)fd->abs_ts.nsecs / 10000000);
|
||||
break;
|
||||
case(TS_PREC_FIXED_MSEC):
|
||||
case(TS_PREC_AUTO_MSEC):
|
||||
case TS_PREC_FIXED_MSEC:
|
||||
case TS_PREC_AUTO_MSEC:
|
||||
g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%03ld",
|
||||
tmp->tm_hour,
|
||||
tmp->tm_min,
|
||||
tmp->tm_sec,
|
||||
(long)fd->abs_ts.nsecs / 1000000);
|
||||
break;
|
||||
case(TS_PREC_FIXED_USEC):
|
||||
case(TS_PREC_AUTO_USEC):
|
||||
case TS_PREC_FIXED_USEC:
|
||||
case TS_PREC_AUTO_USEC:
|
||||
g_snprintf(buf, COL_MAX_LEN,"%02d:%02d:%02d.%06ld",
|
||||
tmp->tm_hour,
|
||||
tmp->tm_min,
|
||||
tmp->tm_sec,
|
||||
(long)fd->abs_ts.nsecs / 1000);
|
||||
break;
|
||||
case(TS_PREC_FIXED_NSEC):
|
||||
case(TS_PREC_AUTO_NSEC):
|
||||
case TS_PREC_FIXED_NSEC:
|
||||
case TS_PREC_AUTO_NSEC:
|
||||
g_snprintf(buf, COL_MAX_LEN, "%02d:%02d:%02d.%09ld",
|
||||
tmp->tm_hour,
|
||||
tmp->tm_min,
|
||||
|
@ -928,33 +1008,33 @@ static gint
|
|||
set_epoch_time(const frame_data *fd, gchar *buf)
|
||||
{
|
||||
switch(timestamp_get_precision()) {
|
||||
case(TS_PREC_FIXED_SEC):
|
||||
case(TS_PREC_AUTO_SEC):
|
||||
case TS_PREC_FIXED_SEC:
|
||||
case TS_PREC_AUTO_SEC:
|
||||
display_epoch_time(buf, COL_MAX_LEN,
|
||||
fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000000, TO_STR_TIME_RES_T_SECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_DSEC):
|
||||
case(TS_PREC_AUTO_DSEC):
|
||||
case TS_PREC_FIXED_DSEC:
|
||||
case TS_PREC_AUTO_DSEC:
|
||||
display_epoch_time(buf, COL_MAX_LEN,
|
||||
fd->abs_ts.secs, fd->abs_ts.nsecs / 100000000, TO_STR_TIME_RES_T_DSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_CSEC):
|
||||
case(TS_PREC_AUTO_CSEC):
|
||||
case TS_PREC_FIXED_CSEC:
|
||||
case TS_PREC_AUTO_CSEC:
|
||||
display_epoch_time(buf, COL_MAX_LEN,
|
||||
fd->abs_ts.secs, fd->abs_ts.nsecs / 10000000, TO_STR_TIME_RES_T_CSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_MSEC):
|
||||
case(TS_PREC_AUTO_MSEC):
|
||||
case TS_PREC_FIXED_MSEC:
|
||||
case TS_PREC_AUTO_MSEC:
|
||||
display_epoch_time(buf, COL_MAX_LEN,
|
||||
fd->abs_ts.secs, fd->abs_ts.nsecs / 1000000, TO_STR_TIME_RES_T_MSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_USEC):
|
||||
case(TS_PREC_AUTO_USEC):
|
||||
case TS_PREC_FIXED_USEC:
|
||||
case TS_PREC_AUTO_USEC:
|
||||
display_epoch_time(buf, COL_MAX_LEN,
|
||||
fd->abs_ts.secs, fd->abs_ts.nsecs / 1000, TO_STR_TIME_RES_T_USECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_NSEC):
|
||||
case(TS_PREC_AUTO_NSEC):
|
||||
case TS_PREC_FIXED_NSEC:
|
||||
case TS_PREC_AUTO_NSEC:
|
||||
display_epoch_time(buf, COL_MAX_LEN,
|
||||
fd->abs_ts.secs, fd->abs_ts.nsecs, TO_STR_TIME_RES_T_NSECS);
|
||||
break;
|
||||
|
@ -1114,33 +1194,33 @@ col_set_time(column_info *cinfo, const gint el, const nstime_t *ts, char *fieldn
|
|||
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):
|
||||
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, TO_STR_TIME_RES_T_SECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_DSEC):
|
||||
case(TS_PREC_AUTO_DSEC):
|
||||
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, TO_STR_TIME_RES_T_DSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_CSEC):
|
||||
case(TS_PREC_AUTO_CSEC):
|
||||
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, TO_STR_TIME_RES_T_CSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_MSEC):
|
||||
case(TS_PREC_AUTO_MSEC):
|
||||
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, TO_STR_TIME_RES_T_MSECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_USEC):
|
||||
case(TS_PREC_AUTO_USEC):
|
||||
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, TO_STR_TIME_RES_T_USECS);
|
||||
break;
|
||||
case(TS_PREC_FIXED_NSEC):
|
||||
case(TS_PREC_AUTO_NSEC):
|
||||
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, TO_STR_TIME_RES_T_NSECS);
|
||||
break;
|
||||
|
|
|
@ -984,8 +984,10 @@ time_msecs_to_str
|
|||
time_secs_to_str
|
||||
timestamp_get_precision
|
||||
timestamp_get_type
|
||||
timestamp_get_seconds_type
|
||||
timestamp_set_precision
|
||||
timestamp_set_type
|
||||
timestamp_set_seconds_type
|
||||
trans2_cmd_vals DATA
|
||||
tree_is_expanded DATA
|
||||
tvb_bytes_exist
|
||||
|
|
|
@ -34,6 +34,8 @@ static ts_type timestamp_type = TS_NOT_SET;
|
|||
|
||||
static int timestamp_precision = TS_PREC_AUTO_USEC;
|
||||
|
||||
static ts_seconds_type timestamp_seconds_type = TS_SECONDS_NOT_SET;
|
||||
|
||||
ts_type timestamp_get_type(void)
|
||||
{
|
||||
return timestamp_type;
|
||||
|
@ -55,3 +57,13 @@ void timestamp_set_precision(int tsp)
|
|||
timestamp_precision = tsp;
|
||||
}
|
||||
|
||||
|
||||
ts_seconds_type timestamp_get_seconds_type(void)
|
||||
{
|
||||
return timestamp_seconds_type;
|
||||
}
|
||||
|
||||
void timestamp_set_seconds_type(ts_seconds_type ts_t)
|
||||
{
|
||||
timestamp_seconds_type = ts_t;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ typedef enum {
|
|||
TS_PREC_FIXED_SEC, /* recent and internal */
|
||||
TS_PREC_FIXED_DSEC, /* recent and internal */
|
||||
TS_PREC_FIXED_CSEC, /* recent and internal */
|
||||
TS_PREC_FIXED_MSEC, /* recent and internal */
|
||||
TS_PREC_FIXED_MSEC, /* recent and internal */
|
||||
TS_PREC_FIXED_USEC, /* recent and internal */
|
||||
TS_PREC_FIXED_NSEC, /* recent and internal */
|
||||
TS_PREC_AUTO_SEC, /* internal */
|
||||
|
@ -59,10 +59,24 @@ typedef enum {
|
|||
TS_PREC_AUTO_NSEC /* internal */
|
||||
} ts_precision;
|
||||
|
||||
typedef enum {
|
||||
TS_SECONDS_DEFAULT, /* recent */
|
||||
TS_SECONDS_HOUR_MIN_SEC,/* recent */
|
||||
|
||||
/*
|
||||
* Special value used for the command-line setting in Wireshark, to indicate
|
||||
* that no value has been set from the command line.
|
||||
*/
|
||||
TS_SECONDS_NOT_SET
|
||||
} ts_seconds_type;
|
||||
|
||||
extern ts_type timestamp_get_type(void);
|
||||
extern void timestamp_set_type(ts_type);
|
||||
|
||||
extern int timestamp_get_precision(void);
|
||||
extern void timestamp_set_precision(int tsp);
|
||||
|
||||
extern ts_seconds_type timestamp_get_seconds_type(void);
|
||||
extern void timestamp_set_seconds_type(ts_seconds_type);
|
||||
|
||||
#endif /* timestamp.h */
|
||||
|
|
14
gtk/main.c
14
gtk/main.c
|
@ -2018,7 +2018,7 @@ main(int argc, char *argv[])
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#define OPTSTRING_INIT "a:b:c:C:Df:g:Hhi:jJ:kK:lLm:nN:o:P:pQr:R:Ss:t:vw:X:y:z:"
|
||||
#define OPTSTRING_INIT "a:b:c:C:Df:g:Hhi:jJ:kK:lLm:nN:o:P:pQr:R:Ss:t:T:vw:X:y:z:"
|
||||
|
||||
#if defined HAVE_LIBPCAP && defined _WIN32
|
||||
#define OPTSTRING_WIN32 "B:"
|
||||
|
@ -2542,6 +2542,17 @@ main(int argc, char *argv[])
|
|||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'T': /* Seconds type */
|
||||
if (strcmp(optarg, "s") == 0)
|
||||
timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
|
||||
else if (strcmp(optarg, "hms") == 0)
|
||||
timestamp_set_seconds_type(TS_SECONDS_HOUR_MIN_SEC);
|
||||
else {
|
||||
cmdarg_err("Invalid seconds type \"%s\"", optarg);
|
||||
cmdarg_err_cont("It must be \"s\" for seconds or \"hms\" for hours, minutes and seconds.");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'X':
|
||||
/* ext ops were already processed just ignore them this time*/
|
||||
break;
|
||||
|
@ -3615,6 +3626,7 @@ void change_configuration_profile (const gchar *profile_name)
|
|||
rf_path, strerror(rf_open_errno));
|
||||
}
|
||||
timestamp_set_type (recent.gui_time_format);
|
||||
timestamp_set_seconds_type (recent.gui_seconds_format);
|
||||
color_filters_enable(recent.packet_list_colorize);
|
||||
|
||||
prefs_to_capture_opts();
|
||||
|
|
45
gtk/menus.c
45
gtk/menus.c
|
@ -132,6 +132,7 @@ static void set_menu_sensitivity (GtkItemFactory *, const gchar *, gint);
|
|||
static void show_hide_cb(GtkWidget *w, gpointer data, gint action);
|
||||
static void timestamp_format_cb(GtkWidget *w, gpointer d, gint action);
|
||||
static void timestamp_precision_cb(GtkWidget *w, gpointer d, gint action);
|
||||
static void timestamp_seconds_time_cb(GtkWidget *w, gpointer d, gint action);
|
||||
static void name_resolution_cb(GtkWidget *w, gpointer d, gint action);
|
||||
#ifdef HAVE_LIBPCAP
|
||||
static void auto_scroll_live_cb(GtkWidget *w, gpointer d);
|
||||
|
@ -590,6 +591,8 @@ static GtkItemFactoryEntry menu_items[] =
|
|||
TS_PREC_FIXED_USEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
|
||||
{"/View/Time Display Format/Nanoseconds: 0.123456789", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
|
||||
TS_PREC_FIXED_NSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
|
||||
{"/View/Time Display Format/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
|
||||
{"/View/Time Display Format/Display Seconds with hours and minutes", "<alt><control>0", GTK_MENU_FUNC(timestamp_seconds_time_cb), 0, "<CheckItem>", NULL,},
|
||||
{"/View/Name Resol_ution", NULL, NULL, 0, "<Branch>", NULL,},
|
||||
{"/View/Name Resolution/_Resolve Name", NULL, GTK_MENU_FUNC(resolve_name_cb), 0, NULL, NULL,},
|
||||
{"/View/Name Resolution/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
|
||||
|
@ -2164,6 +2167,24 @@ timestamp_precision_cb(GtkWidget *w _U_, gpointer d _U_, gint action)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
timestamp_seconds_time_cb(GtkWidget *w, gpointer d _U_, gint action _U_)
|
||||
{
|
||||
if (GTK_CHECK_MENU_ITEM(w)->active) {
|
||||
recent.gui_seconds_format = TS_SECONDS_HOUR_MIN_SEC;
|
||||
} else {
|
||||
recent.gui_seconds_format = TS_SECONDS_DEFAULT;
|
||||
}
|
||||
timestamp_set_seconds_type (recent.gui_seconds_format);
|
||||
|
||||
#ifdef NEW_PACKET_LIST
|
||||
/* This call adjusts column width */
|
||||
cf_timestamp_auto_precision(&cfile);
|
||||
new_packet_list_queue_draw();
|
||||
#else
|
||||
cf_change_time_formats(&cfile);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
menu_name_resolution_changed(void)
|
||||
|
@ -2369,6 +2390,30 @@ menu_recent_read_finished(void) {
|
|||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
|
||||
|
||||
/* don't change the seconds format, if we had a command line value */
|
||||
if (timestamp_get_seconds_type() != TS_SECONDS_NOT_SET) {
|
||||
recent.gui_seconds_format = timestamp_get_seconds_type();
|
||||
}
|
||||
|
||||
menu = gtk_item_factory_get_widget(main_menu_factory,
|
||||
"/View/Time Display Format/Display Seconds with hours and minutes");
|
||||
switch (recent.gui_seconds_format) {
|
||||
case TS_SECONDS_DEFAULT:
|
||||
recent.gui_seconds_format = -1;
|
||||
/* set_active will not trigger the callback when deactivating an inactive item! */
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
|
||||
break;
|
||||
case TS_SECONDS_HOUR_MIN_SEC:
|
||||
recent.gui_seconds_format = -1;
|
||||
/* set_active will not trigger the callback when activating an active item! */
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
menu_colorize_changed(recent.packet_list_colorize);
|
||||
|
||||
switch (recent.gui_bytes_view) {
|
||||
|
|
13
gtk/recent.c
13
gtk/recent.c
|
@ -70,6 +70,7 @@
|
|||
#define RECENT_KEY_PACKET_LIST_COLORIZE "gui.packet_list_colorize"
|
||||
#define RECENT_GUI_TIME_FORMAT "gui.time_format"
|
||||
#define RECENT_GUI_TIME_PRECISION "gui.time_precision"
|
||||
#define RECENT_GUI_SECONDS_FORMAT "gui.seconds_format"
|
||||
#define RECENT_GUI_ZOOM_LEVEL "gui.zoom_level"
|
||||
#define RECENT_GUI_BYTES_VIEW "gui.bytes_view"
|
||||
#define RECENT_GUI_GEOMETRY_MAIN_X "gui.geometry_main_x"
|
||||
|
@ -99,6 +100,9 @@ static const char *ts_type_text[] =
|
|||
static const char *ts_precision_text[] =
|
||||
{ "AUTO", "SEC", "DSEC", "CSEC", "MSEC", "USEC", "NSEC", NULL };
|
||||
|
||||
static const char *ts_seconds_text[] =
|
||||
{ "SECONDS", "HOUR_MIN_SEC", NULL };
|
||||
|
||||
/* Takes an string and a pointer to an array of strings, and a default int value.
|
||||
* The array must be terminated by a NULL string. If the string is found in the array
|
||||
* of strings, the index of that string in the array is returned. Otherwise, the
|
||||
|
@ -358,6 +362,11 @@ write_profile_recent(void)
|
|||
fprintf(rf, RECENT_GUI_TIME_PRECISION ": %s\n",
|
||||
ts_precision_text[recent.gui_time_precision]);
|
||||
|
||||
fprintf(rf, "\n# Seconds display format.\n");
|
||||
fprintf(rf, "# One of: SECONDS, HOUR_MIN_SEC\n");
|
||||
fprintf(rf, RECENT_GUI_SECONDS_FORMAT ": %s\n",
|
||||
ts_seconds_text[recent.gui_seconds_format]);
|
||||
|
||||
fprintf(rf, "\n# Zoom level.\n");
|
||||
fprintf(rf, "# A decimal number.\n");
|
||||
fprintf(rf, RECENT_GUI_ZOOM_LEVEL ": %d\n",
|
||||
|
@ -603,6 +612,9 @@ read_set_recent_pair_static(gchar *key, gchar *value, void *private_data _U_)
|
|||
} else if (strcmp(key, RECENT_GUI_TIME_PRECISION) == 0) {
|
||||
recent.gui_time_precision =
|
||||
find_index_from_string_array(value, ts_precision_text, TS_PREC_AUTO);
|
||||
} else if (strcmp(key, RECENT_GUI_SECONDS_FORMAT) == 0) {
|
||||
recent.gui_seconds_format =
|
||||
find_index_from_string_array(value, ts_seconds_text, TS_SECONDS_DEFAULT);
|
||||
} else if (strcmp(key, RECENT_GUI_ZOOM_LEVEL) == 0) {
|
||||
num = strtol(value, &p, 0);
|
||||
if (p == value || *p != '\0')
|
||||
|
@ -848,6 +860,7 @@ recent_read_profile_static(char **rf_path_return, int *rf_errno_return)
|
|||
recent.packet_list_colorize = TRUE;
|
||||
recent.gui_time_format = TS_RELATIVE;
|
||||
recent.gui_time_precision = TS_PREC_AUTO;
|
||||
recent.gui_seconds_format = TS_SECONDS_DEFAULT;
|
||||
recent.gui_zoom_level = 0;
|
||||
recent.gui_bytes_view = 0;
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ typedef struct recent_settings_tag {
|
|||
gboolean packet_list_colorize;
|
||||
gint gui_time_format;
|
||||
gint gui_time_precision;
|
||||
gint gui_seconds_format;
|
||||
gint gui_zoom_level;
|
||||
gint gui_bytes_view;
|
||||
|
||||
|
|
Loading…
Reference in New Issue