diff options
author | John Thacker <johnthacker@gmail.com> | 2023-10-14 09:52:49 -0400 |
---|---|---|
committer | John Thacker <johnthacker@gmail.com> | 2023-10-15 13:47:14 +0000 |
commit | f1f6c1369d1227ec42ebc1fe7563a15eee245eee (patch) | |
tree | 26f48aabe03ed08fcd38d5c1b1bcb377e9adeba8 /rawshark.c | |
parent | 8da773da7a447fe918a4156e0a3dece4dd9d3d4e (diff) |
Don't use frames without timestamp for delta time calculations
pcapng allows simple packet blocks (which don't have timestamps),
enhanced packet blocks (which do) and custom blocks (which might
or might not have timestamps, and even if they do have timestamps,
libwiretap might not know about them), and so some records may have
timestamps while others do not.
Do not use frames without timestamps in delta time calculations.
Don't use them as reference frames for time calculations, or for
the previously displayed frame for time calculations, where the
previously displayed frame that actually has a timestamp is used.
Have the various _get_frame_ts functions return null instead of
their ts value (that is currently handled; if records without
timestamps set their abs_ts to the special "unset" value of nstime_t
that could work too, except that isn't currently handled.)
Still allow the GUI to set frames without timestamps as "Time
References", because that does still affect the "Cumulative Bytes"
column, so it's not entirely pointless; unset the reference time
so that the timestamp from the next frame that does have a timestamp
will be used as reference time.
The "previous captured frame" will show a 0 time delta when
the previous frame doeesn't have a timestamp. Perhaps a user
would also want "previous captured frame with a timestamp,"
but we'd have to store that in frame data (adding memory to
that struct.)
Fix #19397
Diffstat (limited to 'rawshark.c')
-rw-r--r-- | rawshark.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/rawshark.c b/rawshark.c index 6051baed6c..9bdb5aa2bd 100644 --- a/rawshark.c +++ b/rawshark.c @@ -1428,16 +1428,16 @@ show_print_file_io_error(int err) static const nstime_t * raw_get_frame_ts(struct packet_provider_data *prov, guint32 frame_num) { - if (prov->ref && prov->ref->num == frame_num) - return &prov->ref->abs_ts; - - if (prov->prev_dis && prov->prev_dis->num == frame_num) - return &prov->prev_dis->abs_ts; - - if (prov->prev_cap && prov->prev_cap->num == frame_num) - return &prov->prev_cap->abs_ts; + const frame_data *ts_fd = NULL; + if (prov->ref && prov->ref->num == frame_num) { + ts_fd = prov->ref; + } else if (prov->prev_dis && prov->prev_dis->num == frame_num) { + ts_fd = prov->prev_dis; + } else if (prov->prev_cap && prov->prev_cap->num == frame_num) { + ts_fd = prov->prev_cap; + } - return NULL; + return (ts_fd && ts_fd->has_ts) ? &ts_fd->abs_ts : NULL; } static epan_t * |