Store pointers to previously displayed and captured packet, not nstime_t deltas.
authorJakub Zawadzki <darkjames-ws@darkjames.pl>
Sun, 23 Sep 2012 16:25:28 +0000 (16:25 -0000)
committerJakub Zawadzki <darkjames-ws@darkjames.pl>
Sun, 23 Sep 2012 16:25:28 +0000 (16:25 -0000)
This commit reduces size (from 144B to 128B on AMD64) of frame_data structure.

Part of bug 5821: Reduce per-packet memory requirements.

svn path=/trunk/; revision=45071

epan/column-utils.c
epan/dissectors/packet-frame.c
epan/frame_data.c
epan/frame_data.h
epan/wslua/wslua_pinfo.c
file.c
plugins/ethercat/packet-esl.c
rawshark.c
tshark.c
ui/gtk/time_shift_dlg.c

index a26950c4df95294c6fadc10b6b48783e3569fdc4..7737ec99dc13fc8900604768a994e62c409b57f8 100644 (file)
@@ -944,16 +944,20 @@ col_set_rel_time(const frame_data *fd, column_info *cinfo, const int col)
 static void
 col_set_delta_time(const frame_data *fd, column_info *cinfo, const int col)
 {
+  nstime_t del_cap_ts;
+
+  frame_delta_abs_time(fd, fd->prev_cap, &del_cap_ts);
+
   switch (timestamp_get_seconds_type()) {
   case TS_SECONDS_DEFAULT:
-    set_time_seconds(&fd->del_cap_ts, cinfo->col_buf[col]);
+    set_time_seconds(&del_cap_ts, cinfo->col_buf[col]);
     cinfo->col_expr.col_expr[col] = "frame.time_delta";
     g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
     break;
   case TS_SECONDS_HOUR_MIN_SEC:
-    set_time_hour_min_sec(&fd->del_cap_ts, cinfo->col_buf[col]);
+    set_time_hour_min_sec(&del_cap_ts, cinfo->col_buf[col]);
     cinfo->col_expr.col_expr[col] = "frame.time_delta";
-    set_time_seconds(&fd->del_cap_ts, cinfo->col_expr.col_expr_val[col]);
+    set_time_seconds(&del_cap_ts, cinfo->col_expr.col_expr_val[col]);
     break;
   default:
     g_assert_not_reached();
@@ -965,20 +969,25 @@ col_set_delta_time(const frame_data *fd, column_info *cinfo, const int col)
 static void
 col_set_delta_time_dis(const frame_data *fd, column_info *cinfo, const int col)
 {
+  nstime_t del_dis_ts;
+
   if (!fd->flags.has_ts) {
     cinfo->col_buf[col][0] = '\0';
     return;
   }
+
+  frame_delta_abs_time(fd, fd->prev_dis, &del_dis_ts);
+
   switch (timestamp_get_seconds_type()) {
   case TS_SECONDS_DEFAULT:
-    set_time_seconds(&fd->del_dis_ts, cinfo->col_buf[col]);
+    set_time_seconds(&del_dis_ts, cinfo->col_buf[col]);
     cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed";
     g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN);
     break;
   case TS_SECONDS_HOUR_MIN_SEC:
-    set_time_hour_min_sec(&fd->del_dis_ts, cinfo->col_buf[col]);
+    set_time_hour_min_sec(&del_dis_ts, cinfo->col_buf[col]);
     cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed";
-    set_time_seconds(&fd->del_dis_ts, cinfo->col_expr.col_expr_val[col]);
+    set_time_seconds(&del_dis_ts, cinfo->col_expr.col_expr_val[col]);
     break;
   default:
     g_assert_not_reached();
@@ -1165,12 +1174,16 @@ set_fd_time(frame_data *fd, gchar *buf)
 
     case TS_DELTA:
       if (fd->flags.has_ts) {
+        nstime_t del_cap_ts;
+
+        frame_delta_abs_time(fd, fd->prev_cap, &del_cap_ts);
+
         switch (timestamp_get_seconds_type()) {
         case TS_SECONDS_DEFAULT:
-          set_time_seconds(&fd->del_cap_ts, buf);
+          set_time_seconds(&del_cap_ts, buf);
           break;
         case TS_SECONDS_HOUR_MIN_SEC:
-          set_time_hour_min_sec(&fd->del_cap_ts, buf);
+          set_time_hour_min_sec(&del_cap_ts, buf);
           break;
         default:
           g_assert_not_reached();
@@ -1182,12 +1195,16 @@ set_fd_time(frame_data *fd, gchar *buf)
 
     case TS_DELTA_DIS:
       if (fd->flags.has_ts) {
+        nstime_t del_dis_ts;
+
+        frame_delta_abs_time(fd, fd->prev_dis, &del_dis_ts);
+
         switch (timestamp_get_seconds_type()) {
         case TS_SECONDS_DEFAULT:
-          set_time_seconds(&fd->del_dis_ts, buf);
+          set_time_seconds(&del_dis_ts, buf);
           break;
         case TS_SECONDS_HOUR_MIN_SEC:
-          set_time_hour_min_sec(&fd->del_dis_ts, buf);
+          set_time_hour_min_sec(&del_dis_ts, buf);
           break;
         default:
           g_assert_not_reached();
index e38a0a98cfd9703e57c59a6aec35f51228a93f30..c8ce23df5edd92aef64f536be0f6ffe51d7b5691 100644 (file)
@@ -258,13 +258,25 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
                                                    0, 0, &(pinfo->fd->abs_ts));
                        }
 
-                       item = proto_tree_add_time(fh_tree, hf_frame_time_delta, tvb,
-                                                  0, 0, &(pinfo->fd->del_cap_ts));
-                       PROTO_ITEM_SET_GENERATED(item);
+                       if (proto_field_is_referenced(tree, hf_frame_time_delta)) {
+                               nstime_t     del_cap_ts;
 
-                       item = proto_tree_add_time(fh_tree, hf_frame_time_delta_displayed, tvb,
-                                                  0, 0, &(pinfo->fd->del_dis_ts));
-                       PROTO_ITEM_SET_GENERATED(item);
+                               frame_delta_abs_time(pinfo->fd, pinfo->fd->prev_cap, &del_cap_ts);
+
+                               item = proto_tree_add_time(fh_tree, hf_frame_time_delta, tvb,
+                                                          0, 0, &(del_cap_ts));
+                               PROTO_ITEM_SET_GENERATED(item);
+                       }
+
+                       if (proto_field_is_referenced(tree, hf_frame_time_delta_displayed)) {
+                               nstime_t del_dis_ts;
+
+                               frame_delta_abs_time(pinfo->fd, pinfo->fd->prev_dis, &del_dis_ts);
+
+                               item = proto_tree_add_time(fh_tree, hf_frame_time_delta_displayed, tvb,
+                                                          0, 0, &(del_dis_ts));
+                               PROTO_ITEM_SET_GENERATED(item);
+                       }
 
                        item = proto_tree_add_time(fh_tree, hf_frame_time_relative, tvb,
                                                   0, 0, &(pinfo->fd->rel_ts));
index 922a655d70225833cf6593fd245547a057017b73..e911f68ed3040f673fc728b40353f3b1647989d5 100644 (file)
@@ -121,15 +121,52 @@ p_remove_proto_data(frame_data *fd, int proto)
    a lower time stamp than any frame with a non-reference time;
    if both packets' times are reference times, we compare the
    times of the packets. */
-#define COMPARE_TS(ts) \
+#define COMPARE_TS_REAL(time1, time2) \
                 ((fdata1->flags.ref_time && !fdata2->flags.ref_time) ? -1 : \
                  (!fdata1->flags.ref_time && fdata2->flags.ref_time) ? 1 : \
-                 (fdata1->ts.secs < fdata2->ts.secs) ? -1 : \
-                 (fdata1->ts.secs > fdata2->ts.secs) ? 1 : \
-                 (fdata1->ts.nsecs < fdata2->ts.nsecs) ? -1 :\
-                 (fdata1->ts.nsecs > fdata2->ts.nsecs) ? 1 : \
+                 ((time1).secs < (time2).secs) ? -1 : \
+                 ((time1).secs > (time2).secs) ? 1 : \
+                 ((time1).nsecs < (time2).nsecs) ? -1 :\
+                 ((time1).nsecs > (time2).nsecs) ? 1 : \
                  COMPARE_FRAME_NUM())
 
+#define COMPARE_TS(ts) COMPARE_TS_REAL(fdata1->ts, fdata2->ts)
+
+void
+frame_delta_abs_time(const frame_data *fdata, const frame_data *prev, nstime_t *delta)
+{
+       if (prev) {
+               nstime_delta(delta, &fdata->abs_ts, &prev->abs_ts);
+       } else {
+               /* If we don't have the time stamp of the previous packet,
+                  it's because we have no displayed/captured packets prior to this.
+                  Set the delta time to zero. */
+               nstime_set_zero(delta);
+       }
+}
+
+static gint
+frame_data_time_delta_compare(const frame_data *fdata1, const frame_data *fdata2)
+{
+       nstime_t del_cap_ts1, del_cap_ts2;
+
+       frame_delta_abs_time(fdata1, fdata1->prev_cap, &del_cap_ts1);
+       frame_delta_abs_time(fdata2, fdata2->prev_cap, &del_cap_ts2);
+
+       return COMPARE_TS_REAL(del_cap_ts1, del_cap_ts2);
+}
+
+static gint
+frame_data_time_delta_dis_compare(const frame_data *fdata1, const frame_data *fdata2)
+{
+       nstime_t del_dis_ts1, del_dis_ts2;
+
+       frame_delta_abs_time(fdata1, fdata1->prev_dis, &del_dis_ts1);
+       frame_delta_abs_time(fdata2, fdata2->prev_dis, &del_dis_ts2);
+
+       return COMPARE_TS_REAL(del_dis_ts1, del_dis_ts2);
+}
+
 gint
 frame_data_compare(const frame_data *fdata1, const frame_data *fdata2, int field)
 {
@@ -150,10 +187,10 @@ frame_data_compare(const frame_data *fdata1, const frame_data *fdata2, int field
                     return COMPARE_TS(rel_ts);
 
                 case TS_DELTA:
-                    return COMPARE_TS(del_cap_ts);
+                    return frame_data_time_delta_compare(fdata1, fdata2);
 
                 case TS_DELTA_DIS:
-                    return COMPARE_TS(del_dis_ts);
+                    return frame_data_time_delta_dis_compare(fdata1, fdata2);
 
                 case TS_NOT_SET:
                     return 0;
@@ -170,10 +207,10 @@ frame_data_compare(const frame_data *fdata1, const frame_data *fdata2, int field
             return COMPARE_TS(rel_ts);
 
         case COL_DELTA_TIME:
-            return COMPARE_TS(del_cap_ts);
+            return frame_data_time_delta_compare(fdata1, fdata2);
 
         case COL_DELTA_TIME_DIS:
-            return COMPARE_TS(del_dis_ts);
+            return frame_data_time_delta_dis_compare(fdata1, fdata2);
 
         case COL_PACKET_LENGTH:
             return COMPARE_NUM(pkt_len);
@@ -217,10 +254,8 @@ frame_data_init(frame_data *fdata, guint32 num,
   fdata->shift_offset.nsecs = 0;
   fdata->rel_ts.secs = 0;
   fdata->rel_ts.nsecs = 0;
-  fdata->del_dis_ts.secs = 0;
-  fdata->del_dis_ts.nsecs = 0;
-  fdata->del_cap_ts.secs = 0;
-  fdata->del_cap_ts.nsecs = 0;
+  fdata->prev_dis = NULL;
+  fdata->prev_cap = NULL;
   fdata->opt_comment = phdr->opt_comment;
 }
 
@@ -228,8 +263,8 @@ void
 frame_data_set_before_dissect(frame_data *fdata,
                 nstime_t *elapsed_time,
                 nstime_t *first_ts,
-                nstime_t *prev_dis_ts,
-                nstime_t *prev_cap_ts)
+                const frame_data *prev_dis,
+                const frame_data *prev_cap)
 {
   /* If we don't have the time stamp of the first packet in the
      capture, it's because this is the first packet.  Save the time
@@ -242,13 +277,6 @@ frame_data_set_before_dissect(frame_data *fdata,
   if(fdata->flags.ref_time)
     *first_ts = fdata->abs_ts;
 
-  /* If we don't have the time stamp of the previous captured packet,
-     it's because this is the first packet.  Save the time
-     stamp of this packet as the time stamp of the previous captured
-     packet. */
-  if (nstime_is_unset(prev_cap_ts))
-    *prev_cap_ts = fdata->abs_ts;
-
   /* Get the time elapsed between the first packet and this packet. */
   nstime_delta(&fdata->rel_ts, &fdata->abs_ts, first_ts);
 
@@ -260,26 +288,13 @@ frame_data_set_before_dissect(frame_data *fdata,
     *elapsed_time = fdata->rel_ts;
   }
 
-  /* Get the time elapsed between the previous displayed packet and
-     this packet. */
-  if (nstime_is_unset(prev_dis_ts))
-    /* If we don't have the time stamp of the previous displayed packet,
-       it's because we have no displayed packets prior to this.
-       Set the delta time to zero. */
-    nstime_set_zero(&fdata->del_dis_ts);
-  else
-    nstime_delta(&fdata->del_dis_ts, &fdata->abs_ts, prev_dis_ts);
-
-  /* Get the time elapsed between the previous captured packet and
-     this packet. */
-  nstime_delta(&fdata->del_cap_ts, &fdata->abs_ts, prev_cap_ts);
-  *prev_cap_ts = fdata->abs_ts;
+  fdata->prev_dis = prev_dis;
+  fdata->prev_cap = prev_cap;
 }
 
 void
 frame_data_set_after_dissect(frame_data *fdata,
-                guint32 *cum_bytes,
-                nstime_t *prev_dis_ts)
+                guint32 *cum_bytes)
 {
   /* This frame either passed the display filter list or is marked as
      a time reference frame.  All time reference frames are displayed
@@ -293,10 +308,6 @@ frame_data_set_after_dissect(frame_data *fdata,
     *cum_bytes += fdata->pkt_len;
     fdata->cum_bytes = *cum_bytes;
   }
-
-  /* Set the time of the previous displayed frame to the time of this
-     frame. */
-  *prev_dis_ts = fdata->abs_ts;
 }
 
 void
index 290693b4c9c0c0fb681fec2c8a2b1febfae6bb25..87994cabf184b1e6976a710fa429633c39e4c0c5 100644 (file)
@@ -66,8 +66,8 @@ typedef struct _frame_data {
   nstime_t     abs_ts;       /**< Absolute timestamp */
   nstime_t     shift_offset; /**< How much the abs_tm of the frame is shifted */
   nstime_t     rel_ts;       /**< Relative timestamp (yes, it can be negative) */
-  nstime_t     del_dis_ts;   /**< Delta timestamp to previous displayed frame (yes, it can be negative) */
-  nstime_t     del_cap_ts;   /**< Delta timestamp to previous captured frame (yes, it can be negative) */
+  const struct _frame_data *prev_dis;   /**< Previous displayed frame */
+  const struct _frame_data *prev_cap;   /**< Previous captured frame */
   gchar        *opt_comment; /**< NULL if not available */
 } frame_data;
 
@@ -103,18 +103,20 @@ extern void frame_data_cleanup(frame_data *fdata);
 extern void frame_data_init(frame_data *fdata, guint32 num,
                 const struct wtap_pkthdr *phdr, gint64 offset,
                 guint32 cum_bytes);
+
+extern void frame_delta_abs_time(const frame_data *fdata, 
+                const frame_data *prev, nstime_t *delta);
 /**
  * Sets the frame data struct values before dissection.
  */
 extern void frame_data_set_before_dissect(frame_data *fdata,
                 nstime_t *elapsed_time,
                 nstime_t *first_ts,
-                nstime_t *prev_dis_ts,
-                nstime_t *prev_cap_ts);
+                const frame_data *prev_dis,
+                const frame_data *prev_cap);
 
 extern void frame_data_set_after_dissect(frame_data *fdata,
-                guint32 *cum_bytes,
-                nstime_t *prev_dis_ts);
+                guint32 *cum_bytes);
 
 #endif  /* __FRAME_DATA__ */
 
index 9d9c2ae28579ba12b5a9cb86e048363085b1742d..5fecb5ea85961c7177dc7661b821108e83008cc1 100644 (file)
@@ -984,6 +984,15 @@ lua_nstime_to_sec(const nstime_t *nstime)
     return (((double)nstime->secs) + (((double)nstime->nsecs) / 1000000000.0));
 }
 
+static double
+lua_delta_nstime_to_sec(const frame_data *fd, const frame_data *prev)
+{
+       nstime_t del;
+
+       frame_delta_abs_time(fd, prev, &del);
+       return lua_nstime_to_sec(&del);
+}
+
 PINFO_GET_BOOLEAN(Pinfo_fragmented,pinfo->ws_pinfo->fragmented)
 PINFO_GET_BOOLEAN(Pinfo_in_error_pkt,pinfo->ws_pinfo->flags.in_error_pkt)
 PINFO_GET_BOOLEAN(Pinfo_visited,pinfo->ws_pinfo->fd->flags.visited)
@@ -993,8 +1002,8 @@ PINFO_GET_NUMBER(Pinfo_len,pinfo->ws_pinfo->fd->pkt_len)
 PINFO_GET_NUMBER(Pinfo_caplen,pinfo->ws_pinfo->fd->cap_len)
 PINFO_GET_NUMBER(Pinfo_abs_ts,lua_nstime_to_sec(&pinfo->ws_pinfo->fd->abs_ts))
 PINFO_GET_NUMBER(Pinfo_rel_ts,lua_nstime_to_sec(&pinfo->ws_pinfo->fd->rel_ts))
-PINFO_GET_NUMBER(Pinfo_delta_ts,lua_nstime_to_sec(&pinfo->ws_pinfo->fd->del_cap_ts))
-PINFO_GET_NUMBER(Pinfo_delta_dis_ts,lua_nstime_to_sec(&pinfo->ws_pinfo->fd->del_dis_ts))
+PINFO_GET_NUMBER(Pinfo_delta_ts,lua_delta_nstime_to_sec(pinfo->ws_pinfo->fd, pinfo->ws_pinfo->fd->prev_cap))
+PINFO_GET_NUMBER(Pinfo_delta_dis_ts,lua_delta_nstime_to_sec(pinfo->ws_pinfo->fd, pinfo->ws_pinfo->fd->prev_dis))
 PINFO_GET_NUMBER(Pinfo_ipproto,pinfo->ws_pinfo->ipproto)
 PINFO_GET_NUMBER(Pinfo_circuit_id,pinfo->ws_pinfo->circuit_id)
 PINFO_GET_NUMBER(Pinfo_desegment_len,pinfo->ws_pinfo->desegment_len)
diff --git a/file.c b/file.c
index c04b336b9fd8db6ec4ee7ae050119defaa435bbc..ced94b7d0b492c59f7cc4a265abe37b8aa75d4b7 100644 (file)
--- a/file.c
+++ b/file.c
@@ -81,8 +81,8 @@ gboolean auto_scroll_live;
 
 static guint32 cum_bytes;
 static nstime_t first_ts;
-static nstime_t prev_dis_ts;
-static nstime_t prev_cap_ts;
+static frame_data *prev_dis;
+static frame_data *prev_cap;
 
 static gulong computed_elapsed;
 
@@ -332,8 +332,8 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
 
   nstime_set_zero(&cf->elapsed_time);
   nstime_set_unset(&first_ts);
-  nstime_set_unset(&prev_dis_ts);
-  nstime_set_unset(&prev_cap_ts);
+  prev_dis = NULL;
+  prev_cap = NULL;
   cum_bytes = 0;
 
   /* Adjust timestamp precision if auto is selected, col width will be adjusted */
@@ -1099,7 +1099,8 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
   cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
 
   frame_data_set_before_dissect(fdata, &cf->elapsed_time,
-                                &first_ts, &prev_dis_ts, &prev_cap_ts);
+                                &first_ts, prev_dis, prev_cap);
+  prev_cap = fdata;
 
   /* If either
     + we have a display filter and are re-applying it;
@@ -1153,7 +1154,8 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
 
   if (fdata->flags.passed_dfilter || fdata->flags.ref_time)
   {
-    frame_data_set_after_dissect(fdata, &cum_bytes, &prev_dis_ts);
+    frame_data_set_after_dissect(fdata, &cum_bytes);
+    prev_dis = fdata;
 
     /* If we haven't yet seen the first frame, this is it.
 
@@ -1836,8 +1838,8 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item,
      to check whether it should be displayed and, if so, add it to
      the display list. */
   nstime_set_unset(&first_ts);
-  nstime_set_unset(&prev_dis_ts);
-  nstime_set_unset(&prev_cap_ts);
+  prev_dis = NULL;
+  prev_cap = NULL;
   cum_bytes = 0;
 
   /* Update the progress bar when it gets to this value. */
@@ -2077,7 +2079,7 @@ ref_time_packets(capture_file *cf)
   frame_data *fdata;
 
   nstime_set_unset(&first_ts);
-  nstime_set_unset(&prev_dis_ts);
+  prev_dis = NULL;
   cum_bytes = 0;
 
   for (framenum = 1; framenum <= cf->count; framenum++) {
@@ -2106,8 +2108,8 @@ ref_time_packets(capture_file *cf)
      it's because this is the first displayed packet.  Save the time
      stamp of this packet as the time stamp of the previous displayed
      packet. */
-    if (nstime_is_unset(&prev_dis_ts)) {
-        prev_dis_ts = fdata->abs_ts;
+    if (prev_dis == NULL) {
+        prev_dis = fdata;
     }
 
     /* Get the time elapsed between the first packet and this packet. */
@@ -2124,8 +2126,8 @@ ref_time_packets(capture_file *cf)
     /* If this frame is displayed, get the time elapsed between the
      previous displayed packet and this packet. */
     if ( fdata->flags.passed_dfilter ) {
-        nstime_delta(&fdata->del_dis_ts, &fdata->abs_ts, &prev_dis_ts);
-        prev_dis_ts = fdata->abs_ts;
+        fdata->prev_dis = prev_dis;
+        prev_dis = fdata;
     }
 
     /*
index b3e1f9fc0ba5104e4a7c3a5d4cf00b46661fb6ce..34e6dfdfd8a01bae0349bbd92a4a788a835d67ae 100644 (file)
@@ -252,8 +252,6 @@ void modify_times(tvbuff_t *tvb, gint offset, packet_info *pinfo)
 
         pinfo->fd->abs_ts = ts;
         nstime_add(&pinfo->fd->rel_ts, &ts_delta);
-        nstime_add(&pinfo->fd->del_dis_ts, &ts_delta);
-        nstime_add(&pinfo->fd->del_cap_ts, &ts_delta);
     }
 }
 
index 7df9475fb2a0982507648b15c582da2e29c256ab..d6f319ab76519b1823b4550868cdd09e1eb8ac5b 100644 (file)
@@ -120,8 +120,10 @@ static const gchar decode_as_arg_template[] = "<layer_type>==<selector>,<decode_
 
 static guint32 cum_bytes;
 static nstime_t first_ts;
-static nstime_t prev_dis_ts;
-static nstime_t prev_cap_ts;
+static frame_data *prev_dis;
+static frame_data prev_dis_frame;
+static frame_data *prev_cap;
+static frame_data prev_cap_frame;
 
 /*
  * The way the packet decode is to be written.
@@ -1063,7 +1065,7 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
     printf("%lu", (unsigned long int) cf->count);
 
     frame_data_set_before_dissect(&fdata, &cf->elapsed_time,
-                                  &first_ts, &prev_dis_ts, &prev_cap_ts);
+                                  &first_ts, prev_dis, prev_cap);
 
     /* We only need the columns if we're printing packet info but we're
      *not* verbose; in verbose mode, we print the protocol tree, not
@@ -1072,7 +1074,12 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
 
     tap_push_tapped_queue(&edt);
 
-    frame_data_set_after_dissect(&fdata, &cum_bytes, &prev_dis_ts);
+    frame_data_set_after_dissect(&fdata, &cum_bytes);
+    prev_dis_frame = fdata;
+    prev_dis = &prev_dis_frame;
+
+    prev_cap_frame = fdata;
+    prev_cap = &prev_cap_frame;
 
     for(i = 0; i < n_rfilters; i++) {
         /* Run the read filter if we have one. */
@@ -1587,8 +1594,8 @@ raw_cf_open(capture_file *cf, const char *fname)
     cf->snap = WTAP_MAX_PACKET_SIZE;
     nstime_set_zero(&cf->elapsed_time);
     nstime_set_unset(&first_ts);
-    nstime_set_unset(&prev_dis_ts);
-    nstime_set_unset(&prev_cap_ts);
+    prev_dis = NULL;
+    prev_cap = NULL;
 
     return CF_OK;
 }
index 9e1cf2c22ab78a57919159a6b8a555dc630c8bb4..118c75e2058d672b2a5ad40a3668056403d9c94a 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -103,8 +103,10 @@ static const gchar decode_as_arg_template[] = "<layer_type>==<selector>,<decode_
 
 static guint32 cum_bytes;
 static nstime_t first_ts;
-static nstime_t prev_dis_ts;
-static nstime_t prev_cap_ts;
+static frame_data *prev_dis;
+static frame_data prev_dis_frame;
+static frame_data *prev_cap;
+static frame_data prev_cap_frame;
 
 static gboolean print_packet_info;      /* TRUE if we're to print packet information */
 static const char* prev_display_dissector_name = NULL;
@@ -2561,7 +2563,7 @@ process_packet_first_pass(capture_file *cf,
       epan_dissect_prime_dfilter(&edt, cf->rfcode);
 
     frame_data_set_before_dissect(&fdlocal, &cf->elapsed_time,
-                                  &first_ts, &prev_dis_ts, &prev_cap_ts);
+                                  &first_ts, prev_dis, prev_cap);
 
     epan_dissect_run(&edt, pseudo_header, pd, &fdlocal, NULL);
 
@@ -2571,11 +2573,16 @@ process_packet_first_pass(capture_file *cf,
   }
 
   if (passed) {
-    frame_data_set_after_dissect(&fdlocal, &cum_bytes, &prev_dis_ts);
+    frame_data_set_after_dissect(&fdlocal, &cum_bytes);
+    prev_dis_frame = fdlocal;
+    prev_dis = &prev_dis_frame;
     frame_data_sequence_add(cf->frames, &fdlocal);
     cf->count++;
   }
 
+  prev_cap_frame = fdlocal;
+  prev_cap = &prev_cap_frame;
+
   if (do_dissection)
     epan_dissect_cleanup(&edt);
 
@@ -3096,7 +3103,7 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
       cinfo = NULL;
 
     frame_data_set_before_dissect(&fdata, &cf->elapsed_time,
-                                  &first_ts, &prev_dis_ts, &prev_cap_ts);
+                                  &first_ts, prev_dis, prev_cap);
 
     epan_dissect_run(&edt, pseudo_header, pd, &fdata, cinfo);
 
@@ -3108,7 +3115,9 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
   }
 
   if (passed) {
-    frame_data_set_after_dissect(&fdata, &cum_bytes, &prev_dis_ts);
+    frame_data_set_after_dissect(&fdata, &cum_bytes);
+    prev_dis_frame = fdata;
+    prev_dis = &prev_dis_frame;
 
     /* Process this packet. */
     if (print_packet_info) {
@@ -3149,6 +3158,9 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
     }
   }
 
+  prev_cap_frame = fdata;
+  prev_cap = &prev_cap_frame;
+
   if (do_dissection) {
     epan_dissect_cleanup(&edt);
     frame_data_cleanup(&fdata);
@@ -3577,8 +3589,8 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
     cf->has_snap = TRUE;
   nstime_set_zero(&cf->elapsed_time);
   nstime_set_unset(&first_ts);
-  nstime_set_unset(&prev_dis_ts);
-  nstime_set_unset(&prev_cap_ts);
+  prev_dis = NULL;
+  prev_cap = NULL;
 
   cf->state = FILE_READ_IN_PROGRESS;
 
index 37ad3eeb380683c32727ddc93baa76630187f872..57a31c8155f8601fba2aecf0d75769bea85f15dc 100644 (file)
@@ -938,15 +938,11 @@ static void
 modify_time_perform(frame_data *fd, int neg, nstime_t *offset, int settozero)
 {
   static frame_data *first_packet = NULL;
-  static frame_data *lastdisplayed_packet = NULL;
-  static frame_data *prevcaptured_packet = NULL;
   static nstime_t nulltime;
 
   /* Only for initializing */
   if (offset == NULL) {
     first_packet = fd;
-    lastdisplayed_packet = NULL;
-    prevcaptured_packet = NULL;
     nulltime.secs = nulltime.nsecs = 0;
     return;
   }
@@ -974,28 +970,10 @@ modify_time_perform(frame_data *fd, int neg, nstime_t *offset, int settozero)
 
   /*
    * rel_ts     - Relative timestamp to first packet
-   * del_dis_ts - Delta timestamp to previous displayed frame
-   * del_cap_ts - Delta timestamp to previous captured frame
    */
   if (first_packet != NULL) {
     nstime_copy(&(fd->rel_ts), &(fd->abs_ts));
     nstime_subtract(&(fd->rel_ts), &(first_packet->abs_ts));
   } else
     nstime_copy(&(fd->rel_ts), &nulltime);
-
-  if (prevcaptured_packet != NULL) {
-    nstime_copy(&(fd->del_cap_ts), &(fd->abs_ts));
-    nstime_subtract(&(fd->del_cap_ts), &(prevcaptured_packet->abs_ts));
-  } else
-    nstime_copy(&(fd->del_cap_ts), &nulltime);
-
-  if (lastdisplayed_packet != NULL) {
-    nstime_copy(&(fd->del_dis_ts), &(fd->abs_ts));
-    nstime_subtract(&(fd->del_dis_ts), &(lastdisplayed_packet->abs_ts));
-  } else
-    nstime_copy(&(fd->del_dis_ts), &nulltime);
-
-  prevcaptured_packet = fd;
-  if (fd->flags.passed_dfilter)
-    lastdisplayed_packet = fd;
 }