From 723c80ea90a3c56c069a0a99e22edd43b00cf357 Mon Sep 17 00:00:00 2001 From: Ulf Lamping Date: Thu, 25 Aug 2005 21:29:54 +0000 Subject: timestamp display precision: - automatic adjustment depending on file format - manual adjustment through menu items save the setting in the recent file svn path=/trunk/; revision=15534 --- cfile.h | 8 +- dftest.c | 2 +- epan/column-utils.c | 200 ++++++++++++++++++++++++++++++++++++++++-- epan/column.c | 128 ++++++++++++++++++++++++--- epan/libethereal.def | 6 +- epan/timestamp.c | 18 +++- epan/timestamp.h | 30 +++++-- epan/to_str.c | 12 +++ epan/to_str.h | 3 + file.c | 55 +++++++++++- gtk/main.c | 8 +- gtk/menu.c | 182 ++++++++++++++++++++++++++++++++++---- gtk/packet_list.c | 2 +- gtk/recent.c | 13 +++ gtk/recent.h | 1 + tethereal.c | 11 +-- wiretap/5views.c | 1 + wiretap/airopeek9.c | 1 + wiretap/ascend.c | 1 + wiretap/cosine.c | 1 + wiretap/csids.c | 1 + wiretap/dbs-etherwatch.c | 1 + wiretap/erf.c | 1 + wiretap/etherpeek.c | 1 + wiretap/eyesdn.c | 1 + wiretap/hcidump.c | 1 + wiretap/i4btrace.c | 1 + wiretap/iptrace.c | 2 + wiretap/k12.c | 1 + wiretap/lanalyzer.c | 1 + wiretap/libpcap.c | 7 +- wiretap/netmon.c | 1 + wiretap/nettl.c | 1 + wiretap/network_instruments.c | 1 + wiretap/netxray.c | 8 ++ wiretap/ngsniffer.c | 2 + wiretap/pppdump.c | 1 + wiretap/radcom.c | 1 + wiretap/snoop.c | 1 + wiretap/toshiba.c | 1 + wiretap/visual.c | 1 + wiretap/vms.c | 1 + wiretap/wtap-int.h | 2 +- wiretap/wtap.h | 6 +- 44 files changed, 658 insertions(+), 70 deletions(-) diff --git a/cfile.h b/cfile.h index 89cd3d61b2..e2642010c8 100644 --- a/cfile.h +++ b/cfile.h @@ -54,14 +54,15 @@ typedef struct _capture_file { int displayed_count; /* Number of displayed frames */ int marked_count; /* Number of marked frames */ gboolean drops_known; /* TRUE if we know how many packets were dropped */ - guint32 drops; /* Dropped packets */ - nstime_t elapsed_time;/* Elapsed time (see: tsaccur below!) */ + guint32 drops; /* Dropped packets */ + nstime_t elapsed_time;/* Elapsed time */ gboolean has_snap; /* TRUE if maximum capture packet length is known */ int snap; /* Maximum captured packet length */ wtap *wth; /* Wiretap session */ dfilter_t *rfcode; /* Compiled read (display) filter program */ gchar *dfilter; /* Display filter string */ dfilter_t *dfcode; /* Compiled display filter program */ + /* search */ gchar *sfilter; /* Search filter string */ gboolean sbackward; /* TRUE if search is backward, FALSE if forward */ gboolean hex; /* TRUE is raw data search is being performed */ @@ -70,6 +71,7 @@ typedef struct _capture_file { gboolean case_type; /* TRUE if case-insensitive text search */ gboolean decode_data; /* TRUE if searching protocol tree text */ gboolean summary_data; /* TRUE if searching Info column text */ + /* packet data */ union wtap_pseudo_header pseudo_header; /* Packet pseudo_header */ guint8 pd[WTAP_MAX_PACKET_SIZE]; /* Packet data */ GMemChunk *plist_chunk; /* Memory chunk for frame_data structures */ @@ -82,8 +84,6 @@ typedef struct _capture_file { epan_dissect_t *edt; /* Protocol dissection for currently selected packet */ field_info *finfo_selected; /* Field info for currently selected field */ struct ph_stats_s* pstats; /* accumulated stats (reset on redisplay in GUI)*/ - int tsprecision; /* timestamp precision - (WTAP_FILE_TSPREC_USEC or WTAP_FILE_TSPREC_NSEC) */ } capture_file; void init_cap_file(capture_file *); diff --git a/dftest.c b/dftest.c index b567685ce6..75fa9aa82e 100644 --- a/dftest.c +++ b/dftest.c @@ -65,7 +65,7 @@ main(int argc, char **argv) e_prefs *prefs; dfilter_t *df; - set_timestamp_setting(TS_RELATIVE); + timestamp_set_type(TS_RELATIVE); /* register all dissectors; we must do this before checking for the "-g" flag, as the "-g" flag dumps a list of fields registered diff --git a/epan/column-utils.c b/epan/column-utils.c index 7120ce474a..d77b3c650a 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -476,7 +476,57 @@ col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col) then = fd->abs_ts.secs; tmp = localtime(&then); if (tmp != NULL) { - g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, + switch(timestamp_get_precision()) { + case(TS_PREC_FIXED_SEC): + case(TS_PREC_AUTO_SEC): + g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, + "%04d-%02d-%02d %02d:%02d:%02d", + tmp->tm_year + 1900, + tmp->tm_mon + 1, + tmp->tm_mday, + tmp->tm_hour, + tmp->tm_min, + tmp->tm_sec); + break; + case(TS_PREC_FIXED_DSEC): + case(TS_PREC_AUTO_DSEC): + g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, + "%04d-%02d-%02d %02d:%02d:%02d.%01ld", + tmp->tm_year + 1900, + tmp->tm_mon + 1, + tmp->tm_mday, + 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): + g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, + "%04d-%02d-%02d %02d:%02d:%02d.%02ld", + tmp->tm_year + 1900, + tmp->tm_mon + 1, + tmp->tm_mday, + 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): + g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, + "%04d-%02d-%02d %02d:%02d:%02d.%03ld", + tmp->tm_year + 1900, + tmp->tm_mon + 1, + tmp->tm_mday, + 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): + g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, "%04d-%02d-%02d %02d:%02d:%02d.%06ld", tmp->tm_year + 1900, tmp->tm_mon + 1, @@ -484,7 +534,23 @@ col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col) tmp->tm_hour, tmp->tm_min, tmp->tm_sec, - (long)fd->abs_ts.nsecs / 1000); /* XXX - this has to be improved */ + (long)fd->abs_ts.nsecs / 1000); + break; + case(TS_PREC_FIXED_NSEC): + case(TS_PREC_AUTO_NSEC): + g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, + "%04d-%02d-%02d %02d:%02d:%02d.%09ld", + tmp->tm_year + 1900, + tmp->tm_mon + 1, + tmp->tm_mday, + tmp->tm_hour, + tmp->tm_min, + tmp->tm_sec, + (long)fd->abs_ts.nsecs); + break; + default: + g_assert_not_reached(); + } } else { cinfo->col_buf[col][0] = '\0'; } @@ -496,8 +562,40 @@ col_set_abs_date_time(frame_data *fd, column_info *cinfo, int col) static void col_set_rel_time(frame_data *fd, column_info *cinfo, int col) { - display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, - fd->rel_ts.secs, fd->rel_ts.nsecs / 1000, USECS); /* XXX - this has to be improved */ + switch(timestamp_get_precision()) { + case(TS_PREC_FIXED_SEC): + case(TS_PREC_AUTO_SEC): + display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + fd->rel_ts.secs, fd->rel_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, + fd->rel_ts.secs, fd->rel_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, + fd->rel_ts.secs, fd->rel_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, + fd->rel_ts.secs, fd->rel_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, + fd->rel_ts.secs, fd->rel_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, + fd->rel_ts.secs, fd->rel_ts.nsecs, NSECS); + break; + default: + g_assert_not_reached(); + } cinfo->col_data[col] = cinfo->col_buf[col]; strcpy(cinfo->col_expr[col],"frame.time_relative"); strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]); @@ -506,8 +604,40 @@ col_set_rel_time(frame_data *fd, column_info *cinfo, int col) static void col_set_delta_time(frame_data *fd, column_info *cinfo, int col) { - display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, - fd->del_ts.secs, fd->del_ts.nsecs / 1000, USECS); + switch(timestamp_get_precision()) { + case(TS_PREC_FIXED_SEC): + case(TS_PREC_AUTO_SEC): + display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + fd->del_ts.secs, fd->del_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, + fd->del_ts.secs, fd->del_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, + fd->del_ts.secs, fd->del_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, + fd->del_ts.secs, fd->del_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, + fd->del_ts.secs, fd->del_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, + fd->del_ts.secs, fd->del_ts.nsecs, NSECS); + break; + default: + g_assert_not_reached(); + } cinfo->col_data[col] = cinfo->col_buf[col]; strcpy(cinfo->col_expr[col],"frame.time_delta"); strcpy(cinfo->col_expr_val[col],cinfo->col_buf[col]); @@ -524,11 +654,63 @@ col_set_abs_time(frame_data *fd, column_info *cinfo, int col) then = fd->abs_ts.secs; tmp = localtime(&then); if (tmp != NULL) { - g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, "%02d:%02d:%02d.%06ld", + switch(timestamp_get_precision()) { + case(TS_PREC_FIXED_SEC): + case(TS_PREC_AUTO_SEC): + g_snprintf(cinfo->col_buf[col], 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): + g_snprintf(cinfo->col_buf[col], 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): + g_snprintf(cinfo->col_buf[col], 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): + g_snprintf(cinfo->col_buf[col], 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): + g_snprintf(cinfo->col_buf[col], 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): + g_snprintf(cinfo->col_buf[col], COL_MAX_LEN, + "%02d:%02d:%02d.%09ld", tmp->tm_hour, tmp->tm_min, tmp->tm_sec, - (long)fd->abs_ts.nsecs / 1000); /* XXX - this has to be improved */ + (long)fd->abs_ts.nsecs); + break; + default: + g_assert_not_reached(); + } } else { cinfo->col_buf[col][0] = '\0'; } @@ -547,7 +729,7 @@ col_set_abs_time(frame_data *fd, column_info *cinfo, int col) void col_set_cls_time(frame_data *fd, column_info *cinfo, int col) { - switch (get_timestamp_setting()) { + switch (timestamp_get_type()) { case TS_ABSOLUTE: col_set_abs_time(fd, cinfo, col); break; diff --git a/epan/column.c b/epan/column.c index 83d96d0004..90dae76709 100644 --- a/epan/column.c +++ b/epan/column.c @@ -214,6 +214,115 @@ get_column_format_matches(gboolean *fmt_list, gint format) { } } +/* Returns a string representing the longest possible value for + a timestamp column type. */ +static const char * +get_timestamp_column_longest_string(gint type, gint precision) +{ + + switch(type) { + case(TS_ABSOLUTE_WITH_DATE): + switch(precision) { + case(TS_PREC_AUTO_SEC): + case(TS_PREC_FIXED_SEC): + return "0000-00-00 00:00:00"; + break; + case(TS_PREC_AUTO_DSEC): + case(TS_PREC_FIXED_DSEC): + return "0000-00-00 00:00:00.0"; + break; + case(TS_PREC_AUTO_CSEC): + case(TS_PREC_FIXED_CSEC): + return "0000-00-00 00:00:00.00"; + break; + case(TS_PREC_AUTO_MSEC): + case(TS_PREC_FIXED_MSEC): + return "0000-00-00 00:00:00.000"; + break; + case(TS_PREC_AUTO_USEC): + case(TS_PREC_FIXED_USEC): + return "0000-00-00 00:00:00.000000"; + break; + case(TS_PREC_AUTO_NSEC): + case(TS_PREC_FIXED_NSEC): + return "0000-00-00 00:00:00.000000000"; + break; + default: + g_assert_not_reached(); + } + break; + case(TS_ABSOLUTE): + switch(precision) { + case(TS_PREC_AUTO_SEC): + case(TS_PREC_FIXED_SEC): + return "00:00:00"; + break; + case(TS_PREC_AUTO_DSEC): + case(TS_PREC_FIXED_DSEC): + return "00:00:00.0"; + break; + case(TS_PREC_AUTO_CSEC): + case(TS_PREC_FIXED_CSEC): + return "00:00:00.00"; + break; + case(TS_PREC_AUTO_MSEC): + case(TS_PREC_FIXED_MSEC): + return "00:00:00.000"; + break; + case(TS_PREC_AUTO_USEC): + case(TS_PREC_FIXED_USEC): + return "00:00:00.000000"; + break; + case(TS_PREC_AUTO_NSEC): + case(TS_PREC_FIXED_NSEC): + return "00:00:00.000000000"; + break; + default: + g_assert_not_reached(); + } + break; + case(TS_RELATIVE): /* fallthrough */ + case(TS_DELTA): + switch(precision) { + case(TS_PREC_AUTO_SEC): + case(TS_PREC_FIXED_SEC): + return "0000"; + break; + case(TS_PREC_AUTO_DSEC): + case(TS_PREC_FIXED_DSEC): + return "0000.0"; + break; + case(TS_PREC_AUTO_CSEC): + case(TS_PREC_FIXED_CSEC): + return "0000.00"; + break; + case(TS_PREC_AUTO_MSEC): + case(TS_PREC_FIXED_MSEC): + return "0000.000"; + break; + case(TS_PREC_AUTO_USEC): + case(TS_PREC_FIXED_USEC): + return "0000.000000"; + break; + case(TS_PREC_AUTO_NSEC): + case(TS_PREC_FIXED_NSEC): + return "0000.000000000"; + break; + default: + g_assert_not_reached(); + } + break; + case(TS_NOT_SET): + return "0000.000000"; + break; + default: + g_assert_not_reached(); + } + + /* never reached, satisfy compiler */ + return ""; +} + /* Returns a string representing the longest possible value for a particular column type. @@ -234,22 +343,19 @@ get_column_longest_string(gint format) return "0000000"; break; case COL_CLS_TIME: - if (get_timestamp_setting() == TS_ABSOLUTE) - return "00:00:00.000000"; - else if (get_timestamp_setting() == TS_ABSOLUTE_WITH_DATE) - return "0000-00-00 00:00:00.000000"; - else - return "0000.000000"; - break; - case COL_ABS_TIME: - return "00:00:00.000000"; + return get_timestamp_column_longest_string(timestamp_get_type(), timestamp_get_precision()); break; case COL_ABS_DATE_TIME: - return "0000-00-00 00:00:00.000000"; + return get_timestamp_column_longest_string(TS_ABSOLUTE_WITH_DATE, timestamp_get_precision()); + break; + case COL_ABS_TIME: + return get_timestamp_column_longest_string(TS_ABSOLUTE, timestamp_get_precision()); break; case COL_REL_TIME: + return get_timestamp_column_longest_string(TS_RELATIVE, timestamp_get_precision()); + break; case COL_DELTA_TIME: - return "0000.000000"; + return get_timestamp_column_longest_string(TS_DELTA, timestamp_get_precision()); break; case COL_DEF_SRC: case COL_RES_SRC: diff --git a/epan/libethereal.def b/epan/libethereal.def index ea14571675..7e8db18328 100644 --- a/epan/libethereal.def +++ b/epan/libethereal.def @@ -307,7 +307,6 @@ get_plugins_pers_dir get_systemfile_dir get_tcp_port get_tempfile_path -get_timestamp_setting get_udp_port gsm_a_bssmap_msg_strings DATA gsm_a_dtap_msg_cc_strings DATA @@ -522,7 +521,6 @@ rtp_free_hash_dyn_payload rtp_payload_type_vals DATA rtp_payload_type_short_vals DATA set_actual_length -set_timestamp_setting show_fragment_seq_tree show_fragment_tree sid_name_snooping DATA @@ -563,6 +561,10 @@ test_for_directory test_for_fifo time_msecs_to_str time_secs_to_str +timestamp_get_precision +timestamp_get_type +timestamp_set_precision +timestamp_set_type trans2_cmd_vals DATA tree_is_expanded DATA tvb_bytes_exist diff --git a/epan/timestamp.c b/epan/timestamp.c index d948fda3d5..b7cef811f6 100644 --- a/epan/timestamp.c +++ b/epan/timestamp.c @@ -32,12 +32,26 @@ * and distinguish it from a command line value */ static ts_type timestamp_type = TS_NOT_SET; -ts_type get_timestamp_setting(void) +static int timestamp_precision = TS_PREC_AUTO_USEC; + +ts_type timestamp_get_type(void) { return timestamp_type; } -void set_timestamp_setting(ts_type ts_t) +void timestamp_set_type(ts_type ts_t) { timestamp_type = ts_t; } + + +int timestamp_get_precision(void) +{ + return timestamp_precision; +} + +void timestamp_set_precision(int tsp) +{ + timestamp_precision = tsp; +} + diff --git a/epan/timestamp.h b/epan/timestamp.h index 706fba4ce9..f9f953219b 100644 --- a/epan/timestamp.h +++ b/epan/timestamp.h @@ -32,16 +32,34 @@ typedef enum { TS_RELATIVE, TS_ABSOLUTE, TS_ABSOLUTE_WITH_DATE, - TS_DELTA -} ts_type; - + TS_DELTA, /* * Special value used for the command-line setting in Ethereal, to indicate * that no value has been set from the command line. */ -#define TS_NOT_SET ((ts_type)-1) + TS_NOT_SET +} ts_type; + +typedef enum { + TS_PREC_AUTO, /* recent */ + 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_USEC, /* recent and internal */ + TS_PREC_FIXED_NSEC, /* recent and internal */ + TS_PREC_AUTO_SEC, /* internal */ + TS_PREC_AUTO_DSEC, /* internal */ + TS_PREC_AUTO_CSEC, /* internal */ + TS_PREC_AUTO_MSEC, /* internal */ + TS_PREC_AUTO_USEC, /* internal */ + TS_PREC_AUTO_NSEC /* internal */ +} ts_precision; + +extern ts_type timestamp_get_type(void); +extern void timestamp_set_type(ts_type); -extern ts_type get_timestamp_setting(void); -extern void set_timestamp_setting(ts_type); +extern int timestamp_get_precision(void); +extern void timestamp_set_precision(int tsp); #endif /* timestamp.h */ diff --git a/epan/to_str.c b/epan/to_str.c index 3e00274fe0..0431f66233 100644 --- a/epan/to_str.c +++ b/epan/to_str.c @@ -506,6 +506,18 @@ display_signed_time(gchar *buf, int buflen, gint32 sec, gint32 frac, } switch (units) { + case SECS: + g_snprintf(buf, buflen, "%s%d", sign, sec); + break; + + case DSECS: + g_snprintf(buf, buflen, "%s%d.%01d", sign, sec, frac); + break; + + case CSECS: + g_snprintf(buf, buflen, "%s%d.%02d", sign, sec, frac); + break; + case MSECS: g_snprintf(buf, buflen, "%s%d.%03d", sign, sec, frac); break; diff --git a/epan/to_str.h b/epan/to_str.h index e34a8242b5..55449f490d 100644 --- a/epan/to_str.h +++ b/epan/to_str.h @@ -37,6 +37,9 @@ * Resolution of a time stamp. */ typedef enum { + SECS, /* seconds */ + DSECS, /* deciseconds */ + CSECS, /* centiseconds */ MSECS, /* milliseconds */ USECS, /* microseconds */ NSECS /* nanoseconds */ diff --git a/file.c b/file.c index 14a79a1ba7..7b328b4b57 100644 --- a/file.c +++ b/file.c @@ -76,6 +76,8 @@ #include "stat_menu.h" #include "tap_dfilter_dlg.h" #include +#include + /* Win32 needs the O_BINARY flag for open() */ #ifndef O_BINARY @@ -162,6 +164,51 @@ cf_callback_remove(cf_callback_t func _U_) cf_cb_user_data = NULL; } +void +cf_timestamp_auto_precision(capture_file *cf) +{ + int prec = timestamp_get_precision(); + + + /* don't try to get the file's precision if none is opened */ + if(cf->state == FILE_CLOSED) { + return; + } + + /* if we are in auto mode, set precision of current file */ + if(prec == TS_PREC_AUTO || + prec == TS_PREC_AUTO_SEC || + prec == TS_PREC_AUTO_DSEC || + prec == TS_PREC_AUTO_CSEC || + prec == TS_PREC_AUTO_MSEC || + prec == TS_PREC_AUTO_USEC || + prec == TS_PREC_AUTO_NSEC) + { + switch(wtap_file_tsprecision(cf->wth)) { + case(WTAP_FILE_TSPREC_SEC): + timestamp_set_precision(TS_PREC_AUTO_SEC); + break; + case(WTAP_FILE_TSPREC_DSEC): + timestamp_set_precision(TS_PREC_AUTO_DSEC); + break; + case(WTAP_FILE_TSPREC_CSEC): + timestamp_set_precision(TS_PREC_AUTO_CSEC); + break; + case(WTAP_FILE_TSPREC_MSEC): + timestamp_set_precision(TS_PREC_AUTO_MSEC); + break; + case(WTAP_FILE_TSPREC_USEC): + timestamp_set_precision(TS_PREC_AUTO_USEC); + break; + case(WTAP_FILE_TSPREC_NSEC): + timestamp_set_precision(TS_PREC_AUTO_NSEC); + break; + default: + g_assert_not_reached(); + } + } +} + cf_status_t cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err) @@ -198,7 +245,6 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err) cf->user_saved = !is_tempfile; cf->cd_t = wtap_file_type(cf->wth); - cf->tsprecision = wtap_file_tsprecision(cf->wth); cf->count = 0; cf->displayed_count = 0; cf->marked_count = 0; @@ -221,6 +267,9 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err) G_ALLOC_AND_FREE); g_assert(cf->plist_chunk); + /* change the time formats now, as we might have a new precision */ + cf_change_time_formats(cf); + fileset_file_opened(fname); return CF_OK; @@ -2124,6 +2173,10 @@ cf_change_time_formats(capture_file *cf) int first, last; gboolean sorted_by_frame_column; + + /* adjust timestamp precision if auto is selected */ + cf_timestamp_auto_precision(cf); + /* Are there any columns with time stamps in the "command-line-specified" format? diff --git a/gtk/main.c b/gtk/main.c index dd8642216b..23201d2d8b 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -2085,13 +2085,13 @@ main(int argc, char *argv[]) break; case 't': /* Time stamp type */ if (strcmp(optarg, "r") == 0) - set_timestamp_setting(TS_RELATIVE); + timestamp_set_type(TS_RELATIVE); else if (strcmp(optarg, "a") == 0) - set_timestamp_setting(TS_ABSOLUTE); + timestamp_set_type(TS_ABSOLUTE); else if (strcmp(optarg, "ad") == 0) - set_timestamp_setting(TS_ABSOLUTE_WITH_DATE); + timestamp_set_type(TS_ABSOLUTE_WITH_DATE); else if (strcmp(optarg, "d") == 0) - set_timestamp_setting(TS_DELTA); + timestamp_set_type(TS_DELTA); else { fprintf(stderr, "ethereal: Invalid time stamp type \"%s\"\n", optarg); diff --git a/gtk/menu.c b/gtk/menu.c index 7cdec439fa..20a4148569 100644 --- a/gtk/menu.c +++ b/gtk/menu.c @@ -114,6 +114,13 @@ static void timestamp_absolute_cb(GtkWidget *w _U_, gpointer d _U_); static void timestamp_absolute_date_cb(GtkWidget *w _U_, gpointer d _U_); static void timestamp_relative_cb(GtkWidget *w _U_, gpointer d _U_); static void timestamp_delta_cb(GtkWidget *w _U_, gpointer d _U_); +static void timestamp_auto_cb(GtkWidget *w _U_, gpointer d _U_); +static void timestamp_sec_cb(GtkWidget *w _U_, gpointer d _U_); +static void timestamp_dsec_cb(GtkWidget *w _U_, gpointer d _U_); +static void timestamp_csec_cb(GtkWidget *w _U_, gpointer d _U_); +static void timestamp_msec_cb(GtkWidget *w _U_, gpointer d _U_); +static void timestamp_usec_cb(GtkWidget *w _U_, gpointer d _U_); +static void timestamp_nsec_cb(GtkWidget *w _U_, gpointer d _U_); static void name_resolution_mac_cb(GtkWidget *w _U_, gpointer d _U_); static void name_resolution_network_cb(GtkWidget *w _U_, gpointer d _U_); static void name_resolution_transport_cb(GtkWidget *w _U_, gpointer d _U_); @@ -247,14 +254,29 @@ static GtkItemFactoryEntry menu_items[] = ITEM_FACTORY_ENTRY("/View/Packet _Bytes", NULL, byte_view_show_cb, 0, "", NULL), ITEM_FACTORY_ENTRY("/View/", NULL, NULL, 0, "", NULL), ITEM_FACTORY_ENTRY("/View/_Time Display Format", NULL, NULL, 0, "", NULL), - ITEM_FACTORY_ENTRY("/View/Time Display Format/Time of Day", NULL, timestamp_absolute_cb, + ITEM_FACTORY_ENTRY("/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", NULL, timestamp_absolute_date_cb, 0, "", NULL), - ITEM_FACTORY_ENTRY("/View/Time Display Format/Date and Time of Day", NULL, timestamp_absolute_date_cb, - 0, "/View/Time Display Format/Time of Day", NULL), - ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds Since Beginning of Capture", NULL, timestamp_relative_cb, - 0, "/View/Time Display Format/Time of Day", NULL), - ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds Since Previous Packet", NULL, timestamp_delta_cb, - 0, "/View/Time Display Format/Time of Day", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Time of Day: 01:02:03.123456", NULL, timestamp_absolute_cb, + 0, "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds Since Beginning of Capture: 123.123456", NULL, timestamp_relative_cb, + 0, "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds Since Previous Packet: 1.123456", NULL, timestamp_delta_cb, + 0, "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/", NULL, NULL, 0, "", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Automatic (File Format Precision)", NULL, timestamp_auto_cb, + 0, "", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds: 0", NULL, timestamp_sec_cb, + 0, "/View/Time Display Format/Automatic (File Format Precision)", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Deciseconds: 0.1", NULL, timestamp_dsec_cb, + 0, "/View/Time Display Format/Automatic (File Format Precision)", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Centiseconds: 0.12", NULL, timestamp_csec_cb, + 0, "/View/Time Display Format/Automatic (File Format Precision)", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Milliseconds: 0.123", NULL, timestamp_msec_cb, + 0, "/View/Time Display Format/Automatic (File Format Precision)", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Microseconds: 0.123456", NULL, timestamp_usec_cb, + 0, "/View/Time Display Format/Automatic (File Format Precision)", NULL), + ITEM_FACTORY_ENTRY("/View/Time Display Format/Nanoseconds: 0.123456789", NULL, timestamp_nsec_cb, + 0, "/View/Time Display Format/Automatic (File Format Precision)", NULL), ITEM_FACTORY_ENTRY("/View/Name Resol_ution", NULL, NULL, 0, "", NULL), ITEM_FACTORY_ENTRY("/View/Name Resolution/_Resolve Name", NULL, resolve_name_cb, 0, NULL, NULL), ITEM_FACTORY_ENTRY("/View/Name Resolution/", NULL, NULL, 0, "", NULL), @@ -1294,7 +1316,7 @@ static void timestamp_absolute_cb(GtkWidget *w _U_, gpointer d _U_) { if (recent.gui_time_format != TS_ABSOLUTE) { - set_timestamp_setting(TS_ABSOLUTE); + timestamp_set_type(TS_ABSOLUTE); recent.gui_time_format = TS_ABSOLUTE; cf_change_time_formats(&cfile); } @@ -1304,7 +1326,7 @@ static void timestamp_absolute_date_cb(GtkWidget *w _U_, gpointer d _U_) { if (recent.gui_time_format != TS_ABSOLUTE_WITH_DATE) { - set_timestamp_setting(TS_ABSOLUTE_WITH_DATE); + timestamp_set_type(TS_ABSOLUTE_WITH_DATE); recent.gui_time_format = TS_ABSOLUTE_WITH_DATE; cf_change_time_formats(&cfile); } @@ -1314,7 +1336,7 @@ static void timestamp_relative_cb(GtkWidget *w _U_, gpointer d _U_) { if (recent.gui_time_format != TS_RELATIVE) { - set_timestamp_setting(TS_RELATIVE); + timestamp_set_type(TS_RELATIVE); recent.gui_time_format = TS_RELATIVE; cf_change_time_formats(&cfile); } @@ -1324,12 +1346,84 @@ static void timestamp_delta_cb(GtkWidget *w _U_, gpointer d _U_) { if (recent.gui_time_format != TS_DELTA) { - set_timestamp_setting(TS_DELTA); + timestamp_set_type(TS_DELTA); recent.gui_time_format = TS_DELTA; cf_change_time_formats(&cfile); } } +static void +timestamp_auto_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (recent.gui_time_precision != TS_PREC_AUTO) { + /* the actual precision will be set in cf_change_time_formats() below */ + timestamp_set_precision(TS_PREC_AUTO_SEC); + recent.gui_time_precision = TS_PREC_AUTO; + cf_change_time_formats(&cfile); + } +} + +static void +timestamp_sec_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (recent.gui_time_precision != TS_PREC_FIXED_SEC) { + timestamp_set_precision(TS_PREC_FIXED_SEC); + recent.gui_time_precision = TS_PREC_FIXED_SEC; + cf_change_time_formats(&cfile); + } +} + +static void +timestamp_dsec_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (recent.gui_time_precision != TS_PREC_FIXED_DSEC) { + timestamp_set_precision(TS_PREC_FIXED_DSEC); + recent.gui_time_precision = TS_PREC_FIXED_DSEC; + cf_change_time_formats(&cfile); + } +} + +static void +timestamp_csec_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (recent.gui_time_precision != TS_PREC_FIXED_CSEC) { + timestamp_set_precision(TS_PREC_FIXED_CSEC); + recent.gui_time_precision = TS_PREC_FIXED_CSEC; + cf_change_time_formats(&cfile); + } +} + +static void +timestamp_msec_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (recent.gui_time_precision != TS_PREC_FIXED_MSEC) { + timestamp_set_precision(TS_PREC_FIXED_MSEC); + recent.gui_time_precision = TS_PREC_FIXED_MSEC; + cf_change_time_formats(&cfile); + } +} + +static void +timestamp_usec_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (recent.gui_time_precision != TS_PREC_FIXED_USEC) { + timestamp_set_precision(TS_PREC_FIXED_USEC); + recent.gui_time_precision = TS_PREC_FIXED_USEC; + cf_change_time_formats(&cfile); + } +} + +static void +timestamp_nsec_cb(GtkWidget *w _U_, gpointer d _U_) +{ + if (recent.gui_time_precision != TS_PREC_FIXED_NSEC) { + timestamp_set_precision(TS_PREC_FIXED_NSEC); + recent.gui_time_precision = TS_PREC_FIXED_NSEC; + cf_change_time_formats(&cfile); + } +} + + void menu_name_resolution_changed(void) { @@ -1469,34 +1563,35 @@ menu_recent_read_finished(void) { main_widgets_rearrange(); /* don't change the time format, if we had a command line value */ - if (get_timestamp_setting() != TS_NOT_SET) { - recent.gui_time_format = get_timestamp_setting(); + if (timestamp_get_type() != TS_NOT_SET) { + recent.gui_time_format = timestamp_get_type(); } switch(recent.gui_time_format) { - case(TS_ABSOLUTE): + case(TS_ABSOLUTE_WITH_DATE): menu = gtk_item_factory_get_widget(main_menu_factory, - "/View/Time Display Format/Time of Day"); + "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456"); /* set_active will not trigger the callback when activating an active item! */ recent.gui_time_format = -1; 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; - case(TS_ABSOLUTE_WITH_DATE): + case(TS_ABSOLUTE): menu = gtk_item_factory_get_widget(main_menu_factory, - "/View/Time Display Format/Date and Time of Day"); + "/View/Time Display Format/Time of Day: 01:02:03.123456"); + /* set_active will not trigger the callback when activating an active item! */ recent.gui_time_format = -1; gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); break; case(TS_RELATIVE): menu = gtk_item_factory_get_widget(main_menu_factory, - "/View/Time Display Format/Seconds Since Beginning of Capture"); + "/View/Time Display Format/Seconds Since Beginning of Capture: 123.123456"); recent.gui_time_format = -1; gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); break; case(TS_DELTA): menu = gtk_item_factory_get_widget(main_menu_factory, - "/View/Time Display Format/Seconds Since Previous Packet"); + "/View/Time Display Format/Seconds Since Previous Packet: 1.123456"); recent.gui_time_format = -1; gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); break; @@ -1504,6 +1599,55 @@ menu_recent_read_finished(void) { g_assert_not_reached(); } + switch(recent.gui_time_precision) { + case(TS_PREC_AUTO): + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/Automatic (File Format Precision)"); + /* set_active will not trigger the callback when activating an active item! */ + recent.gui_time_precision = -1; + 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; + case(TS_PREC_FIXED_SEC): + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/Seconds: 0"); + recent.gui_time_precision = -1; + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); + break; + case(TS_PREC_FIXED_DSEC): + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/Deciseconds: 0.1"); + recent.gui_time_precision = -1; + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); + break; + case(TS_PREC_FIXED_CSEC): + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/Centiseconds: 0.12"); + recent.gui_time_precision = -1; + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); + break; + case(TS_PREC_FIXED_MSEC): + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/Milliseconds: 0.123"); + recent.gui_time_precision = -1; + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); + break; + case(TS_PREC_FIXED_USEC): + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/Microseconds: 0.123456"); + recent.gui_time_precision = -1; + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE); + break; + case(TS_PREC_FIXED_NSEC): + menu = gtk_item_factory_get_widget(main_menu_factory, + "/View/Time Display Format/Nanoseconds: 0.123456789"); + recent.gui_time_precision = -1; + 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); } diff --git a/gtk/packet_list.c b/gtk/packet_list.c index 880860bb60..4ed93e3f93 100644 --- a/gtk/packet_list.c +++ b/gtk/packet_list.c @@ -158,7 +158,7 @@ packet_list_compare(EthCList *clist, gconstpointer ptr1, gconstpointer ptr2) return COMPARE_FRAME_NUM(); case COL_CLS_TIME: - switch (get_timestamp_setting()) { + switch (timestamp_get_type()) { case TS_ABSOLUTE: case TS_ABSOLUTE_WITH_DATE: diff --git a/gtk/recent.c b/gtk/recent.c index c5a955dc55..85e505cdb3 100644 --- a/gtk/recent.c +++ b/gtk/recent.c @@ -52,6 +52,7 @@ #define RECENT_KEY_STATUSBAR_SHOW "gui.statusbar_show" #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_ZOOM_LEVEL "gui.zoom_level" #define RECENT_GUI_GEOMETRY_MAIN_X "gui.geometry_main_x" #define RECENT_GUI_GEOMETRY_MAIN_Y "gui.geometry_main_y" @@ -71,6 +72,9 @@ recent_settings_t recent; static const char *ts_type_text[] = { "RELATIVE", "ABSOLUTE", "ABSOLUTE_WITH_DATE", "DELTA", NULL }; +static const char *ts_precision_text[] = + { "AUTO", "SEC", "DSEC", "CSEC", "MSEC", "USEC", "NSEC", 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 @@ -187,6 +191,11 @@ write_recent(void) fprintf(rf, RECENT_GUI_TIME_FORMAT ": %s\n", ts_type_text[recent.gui_time_format]); + fprintf(rf, "\n# Timestamp display precision.\n"); + fprintf(rf, "# One of: AUTO, SEC, DSEC, CSEC, MSEC, USEC, NSEC\n"); + fprintf(rf, RECENT_GUI_TIME_PRECISION ": %s\n", + ts_precision_text[recent.gui_time_precision]); + fprintf(rf, "\n# Zoom level.\n"); fprintf(rf, "# A decimal number.\n"); fprintf(rf, RECENT_GUI_ZOOM_LEVEL ": %d\n", @@ -326,6 +335,9 @@ read_set_recent_pair_static(gchar *key, gchar *value) } else if (strcmp(key, RECENT_GUI_TIME_FORMAT) == 0) { recent.gui_time_format = find_index_from_string_array(value, ts_type_text, TS_RELATIVE); + } 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_ZOOM_LEVEL) == 0) { num = strtol(value, &p, 0); if (p == value || *p != '\0') @@ -479,6 +491,7 @@ recent_read_static(char **rf_path_return, int *rf_errno_return) recent.statusbar_show = TRUE; recent.packet_list_colorize = TRUE; recent.gui_time_format = TS_RELATIVE; + recent.gui_time_precision = TS_PREC_AUTO; recent.gui_zoom_level = 0; recent.gui_geometry_main_x = 20; diff --git a/gtk/recent.h b/gtk/recent.h index 43d9bf636e..ab53fa642c 100644 --- a/gtk/recent.h +++ b/gtk/recent.h @@ -49,6 +49,7 @@ typedef struct recent_settings_tag { gboolean statusbar_show; gboolean packet_list_colorize; gint gui_time_format; + gint gui_time_precision; gint gui_zoom_level; gint gui_geometry_main_x; diff --git a/tethereal.c b/tethereal.c index 65f933cd81..2f3d7db5dc 100644 --- a/tethereal.c +++ b/tethereal.c @@ -656,7 +656,8 @@ main(int argc, char *argv[]) capture_opts_init(&capture_opts, NULL /* cfile */); #endif - set_timestamp_setting(TS_RELATIVE); + timestamp_set_type(TS_RELATIVE); + timestamp_set_precision(TS_PREC_AUTO); /* Register all dissectors; we must do this before checking for the "-G" flag, as the "-G" flag dumps information registered by the @@ -961,13 +962,13 @@ main(int argc, char *argv[]) break; case 't': /* Time stamp type */ if (strcmp(optarg, "r") == 0) - set_timestamp_setting(TS_RELATIVE); + timestamp_set_type(TS_RELATIVE); else if (strcmp(optarg, "a") == 0) - set_timestamp_setting(TS_ABSOLUTE); + timestamp_set_type(TS_ABSOLUTE); else if (strcmp(optarg, "ad") == 0) - set_timestamp_setting(TS_ABSOLUTE_WITH_DATE); + timestamp_set_type(TS_ABSOLUTE_WITH_DATE); else if (strcmp(optarg, "d") == 0) - set_timestamp_setting(TS_DELTA); + timestamp_set_type(TS_DELTA); else { fprintf(stderr, "tethereal: Invalid time stamp type \"%s\"\n", optarg); diff --git a/wiretap/5views.c b/wiretap/5views.c index 38fc251ef9..e44969fe4f 100644 --- a/wiretap/5views.c +++ b/wiretap/5views.c @@ -197,6 +197,7 @@ int _5views_open(wtap *wth, int *err, gchar **err_info) wth->subtype_seek_read = _5views_seek_read; wth->file_encap = encap; wth->snapshot_length = 0; /* not available in header */ + wth->tsprecision = WTAP_FILE_TSPREC_NSEC; return 1; } diff --git a/wiretap/airopeek9.c b/wiretap/airopeek9.c index 2eee7f5f76..30aa098008 100644 --- a/wiretap/airopeek9.c +++ b/wiretap/airopeek9.c @@ -301,6 +301,7 @@ int airopeek9_open(wtap *wth, int *err, gchar **err_info) wth->subtype_read = airopeekv9_read; wth->subtype_seek_read = airopeekv9_seek_read; wth->subtype_close = airopeekv9_close; + wth->tsprecision = WTAP_FILE_TSPREC_NSEC; wth->capture.airopeek9 = g_malloc(sizeof(airopeek9_t)); switch (mediaSubType) { diff --git a/wiretap/ascend.c b/wiretap/ascend.c index 0145aec796..2ff4794a01 100644 --- a/wiretap/ascend.c +++ b/wiretap/ascend.c @@ -225,6 +225,7 @@ int ascend_open(wtap *wth, int *err, gchar **err_info _U_) } wth->capture.ascend->inittime = statbuf.st_ctime; wth->capture.ascend->adjusted = 0; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; init_parse_ascend(); diff --git a/wiretap/cosine.c b/wiretap/cosine.c index e185ea9f7f..841d80bac9 100644 --- a/wiretap/cosine.c +++ b/wiretap/cosine.c @@ -299,6 +299,7 @@ int cosine_open(wtap *wth, int *err, gchar **err_info _U_) wth->snapshot_length = 0; /* not known */ wth->subtype_read = cosine_read; wth->subtype_seek_read = cosine_seek_read; + wth->tsprecision = WTAP_FILE_TSPREC_CSEC; return 1; } diff --git a/wiretap/csids.c b/wiretap/csids.c index ff7c55c687..28ea047c71 100644 --- a/wiretap/csids.c +++ b/wiretap/csids.c @@ -138,6 +138,7 @@ int csids_open(wtap *wth, int *err, gchar **err_info _U_) wth->subtype_read = csids_read; wth->subtype_seek_read = csids_seek_read; wth->subtype_close = csids_close; + wth->tsprecision = WTAP_FILE_TSPREC_SEC; return 1; } diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c index 7331b694c1..39f41494e2 100644 --- a/wiretap/dbs-etherwatch.c +++ b/wiretap/dbs-etherwatch.c @@ -199,6 +199,7 @@ int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info _U_) wth->snapshot_length = 0; /* not known */ wth->subtype_read = dbs_etherwatch_read; wth->subtype_seek_read = dbs_etherwatch_seek_read; + wth->tsprecision = WTAP_FILE_TSPREC_CSEC; return 1; } diff --git a/wiretap/erf.c b/wiretap/erf.c index 0937e9004b..a71424eed6 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -214,6 +214,7 @@ int erf_open(wtap *wth, int *err, gchar **err_info _U_) wth->subtype_read = erf_read; wth->subtype_seek_read = erf_seek_read; wth->subtype_close = erf_close; + wth->tsprecision = WTAP_FILE_TSPREC_NSEC; return 1; } diff --git a/wiretap/etherpeek.c b/wiretap/etherpeek.c index afa8044f90..6aea88515b 100644 --- a/wiretap/etherpeek.c +++ b/wiretap/etherpeek.c @@ -353,6 +353,7 @@ int etherpeek_open(wtap *wth, int *err, gchar **err_info _U_) } wth->snapshot_length = 0; /* not available in header */ + wth->tsprecision = WTAP_FILE_TSPREC_USEC; return 1; } diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c index 277a4684ec..6c47523d2c 100644 --- a/wiretap/eyesdn.c +++ b/wiretap/eyesdn.c @@ -155,6 +155,7 @@ int eyesdn_open(wtap *wth, int *err, gchar **err_info _U_) wth->snapshot_length = 0; /* not known */ wth->subtype_read = eyesdn_read; wth->subtype_seek_read = eyesdn_seek_read; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; return 1; } diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c index ccca83ce8f..7aeadeab70 100644 --- a/wiretap/hcidump.c +++ b/wiretap/hcidump.c @@ -154,6 +154,7 @@ int hcidump_open(wtap *wth, int *err, gchar **err_info _U_) wth->subtype_read = hcidump_read; wth->subtype_seek_read = hcidump_seek_read; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; return 1; } diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c index 11dc2cc2fd..9b9d2d6a7c 100644 --- a/wiretap/i4btrace.c +++ b/wiretap/i4btrace.c @@ -109,6 +109,7 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info _U_) wth->capture.i4btrace->byte_swapped = byte_swapped; wth->file_encap = WTAP_ENCAP_ISDN; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; return 1; } diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c index 9281b6b80c..a78323d96c 100644 --- a/wiretap/iptrace.c +++ b/wiretap/iptrace.c @@ -72,11 +72,13 @@ int iptrace_open(wtap *wth, int *err, gchar **err_info _U_) wth->file_type = WTAP_FILE_IPTRACE_1_0; wth->subtype_read = iptrace_read_1_0; wth->subtype_seek_read = iptrace_seek_read_1_0; + wth->tsprecision = WTAP_FILE_TSPREC_SEC; } else if (strcmp(name, "iptrace 2.0") == 0) { wth->file_type = WTAP_FILE_IPTRACE_2_0; wth->subtype_read = iptrace_read_2_0; wth->subtype_seek_read = iptrace_seek_read_2_0; + wth->tsprecision = WTAP_FILE_TSPREC_NSEC; } else { return 0; diff --git a/wiretap/k12.c b/wiretap/k12.c index ecd9b75185..3df194516e 100644 --- a/wiretap/k12.c +++ b/wiretap/k12.c @@ -419,6 +419,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info _U_) { wth->subtype_seek_read = k12_seek_read; wth->subtype_close = k12_close; wth->capture.k12 = file_data; + wth->tsprecision = WTAP_FILE_TSPREC_NSEC; /* if we use just one encapsulation for all the file we will use that for the whole file so we can diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index a6553ecc60..006dc4a538 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -163,6 +163,7 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info) wth->subtype_seek_read = lanalyzer_seek_read; wth->subtype_close = lanalyzer_close; wth->snapshot_length = 0; + wth->tsprecision = WTAP_FILE_TSPREC_NSEC; /* Read records until we find the start of packets */ while (1) { diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index 86bf798a6f..b1bccc7541 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -602,9 +602,6 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info) int file_encap; - /* XXX - this must be done depending on the magic number */ - /*wth->tsrecision = WTAP_FILE_TSPREC_NSEC;*/ - /* Read in the number that should be at the start of a "libpcap" file */ errno = WTAP_ERR_CANT_READ; bytes_read = file_read(&magic, 1, sizeof magic, wth->fh); @@ -623,6 +620,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info) a program using either standard or ss990417 libpcap. */ byte_swapped = FALSE; modified = FALSE; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; break; case PCAP_MODIFIED_MAGIC: @@ -630,6 +628,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info) a program using either ss990915 or ss991029 libpcap. */ byte_swapped = FALSE; modified = TRUE; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; break; case PCAP_SWAPPED_MAGIC: @@ -638,6 +637,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info) ss990417 libpcap. */ byte_swapped = TRUE; modified = FALSE; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; break; case PCAP_SWAPPED_MODIFIED_MAGIC: @@ -646,6 +646,7 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info) or ss991029 libpcap. */ byte_swapped = TRUE; modified = TRUE; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; break; default: diff --git a/wiretap/netmon.c b/wiretap/netmon.c index c3c552d2d0..19eb125bcd 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -299,6 +299,7 @@ int netmon_open(wtap *wth, int *err, gchar **err_info) /* Set up to start reading at the first frame. */ wth->capture.netmon->current_frame = 0; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; return 1; } diff --git a/wiretap/nettl.c b/wiretap/nettl.c index 75ffb9e1ca..e24e30ec7f 100644 --- a/wiretap/nettl.c +++ b/wiretap/nettl.c @@ -263,6 +263,7 @@ int nettl_open(wtap *wth, int *err, gchar **err_info _U_) return -1; } wth->data_offset = FILE_HDR_SIZE; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; return 1; } diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c index 0e226e6e48..7d723c4804 100644 --- a/wiretap/network_instruments.c +++ b/wiretap/network_instruments.c @@ -178,6 +178,7 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info) wth->subtype_close = NULL; wth->subtype_sequential_close = NULL; wth->snapshot_length = 0; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; /* reset the pointer to the first packet */ if (file_seek(wth->fh, file_header.offset_to_first_packet, SEEK_SET, diff --git a/wiretap/netxray.c b/wiretap/netxray.c index f5164a0615..f477ef70fc 100644 --- a/wiretap/netxray.c +++ b/wiretap/netxray.c @@ -404,10 +404,12 @@ int netxray_open(wtap *wth, int *err, gchar **err_info) case WTAP_FILE_NETXRAY_OLD: timeunit = 1000.0; + wth->tsprecision = WTAP_FILE_TSPREC_MSEC; break; case WTAP_FILE_NETXRAY_1_0: timeunit = 1000.0; + wth->tsprecision = WTAP_FILE_TSPREC_MSEC; break; case WTAP_FILE_NETXRAY_1_1: @@ -418,6 +420,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info) * and older versions of Windows Sniffer. */ timeunit = 1000000.0; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; break; case WTAP_FILE_NETXRAY_2_00x: @@ -443,6 +446,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info) return -1; } timeunit = TpS[hdr.timeunit]; + wth->tsprecision = WTAP_FILE_TSPREC_NSEC; /* XXX */ break; case ETH_CAPTYPE_GIGPOD: @@ -455,6 +459,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info) return -1; } timeunit = TpS_gigpod[hdr.timeunit]; + wth->tsprecision = WTAP_FILE_TSPREC_NSEC; /* XXX */ /* * At least for 002.002 and 002.003 @@ -475,6 +480,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info) return -1; } timeunit = TpS_otherpod[hdr.timeunit]; + wth->tsprecision = WTAP_FILE_TSPREC_NSEC; /* XXX */ /* * At least for 002.002 and 002.003 @@ -495,6 +501,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info) return -1; } timeunit = TpS_gigpod2[hdr.timeunit]; + wth->tsprecision = WTAP_FILE_TSPREC_NSEC; /* XXX */ break; default: @@ -516,6 +523,7 @@ int netxray_open(wtap *wth, int *err, gchar **err_info) return -1; } timeunit = TpS[hdr.timeunit]; + wth->tsprecision = WTAP_FILE_TSPREC_NSEC; /* XXX */ break; } break; diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index 04bcb78e89..d219c29c30 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -628,6 +628,8 @@ int ngsniffer_open(wtap *wth, int *err, gchar **err_info) * isn't stored in the capture file. */ + wth->tsprecision = WTAP_FILE_TSPREC_NSEC; /* XXX */ + return 1; } diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c index 8913cd8c4a..9513d6ab8f 100644 --- a/wiretap/pppdump.c +++ b/wiretap/pppdump.c @@ -295,6 +295,7 @@ pppdump_open(wtap *wth, int *err, gchar **err_info _U_) wth->subtype_read = pppdump_read; wth->subtype_seek_read = pppdump_seek_read; wth->subtype_close = pppdump_close; + wth->tsprecision = WTAP_FILE_TSPREC_DSEC; state->seek_state = g_malloc(sizeof(pppdump_t)); diff --git a/wiretap/radcom.c b/wiretap/radcom.c index 9c3934504a..c32bfbaa3b 100644 --- a/wiretap/radcom.c +++ b/wiretap/radcom.c @@ -172,6 +172,7 @@ int radcom_open(wtap *wth, int *err, gchar **err_info) wth->subtype_read = radcom_read; wth->subtype_seek_read = radcom_seek_read; wth->snapshot_length = 0; /* not available in header, only in frame */ + wth->tsprecision = WTAP_FILE_TSPREC_USEC; tm.tm_year = pletohs(&start_date.year)-1900; tm.tm_mon = start_date.month-1; diff --git a/wiretap/snoop.c b/wiretap/snoop.c index 5dc0c2a27d..c0aa19e0ee 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -398,6 +398,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info) wth->subtype_seek_read = snoop_seek_read; wth->file_encap = file_encap; wth->snapshot_length = 0; /* not available in header */ + wth->tsprecision = WTAP_FILE_TSPREC_USEC; return 1; } diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c index a9cc44d503..824b0a1591 100644 --- a/wiretap/toshiba.c +++ b/wiretap/toshiba.c @@ -226,6 +226,7 @@ int toshiba_open(wtap *wth, int *err, gchar **err_info _U_) wth->snapshot_length = 0; /* not known */ wth->subtype_read = toshiba_read; wth->subtype_seek_read = toshiba_seek_read; + wth->tsprecision = WTAP_FILE_TSPREC_CSEC; return 1; } diff --git a/wiretap/visual.c b/wiretap/visual.c index b270d508fa..34f4ab52b6 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -215,6 +215,7 @@ int visual_open(wtap *wth, int *err, gchar **err_info) wth->subtype_read = visual_read; wth->subtype_seek_read = visual_seek_read; wth->subtype_close = visual_close; + wth->tsprecision = WTAP_FILE_TSPREC_USEC; /* Add Visual-specific information to the wiretap struct for later use. */ visual = g_malloc(sizeof(struct visual_read_info)); diff --git a/wiretap/vms.c b/wiretap/vms.c index 02d0e6cc8a..81b00986dc 100644 --- a/wiretap/vms.c +++ b/wiretap/vms.c @@ -271,6 +271,7 @@ int vms_open(wtap *wth, int *err, gchar **err_info _U_) wth->snapshot_length = 0; /* not known */ wth->subtype_read = vms_read; wth->subtype_seek_read = vms_seek_read; + wth->tsprecision = WTAP_FILE_TSPREC_CSEC; return 1; } diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h index 91a7456a84..91d1c6f685 100644 --- a/wiretap/wtap-int.h +++ b/wiretap/wtap-int.h @@ -177,7 +177,7 @@ struct wtap { per-file encapsulation types */ int tsprecision; /* timestamp precision of the lower 32bits - * 6 is microseconds, 9 is nanoseconds */ + * e.g. WTAP_FILE_TSPREC_USEC */ }; struct wtap_dumper; diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 44da7e5c6a..6a852ef16e 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -224,7 +224,11 @@ /* last WTAP_FILE_ value + 1 */ #define WTAP_NUM_FILE_TYPES 41 -/* timestamp accuracy (currently only these values are supported) */ +/* timestamp precision (currently only these values are supported) */ +#define WTAP_FILE_TSPREC_SEC 0 +#define WTAP_FILE_TSPREC_DSEC 1 +#define WTAP_FILE_TSPREC_CSEC 2 +#define WTAP_FILE_TSPREC_MSEC 3 #define WTAP_FILE_TSPREC_USEC 6 #define WTAP_FILE_TSPREC_NSEC 9 -- cgit v1.2.1