timestamp display precision:
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 25 Aug 2005 21:29:54 +0000 (21:29 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 25 Aug 2005 21:29:54 +0000 (21:29 +0000)
- automatic adjustment depending on file format
- manual adjustment through menu items

save the setting in the recent file

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@15534 f5534014-38df-0310-8fa8-9805f1628bb7

44 files changed:
cfile.h
dftest.c
epan/column-utils.c
epan/column.c
epan/libethereal.def
epan/timestamp.c
epan/timestamp.h
epan/to_str.c
epan/to_str.h
file.c
gtk/main.c
gtk/menu.c
gtk/packet_list.c
gtk/recent.c
gtk/recent.h
tethereal.c
wiretap/5views.c
wiretap/airopeek9.c
wiretap/ascend.c
wiretap/cosine.c
wiretap/csids.c
wiretap/dbs-etherwatch.c
wiretap/erf.c
wiretap/etherpeek.c
wiretap/eyesdn.c
wiretap/hcidump.c
wiretap/i4btrace.c
wiretap/iptrace.c
wiretap/k12.c
wiretap/lanalyzer.c
wiretap/libpcap.c
wiretap/netmon.c
wiretap/nettl.c
wiretap/network_instruments.c
wiretap/netxray.c
wiretap/ngsniffer.c
wiretap/pppdump.c
wiretap/radcom.c
wiretap/snoop.c
wiretap/toshiba.c
wiretap/visual.c
wiretap/vms.c
wiretap/wtap-int.h
wiretap/wtap.h

diff --git a/cfile.h b/cfile.h
index 89cd3d61b2c8ca3de6a84d73ba5663a1eec41e93..e2642010c8be0b04574c0bfcfcc07af6ecba94eb 100644 (file)
--- 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 *);
index b567685ce60e3b52355642d077444f19ff67693f..75fa9aa82e98b6f0f8ae0ca5c60f630455092b0a 100644 (file)
--- 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
index 7120ce474aff02060a37725c92499980596837cb..d77b3c650ac676d19dc5036850e45aff62716546 100644 (file)
@@ -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;
index 83d96d0004ce936538ee23e34318a406f374f99e..90dae767092aad59c589e5d16b1f9a388456d6ca 100644 (file)
@@ -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:
index ea14571675544d454de03c947556a80cd1cf1300..7e8db18328511400024891f5a9c2b173e9f61160 100644 (file)
@@ -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
index d948fda3d569077b7bfb9cd7120bde63a292b1bf..b7cef811f623e37a2125b35401ef5d3a376eaf8f 100644 (file)
  * 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;
+}
+
index 706fba4ce9c366e4bffbeee1e0c5233ba9e02e80..f9f953219bfcd5036c5c7be7f23e7e6892512c90 100644 (file)
@@ -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 */
index 3e00274fe0ce807760c178b649135a7f966f470f..0431f66233387e19725c2d7356558b6c788eb7d4 100644 (file)
@@ -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;
index e34a8242b5ec94db6e589869143961468a74b88a..55449f490d58c9a1bf5669f8f7375e4ef34eaf92 100644 (file)
@@ -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 14a79a1ba7ab4f4db9efdaabdf1385a9fc31ac62..7b328b4b57db4def419da37d204445250292448b 100644 (file)
--- a/file.c
+++ b/file.c
@@ -76,6 +76,8 @@
 #include "stat_menu.h"
 #include "tap_dfilter_dlg.h"
 #include <epan/dissectors/packet-data.h>
