diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-11-06 20:39:09 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-11-06 20:39:09 +0000 |
commit | 2a088c1d53ee1e1e3012f68aea745324a44e8120 (patch) | |
tree | 720d67bd7491d44e85fe80ba2e10d99d53ec3f49 /ui | |
parent | 67f69e99e876f9303357b912f877b18f72380dba (diff) | |
download | wireshark-2a088c1d53ee1e1e3012f68aea745324a44e8120.tar.gz |
Add support for displaying dates as year and day-of-year (1-origin).
In the process, fix various man page descriptions of the -t flag,
and add support for UTC absolute times in the iousers and iostat TShark
taps.
svn path=/trunk/; revision=53114
Diffstat (limited to 'ui')
-rw-r--r-- | ui/cli/tap-iostat.c | 70 | ||||
-rw-r--r-- | ui/cli/tap-iousers.c | 50 | ||||
-rw-r--r-- | ui/gtk/main.c | 21 | ||||
-rw-r--r-- | ui/gtk/main_menubar.c | 12 |
4 files changed, 129 insertions, 24 deletions
diff --git a/ui/cli/tap-iostat.c b/ui/cli/tap-iostat.c index b6835946bd..4c98582103 100644 --- a/ui/cli/tap-iostat.c +++ b/ui/cli/tap-iostat.c @@ -630,11 +630,19 @@ iostat_draw(void *arg) else invl_col_w = (2*dur_mag) + (2*invl_prec) + 10; - /* Update the width of the time interval column for "-t ad" */ - if (timestamp_get_type()==TS_ABSOLUTE_WITH_DATE) + /* Update the width of the time interval column if date is shown */ + switch (timestamp_get_type()) { + case TS_ABSOLUTE_WITH_YMD: + case TS_ABSOLUTE_WITH_YDOY: + case TS_UTC_WITH_YMD: + case TS_UTC_WITH_YDOY: invl_col_w = MAX(invl_col_w, 23); - else + break; + + default: invl_col_w = MAX(invl_col_w, 12); + break; + } borderlen = MAX(borderlen, invl_col_w); @@ -898,7 +906,10 @@ iostat_draw(void *arg) case TS_ABSOLUTE: printf("\n| Time "); break; - case TS_ABSOLUTE_WITH_DATE: + case TS_ABSOLUTE_WITH_YMD: + case TS_ABSOLUTE_WITH_YDOY: + case TS_UTC_WITH_YMD: + case TS_UTC_WITH_YDOY: printf("\n| Date and time"); k = 16; break; @@ -973,18 +984,19 @@ iostat_draw(void *arg) /* Patch for Absolute Time */ /* XXX - has a Y2.038K problem with 32-bit time_t */ the_time = (time_t)(iot->start_time + (t/1000000ULL)); - tm_time = localtime(&the_time); /* Display the interval for this row */ switch (timestamp_get_type()) { case TS_ABSOLUTE: + tm_time = localtime(&the_time); printf("| %02d:%02d:%02d |", tm_time->tm_hour, tm_time->tm_min, tm_time->tm_sec); break; - case TS_ABSOLUTE_WITH_DATE: + case TS_ABSOLUTE_WITH_YMD: + tm_time = localtime(&the_time); printf("| %04d-%02d-%02d %02d:%02d:%02d |", tm_time->tm_year + 1900, tm_time->tm_mon + 1, @@ -994,9 +1006,47 @@ iostat_draw(void *arg) tm_time->tm_sec); break; + case TS_ABSOLUTE_WITH_YDOY: + tm_time = localtime(&the_time); + printf("| %04d/%03d %02d:%02d:%02d |", + tm_time->tm_year + 1900, + tm_time->tm_yday + 1, + tm_time->tm_hour, + tm_time->tm_min, + tm_time->tm_sec); + break; + + case TS_UTC: + tm_time = gmtime(&the_time); + printf("| %02d:%02d:%02d |", + tm_time->tm_hour, + tm_time->tm_min, + tm_time->tm_sec); + break; + + case TS_UTC_WITH_YMD: + tm_time = gmtime(&the_time); + printf("| %04d-%02d-%02d %02d:%02d:%02d |", + tm_time->tm_year + 1900, + tm_time->tm_mon + 1, + tm_time->tm_mday, + tm_time->tm_hour, + tm_time->tm_min, + tm_time->tm_sec); + break; + + case TS_UTC_WITH_YDOY: + tm_time = gmtime(&the_time); + printf("| %04d/%03d %02d:%02d:%02d |", + tm_time->tm_year + 1900, + tm_time->tm_yday + 1, + tm_time->tm_hour, + tm_time->tm_min, + tm_time->tm_sec); + break; + case TS_RELATIVE: case TS_NOT_SET: - if (invl_prec==0) { if(last_row) { int maxw; @@ -1021,8 +1071,6 @@ iostat_draw(void *arg) /* case TS_DELTA: case TS_DELTA_DIS: case TS_EPOCH: - case TS_UTC: - case TS_UTC_WITH_DATE: are not implemented */ default: break; @@ -1337,9 +1385,7 @@ iostat_init(const char *opt_arg, void* userdata _U_) case TS_DELTA: case TS_DELTA_DIS: case TS_EPOCH: - case TS_UTC: - case TS_UTC_WITH_DATE: - fprintf(stderr, "\ntshark: invalid -t operand. io,stat only supports -t <r|a|ad>\n"); + fprintf(stderr, "\ntshark: invalid -t operand. io,stat only supports -t <r|a|ad|adoy|u|ud|udoy>\n"); exit(1); default: break; diff --git a/ui/cli/tap-iousers.c b/ui/cli/tap-iousers.c index b51d708e59..e1bac1f0ac 100644 --- a/ui/cli/tap-iousers.c +++ b/ui/cli/tap-iousers.c @@ -373,10 +373,14 @@ iousers_draw(void *arg) switch (timestamp_get_type()) { case TS_ABSOLUTE: + case TS_UTC: printf(" | <- | | -> | | Total | Absolute Time | Duration |\n"); printf(" | Frames Bytes | | Frames Bytes | | Frames Bytes | Start | |\n"); break; - case TS_ABSOLUTE_WITH_DATE: + case TS_ABSOLUTE_WITH_YMD: + case TS_ABSOLUTE_WITH_YDOY: + case TS_UTC_WITH_YMD: + case TS_UTC_WITH_YDOY: printf(" | <- | | -> | | Total | Absolute Date | Duration |\n"); printf(" | Frames Bytes | | Frames Bytes | | Frames Bytes | Start | |\n"); break; @@ -413,16 +417,17 @@ iousers_draw(void *arg) iui->bytes1+iui->bytes2 ); - tm_time = localtime(&iui->start_abs_time.secs); switch (timestamp_get_type()) { case TS_ABSOLUTE: + tm_time = localtime(&iui->start_abs_time.secs); printf("%02d:%02d:%02d %12.4f\n", tm_time->tm_hour, tm_time->tm_min, tm_time->tm_sec, nstime_to_sec(&iui->stop_rel_time) - nstime_to_sec(&iui->start_rel_time)); break; - case TS_ABSOLUTE_WITH_DATE: + case TS_ABSOLUTE_WITH_YMD: + tm_time = localtime(&iui->start_abs_time.secs); printf("%04d-%02d-%02d %02d:%02d:%02d %12.4f\n", tm_time->tm_year + 1900, tm_time->tm_mon + 1, @@ -432,6 +437,45 @@ iousers_draw(void *arg) tm_time->tm_sec, nstime_to_sec(&iui->stop_rel_time) - nstime_to_sec(&iui->start_rel_time)); break; + case TS_ABSOLUTE_WITH_YDOY: + tm_time = localtime(&iui->start_abs_time.secs); + printf("%04d/%03d %02d:%02d:%02d %12.4f\n", + tm_time->tm_year + 1900, + tm_time->tm_yday + 1, + tm_time->tm_hour, + tm_time->tm_min, + tm_time->tm_sec, + nstime_to_sec(&iui->stop_rel_time) - nstime_to_sec(&iui->start_rel_time)); + break; + case TS_UTC: + tm_time = gmtime(&iui->start_abs_time.secs); + printf("%02d:%02d:%02d %12.4f\n", + tm_time->tm_hour, + tm_time->tm_min, + tm_time->tm_sec, + nstime_to_sec(&iui->stop_rel_time) - nstime_to_sec(&iui->start_rel_time)); + break; + case TS_UTC_WITH_YMD: + tm_time = gmtime(&iui->start_abs_time.secs); + printf("%04d-%02d-%02d %02d:%02d:%02d %12.4f\n", + tm_time->tm_year + 1900, + tm_time->tm_mon + 1, + tm_time->tm_mday, + tm_time->tm_hour, + tm_time->tm_min, + tm_time->tm_sec, + nstime_to_sec(&iui->stop_rel_time) - nstime_to_sec(&iui->start_rel_time)); + break; + case TS_UTC_WITH_YDOY: + tm_time = gmtime(&iui->start_abs_time.secs); + printf("%04d/%03d %02d:%02d:%02d %12.4f\n", + tm_time->tm_year + 1900, + tm_time->tm_yday + 1, + tm_time->tm_hour, + tm_time->tm_min, + tm_time->tm_sec, + nstime_to_sec(&iui->stop_rel_time) - nstime_to_sec(&iui->start_rel_time)); + break; case TS_RELATIVE: case TS_NOT_SET: default: diff --git a/ui/gtk/main.c b/ui/gtk/main.c index bad98e4873..8111264da1 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -2712,7 +2712,9 @@ main(int argc, char *argv[]) else if (strcmp(optarg, "a") == 0) timestamp_set_type(TS_ABSOLUTE); else if (strcmp(optarg, "ad") == 0) - timestamp_set_type(TS_ABSOLUTE_WITH_DATE); + timestamp_set_type(TS_ABSOLUTE_WITH_YMD); + else if (strcmp(optarg, "adoy") == 0) + timestamp_set_type(TS_ABSOLUTE_WITH_YDOY); else if (strcmp(optarg, "d") == 0) timestamp_set_type(TS_DELTA); else if (strcmp(optarg, "dd") == 0) @@ -2722,12 +2724,21 @@ main(int argc, char *argv[]) else if (strcmp(optarg, "u") == 0) timestamp_set_type(TS_UTC); else if (strcmp(optarg, "ud") == 0) - timestamp_set_type(TS_UTC_WITH_DATE); + timestamp_set_type(TS_UTC_WITH_YMD); + else if (strcmp(optarg, "udoy") == 0) + timestamp_set_type(TS_UTC_WITH_YDOY); else { cmdarg_err("Invalid time stamp type \"%s\"", optarg); - cmdarg_err_cont("It must be \"a\" for absolute, \"ad\" for absolute with date, \"d\" for delta,"); - cmdarg_err_cont("\"dd\" for delta displayed, \"e\" for epoch, \"r\" for relative, \"u\" for UTC, "); - cmdarg_err_cont("or \"ud\" for UTC with date."); + cmdarg_err_cont( +"It must be \"a\" for absolute, \"ad\" for absolute with YYYY-MM-DD date,"); + cmdarg_err_cont( +"\"adoy\" for absolute with YYYY/DOY date, \"d\" for delta,"); + cmdarg_err_cont( +"\"dd\" for delta displayed, \"e\" for epoch, \"r\" for relative,"); + cmdarg_err_cont( +"\"u\" for absolute UTC, \"ud\" for absolute UTC with YYYY-MM-DD date,"); + cmdarg_err_cont( +"or \"udoy\" for absolute UTC with YYYY/DOY date."); exit(1); } break; diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index 410217792e..be5fc6c0d9 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -1045,13 +1045,15 @@ static const char *ui_desc_menubar = " <menuitem name='PacketBytes' action='/View/PacketBytes'/>\n" " <separator/>\n" " <menu name= 'TimeDisplayFormat' action='/View/TimeDisplayFormat'>\n" -" <menuitem name='DateandTimeofDay' action='/View/TimeDisplayFormat/DateandTimeofDay'/>\n" +" <menuitem name='DateYMDandTimeofDay' action='/View/TimeDisplayFormat/DateYMDandTimeofDay'/>\n" +" <menuitem name='DateYDOYandTimeofDay' action='/View/TimeDisplayFormat/DateYDOYandTimeofDay'/>\n" " <menuitem name='TimeofDay' action='/View/TimeDisplayFormat/TimeofDay'/>\n" " <menuitem name='SecondsSinceEpoch' action='/View/TimeDisplayFormat/SecondsSinceEpoch'/>\n" " <menuitem name='SecondsSinceBeginningofCapture' action='/View/TimeDisplayFormat/SecondsSinceBeginningofCapture'/>\n" " <menuitem name='SecondsSincePreviousCapturedPacket' action='/View/TimeDisplayFormat/SecondsSincePreviousCapturedPacket'/>\n" " <menuitem name='SecondsSincePreviousDisplayedPacket' action='/View/TimeDisplayFormat/SecondsSincePreviousDisplayedPacket'/>\n" -" <menuitem name='UTCDateandTimeofDay' action='/View/TimeDisplayFormat/UTCDateandTimeofDay'/>\n" +" <menuitem name='UTCDateYMDandTimeofDay' action='/View/TimeDisplayFormat/UTCDateYMDandTimeofDay'/>\n" +" <menuitem name='UTCDateYDOYandTimeofDay' action='/View/TimeDisplayFormat/UTCDateYDOYandTimeofDay'/>\n" " <menuitem name='UTCTimeofDay' action='/View/TimeDisplayFormat/UTCTimeofDay'/>\n" " <separator/>\n" " <menuitem name='FileFormatPrecision-Automatic' action='/View/TimeDisplayFormat/FileFormatPrecision-Automatic'/>\n" @@ -1797,13 +1799,15 @@ static const GtkToggleActionEntry main_menu_bar_toggle_action_entries[] = static const GtkRadioActionEntry main_menu_bar_radio_view_time_entries [] = { /* name, stock id, label, accel, tooltip, value */ - { "/View/TimeDisplayFormat/DateandTimeofDay", NULL, "Date and Time of Day: 1970-01-01 01:02:03.123456", "<alt><control>1", NULL, TS_ABSOLUTE_WITH_DATE }, + { "/View/TimeDisplayFormat/DateYMDandTimeofDay", NULL, "Date and Time of Day: 1970-01-01 01:02:03.123456", "<alt><control>1", NULL, TS_ABSOLUTE_WITH_YMD }, + { "/View/TimeDisplayFormat/DateYDOYandTimeofDay", NULL, "Date (with day of year) and Time of Day: 1970/001 01:02:03.123456", NULL, NULL, TS_ABSOLUTE_WITH_YDOY }, { "/View/TimeDisplayFormat/TimeofDay", NULL, "Time of Day: 01:02:03.123456", "<alt><control>2", NULL, TS_ABSOLUTE }, { "/View/TimeDisplayFormat/SecondsSinceEpoch", NULL, "Seconds Since Epoch (1970-01-01): 1234567890.123456", "<alt><control>3", NULL, TS_EPOCH }, { "/View/TimeDisplayFormat/SecondsSinceBeginningofCapture", NULL, "Seconds Since Beginning of Capture: 123.123456", "<alt><control>4", NULL, TS_RELATIVE }, { "/View/TimeDisplayFormat/SecondsSincePreviousCapturedPacket", NULL, "Seconds Since Previous Captured Packet: 1.123456", "<alt><control>5", NULL, TS_DELTA }, { "/View/TimeDisplayFormat/SecondsSincePreviousDisplayedPacket",NULL, "Seconds Since Previous Displayed Packet: 1.123456", "<alt><control>6", NULL, TS_DELTA_DIS }, - { "/View/TimeDisplayFormat/UTCDateandTimeofDay", NULL, "UTC Date and Time of Day: 1970-01-01 01:02:03.123456", "<alt><control>7", NULL, TS_UTC_WITH_DATE }, + { "/View/TimeDisplayFormat/UTCDateYMDandTimeofDay", NULL, "UTC Date and Time of Day: 1970-01-01 01:02:03.123456", "<alt><control>7", NULL, TS_UTC_WITH_YMD }, + { "/View/TimeDisplayFormat/UTCDateYDOYandTimeofDay", NULL, "UTC Date (with day of year) and Time of Day: 1970/001 01:02:03.123456", NULL, NULL, TS_UTC_WITH_YDOY }, { "/View/TimeDisplayFormat/UTCTimeofDay", NULL, "UTC Time of Day: 01:02:03.123456", "<alt><control>7", NULL, TS_UTC }, }; |