Switch Wireshark GUI (file.c) over to using frame_data.c
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Tue, 22 Sep 2009 14:41:30 +0000 (14:41 -0000)
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Tue, 22 Sep 2009 14:41:30 +0000 (14:41 -0000)
svn path=/trunk/; revision=30067

epan/frame_data.c
file.c

index 7ccb82a4648a129ffa01bc5fbed7c85a9622fd94..768dc4776e828de6faf0e13e868c3c74ef326dc7 100644 (file)
@@ -197,7 +197,7 @@ frame_data_init(frame_data *fdata, guint32 num,
   fdata->pfd = NULL;
   fdata->num = num;
   fdata->pkt_len = phdr->len;
-  fdata->cum_bytes  = cum_bytes + phdr->len;
+  fdata->cum_bytes = cum_bytes + phdr->len;
   fdata->cap_len = phdr->caplen;
   fdata->file_off = offset;
   /* To save some memory, we coarcese it into a gint8 */
@@ -227,15 +227,13 @@ frame_data_set_before_dissect(frame_data *fdata,
   /* 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
      stamp of this packet as the time stamp of the first packet. */
-  if (nstime_is_unset(first_ts)) {
+  if (nstime_is_unset(first_ts))
     *first_ts = fdata->abs_ts;
-  }
 
   /* if this frames is marked as a reference time frame, reset
      firstsec and firstusec to this frame */
-  if(fdata->flags.ref_time){
+  if(fdata->flags.ref_time)
     *first_ts = fdata->abs_ts;
-  }
 
   /* If we don't have the time stamp of the previous displayed packet,
      it's because this is the first packet that's being displayed.  Save the time
@@ -248,9 +246,8 @@ frame_data_set_before_dissect(frame_data *fdata,
      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)) {
+  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);
diff --git a/file.c b/file.c
index 42898da0261e0e93e96cc5741b5451f147ecc487..ad8af0e8dddcfc1209e207bac9c005d589b54b4c 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1083,54 +1083,8 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
 
   cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
 
-  /* 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
-     stamp of this packet as the time stamp of the first packet. */
-  if (nstime_is_unset(&first_ts)) {
-    first_ts  = fdata->abs_ts;
-  }
-
-  /* if this frames is marked as a reference time frame, reset
-     firstsec and firstusec to this frame */
-  if(fdata->flags.ref_time){
-    first_ts = fdata->abs_ts;
-  }
-
-  /* If we don't have the time stamp of the previous displayed packet,
-     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 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);
-
-  /* If it's greater than the current elapsed time, set the elapsed time
-     to it (we check for "greater than" so as not to be confused by
-     time moving backwards). */
-  if ((gint32)cf->elapsed_time.secs < fdata->rel_ts.secs
-  || ((gint32)cf->elapsed_time.secs == fdata->rel_ts.secs && (gint32)cf->elapsed_time.nsecs < fdata->rel_ts.nsecs)) {
-    cf->elapsed_time = fdata->rel_ts;
-  }
-
-  /* Get the time elapsed between the previous displayed packet and
-     this packet. */
-  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;
+  frame_data_set_before_dissect(fdata, &cf->elapsed_time,
+                                &first_ts, &prev_dis_ts, &prev_cap_ts);
 
   /* If either
     + we have a display filter and are re-applying it;
@@ -1173,22 +1127,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
 
   if(fdata->flags.passed_dfilter || fdata->flags.ref_time)
   {
-    /* This frame either passed the display filter list or is marked as
-       a time reference frame.  All time reference frames are displayed
-       even if they dont pass the display filter */
-    if(fdata->flags.ref_time){
-      /* if this was a TIME REF frame we should reset the cul bytes field */
-      cum_bytes = fdata->pkt_len;
-      fdata->cum_bytes = cum_bytes;
-    } else {
-      /* increase cum_bytes with this packets length */
-      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;
+    frame_data_set_after_dissect(fdata, &cum_bytes, &prev_dis_ts);
 
     /* If we haven't yet seen the first frame, this is it.
 
@@ -1402,23 +1341,9 @@ read_packet(capture_file *cf, dfilter_t *dfcode,
 #else
   fdata = g_mem_chunk_alloc(cf->plist_chunk);
 #endif
-  fdata->num = cf->count;
-  fdata->next = NULL;
-  fdata->prev = NULL;
-  fdata->pfd  = NULL;
-  fdata->pkt_len  = phdr->len;
-  fdata->cap_len  = phdr->caplen;
-  fdata->file_off = offset;
-  /* To save some memory, we coarcese it into a gint8 */
-  g_assert(phdr->pkt_encap <= G_MAXINT8);
-  fdata->lnk_t = (gint8) phdr->pkt_encap;
-  fdata->abs_ts.secs = phdr->ts.secs;
-  fdata->abs_ts.nsecs = phdr->ts.nsecs;
-  fdata->flags.encoding = CHAR_ASCII;
-  fdata->flags.visited = 0;
-  fdata->flags.marked = 0;
-  fdata->flags.ref_time = 0;
-  fdata->color_filter = NULL;
+
+  frame_data_init(fdata, cf->count, phdr, offset, cum_bytes);
+
 #ifdef NEW_PACKET_LIST
   fdata->col_text_len = se_alloc0(sizeof(fdata->col_text_len) * (cf->cinfo.num_cols));
   fdata->col_text = se_alloc0(sizeof(fdata->col_text) * (cf->cinfo.num_cols));