*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
#include <wiretap/wtap.h>
#include <epan/frame_data.h>
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)
{
switch (timestamp_get_type()) {
case TS_ABSOLUTE:
case TS_ABSOLUTE_WITH_DATE:
+ case TS_UTC:
+ case TS_UTC_WITH_DATE:
case TS_EPOCH:
return COMPARE_TS(abs_ts);
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;
case COL_ABS_TIME:
case COL_ABS_DATE_TIME:
+ case COL_UTC_TIME:
+ case COL_UTC_DATE_TIME:
return COMPARE_TS(abs_ts);
case COL_REL_TIME:
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);
{
fdata->pfd = NULL;
fdata->num = num;
+ fdata->interface_id = phdr->interface_id;
fdata->pkt_len = phdr->len;
fdata->cum_bytes = cum_bytes + phdr->len;
fdata->cap_len = phdr->caplen;
fdata->file_off = offset;
+ fdata->subnum = 0;
/* To save some memory, we coerce it into a gint16 */
g_assert(phdr->pkt_encap <= G_MAXINT16);
fdata->lnk_t = (gint16) phdr->pkt_encap;
- fdata->abs_ts.secs = phdr->ts.secs;
- fdata->abs_ts.nsecs = phdr->ts.nsecs;
fdata->flags.passed_dfilter = 0;
+ fdata->flags.dependent_of_displayed = 0;
fdata->flags.encoding = PACKET_CHAR_ENC_CHAR_ASCII;
fdata->flags.visited = 0;
fdata->flags.marked = 0;
fdata->flags.ref_time = 0;
fdata->flags.ignored = 0;
+ fdata->flags.has_ts = (phdr->presence_flags & WTAP_HAS_TS) ? 1 : 0;
+ fdata->flags.has_if_id = (phdr->presence_flags & WTAP_HAS_INTERFACE_ID) ? 1 : 0;
fdata->color_filter = NULL;
+ fdata->abs_ts.secs = phdr->ts.secs;
+ fdata->abs_ts.nsecs = phdr->ts.nsecs;
+ fdata->shift_offset.secs = 0;
+ fdata->shift_offset.nsecs = 0;
+ fdata->rel_ts.secs = 0;
+ fdata->rel_ts.nsecs = 0;
+ fdata->prev_dis = NULL;
+ fdata->prev_cap = NULL;
+ fdata->opt_comment = phdr->opt_comment;
}
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
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);
*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
*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
frame_data_cleanup(frame_data *fdata)
{
- if (fdata->pfd)
+ if (fdata->pfd) {
g_slist_free(fdata->pfd);
+ fdata->pfd = NULL;
+ }
- fdata->pfd = NULL;
+ /* XXX, frame_data_cleanup() is called when redissecting (rescan_packets()),
+ * which might be triggered by lot of things, like: preferences change, setting manual address resolve, etc.. (grep by redissect_packets)
+ * fdata->opt_comment can be set by user, which we must not discard when redissecting.
+ */
+#if 0
+ if (fdata->opt_comment) {
+ g_free(fdata->opt_comment);
+ fdata->opt_comment = NULL;
+ }
+#endif
}
-