diff options
author | Anders Broman <anders.broman@ericsson.com> | 2011-07-04 21:43:34 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2011-07-04 21:43:34 +0000 |
commit | 2f05cf4dcfbecb970713c564fdbe8d0fa40d6ffb (patch) | |
tree | 48ae1991be5f20fc1b47e42036a09bc0a79f2717 | |
parent | 78d22ed8ee61de8e350b6228b07fa43f3384d489 (diff) | |
download | wireshark-2f05cf4dcfbecb970713c564fdbe8d0fa40d6ffb.tar.gz |
From Michael Mann:
Added ability to display UTC time or UTC time with date. I liked having the
difference between UTC and local time, not just setting local=UTC.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2629
svn path=/trunk/; revision=37898
-rw-r--r-- | epan/column-utils.c | 80 | ||||
-rw-r--r-- | epan/column.c | 16 | ||||
-rw-r--r-- | epan/column_info.h | 6 | ||||
-rw-r--r-- | epan/frame_data.c | 4 | ||||
-rw-r--r-- | epan/timestamp.h | 2 | ||||
-rw-r--r-- | epan/wslua/wslua_pinfo.c | 2 | ||||
-rw-r--r-- | gtk/main.c | 4 | ||||
-rw-r--r-- | gtk/menus.c | 12 | ||||
-rw-r--r-- | gtk/packet_list_store.c | 11 | ||||
-rw-r--r-- | gtk/recent.c | 4 | ||||
-rw-r--r-- | rawshark.c | 4 | ||||
-rw-r--r-- | tshark.c | 8 |
12 files changed, 130 insertions, 23 deletions
diff --git a/epan/column-utils.c b/epan/column-utils.c index ddd2ffa7c2..e3397aa9a4 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -613,19 +613,24 @@ col_has_time_fmt(column_info *cinfo, const gint col) return ((cinfo->fmt_matx[col][COL_CLS_TIME]) || (cinfo->fmt_matx[col][COL_ABS_TIME]) || (cinfo->fmt_matx[col][COL_ABS_DATE_TIME]) || + (cinfo->fmt_matx[col][COL_UTC_TIME]) || + (cinfo->fmt_matx[col][COL_UTC_DATE_TIME]) || (cinfo->fmt_matx[col][COL_REL_TIME]) || (cinfo->fmt_matx[col][COL_DELTA_TIME]) || (cinfo->fmt_matx[col][COL_DELTA_TIME_DIS])); } static gint -set_abs_date_time(const frame_data *fd, gchar *buf) +set_abs_date_time(const frame_data *fd, gchar *buf, gboolean local) { struct tm *tmp; time_t then; then = fd->abs_ts.secs; - tmp = localtime(&then); + if (local) + tmp = localtime(&then); + else + tmp = gmtime(&then); if (tmp != NULL) { switch(timestamp_get_precision()) { case TS_PREC_FIXED_SEC: @@ -705,7 +710,17 @@ set_abs_date_time(const frame_data *fd, gchar *buf) static void col_set_abs_date_time(const frame_data *fd, column_info *cinfo, const int col) { - if (set_abs_date_time(fd, cinfo->col_buf[col])) { + if (set_abs_date_time(fd, cinfo->col_buf[col], TRUE)) { + cinfo->col_expr.col_expr[col] = "frame.time"; + g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); + } + cinfo->col_data[col] = cinfo->col_buf[col]; +} + +static void +col_set_utc_date_time(const frame_data *fd, column_info *cinfo, const int col) +{ + if (set_abs_date_time(fd, cinfo->col_buf[col], FALSE)) { cinfo->col_expr.col_expr[col] = "frame.time"; g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); } @@ -969,13 +984,16 @@ col_set_delta_time_dis(const frame_data *fd, column_info *cinfo, const int col) } static gint -set_abs_time(const frame_data *fd, gchar *buf) +set_abs_time(const frame_data *fd, gchar *buf, gboolean local) { struct tm *tmp; time_t then; then = fd->abs_ts.secs; - tmp = localtime(&then); + if (local) + tmp = localtime(&then); + else + tmp = gmtime(&then); if (tmp != NULL) { switch(timestamp_get_precision()) { case TS_PREC_FIXED_SEC: @@ -1038,7 +1056,17 @@ set_abs_time(const frame_data *fd, gchar *buf) static void col_set_abs_time(const frame_data *fd, column_info *cinfo, const int col) { - if (set_abs_time(fd, cinfo->col_buf[col])) { + if (set_abs_time(fd, cinfo->col_buf[col], TRUE)) { + cinfo->col_expr.col_expr[col] = "frame.time"; + g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); + } + cinfo->col_data[col] = cinfo->col_buf[col]; +} + +static void +col_set_utc_time(const frame_data *fd, column_info *cinfo, const int col) +{ + if (set_abs_time(fd, cinfo->col_buf[col], FALSE)) { cinfo->col_expr.col_expr[col] = "frame.time"; g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); } @@ -1169,6 +1197,14 @@ col_set_cls_time(const frame_data *fd, column_info *cinfo, const gint col) col_set_epoch_time(fd, cinfo, col); break; + case TS_UTC: + col_set_utc_time(fd, cinfo, col); + break; + + case TS_UTC_WITH_DATE: + col_set_utc_date_time(fd, cinfo, col); + break; + case TS_NOT_SET: /* code is missing for this case, but I don't know which [jmayer20051219] */ g_assert_not_reached(); @@ -1213,6 +1249,14 @@ col_set_fmt_time(const frame_data *fd, column_info *cinfo, const gint fmt, const col_set_delta_time_dis(fd, cinfo, col); break; + case TS_UTC: + col_set_utc_time(fd, cinfo, col); + break; + + case TS_UTC_WITH_DATE: + col_set_utc_date_time(fd, cinfo, col); + break; + default: g_assert_not_reached(); break; @@ -1456,6 +1500,8 @@ col_based_on_frame_data(column_info *cinfo, const gint col) case COL_CLS_TIME: case COL_ABS_TIME: case COL_ABS_DATE_TIME: + case COL_UTC_TIME: + case COL_UTC_DATE_TIME: case COL_REL_TIME: case COL_DELTA_TIME: case COL_DELTA_TIME_DIS: @@ -1481,6 +1527,8 @@ col_fill_in_frame_data(const frame_data *fd, column_info *cinfo, const gint col, case COL_CLS_TIME: case COL_ABS_TIME: case COL_ABS_DATE_TIME: + case COL_UTC_TIME: + case COL_UTC_DATE_TIME: case COL_REL_TIME: case COL_DELTA_TIME: case COL_DELTA_TIME_DIS: @@ -1515,6 +1563,8 @@ col_fill_in_frame_data(const frame_data *fd, column_info *cinfo, const gint col, case COL_CLS_TIME: case COL_ABS_TIME: case COL_ABS_DATE_TIME: + case COL_UTC_TIME: + case COL_UTC_DATE_TIME: case COL_REL_TIME: case COL_DELTA_TIME: case COL_DELTA_TIME_DIS: @@ -1549,6 +1599,8 @@ col_fill_in(packet_info *pinfo, const gboolean fill_col_exprs, const gboolean fi case COL_CLS_TIME: case COL_ABS_TIME: case COL_ABS_DATE_TIME: + case COL_UTC_TIME: + case COL_UTC_DATE_TIME: case COL_REL_TIME: case COL_DELTA_TIME: case COL_DELTA_TIME_DIS: @@ -1671,6 +1723,8 @@ col_fill_in_error(column_info *cinfo, frame_data *fdata, const gboolean fill_col case COL_CLS_TIME: case COL_ABS_TIME: case COL_ABS_DATE_TIME: + case COL_UTC_TIME: + case COL_UTC_DATE_TIME: case COL_REL_TIME: case COL_DELTA_TIME: case COL_DELTA_TIME_DIS: @@ -1741,7 +1795,9 @@ col_fill_fdata(packet_info *pinfo) case COL_CUMULATIVE_BYTES: /* fd->cum_bytes */ case COL_CLS_TIME: case COL_ABS_TIME: - case COL_ABS_DATE_TIME: /* from fd structures */ + case COL_ABS_DATE_TIME: + case COL_UTC_TIME: + case COL_UTC_DATE_TIME: /* from fd structures */ case COL_REL_TIME: case COL_DELTA_TIME: case COL_DELTA_TIME_DIS: @@ -1879,10 +1935,16 @@ gchar *ptr; set_cls_time(fd, buf); break; case COL_ABS_TIME: - set_abs_time(fd, buf); + set_abs_time(fd, buf, TRUE); + break; + case COL_UTC_TIME: + set_abs_time(fd, buf, FALSE); break; case COL_ABS_DATE_TIME: - set_abs_date_time(fd, buf); + set_abs_date_time(fd, buf, TRUE); + break; + case COL_UTC_DATE_TIME: + set_abs_date_time(fd, buf, FALSE); break; case COL_REL_TIME: set_rel_time(fd, buf); diff --git a/epan/column.c b/epan/column.c index 3cbbb6d876..a3d3513a42 100644 --- a/epan/column.c +++ b/epan/column.c @@ -105,7 +105,9 @@ col_format_to_string(const gint fmt) { "%rS", /* 55) COL_RES_SRC_PORT */ "%uS", /* 56) COL_UNRES_SRC_PORT */ "%E", /* 57) COL_TEI */ - "%t" /* 58) COL_CLS_TIME */ + "%Yut", /* 58) COL_UTC_DATE_TIME */ + "%Aut", /* 59) COL_UTC_TIME */ + "%t" /* 60) COL_CLS_TIME */ }; if (fmt < 0 || fmt >= NUM_COL_FMTS) @@ -175,7 +177,9 @@ static const gchar *dlist[NUM_COL_FMTS] = { "Src port (resolved)", /* 55) COL_RES_SRC_PORT */ "Src port (unresolved)", /* 56) COL_UNRES_SRC_PORT */ "TEI", /* 57) COL_TEI */ - "Time (format as specified)" /* 58) COL_CLS_TIME */ + "UTC date and time", /* 58) COL_UTC_DATE_TIME */ + "UTC time", /* 59) COL_UTC_TIME */ + "Time (format as specified)" /* 60) COL_CLS_TIME */ }; const gchar * @@ -316,6 +320,7 @@ get_timestamp_column_longest_string(const gint type, const gint precision) switch(type) { case(TS_ABSOLUTE_WITH_DATE): + case(TS_UTC_WITH_DATE): switch(precision) { case(TS_PREC_AUTO_SEC): case(TS_PREC_FIXED_SEC): @@ -346,6 +351,7 @@ get_timestamp_column_longest_string(const gint type, const gint precision) } break; case(TS_ABSOLUTE): + case(TS_UTC): switch(precision) { case(TS_PREC_AUTO_SEC): case(TS_PREC_FIXED_SEC): @@ -486,9 +492,15 @@ get_column_longest_string(const gint format) case COL_ABS_DATE_TIME: return get_timestamp_column_longest_string(TS_ABSOLUTE_WITH_DATE, timestamp_get_precision()); break; + case COL_UTC_DATE_TIME: + return get_timestamp_column_longest_string(TS_UTC_WITH_DATE, timestamp_get_precision()); + break; case COL_ABS_TIME: return get_timestamp_column_longest_string(TS_ABSOLUTE, timestamp_get_precision()); break; + case COL_UTC_TIME: + return get_timestamp_column_longest_string(TS_UTC, timestamp_get_precision()); + break; case COL_REL_TIME: return get_timestamp_column_longest_string(TS_RELATIVE, timestamp_get_precision()); break; diff --git a/epan/column_info.h b/epan/column_info.h index 8bf4c05191..74d22575b2 100644 --- a/epan/column_info.h +++ b/epan/column_info.h @@ -132,8 +132,10 @@ enum { COL_RES_SRC_PORT, /**< 55) Resolved source port */ COL_UNRES_SRC_PORT, /**< 56) Unresolved source port */ COL_TEI, /**< 57) Q.921 TEI */ - COL_CLS_TIME, /**< 58) Command line-specified time (default relative) */ - NUM_COL_FMTS /**< 59) Should always be last */ + COL_UTC_DATE_TIME, /**< 58) UTC date and time */ + COL_UTC_TIME, /**< 59) UTC time */ + COL_CLS_TIME, /**< 60) Command line-specified time (default relative) */ + NUM_COL_FMTS /**< 61) Should always be last */ }; #ifdef __cplusplus diff --git a/epan/frame_data.c b/epan/frame_data.c index 4bde07fa33..1154090ae6 100644 --- a/epan/frame_data.c +++ b/epan/frame_data.c @@ -143,6 +143,8 @@ frame_data_compare(const frame_data *fdata1, const frame_data *fdata2, int field switch (timestamp_get_type()) { case TS_ABSOLUTE: case TS_ABSOLUTE_WITH_DATE: + case TS_UTC: + case TS_UTC_WITH_DATE: case TS_EPOCH: return COMPARE_TS(abs_ts); @@ -162,6 +164,8 @@ frame_data_compare(const frame_data *fdata1, const frame_data *fdata2, int field case COL_ABS_TIME: case COL_ABS_DATE_TIME: + case COL_UTC_TIME: + case COL_UTC_DATE_TIME: return COMPARE_TS(abs_ts); case COL_REL_TIME: diff --git a/epan/timestamp.h b/epan/timestamp.h index bdc9ab0d62..9282ac5216 100644 --- a/epan/timestamp.h +++ b/epan/timestamp.h @@ -35,6 +35,8 @@ typedef enum { TS_DELTA, /* Since previous captured packet */ TS_DELTA_DIS, /* Since previous displayed packet */ TS_EPOCH, /* Seconds (and fractions) since epoch */ + TS_UTC, + TS_UTC_WITH_DATE, /* * Special value used for the command-line setting in Wireshark, to indicate diff --git a/epan/wslua/wslua_pinfo.c b/epan/wslua/wslua_pinfo.c index 2e12ac59b6..9a0969dcfc 100644 --- a/epan/wslua/wslua_pinfo.c +++ b/epan/wslua/wslua_pinfo.c @@ -299,9 +299,11 @@ struct col_names_t { static const struct col_names_t colnames[] = { {"number",COL_NUMBER}, {"abs_time",COL_ABS_TIME}, + {"utc_time",COL_UTC_TIME}, {"cls_time",COL_CLS_TIME}, {"rel_time",COL_REL_TIME}, {"date",COL_ABS_DATE_TIME}, + {"utc_date",COL_UTC_DATE_TIME}, {"delta_time",COL_DELTA_TIME}, {"delta_time_displayed",COL_DELTA_TIME_DIS}, {"src",COL_DEF_SRC}, diff --git a/gtk/main.c b/gtk/main.c index f4213486ed..8214fee117 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -2568,6 +2568,10 @@ main(int argc, char *argv[]) timestamp_set_type(TS_DELTA_DIS); else if (strcmp(optarg, "e") == 0) timestamp_set_type(TS_EPOCH); + else if (strcmp(optarg, "u") == 0) + timestamp_set_type(TS_UTC); + else if (strcmp(optarg, "ud") == 0) + timestamp_set_type(TS_UTC_WITH_DATE); else { cmdarg_err("Invalid time stamp type \"%s\"", optarg); cmdarg_err_cont("It must be \"r\" for relative, \"a\" for absolute,"); diff --git a/gtk/menus.c b/gtk/menus.c index 7958b0224f..253db6702f 100644 --- a/gtk/menus.c +++ b/gtk/menus.c @@ -2015,6 +2015,10 @@ static GtkItemFactoryEntry menu_items[] = TS_DELTA, "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", NULL,}, {"/View/Time Display Format/Seconds Since Previous Displayed Packet: 1.123456", "<alt><control>6", GTK_MENU_FUNC(timestamp_format_cb), TS_DELTA_DIS, "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", NULL,}, + {"/View/Time Display Format/UTC Date and Time of Day: 1970-01-01 01:02:03.123456", "<alt><control>7", GTK_MENU_FUNC(timestamp_format_cb), + TS_UTC_WITH_DATE, "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", NULL,}, + {"/View/Time Display Format/UTC Time of Day: 01:02:03.123456", "<alt><control>8", GTK_MENU_FUNC(timestamp_format_cb), + TS_UTC, "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", NULL,}, {"/View/Time Display Format/<separator>", NULL, NULL, 0, "<Separator>", NULL,}, {"/View/Time Display Format/Automatic (File Format Precision)", NULL, GTK_MENU_FUNC(timestamp_precision_cb), TS_PREC_AUTO, "<RadioItem>", NULL,}, @@ -5638,6 +5642,14 @@ menu_recent_read_finished(void) { menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Time Display Format/Seconds Since Epoch (1970-01-01): 1234567890.123456"); break; + case(TS_UTC_WITH_DATE): + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/UTC Date and Time of Day: 1970-01-01 01:02:03.123456"); + break; + case(TS_UTC): + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/UTC Time of Day: 01:02:03.123456"); + break; default: g_assert_not_reached(); } diff --git a/gtk/packet_list_store.c b/gtk/packet_list_store.c index cd1ff3d7a4..b974b5e278 100644 --- a/gtk/packet_list_store.c +++ b/gtk/packet_list_store.c @@ -1254,10 +1254,9 @@ packet_list_get_widest_column_string(PacketList *packet_list, gint col) fdata.cum_bytes = record->fdata->cum_bytes; break; case COL_ABS_TIME: - if (nstime_cmp(&record->fdata->abs_ts, &fdata.abs_ts) > 0) - fdata.abs_ts = record->fdata->abs_ts; - break; case COL_ABS_DATE_TIME: + case COL_UTC_TIME: + case COL_UTC_DATE_TIME: if (nstime_cmp(&record->fdata->abs_ts, &fdata.abs_ts) > 0) fdata.abs_ts = record->fdata->abs_ts; break; @@ -1276,11 +1275,9 @@ packet_list_get_widest_column_string(PacketList *packet_list, gint col) case COL_CLS_TIME: switch (timestamp_get_type()) { case TS_ABSOLUTE: - if (nstime_cmp(&record->fdata->abs_ts, &fdata.abs_ts) > 0) - fdata.abs_ts = record->fdata->abs_ts; - break; - case TS_ABSOLUTE_WITH_DATE: + case TS_UTC: + case TS_UTC_WITH_DATE: if (nstime_cmp(&record->fdata->abs_ts, &fdata.abs_ts) > 0) fdata.abs_ts = record->fdata->abs_ts; break; diff --git a/gtk/recent.c b/gtk/recent.c index e49543e2fe..43e6aedbde 100644 --- a/gtk/recent.c +++ b/gtk/recent.c @@ -91,7 +91,7 @@ recent_settings_t recent; static const char *ts_type_text[] = - { "RELATIVE", "ABSOLUTE", "ABSOLUTE_WITH_DATE", "DELTA", "DELTA_DIS", "EPOCH", NULL }; + { "RELATIVE", "ABSOLUTE", "ABSOLUTE_WITH_DATE", "DELTA", "DELTA_DIS", "EPOCH", "UTC", "UTC_WITH_DATE", NULL }; static const char *ts_precision_text[] = { "AUTO", "SEC", "DSEC", "CSEC", "MSEC", "USEC", "NSEC", NULL }; @@ -349,7 +349,7 @@ write_profile_recent(void) recent.packet_list_colorize == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "\n# Timestamp display format.\n"); - fprintf(rf, "# One of: RELATIVE, ABSOLUTE, ABSOLUTE_WITH_DATE, DELTA, DELTA_DIS, EPOCH\n"); + fprintf(rf, "# One of: RELATIVE, ABSOLUTE, ABSOLUTE_WITH_DATE, DELTA, DELTA_DIS, EPOCH, UTC, UTC_WITH_DATE\n"); fprintf(rf, RECENT_GUI_TIME_FORMAT ": %s\n", ts_type_text[recent.gui_time_format]); diff --git a/rawshark.c b/rawshark.c index 4d2e0fef57..df30037b89 100644 --- a/rawshark.c +++ b/rawshark.c @@ -691,6 +691,10 @@ main(int argc, char *argv[]) timestamp_set_type(TS_DELTA_DIS); else if (strcmp(optarg, "e") == 0) timestamp_set_type(TS_EPOCH); + else if (strcmp(optarg, "u") == 0) + timestamp_set_type(TS_UTC); + else if (strcmp(optarg, "ud") == 0) + timestamp_set_type(TS_UTC_WITH_DATE); else { cmdarg_err("Invalid time stamp type \"%s\"", optarg); @@ -1263,6 +1263,10 @@ main(int argc, char *argv[]) timestamp_set_type(TS_DELTA_DIS); else if (strcmp(optarg, "e") == 0) timestamp_set_type(TS_EPOCH); + else if (strcmp(optarg, "u") == 0) + timestamp_set_type(TS_UTC); + else if (strcmp(optarg, "ud") == 0) + timestamp_set_type(TS_UTC_WITH_DATE); else { cmdarg_err("Invalid time stamp type \"%s\"", optarg); @@ -3108,7 +3112,9 @@ print_columns(capture_file *cf) case COL_CLS_TIME: case COL_REL_TIME: case COL_ABS_TIME: - case COL_ABS_DATE_TIME: /* XXX - wider */ + case COL_ABS_DATE_TIME: + case COL_UTC_TIME: + case COL_UTC_DATE_TIME: /* XXX - wider */ column_len = strlen(cf->cinfo.col_data[i]); if (column_len < 10) column_len = 10; |