+#include <epan/timestamp.h>
+
 
 /* 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?
 
index dd8642216b5af5abfcd4691e3ef79dc3b0a16666..23201d2d8bce109ff8eb70f38ea90088e7dc9948 100644 (file)
@@ -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);
index 7cdec439fa731b538d7173b105dcd3a15365fb2f..20a41485690ca41a953144e4d56873d45e0c40b9 100644 (file)
@@ -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, "<CheckItem>", NULL),
     ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
     ITEM_FACTORY_ENTRY("/View/_Time Display Format", NULL, NULL, 0, "<Branch>", 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, "<RadioItem>", 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/<separator>", NULL, NULL, 0, "<Separator>", NULL),
+    ITEM_FACTORY_ENTRY("/View/Time Display Format/Automatic (File Format Precision)", NULL, timestamp_auto_cb, 
+                        0, "<RadioItem>", 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, "<Branch>", NULL),
     ITEM_FACTORY_ENTRY("/View/Name Resolution/_Resolve Name", NULL, resolve_name_cb, 0, NULL, NULL),
     ITEM_FACTORY_ENTRY("/View/Name Resolution/<separator>", NULL, NULL, 0, "<Separator>", 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);
 }
 
index 880860bb6045bcff3d41fb11c1bec3886ff8dc57..4ed93e3f936aab9a5c47beb02f9879afaa4f03cc 100644 (file)
@@ -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:
index c5a955dc552d0c2c6b8ca37187ccca5f15508dc6..85e505cdb34113b54893259f32ece3516ec367c3 100644 (file)
@@ -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;
index 43d9bf636ed1b5ae669bd420cc711d38ef1405e2..ab53fa642c30fd4559ce63e68d66058dbfe39ee8 100644 (file)
@@ -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;
index 65f933cd8129d56e5de7e461660c0504a6bd5b79..2f3d7db5dc93a25ed0384cb0ca826c4c73091cd8 100644 (file)
@@ -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);
index 38fc251ef9d9a3a60c2fa2b95f3f4a083d7e6604..e44969fe4fccbe7e6613e1f1d71c1eaf44162743 100644 (file)
@@ -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;
 }
index 2eee7f5f76b5736249ce7ae975ac1f6fe6de8758..30aa0980081657597e2b5e0cab3cdcbcb6a29cef 100644 (file)
@@ -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) {
index 0145aec7968343eb6a9f9aee2f38655eae69d70e..2ff4794a01bb970eae06615a1405c03e6e68e487 100644 (file)
@@ -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();
 
index e185ea9f7f4d185dd4ce33898c858dca176ca4df..841d80bac9e9d0a7547b32adb0b9a1ea3e17b1ba 100644 (file)
@@ -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;
 }
index ff7c55c687b7630a00822827982cbe6b97ea5f11..28ea047c71eb0bcc33f34a4f70cfdbb78badb35b 100644 (file)
@@ -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;
 }
index 7331b694c1351751ef488471a31f6dfa6ed73de3..39f41494e29d9839b0352fe34edcc4007773789b 100644 (file)
@@ -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;
 }
index 0937e9004b4f474c255d541d737e2064701608c4..a71424eed69663477d98f95bc17a60f38bbffc47 100644 (file)
@@ -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;
 }
index afa8044f900d525b64dc1dc2c5d12de5fabc4781..6aea88515b4c0b61799f0a51549814f3ac1fc598 100644 (file)
@@ -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;
 }
index 277a4684ecc85ac10775f12bafb8b4495e11153e..6c47523d2c6c23a356968630b3a7f90f63f11fd0 100644 (file)
@@ -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;
 }
index ccca83ce8f42aad1dca3682e0b31064f2677f85a..7aeadeab70997284a8a0f3f2e9018815bf14f05b 100644 (file)
@@ -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;
 }
index 11dc2cc2fd415fe9e3912376dd1ee6de092ac592..9b9d2d6a7ca9d5e92bc8ef716b2f90ff798286a6 100644 (file)
@@ -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;
 }
index 9281b6b80ceb7063ab56f8491bb7473932a7dbec..a78323d96c7c3d42fbc549bc24aeea5cfde49910 100644 (file)
@@ -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;
index ecd9b751855ff560e1a691918f19f17edf45da28..3df194516e33e529d172a066805940f7a37b8ff5 100644 (file)
@@ -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
index a6553ecc602cfc64e024693b33a60394ac4fe42d..006dc4a538928472fe0fe8c6c1c714680339a5a3 100644 (file)
@@ -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) {
index 86bf798a6f023b0a628f39dfbfd0c99fa640826e..b1bccc7541dda8ea0b7fa84124e4039e5e541f47 100644 (file)
@@ -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:
index c3c552d2d0346f7a169c20ec0c42920adb181f38..19eb125bcdc8b7a032f1ac2dc055faf61c26b1bc 100644 (file)
@@ -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;
 }
index 75ffb9e1ca4aed95a98ffe1ec92123e6a4695708..e24e30ec7fc3dd39e5fba377963d09d1e536bd3e 100644 (file)
@@ -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;
 }
index 0e226e6e481f5f103867691742a7b46441d3908d..7d723c4804c1f6454b3af947a7e095e998ca3b1c 100644 (file)
@@ -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,
index f5164a06157391b6526f3668a6a7c2f40867b4ab..f477ef70fc0d81045522af8a1056eb47708bb069 100644 (file)
@@ -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;
index 04bcb78e89994383847a9c3354b9629f2303396d..d219c29c30fbc153bdb6690071061bc58eefbfbb 100644 (file)
@@ -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;
 }
 
index 8913cd8c4a010278342cb87d742b581df9e7b63d..9513d6ab8fdfbb45286a8e93a9041915be4f06a6 100644 (file)
@@ -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));
 
index 9c3934504a4d20214beaf79ff35281029e50e06b..c32bfbaa3bd9c13c8aaf82c4459b31b925835ac3 100644 (file)
@@ -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;
index 5dc0c2a27d8580204fe1206a88daed477202124d..c0aa19e0ee3d4f19f5fabd8cb0e9521aeb171467 100644 (file)
@@ -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;
 }
 
index a9cc44d50328fc5f27a12753359929f23acee36d..824b0a15910a0219f1f6a4a114ba5cac431b1780 100644 (file)
@@ -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;
 }
index b270d508facb397b01f42ccc57ed7b9164d22d73..34f4ab52b60f08827886954bd093754d76a329d6 100644 (file)
@@ -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));
index 02d0e6cc8a59057771c27fe1c71f0f12baa105ba..81b00986dc50ffe2ced1198f85bea80d6246b289 100644 (file)
@@ -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;
 }
index 91a7456a84524c907fbf2c2ea7302c64103d6433..91d1c6f68501eebc0c27fcf4a79c6d66cdcf179c 100644 (file)
@@ -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;
index 44da7e5c6a3fbf7a20213b0ad510a78dd89845ff..6a852ef16e66c1a7473e085c64ca48e92f333544 100644 (file)
 /* 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